Example #1
0
        //public ContinuityBatch GetContBatch(Order orderItem)
        //{
        //    //String strXml = String.Empty;
        //    orderItem.LoadAttributeValues();

        //    string ShippingStateProvinceAbbreviation = "";
        //    string BillingStateProvinceAbbreviation = "";
        //    List<StateProvince> states = StateManager.GetAllStates(0);
        //    StateProvince itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.ShippingAddress.StateProvinceId));
        //    if (itemShippingStateProvince != null)
        //    {
        //        ShippingStateProvinceAbbreviation = itemShippingStateProvince.Abbreviation.Trim();
        //    }
        //    StateProvince itemBillingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.BillingAddress.StateProvinceId));
        //    if (itemBillingStateProvince != null)
        //    {
        //        BillingStateProvinceAbbreviation = itemBillingStateProvince.Abbreviation.Trim();
        //    }

        //    Sku ShippingSku = GetShippingSku(orderItem);
        //    CustomerElement custElement = new CustomerElement();
        //    //PostOrderBatchRequestOrderBatchCustomer Customer = new PostOrderBatchRequestOrderBatchCustomer();

        //    custElement.Project = Convert.ToInt32(config.Attributes["Project"].Value);
        //    custElement.Customer = Convert.ToInt32(config.Attributes["CustomerNo"].Value);
        //    custElement.ClientCustomer = Convert.ToInt32(config.Attributes["ClientCustomer"].Value);
        //    custElement.First = orderItem.CustomerInfo.ShippingAddress.FirstName;
        //    custElement.Last = orderItem.CustomerInfo.ShippingAddress.LastName;
        //    custElement.Address = orderItem.CustomerInfo.ShippingAddress.Address1;
        //    custElement.Address2 = orderItem.CustomerInfo.ShippingAddress.Address2;
        //    custElement.City = orderItem.CustomerInfo.ShippingAddress.City;
        //    custElement.State = BillingStateProvinceAbbreviation; //  orderItem.CustomerInfo.BillingAddress.StateProvinceName;
        //    custElement.Zip = orderItem.CustomerInfo.ShippingAddress.ZipPostalCode;
        //    if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
        //    {
        //        custElement.Country = "CN";
        //    }
        //    else
        //    {
        //        custElement.Country = orderItem.CustomerInfo.ShippingAddress.CountryCode.Trim();
        //    }
        //    custElement.TmPhone = 0;
        //    custElement.DayPhone = (long)Convert.ToDouble(OrderHelper.GetCleanPhoneNumber(orderItem.CustomerInfo.ShippingAddress.PhoneNumber));
        //    custElement.NightPhone = (long)Convert.ToDouble(OrderHelper.GetCleanPhoneNumber(orderItem.CustomerInfo.ShippingAddress.PhoneNumber));
        //    custElement.CreationDate = DateTime.Now;
        //    custElement.CreationDate = DateTime.Now;
        //    custElement.CreationDate = DateTime.Now;

        //    Sku ContinuitySKU = GetContinuitySKU(orderItem);
        //    ContinuityTemplate contTemplate = new ContinuityTemplate();
        //    contTemplate.ContinuityPlan = ContinuitySKU.AttributeValues["continuityplan"].Value; // "CN60"; // config.Attributes["ContinuityPlan"].Value;
        //    contTemplate.ContinuityShipCode = "0";
        //    contTemplate.ContinuityFirst = orderItem.CustomerInfo.ShippingAddress.FirstName;
        //    contTemplate.ContinuityLast = orderItem.CustomerInfo.ShippingAddress.LastName;
        //    contTemplate.ContinuityAddress = orderItem.CustomerInfo.ShippingAddress.Address1;
        //    contTemplate.ContinuityAddress2 = orderItem.CustomerInfo.ShippingAddress.Address2;
        //    contTemplate.ContinuityCity = orderItem.CustomerInfo.ShippingAddress.City;
        //    contTemplate.ContinuityState = ShippingStateProvinceAbbreviation; // BillingStateProvinceAbbreviation; //  orderItem.CustomerInfo.BillingAddress.StateProvinceName;
        //    contTemplate.ContinuityZip = orderItem.CustomerInfo.ShippingAddress.ZipPostalCode;
        //    if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
        //    {
        //        contTemplate.ContinuityCountry = "CN";
        //    }
        //    else
        //    {
        //        contTemplate.ContinuityCountry = orderItem.CustomerInfo.ShippingAddress.CountryCode.Trim();
        //    }
        //    contTemplate.ContinuityPhone = (long)Convert.ToDouble(OrderHelper.GetCleanPhoneNumber(orderItem.CustomerInfo.ShippingAddress.PhoneNumber));
        //    contTemplate.ContinuityStatus = "A";
        //    contTemplate.ContinuityCreationUser = "******";
        //    contTemplate.ContinuityCreationDate = DateTime.Now;
        //    contTemplate.ContinuityModifyDate = DateTime.Now;
        //    contTemplate.ContinuityWarehouse = 0;
        //    // The Continuity Post should not contain a Payment Plan ) of U3TP (<ContinuityPaymentPlan> ).  Only 02M is available as a payment plan for continuities.
        //    contTemplate.ContinuityPaymentPlan = "02M"; //  GetPaymentPlan(orderItem);
        //    if (orderItem.CreditInfo.CreditCardName.ToLower().Contains("americanexpress"))
        //        contTemplate.ContinuityPaymentCode = "X";
        //    else
        //        contTemplate.ContinuityPaymentCode = orderItem.CreditInfo.CreditCardName.Substring(0, 1);

        //    contTemplate.ContinuityCCNo_Check = orderItem.CreditInfo.CreditCardNumber;
        //    contTemplate.ContinuityExpDate = (long)Convert.ToDecimal(orderItem.CreditInfo.CreditCardExpired.ToString("MMyy"));
        //    contTemplate.ContinuityNo = 1;
        //    if (contTemplate.ContinuityPlan.ToUpper().Equals("CN60"))
        //    {
        //        // CN60	Order Date + 60 Days // <NextShipDate> that reflects Order Date + 60 Days when using Continuity Plan CN60
        //        contTemplate.NextShipDate = orderItem.CreatedDate.AddDays(60);
        //    }
        //    else
        //    {
        //        // Order Date + 30 Days
        //        contTemplate.NextShipDate = orderItem.CreatedDate.AddDays(30);
        //    }
        //    // contTemplate.NextShipDate = DateTime.Now.AddMonths(1);
        //    //TODO: get from sku attribute (must be set)
        //    contTemplate.DaysBetweenShipment = Convert.ToInt32(ContinuitySKU.AttributeValues["contdays"].Value); // 60;
        //    contTemplate.FreeOrder = 0;
        //    contTemplate.ContinuityConfirmation = 0;
        //    // The Ship Service (<ContinuityShpCodeService>, <ContinuityShipFeeService>) for continuities is always Standard, yet I saw some continuities with R or E.  Please default these 2 fields to S on continuity posts.
        //    contTemplate.ContinuityShpCodeService = "S"; // GetShippingSku(orderItem).SkuCode;
        //    contTemplate.ContinuityShipFeeService = "S"; // contTemplate.ContinuityShpCodeService;
        //    contTemplate.ContinuityPurchaseOrder = config.Attributes["OrderIdPrefix"].Value + orderItem.OrderId.ToString();
        //    contTemplate.ContinuityClientOrderNo = 0;
        //    contTemplate.OriginalTelemarketer = config.Attributes["Telemarketer"].Value;
        //    contTemplate.ContinuityPromotionalOffer = config.Attributes["Promotion"].Value + "C";
        //    contTemplate.PricingCalculationMethod = "P";
        //    contTemplate.ShippingCalculationMethod = "P";
        //    contTemplate.ContinuityContact = contTemplate.ContinuityFirst + " " + contTemplate.ContinuityLast;
        //    contTemplate.ContinuityModifyUser = string.Empty;
        //    contTemplate.ContinuityMedia = "";
        //    contTemplate.ContinuityBackEndCode = "";
        //    contTemplate.ContinuityBankName = "";
        //    contTemplate.ContinuityBankState = "";
        //    contTemplate.ContinuityBankTown = "";
        //    contTemplate.ContinuityCheckSavingsFlag = "";
        //    contTemplate.ContinuityConfirmation = 0;
        //    contTemplate.ContinuityMICR = "";
        //    contTemplate.ContinuityOrderCat = "";
        //    contTemplate.PrePay = "";

        //    ContinuityItem[] contItems = new ContinuityItem[orderItem.SkuItems.Count];

        //    int currentItem = 0;
        //    SkuManager skuManager = new SkuManager();
        //    int ContinuitySkuId = InnotracDAL.GetInnotracContinuitySKU(orderItem.OrderId);
        //    if (ContinuitySkuId > 0)
        //    {
        //        //foreach (Sku Item in orderItem.SkuItems)
        //        //{
        //            Sku sku = skuManager.GetSkuByID(ContinuitySkuId);
        //            if (sku.CategoryId == 13)
        //            {
        //                sku.LoadAttributeValues();
        //                ContinuityItem contItem = new ContinuityItem();
        //                contItem.ContinuitySKU = sku.SkuCode;
        //                contItem.ContinuityQtyOrdered = 1; // Item.Quantity;
        //                contItem.ExtendedPrice = (double)sku.FullPrice;
        //                contItem.ExtendedShipping = 0;//ItemPricing1.SKU_Shipping_Price.ToString("N2"));
        //                contItem.ExtendedTax = (double)GetSkuTaxCost(orderItem.CustomerInfo.ShippingAddress, sku) ; // Item);
        //                contItems[currentItem++] = contItem;

        //            }
        //        // }
        //    }

        //    contTemplate.ContinuityItems = contItems.Take<ContinuityItem>(currentItem).ToArray<ContinuityItem>();
        //    custElement.ContinuityTemplates = new ContinuityTemplate[] { contTemplate };
        //    ContinuityBatch contBatch = new ContinuityBatch();
        //    contBatch.CustomerElement = new CustomerElement[] { custElement };

        //    InnotracCWS.WSAuthorization auth = new InnotracCWS.WSAuthorization();
        //    auth.Username = config.Attributes["Username"].Value;
        //    auth.Password = config.Attributes["Password"].Value;
        //    contBatch.Authorization = auth;

        //    return contBatch;
        //}

        public bool IsMainOrderPosted(int orderId)
        {
            bool   IsPosted       = false;
            string Response1      = "";
            string InotracOrderNo = "";
            Order  orderItem      = CSResolve.Resolve <IOrderService>().GetOrderDetails(orderId, true);

            if (orderItem.OrderStatusId == 5)
            {
                orderItem.LoadAttributeValues();

                if (orderItem.AttributeValues.ContainsAttribute("response") && orderItem.AttributeValues["response"].Value != null)
                {
                    Response1 = orderItem.AttributeValues["response"].Value;
                    PostOrderBatchResponse PostOrderBatchResponse1 = FromXml <PostOrderBatchResponse>(Response1);
                    InotracOrderNo = PostOrderBatchResponse1.Orders[0].orderNumber.ToString();
                    if (InotracOrderNo.Length >= 8)
                    {
                        // base orders should never be re-posted if our 8-digit order number is returned in the response.
                        IsPosted = true;
                    }
                }
            }
            return(IsPosted);
        }
Example #2
0
        public bool PostOrder(int orderId)
        {
            bool result = false;
            Dictionary <string, AttributeValue> orderAttributes = new Dictionary <string, AttributeValue>();

            try
            {
                Order orderItem = new OrderManager().GetBatchProcessOrder(orderId);

                bool MainOrderPosted = false;

                // This is Duplicate Order Check with Innotrac CRM Production. If you want enable it please add below web services.
                // https://gateway.west.innotrac.com:8443/invoke/INOC_ATS_CRMS.SOA.WebSelfHelp.DM:wsdl
                //if (SearchByExternalOrderId(orderItem.OrderId, orderItem.OrderStatusId))
                //{
                //    // Order found in Innotrac CRM  WEBSelfHelp
                //    MainOrderPosted = true;
                //    result = true;
                //}
                // else
                if (IsMainOrderPosted(orderItem.OrderId))
                {
                    // Order was posted by Conversion Systems to Innotrac successfully previously
                    MainOrderPosted = true;
                    result          = true;
                }
                if (MainOrderPosted == false)
                {
                    InnotracWS.InocOrdersSoapClient RequestOrder = new InnotracWS.InocOrdersSoapClient();
                    //RequestOrder.Timeout = 30000; // Time outs of 30 seconds should be implemented for every web service call.
                    PostOrderBatchRequest PostOrderBatchRequest1 = GetRequest(orderItem);
                    XmlSerializer         serializer             = new XmlSerializer(typeof(PostOrderBatchRequest));
                    StringWriter          writer = new StringWriter();
                    serializer.Serialize(writer, PostOrderBatchRequest1);
                    writer.Close();
                    string req = writer.ToString();

                    PostOrderBatchResponse PostOrderBatchResponse1 = RequestOrder.PostOrderBatch(PostOrderBatchRequest1);


                    string        res         = "";
                    XmlSerializer serializer2 = new XmlSerializer(typeof(PostOrderBatchResponse));
                    StringWriter  writer2     = new StringWriter();
                    serializer2.Serialize(writer2, PostOrderBatchResponse1);
                    writer2.Close();
                    res = writer2.ToString();
                    // orderAttributes.Add("Request", new CSBusiness.Attributes.AttributeValue(req));
                    orderAttributes.Add("Response", new CSBusiness.Attributes.AttributeValue(res));
                    if (PostOrderBatchResponse1.Orders[0].OrderStatus[0].Code == 0 || PostOrderBatchResponse1.Orders[0].OrderStatus[0].Code >= 100)
                    {
                        //InnotracDAL.InsertInnoTracLog(orderId, 2);
                        CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderId, orderAttributes, 2);
                        result = true;
                    }
                    else
                    {
                        //InnotracDAL.InsertInnoTracLog(orderId, 8);
                        CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderId, orderAttributes, 5);
                        result = false;
                        OrderHelper.SendOrderFailedEmail(orderId, "main", "");
                    }
                }

                // Below code is for Posting Orders with Continuity Products.
                //if (result == true)
                //{
                //    if (GetContinuityFlag(orderItem) == "Y")
                //        PostOrderContinuity(orderItem);
                //}
            }
            catch (Exception ex)
            {
                //InnotracDAL.InsertInnoTracLog(orderId, 8);
                string errormessage = ex.Message + " StackTrace:: " + ex.StackTrace;
                CSResolve.Resolve <IOrderService>().UpdateOrderStatus(orderId, 5);
                result = false;
                OrderHelper.SendOrderFailedEmail(orderId, "custom", errormessage);
            }
            return(result);
        }