public List <DirectBookingCustomer> GetAgents()
        {
            // To Do : customer should come according to moduleType
            var operationzone = UtilityRepository.GetOperationZone();
            var customers     = (from r in dbContext.Users
                                 join ua in dbContext.UserAdditionals on r.UserId equals ua.UserId
                                 join ur in dbContext.UserRoles on r.UserId equals ur.UserId
                                 where
                                 ur.RoleId == (int)FrayteUserRole.Agent &&
                                 r.IsActive == true &&
                                 r.OperationZoneId == operationzone.OperationZoneId
                                 select new DirectBookingCustomer
            {
                CustomerId = r.UserId,
                CustomerName = r.ContactName,
                CompanyName = r.CompanyName,
                AccountNumber = ua.AccountNo,
                EmailId = r.UserEmail,
                ValidDays = ua.DaysValidity.HasValue ? ua.DaysValidity.Value : 0,
                CustomerCurrency = ua.CreditLimitCurrencyCode,
                OperationZoneId = r.OperationZoneId
            }).Distinct().ToList();

            return(customers.OrderBy(p => p.CompanyName).ToList());
        }
Exemplo n.º 2
0
        public TermAndCondition SaveTermAndCondition(TermAndCondition termAndCondition)
        {
            //For Term And Condition, we always have to create new term and condition in database.

            string shortCode             = string.Empty;
            var    customerCompanyDetail = dbContext.CustomerCompanyDetails.Where(p => p.UserId == termAndCondition.CreatedBy).FirstOrDefault();

            if (customerCompanyDetail != null)
            {
                shortCode = customerCompanyDetail.CompanyName.ToLower().Contains("mex") ? "MEX" : "";
            }

            var OperationZone = UtilityRepository.GetOperationZone();

            TermAndCondition newTermAndCondition = new TermAndCondition();

            newTermAndCondition.TermAndConditionId   = 0;
            newTermAndCondition.Detail               = termAndCondition.Detail;
            newTermAndCondition.CreatedOn            = DateTime.UtcNow;
            newTermAndCondition.OperationZoneId      = termAndCondition.OperationZoneId;
            newTermAndCondition.TermAndConditionType = termAndCondition.TermAndConditionType;
            newTermAndCondition.CreatedBy            = termAndCondition.CreatedBy;
            newTermAndCondition.ConpanyCode          = shortCode;
            dbContext.TermAndConditions.Add(newTermAndCondition);
            dbContext.SaveChanges();

            return(newTermAndCondition);
        }
Exemplo n.º 3
0
        public List <FrayteLogisticServices> LogisticServices(int operationZoneId)
        {
            List <FrayteLogisticServices> list = new List <FrayteLogisticServices>();
            var OperationZone = UtilityRepository.GetOperationZone();
            var collection    = dbContext.LogisticServices.Where(p => p.OperationZoneId == OperationZone.OperationZoneId && p.IsActive == true).ToList();

            FrayteLogisticServices lt;

            foreach (var item in collection)
            {
                lt = new FrayteLogisticServices();
                lt.LogisticCompany        = item.LogisticCompany;
                lt.LogisticCompanyDisplay = item.LogisticCompanyDisplay;
                lt.LogisticServiceId      = item.LogisticServiceId;
                lt.LogisticType           = item.LogisticType;
                lt.LogisticTypeDisplay    = item.LogisticTypeDisplay;
                lt.RateType        = item.RateType;
                lt.RateTypeDisplay = item.RateTypeDisplay;
                lt.ModuleType      = item.ModuleType;
                lt.OperationZoneId = item.OperationZoneId;

                list.Add(lt);
            }

            return(list);
        }
Exemplo n.º 4
0
        public SkyPostalResponse CreateShipment(SkyPostalRequest skyPostalRequest, int ExpressId)
        {
            SkyPostalResponse respone  = new SkyPostalResponse();
            var    logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.SKYPOSTAL);
            string result = string.Empty;

            #region SKYPOSTaL API Login

            skyPostalRequest.user_info.user_code = Convert.ToInt32(logisticIntegration.AppId);

            skyPostalRequest.user_info.app_key = logisticIntegration.InetgrationKey;

            skyPostalRequest.user_info.user_key = logisticIntegration.UserName;

            var skyPostalJson = Newtonsoft.Json.JsonConvert.SerializeObject(skyPostalRequest);

            result = SkyPostalWebApi(logisticIntegration, skyPostalJson);

            try
            {
                respone = Newtonsoft.Json.JsonConvert.DeserializeObject <SkyPostalResponse>(result);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }

            return(respone);
        }
        public List <TradelaneBookingCoLoadFormModel> ColoadReportObj(TradelaneBooking ShipmentDetail)
        {
            List <TradelaneBookingCoLoadFormModel> ColoadList = new List <TradelaneBookingCoLoadFormModel>();

            if (ShipmentDetail != null)
            {
                TradelaneBookingCoLoadFormModel ColoadModel = new TradelaneBookingCoLoadFormModel();
                ColoadModel.FrayteNumber       = ShipmentDetail.FrayteNumber;
                ColoadModel.ColoadTitle        = "CO LOAD BOOKING FORM (" + DateTime.UtcNow.Date.Year + ")";
                ColoadModel.ShipperAddress     = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipFrom, ShipmentDetail.DepartureAirport.AirportCode);
                ColoadModel.ConsigneeAddress   = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipTo, ShipmentDetail.DestinationAirport.AirportCode);
                ColoadModel.OperationZoneId    = UtilityRepository.GetOperationZone().OperationZoneId;
                ColoadModel.CTCPerson          = "";
                ColoadModel.ShipperPhoneNo     = !string.IsNullOrEmpty(ShipmentDetail.ShipFrom.Phone) && !string.IsNullOrEmpty(ShipmentDetail.ShipFrom.Country.CountryPhoneCode) ? "(+" + ShipmentDetail.ShipFrom.Country.CountryPhoneCode + ") " + ShipmentDetail.ShipFrom.Phone : "";
                ColoadModel.ConsigneePhoneNo   = !string.IsNullOrEmpty(ShipmentDetail.ShipTo.Phone) && !string.IsNullOrEmpty(ShipmentDetail.ShipTo.Country.CountryPhoneCode) ? "(+" + ShipmentDetail.ShipTo.Country.CountryPhoneCode + ") " + ShipmentDetail.ShipTo.Phone : "";
                ColoadModel.NotifyPartyAddress = ShipmentDetail.IsNotifyPartySameAsReceiver ? ColoadModel.ConsigneeAddress : UtilityRepository.ConcatinateAddress(ShipmentDetail.NotifyParty, "");
                ColoadModel.NotifyPartyPhoneNo = !string.IsNullOrEmpty(ShipmentDetail.NotifyParty.Phone) && !string.IsNullOrEmpty(ShipmentDetail.NotifyParty.Country.CountryPhoneCode) ? "(+" + ShipmentDetail.NotifyParty.Country.CountryPhoneCode + ") " + ShipmentDetail.NotifyParty.Phone : "";
                ColoadModel.CagroReadyDate     = dbContext.TradelaneShipmentAllocations.Where(a => a.TradelaneShipmentId == ShipmentDetail.TradelaneShipmentId).FirstOrDefault() != null && dbContext.TradelaneShipmentAllocations.Where(a => a.TradelaneShipmentId == ShipmentDetail.TradelaneShipmentId).FirstOrDefault().CreatedOnUTC != null?dbContext.TradelaneShipmentAllocations.Where(a => a.TradelaneShipmentId == ShipmentDetail.TradelaneShipmentId).FirstOrDefault().CreatedOnUTC.Value.Date.ToString("dd-MMM-yy") : "";

                ColoadModel.DepartureAirport    = ShipmentDetail.DepartureAirport != null ? ShipmentDetail.DepartureAirport.AirportCode + " - " + ShipmentDetail.DepartureAirport.AirportName : "";
                ColoadModel.DestinationAirport  = ShipmentDetail.DestinationAirport != null ? ShipmentDetail.DestinationAirport.AirportCode + " - " + ShipmentDetail.DestinationAirport.AirportName : "";
                ColoadModel.MawbNo              = !string.IsNullOrEmpty(ShipmentDetail.MAWB) ? ShipmentDetail.AirlinePreference.AilineCode + " " + ShipmentDetail.MAWB.Substring(0, 4) + " " + ShipmentDetail.MAWB.Substring(4, 4) : "";
                ColoadModel.SpecialInstruction  = "";
                ColoadModel.ExportLicenceNo     = !string.IsNullOrEmpty(ShipmentDetail.ExportLicenceNo) ? ShipmentDetail.ExportLicenceNo : "";;
                ColoadModel.AirLine             = ShipmentDetail.AirlinePreference != null && !string.IsNullOrEmpty(ShipmentDetail.AirlinePreference.AirLineName) ? ShipmentDetail.AirlinePreference.AirLineName : "";
                ColoadModel.TotalPackages       = GetTotalPackages(ShipmentDetail.TradelaneShipmentId);
                ColoadModel.ShipmentDescription = !string.IsNullOrEmpty(ShipmentDetail.ShipmentDescription) ? ShipmentDetail.ShipmentDescription : "";
                ColoadModel.GrossWeight         = GetGrossWeight(ShipmentDetail.TradelaneShipmentId);
                ColoadModel.Volume              = ShipmentDetail.HAWBPackages.Select(a => a.TotalVolume).Sum().ToString();
                ColoadModel.CopyrightText       = "Published by FRAYTE Logistics Ltd" + Environment.NewLine + "© CopyRight " + DateTime.UtcNow.Date.Year;
                ColoadList.Add(ColoadModel);
            }
            return(ColoadList);
        }
Exemplo n.º 6
0
        public List <FrayteLogisticServiceItem> GetLogisticServiceItems(int Year)
        {
            FrayteOperationZone OperationZone = UtilityRepository.GetOperationZone();

            var list = (from ls in dbContext.LogisticServices
                        join lsbrch in dbContext.LogisticServiceBaseRateCardHistories on ls.LogisticServiceId equals lsbrch.LogisticServiceId into leftJoin
                        from tempRate in leftJoin.DefaultIfEmpty()
                        where ls.OperationZoneId == OperationZone.OperationZoneId &&
                        ls.IsActive == true &&
                        tempRate.ReportYear == Year
                        select new FrayteLogisticServiceItem
            {
                LogisticServiceId = ls.LogisticServiceId,
                LogisticCompany = ls.LogisticCompany,
                LogisticCompanyDisplay = ls.LogisticCompanyDisplay,
                LogisticType = ls.LogisticType,
                LogisticTypeDisplay = ls.LogisticTypeDisplay,
                RateType = ls.RateType,
                RateTypeDisplay = ls.RateTypeDisplay,
                IssueDate = ls.IssuedDate.Value,
                ExpiryDate = ls.ExpiryDate.Value
            }).ToList();

            return(list);
        }
Exemplo n.º 7
0
        public List <FrayteWarehouseLocation> GetAllLocations(int userId)
        {
            List <FrayteWarehouseLocation> locations = new List <FrayteWarehouseLocation>();

            try
            {
                var OpearatiopZone = UtilityRepository.GetOperationZone();
                var Country        = dbContext.Countries.Where(p => p.CountryCode == OpearatiopZone.OperationZoneName).FirstOrDefault();
                var list           = dbContext.Locations.Where(p => p.CountryId == Country.CountryId).ToList();
                if (list != null && list.Count > 0)
                {
                    FrayteWarehouseLocation location;
                    foreach (var data in list)
                    {
                        location = new FrayteWarehouseLocation();
                        location.LocationName = data.LocationName;
                        location.Barcode      = data.Barcode;
                        locations.Add(location);
                    }
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }

            return(locations);
        }
Exemplo n.º 8
0
        public List <DirectBookingCustomer> GetCustomersWithoutCharges(int userId, string moduleType, string mode)
        {
            var customerIds = dbcontext.AdminCharges.Where(p => p.CustomerId > 0 && p.IsActive == true).Select(p => p.CustomerId).Distinct().ToList();

            // To Do : customer should come according to moduleType
            var operationzone = UtilityRepository.GetOperationZone();
            List <DirectBookingCustomer> customers = new List <DirectBookingCustomer>();

            if (mode == "Add")
            {
                customers = (from r in dbcontext.Users
                             join ua in dbcontext.UserAdditionals on r.UserId equals ua.UserId
                             join ur in dbcontext.UserRoles on r.UserId equals ur.UserId
                             join CM in dbcontext.CustomerMarginCosts on r.UserId equals CM.CustomerId
                             where
                             ur.RoleId == (int)FrayteUserRole.Customer &&
                             r.IsActive == true &&
                             r.OperationZoneId == operationzone.OperationZoneId &&
                             !customerIds.Contains(r.UserId)
                             select new DirectBookingCustomer
                {
                    CustomerId = r.UserId,
                    CustomerName = r.ContactName,
                    CompanyName = r.CompanyName,
                    AccountNumber = ua.AccountNo,
                    EmailId = r.Email,
                    ValidDays = ua.DaysValidity.HasValue ? ua.DaysValidity.Value : 0,
                    CustomerCurrency = ua.CreditLimitCurrencyCode,
                    OperationZoneId = r.OperationZoneId
                }).Distinct().ToList();


                //      customers.Where(p => !customerIds.Contains(p.CustomerId)).ToList();
            }
            else
            {
                customers = (from r in dbcontext.Users
                             join ua in dbcontext.UserAdditionals on r.UserId equals ua.UserId
                             join ur in dbcontext.UserRoles on r.UserId equals ur.UserId
                             join CM in dbcontext.CustomerMarginCosts on r.UserId equals CM.CustomerId
                             where
                             ur.RoleId == (int)FrayteUserRole.Customer &&
                             r.IsActive == true &&
                             r.OperationZoneId == operationzone.OperationZoneId
                             select new DirectBookingCustomer
                {
                    CustomerId = r.UserId,
                    CustomerName = r.ContactName,
                    CompanyName = r.CompanyName,
                    AccountNumber = ua.AccountNo,
                    EmailId = r.Email,
                    ValidDays = ua.DaysValidity.HasValue ? ua.DaysValidity.Value : 0,
                    CustomerCurrency = ua.CreditLimitCurrencyCode,
                    OperationZoneId = r.OperationZoneId
                }).Distinct().ToList();
            }

            return(customers);
        }
        public FrayteManifestName GenerateExpressTrackandTraceDetail(ExpressTrackandTrace trackdetail)
        {
            FrayteManifestName result = new FrayteManifestName();

            string Name = "";

            if (trackdetail.CustomerName == "ALL")
            {
                var OperationZone = UtilityRepository.GetOperationZone();
                if (OperationZone.OperationZoneId == 1)
                {
                    Name = "AllHK";
                }
                else if (OperationZone.OperationZoneId == 2)
                {
                    Name = "AllUK";
                }
            }
            else
            {
                Name = trackdetail.CustomerName;
            }

            try
            {
                var track = new ExpressRepository().GetExpressTrackAndTraceDetail(trackdetail);
                if (track != null && track.Count > 0)
                {
                    ReportTemplate.Other.AllUKReport rp = new ReportTemplate.Other.AllUKReport();
                    rp.DataSource = track;
                    if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"))
                    {
                        File.Delete(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx");
                        rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx");
                        result.FileName   = Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                        result.FilePath   = AppSettings.WebApiPath + "ReportFiles/ExpressTrack&Trace/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                        result.FileStatus = true;
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder + "/" + "ExpressTrack&Trace" + "/"));
                        rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx");
                        result.FileName   = Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                        result.FilePath   = AppSettings.WebApiPath + "ReportFiles/ExpressTrack&Trace/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                        result.FileStatus = true;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Exemplo n.º 10
0
        public List <FrayteUnAssignedJob> GetUnAssignedJobs(TrackHSCodeJob obj)
        {
            List <FrayteUnAssignedJob> list = new List <FrayteUnAssignedJob>();

            try
            {
                int SkipRows = 0;
                SkipRows = (obj.CurrentPage - 1) * obj.TakeRows;
                var OperationZone = UtilityRepository.GetOperationZone();
                // To Do : Get ETD Date And Time  in the list
                var jobs = dbContext.TrackUnAssignedJob(obj.FromDate, obj.ToDate, SkipRows, obj.TakeRows, OperationZone.OperationZoneId).ToList();

                var d = jobs.Where(p => p.EstimatedDateOfDelivery.HasValue).ToList();
                if (jobs != null && jobs.Count > 0)
                {
                    foreach (var data in jobs)
                    {
                        FrayteUnAssignedJob job = new FrayteUnAssignedJob();
                        job.CourierCompany        = data.LogisticCompany;
                        job.CourierCompanyDisplay = data.LogisticCompanyDisplay;
                        job.Customer                 = data.ContactName;
                        job.DisplayStatus            = data.StatusName;
                        job.ShippedFromCompany       = data.FromCompany;
                        job.ShippedToCompany         = data.ToCompany;
                        job.ShippingDate             = data.CreatedOn;
                        job.TotalRows                = data.TotalRows.HasValue ? data.TotalRows.Value : 0;
                        job.TrackingNo               = data.TrackingNo;
                        job.EstimatedDateOfDeparture = data.EstimatedDateOfDelivery;
                        job.EstimatedTimeOfDeparture = UtilityRepository.GetTimeZoneTime(data.EstimatedTimeofDelivery);
                        job.EstimatedDateOfArrival   = data.EstimatedDateofArrival;
                        job.EstimatedTimeOfArrival   = UtilityRepository.GetTimeZoneTime(data.EstimatedTimeofArrival);
                        job.ShipmentId               = data.DirectShipmentId;
                        job.ShipmentDescription      = data.ContentDescription;
                        job.Reference1               = data.Reference1;
                        job.FrayteNumber             = data.FrayteNumber;
                        job.FromCountry              = data.FromCountry;
                        job.ToCountry                = data.ToCountry;

                        list.Add(job);
                    }
                }

                // To Do : OrderBy on ETD date and then ETD Time
                var collection = list.OrderByDescending(p => p.EstimatedDateOfDeparture).ThenByDescending(p => UtilityRepository.GetTimeFromString(p.EstimatedTimeOfDeparture)).ToList();
                return(collection);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(list);
            }
        }
Exemplo n.º 11
0
        public List <FrayteCustomerSpecificAdminCharges> GetCustomerSpecificAdminCharges()
        {
            List <FrayteCustomerSpecificAdminCharges> list = new List <FrayteCustomerSpecificAdminCharges>();

            try
            {
                var OperationZoneId = UtilityRepository.GetOperationZone().OperationZoneId;

                var charges = (from r in dbcontext.AdminCharges
                               join u in dbcontext.Users on r.CustomerId equals u.UserId
                               join ua in dbcontext.UserAdditionals on r.CustomerId equals ua.UserId
                               where r.IsActive == true && r.OperationZoneId == OperationZoneId
                               select new
                {
                    CustomerName = u.CompanyName,
                    CustomerId = r.CustomerId,
                    AdminChargeId = r.AdminChargesId,
                    CreatedBy = r.CreatedBy,
                    ChargeType = r.ChargeType,
                    Key = r.ShortName,
                    Value = r.Name,
                    Amount = r.Value,
                    CurrencyCode = r.CurrencyCode,
                    CreatedOn = r.CreatedOnUtc
                }
                               ).ToList();
                list = charges.GroupBy(x => x.CustomerId)
                       .Select(group => new FrayteCustomerSpecificAdminCharges
                {
                    CustomerId   = group.FirstOrDefault().CustomerId,
                    CustomerName = group.FirstOrDefault().CustomerName,
                    Charges      = group.Select(subGroup => new AdminChargesTypes
                    {
                        AdminChargeId = subGroup.AdminChargeId,
                        Amount        = subGroup.Amount,
                        ChargeType    = subGroup.ChargeType,
                        CreatedBy     = subGroup.CreatedBy,
                        CreatedOn     = subGroup.CreatedOn,
                        Key           = subGroup.Key,
                        CurrencyCode  = subGroup.CurrencyCode,
                        Value         = subGroup.Value
                    }).ToList()
                }).ToList();
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }

            return(list);
        }
Exemplo n.º 12
0
        public EtowerResponseModel CreateShipment(List <ETowerRequestModel> request, int DirectShipmentDraftId)
        {
            EtowerResponseModel response = new EtowerResponseModel();
            var    logisticIntegration   = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.ETOWER);
            string url = logisticIntegration.ServiceUrl + "/services/shipper/orders";
            var    shipmentRequestjson = JsonConvert.SerializeObject(request);
            var    result = ETowerApiCalling(url, shipmentRequestjson, "Shipment");

            response          = Newtonsoft.Json.JsonConvert.DeserializeObject <EtowerResponseModel>(result);
            response.Request  = shipmentRequestjson;
            response.Response = result;
            if (response.status == "Success")
            {
                LabelResponseModel label = new LabelResponseModel();

                #region Label Dwonload

                var eTowerLableRequest = new EtowerLableRequest()
                {
                    labelFormat = "PDF",
                    labelType   = 1,
                    merged      = false,
                    packinglist = true,
                };
                eTowerLableRequest.orderIds = new List <string>();
                eTowerLableRequest.orderIds.Add(response.data[0].orderId);
                var    labeljson     = JsonConvert.SerializeObject(eTowerLableRequest);
                string Labelurl      = logisticIntegration.ServiceUrl + "/services/shipper/labels";
                var    lableResponse = ETowerApiCalling(Labelurl, labeljson, "Label");
                label = JsonConvert.DeserializeObject <LabelResponseModel>(lableResponse);

                if (label.status == "Success")
                {
                    response.data[0].labelContent = label.data[0].labelContent;
                }
                else
                {
                    //Label Error
                }

                #endregion
            }
            else
            {
                var EtowerError = JsonConvert.DeserializeObject <EtowerError>(result);
            }
            return(response);
        }
Exemplo n.º 13
0
        public TimeZoneModal GetOperationTimezone()
        {
            FrayteOperationZone operationZone = UtilityRepository.GetOperationZone();

            var timeZone = (from tz in dbContext.Timezones join
                            c in dbContext.Countries on tz.TimezoneId equals c.TimeZoneId
                            where c.CountryCode == operationZone.OperationZoneName
                            select new TimeZoneModal()
            {
                TimezoneId = tz.TimezoneId,
                Name = tz.Name,
                Offset = tz.Offset,
                OffsetShort = tz.OffsetShort
            }).FirstOrDefault();

            return(timeZone);
        }
Exemplo n.º 14
0
        public FrayteResult SaveCustomerCharge(FrayteCustomerSpecificAdminCharges charge)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                AdminCharge adminCharge;
                foreach (var item in charge.Charges)
                {
                    if (item.AdminChargeId == 0)
                    {
                        adminCharge                 = new AdminCharge();
                        adminCharge.Value           = item.Amount;
                        adminCharge.CustomerId      = charge.CustomerId;
                        adminCharge.CreatedOnUtc    = DateTime.UtcNow;
                        adminCharge.IsActive        = true;
                        adminCharge.Name            = item.Value;
                        adminCharge.ShortName       = item.Key;
                        adminCharge.OperationZoneId = UtilityRepository.GetOperationZone().OperationZoneId;
                        adminCharge.ChargeType      = item.ChargeType;
                        adminCharge.CreatedBy       = item.CreatedBy;
                        adminCharge.CurrencyCode    = "GBP";// item.CurrencyCode;
                        dbcontext.AdminCharges.Add(adminCharge);
                        dbcontext.SaveChanges();
                    }
                    else
                    {
                        adminCharge              = dbcontext.AdminCharges.Find(item.AdminChargeId);
                        adminCharge.Value        = item.Amount;
                        adminCharge.UpdatedOnUtc = DateTime.UtcNow;
                        adminCharge.UpdatedBy    = item.CreatedBy;
                        dbcontext.SaveChanges();
                    }
                }
                result.Status = true;
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                result.Status = false;
            }
            return(result);
        }
Exemplo n.º 15
0
        public BringResponseModel CreateShipment(BringRequestModel bringRequest, int DraftShipmentId, string ShipmentType)
        {
            BringResponseModel response = new BringResponseModel();
            var logisticIntegration     = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.BRING);
            //API Login
            var    shipmentRequestjson = JsonConvert.SerializeObject(bringRequest);
            string result = string.Empty;

            try
            {
                result = CallBringApi(logisticIntegration, shipmentRequestjson);

                if (!string.IsNullOrWhiteSpace(result))
                {
                    response = Newtonsoft.Json.JsonConvert.DeserializeObject <BringResponseModel>(result);
                }
                else
                {
                    var error = new Models.Bring.Error();
                    error.code      = "There is something is error please contact to admin";
                    response.errors = new List <Models.Bring.Error>();
                    response.errors.Add(error);
                    if (ShipmentType == FrayteShipmentServiceType.DirectBooking)
                    {
                        new DirectShipmentRepository().SaveEasyPostErrorObject("Bring-result:-" + @result, "Bring-ShipJSON:-" + shipmentRequestjson, DraftShipmentId);
                    }
                }
                response.request  = shipmentRequestjson;
                response.response = result;
            }
            catch (Exception ex)
            {
                var error = new Models.Bring.Error();
                error.code = ex.InnerException.ToString();
                response.errors.Add(error);
                if (ShipmentType == FrayteShipmentServiceType.DirectBooking)
                {
                    new DirectShipmentRepository().SaveEasyPostErrorObject("Bring-result:-" + @result, "Bring-ShipJSON:-" + shipmentRequestjson, DraftShipmentId);
                }
            }
            return(response);
        }
Exemplo n.º 16
0
        public List <FrayteCustomerAssociatedUser> GetCustomerDetail(string Name, int RoleId)
        {
            List <FrayteCustomerAssociatedUser> customer = new List <FrayteCustomerAssociatedUser>();

            // To Do : customer should come according to moduleType
            var operationzone = UtilityRepository.GetOperationZone();

            if (RoleId == (int)FrayteUserRole.Admin || RoleId == (int)FrayteUserRole.Staff)
            {
                var findUser = (from u in dbContext.Users.Where(p => p.ContactName.Contains(Name))
                                join ur in dbContext.UserRoles on u.UserId equals ur.UserId
                                where u.IsActive == true &&
                                u.OperationZoneId == operationzone.OperationZoneId &&
                                ur.RoleId == (int)FrayteUserRole.Customer
                                select u).ToList();

                if (findUser != null && findUser.Count > 0)
                {
                    FrayteCustomerAssociatedUser associateUser;
                    foreach (var uu in findUser)
                    {
                        var phonecode = (from ua in dbContext.UserAddresses
                                         join c in dbContext.Countries on ua.CountryId equals c.CountryId
                                         where ua.UserId == uu.UserId
                                         select new
                        {
                            PhoneCode = c.CountryPhoneCode
                        }).FirstOrDefault();

                        associateUser              = new FrayteCustomerAssociatedUser();
                        associateUser.UserId       = uu.UserId;
                        associateUser.ContactName  = uu.ContactName;
                        associateUser.Email        = uu.UserEmail;
                        associateUser.TelephoneNo  = (phonecode == null || phonecode.PhoneCode == "") ? uu.TelephoneNo : "(+" + phonecode.PhoneCode + ") " + uu.TelephoneNo;
                        associateUser.WorkingHours = UtilityRepository.GetWorkingHours(uu.WorkingStartTime, uu.WorkingEndTime);
                        customer.Add(associateUser);
                    }
                }
            }

            return(customer);
        }
Exemplo n.º 17
0
        public JobsInProgressCount GetJobsInProgressCount()
        {
            JobsInProgressCount jobCount = new JobsInProgressCount();

            try
            {
                var OperationZone = UtilityRepository.GetOperationZone();
                var data          = dbContext.eCommerceShipments
                                    .Where(p => (p.CustomManifestId == null || p.CustomManifestId == 0) && p.ShipmentStatusId == (int)FrayteShipmentStatus.eCCurrent &&
                                           p.OpearionZoneId == OperationZone.OperationZoneId).ToList();
                if (data != null && data.Count > 0)
                {
                    jobCount.TotalJobs = data.Count;
                }
                else
                {
                    jobCount.TotalJobs = 0;
                }

                var mycount1 = (from cnt in dbContext.eCommerceShipmentDetails
                                join ec in dbContext.eCommerceShipments on cnt.eCommerceShipmentId equals ec.eCommerceShipmentId
                                where ec.OpearionZoneId == OperationZone.OperationZoneId && // ec.eCommerceShipmentId == 11 &&
                                ec.ShipmentStatusId == (int)FrayteShipmentStatus.eCCurrent && (ec.CustomManifestId == null || ec.CustomManifestId == 0) &&
                                ec.AssignedTo != null
                                group cnt by cnt.eCommerceShipmentId into g
                                select new
                {
                    name = g.Key,
                    HSCode = g.Min(r => string.IsNullOrEmpty(r.HSCode) ? "" : r.HSCode),
                    count = g.Count()
                }).ToList().Where(p => !string.IsNullOrEmpty(p.HSCode)).ToList();
                var mycount = mycount1.Count;
                jobCount.CompletedJobs = mycount;
                return(jobCount);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(jobCount);
            }
        }
        public FrayteResult MailSendToControlDept(string FileName, string FilePath, List <FrayteUploadshipment> UnpaidShipments)
        {
            FrayteResult fr = new FrayteResult();

            var            operationzone = UtilityRepository.GetOperationZone();
            string         logoImage     = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";
            DynamicViewBag viewBag       = new DynamicViewBag();

            viewBag.AddValue("TrackingDescription", "Please find the attachment.");
            viewBag.AddValue("Name", AppSettings.ControllerDeptName);
            viewBag.AddValue("ImageHeader", "FrayteLogo");

            if (operationzone.OperationZoneId == 1)
            {
                viewBag.AddValue("SiteAddress", AppSettings.TrackingUrl);
            }
            else
            {
                viewBag.AddValue("SiteAddress", AppSettings.TrackingUrl);
            }
            var res = UnpaidShipments[0];
            //string template = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/eCommerceControlDept.cshtml");
            string template = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/dhl.cshtml");

            TemplateService templateService    = new TemplateService();
            var             EmailBody          = templateService.Parse(template, res, viewBag, null);
            string          EmailSubject       = "Manifest Tracking";
            string          Attachmentfilepath = FilePath;
            var             To = AppSettings.ControllerDeptEmail;
            //_log.Error(MTM.ReceiverMail);
            //var To = "*****@*****.**";
            //var CC = customerDetail.UserEmail;
            string Status = "Confirmation";

            //Send mail to Customer
            //SendMail_New(To, CC, "FRAYTE (" + UtilityRepository.OperationZoneName(operationzone.OperationZoneId) + ")", EmailSubject, EmailBody, Attachment, Status);
            FrayteEmail.SendMail(To, "", EmailSubject, EmailBody, Attachmentfilepath, logoImage);
            return(fr);
        }
Exemplo n.º 19
0
        public List <FrayteZone> GetZoneList()
        {
            FrayteOperationZone OperationZone = UtilityRepository.GetOperationZone();
            //var list = dbContext.Zones.Where(p => p.OperationZoneId == OperationZone.OperationZoneId).ToList();
            var list = (from ls in dbContext.LogisticServices
                        join lsz in dbContext.LogisticServiceZones on ls.LogisticServiceId equals lsz.LogisticServiceId
                        where ls.OperationZoneId == OperationZone.OperationZoneId
                        select new FrayteZone
            {
                ZoneId = lsz.LogisticServiceZoneId,
                OperationZoneId = ls.OperationZoneId,
                ZoneName = lsz.ZoneName,
                ZoneDisplayName = lsz.ZoneDisplayName,
                ZoneColor = lsz.ZoneColor,
                LogisticType = ls.LogisticType,
                CourierComapny = ls.LogisticCompany,
                RateType = ls.RateType,
                ModuleType = ls.ModuleType
            }).ToList();

            return(list);
        }
Exemplo n.º 20
0
        public List <FrayteLogisticServiceItem> GetCustomerLogisticServiceItems(int UserId)
        {
            FrayteOperationZone OperationZone = UtilityRepository.GetOperationZone();

            var list = (from cl in dbContext.CustomerLogistics
                        join ls in dbContext.LogisticServices on cl.LogisticServiceId equals ls.LogisticServiceId
                        where
                        cl.UserId == UserId &&
                        ls.IsActive == true
                        select new FrayteLogisticServiceItem
            {
                LogisticServiceId = ls.LogisticServiceId,
                LogisticCompany = ls.LogisticCompany,
                LogisticCompanyDisplay = ls.LogisticCompanyDisplay,
                LogisticType = ls.LogisticType,
                LogisticTypeDisplay = ls.LogisticTypeDisplay,
                RateType = ls.RateType,
                RateTypeDisplay = ls.RateTypeDisplay,
                IssueDate = ls.IssuedDate.HasValue ? ls.IssuedDate.Value : DateTime.UtcNow,
                ExpiryDate = ls.ExpiryDate.HasValue ? ls.ExpiryDate.Value : DateTime.UtcNow
            }).OrderBy(p => p.LogisticCompany).ToList();

            return(list);
        }
Exemplo n.º 21
0
        public List <FrayteRateCardLogisticServices> RateCardLogisticServices(int operationZoneId)
        {
            var OperationZone = UtilityRepository.GetOperationZone();
            var list          = (from r in dbContext.LogisticServices
                                 join ld in dbContext.LogisticServiceDetails on r.LogisticServiceId equals ld.LogisticServiceId into lsdTemp
                                 from ldTemp in lsdTemp.DefaultIfEmpty()
                                 join ls in dbContext.LogisticServiceShipmentTypes on r.LogisticServiceId equals ls.LogisticServiceId into lsTemp
                                 from sTemp in lsTemp.DefaultIfEmpty()
                                 where r.OperationZoneId == OperationZone.OperationZoneId && r.ModuleType == FrayteShipmentServiceType.DirectBooking && r.IsActive == true
                                 select new FrayteRateCardLogisticServices
            {
                LogisticServiceId = r.LogisticServiceId,
                DocType = sTemp == null? "": sTemp.LogisticDescription,
                DocTypeDisplay = sTemp == null ? "" : sTemp.LogisticDescriptionDisplayType,
                LogisticType = r.LogisticType,
                LogisticTypeDisplay = r.LogisticTypeDisplay,
                LogisticCompany = r.LogisticCompany,
                LogisticCompanyDisplay = r.LogisticCompanyDisplay,
                RateType = r.RateType,
                RateTypeDisplay = r.RateTypeDisplay,
                OperationZoneId = r.OperationZoneId,
                AddressType = ldTemp == null? "": ldTemp.AddressType,
                AddressTypeDisplay = ldTemp == null ? "" : ldTemp.AddressTypeDisplay,
                PackageType = ldTemp == null ? "" : ldTemp.PackageType,
                PackageTypeDisplay = ldTemp == null ? "" : ldTemp.PackageTypeDisplay,
                ParcelType = ldTemp == null ? "" : ldTemp.ParcelType,
                ParcelTypeDisplay = ldTemp == null ? "" : ldTemp.ParcelTypeDisplay,
                PODType = ldTemp == null ? "" : ldTemp.PODType,
                PODTypeDisplay = ldTemp == null ? "" : ldTemp.PODTypeDisplay,
                ServiceType = ldTemp == null ? "" : ldTemp.ServiceType,
                ServiceTypeDisplay = ldTemp == null ? "" : ldTemp.ServiceTypeDisplay,
                ModuleType = r.ModuleType
            }).ToList();

            return(list);
        }
Exemplo n.º 22
0
        public SkyPostalTrackingResponseModel SkyPostalTrackWebApiCalling(SkyPostalTrackingModel trackModel)
        {
            SkyPostalTrackingResponseModel result = new SkyPostalTrackingResponseModel();
            string response = string.Empty;

            try
            {
                var logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.SKYPOSTAL);

                var skyPostalJson = Newtonsoft.Json.JsonConvert.SerializeObject(trackModel);

                WebClient client = new WebClient();
                client.UseDefaultCredentials         = true;
                client.Credentials                   = CredentialCache.DefaultCredentials;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                SslProtocols         _Tls12 = (SslProtocols)0x00000C00;
                SecurityProtocolType Tls12  = (SecurityProtocolType)_Tls12;
                ServicePointManager.SecurityProtocol = Tls12;

                response = client.UploadString(logisticIntegration.ServiceUrl, "POST", skyPostalJson);
                if (!string.IsNullOrWhiteSpace(response))
                {
                    result = Newtonsoft.Json.JsonConvert.DeserializeObject <SkyPostalTrackingResponseModel>(response);
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception ex)
            {
                result = null;
            }

            return(result);
        }
        public FrayteManifestName DownloadRateCardExcelTemplate(string CourierCompany, string LogisticType, string RateType)
        {
            FrayteManifestName file = new FrayteManifestName();

            FrayteOperationZone OperationZone = UtilityRepository.GetOperationZone();

            var zonelist = (from lsz in dbContext.LogisticServiceZones
                            join ls in dbContext.LogisticServices on lsz.LogisticServiceId equals ls.LogisticServiceId
                            where ls.OperationZoneId == OperationZone.OperationZoneId &&
                            ls.LogisticCompany == CourierCompany &&
                            ls.LogisticType == LogisticType &&
                            ls.RateType == RateType
                            select new FrayteBaseRateCardZone
            {
                LogisticZoneId = lsz.LogisticServiceZoneId,
                LogisticZoneName = lsz.ZoneDisplayName
            }).ToList();

            var weightlist = (from lsw in dbContext.LogisticServiceWeights
                              join lsst in dbContext.LogisticServiceShipmentTypes on lsw.LogisticServiceShipmentTypeId equals lsst.LogisticServiceShipmentTypeId
                              join ls in dbContext.LogisticServices on lsst.LogisticServiceId equals ls.LogisticServiceId
                              where ls.OperationZoneId == OperationZone.OperationZoneId &&
                              ls.LogisticCompany == CourierCompany &&
                              ls.LogisticType == LogisticType &&
                              ls.RateType == RateType
                              select new FrayteBaseRateCardWeight
            {
                LogisticWeightId = lsw.LogisticServiceWeightId,
                LogisticWeight = lsw.WeightToDisplay,
                LogisticShipmentType = lsst.LogisticDescription
            }).ToList();

            Application ExcelApp       = new Application();
            Workbook    ExcelWorkBook  = null;
            Worksheet   ExcelWorkSheet = null;

            //ExcelApp.Visible = true;
            ExcelWorkBook = ExcelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);

            try
            {
                int r = 1;
                ExcelWorkBook.Worksheets.Add();
                ExcelWorkSheet = ExcelWorkBook.Worksheets[1];
                for (int i = 0; i < zonelist.Count; i++)
                {
                    ExcelWorkSheet.Cells[r, i + 4]     = zonelist[i].LogisticZoneId;
                    ExcelWorkSheet.Cells[r + 1, i + 4] = zonelist[i].LogisticZoneName;
                }
                r++;

                for (int j = 0; j < weightlist.Count; j++)
                {
                    ExcelWorkSheet.Cells[r + 1, 1] = weightlist[j].LogisticWeightId;
                    ExcelWorkSheet.Cells[r + 1, 2] = weightlist[j].LogisticShipmentType;
                    ExcelWorkSheet.Cells[r + 1, 3] = weightlist[j].LogisticWeight;
                    r++;
                }

                ExcelWorkBook.SaveAs(HostingEnvironment.MapPath("~/UploadFiles/BaseRateCardUpdate/" + CourierCompany + " " + LogisticType + " " + RateType));
                ExcelWorkBook.Close();
                ExcelApp.Quit();
                Marshal.ReleaseComObject(ExcelWorkSheet);
                Marshal.ReleaseComObject(ExcelWorkBook);
                Marshal.ReleaseComObject(ExcelApp);

                file.FileName = CourierCompany + " " + LogisticType + " " + RateType + ".xlsx";
                file.FilePath = AppSettings.WebApiPath + "UploadFiles/BaseRateCardUpdate/" + CourierCompany + " " + LogisticType + " " + RateType + ".xlsx";
            }
            catch (Exception ex)
            {
            }
            finally
            {
                foreach (Process process in Process.GetProcessesByName("Excel"))
                {
                    process.Kill();
                }
            }

            return(file);
        }
Exemplo n.º 24
0
        public FrayteCustomerSpecificAdminCharges GetDefaultCustomerAdminCharges(int customerId)
        {
            try
            {
                var OperationZoneId = UtilityRepository.GetOperationZone().OperationZoneId;
                FrayteCustomerSpecificAdminCharges charge = new FrayteCustomerSpecificAdminCharges();
                charge.Charges = new List <AdminChargesTypes>();
                var data = (from r in dbcontext.AdminCharges
                            join u in dbcontext.Users on r.CustomerId equals u.UserId
                            join ua in dbcontext.UserAdditionals on r.CustomerId equals ua.UserId
                            where r.CustomerId == customerId && r.IsActive == true && r.OperationZoneId == OperationZoneId
                            select new
                {
                    CustomerName = u.CompanyName,
                    CustomerId = r.CustomerId,
                    AdminChargeId = r.AdminChargesId,
                    CreatedBy = r.CreatedBy,
                    ChargeType = r.ChargeType,
                    Key = r.ShortName,
                    Value = r.Name,
                    Amount = r.Value,
                    Currency = r.CurrencyCode,
                    CreatedOn = r.CreatedOnUtc
                }).ToList();
                if (data == null || (data != null && data.Count == 0))
                {
                    data = (from r in dbcontext.AdminCharges
                            where r.CustomerId == 0 && r.IsActive == true && r.OperationZoneId == OperationZoneId
                            select new
                    {
                        CustomerName = "",
                        CustomerId = r.CustomerId,
                        AdminChargeId = r.AdminChargesId,
                        CreatedBy = r.CreatedBy,
                        ChargeType = r.ChargeType,
                        Key = r.ShortName,
                        Value = r.Name,
                        Amount = r.Value,
                        Currency = r.CurrencyCode,
                        CreatedOn = r.CreatedOnUtc
                    }).ToList();
                }

                charge = data.GroupBy(x => x.CustomerId)
                         .Select(group => new FrayteCustomerSpecificAdminCharges
                {
                    CustomerId   = group.FirstOrDefault().CustomerId,
                    CustomerName = group.FirstOrDefault().CustomerName,
                    Charges      = group.Select(subGroup => new AdminChargesTypes
                    {
                        AdminChargeId = subGroup.AdminChargeId,
                        Amount        = subGroup.Amount,
                        ChargeType    = subGroup.ChargeType,
                        CreatedBy     = subGroup.CreatedBy,
                        CreatedOn     = subGroup.CreatedOn,
                        Key           = subGroup.Key,
                        CurrencyCode  = subGroup.Currency,
                        Value         = subGroup.Value
                    }).ToList()
                }).FirstOrDefault();
                return(charge);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(null);
            }
        }
Exemplo n.º 25
0
        public List <AdminChargesTypes> CreateCharges(List <AdminChargesTypes> charges)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                AdminCharge adminCharge;
                foreach (var item in charges)
                {
                    if (item.AdminChargeId == 0)
                    {
                        adminCharge                 = new AdminCharge();
                        adminCharge.ChargeType      = item.ChargeType;
                        adminCharge.CreatedBy       = item.CreatedBy;
                        adminCharge.CreatedOnUtc    = DateTime.UtcNow;
                        adminCharge.CustomerId      = 0;
                        adminCharge.Name            = item.Value;
                        adminCharge.ShortName       = item.Key;
                        adminCharge.Value           = item.Amount;
                        adminCharge.OperationZoneId = UtilityRepository.GetOperationZone().OperationZoneId;
                        adminCharge.IsActive        = true;
                        adminCharge.CurrencyCode    = "GBP"; // item.CurrencyCode;
                                                             //dbcontext.AdminCharges.Attach(adminCharge);
                        dbcontext.AdminCharges.Add(adminCharge);
                        dbcontext.SaveChanges();
                        item.AdminChargeId = adminCharge.AdminChargesId;

                        var collection = GetCustomerSpecificAdminCharges();

                        if (collection.Count > 0)
                        {
                            foreach (var ite in collection)
                            {
                                AdminCharge customerAdminCharge = new AdminCharge();
                                customerAdminCharge.ChargeType      = item.ChargeType;
                                customerAdminCharge.CreatedBy       = item.CreatedBy;
                                customerAdminCharge.CreatedOnUtc    = DateTime.UtcNow;
                                customerAdminCharge.CustomerId      = ite.CustomerId;
                                customerAdminCharge.Name            = item.Value;
                                customerAdminCharge.ShortName       = item.Key;
                                customerAdminCharge.Value           = item.Amount;
                                customerAdminCharge.OperationZoneId = UtilityRepository.GetOperationZone().OperationZoneId;
                                customerAdminCharge.IsActive        = true;
                                customerAdminCharge.CurrencyCode    = "GBP"; // item.CurrencyCode;
                                                                             //dbcontext.AdminCharges.Attach(adminCharge);
                                dbcontext.AdminCharges.Add(customerAdminCharge);
                                dbcontext.SaveChanges();
                            }
                        }
                    }
                    else
                    {
                        adminCharge = dbcontext.AdminCharges.Find(item.AdminChargeId);
                        if (adminCharge != null)
                        {
                            adminCharge.UpdatedBy    = item.CreatedBy;
                            adminCharge.UpdatedOnUtc = DateTime.UtcNow;
                            adminCharge.Value        = item.Amount;

                            dbcontext.SaveChanges();
                        }
                    }
                }
                result.Status = true;
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                result.Status = false;
            }
            if (result.Status)
            {
                return(charges);
            }
            else
            {
                return(null);
            }
        }
        public List <TradelaneBookingReportMAWB> GetMAWBObj(int tradelaneShipmentId)
        {
            try
            {
                List <TradelaneBookingReportMAWB> list        = new List <TradelaneBookingReportMAWB>();
                TradelaneBookingReportMAWB        reportModel = new TradelaneBookingReportMAWB();
                var    ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, "");
                var    Custompdf      = new TradelaneShipmentRepository().GetMawbCustomizePdf(tradelaneShipmentId);
                string mawb           = string.Empty;
                if (!string.IsNullOrEmpty(ShipmentDetail.MAWB))
                {
                    if (ShipmentDetail.MAWB.Length == 8)
                    {
                        mawb = ShipmentDetail.MAWB.Substring(0, 4) + " " + ShipmentDetail.MAWB.Substring(3, 4);
                    }
                    else
                    {
                        mawb = ShipmentDetail.MAWB;
                    }
                }
                reportModel.MAWB                   = mawb;
                reportModel.ShipperAddress         = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipFrom, ShipmentDetail.DepartureAirport.AirportCode);
                reportModel.ShipperAccountNumber   = string.Empty;
                reportModel.ConsigneeAddress       = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipTo, ShipmentDetail.DestinationAirport.AirportCode);
                reportModel.ConsigneeAccountNumber = string.Empty;
                reportModel.NotifyParty            = ShipmentDetail.IsNotifyPartySameAsReceiver ? "NOTIFY: " + reportModel.ConsigneeAddress : "NOTIFY: " + UtilityRepository.ConcatinateAddress(ShipmentDetail.NotifyParty, "");
                reportModel.CarrierAgent           = string.Empty;
                reportModel.AirportofDeparture     = ShipmentDetail.ShipFrom.Country.Name;
                reportModel.DestinationAirport     = ShipmentDetail.DestinationAirport.AirportName;
                reportModel.DestinationAirportCode = ShipmentDetail.DestinationAirport.AirportCode;
                reportModel.CurencyCode            = ShipmentDetail.DeclaredCurrency.CurrencyCode;
                reportModel.AmountOfInsurance      = ShipmentDetail.InsuranceAmount.HasValue ? ShipmentDetail.InsuranceAmount.Value : 0;
                reportModel.MAWBCode               = ShipmentDetail.AirlinePreference.AilineCode;
                reportModel.MAWBWithCode           = ShipmentDetail.AirlinePreference.AilineCode + " " + mawb;
                reportModel.MAWBCountryCode        = ShipmentDetail.ShipFrom.Country.Code;
                reportModel.ShipmentDescription    = ShipmentDetail.ShipmentDescription;
                reportModel.Airline                = ShipmentDetail.AirlinePreference.AirLineName;

                reportModel.IssuingCarriersAgentNameandCity = Custompdf.IssuingCarriersAgentNameandCity;
                reportModel.AccountNo = Custompdf.AccountNo;
                reportModel.DeclaredValueForCarriage = Custompdf.DeclaredValueForCarriage;
                reportModel.DeclaredValueForCustoms  = Custompdf.DeclaredValueForCustoms;
                reportModel.ValuationCharge          = Custompdf.ValuationCharge;
                reportModel.Tax = Custompdf.Tax;
                reportModel.TotalOtherChargesDueAgent   = Custompdf.TotalOtherChargesDueAgent;
                reportModel.TotalOtherChargesDueCarrier = Custompdf.TotalOtherChargesDueCarrier;
                reportModel.OtherCharges            = Custompdf.OtherCharges;
                reportModel.ChargesAtDestination    = Custompdf.ChargesAtDestination;
                reportModel.TotalCollectCharges     = Custompdf.TotalCollectCharges;
                reportModel.CurrencyConversionRates = Custompdf.CurrencyConversionRates;
                reportModel.TotalPrepaid            = Custompdf.TotalPrepaid;
                reportModel.TotalCollect            = Custompdf.TotalCollect;
                reportModel.HandlingInformation     = Custompdf.HandlingInformation;
                reportModel.AgentsIATACode          = Custompdf.AgentsIATACode;

                if (UtilityRepository.GetOperationZone().OperationZoneId == 1)
                {
                    reportModel.IssuedBy  = "FRAYTE LOGISTICS LIMITED" + Environment.NewLine;
                    reportModel.IssuedBy += "501 5/F KWONG LOONG TAI BUILDING" + Environment.NewLine;
                    reportModel.IssuedBy += "1016-1018 TAI NAN WEST STREET" + ", " + "CHEUNG SHA WAN" + " ," + "HON";
                }
                else
                {
                    reportModel.IssuedBy  = "FRAYTE LOGISTICS LIMITED" + Environment.NewLine;
                    reportModel.IssuedBy += "501 5/F KWONG LOONG TAI BUILDING" + Environment.NewLine;
                    reportModel.IssuedBy += "1016-1018 TAI NAN WEST STREET" + ", " + "CHEUNG SHA WAN" + " ," + "HON";
                }

                List <HAWBTradelanePackage> package;
                var collection = (from r in dbContext.TradelaneShipmentDetails
                                  join s in dbContext.TradelaneShipments on r.TradelaneShipmentId equals s.TradelaneShipmentId
                                  select new
                {
                    HAWBNumber = s.HAWBNumber,
                    TradelaneShipmentId = r.TradelaneShipmentId,
                    TradelaneShipmentDetailId = r.TradelaneShipmentDetailId,
                    CartonNumber = r.CartonNumber,
                    CartonValue = r.CartonValue,
                    Length = r.Length,
                    Width = r.Width,
                    Height = r.Height,
                    Weight = r.Weight,
                    HAWB = r.HAWB
                }).Where(p => p.TradelaneShipmentId == tradelaneShipmentId).ToList();

                if (collection.Count > 0)
                {
                    package = collection.GroupBy(x => x.HAWB)
                              .Select(group => new HAWBTradelanePackage
                    {
                        TradelaneShipmentId = group.FirstOrDefault().TradelaneShipmentId,
                        HAWB            = group.Key,
                        HAWBNumber      = group.FirstOrDefault().HAWBNumber.HasValue ? group.FirstOrDefault().HAWBNumber.Value : 0,
                        TotalCartons    = group.Select(p => p.CartonValue).Sum(),
                        EstimatedWeight = group.Select(p => p.Weight * p.CartonValue).Sum(),
                        TotalVolume     = group.Select(p => (p.Length * p.Width * p.Height) * p.CartonValue).Sum(),
                        TotalWeight     = group.Select(p => p.Weight * p.CartonValue).Sum(),
                        Packages        = group.Select(subGroup => new TradelanePackage
                        {
                            CartonNumber = subGroup.CartonNumber,
                            CartonValue  = subGroup.CartonValue,
                            HAWB         = subGroup.HAWB,
                            Height       = subGroup.Height,
                            Length       = subGroup.Length,
                            TradelaneShipmentDetailId = subGroup.TradelaneShipmentDetailId,
                            TradelaneShipmentId       = subGroup.TradelaneShipmentId,
                            Weight = subGroup.Weight,
                            Width  = subGroup.Width
                        }).ToList()
                    }).ToList();
                }
                else
                {
                    return(null);
                }

                if (package != null)
                {
                    reportModel.TotalCartons    = package.Sum(p => p.TotalCartons);
                    reportModel.TotalWeight     = package.Sum(p => p.TotalWeight);
                    reportModel.EstimatedWeight = package.Sum(p => p.EstimatedWeight);
                    reportModel.TotalVolume     = reportModel.TotalVolume = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? Math.Round(package.Sum(p => p.TotalVolume) / (100 * 100 * 100), 2) : Math.Round(package.Sum(p => p.TotalVolume) / (39.37M * 39.37M * 39.37M), 2);
                    reportModel.DimensionUnit   = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CM" : "IN";
                    reportModel.WeightUnit      = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "KG" : "LB";
                    reportModel.VolumeUnit      = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CBM" : "CBM";

                    reportModel.ShipmentDescription += Environment.NewLine + "VOL " + reportModel.TotalVolume + " " + reportModel.VolumeUnit;
                    reportModel.ShipmentDescription += Environment.NewLine + "VOL WEIGHT = " + reportModel.TotalWeight + " " + reportModel.WeightUnit;
                    reportModel.CreatedOn            = DateTime.UtcNow;
                    reportModel.Signature            = "Frayte Logistics SPX";
                    reportModel.CreatedOnCountry     = "Hong Kong";
                }

                list.Add(reportModel);
                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 27
0
        public USPSResponse CreateShipment(USPSRequest request, int ExpressId)
        {
            USPSResponse response = new USPSResponse();

            FrayteLogisticIntegration logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.USPS);

            string res = string.Empty;

            request.header.key     = logisticIntegration.InetgrationKey;
            request.header.version = logisticIntegration.AppVersion;

            var usps = Newtonsoft.Json.JsonConvert.SerializeObject(request);

            res      = GetResponse(logisticIntegration, usps);
            response = JsonConvert.DeserializeObject <USPSResponse>(res);
            var error = JsonConvert.DeserializeObject <USPSError>(res);

            return(response);
        }
Exemplo n.º 28
0
        public string CreateXMLDPDCHLogin()
        {
            string xmlPath = string.Empty;

            try
            {
                var logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.DPDCH);
                if (AppSettings.LabelSave == "")
                {
                    xmlPath = AppSettings.WebApiPath + "/UploadFiles/PDFGenerator/HTMLFile";
                    // _log.Error("if section" + xmlPath);
                }
                else
                {
                    if (AppSettings.ShipmentCreatedFrom == "BATCH")
                    {
                        xmlPath = AppSettings.WebApiPath + "/UploadFiles/PDFGenerator/HTMLFile";
                        //_log.Error("else section BATCH" + xmlPath);
                    }
                    else
                    {
                        // _log.Error("else section BATCH");
                        xmlPath = HttpContext.Current.Server.MapPath("~/UploadFiles/PDFGenerator/HTMLFile");
                    }
                }

                if (!Directory.Exists(xmlPath))
                {
                    Directory.CreateDirectory(xmlPath);
                }

                xmlPath = xmlPath + "/DPDCHLogin.xml";
                //_log.Error(xmlPath);
                if (File.Exists(xmlPath))
                {
                    File.Delete(xmlPath);
                }
                XmlDocument xmlDoc = new XmlDocument();

                // XML Declaration
                XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                string         soapNSURI      = "http://schemas.xmlsoap.org/soap/envelope/";
                // Create the root element soapenv:Envelope
                XmlElement rootEnvelope = xmlDoc.CreateElement("soapenv:Envelope", soapNSURI);
                rootEnvelope.SetAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
                rootEnvelope.SetAttribute("xmlns:ns", "http://dpd.com/common/service/types/LoginService/2.0");

                xmlDoc.AppendChild(rootEnvelope);

                // Create soapenv:Header
                XmlElement headerNode = xmlDoc.CreateElement("soapenv:Header", soapNSURI);

                // Append soapenv:Header
                rootEnvelope.AppendChild(headerNode);
                XmlElement bodyNode = xmlDoc.CreateElement("soapenv:Body", soapNSURI);

                XmlElement getAuth = xmlDoc.CreateElement("ns:getAuth", "ns");

                XmlElement usernameNode = xmlDoc.CreateElement("delisId");
                usernameNode.AppendChild(xmlDoc.CreateTextNode(logisticIntegration.UserName.ToString()));

                XmlElement password = xmlDoc.CreateElement("password");
                password.AppendChild(xmlDoc.CreateTextNode(logisticIntegration.Password.ToString()));

                XmlElement messageLanguage = xmlDoc.CreateElement("messageLanguage");
                messageLanguage.AppendChild(xmlDoc.CreateTextNode("de_EN"));

                getAuth.AppendChild(usernameNode);
                getAuth.AppendChild(password);
                getAuth.AppendChild(messageLanguage);
                bodyNode.AppendChild(getAuth);

                rootEnvelope.AppendChild(bodyNode);
                xmlDoc.Save(xmlPath);
                return(xmlPath);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 29
0
        public string CreateXMLDPDCH(DPDChRequestModel dPdChRequestModel)
        {
            string xmlPath = string.Empty;

            try
            {
                var logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.DHL);

                if (AppSettings.LabelSave == "")
                {
                    xmlPath = AppSettings.WebApiPath + "/UploadFiles/PDFGenerator/HTMLFile";
                    // _log.Error("if section" + xmlPath);
                }
                else
                {
                    if (AppSettings.ShipmentCreatedFrom == "BATCH")
                    {
                        xmlPath = AppSettings.WebApiPath + "/UploadFiles/PDFGenerator/HTMLFile";
                        //_log.Error("else section BATCH" + xmlPath);
                    }
                    else
                    {
                        // _log.Error("else section BATCH");
                        xmlPath = HttpContext.Current.Server.MapPath("~/UploadFiles/PDFGenerator/HTMLFile");
                    }
                }

                if (!Directory.Exists(xmlPath))
                {
                    Directory.CreateDirectory(xmlPath);
                }

                xmlPath = xmlPath + "/DPDCHShipment.xml";
                //_log.Error(xmlPath);
                if (File.Exists(xmlPath))
                {
                    File.Delete(xmlPath);
                }

                XmlDocument xmlDoc = new XmlDocument();

                // XML Declaration
                XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                string         soapNSURI      = "http://schemas.xmlsoap.org/soap/envelope/";
                // Create the root element soapenv:Envelope
                XmlElement rootEnvelope = xmlDoc.CreateElement("soapenv:Envelope", soapNSURI);
                rootEnvelope.SetAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
                rootEnvelope.SetAttribute("xmlns:ns", "http://dpd.com/common/service/types/Authentication/2.0");
                rootEnvelope.SetAttribute("xmlns:ns1", "http://dpd.com/common/service/types/ShipmentService/3.2");

                xmlDoc.AppendChild(rootEnvelope);

                //#region soapenv:Header
                XmlElement headerNode = xmlDoc.CreateElement("soapenv:Header", soapNSURI);

                // Append soapenv:Header
                XmlElement authentication = xmlDoc.CreateElement("ns:authentication", "ns");

                XmlElement usernameNode = xmlDoc.CreateElement("delisId");
                usernameNode.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.UserName));

                XmlElement authToken = xmlDoc.CreateElement("authToken");
                authToken.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.AuthToken));

                XmlElement messageLanguage = xmlDoc.CreateElement("messageLanguage");
                messageLanguage.AppendChild(xmlDoc.CreateTextNode("de_EN"));

                authentication.AppendChild(usernameNode);
                authentication.AppendChild(authToken);
                authentication.AppendChild(messageLanguage);

                headerNode.AppendChild(authentication);

                rootEnvelope.AppendChild(headerNode);

                XmlElement bodyNode = xmlDoc.CreateElement("soapenv:Body", soapNSURI);

                XmlElement storeOrders = xmlDoc.CreateElement("ns1:storeOrders", "ns1");

                XmlElement printOptions = xmlDoc.CreateElement("printOptions");

                XmlElement printerLanguage = xmlDoc.CreateElement("printerLanguage");

                printerLanguage.AppendChild(xmlDoc.CreateTextNode("PDF"));

                XmlElement paperFormat = xmlDoc.CreateElement("paperFormat");
                paperFormat.AppendChild(xmlDoc.CreateTextNode("A6"));

                printOptions.AppendChild(printerLanguage);
                printOptions.AppendChild(paperFormat);

                XmlElement order = xmlDoc.CreateElement("order");

                XmlElement generalShipmentData = xmlDoc.CreateElement("generalShipmentData");

                XmlElement sendingDepot = xmlDoc.CreateElement("sendingDepot");
                sendingDepot.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.SendingDepot));

                XmlElement product = xmlDoc.CreateElement("product");
                product.AppendChild(xmlDoc.CreateTextNode("CL"));

                XmlElement sender = xmlDoc.CreateElement("sender");

                generalShipmentData.AppendChild(sendingDepot);
                generalShipmentData.AppendChild(product);

                XmlElement name1 = xmlDoc.CreateElement("name1");
                name1.AppendChild(xmlDoc.CreateTextNode((dPdChRequestModel.Shipper.Company == null || dPdChRequestModel.Shipper.Company == "") ? dPdChRequestModel.Shipper.Contact : dPdChRequestModel.Shipper.Company));

                XmlElement name2 = xmlDoc.CreateElement("name2");
                name2.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Shipper.Address1));

                XmlElement street = xmlDoc.CreateElement("street");
                street.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Shipper.Address2));

                XmlElement country = xmlDoc.CreateElement("country");
                country.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Shipper.Country));

                XmlElement zipCode = xmlDoc.CreateElement("zipCode");
                zipCode.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Shipper.Postcode));

                XmlElement city = xmlDoc.CreateElement("city");
                city.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Shipper.Town));

                XmlElement phone = xmlDoc.CreateElement("phone");
                phone.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Shipper.Telephone));

                sender.AppendChild(name1);
                sender.AppendChild(name2);
                sender.AppendChild(street);
                sender.AppendChild(country);
                sender.AppendChild(zipCode);
                sender.AppendChild(city);
                sender.AppendChild(phone);

                XmlElement recipient = xmlDoc.CreateElement("recipient");

                XmlElement recipientname = xmlDoc.CreateElement("name1");
                recipientname.AppendChild(xmlDoc.CreateTextNode((dPdChRequestModel.Recipient.Company == null || dPdChRequestModel.Recipient.Company == "") ? dPdChRequestModel.Recipient.Contact : dPdChRequestModel.Recipient.Company));

                XmlElement recipientname2 = xmlDoc.CreateElement("name2");
                recipientname2.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Recipient.Address1));

                XmlElement recipientstreet = xmlDoc.CreateElement("street");
                recipientstreet.AppendChild(xmlDoc.CreateTextNode((dPdChRequestModel.Recipient.Address2 == null || dPdChRequestModel.Recipient.Address2 == "") ? dPdChRequestModel.Recipient.Address1 : dPdChRequestModel.Recipient.Address2));

                XmlElement recipientcountry = xmlDoc.CreateElement("country");
                recipientcountry.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Recipient.Country));

                XmlElement recipientzipCode = xmlDoc.CreateElement("zipCode");
                recipientzipCode.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Recipient.Postcode));

                XmlElement recipientcity = xmlDoc.CreateElement("city");
                recipientcity.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Recipient.Town));

                XmlElement recipientphone = xmlDoc.CreateElement("phone");
                recipientphone.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Recipient.Telephone));
                recipient.AppendChild(recipientname);
                recipient.AppendChild(recipientname2);
                recipient.AppendChild(recipientstreet);
                recipient.AppendChild(recipientcountry);
                recipient.AppendChild(recipientzipCode);
                recipient.AppendChild(recipientcity);
                recipient.AppendChild(recipientphone);

                generalShipmentData.AppendChild(sender);
                generalShipmentData.AppendChild(recipient);

                order.AppendChild(generalShipmentData);

                for (int i = 0; i < dPdChRequestModel.Package.Count; i++)
                {
                    XmlElement parcels = xmlDoc.CreateElement("parcels");

                    XmlElement customerReferenceNumber1 = xmlDoc.CreateElement("customerReferenceNumber1");
                    customerReferenceNumber1.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.ReferenceNumber1));

                    XmlElement weight = xmlDoc.CreateElement("weight");
                    weight.AppendChild(xmlDoc.CreateTextNode(dPdChRequestModel.Package[i].Weight));

                    parcels.AppendChild(customerReferenceNumber1);
                    parcels.AppendChild(weight);

                    order.AppendChild(parcels);
                }

                XmlElement productAndServiceData = xmlDoc.CreateElement("productAndServiceData");

                XmlElement orderType = xmlDoc.CreateElement("orderType");
                orderType.AppendChild(xmlDoc.CreateTextNode("consignment"));

                productAndServiceData.AppendChild(orderType);

                XmlElement predict = xmlDoc.CreateElement("predict");

                XmlElement channel = xmlDoc.CreateElement("channel");
                channel.AppendChild(xmlDoc.CreateTextNode("1"));

                XmlElement value = xmlDoc.CreateElement("value");
                value.AppendChild(xmlDoc.CreateTextNode("*****@*****.**"));

                XmlElement language = xmlDoc.CreateElement("language");
                language.AppendChild(xmlDoc.CreateTextNode("EN"));

                predict.AppendChild(channel);
                predict.AppendChild(value);
                predict.AppendChild(language);

                productAndServiceData.AppendChild(predict);

                order.AppendChild(productAndServiceData);

                storeOrders.AppendChild(printOptions);
                storeOrders.AppendChild(order);

                bodyNode.AppendChild(storeOrders);
                rootEnvelope.AppendChild(bodyNode);

                xmlDoc.Save(xmlPath);
                return(xmlPath);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 30
0
        public DPDChResponseModel CreateShipment(DPDChRequestModel dpdChRequest, string ShipmentType)
        {
            DPDChResponseModel response = new DPDChResponseModel();
            var logisticIntegration     = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.DPDCH);
            //API Login
            string ApiShipment = string.Empty;
            string xml_ship    = string.Empty;
            string xml_in      = string.Empty;
            string ApiLogin    = string.Empty;

            try
            {
                #region API Login

                string XMLDPDCHLogin = CreateXMLDPDCHLogin();
                xml_in = File.ReadAllText(@XMLDPDCHLogin);
                var kk = "xmlns:ns=\"ns\"";
                xml_in = xml_in.Replace(kk, "");

                ApiLogin = CallWebservice(xml_in, logisticIntegration.LabelApiUrl);

                var result = XDocument.Parse(ApiLogin);
                if (!string.IsNullOrWhiteSpace(ApiLogin) && !ApiLogin.Contains("soap:Fault"))
                {
                    var loginResult = (from r in result.Descendants("return")
                                       select new
                    {
                        delisId = r.Element("delisId") != null ? r.Element("delisId").Value : "",
                        authToken = r.Element("authToken") != null ? r.Element("authToken").Value : "",
                        depot = r.Element("depot") != null ? r.Element("depot").Value : ""
                    }).FirstOrDefault();
                    dpdChRequest.AuthToken    = loginResult.authToken;
                    dpdChRequest.UserName     = loginResult.delisId;
                    dpdChRequest.SendingDepot = loginResult.depot;
                }
                else
                {
                    var xml   = XDocument.Parse(@ApiLogin);
                    var Error = (from r in xml.Descendants("detail")
                                 select new
                    {
                        code = r.Element("errorCode") != null ? r.Element("errorCode").Value : "",
                        message = r.Element("ConditionData") != null ? r.Element("ConditionData").Value : "",
                    }).ToList();

                    response.Status        = false;
                    response.Error         = new FratyteError();
                    response.Error.Service = new List <string>();

                    foreach (var i in Error)
                    {
                        string err = string.Empty;
                        err = i.code + "-" + i.message;
                        response.Error.ServiceError.Add(err);
                    }
                    if (ShipmentType == FrayteShipmentServiceType.DirectBooking)
                    {
                        new DirectShipmentRepository().SaveEasyPostErrorObject(@ApiLogin, xml_in, dpdChRequest.DraftShipmentId);
                    }
                }

                #endregion

                #region Order Insert

                if (logisticIntegration != null && !string.IsNullOrWhiteSpace(dpdChRequest.AuthToken))
                {
                    string xml_path = CreateXMLDPDCH(dpdChRequest);
                    xml_ship = File.ReadAllText(@xml_path);
                    var ns = "xmlns:ns=\"ns\"";
                    xml_ship = xml_ship.Replace(ns, "");
                    var ns1 = "xmlns:ns1=\"ns1\"";
                    xml_ship = xml_ship.Replace(ns1, "");

                    response.Request  = xml_ship;
                    ApiShipment       = CallWebservice(xml_ship, logisticIntegration.ServiceUrl);
                    response.Response = @ApiShipment;
                    var ApiShipmentresult = XDocument.Parse(ApiShipment);
                    if (!string.IsNullOrWhiteSpace(ApiShipment) && !ApiLogin.Contains("soap:Fault") && !ApiShipment.Contains("faults"))
                    {
                        var parcellabelsPDF = (from r in ApiShipmentresult.Descendants("orderResult")
                                               select new
                        {
                            parcellabelsPDF = r.Element("parcellabelsPDF") != null ? r.Element("parcellabelsPDF").Value : "",
                        }).FirstOrDefault();

                        var shipmentResponses = (from r in ApiShipmentresult.Descendants("shipmentResponses")
                                                 select new
                        {
                            mpsId = r.Element("mpsId") != null ? r.Element("mpsId").Value : "",
                        }).FirstOrDefault();

                        var parcelInformation = (from r in ApiShipmentresult.Descendants("parcelInformation")
                                                 select new
                        {
                            parcelLabelNumber = r.Element("parcelLabelNumber") != null ? r.Element("parcelLabelNumber").Value : "",
                        }).ToList();

                        response.ParcelLabelPDF                      = parcellabelsPDF.parcellabelsPDF;
                        response.ShipmentResponses                   = new ShipmentResponse();
                        response.ShipmentResponses.mpsId             = shipmentResponses.mpsId;
                        response.ShipmentResponses.ParcelLabelNumber = new List <string>();
                        foreach (var Label in parcelInformation)
                        {
                            response.ShipmentResponses.ParcelLabelNumber.Add(Label.parcelLabelNumber);
                        }
                    }
                    else
                    {
                        var xml   = XDocument.Parse(@ApiShipment);
                        var Error = (from r in xml.Descendants("faults")
                                     select new
                        {
                            code = r.Element("faultCode") != null ? r.Element("faultCode").Value : "",
                            message = r.Element("message") != null ? r.Element("message").Value : "",
                        }).ToList();

                        response.Status        = false;
                        response.Error         = new FratyteError();
                        response.Error.Service = new List <string>();

                        foreach (var i in Error)
                        {
                            string err = string.Empty;
                            err = i.code + "-" + i.message;
                            response.Error.Service.Add(err);
                        }
                        if (ShipmentType == FrayteShipmentServiceType.DirectBooking)
                        {
                            new DirectShipmentRepository().SaveEasyPostErrorObject(@ApiShipment, xml_ship, dpdChRequest.DraftShipmentId);
                        }
                    }
                }
                else
                {
                    var xml   = XDocument.Parse(@ApiLogin);
                    var Error = (from r in xml.Descendants("soap:Fault")
                                 select new
                    {
                        code = r.Element("faultcode") != null ? r.Element("faultcode").Value : "",
                        message = r.Element("faultstring") != null ? r.Element("faultstring").Value : "",
                    }).ToList();

                    response.Status        = false;
                    response.Error         = new FratyteError();
                    response.Error.Service = new List <string>();

                    foreach (var i in Error)
                    {
                        string err = string.Empty;
                        err = i.code + "-" + i.message;
                        response.Error.Service.Add(err);
                    }
                    if (ShipmentType == FrayteShipmentServiceType.DirectBooking)
                    {
                        new DirectShipmentRepository().SaveEasyPostErrorObject(@ApiShipment, xml_ship, dpdChRequest.DraftShipmentId);
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                response.Status = false;
                response.Error  = new FratyteError();
                response.Error.Miscellaneous = new List <string>();
                response.Error.Miscellaneous.Add((ex.InnerException != null ? ex.InnerException.ToString() : ex.Message.ToString()));
                new DirectShipmentRepository().SaveEasyPostErrorObject("DPD-CHShipmentResult:-" + @ApiShipment + "DPD-CH API LoginResult:-" + @ApiLogin, "DPDCH-ShipXML:-" + xml_ship + "DPDCH-LoginXMl:-" + xml_in, dpdChRequest.DraftShipmentId);
            }
            return(response);
        }