コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }