Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            key1 = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

            Batch StartBatch = new Batch();

            //  StartBatch.MakeUpsells();
            Console.WriteLine("TryMyPurmist Batch - Started");
            Console.WriteLine("Please Wait - ");
            Console.WriteLine("Start - Batching Control Version");
            // StartBatch.DoVeripurBatch();
            StartBatch.DoTryMyPurmistBatch();
            Console.WriteLine("End - Batching Control Version");

            Console.WriteLine("Start - Encryption Process");
            encryptfile(file1);
            encryptfile(file2);
            Console.WriteLine("Start - Successfulyy Encrypted");

            //upload files
            //Console.WriteLine("Start - Upload Process");
            //uploadFile(Helper.AppSettings["ftpServerName"].ToString(), file1.ToLower().Replace("batchstaging", "ftp") + ".pgp", Helper.AppSettings["ftpUserName"].ToString(), Helper.AppSettings["ftpPassword"].ToString());

            count1 = LineCount(file1);
            count2 = LineCount(file2);
            //count3 = LineCount(file3);

            ////sendemail(file1, file2, count1-1, count2-1);

            Console.WriteLine("Task Completed - ");
        }
Ejemplo n.º 2
0
        public void UploadOrdersToOrderMotion()
        {
            try
            {
                key1 = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
                Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
                em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

                foreach (DataRow _drOrder in Orders.Rows)
                {
                    if (_drOrder["OrderId"].ToString() != null)
                    {
                        sendxml1("True", _drOrder["OrderId"].ToString());
                        if (DoAuthorization(_drOrder["OrderId"].ToString()))
                        {
                            sendxml1("False", _drOrder["OrderId"].ToString());
                        }
                        else
                        {
                            //update the order tabe for coloum authStaus.
                            runsql("update [order] set orderstatusid = 2, AuthStatus = 'False' where orderid= " + _drOrder["OrderId"].ToString());
                        }
                    }
                    _dtOrderSKU = null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while uploading orders -- " + e.Message);
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            key1 = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

            Batch StartBatch = new Batch();

            Console.WriteLine("ContourAbs Batch - Started");
            Console.WriteLine("Please Wait - ");
            StartBatch.UploadOrdersToOrderMotion();
            Console.WriteLine("End - ContourAbs Batch - Started");
            StartBatch.RejectedOrdersCheck();
            Console.WriteLine("Task Completed - ");
        }
Ejemplo n.º 4
0
        public bool ProcessBatch(DateTime dtbp, string EmployeeNumber)
        {
            bool _breturn = false;
            // string DNIS = "5700";
            string DNIS = Helper.DataServicesTxtBatchConfig["Field#22_GET"];

            //Console.WriteLine("\n Please Enter the 4 digit DNIS of the Telephone # dialed by customer.");
            //DNIS = Console.ReadLine();


            #region Create Files
            if (!Directory.Exists(_srtPath))
            {
                Directory.CreateDirectory(_srtPath);
            }
            Actualfilename = EmployeeNumber + DateTime.Now.ToString("MMddyyyy") + "_cellu.txt";
            txtfilename    = _srtPath + "\\" + Actualfilename;
            StreamWriter SWtxtfile = new StreamWriter(txtfilename, true);
            SWtxtfile.Flush();
            #endregion

            try
            {
                DAL.SQLServerDAL_Get.GetOrdersForTxtBatch(dtbp, out _dtOrders);
                foreach (DataRow _drOrder in _dtOrders.Rows)
                {
                    #region MyRegion
                    Order ord = new Order();
                    _breturn    = true;
                    _intOrderID = Helper.ToInt32(_drOrder["OrderId"].ToString());
                    #region Shipping Address Info

                    _intShippingAddress = Helper.ToInt32(_drOrder["CustomerShippingAddressId"].ToString());

                    foreach (DataRow _drShippingInfo in CustomerShippingAddress.Rows)
                    {
                        ord.ShipToLastName         = _drShippingInfo["LastName"].ToString();
                        ord.ShipToFirstName        = _drShippingInfo["FirstName"].ToString();
                        ord.ShipToAddress1         = _drShippingInfo["Address1"].ToString();
                        ord.ShipToAddress2         = _drShippingInfo["Address2"].ToString();
                        ord.ShipToCity             = _drShippingInfo["City"].ToString();
                        ord.ShipToState            = _drShippingInfo["StateProvince"].ToString();
                        ord.ShipToZip              = _drShippingInfo["ZipPostalCode"].ToString();
                        ord.ShipToCountry          = _drShippingInfo["CountryCode"].ToString();
                        ord.ShipToPhone            = ValidatePhone(_drShippingInfo["PhoneNumber"].ToString());
                        _dtCustomerShippingAddress = null;
                        break;
                    }
                    #endregion
                    #region Billing Address Info

                    _intBillingAddress = Helper.ToInt32(_drOrder["BillingAddressId"].ToString());

                    foreach (DataRow _drBillingInfo in CustomerBillingAddress.Rows)
                    {
                        ord.BillingFirstName      = _drBillingInfo["FirstName"].ToString();
                        ord.BillingLastName       = _drBillingInfo["LastName"].ToString();
                        ord.BillingAddress1       = _drBillingInfo["Address1"].ToString();
                        ord.BillingAddress2       = _drBillingInfo["Address2"].ToString();
                        ord.BillingCity           = _drBillingInfo["City"].ToString();
                        ord.BillingState          = _drBillingInfo["StateProvince"].ToString();
                        ord.BillingZip            = _drBillingInfo["ZipPostalCode"].ToString();
                        ord.BillingCountry        = _drBillingInfo["CountryCode"].ToString();
                        ord.BillingPhone          = ord.ShipToPhone; //Billing Phone number is always same as shipping phone number.
                        _dtCustomerBillingAddress = null;
                        break;
                    }
                    #endregion
                    ord.Email = _drOrder["Email"].ToString();
                    #region Credit Card Info
                    key1 = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
                    Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
                    em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();
                    ord.CreditCardNumber = em.Decrypt(_drOrder["CreditCardNumber"].ToString());
                    ord.CreditCardType   = _drOrder["CreditCardName"].ToString().Substring(0, 1).ToUpper();
                    if (ord.CreditCardType == "M")
                    {
                        ord.CreditCardType = "MC";
                    }
                    ord.CreditCardExpiration = Convert.ToDateTime(_drOrder["CreditCardExpired"]).ToString("MM/yy");
                    ord.CVV = _drOrder["CreditCardCSC"].ToString();
                    #endregion
                    #region Sales Tax

                    DAL.SQLServerDAL_Get.GetSalesTaxRate(ord.ShipToState, out _dtSalesTaxRate);
                    foreach (DataRow _drSalesTax in _dtSalesTaxRate.Rows)
                    {
                        ord.SalesTaxRate = _drSalesTax["taxrate"].ToString();
                        _dtSalesTaxRate  = null;
                        break;
                    }
                    #endregion
                    #region Order Info
                    //Start - Taking care of passing multipay as one pay - as per clients need
                    IsMultiPay = false;
                    foreach (DataRow _drOrderSKU in OrderSKU.Rows)
                    {
                        if (_drOrderSKU["SKUID"].ToString().Equals("326") || _drOrderSKU["SKUID"].ToString().Equals("327") || _drOrderSKU["SKUID"].ToString().Equals("328") || _drOrderSKU["SKUID"].ToString().Equals("329"))
                        {
                            IsMultiPay = true;
                        }
                    }
                    if (IsMultiPay)
                    {
                        if (ord.ShipToCountry.Equals("US "))
                        {
                            if (ord.ShipToState.Equals("FL"))
                            {
                                //Recalculating Tax for FL only
                                ord.OrderNumber = _drOrder["OrderId"].ToString();
                                ord.OrderDate   = Convert.ToDateTime(_drOrder["Created"]).ToString("MM/dd/yyyy");
                                ord.OrderTime   = Convert.ToDateTime(_drOrder["Created"]).ToString("HH:mm:ss");

                                ord.MerchandiseTotal = Helper.ToDecimal("292.96").ToString();
                                ord.MerchandiseTotal = Math.Round((decimal.Parse(ord.MerchandiseTotal)), 2).ToString();

                                ord.ShippingTotal = Helper.ToDecimal("0").ToString();
                                ord.ShippingTotal = Math.Round(decimal.Parse(ord.ShippingTotal), 2).ToString();
                                decimal _taxRate = decimal.Parse(ord.SalesTaxRate);

                                ord.SalesTaxTotal = (_taxRate * (decimal.Parse(ord.ShippingTotal) + decimal.Parse(ord.MerchandiseTotal))).ToString();
                                ord.SalesTaxTotal = Math.Round(decimal.Parse(ord.SalesTaxTotal), 2).ToString();

                                ord.OrderTotal = (decimal.Parse(ord.MerchandiseTotal) + decimal.Parse(ord.ShippingTotal) + decimal.Parse(ord.SalesTaxTotal)).ToString();
                                ord.OrderTotal = Math.Round(decimal.Parse(ord.OrderTotal), 2).ToString();
                            }
                            else
                            {
                                ord.OrderNumber = _drOrder["OrderId"].ToString();
                                ord.OrderDate   = Convert.ToDateTime(_drOrder["Created"]).ToString("MM/dd/yyyy");
                                ord.OrderTime   = Convert.ToDateTime(_drOrder["Created"]).ToString("HH:mm:ss");

                                ord.MerchandiseTotal = Helper.ToDecimal("292.96").ToString();
                                ord.MerchandiseTotal = Math.Round((decimal.Parse(ord.MerchandiseTotal)), 2).ToString();

                                ord.ShippingTotal = Helper.ToDecimal("0").ToString();
                                ord.ShippingTotal = Math.Round(decimal.Parse(ord.ShippingTotal), 2).ToString();

                                ord.SalesTaxTotal = _drOrder["Tax"].ToString().Trim();
                                ord.SalesTaxTotal = Math.Round(decimal.Parse(ord.SalesTaxTotal), 2).ToString();

                                ord.OrderTotal = (decimal.Parse(ord.MerchandiseTotal) + decimal.Parse(ord.ShippingTotal) + decimal.Parse(ord.SalesTaxTotal)).ToString();
                                ord.OrderTotal = Math.Round(decimal.Parse(ord.OrderTotal), 2).ToString();
                            }
                        }
                        else
                        {
                            ord.OrderNumber = _drOrder["OrderId"].ToString();
                            ord.OrderDate   = Convert.ToDateTime(_drOrder["Created"]).ToString("MM/dd/yyyy");
                            ord.OrderTime   = Convert.ToDateTime(_drOrder["Created"]).ToString("HH:mm:ss");

                            ord.MerchandiseTotal = Helper.ToDecimal("292.96").ToString();
                            ord.MerchandiseTotal = Math.Round((decimal.Parse(ord.MerchandiseTotal)), 2).ToString();

                            ord.ShippingTotal = Helper.ToDecimal("10").ToString();
                            ord.ShippingTotal = Math.Round(decimal.Parse(ord.ShippingTotal), 2).ToString();

                            ord.SalesTaxTotal = _drOrder["Tax"].ToString().Trim();
                            ord.SalesTaxTotal = Math.Round(decimal.Parse(ord.SalesTaxTotal), 2).ToString();

                            ord.OrderTotal = (decimal.Parse(ord.MerchandiseTotal) + decimal.Parse(ord.ShippingTotal) + decimal.Parse(ord.SalesTaxTotal)).ToString();
                            ord.OrderTotal = Math.Round(decimal.Parse(ord.OrderTotal), 2).ToString();
                        }
                    }
                    else
                    {
                        //This means it is single pay.
                        ord.OrderNumber = _drOrder["OrderId"].ToString();
                        ord.OrderDate   = Convert.ToDateTime(_drOrder["Created"]).ToString("MM/dd/yyyy");
                        ord.OrderTime   = Convert.ToDateTime(_drOrder["Created"]).ToString("HH:mm:ss");

                        ord.MerchandiseTotal = _drOrder["SubTotal"].ToString();
                        ord.MerchandiseTotal = Math.Round(decimal.Parse(ord.MerchandiseTotal), 2).ToString();

                        ord.ShippingTotal = _drOrder["ShippingCost"].ToString();
                        ord.ShippingTotal = Math.Round(decimal.Parse(ord.ShippingTotal), 2).ToString();

                        ord.SalesTaxTotal = _drOrder["Tax"].ToString().Trim();
                        ord.SalesTaxTotal = Math.Round(decimal.Parse(ord.SalesTaxTotal), 2).ToString();

                        ord.OrderTotal = (decimal.Parse(ord.MerchandiseTotal) + decimal.Parse(ord.ShippingTotal) + decimal.Parse(ord.SalesTaxTotal)).ToString();
                        ord.OrderTotal = Math.Round(decimal.Parse(ord.OrderTotal), 2).ToString();
                    }
                    //End - Taking care of passing multipay as one pay - as per clients need
                    ord.ShippingMethod = _drOrder["ShippingMethod"].ToString();
                    if (ord.ShippingMethod.Equals("RegularShipping"))
                    {
                        ord.ShippingMethod = "REG";
                    }
                    if (ord.ShippingMethod.Equals("RushShipping"))
                    {
                        ord.ShippingMethod = "RSH";
                    }

                    #endregion

                    #endregion

                    #region OrderSku1
                    string PRODUCT    = "";
                    string PRODUCT01  = "";
                    string PRODUCT02  = "";
                    string PRODUCT03  = "";
                    string PRODUCT04  = "";
                    string PRODUCT05  = "";
                    string QUANTITY   = "";
                    string QUANTITY01 = "";
                    string QUANTITY02 = "";
                    string QUANTITY03 = "";
                    string QUANTITY04 = "";
                    string QUANTITY05 = "";
                    string PRICE      = "";
                    string PRICE01    = "";
                    string PRICE02    = "";
                    string PRICE03    = "";
                    string PRICE04    = "";
                    string PRICE05    = "";
                    string DISCOUNT   = "";
                    string DISCOUNT01 = "";
                    string DISCOUNT02 = "";
                    string DISCOUNT03 = "";
                    string DISCOUNT04 = "";
                    string DISCOUNT05 = "";
                    int    SrNo       = 1;
                    foreach (DataRow _drOrderSKU in OrderSKU.Rows)
                    {
                        PRODUCT  = _drOrderSKU["SKUCode"].ToString();
                        QUANTITY = _drOrderSKU["OrderSkuQuantity"].ToString();
                        if (IsMultiPay)
                        {
                            PRICE = Helper.ToDecimal("292.96").ToString();
                            PRICE = Math.Round((decimal.Parse(PRICE)), 2).ToString();
                        }
                        else
                        {
                            PRICE = _drOrderSKU["OrderSkuPrice"].ToString();
                            PRICE = Math.Round(decimal.Parse(PRICE), 2).ToString();
                        }
                        DISCOUNT = _drOrderSKU["OrderSkuDiscount"].ToString();
                        DISCOUNT = Math.Round(decimal.Parse(DISCOUNT), 2).ToString();
                        switch (SrNo)
                        {
                        case 1:
                            PRODUCT01  = PRODUCT;
                            QUANTITY01 = QUANTITY;
                            PRICE01    = PRICE;
                            DISCOUNT01 = DISCOUNT;
                            break;

                        case 2:
                            PRODUCT02  = PRODUCT;
                            QUANTITY02 = QUANTITY;
                            PRICE02    = PRICE;
                            DISCOUNT02 = DISCOUNT;
                            break;

                        case 3:
                            PRODUCT03  = PRODUCT;
                            QUANTITY03 = QUANTITY;
                            PRICE03    = PRICE;
                            DISCOUNT03 = DISCOUNT;
                            break;

                        case 4:
                            PRODUCT04  = PRODUCT;
                            QUANTITY04 = QUANTITY;
                            PRICE04    = PRICE;
                            DISCOUNT04 = DISCOUNT;
                            break;

                        case 5:
                            PRODUCT05  = PRODUCT;
                            QUANTITY05 = QUANTITY;
                            PRICE05    = PRICE;
                            DISCOUNT05 = DISCOUNT;
                            break;
                        }
                        SrNo += 1;
                    }
                    _dtOrderSKU = null;
                    #endregion
                    #region txt output
                    string BCOUNTRY = "001";
                    string SCOUNTRY = "001";
                    if (ord.BillingCountry == "CA")
                    {
                        BCOUNTRY = "034";
                    }
                    if (ord.ShipToCountry == "CA")
                    {
                        SCOUNTRY = "034";
                    }

                    string OrderRecord = dq + RESERVED + dqcdq                            //1	RESERVED
                                         + EmployeeNumber + "-" + ord.OrderNumber + dqcdq //2	CUSTOMER_NUMBER
                                         + ord.BillingLastName + dqcdq                    //3	BILL_LAST_NAME
                                         + ord.BillingFirstName + dqcdq                   //4	BILL_FIRST_NAME
                                         + ord.BillingCompany + dqcdq                     //5   BILL_COMPANY

                                         + ord.BillingAddress1 + dqcdq                    //6	    BILL_ADDRESS1
                                         + ord.BillingAddress2 + dqcdq                    //7	    BILL_ADDRESS2
                                         + ord.BillingCity + dqcdq                        //8	    BILL_CITY
                                         + ord.BillingState + dqcdq                       //9	    BILL_STATE
                                         + ord.BillingZip + dqcdq                         //10	BILL_ZIPCODE

                                         + RESERVED + dqcdq                               //11	RESERVED
                                         + ord.BillingPhone + dqcdq                       //12	BILL_PHONE_NUMBER
                                         + RESERVED + dqcdq                               //13	ACH_BANK_NAME
                                         + RESERVED + dqcdq                               //14	NO_SOLICITING
                                         + RESERVED + dqcdq                               //15	RESERVED

                                         + RESERVED + dqcdq                               //16	PAYMENT_TYPE
                                         + RESERVED + dqcdq                               //17	RESERVED
                                         + RESERVED + dqcdq                               //18	RESERVED
                                         + ord.CreditCardType + dqcdq                     //19	CC_TYPE
                                         + ord.CreditCardNumber + dqcdq                   //20	CC_NUMBER

                                         + ord.CreditCardExpiration + dqcdq               //21	EXP_DATE
                                         + DNIS + dqcdq                                   //22	DNIS
                                         + RESERVED + dqcdq                               //23	KEY_CODE
                                         + EmployeeNumber + dqcdq                         //24	EMP_NUMBER
                                         + RESERVED + dqcdq                               //25	RESERVED

                                         + RESERVED + dqcdq                               //26	RESERVED
                                         + ord.ShippingMethod + dqcdq                     //27	SHIPPING_METHOD
                                         + RESERVED + dqcdq                               //28	ORDER_ALREADY_FULLFILLED
                                         + RESERVED + dqcdq                               //29	AMOUNT_ALREADY_PAID
                                         + "N" + dqcdq                                    //30	CONTINUED

                                         + ord.OrderDate + dqcdq                          //31	ORDER_DATE
                                         + EmployeeNumber + "-" + ord.OrderNumber + dqcdq //32	ORDER_NUMBER
                                         + PRODUCT01 + dqcdq                              //33	PRODUCT01
                                         + QUANTITY01 + dqcdq                             //34	QUANTITY01
                                         + PRODUCT02 + dqcdq                              //35	PRODUCT02

                                         + QUANTITY02 + dqcdq                             //36	QUANTITY02
                                         + PRODUCT03 + dqcdq                              //37	PRODUCT03
                                         + QUANTITY03 + dqcdq                             //38	QUANTITY03
                                         + PRODUCT04 + dqcdq                              //39	PRODUCT04
                                         + QUANTITY04 + dqcdq                             //40	QUANTITY04

                                         + PRODUCT05 + dqcdq                              //41	PRODUCT05
                                         + QUANTITY05 + dqcdq                             //42	QUANTITY05
                                         + ord.ShipToLastName + dqcdq                     //43	SHIP_TO_LAST_NAME
                                         + ord.ShipToFirstName + dqcdq                    //44	SHIP_TO_FIRST_NAME
                                         + ord.ShipToCompany + dqcdq                      //45	SHIP_TO_COMPANY

                                         + ord.ShipToAddress1 + dqcdq                     //46	SHIP_TO_ADDRESS1
                                         + ord.ShipToAddress2 + dqcdq                     //47	SHIP_TO_ADDRESS2
                                         + ord.ShipToCity + dqcdq                         //48	SHIP_TO_CITY
                                         + ord.ShipToState + dqcdq                        //49	SHIP_TO_STATE
                                         + ord.ShipToZip + dqcdq                          //50	SHIP_TO_ZIP

                                         + RESERVED + dqcdq                               //51	ORDER_HOLD_DATE
                                         + "CC" + dqcdq                                   //52	PAYMENT_METHOD
                                         + RESERVED + dqcdq                               //53	ACH_ROUTING_NUMBER
                                         + RESERVED + dqcdq                               //54	ACH_ACCOUNT_NUMBER
                                         + RESERVED + dqcdq                               //55	RESERVED

                                         + "N" + dqcdq                                    //56	USE_PRICES
                                         + PRICE01 + dqcdq                                //57	PRICE01
                                         + DISCOUNT01 + dqcdq                             //58	DISCOUNT01
                                         + PRICE02 + dqcdq                                //59	PRICE02
                                         + DISCOUNT02 + dqcdq                             //60	DISCOUNT02

                                         + PRICE03 + dqcdq                                //61	PRICE03
                                         + DISCOUNT03 + dqcdq                             //62	DISCOUNT03
                                         + PRICE04 + dqcdq                                //63	PRICE04
                                         + DISCOUNT04 + dqcdq                             //64	DISCOUNT04
                                         + PRICE05 + dqcdq                                //65	PRICE05

                                         + DISCOUNT05 + dqcdq                             //66	DISCOUNT05
                                         + "N" + dqcdq                                    //67	USE_SHIPPING
                                         + ord.ShippingTotal + dqcdq                      //68	SHIPPING
                                         + ord.Email + dqcdq                              //69	EMAIL
                                         + RESERVED + dqcdq                               //70	MERCHANT_TRANSACTION_ID

                                         + BCOUNTRY + dqcdq                               //71	COUNTRY USA = 001
                                         + SCOUNTRY + dqcdq                               //72	SCOUNTRY USA = 001
                                         + ord.BillingPhone + dqcdq                       //73	BILL_PHONE_2
                                         + ord.ShipToPhone + dqcdq                        //74	SHIP_TO_PHONE
                                         + RESERVED + dqcdq                               //75	RESERVED

                                         + RESERVED + dqcdq                               //76	RESERVED
                                         + RESERVED + dqcdq                               //77	RESERVED
                                         + RESERVED + dqcdq                               //78	RESERVED
                                         + RESERVED + dqcdq                               //79	CUSTOM_1
                                         + RESERVED + dqcdq                               //80	CUSTOM_2

                                         + RESERVED + dqcdq                               //81	CUSTOM_3
                                         + RESERVED + dqcdq                               //82	CUSTOM_4
                                         + RESERVED + dqcdq                               //83	CUSTOM_5
                                         + RESERVED + dqcdq                               //84	COUPON_CODE01
                                         + RESERVED + dqcdq                               //85	COUPON_CODE02

                                         + RESERVED + dqcdq                               //86	COUPON_CODE03
                                         + RESERVED + dqcdq                               //87	COUPON_CODE04
                                         + RESERVED + dqcdq                               //88	COUPON_CODE05
                                         + RESERVED + dqcdq                               //89	RESERVED
                                         + RESERVED + dqcdq                               //90	TRACKING_NUM
                                         + RESERVED + dqcdq
                                         + RESERVED + dqcdq                               //91	SHIPPING_CARRIER
                                         + RESERVED + dqcdq                               //92	SHIPPING_DATE
                                         + RESERVED + dqcdq                               //93	CLIENT_TRANSACTION_ID
                                         + ord.CVV + dqcdq                                //94	CVV_CODE
                                         + RESERVED + dqcdq                               //95	VOICE_RECORDING_ID

                                         + RESERVED + dqcdq                               //96	ACH_CHECK_NUMBER
                                         + ord.SalesTaxTotal + dqcdq                      //97	ORDER_STATE_SALES_TAX
                                         + "0" + dqcdq                                    //98	ORDER_FEDERAL_SALES_TAX
                                         + RESERVED + dqcdq                               //99	CUSTOMER_COMMENTS
                                         + RESERVED + dqcdq                               //100	ACH_IS_SAVINGS_ACCOUNT
                                         + RESERVED + dqcdq
                                         + RESERVED + dqcdq                               //101	CUSTOMER_AGE
                                         + RESERVED + dqcdq                               //102	CUSTOMER_DOB
                                         + RESERVED + dqcdq                               //103	CUSTOMER_GENDER
                                         + RESERVED + dqcdq                               //104	CUSTOMER_SSN
                                         + RESERVED + dqcdq                               //105	PACKING_SLIP_COMMENTS

                                         + RESERVED + dqcdq                               //106	ORDER_COMMENTS
                                         + RESERVED + dqcdq                               //107	LOCATION_CODE
                                         + dq;
                    SWtxtfile.WriteLine(OrderRecord);

                    #endregion
                }
                SWtxtfile.Flush();
                SWtxtfile.Close();
                log.LogToFile("   " + txtfilename + " - File Successfully created ");
                Console.WriteLine("   " + txtfilename + " - File Successfully created ");
            }
            catch (Exception e)
            {
                log.LogToFile("Error creating file ---" + e.Message);
                _breturn = false;
                SWtxtfile.Flush();
                SWtxtfile.Close();
                return(_breturn);
            }
            return(_breturn);
        }
Ejemplo n.º 5
0
        public void sendxml1(string verifyflag, string ordernumber)
        {
            _intOrderID = Convert.ToInt32(ordernumber);
            string key1           = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            string response1      = "";
            string DeclineToEmail = "";
            string FirstName      = "";
            string LastName       = "";

            _dtOrderSKU = null;
            _dtCustomerBillingAddress  = null;
            _dtCustomerShippingAddress = null;
            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            Mediachase.eCF.BusLayer.Common.Util.EncryptionManager em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

            string orderid1 = ordernumber;

            DataSet ds = new DataSet();

            ds = getsql("exec getorders4 " + orderid1.ToString());

            string s1a = getomxml(verifyflag, orderid1);

            decimal total1z;
            decimal shipping1z;

            //<UnitPrice>@4</UnitPrice>
            string stb = "<LineItem lineNumber=[[[@1[[[>~<ItemCode>@2</ItemCode>~<Quantity>@3</Quantity>~<UnitPrice>@4</UnitPrice>~<Recurrence patternID=[[[@5[[[></Recurrence>~@6~</LineItem>";

            stb = stb.Replace("~", ((char)(13)).ToString() + ((char)(10)).ToString());
            stb = stb.Replace("[[[", ((char)(34)).ToString());

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                string s1  = s1a;
                string cc1 = "";
                string cc2 = "";

                FirstName = r["billfirstname"].ToString();
                LastName  = r["billlastname"].ToString();
                s1        = s1.Replace("@billfirstname@", fixstring(r["billfirstname"]));

                s1 = s1.Replace("@billlastname@", fixstring(r["billlastname"]));
                s1 = s1.Replace("@billaddress@", fixstring(r["billaddress"]));
                s1 = s1.Replace("@billaddress2@", fixstring(r["billaddress2"]));

                s1 = s1.Replace("@billcity@", fixstring(r["billcity"]));
                s1 = s1.Replace("@billstate@", fixstring(r["billstate"]));
                s1 = s1.Replace("@billzip@", fixstring(r["billzip"]));
                DataSet dsCountry = getsql("select * from country where countryid = " + r["billcountry"]);
                s1 = s1.Replace("@billcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                DateTime d = new DateTime();
                d = Convert.ToDateTime(fixstring(r["orderdate"]));

                s1 = s1.Replace("@orderdate@", d.ToString("yyyy-MM-dd HH:MM:ss"));
                s1 = s1.Replace("@OrderDateFormat@", d.ToString("yyyy-MM-dd"));
                s1 = s1.Replace("@AffiliateID@", fixstring(r["affiliateid"]));
                s1 = s1.Replace("@CardAuthCode@", _TransactionId);// Will enter something in future.


                //s1 = s1.Replace("@keycode@", fixstring(r["keycode"]));
                s1 = s1.Replace("@orderid@", "CS" + fixstring(r["orderid"]));


                s1        = s1.Replace("@shipfirstname@", fixstring(r["shipfirstname"]));
                s1        = s1.Replace("@shiplastname@", fixstring(r["shiplastname"]));
                s1        = s1.Replace("@shipaddress@", fixstring(r["shipaddress"]));
                s1        = s1.Replace("@shipaddress2@", fixstring(r["shipaddress2"]));
                s1        = s1.Replace("@shipcity@", fixstring(r["shipcity"]));
                s1        = s1.Replace("@shipstate@", fixstring(r["shipstate"]));
                s1        = s1.Replace("@shipzip@", fixstring(r["shipzip"]));
                dsCountry = getsql("select * from country where countryid = " + r["shipcountry"]);
                s1        = s1.Replace("@shipcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                cc1 = r["creditcardnumber"].ToString();
                cc2 = em.Decrypt(cc1);

                s1             = s1.Replace("@cardnumber@", fixstring(cc2));
                s1             = s1.Replace("@cvv@", fixstring(r["creditcardcsc"]));
                s1             = s1.Replace("@cardexpmonth@", fixstring(r["creditcardexpiredmonth"]));
                s1             = s1.Replace("@cardexpyear@", fixstring(r["creditcardexpiredyear"]));
                s1             = s1.Replace("@1@", fixstring(r["phonenumber"]));
                s1             = s1.Replace("@2@", fixstring(r["email"]));
                DeclineToEmail = fixstring(r["email"]);
                total1z        = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z     = Convert.ToDecimal(r["shippingamount"].ToString());
                decimal cust1 = Convert.ToDecimal("0");
                string  stc   = "";
                string  stc1  = "";
                int     cnt;
                cnt = 0;
                decimal price1;
                decimal price2;
                int     qty1;
                int     qty2;
                decimal price2b = 0;
                string  coupcode;
                bool    extra;
                string  rep1    = "no";
                string  method1 = fixstring(r["methodcode"]);
                foreach (DataRow r1 in OrderSKU.Rows)
                {
                    if (r1["skuid"].ToString().Contains("389") || r1["skuid"].ToString().Contains("390") || r1["skuid"].ToString().Contains("337") || r1["skuid"].ToString().Contains("392") || r1["skuid"].ToString().Contains("393") || r1["skuid"].ToString().Contains("394") || r1["skuid"].ToString().Contains("395"))
                    {
                        continue;
                    }
                    cnt++;
                    stc1     = stc;
                    stc     += stb;
                    stc      = stc.Replace("@1", cnt.ToString());
                    stc      = stc.Replace("@2", fixstring(r1["skucode"].ToString()).Replace(" ", "").Replace("-", ""));
                    qty1     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    qty2     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    price1   = Convert.ToDecimal(r1["Fullprice"].ToString());
                    price2b  = price1;
                    coupcode = "";
                    extra    = false;
                    if (r1["skuid"].ToString().Contains("334"))
                    {
                        qty2   = 2;
                        price1 = 14.95M;
                    }

                    //Console.WriteLine("total1:" + total1.ToString());
                    stc = stc.Replace("@3", qty2.ToString());
                    stc = stc.Replace("@4", fixstring(price1.ToString()));
                    stc = stc.Replace("@5", "");
                    stc = stc.Replace("@5", "");
                    try
                    {
                        DateTime w = new DateTime();
                        if (Convert.ToDecimal(r["shippingamount"].ToString()) < 8)
                        {
                            w   = d.AddDays(2);
                            stc = stc.Replace("@6", "<WaitDate>" + w.ToString("MM-dd-yyyy") + "</WaitDate>");
                        }
                        else
                        {
                            stc = stc.Replace("@6", "");
                        }
                    }
                    catch { }
                    if (r1["skuid"].ToString().Contains("337") || r1["skuid"].ToString().Contains("338"))
                    {
                        rep1 = "yes";
                    }
                }
                string cardstatus = "";
                cardstatus = "0";
                string st1   = "";
                int    cnt39 = 0;

                if (PaymentPlanSKU.Contains("389") || PaymentPlanSKU.Contains("390") || PaymentPlanSKU.Contains("337") || PaymentPlanSKU.Contains("394"))
                {
                    s1 = s1.Replace("@methodcode@", "12");
                }
                else if (PaymentPlanSKU.Contains("392") || PaymentPlanSKU.Contains("393") || PaymentPlanSKU.Contains("395"))
                {
                    s1 = s1.Replace("@methodcode@", "13");
                }
                else
                {
                    s1 = s1.Replace("@methodcode@", "0");
                }
                if (r["sid"] != null)
                {
                    try
                    {
                        s1 = s1.Replace("@siteid@", Helper.SID[r["sid"].ToString().ToUpper()].ToString());
                    }
                    catch (Exception)
                    {
                        s1 = s1.Replace("@siteid@", "");
                    }
                }
                else
                {
                    s1 = s1.Replace("@siteid@", "");
                }
                total1z    = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z = Convert.ToDecimal(r["shippingamount"].ToString());
                s1         = s1.Replace("@total@", fixstring(total1z.ToString()));
                s1         = s1.Replace("@shippingamount@", fixstring(shipping1z.ToString()));
                s1         = s1.Replace("@rep@", rep1);
                stc        = "<OrderDetail>" + stc + "</OrderDetail>";
                s1         = s1.Replace("<OrderDetail>@orderdetailstuff@</OrderDetail>", stc);
                string s2  = "";
                string url = "https://api.omx.ordermotion.com/hdde/xml/udi.asp";
                s2 = HttpPost(url, s1);
                //<TotalMerchandise>99.98</TotalMerchandise>

                //Decimal tax3 = Convert.ToDecimal(fixempty(getfromto(s2, "<Tax>", "</Tax>")))/Convert.ToDecimal(Session["numpay"].ToString());
                response1 = s2;
                decimal salesTax = 0;
                if (response1 != "")
                {
                    string CheckSuccess = "";
                    try
                    {
                        CheckSuccess = getfromto(response1, "<Success>", "</Success>");
                        if (CheckSuccess.Equals("1"))
                        {
                            if (verifyflag.ToString().Equals("True"))
                            {
                                salesTax = Convert.ToDecimal(fixempty(getfromto(response1, "<Tax>", "</Tax>")));
                                runsql("update [order] set orderstatusid = 2, Request='" + ClearAccents(fixQuot(s1)) + "', Response = '" + ClearAccents(fixQuot(response1)) + "', tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                                runsql("update [ordershipment] set tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                            }
                            else
                            {
                                runsql("update [order] set orderstatusid = 2, Authorizationcode='" + _TransactionId + "',  Request1='" + ClearAccents(fixQuot(s1)) + "', Response1 = '" + ClearAccents(fixQuot(response1)) + "', tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                            }
                        }
                        else
                        {
                            runsql("update [order] set orderstatusid = 2, Request='" + ClearAccents(fixQuot(s1)) + "', Response = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Error While sending message---" + E.Message);
                    }
                }
                response1 = "";
                s1        = "";
            }
        }
Ejemplo n.º 6
0
        public void sendxml1(string verifyflag, string ordernumber)
        {
            _intOrderID = Convert.ToInt32(ordernumber);
            string key1           = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            string response1      = "";
            string DeclineToEmail = "";
            string FirstName      = "";
            string LastName       = "";

            _dtOrderSKU = null;
            _dtCustomerBillingAddress  = null;
            _dtCustomerShippingAddress = null;
            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            Mediachase.eCF.BusLayer.Common.Util.EncryptionManager em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

            string orderid1 = ordernumber;

            DataSet ds = new DataSet();

            ds = getsql("exec getorders4 " + orderid1.ToString());

            string s1a = getomxml(verifyflag, orderid1);

            decimal total1z;
            decimal shipping1z;

            //<UnitPrice>@4</UnitPrice>

            // string stb = "<LineItem lineNumber=[[[@1[[[>~<PaymentPlanID>@paymentplan@</PaymentPlanID><ItemCode>@2</ItemCode>~<Quantity>@3</Quantity>~<UnitPrice>@4</UnitPrice>~@6~@7</LineItem>";
            string stb = "<LineItem lineNumber=[[[@1[[[>~<ItemCode>@2</ItemCode>@PayPlan<Quantity>@3</Quantity>~<UnitPrice>@4</UnitPrice>~<Recurrence patternID=[[[@5[[[></Recurrence>~</LineItem>";

            stb = stb.Replace("~", ((char)(13)).ToString() + ((char)(10)).ToString());
            stb = stb.Replace("[[[", ((char)(34)).ToString());

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                string s1  = s1a;
                string cc1 = "";
                string cc2 = "";

                FirstName = r["billfirstname"].ToString();
                LastName  = r["billlastname"].ToString();
                s1        = s1.Replace("@billfirstname@", fixstring(r["billfirstname"]));

                s1 = s1.Replace("@billlastname@", fixstring(r["billlastname"]));
                s1 = s1.Replace("@billaddress@", fixstring(r["billaddress"]));
                s1 = s1.Replace("@billaddress2@", fixstring(r["billaddress2"]));

                s1 = s1.Replace("@billcity@", fixstring(r["billcity"]));
                s1 = s1.Replace("@billstate@", fixstring(r["billstate"]));
                s1 = s1.Replace("@billzip@", fixstring(r["billzip"]));
                DataSet dsCountry = getsql("select * from country where countryid = " + r["billcountry"]);
                s1 = s1.Replace("@billcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                DateTime d = new DateTime();
                d = Convert.ToDateTime(fixstring(r["orderdate"]));

                s1 = s1.Replace("@orderdate@", d.ToString("yyyy-MM-dd HH:MM:ss"));
                s1 = s1.Replace("@OrderDateFormat@", d.ToString("yyyy-MM-dd"));
                s1 = s1.Replace("@AffiliateID@", fixstring(r["affiliateid"]));
                s1 = s1.Replace("@CardAuthCode@", _AuthCode);// Will enter something in future.

                //s1 = s1.Replace("@keycode@", fixstring(r["keycode"]));
                s1 = s1.Replace("@orderid@", "CS_N_GIFTCARD" + fixstring(r["orderid"]));

                s1        = s1.Replace("@shipfirstname@", fixstring(r["shipfirstname"]));
                s1        = s1.Replace("@shiplastname@", fixstring(r["shiplastname"]));
                s1        = s1.Replace("@shipaddress@", fixstring(r["shipaddress"]));
                s1        = s1.Replace("@shipaddress2@", fixstring(r["shipaddress2"]));
                s1        = s1.Replace("@shipcity@", fixstring(r["shipcity"]));
                s1        = s1.Replace("@shipstate@", fixstring(r["shipstate"]));
                s1        = s1.Replace("@shipzip@", fixstring(r["shipzip"]));
                dsCountry = getsql("select * from country where countryid = " + r["shipcountry"]);
                s1        = s1.Replace("@shipcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                if (r["ipaddress"] != null && r["ipaddress"].ToString() != "")
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(em.Decrypt(r["ipaddress"].ToString())));
                }
                else
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(""));
                }
                s1 = s1.Replace("@cardnumber@", fixstring(cc2));
                s1 = s1.Replace("@cvv@", fixstring(r["creditcardcsc"]));
                s1 = s1.Replace("@cardexpmonth@", fixstring(r["creditcardexpiredmonth"]));
                s1 = s1.Replace("@cardexpyear@", fixstring(r["creditcardexpiredyear"]));
                s1 = s1.Replace("@1@", fixstring(r["phonenumber"]));
                s1 = s1.Replace("@2@", fixstring(r["email"]));

                DeclineToEmail = fixstring(r["email"]);
                total1z        = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z     = Convert.ToDecimal(r["shippingamount"].ToString());
                decimal cust1 = Convert.ToDecimal("0");
                string  stc   = "";
                string  stc1  = "";
                int     cnt;
                cnt = 0;
                decimal price1;
                decimal price2;
                int     qty1;
                int     qty2;
                decimal price2b = 0;
                string  coupcode;
                bool    extra;
                string  rep1    = "no";
                string  method1 = fixstring(r["methodcode"]);

                foreach (DataRow r1 in OrderSKU.Rows)
                {
                    if (r1["GiftCardCode"] != null && !(r1["GiftCardCode"].ToString().Length > 1))
                    {
                        continue;
                    }
                    cnt++;
                    stc1 = stc;
                    stc += stb;
                    stc  = stc.Replace("@1", cnt.ToString());

                    string[] gcInfo = null;
                    if (r1["GiftCardCode"] != null)
                    {
                        gcInfo = r1["GiftCardCode"].ToString().Split(';');
                    }
                    stc     = stc.Replace("@2", fixstring(gcInfo[0].ToString())); // stc.Replace("@2", fixstring(r1["skucode"].ToString()).Replace(" ", ""));
                    qty1    = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    qty2    = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    price1  = Convert.ToDecimal(gcInfo[1].ToString());
                    price2b = price1;

                    coupcode = "";
                    extra    = false;
                    //Console.WriteLine("total1:" + total1.ToString());
                    stc = stc.Replace("@3", qty2.ToString());
                    stc = stc.Replace("@4", fixstring(price1.ToString()));
                    stc = stc.Replace("@PayPlan", "");
                    stc = stc.Replace("@5", "");
                    stc = stc.Replace("@PayPlan", "");
                    stc = stc.Replace("@paymentplan@", "");


                    stc = stc.Replace("@6", "");
                    stc = stc.Replace("@7", "");
                    stc = stc.Replace("[[[", ((char)(34)).ToString());
                    //string keycode = r1["keyCode"].ToString();
                    //s1 = s1.Replace("@keyCode@", r1["keyCode"].ToString());
                }

                string cardstatus = "";
                cardstatus = "0";
                string st1   = "";
                int    cnt39 = 0;
                s1         = s1.Replace("@methodcode@", "0");
                total1z    = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z = Convert.ToDecimal(r["shippingamount"].ToString());
                s1         = s1.Replace("@siteid@", "");
                s1         = s1.Replace("@total@", fixstring(total1z.ToString()));
                s1         = s1.Replace("@shippingamount@", fixstring(shipping1z.ToString()));
                // s1 = s1.Replace("@rep@", rep1);
                stc = "<OrderDetail>" + stc + "</OrderDetail>";
                s1  = s1.Replace("<OrderDetail>@orderdetailstuff@</OrderDetail>", stc);
                string s2  = "";
                string url = Helper.AppSettings["OMXUrl"].ToString();
                s2 = HttpPost(url, s1);

                //<TotalMerchandise>99.98</TotalMerchandise>

                //Decimal tax3 = Convert.ToDecimal(fixempty(getfromto(s2, "<Tax>", "</Tax>")))/Convert.ToDecimal(Session["numpay"].ToString());
                response1 = s2;
                decimal salesTax = 0;
                if (response1 != "")
                {
                    string CheckSuccess = "";
                    try
                    {
                        CheckSuccess = getfromto(response1, "<Success>", "</Success>");
                        if (CheckSuccess.Equals("1"))
                        {
                            runsql("update [order] set RequestGift='" + ClearAccents(fixQuot(s1)) + "', ResponseGift = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                        }
                    }
                    catch (Exception E)
                    {
                        sendEmailToAdmin(response1 + "<br />" + E.Message, ordernumber);
                        Console.WriteLine("Error While sending message---" + E.Message);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void UploadOrdersToOrderMotion()
        {
            key1 = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();
            try
            {
                foreach (DataRow _drOrder in Orders.Rows)
                {
                    try
                    {
                        if (_drOrder["OrderId"].ToString() != null)
                        {
                            sendxml1("True", _drOrder["OrderId"].ToString());


                            if (_drOrder["ConfirmationCode"] != null)
                            {
                                if (_drOrder["ConfirmationCode"].ToString().Length > 2)
                                {
                                    _TransactionId = _drOrder["Authorizationcode"].ToString();
                                    sendxml1("False", _drOrder["OrderId"].ToString());
                                }
                                else
                                {
                                    if (DoAuthorization(_drOrder["OrderId"].ToString()))
                                    {
                                        sendxml1("False", _drOrder["OrderId"].ToString());
                                    }
                                    else
                                    {
                                        //update the order tabe for coloum authStaus and orderstatusid = 7.
                                        runsql("update [order] set orderstatusid = 7, AuthStatus = 'False' where orderid= " + _drOrder["OrderId"].ToString());
                                        try
                                        { sendDeclineEmail(DeclineToEmail, FirstName, LastName); }
                                        catch { }
                                    }
                                }
                            }
                            else
                            {
                                if (DoAuthorization(_drOrder["OrderId"].ToString()))
                                {
                                    sendxml1("False", _drOrder["OrderId"].ToString());
                                }
                                else
                                {
                                    //update the order tabe for coloum authStaus and orderstatusid = 7.
                                    runsql("update [order] set orderstatusid = 7, AuthStatus = 'False' where orderid= " + _drOrder["OrderId"].ToString());
                                    try
                                    { sendDeclineEmail(DeclineToEmail, FirstName, LastName); }
                                    catch { }
                                }
                            }
                        }

                        _dtOrderSKU = null;
                    }
                    catch (Exception e) { }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while uploading orders -- " + e.Message);
            }
        }
Ejemplo n.º 8
0
        public void sendxml1(string verifyflag, string ordernumber)
        {
            _intOrderID = Convert.ToInt32(ordernumber);
            _dtOrderSKU = null;
            string key1           = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            string response1      = "";
            string DeclineToEmail = "";
            string FirstName      = "";
            string LastName       = "";

            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            Mediachase.eCF.BusLayer.Common.Util.EncryptionManager em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

            string orderid1 = ordernumber;

            DataSet ds = new DataSet();

            ds = getsql("exec getorders4 " + orderid1.ToString());

            string s1a = getomxml(verifyflag, orderid1);

            decimal total1z;
            decimal shipping1z;

            //<UnitPrice>@4</UnitPrice>
            string stb = "<LineItem lineNumber=[[[@1[[[>~<PaymentPlanID>@0</PaymentPlanID>~<ItemCode>@2</ItemCode>~<Quantity>@3</Quantity>~<UnitPrice>@4</UnitPrice>~<Recurrence patternID=[[[@5[[[></Recurrence>~</LineItem>";

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                //If PayPal orders then we do not need PaymentPlanId to be passed at all so below line takes care of that
                if (r["CreditCardName"].ToString().ToUpper().Equals("PAYPAL"))
                {
                    stb = "<LineItem lineNumber=[[[@1[[[>~<ItemCode>@2</ItemCode>~<Quantity>@3</Quantity>~<UnitPrice>@4</UnitPrice>~<Recurrence patternID=[[[@5[[[></Recurrence>~</LineItem>";
                }
                stb = stb.Replace("~", ((char)(13)).ToString() + ((char)(10)).ToString());
                stb = stb.Replace("[[[", ((char)(34)).ToString());

                string s1                    = s1a;
                string cc1                   = "";
                string cc2                   = "";
                string strPayment            = "";
                string strBillingAgreementId = "";


                if (r["CreditCardName"].ToString().ToUpper().Equals("PAYPAL"))
                {
                    strPayment  = "";
                    strPayment += "	<Payment type=[[[13[[[>~";
                    strPayment += "		<PaidAmount>@AuthorizationAmount@</PaidAmount>~";
                    strPayment += "		<TransactionID>@TranasactionID@</TransactionID>~";
                    strPayment += "		<PayerID>@PayerID@</PayerID>~";
                    strPayment += "		<BuyerEmail>@BuyerEmail@</BuyerEmail>~";
                    strPayment += "		<PayPalTransactionType>1</PayPalTransactionType>~";
                    strPayment += "	</Payment>~";
                }
                else
                {
                    strPayment += "	<Payment type=[[[1[[[>~";
                    strPayment += "		<CardNumber>@cardnumber@</CardNumber>~";
                    strPayment += "		<CardVerification>@cvv@</CardVerification>~";
                    strPayment += "		<CardExpDateMonth>@cardexpmonth@</CardExpDateMonth>~";
                    strPayment += "		<CardExpDateYear>@cardexpyear@</CardExpDateYear>~";
                    strPayment += "		<RealTimeCreditCardProcessing>False</RealTimeCreditCardProcessing>~";
                    strPayment += "		<CardStatus>11</CardStatus>~";
                    strPayment += "		<CardAuthCode>@CardAuthCode@</CardAuthCode>~";
                    strPayment += "	</Payment>~";
                }
                strPayment = strPayment.Replace("[[[", ((char)(34)).ToString());
                strPayment = strPayment.Replace("~", ((char)(13)).ToString() + ((char)(10)).ToString());

                s1 = s1.Replace("@@paymentInfo@@", strPayment.ToString());

                //updating above params:

                try
                {
                    NameValueCollection nvcQueryString = null;
                    nvcQueryString = HttpUtility.ParseQueryString(HttpUtility.HtmlDecode(r["PaypalResponse"].ToString()));
                    if (nvcQueryString["BILLINGAGREEMENTID"] != null)
                    {
                        strBillingAgreementId = nvcQueryString["BILLINGAGREEMENTID"].ToString();
                    }
                }
                catch { }

                s1 = s1.Replace("@AuthorizationAmount@", Math.Round(Convert.ToDecimal(fixstring(r["totalamount"])), 2).ToString());
                s1 = s1.Replace("@TranasactionID@", _TransactionId);
                s1 = s1.Replace("@PayerID@", _AuthCode);
                s1 = s1.Replace("@BuyerEmail@", fixstring(r["email"]));
                s1 = s1.Replace("@PayPalBillingAgreementID@", fixstring(strBillingAgreementId));
                s1 = s1.Replace("@BuyerEmail@", fixstring(r["email"]));



                FirstName = r["billfirstname"].ToString();
                LastName  = r["billlastname"].ToString();
                s1        = s1.Replace("@billfirstname@", ClearAccents(fixstring(r["billfirstname"])));

                s1 = s1.Replace("@billlastname@", ClearAccents(fixstring(r["billlastname"])));
                s1 = s1.Replace("@billaddress@", ClearAccents(fixstring(r["billaddress"])));
                s1 = s1.Replace("@billaddress2@", ClearAccents(fixstring(r["billaddress2"])));

                s1 = s1.Replace("@billcity@", fixstring(r["billcity"]));
                //s1 = s1.Replace("@billstate@", fixstring(r["billstate"]));
                s1 = s1.Replace("@billstate@", "");
                s1 = s1.Replace("@billzip@", fixstring(r["billzip"]));

                DataSet dsCountry = getsql("select * from country where countryid = " + r["billcountry"]);
                s1 = s1.Replace("@billcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                DateTime d = new DateTime();
                d = Convert.ToDateTime(fixstring(r["orderdate"]));

                s1 = s1.Replace("@orderdate@", d.ToString("yyyy-MM-dd HH:MM:ss"));
                s1 = s1.Replace("@OrderDateFormat@", d.ToString("yyyy-MM-dd"));
                s1 = s1.Replace("@AffiliateID@", fixstring(r["affiliateid"]));
                s1 = s1.Replace("@CardAuthCode@", _AuthCode);// Will enter something in future.



                s1 = s1.Replace("@keycode@", fixstring(r["keycode"]));
                s1 = s1.Replace("@orderid@", "NONOSKINUK" + fixstring(r["orderid"]));


                s1 = s1.Replace("@shipfirstname@", ClearAccents(fixstring(r["shipfirstname"])));
                s1 = s1.Replace("@shiplastname@", ClearAccents(fixstring(r["shiplastname"])));
                s1 = s1.Replace("@shipaddress@", ClearAccents(fixstring(r["shipaddress"])));
                s1 = s1.Replace("@shipaddress2@", ClearAccents(fixstring(r["shipaddress2"])));
                s1 = s1.Replace("@shipcity@", fixstring(r["shipcity"]));
                //s1 = s1.Replace("@shipstate@", fixstring(r["shipstate"]));
                s1        = s1.Replace("@shipstate@", "");
                s1        = s1.Replace("@shipzip@", fixstring(r["shipzip"]));
                dsCountry = getsql("select * from country where countryid = " + r["shipcountry"]);
                s1        = s1.Replace("@shipcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                cc1 = r["creditcardnumber"].ToString();
                cc2 = em.Decrypt(cc1);
                if (r["ipaddress"] != null && r["ipaddress"].ToString() != "")
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(em.Decrypt(r["ipaddress"].ToString())));
                }
                else
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(""));
                }
                s1 = s1.Replace("@cardnumber@", fixstring(cc2));
                s1 = s1.Replace("@cvv@", fixstring(r["creditcardcsc"]));
                s1 = s1.Replace("@cardexpmonth@", fixstring(r["creditcardexpiredmonth"]));
                s1 = s1.Replace("@cardexpyear@", fixstring(r["creditcardexpiredyear"]));
                s1 = s1.Replace("@1@", fixstring(r["phonenumber"]));
                s1 = s1.Replace("@2@", fixstring(r["email"]));
                if (r["ipaddress"] != null)
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(em.Decrypt(r["ipaddress"].ToString())));
                }
                DeclineToEmail = fixstring(r["email"]);
                total1z        = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z     = Convert.ToDecimal(r["shippingamount"].ToString());
                decimal cust1 = Convert.ToDecimal("0");
                string  stc   = "";
                string  stc1  = "";
                int     cnt;
                cnt = 0;
                decimal price1;
                decimal price2;
                int     qty1;
                int     qty2;
                decimal price2b = 0;
                string  coupcode;
                bool    extra;

                string method1 = fixstring(r["methodcode"]);

                foreach (DataRow r1 in OrderSKU.Rows)
                {
                    if (r1["skuid"].ToString().Equals("336"))
                    {
                        continue;
                    }
                    cnt++;
                    stc1 = stc;
                    stc += stb;
                    stc  = stc.Replace("@1", cnt.ToString());
                    if (r1["skuid"].ToString().Equals("371") || r1["skuid"].ToString().Equals("373") || r1["skuid"].ToString().Equals("354") || r1["skuid"].ToString().Equals("361") || r1["skuid"].ToString().Equals("363"))
                    {
                        stc = stc.Replace("@0", "1");
                    }
                    else
                    {
                        stc = stc.Replace("@0", "0");
                    }
                    if (r1["skucode"].ToString().Equals("CONTINUITY"))
                    {
                        stc = stc.Replace("@2", "");
                    }
                    else
                    {
                        stc = stc.Replace("@2", fixstring(r1["skucode"].ToString()).Replace(" ", ""));
                    }
                    qty1     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    qty2     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    price1   = Convert.ToDecimal(r1["Fullprice"].ToString());
                    price2b  = price1;
                    coupcode = "";
                    extra    = false;
                    //Console.WriteLine("total1:" + total1.ToString());
                    stc = stc.Replace("@3", qty2.ToString());
                    stc = stc.Replace("@4", fixstring(price1.ToString()));
                    if (r1["skuid"].ToString().Equals("327") || r1["skuid"].ToString().Equals("330") || r1["skuid"].ToString().Equals("331") || r1["skuid"].ToString().Equals("332") || r1["skuid"].ToString().Equals("380") || r1["skuid"].ToString().Equals("381") || r1["skuid"].ToString().Equals("383") || r1["skuid"].ToString().Equals("384") || r1["skuid"].ToString().Equals("332") || r1["skuid"].ToString().Equals("340") || r1["skuid"].ToString().Equals("341") || r1["skuid"].ToString().Equals("342") || r1["skuid"].ToString().Equals("343") || r1["skuid"].ToString().Equals("364") || r1["skuid"].ToString().Equals("365") || r1["skuid"].ToString().Equals("368") || r1["skuid"].ToString().Equals("369") || r1["skuid"].ToString().Equals("350") || r1["skuid"].ToString().Equals("357") || r1["skuid"].ToString().Equals("359") || r1["skuid"].ToString().Equals("360"))
                    {
                        if (PaymentPlanSKU.Contains("336") || PaymentPlanSKU.Contains("365") || PaymentPlanSKU.Contains("369"))
                        {
                            stc = stc.Replace("@5", "1");
                        }
                        else
                        {
                            stc = stc.Replace("@5", "");
                        }
                    }
                    else
                    {
                        stc = stc.Replace("@5", "");
                    }
                }
                if (PaymentPlanSKU.Contains("340") || PaymentPlanSKU.Contains("341") || PaymentPlanSKU.Contains("342") || PaymentPlanSKU.Contains("343") || PaymentPlanSKU.Contains("344") || PaymentPlanSKU.Contains("345") || PaymentPlanSKU.Contains("346") || PaymentPlanSKU.Contains("347"))
                {
                    cnt++;
                    stc += stb;
                    stc  = stc.Replace("@1", cnt.ToString());
                    stc  = stc.Replace("@2", fixstring("2YRWAR".ToString()).Replace(" ", "").Replace("-", ""));
                    stc  = stc.Replace("@3", "1".ToString());
                    stc  = stc.Replace("@4", fixstring("0".ToString()));
                    stc  = stc.Replace("@5", "");
                }
                string cardstatus = "";
                cardstatus = "0";
                string st1   = "";
                int    cnt39 = 0;

                if (dsCountry.Tables[0].Rows[0]["Code"].ToString().ToLower().Equals("uk"))
                {
                    if (PaymentPlanSKU.Contains("354"))
                    {
                        s1 = s1.Replace("@methodcode@", "1");
                    }
                    else if (PaymentPlanSKU.Contains("361") || PaymentPlanSKU.Contains("363"))
                    {
                        s1 = s1.Replace("@methodcode@", "12");
                    }
                    else if (PaymentPlanSKU.Contains("360") || PaymentPlanSKU.Contains("362"))
                    {
                        s1 = s1.Replace("@methodcode@", "13");
                    }
                    else
                    {
                        s1 = s1.Replace("@methodcode@", "2");
                    }
                }
                else if (dsCountry.Tables[0].Rows[0]["Code"].ToString().ToLower().Equals("ie") || dsCountry.Tables[0].Rows[0]["Code"].ToString().ToLower().Equals("cha") || dsCountry.Tables[0].Rows[0]["Code"].ToString().ToLower().Equals("je") || dsCountry.Tables[0].Rows[0]["Code"].ToString().ToLower().Equals("gg"))
                {
                    s1 = s1.Replace("@methodcode@", "14");
                }
                else
                {
                    s1 = s1.Replace("@methodcode@", "3");
                }
                total1z    = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z = Convert.ToDecimal(r["shippingamount"].ToString());
                s1         = s1.Replace("@total@", fixstring(total1z.ToString()));
                s1         = s1.Replace("@shippingamount@", fixstring(shipping1z.ToString()));
                stc        = "<OrderDetail>" + stc + "</OrderDetail>";
                s1         = s1.Replace("<OrderDetail>@orderdetailstuff@</OrderDetail>", stc);
                string s2  = "";
                string url = Helper.AppSettings["OMXUrl"].ToString();
                s2 = HttpPost(url, s1);
                //<TotalMerchandise>99.98</TotalMerchandise>

                //Decimal tax3 = Convert.ToDecimal(fixempty(getfromto(s2, "<Tax>", "</Tax>")))/Convert.ToDecimal(Session["numpay"].ToString());
                response1 = s2;
                decimal salesTax = 0;
                if (response1 != "")
                {
                    string CheckSuccess = "";
                    try
                    {
                        CheckSuccess = getfromto(response1, "<Success>", "</Success>");
                        if (CheckSuccess.Equals("1"))
                        {
                            if (verifyflag.ToString().Equals("True"))
                            {
                                //we are not recording sales tax for UK Site.
                                salesTax = Convert.ToDecimal(fixempty(getfromto(response1, "<Tax>", "</Tax>")));
                                runsql("update [order] set orderstatusid = 2, Request='" + ClearAccents(fixQuot(s1)) + "', Response = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                                //runsql("update [ordershipment] set tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                            }
                            else
                            {
                                runsql("update [order] set orderstatusid = 2, Authorizationcode='" + _AuthCode + "',  Request1='" + ClearAccents(fixQuot(s1)) + "', Response1 = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                            }
                        }
                        else
                        {
                            runsql("update [order] set orderstatusid = 2, Request='" + ClearAccents(fixQuot(s1)) + "', Response = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Error While sending message---" + E.Message);
                    }
                }
                response1   = "";
                s1          = "";
                _dtOrderSKU = null;
            }
        }
Ejemplo n.º 9
0
        public void sendxml1(string verifyflag, string ordernumber)
        {
            _intOrderID = Convert.ToInt32(ordernumber);
            string key1           = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            string response1      = "";
            string DeclineToEmail = "";
            string FirstName      = "";
            string LastName       = "";

            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            Mediachase.eCF.BusLayer.Common.Util.EncryptionManager em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

            string orderid1 = ordernumber;

            DataSet ds = new DataSet();

            ds = getsql("exec getorders4 " + orderid1.ToString());

            string s1a = getomxml(verifyflag, orderid1);

            decimal total1z;
            decimal shipping1z;

            //<UnitPrice>@4</UnitPrice>
            string stb = "<LineItem lineNumber=[[[@1[[[>~<ItemCode>@2</ItemCode>@PayPlan<Quantity>@3</Quantity>~<UnitPrice>@4</UnitPrice>~<Recurrence patternID=[[[@5[[[></Recurrence>~</LineItem>";

            stb = stb.Replace("~", ((char)(13)).ToString() + ((char)(10)).ToString());
            stb = stb.Replace("[[[", ((char)(34)).ToString());

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                string s1  = s1a;
                string cc1 = "";
                string cc2 = "";

                FirstName = r["billfirstname"].ToString();
                LastName  = r["billlastname"].ToString();
                s1        = s1.Replace("@billfirstname@", ClearAccents(fixstring(r["billfirstname"])));

                s1 = s1.Replace("@billlastname@", ClearAccents(fixstring(r["billlastname"])));
                s1 = s1.Replace("@billaddress@", ClearAccents(fixstring(r["billaddress"])));
                s1 = s1.Replace("@billaddress2@", ClearAccents(fixstring(r["billaddress2"])));

                s1 = s1.Replace("@billcity@", fixstring(r["billcity"]));
                s1 = s1.Replace("@billstate@", fixstring(r["billstate"]));
                s1 = s1.Replace("@billzip@", fixstring(r["billzip"]));

                DataSet dsCountry = getsql("select * from country where countryid = " + r["billcountry"]);
                s1 = s1.Replace("@billcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                DateTime d = new DateTime();
                d = Convert.ToDateTime(fixstring(r["orderdate"]));

                s1 = s1.Replace("@orderdate@", d.ToString("yyyy-MM-dd HH:MM:ss"));
                s1 = s1.Replace("@OrderDateFormat@", d.ToString("yyyy-MM-dd"));
                s1 = s1.Replace("@AffiliateID@", fixstring(r["affiliateid"]));
                s1 = s1.Replace("@CardAuthCode@", _TransactionId);// Will enter something in future.



                s1 = s1.Replace("@keycode@", fixstring(r["keycode"]));
                s1 = s1.Replace("@orderid@", "NONOSKIN" + fixstring(r["orderid"]));


                s1        = s1.Replace("@shipfirstname@", ClearAccents(fixstring(r["shipfirstname"])));
                s1        = s1.Replace("@shiplastname@", ClearAccents(fixstring(r["shiplastname"])));
                s1        = s1.Replace("@shipaddress@", ClearAccents(fixstring(r["shipaddress"])));
                s1        = s1.Replace("@shipaddress2@", ClearAccents(fixstring(r["shipaddress2"])));
                s1        = s1.Replace("@shipcity@", fixstring(r["shipcity"]));
                s1        = s1.Replace("@shipstate@", fixstring(r["shipstate"]));
                s1        = s1.Replace("@shipzip@", fixstring(r["shipzip"]));
                dsCountry = getsql("select * from country where countryid = " + r["shipcountry"]);
                s1        = s1.Replace("@shipcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                cc1 = r["creditcardnumber"].ToString();
                cc2 = em.Decrypt(cc1);
                if (r["ipaddress"] != null && r["ipaddress"].ToString() != "")
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(em.Decrypt(r["ipaddress"].ToString())));
                }
                else
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(""));
                }

                s1             = s1.Replace("@cardnumber@", fixstring(cc2));
                s1             = s1.Replace("@cvv@", fixstring(r["creditcardcsc"]));
                s1             = s1.Replace("@cardexpmonth@", fixstring(r["creditcardexpiredmonth"]));
                s1             = s1.Replace("@cardexpyear@", fixstring(r["creditcardexpiredyear"]));
                s1             = s1.Replace("@1@", fixstring(r["phonenumber"]));
                s1             = s1.Replace("@2@", fixstring(r["email"]));
                DeclineToEmail = fixstring(r["email"]);
                total1z        = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z     = Convert.ToDecimal(r["shippingamount"].ToString());
                decimal cust1 = Convert.ToDecimal("0");
                string  stc   = "";
                string  stc1  = "";
                int     cnt;
                cnt = 0;
                decimal price1;
                decimal price2;
                int     qty1;
                int     qty2;
                decimal price2b = 0;
                string  coupcode;
                bool    extra;

                string method1 = fixstring(r["methodcode"]);

                foreach (DataRow r1 in OrderSKU.Rows)
                {
                    //340 and 341 are rush sku's we dont need to pass them to OMX. Is used to identify if rush is needed or not and methodcode is set appropriately.

                    if (r1["skuid"].ToString().Equals("336") || r1["skuid"].ToString().Equals("340") || r1["skuid"].ToString().Equals("341"))
                    {
                        continue;
                    }
                    cnt++;
                    stc1 = stc;
                    stc += stb;
                    stc  = stc.Replace("@1", cnt.ToString());
                    if (r1["skucode"].ToString().Equals("CONTINUITY"))
                    {
                        stc = stc.Replace("@2", "");
                    }
                    else
                    {
                        stc = stc.Replace("@2", fixstring(r1["skucode"].ToString()).Replace(" ", ""));
                    }
                    qty1     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    qty2     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    price1   = Convert.ToDecimal(r1["Fullprice"].ToString());
                    price2b  = price1;
                    coupcode = "";
                    extra    = false;
                    //Console.WriteLine("total1:" + total1.ToString());
                    stc = stc.Replace("@3", qty2.ToString());
                    stc = stc.Replace("@4", fixstring(price1.ToString()));
                    if (PaymentPlanSKU.Contains("365") ||
                        PaymentPlanSKU.Contains("367") ||
                        PaymentPlanSKU.Contains("369") ||
                        PaymentPlanSKU.Contains("371") ||
                        PaymentPlanSKU.Contains("373") ||
                        PaymentPlanSKU.Contains("375") ||
                        PaymentPlanSKU.Contains("377") ||
                        PaymentPlanSKU.Contains("379") ||
                        PaymentPlanSKU.Contains("381") ||
                        PaymentPlanSKU.Contains("384") ||
                        PaymentPlanSKU.Contains("386") ||
                        PaymentPlanSKU.Contains("388") ||
                        PaymentPlanSKU.Contains("390")
                        )
                    {
                        //Adding ItemLevel Payment Plan for above skus
                        if (r1["PaymentPlan"] != null)
                        {
                            if (r1["PaymentPlan"].ToString().Equals("") || r1["PaymentPlan"].ToString().Equals("0"))
                            {
                                stc = stc.Replace("@PayPlan", "<PaymentPlanID>@6</PaymentPlanID>").Replace("@6", "0".ToString());
                            }
                            else
                            {
                                stc = stc.Replace("@PayPlan", "<PaymentPlanID>@6</PaymentPlanID>").Replace("@6", r1["PaymentPlan"].ToString());
                            }
                        }
                    }
                    else
                    {
                        //No need for Item Level payment plan as there is one in Payment Tag
                        stc = stc.Replace("@PayPlan", "");
                    }



                    if (r1["skuid"].ToString().Equals("327") || r1["skuid"].ToString().Equals("330") || r1["skuid"].ToString().Equals("331") || r1["skuid"].ToString().Equals("332") || r1["skuid"].ToString().Equals("345") || r1["skuid"].ToString().Equals("347") || r1["skuid"].ToString().Equals("364") || r1["skuid"].ToString().Equals("365") ||
                        r1["skuid"].ToString().Equals("366") || r1["skuid"].ToString().Equals("367") ||
                        r1["skuid"].ToString().Equals("368") || r1["skuid"].ToString().Equals("369") ||
                        r1["skuid"].ToString().Equals("370") || r1["skuid"].ToString().Equals("371") ||
                        r1["skuid"].ToString().Equals("372") || r1["skuid"].ToString().Equals("373") ||
                        r1["skuid"].ToString().Equals("374") || r1["skuid"].ToString().Equals("375") ||
                        r1["skuid"].ToString().Equals("376") || r1["skuid"].ToString().Equals("377") ||
                        r1["skuid"].ToString().Equals("378") || r1["skuid"].ToString().Equals("379") ||
                        r1["skuid"].ToString().Equals("380") || r1["skuid"].ToString().Equals("381") ||
                        r1["skuid"].ToString().Equals("383") || r1["skuid"].ToString().Equals("384") ||
                        r1["skuid"].ToString().Equals("385") || r1["skuid"].ToString().Equals("386") ||
                        r1["skuid"].ToString().Equals("387") || r1["skuid"].ToString().Equals("388") ||
                        r1["skuid"].ToString().Equals("389") || r1["skuid"].ToString().Equals("390")
                        )
                    {
                        if (PaymentPlanSKU.Contains("336"))
                        {
                            stc = stc.Replace("@5", "1");
                        }
                        else
                        {
                            stc = stc.Replace("@5", "");
                        }
                    }
                    else
                    {
                        stc = stc.Replace("@5", "");
                    }
                }
                string cardstatus = "";
                cardstatus = "0";
                string st1   = "";
                int    cnt39 = 0;



                if (PaymentPlanSKU.Contains("330") || PaymentPlanSKU.Contains("327"))
                {
                    if (dsCountry.Tables[0].Rows[0]["Code"].ToString().ToLower().Trim().Equals("us"))
                    {
                        s1 = s1.Replace("@methodcode@", "7");
                    }
                    else
                    {
                        s1 = s1.Replace("@methodcode@", "8");
                    }
                }
                else if (PaymentPlanSKU.Contains("340") || PaymentPlanSKU.Contains("341") || PaymentPlanSKU.Contains("344") || PaymentPlanSKU.Contains("345") || PaymentPlanSKU.Contains("346") || PaymentPlanSKU.Contains("347") || PaymentPlanSKU.Contains("349") || PaymentPlanSKU.Contains("351") ||
                         PaymentPlanSKU.Contains("370") ||
                         PaymentPlanSKU.Contains("371") ||
                         PaymentPlanSKU.Contains("372") ||
                         PaymentPlanSKU.Contains("373") ||
                         PaymentPlanSKU.Contains("374") ||
                         PaymentPlanSKU.Contains("375") ||
                         PaymentPlanSKU.Contains("383") ||
                         PaymentPlanSKU.Contains("384")
                         )
                {
                    s1 = s1.Replace("@methodcode@", "2");
                }
                else
                {
                    s1 = s1.Replace("@methodcode@", "1");
                }
                total1z    = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z = Convert.ToDecimal(r["shippingamount"].ToString());
                s1         = s1.Replace("@total@", fixstring(total1z.ToString()));
                s1         = s1.Replace("@shippingamount@", fixstring(shipping1z.ToString()));
                stc        = "<OrderDetail>" + stc + "</OrderDetail>";
                s1         = s1.Replace("<OrderDetail>@orderdetailstuff@</OrderDetail>", stc);
                string s2  = "";
                string url = Helper.AppSettings["OMXUrl"].ToString();
                s2 = HttpPost(url, s1);
                //<TotalMerchandise>99.98</TotalMerchandise>

                //Decimal tax3 = Convert.ToDecimal(fixempty(getfromto(s2, "<Tax>", "</Tax>")))/Convert.ToDecimal(Session["numpay"].ToString());
                response1 = s2;
                decimal salesTax = 0;
                if (response1 != "")
                {
                    string CheckSuccess = "";
                    try
                    {
                        CheckSuccess = getfromto(response1, "<Success>", "</Success>");
                        if (CheckSuccess.Equals("1"))
                        {
                            if (verifyflag.ToString().Equals("True"))
                            {
                                salesTax = Convert.ToDecimal(fixempty(getfromto(response1, "<Tax>", "</Tax>")));
                                runsql("update [order] set orderstatusid = 2, Request='" + ClearAccents(fixQuot(s1)) + "', Response = '" + ClearAccents(fixQuot(response1)) + "', tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                                runsql("update [ordershipment] set tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                            }
                            else
                            {
                                runsql("update [order] set orderstatusid = 2, Request1='" + ClearAccents(fixQuot(s1)) + "', Response1 = '" + ClearAccents(fixQuot(response1)) + "', tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                            }
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Error While sending message---" + E.Message);
                    }
                }
                response1 = "";
                s1        = "";
            }
        }
Ejemplo n.º 10
0
        public void sendxml1(string verifyflag, string ordernumber)
        {
            _intOrderID = Convert.ToInt32(ordernumber);
            _dtOrderSKU = null;
            string key1           = System.Configuration.ConfigurationSettings.AppSettings["encryptionkey"];
            string response1      = "";
            string DeclineToEmail = "";
            string FirstName      = "";
            string LastName       = "";

            Mediachase.eCF.BusLayer.Common.Configuration.FrameworkConfig.EncryptionPrivateKey = key1;
            Mediachase.eCF.BusLayer.Common.Util.EncryptionManager em = new Mediachase.eCF.BusLayer.Common.Util.EncryptionManager();

            string orderid1 = ordernumber;

            DataSet ds = new DataSet();

            ds = getsql("exec getorders4 " + orderid1.ToString());

            string s1a = getomxml(verifyflag, orderid1);

            decimal total1z;
            decimal shipping1z;


            string stb = "<LineItem lineNumber=[[[@1[[[>~<PaymentPlanID>@0</PaymentPlanID>~<ItemCode>@2</ItemCode>~<Quantity>@3</Quantity>~<UnitPrice>@4</UnitPrice>~<Recurrence patternID=[[[@5[[[></Recurrence>~</LineItem>";

            stb = stb.Replace("~", ((char)(13)).ToString() + ((char)(10)).ToString());
            stb = stb.Replace("[[[", ((char)(34)).ToString());

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                string s1  = s1a;
                string cc1 = "";
                string cc2 = "";

                FirstName = r["billfirstname"].ToString();
                LastName  = r["billlastname"].ToString();
                s1        = s1.Replace("@billfirstname@", ClearAccents(fixstring(r["billfirstname"])));

                s1 = s1.Replace("@billlastname@", ClearAccents(fixstring(r["billlastname"])));
                s1 = s1.Replace("@billaddress@", ClearAccents(fixstring(r["billaddress"])));
                s1 = s1.Replace("@billaddress2@", ClearAccents(fixstring(r["billaddress2"])));

                s1 = s1.Replace("@billcity@", fixstring(r["billcity"]));

                s1 = s1.Replace("@billstate@", "");
                s1 = s1.Replace("@billzip@", fixstring(r["billzip"]));

                DataSet dsCountry = getsql("select * from country where countryid = " + r["billcountry"]);
                s1 = s1.Replace("@billcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                DateTime d = new DateTime();
                d = Convert.ToDateTime(fixstring(r["orderdate"]));

                s1 = s1.Replace("@orderdate@", d.ToString("yyyy-MM-dd HH:MM:ss"));
                s1 = s1.Replace("@OrderDateFormat@", d.ToString("yyyy-MM-dd"));
                s1 = s1.Replace("@AffiliateID@", fixstring(r["affiliateid"]));
                s1 = s1.Replace("@CardAuthCode@", _AuthCode);


                s1 = s1.Replace("@keycode@", fixstring(r["keycode"]));
                s1 = s1.Replace("@orderid@", "FR" + fixstring(r["orderid"]));


                s1 = s1.Replace("@shipfirstname@", ClearAccents(fixstring(r["shipfirstname"])));
                s1 = s1.Replace("@shiplastname@", ClearAccents(fixstring(r["shiplastname"])));
                s1 = s1.Replace("@shipaddress@", ClearAccents(fixstring(r["shipaddress"])));
                s1 = s1.Replace("@shipaddress2@", ClearAccents(fixstring(r["shipaddress2"])));
                s1 = s1.Replace("@shipcity@", fixstring(r["shipcity"]));

                s1        = s1.Replace("@shipstate@", "");
                s1        = s1.Replace("@shipzip@", fixstring(r["shipzip"]));
                dsCountry = getsql("select * from country where countryid = " + r["shipcountry"]);
                s1        = s1.Replace("@shipcountry@", dsCountry.Tables[0].Rows[0]["Code"].ToString().Trim());

                cc1 = r["creditcardnumber"].ToString();
                cc2 = em.Decrypt(cc1);
                if (r["ipaddress"] != null && r["ipaddress"].ToString() != "")
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(em.Decrypt(r["ipaddress"].ToString())));
                }
                else
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(""));
                }
                s1 = s1.Replace("@cardnumber@", fixstring(cc2));
                s1 = s1.Replace("@cvv@", fixstring(r["creditcardcsc"]));
                s1 = s1.Replace("@cardexpmonth@", fixstring(r["creditcardexpiredmonth"]));
                s1 = s1.Replace("@cardexpyear@", fixstring(r["creditcardexpiredyear"]));
                s1 = s1.Replace("@1@", fixstring(r["phonenumber"]));
                s1 = s1.Replace("@2@", fixstring(r["email"]));
                if (r["ipaddress"] != null)
                {
                    s1 = s1.Replace("@CustomerIP@", fixstring(em.Decrypt(r["ipaddress"].ToString())));
                }
                DeclineToEmail = fixstring(r["email"]);
                total1z        = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z     = Convert.ToDecimal(r["shippingamount"].ToString());
                decimal cust1 = Convert.ToDecimal("0");
                string  stc   = "";
                string  stc1  = "";
                int     cnt;
                cnt = 0;
                decimal price1;
                decimal price2;
                int     qty1;
                int     qty2;
                decimal price2b = 0;
                string  coupcode;
                bool    extra;

                string method1 = fixstring(r["methodcode"]);

                foreach (DataRow r1 in OrderSKU.Rows)
                {
                    if (r1["skuid"].ToString().Equals("336"))
                    {
                        continue;
                    }
                    cnt++;
                    stc1 = stc;
                    stc += stb;
                    stc  = stc.Replace("@1", cnt.ToString());
                    if (r1["skuid"].ToString().Equals("453") || r1["skuid"].ToString().Equals("455"))
                    {
                        stc = stc.Replace("@0", "1");
                    }
                    else
                    {
                        stc = stc.Replace("@0", "0");
                    }
                    if (r1["skucode"].ToString().Equals("CONTINUITY"))
                    {
                        stc = stc.Replace("@2", "");
                    }
                    else
                    {
                        stc = stc.Replace("@2", fixstring(r1["skucode"].ToString()).Replace(" ", "").Replace("-", ""));
                    }
                    qty1     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    qty2     = Convert.ToInt32(r1["OrderSkuQuantity"].ToString());
                    price1   = Convert.ToDecimal(r1["Fullprice"].ToString());
                    price2b  = price1;
                    coupcode = "";
                    extra    = false;

                    stc = stc.Replace("@3", qty2.ToString());
                    stc = stc.Replace("@4", fixstring(price1.ToString()));
                    stc = stc.Replace("@5", "");
                }
                if (PaymentPlanSKU.Contains("340") || PaymentPlanSKU.Contains("341") || PaymentPlanSKU.Contains("342") || PaymentPlanSKU.Contains("343") || PaymentPlanSKU.Contains("344") || PaymentPlanSKU.Contains("345") || PaymentPlanSKU.Contains("346") || PaymentPlanSKU.Contains("347"))
                {
                    cnt++;
                    stc += stb;
                    stc  = stc.Replace("@1", cnt.ToString());
                    stc  = stc.Replace("@2", fixstring("2YRWAR".ToString()).Replace(" ", "").Replace("-", ""));
                    stc  = stc.Replace("@3", "1".ToString());
                    stc  = stc.Replace("@4", fixstring("0".ToString()));
                    stc  = stc.Replace("@5", "");
                }

                if (PaymentPlanSKU.Contains("453") || PaymentPlanSKU.Contains("455"))
                {
                    s1 = s1.Replace("@methodcode@", "1");
                }
                else
                {
                    s1 = s1.Replace("@methodcode@", "2");
                }

                string cardstatus = "";
                cardstatus = "0";
                string st1   = "";
                int    cnt39 = 0;

                total1z    = Convert.ToDecimal(r["totalamount"].ToString());
                shipping1z = Convert.ToDecimal(r["shippingamount"].ToString());
                s1         = s1.Replace("@total@", fixstring(total1z.ToString()));
                s1         = s1.Replace("@shippingamount@", fixstring(shipping1z.ToString()));
                stc        = "<OrderDetail>" + stc + "</OrderDetail>";
                s1         = s1.Replace("<OrderDetail>@orderdetailstuff@</OrderDetail>", stc);
                string s2  = "";
                string url = Helper.AppSettings["OMXUrl"].ToString();
                s2 = HttpPost(url, s1);

                response1 = s2;
                decimal salesTax = 0;
                if (response1 != "")
                {
                    string CheckSuccess = "";
                    try
                    {
                        CheckSuccess = getfromto(response1, "<Success>", "</Success>");
                        if (CheckSuccess.Equals("1"))
                        {
                            if (verifyflag.ToString().Equals("True"))
                            {
                                //we are not recording sales tax for UK Site.
                                salesTax = Convert.ToDecimal(fixempty(getfromto(response1, "<Tax>", "</Tax>")));
                                runsql("update [order] set orderstatusid = 2, Request='" + ClearAccents(fixQuot(s1)) + "', Response = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                                //runsql("update [ordershipment] set tax=" + salesTax.ToString("N2") + "where orderid= " + orderid1);
                            }
                            else
                            {
                                runsql("update [order] set orderstatusid = 2, Authorizationcode='" + _AuthCode + "',  Request1='" + ClearAccents(fixQuot(s1)) + "', Response1 = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                            }
                        }
                        else
                        {
                            runsql("update [order] set orderstatusid = 2, Request='" + ClearAccents(fixQuot(s1)) + "', Response = '" + ClearAccents(fixQuot(response1)) + "' where orderid= " + orderid1);
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Error While sending message---" + E.Message);
                    }
                }
                response1   = "";
                s1          = "";
                _dtOrderSKU = null;
            }
        }