コード例 #1
0
        public ResponseModel CheckCourierAvailibilty([FromBody] HSChkCourierAvailibilty hSChkCourierAvailibilty)
        {
            HSOrderCaller hSOrderCaller    = new HSOrderCaller();
            ResponseModel objResponseModel = new ResponseModel();
            ResponseCourierAvailibilty responseCourierAvailibilty = new ResponseCourierAvailibilty();
            int    statusCode    = 0;
            string statusMessage = "";

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                responseCourierAvailibilty = hSOrderCaller.CheckPinCodeForCourierAvailibilty(new HSOrderService(_connectionString), hSChkCourierAvailibilty, authenticate.TenantId, authenticate.UserMasterID, _ClientAPIUrl);
                statusCode =
                    responseCourierAvailibilty.StatusCode != "" ?
                    (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound;

                statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);

                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = responseCourierAvailibilty;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
コード例 #2
0
        /// <summary>
        /// CheckClientPinCodeForCourierAvailibilty
        /// </summary>
        /// <param name="hSChkCourierAvailibilty"></param>
        /// <param name="tenantID"></param>
        /// <param name="userID"></param>
        /// <param name="clientAPIUrl"></param>
        /// <returns></returns>
        public static ResponseCourierAvailibilty CheckClientPinCodeForCourierAvailibilty(HSChkCourierAvailibilty hSChkCourierAvailibilty, int tenantID, int userID, string clientAPIUrl)
        {
            ResponseCourierAvailibilty responseCourierAvailibilty = new ResponseCourierAvailibilty();
            string          apiResponse = string.Empty;
            MySqlConnection con         = null;

            try
            {
                hSChkCourierAvailibilty.Cod    = 0;
                hSChkCourierAvailibilty.Weight = 1;
                string apiReq = JsonConvert.SerializeObject(hSChkCourierAvailibilty);
                apiResponse = CommonService.SendApiRequest(clientAPIUrl + "/api/ShoppingBag/ChkCourierAvailibilty", apiReq);
                responseCourierAvailibilty = JsonConvert.DeserializeObject <ResponseCourierAvailibilty>(apiResponse);
            }
            catch (Exception)
            {
                responseCourierAvailibilty = new ResponseCourierAvailibilty
                {
                    StatusCode = "201",
                    Available  = "false"
                };
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
                GC.Collect();
            }
            return(responseCourierAvailibilty);
        }
コード例 #3
0
        /// <summary>
        /// CheckPinCodeForCourierAvailibilty
        /// </summary>
        /// <param name="orderID"></param>
        ///  <param name="tenantID"></param>
        ///  <param name="userID"></param>
        /// <returns></returns>
        public ResponseCourierAvailibilty CheckPinCodeForCourierAvailibilty(HSChkCourierAvailibilty hSChkCourierAvailibilty, int tenantID, int userID, string clientAPIUrl)
        {
            ResponseCourierAvailibilty responseCourierAvailibilty = new ResponseCourierAvailibilty();

            try
            {
                hSChkCourierAvailibilty.Cod    = 0;
                hSChkCourierAvailibilty.Weight = 1;
                string apiReq = JsonConvert.SerializeObject(hSChkCourierAvailibilty);
                apiResponse = CommonService.SendApiRequest(clientAPIUrl + "api/ShoppingBag/ChkCourierAvailibilty", apiReq);
                responseCourierAvailibilty = JsonConvert.DeserializeObject <ResponseCourierAvailibilty>(apiResponse);

                if (responseCourierAvailibilty != null)
                {
                    if (responseCourierAvailibilty.Available.ToLower() == "false")
                    {
                        OrderTabSetting orderTabSetting = new OrderTabSetting();
                        orderTabSetting = GetOrderTabSettingDetails(tenantID, userID);
                        if (orderTabSetting.StoreDelivery)
                        {
                            responseCourierAvailibilty.Available = "true";
                        }
                    }
                }
                else
                {
                    responseCourierAvailibilty = new ResponseCourierAvailibilty
                    {
                        StatusCode = "201",
                        Available  = "false"
                    };
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(responseCourierAvailibilty);
        }
コード例 #4
0
        /// <summary>
        /// GetdataFromMySQL
        /// </summary>
        /// <param name="ConString"></param>
        public static void GetdataFromMySQL(string ConString)
        {
            string apiResponse       = string.Empty;
            string apiGenPickupRes   = string.Empty;
            string apiGenMenifestRes = string.Empty;

            AWBResponce      awbResponce      = new AWBResponce();
            PickupResponce   pickupResponce   = new PickupResponce();
            ManifestResponce manifestResponce = new ManifestResponce();

            MySqlConnection con = null;

            try
            {
                DataSet        ds           = new DataSet();
                AWBRequest     objdetails   = new AWBRequest();
                orderDetails   orderDetails = new orderDetails();
                IConfiguration config       = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build();

                string ClientAPIURL = config.GetSection("MySettings").GetSection("ClientAPIURL").Value;
                con = new MySqlConnection(ConString);
                MySqlCommand cmd = new MySqlCommand("SP_PHYGetOrderdetailForAWB", con)
                {
                    CommandType = System.Data.CommandType.StoredProcedure
                };
                cmd.Connection.Open();
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                da.Fill(ds);
                cmd.Connection.Close();
                if (ds != null && ds.Tables[0] != null)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        try
                        {
                            if (ds != null && ds.Tables[1] != null)
                            {
                                objdetails = new AWBRequest()
                                {
                                    pickup_postcode   = ds.Tables[1].Rows[i]["pickup_postcode"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[i]["pickup_postcode"]),
                                    delivery_postcode = ds.Tables[1].Rows[i]["delivery_postcode"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[i]["delivery_postcode"]),
                                    weight            = ds.Tables[1].Rows[i]["Weight"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[i]["Weight"]),
                                    orderDetails      = new orderDetails()
                                };
                            }

                            orderDetails = new orderDetails
                            {
                                Id                    = ds.Tables[0].Rows[i]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["ID"]),
                                order_id              = ds.Tables[0].Rows[i]["InvoiceNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["InvoiceNo"]),
                                order_date            = ds.Tables[0].Rows[i]["Date"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Date"]),
                                billing_customer_name = ds.Tables[0].Rows[i]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["CustomerName"]),
                                billing_address       = ds.Tables[0].Rows[i]["ShippingAddress"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ShippingAddress"]),
                                billing_city          = ds.Tables[0].Rows[i]["City"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["City"]),
                                billing_pincode       = ds.Tables[0].Rows[i]["delivery_postcode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["delivery_postcode"]),
                                billing_state         = ds.Tables[0].Rows[i]["State"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["State"]),
                                billing_country       = ds.Tables[0].Rows[i]["Country"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Country"]),
                                //billing_email = ds.Tables[0].Rows[i]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["EmailID"]),
                                billing_phone          = ds.Tables[0].Rows[i]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["MobileNumber"]),
                                shipping_customer_name = ds.Tables[0].Rows[i]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["CustomerName"]),
                                shipping_address       = ds.Tables[0].Rows[i]["ShippingAddress"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ShippingAddress"]),
                                shipping_city          = ds.Tables[0].Rows[i]["City"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["City"]),
                                shipping_pincode       = ds.Tables[0].Rows[i]["delivery_postcode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["delivery_postcode"]),
                                shipping_country       = ds.Tables[0].Rows[i]["Country"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Country"]),
                                shipping_state         = ds.Tables[0].Rows[i]["State"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["State"]),
                                //shipping_email = ds.Tables[0].Rows[i]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["EmailID"]),
                                shipping_phone          = ds.Tables[0].Rows[i]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["MobileNumber"]),
                                shipping_is_billing     = true,
                                billing_email           = "*****@*****.**",
                                shipping_email          = "*****@*****.**",
                                payment_method          = "Prepaid",
                                pickup_location         = "Test",
                                channel_id              = "633828",
                                billing_last_name       = "",
                                billing_address_2       = "",
                                billing_alternate_phone = "",
                                shipping_last_name      = "",
                                shipping_address_2      = "",
                                sub_total     = ds.Tables[0].Rows[i]["Amount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["Amount"]),
                                length        = ds.Tables[0].Rows[i]["Length"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["Length"]),
                                breadth       = ds.Tables[0].Rows[i]["Breath"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["Breath"]),
                                height        = ds.Tables[0].Rows[i]["Height"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["Height"]),
                                weight        = ds.Tables[0].Rows[i]["Weight"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["Weight"]),
                                StoreDelivery = Convert.ToBoolean(ds.Tables[0].Rows[i]["StoreDelivery"]),
                                TenantId      = ds.Tables[0].Rows[i]["TenantId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["TenantId"]),
                                StoreId       = ds.Tables[0].Rows[i]["StoreId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["StoreId"]),
                                ProgramCode   = ds.Tables[0].Rows[i]["ProgramCode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ProgramCode"]),
                                order_items   = new List <order_items>()
                            };
                            List <order_items> listobj = new List <order_items>();

                            string ItemIDs = "";
                            for (int j = 0; j < ds.Tables[2].Rows.Count; j++)
                            {
                                if (Convert.ToInt32(ds.Tables[2].Rows[j]["OrderID"]) == Convert.ToInt32(orderDetails.Id))
                                {
                                    order_items objorder_Items = new order_items()
                                    {
                                        OrderItemID   = ds.Tables[2].Rows[j]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[2].Rows[j]["ID"]),
                                        name          = ds.Tables[2].Rows[j]["ItemName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[j]["ItemName"]),
                                        sku           = ds.Tables[2].Rows[j]["ItemID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[j]["ItemID"]),
                                        units         = ds.Tables[2].Rows[j]["Quantity"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[2].Rows[j]["Quantity"]),
                                        selling_price = ds.Tables[2].Rows[j]["ItemPrice"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[j]["ItemPrice"])
                                    };
                                    listobj.Add(objorder_Items);
                                    ItemIDs += ds.Tables[2].Rows[j]["ID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[j]["ID"]) + ",";
                                }
                            }
                            ItemIDs = ItemIDs.TrimEnd(',');
                            /*Check the Pincode Deliver or not*/

                            HSChkCourierAvailibilty hSChkCourierAvailibilty = new HSChkCourierAvailibilty
                            {
                                Pickup_postcode   = objdetails.pickup_postcode,
                                Delivery_postcode = objdetails.delivery_postcode
                            };

                            ResponseCourierAvailibilty responseCourierAvailibilty = new ResponseCourierAvailibilty();
                            responseCourierAvailibilty = CheckClientPinCodeForCourierAvailibilty(hSChkCourierAvailibilty, orderDetails.TenantId, orderDetails.Id, ClientAPIURL);

                            /*Check the Pincode Deliver or not*/
                            if (responseCourierAvailibilty.Available == "false")
                            {
                                if (orderDetails.StoreDelivery == true)
                                {
                                    AddStoreResponse(orderDetails.Id, ItemIDs, orderDetails.TenantId, true, ConString);
                                }
                                else
                                {
                                    AddStoreResponse(orderDetails.Id, ItemIDs, orderDetails.TenantId, false, ConString);
                                }
                            }
                            else if (responseCourierAvailibilty.Available == "true")
                            {
                                orderDetails.order_items = listobj;
                                ItemIDs = ItemIDs.TrimEnd(',');
                                objdetails.orderDetails = orderDetails;
                                string apiReq = JsonConvert.SerializeObject(objdetails);
                                apiResponse = CommonService.SendApiRequest(ClientAPIURL + "/api/ShoppingBag/GetCouriersPartnerAndAWBCode", apiReq);
                                awbResponce = JsonConvert.DeserializeObject <AWBResponce>(apiResponse);
                                if (awbResponce.data != null)
                                {
                                    if (awbResponce.data.awb_code != "" && awbResponce.data.courier_name != "" && awbResponce.statusCode == "200")
                                    {
                                        InsertCourierResponse(orderDetails.Id, ItemIDs, awbResponce.data.awb_code, awbResponce.data.courier_company_id, awbResponce.data.courier_name, awbResponce.data.order_id, awbResponce.data.shipment_id, ConString);

                                        CommonService.SmsWhatsUpDataSend(orderDetails.TenantId, 0, orderDetails.ProgramCode, orderDetails.Id, ClientAPIURL, "AWBAssigned", ConString);

                                        if (awbResponce != null)
                                        {
                                            if (awbResponce.data != null)
                                            {
                                                if (awbResponce.data.shipment_id != null)
                                                {
                                                    PickupManifestRequest pickupManifestRequest = new PickupManifestRequest()
                                                    {
                                                        shipmentId = new List <int> {
                                                            Convert.ToInt32(awbResponce.data.shipment_id)
                                                        }
                                                    };

                                                    try
                                                    {
                                                        string apiGenPickupReq = JsonConvert.SerializeObject(pickupManifestRequest);
                                                        apiGenPickupRes = CommonService.SendApiRequest(ClientAPIURL + "/api/ShoppingBag/GeneratePickup", apiGenPickupReq);
                                                        pickupResponce  = JsonConvert.DeserializeObject <PickupResponce>(apiGenPickupRes);
                                                        //if (pickupResponce.response.pickupTokenNumber != "")
                                                        //{
                                                        //    UpdateGeneratePickupManifest(orderDetails.Id, orderDetails.TenantId, orderDetails.Id, "Pickup", ConString);
                                                        //}
                                                        if (pickupResponce.status_code == 0 && pickupResponce.pickupStatus == "1")
                                                        {
                                                            if (pickupResponce.response != null)
                                                            {
                                                                if (pickupResponce.response.pickupTokenNumber != null)
                                                                {
                                                                    //UpdateGeneratePickupManifest(ID, "Pickup", ConString, TenantId);
                                                                    UpdateGeneratePickupManifest(orderDetails.Id, orderDetails.TenantId, orderDetails.Id, "Pickup", ConString);

                                                                    CommonService.SmsWhatsUpDataSend(orderDetails.TenantId, 0, orderDetails.ProgramCode, orderDetails.Id, ClientAPIURL, "PickupScheduled", ConString);
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ExLogger(orderDetails.Id, orderDetails.order_id, Convert.ToString(DateTime.Now), Convert.ToString(orderDetails.StoreId), pickupResponce.status_code + " : " + pickupResponce.message, apiGenPickupRes, ConString);
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        ExLogger(orderDetails.Id, orderDetails.order_id, orderDetails.order_date, Convert.ToString(orderDetails.StoreId), ex.Message, ex.StackTrace, ConString);
                                                    }
                                                    try
                                                    {
                                                        string apiGenMenifestReq = JsonConvert.SerializeObject(pickupManifestRequest);
                                                        apiGenMenifestRes = CommonService.SendApiRequest(ClientAPIURL + "/api/ShoppingBag/GenerateManifest", apiGenMenifestReq);
                                                        manifestResponce  = JsonConvert.DeserializeObject <ManifestResponce>(apiGenMenifestRes);
                                                        if (manifestResponce.status_code == 0)
                                                        {
                                                            if (manifestResponce.status == "1" && manifestResponce.manifestUrl != null && manifestResponce.manifestUrl != "")
                                                            {
                                                                UpdateGeneratePickupManifest(orderDetails.Id, orderDetails.TenantId, orderDetails.Id, "Manifest", ConString);

                                                                CommonService.SmsWhatsUpDataSend(orderDetails.TenantId, 0, orderDetails.ProgramCode, orderDetails.Id, ClientAPIURL, "ManifestGenerated", ConString);
                                                            }
                                                            else
                                                            {
                                                                ExLogger(orderDetails.Id, orderDetails.order_id, Convert.ToString(DateTime.Now), Convert.ToString(orderDetails.StoreId), manifestResponce.status, apiGenMenifestRes, ConString);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ExLogger(orderDetails.Id, orderDetails.order_id, Convert.ToString(DateTime.Now), Convert.ToString(orderDetails.StoreId), manifestResponce.status_code + " : " + manifestResponce.message, apiGenMenifestRes, ConString);
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        ExLogger(orderDetails.Id, orderDetails.order_id, orderDetails.order_date, Convert.ToString(orderDetails.StoreId), ex.Message, ex.StackTrace, ConString);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        AddStoreResponse(orderDetails.Id, ItemIDs, orderDetails.TenantId, false, ConString);
                                    }
                                }
                                else
                                {
                                    AddStoreResponse(orderDetails.Id, ItemIDs, orderDetails.TenantId, false, ConString);
                                }
                            }
                        }
                        catch (Exception Ex)
                        {
                            ExLogger(orderDetails.Id, orderDetails.order_id, orderDetails.order_date, Convert.ToString(orderDetails.StoreId), Ex.Message, Ex.StackTrace, ConString);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
                GC.Collect();
            }
        }