我需要一些帮助。我在代码行中遇到异常"e_svr.svr = svr;"
。我不知道为什么,因为svr
不为空。任何帮助将不胜感激。我正在尝试将对象的实例保存在字典中。
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,ConcurrencyMode=ConcurrencyMode.Multiple)]
public class EPS_Service : IEPS_Service
{
public decimal cal;
static Dictionary<string, EPS_Instance> OpenConnections =
new Dictionary<string, EPS_Instance>();
public invoice_data Invoice_to_Client(input_params inputparams)
{
EPS_Instance e_svr = new EPS_Instance();
invoice_data Invoice = new invoice_data();
if (OpenConnections.TryGetValue(inputparams.VSId + inputparams.Username, out e_svr))
{
Trace.WriteLine("FOUND!");
e_svr.svr.PrepareByMoney(e_svr.ck, inputparams.VSId, inputparams.meter_number, inputparams.amount, 0, ref cal);
object tr_bl = e_svr.svr.GetInvoiceData(e_svr.ck, e_svr.svr.Confirm(e_svr.ck));
Invoice.invoice_header = fill_invoice_header(tr_bl);
Invoice.invoice_body = fill_invoice_body(tr_bl);
Invoice.invoice_extra = fill_invoice_extra(tr_bl);
Invoice.invoice_steps = fill_invoice_steps(tr_bl);
Invoice.invoice_transfer = fill_invoice_transfer(tr_bl);
}
else
{
Trace.WriteLine("NOT FOUND");
EPS30Ora.EPS30Svr svr = new EPS30Ora.EPS30Svr();
if (svr.LogOnEx("EDENOR", inputparams.VSId, inputparams.Username, inputparams.Password, "EPS30Ora", ref inputparams.ck) == EPS30Ora.LogonResult.psOK)
{
e_svr.ck = inputparams.ck;
e_svr.svr = svr;
OpenConnections.Add(inputparams.VSId + inputparams.Username, e_svr);
svr.PrepareByMoney(inputparams.ck, inputparams.VSId, inputparams.meter_number, inputparams.amount, 0, ref cal);
object tr_bl = svr.GetInvoiceData(inputparams.ck, svr.Confirm(inputparams.ck));
Invoice.invoice_header = fill_invoice_header(tr_bl);
Invoice.invoice_body = fill_invoice_body(tr_bl);
Invoice.invoice_extra = fill_invoice_extra(tr_bl);
Invoice.invoice_steps = fill_invoice_steps(tr_bl);
Invoice.invoice_transfer = fill_invoice_transfer(tr_bl);
}
}
return Invoice;
}
}