boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C#, recruiter发过来的面试题 (转载)
相关主题
Help: a Perl script question, Thanks (转载)
请各位帮我看看这个最简单的Stored Procedure
Question about OleDb...
Scripting language的几个问题
why vb code faster than csharp???
ip问题
文件压缩问题求教
mysql index优化求助
一个sql问题:怎样实现 (((a1*10)+a2)*10+a3)*10 ...
有谁知道这段tcp通讯到底在干什么事吗? (转载)
相关话题的讨论汇总
话题: null话题: lant话题: trades话题: history话题: tswift
进入Programming版参与讨论
1 (共1页)
p****1
发帖数: 275
1
【 以下文字转载自 JobHunting 讨论区 】
发信人: peace1 (peace1), 信区: JobHunting
标 题: C#, recruiter发过来的面试题
发信站: BBS 未名空间站 (Thu Sep 8 22:17:38 2016, 美东)
有兴趣做不? 我琢磨着, 出题的人是在寻找最优解 :)
Given the table [tSWIFT_History_Trades] , the C# structure TradeNAK and the
C# method UpdateTradeACKNAKDB as defined below:
CREATE TABLE [tSWIFT_History_Trades](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[BatchId] [varchar](25) NOT NULL,
[TradeId] [varchar](25) NOT NULL,
[Account] [varchar](25) NULL,
[TranType] [varchar](50) NULL,
[TradeDate] [int] NULL,
[SettleDate] [int] NULL,
[Exch] [varchar](50) NULL,
[DateSent] [datetime] NOT NULL
CONSTRAINT [DF_tSWIFT_History_Trades_Sent_DateSent] DEFAULT (getdate()),
[Status] [varchar](20) NOT NULL,
[AckNak] [varchar](7) NULL
CONSTRAINT [DF_tSWIFT_History_Trades_AckNak] DEFAULT ('Pending'),
[MachineIdReceived] [varchar](50) NULL,
[FileNameReceived] [varchar](100) NULL,
[DateReceived] [datetime] NULL,
[DirectoryArchivedReceived] [varchar](300) NULL,
[Error] [varchar](500) NULL,
[Price] [float] NULL CONSTRAINT [DF_tSWIFT_History_Trades_Price]
DEFAULT (0),
CONSTRAINT [PK_tSWIFT_History_Trades] PRIMARY KEY NONCLUSTERED ([Id] ASC )
GO
select count (*) from dbo.tSWIFT_History_Trades
--returns 568655
----------------------------------------------------------------
public struct TradeNAK
{ public string BatchId;
public string TradeId;
public bool AckNakSuccess;
public string ErrorText; }
--The number of trade acknowledgements (TradeNAKs) per batch (i.e. _lANT)
can reach 2000.
public int UpdateTradeACKNAKDB(List _lANT, string
strFileNameReceived, string strDirectoryArchivedReceived)
{
try
{
int j = 0;
for (int i = 0; i < _lANT.Count; i++)
{
if (_lANT[i].AckNakSuccess == true)
{
if (_lANT[i].ErrorText == null)
{
j += Convert.ToInt16(dba.ExecuteSQL("UPDATE
tSWIFT_History_Trades SET MachineIdReceived = '" + System.Environment.
UserName.ToUpper() + "', FileNameReceived = '" + strFileNameReceived + "',
DirectoryArchivedReceived = '" + strDirectoryArchivedReceived + "',
DateReceived = GetDate(), AckNak = 'ACK' WHERE (BatchId = '" + _lANT[i].
BatchId + "' AND TradeId = '" + _lANT[i].TradeId + "')"));
}
else
{
j += Convert.ToInt16(dba.ExecuteSQL("UPDATE
tSWIFT_History_Trades SET MachineIdReceived = '" + System.Environment.
UserName.ToUpper() + "', FileNameReceived = '" + strFileNameReceived + "',
DirectoryArchivedReceived = '" + strDirectoryArchivedReceived + "',
DateReceived = GetDate(), AckNak = 'ACK', [Error] = '" + _lANT[i].ErrorText.
Replace("'", "''") + "' WHERE (BatchId = '" + _lANT[i].BatchId + "' AND
TradeId = '" + _lANT[i].TradeId + "')"));
}
}
else
{
if (_lANT[i].ErrorText == null)
{
j += Convert.ToInt16(dba.ExecuteSQL("UPDATE
tSWIFT_History_Trades SET MachineIdReceived = '" + System.Environment.
UserName.ToUpper() + "', FileNameReceived = '" + strFileNameReceived + "',
DirectoryArchivedReceived = '" + strDirectoryArchivedReceived + "',
DateReceived = GetDate(), AckNak = 'NAK' WHERE (BatchId = '" + _lANT[i].
BatchId + "' AND TradeId = '" + _lANT[i].TradeId + "')"));
}
else
{
j += Convert.ToInt16(dba.ExecuteSQL("UPDATE
tSWIFT_History_Trades SET MachineIdReceived = '" + System.Environment.
UserName.ToUpper() + "', FileNameReceived = '" + strFileNameReceived + "',
DirectoryArchivedReceived = '" + strDirectoryArchivedReceived + "',
DateReceived = GetDate(), AckNak = 'NAK', [Error] = '" + _lANT[i].ErrorText.
Replace("'", "''") + "' WHERE (BatchId = '" + _lANT[i].BatchId + "' AND
TradeId = '" + _lANT[i].TradeId + "')"));
}
}
}
return j;
}
catch (Exception ex)
{
throw ex;
}
}
First briefly describe this method does?
1. Describe how the method can be changed, improved or written better.
2. Include an explanation for how and why your solution is better.
3. Rewrite UpdateTradeACKNAKDB function
1 (共1页)
进入Programming版参与讨论
相关主题
有谁知道这段tcp通讯到底在干什么事吗? (转载)
about layout of List in C#
很多东东要是我来设计,会很不一样
春运网站架构之争 MapReduce vs MPI
清净版:写一个Complete Failover Handbook吧
回goodbug,关于DC的failover策略,兼普及基础知识
魏老师在挑战CAP theorum.
想请教魏老师一个方案中的理解问题。
请教魏老师一个协议设计的基本功问题
应该给魏大师发10个图灵奖。
相关话题的讨论汇总
话题: null话题: lant话题: trades话题: history话题: tswift