public void NotifyAboutPaymentCancel(onlinePaymentCancelRequest OnlinePaymentCancelRequest) { //var soapRequest = TraceExtension.XmlRequest.OuterXml; //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", "Request : " + DateTime.Now + soapRequest + Environment.NewLine); SqlConnection sqlcon = new SqlConnection(); try { sqlcon.ConnectionString = SQLConnectionstring; sqlcon.Open(); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = messageHeaderValue.receiverID; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("NotifyAboutPaymentCancel", ert); throw myexp; } SqlCommand cmd = new SqlCommand("[dbo].[spCancelPayment]", sqlcon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@receiptNumber", OnlinePaymentCancelRequest.canceledPayment.receiptNumber)); cmd.Parameters.Add(new SqlParameter("@cancelDateTime", OnlinePaymentCancelRequest.canceledPayment.cancelDateTime)); cmd.ExecuteNonQuery(); sqlcon.Close(); //var soapResponse = TraceExtension.XmlResponse.OuterXml; //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", // "INFO : " + DateTime.Now + soapResponse + Environment.NewLine); return; }
public void CheckIfPaymentCancelAllowed(paymentCancelAllocationCheckRequest PaymentCancelAllocationCheckRequest) { //var soapRequest = TraceExtension.XmlRequest.OuterXml; //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", "Request : " + DateTime.Now + soapRequest + Environment.NewLine); SqlConnection sqlcon = new SqlConnection(); try { sqlcon.ConnectionString = SQLConnectionstring; sqlcon.Open(); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = messageHeaderValue.receiverID; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("CheckIfPaymentCancelAllowed", ert, "Verilənlər Bazasına qoşulmaq mümkün olmadı!"); throw myexp; } SqlCommand cmd = new SqlCommand("[dbo].[spCheckIfPaymentCancelAllowed]", sqlcon); //SqlDataReader reader; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ReceiptNumber", PaymentCancelAllocationCheckRequest.receiptNumber)); SqlParameter returnParameter = cmd.Parameters.Add("RetVal", SqlDbType.Int); returnParameter.Direction = ParameterDirection.ReturnValue; cmd.ExecuteNonQuery(); int cacelallowed = (int)returnParameter.Value; sqlcon.Close(); if (cacelallowed == 0) { errorType ert = new errorType(); ert.errorCode = errorCode.NOT_ALLOWED; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = PaymentCancelAllocationCheckRequest.receiptNumber; ert.errorObjectType = objectType.PAYMENT_CANCEL; CustomSOAPException myexp = new CustomSOAPException("CheckIfPaymentCancelAllowed", ert); throw myexp; } //var soapResponse = TraceExtension.XmlResponse.OuterXml; System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTimeOffset.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - INFO : " + DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + PaymentCancelAllocationCheckRequest.receiptNumber + Environment.NewLine); return; }
public void NotifyAboutPayment(onlinePaymentResultRequest OnlinePaymentResultRequest) { //var soapRequest = TraceExtension.XmlRequest.OuterXml; //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", "Request : " + DateTime.Now + soapRequest + Environment.NewLine); //SqlConnection sqlcon = new SqlConnection(); string TaxpayerID; try { //sqlcon.ConnectionString = SQLConnectionstring; //sqlcon.Open(); TaxpayerID = klas.getdatacell(@"select TaxpayerID from Taxpayer where YVOK=N'" + OnlinePaymentResultRequest.serviceAccount.abonCode + "' and Fordelete=1"); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - yvok=" + OnlinePaymentResultRequest.serviceAccount.abonCode + ",Error notify TaxpayerID tapilmadi : " + ex.Message.ToString() + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = OnlinePaymentResultRequest.serviceAccount.scCode; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("NotifyAboutPayment", ert); throw myexp; } try { for (int i = 0; i < OnlinePaymentResultRequest.paymentList.Length; i++) { municipal.InserTaxes(TaxpayerID, OnlinePaymentResultRequest.paymentList[i].serviceCode.ToString(), OnlinePaymentResultRequest.paymentList[i].amount.ToString(), OnlinePaymentResultRequest.paymentList[i].receiptNumber); } } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " tapayerid=" + TaxpayerID + " yvok=" + OnlinePaymentResultRequest.serviceAccount.abonCode + " - NotifyAboutPayment Error : " + ex.Message.ToString() + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = messageHeaderValue.receiverID; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("NotifyAboutPayment", ert, "Ödəniş keçmədi!"); throw myexp; } //sqlcon.Close(); //var soapResponse = TraceExtension.XmlResponse.OuterXml; //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", // "INFO : " + DateTime.Now + soapResponse + Environment.NewLine); return; }
public invoiceResponse GetInvoiceInfoByServiceCodeList(invoiceDefaultRequest InvoiceDefaultRequest, int[] ServiceCodeList) { // public invoiceResponse GetInvoiceInfoByServiceCodeList(int SCCode, string IdentificationSubtype, string AbonCode // , int[] ServiceCodeList) //{ // invoiceDefaultRequest InvoiceDefaultRequest = new invoiceDefaultRequest(); // InvoiceDefaultRequest.scCode = SCCode; // InvoiceDefaultRequest.identificationSubtype = IdentificationSubtype; // InvoiceDefaultRequest.abonCode = AbonCode; invoiceResponse invResp = new invoiceResponse(); //var soapRequest = TraceExtension.XmlRequest.OuterXml; //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", "Request : " + DateTime.Now + soapRequest + Environment.NewLine); invResp.serviceAccountPartial = new serviceAccountPartial(); invResp.serviceAccountPartial.abonCode = InvoiceDefaultRequest.abonCode; invResp.serviceAccountPartial.scCode = InvoiceDefaultRequest.scCode; invResp.serviceAccountPartial.identificationSubtype = InvoiceDefaultRequest.identificationSubtype; SqlConnection sqlcon = new SqlConnection(); try { sqlcon.ConnectionString = SQLConnectionstring; sqlcon.Open(); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = InvoiceDefaultRequest.scCode; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("GetInvoiceInfoByServiceCodeList", ert); throw myexp; } SqlCommand ckcmd = new SqlCommand("select * from Taxpayer where YVOK=@YVOK and Fordelete=1", sqlcon); ckcmd.Parameters.AddWithValue("@YVOK", InvoiceDefaultRequest.abonCode); SqlDataReader reader1 = ckcmd.ExecuteReader(); if (!(reader1.HasRows) || !(reader1.Read())) { errorType ert = new errorType(); ert.errorCode = errorCode.NOT_FOUND; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = InvoiceDefaultRequest.abonCode; ert.errorObjectType = objectType.SERVICE_ACCOUNT; CustomSOAPException myexp = new CustomSOAPException("GetInvoiceInfoByServiceCodeList", ert); sqlcon.Close(); throw myexp; } reader1.Close(); string TaxpayerID = klas.getdatacell("select TaxpayerID from Taxpayer " + "where YVOK=N'" + InvoiceDefaultRequest.abonCode + "' and Fordelete=1"); DataTable dt = new DataTable(); if (TaxpayerID != null && ServiceCodeList.Length > 0) { //if (municipal.GetTaxesObjects(TaxpayerID,ServiceCodeList) != null) { dt = municipal.GetTaxesObjects(TaxpayerID, ServiceCodeList); } } DataTableReader reader; reader = dt.CreateDataReader(); int cnt = 0; List <invoice> invList = new List <invoice>(); while (reader.Read()) { int colIndex; invoice inv = new invoice(); colIndex = reader.GetOrdinal("InvoiceType"); //invoiceType invtype = new invoiceType(); //if (Enum.TryParse(reader[colIndex].ToString(), out invtype)) //{ inv.invoiceType = invoiceType.AVANS; //} //colIndex = reader.GetOrdinal("InvoiceDate"); //if (!reader.IsDBNull(colIndex)) //{ // inv.invoiceDate = reader.GetDateTime(colIndex); // inv.invoiceDateSpecified = true; //} colIndex = reader.GetOrdinal("AmountDue"); inv.amountDue = reader.IsDBNull(colIndex) ? 0 : reader.GetDecimal(colIndex); inv.amountDueSpecified = true; colIndex = reader.GetOrdinal("CurrentDebt"); inv.currentDebt = reader.IsDBNull(colIndex) ? 0 : reader.GetDecimal(colIndex); inv.currentDebtSpecified = true; colIndex = reader.GetOrdinal("PaymentReceiver"); int paymentReceiver = 0; if (Int32.TryParse(reader[colIndex].ToString(), out paymentReceiver)) { inv.paymentReceiverCode = paymentReceiver; inv.paymentReceiverCodeSpecified = true; } colIndex = reader.GetOrdinal("ServiceCode"); int serviceCode = 0; if (Int32.TryParse(reader[colIndex].ToString(), out serviceCode)) { inv.serviceCode = serviceCode; inv.serviceCodeSpecified = true; } //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log.txt", // "INFO:1:" + DateTime.Now + Environment.NewLine); //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", // "INFO:1:" + DateTime.Now + Environment.NewLine); invList.Add(inv); cnt++; } if (reader.HasRows) { invResp.invoiceList = invList.ToArray(); } else if (invList.Count != ServiceCodeList.Length) { errorType ert = new errorType(); ert.errorCode = errorCode.NOT_ALLOWED; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = InvoiceDefaultRequest.abonCode; ert.errorObjectType = objectType.PRE_PAYMENT; CustomSOAPException myexp = new CustomSOAPException("GetInvoiceInfoByServiceCodeList", ert); throw myexp; } sqlcon.Close(); System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTimeOffset.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - codelistinfo INFO : " + DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + InvoiceDefaultRequest.abonCode.ToString() + Environment.NewLine); //var soapResponse = TraceExtension.XmlResponse.OuterXml; //System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString() + ".txt", // "INFO : " + DateTime.Now + soapResponse + Environment.NewLine); return(invResp); }
public uniqueInvoiceResponse GetInvoiceInfoByDocumentNum(int SCCode, string IdentificationSubtype, string DocumentNum) { SqlConnection sqlcon = new SqlConnection(); SqlCommand cmd; try { sqlcon.ConnectionString = SQLConnectionstring; sqlcon.Open(); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = SCCode; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("GetInvoiceInfoByDocumentNum", ert); throw myexp; } uniqueInvoiceResponse invoiceByDocNumResponce = new uniqueInvoiceResponse(); cmd = new SqlCommand("[dbo].[spGetInvoiceByDocumentNum]", sqlcon); SqlDataReader reader; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@IdentificationSubtype", IdentificationSubtype)); cmd.Parameters.Add(new SqlParameter("@DocumentNum", DocumentNum)); reader = cmd.ExecuteReader(); if (reader.HasRows && reader.Read())//1 sətir olmalıdır. əlavə yoxlama qoymaq lazımdır. { serviceAccountPartial ServiceAccountPartial = new serviceAccountPartial(); invoice Invoice = new invoice(); int colIndex; ServiceAccountPartial.scCode = SCCode; colIndex = reader.GetOrdinal("IdentificationSubtypeACC"); ServiceAccountPartial.identificationSubtype = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); if (ServiceAccountPartial.identificationSubtype == "ACC1") { colIndex = reader.GetOrdinal("AbonCode"); ServiceAccountPartial.abonCode = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); } else if (ServiceAccountPartial.identificationSubtype == "IAMAS") { colIndex = reader.GetOrdinal("PIN"); ServiceAccountPartial.abonCode = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); } Invoice.invoiceType = invoiceType.SIMPLE; //Group invoice-da ola bilər. colIndex = reader.GetOrdinal("InvoiceDate"); if (!reader.IsDBNull(colIndex)) { Invoice.invoiceDate = reader.GetDateTime(colIndex); Invoice.invoiceDateSpecified = true; } colIndex = reader.GetOrdinal("IdentificationSubtypeDOC"); Invoice.identificationSubtype = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); colIndex = reader.GetOrdinal("AmountDue"); Invoice.amountDue = reader.IsDBNull(colIndex) ? 0 : reader.GetDecimal(colIndex); Invoice.amountDueSpecified = true; colIndex = reader.GetOrdinal("CurrentDebt"); Invoice.currentDebt = reader.IsDBNull(colIndex) ? 0 : reader.GetDecimal(colIndex); Invoice.currentDebtSpecified = true; Invoice.maxAllowedAmount = Invoice.currentDebt; Invoice.maxAllowedAmountSpecified = true; Invoice.invoiceCode = DocumentNum; colIndex = reader.GetOrdinal("PaymentReceiver"); int paymentReceiver = 0; if (Int32.TryParse(reader[colIndex].ToString(), out paymentReceiver)) { Invoice.paymentReceiverCode = paymentReceiver; } Invoice.paymentReceiverCodeSpecified = true; colIndex = reader.GetOrdinal("ServiceCode"); int serviceCode = 0; if (Int32.TryParse(reader[colIndex].ToString(), out serviceCode)) { Invoice.serviceCode = serviceCode; } Invoice.serviceCodeSpecified = true; invoiceByDocNumResponce.serviceAccountPartial = ServiceAccountPartial; invoiceByDocNumResponce.invoice = Invoice; System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log.txt", "INFO:1:" + DateTime.Now + Environment.NewLine); } else { errorType ert = new errorType(); ert.errorCode = errorCode.NOT_FOUND; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = DocumentNum; ert.errorObjectType = objectType.INVOICE; CustomSOAPException myexp = new CustomSOAPException("GetInvoiceInfoByDocumentNum", ert); throw myexp; } sqlcon.Close(); return(invoiceByDocNumResponce); }
public serviceAccount GetAccountInfo(int SCCode, string IdentificationSubtype, string AbonCode) { SqlConnection sqlcon = new SqlConnection(); serviceAccount acc = new serviceAccount(); try { sqlcon.ConnectionString = SQLConnectionstring; sqlcon.Open(); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = SCCode; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("GetAccountInfo", ert, "Verilənlər Bazasına qoşulmaq mümkün olmadı!"); throw myexp; } SqlCommand cmd = new SqlCommand(@"select t.*,Name+' '+Sname+' '+Fname FullName,lcm.Municipal_code from Taxpayer t inner join List_classification_Municipal lcm on lcm.MunicipalID=t.MunicipalID where YVOK=@YVOK and t.Fordelete=1 ", sqlcon); SqlDataReader reader; cmd.Parameters.Add(new SqlParameter("@YVOK", AbonCode)); reader = cmd.ExecuteReader(); if (reader.HasRows && reader.Read())//1 sətir olmalıdır. əlavə yoxlama qoymaq lazımdır. { int colIndex; acc.scCode = SCCode; acc.identificationSubtype = IdentificationSubtype; colIndex = reader.GetOrdinal("Municipal_code"); string MunicipalCode = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); acc.branchID = Int32.Parse("92" + MunicipalCode); colIndex = reader.GetOrdinal("YVOK"); acc.abonCode = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); if (reader["Individual_Legal"].ToString() == "1") { acc.abonType = abonType.P; colIndex = reader.GetOrdinal("Pincode"); acc.pinCode = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); colIndex = reader.GetOrdinal("FullName"); acc.description = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); } else { acc.abonType = abonType.J; colIndex = reader.GetOrdinal("VOEN"); acc.taxNumber = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); colIndex = reader.GetOrdinal("CompanyName"); acc.description = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); } acc.smartMeter = false; if (reader["RegistrationAdress"] == null) { acc.address = "-"; } else if (reader["RegistrationAdress"].ToString() == "") { acc.address = "-"; } else { colIndex = reader.GetOrdinal("RegistrationAdress"); acc.address = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); } System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - INFO:1:" + acc.abonCode.ToString() + Environment.NewLine); } else { errorType ert = new errorType(); ert.errorCode = errorCode.NOT_FOUND; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = AbonCode; ert.errorObjectType = objectType.SERVICE_ACCOUNT; CustomSOAPException myexp = new CustomSOAPException("GetAccountInfo", ert); throw myexp; } sqlcon.Close(); return(acc); }
public invoiceResponse GetInvoiceInfo(invoiceDefaultRequest InvoiceDefaultRequest) { //serhe alinan hisse evvel // public invoiceResponse GetInvoiceInfo(int SCCode, string IdentificationSubtype, string AbonCode) //{ // invoiceDefaultRequest InvoiceDefaultRequest = new invoiceDefaultRequest(); // InvoiceDefaultRequest.abonCode = AbonCode; // InvoiceDefaultRequest.scCode = SCCode; // InvoiceDefaultRequest.identificationSubtype = IdentificationSubtype; //serhe alinan hisse son invoiceResponse invResp = new invoiceResponse(); invResp.serviceAccountPartial = new serviceAccountPartial(); invResp.serviceAccountPartial.abonCode = InvoiceDefaultRequest.abonCode; invResp.serviceAccountPartial.scCode = InvoiceDefaultRequest.scCode; invResp.serviceAccountPartial.identificationSubtype = InvoiceDefaultRequest.identificationSubtype; SqlConnection sqlcon = new SqlConnection(); try { sqlcon.ConnectionString = SQLConnectionstring; sqlcon.Open(); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = messageHeaderValue.receiverID.ToString(); ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("GetInvoiceInfo", ert); throw myexp; } SqlCommand ckcmd = new SqlCommand(@"select TaxpayerID from Taxpayer where YVOK=@YVOK and Fordelete=1", sqlcon); ckcmd.Parameters.AddWithValue("@YVOK", InvoiceDefaultRequest.abonCode); SqlDataReader reader1 = ckcmd.ExecuteReader(); if (!(reader1.HasRows) || !(reader1.Read())) { errorType ert = new errorType(); ert.errorCode = errorCode.NOT_FOUND; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = InvoiceDefaultRequest.abonCode; ert.errorObjectType = objectType.SERVICE_ACCOUNT; CustomSOAPException myexp = new CustomSOAPException("GetInvoiceInfo", ert); sqlcon.Close(); throw myexp; } reader1.Close(); int[] ServiceCodeList = { 20000200 /*emlak*/, 20000100 /*torpaq*/, 20000300 /*meden vergisi*/, 20001000 /*Bələdiyyə mülkiyyətinin icarə*/, 20000500 /*reklam*/, 20000800 /*neqliyyat vas day*/, 20000700 /*Mehmanxana*/, 20000600 /*Stasionar*/, 20000900 /*Bələdiyyə mülkiyyətinin özgə*/, 20000400 /*menfeet*/, 20001100 /*sanksiya*/, 20001200 /*iane*/ }; string TaxpayerID = klas.getdatacell(@"select TaxpayerID from Taxpayer where YVOK=N'" + InvoiceDefaultRequest.abonCode + "' and Fordelete=1"); DataTable dt = new DataTable(); if (TaxpayerID != null && ServiceCodeList.Length > 0) { dt = municipal.GetTaxesObjects(TaxpayerID, ServiceCodeList); } DataTableReader reader; reader = dt.CreateDataReader(); int cnt = 0; List <invoice> invList = new List <invoice>(); while (reader.Read()) { int colIndex; invoice inv = new invoice(); colIndex = reader.GetOrdinal("InvoiceType"); //invoiceType invtype = new invoiceType(); //if (Enum.TryParse(reader[colIndex].ToString(), out invtype)) //{ inv.invoiceType = invoiceType.AVANS; //} colIndex = reader.GetOrdinal("AmountDue"); inv.amountDue = reader.IsDBNull(colIndex) ? 0 : reader.GetDecimal(colIndex); inv.amountDueSpecified = true; colIndex = reader.GetOrdinal("CurrentDebt"); inv.currentDebt = reader.IsDBNull(colIndex) ? 0 : reader.GetDecimal(colIndex); inv.currentDebtSpecified = true; colIndex = reader.GetOrdinal("PaymentReceiver"); int paymentReceiver = 0; if (Int32.TryParse(reader[colIndex].ToString(), out paymentReceiver)) { inv.paymentReceiverCode = paymentReceiver; inv.paymentReceiverCodeSpecified = true; } colIndex = reader.GetOrdinal("ServiceCode"); int serviceCode = 0; if (Int32.TryParse(reader[colIndex].ToString(), out serviceCode)) { inv.serviceCode = serviceCode; inv.serviceCodeSpecified = true; } //if (inv.currentDebt > 0) //{ invList.Add(inv); cnt++; //} } sqlcon.Close(); if (cnt > 0) { invResp.invoiceList = invList.ToArray(); } System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTimeOffset.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - INFO : " + DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + InvoiceDefaultRequest.abonCode.ToString() + Environment.NewLine); return(invResp); }
public serviceAccount GetAccountInfoByDocumentNum(int SCCode, string IdentificationSubtype, string DocumentNum) { SqlConnection sqlcon = new SqlConnection(); SqlCommand cmd; serviceAccount acc = new serviceAccount(); try { sqlcon.ConnectionString = SQLConnectionstring; sqlcon.Open(); } catch (Exception ex) { System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - Error : " + ex.Message.ToString() + Environment.NewLine + SQLConnectionstring + Environment.NewLine); errorType ert = new errorType(); ert.errorCode = errorCode.SYSTEM_ERROR; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = SCCode; ert.errorObjectType = objectType.SYSTEM; CustomSOAPException myexp = new CustomSOAPException("GetAccountInfoByDocumentNum", ert); throw myexp; } cmd = new SqlCommand("[dbo].[spGetDocumentNum]", sqlcon); SqlDataReader reader; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@IdentificationSubtype", IdentificationSubtype)); cmd.Parameters.Add(new SqlParameter("@DocumentNum", DocumentNum)); reader = cmd.ExecuteReader(); if (reader.HasRows && reader.Read())//1 sətir olmalıdır. əlavə yoxlama qoymaq lazımdır. { int colIndex; acc.scCode = SCCode; acc.branchID = SCCode + 99; colIndex = reader.GetOrdinal("IdentificationSubtype"); acc.identificationSubtype = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); if (acc.identificationSubtype == "ACC1") { colIndex = reader.GetOrdinal("AbonCode"); acc.abonCode = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); } else if (acc.identificationSubtype == "IAMAS") { colIndex = reader.GetOrdinal("PIN"); acc.abonCode = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); } acc.abonType = abonType.P; acc.smartMeter = false; colIndex = reader.GetOrdinal("FirstName"); acc.name = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); colIndex = reader.GetOrdinal("Surname"); acc.surname = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); colIndex = reader.GetOrdinal("Patronymic"); acc.secondName = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); colIndex = reader.GetOrdinal("Address"); acc.address = reader.IsDBNull(colIndex) ? string.Empty : reader.GetString(colIndex); System.IO.File.AppendAllText(Settings.Default.LogFileDirectory + "log" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTimeOffset.Now.ToString("yyyy-MM-ddTHH:mm:sszzz") + " - INFO:1:" + DateTime.Now + acc.abonCode.ToString() + Environment.NewLine); } else { errorType ert = new errorType(); ert.errorCode = errorCode.NOT_FOUND; ert.errorDateTime = DateTime.Now; ert.errorData = new object[1]; ert.errorData[0] = DocumentNum; ert.errorObjectType = objectType.INVOICE; CustomSOAPException myexp = new CustomSOAPException("GetAccountInfoByDocumentNum", ert, "Invoice not found for " + SCCode.ToString()); throw myexp; } sqlcon.Close(); return(acc); }