public List <FrayteServiceCode> GetLogisticServiceCode(int OperationZoneId, int CustomerId) { List <FrayteServiceCode> _code = new List <FrayteServiceCode>(); _code = new DirectBookingUploadShipmentRepository().GetLogisticServiceCode(OperationZoneId, CustomerId); return(_code); }
public IHttpActionResult FrayteUploadShipments(FrayteUploadshipment Shipment) { var GetShipmentInDraftModel = new DirectBookingUploadShipmentRepository().eCommerceUploadShipmentDraft(Shipment, Shipment.CustomerId); var a = new eCommerceUploadShipmentController().SaveEcommUploadShipment(GetShipmentInDraftModel); return(Ok()); }
public fileName GenerateUnsucessfulShipmentsWithoutService(List <FrayteUserDirectShipment> ShipmentsWithoutService) { fileName fN = new fileName(); var flag = true; //fN.FilePath = @"D:\ProjectFrayte\Frayte\Frayte.WebApi\Manifestedshipments\"; fN.FilePath = AppSettings.WebApiPath + "Manifestedshipments/Incomplete Shipments Without Courier Service Download.csv"; fN.FileName = "Incomplete Shipments Without Courier Service Download"; List <FrayteUploadshipment> FUS = new List <FrayteUploadshipment>(); List <FrayteUploadshipment> FUSNew = new List <FrayteUploadshipment>(); foreach (var Shipment in ShipmentsWithoutService) { var gmd = new DirectBookingUploadShipmentRepository().GetShipmentErrors(Shipment.ShipmentId, "ECOMMERCE_WS"); var res = gmd[0]; FUS.Add(res); } //new eCommerceUploadShipmentRepository().ErrorLog(gmd, ServiceType); //foreach (var g in FUS) //{ // if (g.Errors.Count > 0) // { // FUSNew.Add(g); // } //} var Result = new DirectBookingUploadShipmentRepository().UnsuccessfulExcelWrite(FUS, "ECOMMERCE_WS"); if (fN.FileName.Contains(".csv")) { fN.FileName = fN.FileName; } else { fN.FileName = fN.FileName + ".csv"; } //fN.FilePath = filePath; if (Result.Message == "True") { foreach (var Shipment in ShipmentsWithoutService) { new DirectBookingUploadShipmentRepository().DeleteShipment(Shipment.ShipmentId); } } return(fN); }
static void Main(string[] args) { Program p = new Program(); var SessionIds = new DirectBookingUploadShipmentRepository().GetSessionIds(); foreach (var res in SessionIds) { var result = new DirectBookingUploadShipmentRepository().getLabels(res); if (result.Count > 0) { p.Start(result); new DirectBookingUploadShipmentRepository().SaveIsSessionPrintFalse(res); } } }
public IHttpActionResult SaveShipmentDraft(FrayteUploadshipment Shipment) { var result = new DirectBookingUploadShipmentRepository().SaveShipment(Shipment, Shipment.CustomerId, "DirectBooking_SS"); return(Ok()); }
public IHttpActionResult UploadShipments(int CustomerId, string LogisticService, string ServiceType) { //int eCommerceShipmentId = 0; List <FrayteUploadshipment> frayteShipment = new List <FrayteUploadshipment>(); FrayteResult result = new FrayteResult(); var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { HttpFileCollection files = httpRequest.Files; HttpPostedFile file = files[0]; FrayteSession s = new FrayteSession(); var a = s.EmployeeId; if (!string.IsNullOrEmpty(file.FileName)) { string connString = ""; OleDbConnection conn; string filename = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_") + file.FileName; string filepath = HttpContext.Current.Server.MapPath("~/UploadFiles/Shipments/" + filename); file.SaveAs(filepath); connString = new DirectShipmentRepository().getExcelConnectionString(filename, filepath); string fileExtension = ""; fileExtension = new DirectShipmentRepository().getFileExtensionString(filename); try { if (!string.IsNullOrEmpty(fileExtension)) { var ds = new DataSet(); if (fileExtension == FrayteFileExtension.CSV) { using (conn = new OleDbConnection(connString)) { conn.Open(); var query = "SELECT * FROM [" + Path.GetFileName(filename) + "]"; using (var adapter = new OleDbDataAdapter(query, conn)) { adapter.Fill(ds, "Pieces"); } } } else { using (conn = new OleDbConnection(connString)) { conn.Open(); DataTable dbSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); string firstSheetName = dbSchema.Rows[0]["TABLE_NAME"].ToString(); var query = "SELECT * FROM " + "[" + firstSheetName + "]";//[Sheet1$]"; using (var adapter = new OleDbDataAdapter(query, conn)) { adapter.Fill(ds, "Pieces"); } } } var exceldata = ds.Tables[0]; if (exceldata != null) { var res = new DirectBookingUploadShipmentRepository().CheckValidWithServiceExcel(exceldata); if (res) { frayteShipment = new DirectBookingUploadShipmentRepository().GetAllShipments(exceldata, ServiceType, LogisticService); var flag = false; foreach (var shipment in frayteShipment) { shipment.CollectionTime = shipment.CollectionTime != "" ? new DirectBookingUploadShipmentRepository().ConvertStringToTime(shipment.CollectionTime) : ""; shipment.CollectionDate = shipment.CollectionDate != "" ? new DirectBookingUploadShipmentRepository().ConvertStringToDate(shipment.CollectionDate) : ""; var count = 0; var packagelist = new List <UploadShipmentPackage>(); var package = new List <UploadShipmentPackage>(); packagelist.AddRange(shipment.Package); shipment.Package.RemoveRange(0, shipment.Package.Count); foreach (var ship in packagelist) { if (ship.CartoonValue == 0 && ship.Content == "" && Convert.ToInt32(ship.Height) == 0 && Convert.ToInt32(ship.Length) == 0 && Convert.ToInt32(ship.Value) == 0 && Convert.ToInt32(ship.Weight) == 0 && Convert.ToInt32(ship.Width) == 0) { //shipment.Package.RemoveAt((packagelist.Count - 1) - count); } else { shipment.Package.Add(ship); } count++; } } // check the validation in the excel new DirectBookingUploadShipmentRepository().ErrorLog(frayteShipment, ServiceType); List <FrayteUploadshipment> FUS = new List <FrayteUploadshipment>(); int count1 = 1; foreach (var shipment in frayteShipment) { shipment.ValidationErrors = new List <string>(); if (shipment.ShipFrom.Country == null || (shipment.ShipFrom.Country != null && shipment.ShipFrom.Country.CountryId == 0)) { shipment.ValidationErrors.Add("From Country is Missing in row " + count1); flag = true; } if (shipment.ShipTo.Country == null || (shipment.ShipTo.Country != null && shipment.ShipTo.Country.CountryId == 0)) { shipment.ValidationErrors.Add("To Country is Missing in row " + count1); flag = true; } if (shipment.CurrencyCode == null || shipment.CurrencyCode == "") { shipment.ValidationErrors.Add("Currency is Missing in row " + count1); flag = true; } count1++; } var count2 = 0; foreach (var shipment in frayteShipment) { if (shipment.ValidationErrors.Count > 0) { count2++; } } var SessionId = 0; //if (frayteShipment.Count == count2) //{ //} //else //{ // SessionId = new DirectBookingUploadShipmentRepository().SaveSession(); //} //int Count = 1; //foreach (var shipment in frayteShipment) //{ // if (CustomerId > 0) // { // shipment.CustomerId = CustomerId; // shipment.ShipmentStatusId = 14; // } // if (SessionId > 0) // { // shipment.SessionId = SessionId; // } // if (shipment.ValidationErrors.Count == 0 || ( // !shipment.ValidationErrors[shipment.ValidationErrors.Count - 1].Contains("Currency is Missing in row") && // !shipment.ValidationErrors[shipment.ValidationErrors.Count - 1].Contains("To Country is Missing in row") && // !shipment.ValidationErrors[shipment.ValidationErrors.Count - 1].Contains("From Country is Missing in row"))) // { // result = new DirectBookingUploadShipmentRepository().SaveShipment(shipment, CustomerId, ServiceType); // } // if (shipment.Errors.Count == 0) // { // FUS.Add(shipment); // } // Count++; //} if (!flag) { SessionId = new DirectBookingUploadShipmentRepository().SaveSession(CustomerId); foreach (var shipment in frayteShipment) { if (CustomerId > 0) { shipment.CustomerId = CustomerId; shipment.ShipmentStatusId = 14; } if (SessionId > 0) { shipment.SessionId = SessionId; } if (shipment.PackageCalculationType != null && shipment.PackageCalculationType != "" && shipment.PackageCalculationType.ToLower() == "kgtocms") { shipment.PackageCalculationType = "kgToCms"; } else if (shipment.PackageCalculationType != null && shipment.PackageCalculationType != "" && shipment.PackageCalculationType.ToLower() == "lbtoinchs") { shipment.PackageCalculationType = "lbToInchs"; } result = new DirectBookingUploadShipmentRepository().SaveShipment(shipment, CustomerId, ServiceType); } } else { return(BadRequest("from country or to country or shipmentcurrency name is missing")); } //var Unprocessedshipmentcount = frayteShipment.Count - FUS.Count; //new eCommerceUploadShipmentRepository().RemoveBatchProcessShipment(frayteShipment[0].CustomerId, frayteShipment.Count); //new eCommerceUploadShipmentRepository().SaveBatchProcessUnprocessedShipment(Unprocessedshipmentcount, frayteShipment[0].CustomerId); //if (FUS.Count > 0) //{ // PlaceShipmentBatch(FUS); //} } else { return(BadRequest("CSV file not valid, missing header name or may be wrong name")); } } conn.Close(); if ((System.IO.File.Exists(filepath))) { System.IO.File.Delete(filepath); } } else { //frayteShipmentDetailexcel.Message = "Excel file not valid"; } } catch (Exception ex) { return(BadRequest()); } finally { } } } var aa = GetUnSuccessfulShipments(CustomerId); return(Ok(frayteShipment)); }
public IHttpActionResult SelectService(List <FrayteeCommerceUserShipment> UploadShipment) { List <FrayteUploadshipment> Shipments = new List <FrayteUploadshipment>(); foreach (var a in UploadShipment) { //if (a.ServiceCode != null && a.ServiceCode != "") //{ var res = new DirectBookingUploadShipmentRepository().GetShipmentFromDraft(a.ShipmentId, "DirectBooking_SS"); //var result = new DirectBookingUploadShipmentRepository().UpdateServiceCode(a); Shipments.Add(res); //} } new eCommerceUploadShipmentRepository().RemoveBatchProcessShipment(Shipments[0].CustomerId, Shipments.Count); string ShipmentIds = ""; int i = 0; if (Shipments.Count >= 5) { int len = Shipments.Count; foreach (var a in Shipments) { if (len >= 5) { if (i < 4) { ShipmentIds = ShipmentIds + a.DirectShipmentDraftId.ToString() + "|"; } else if (i == 4) { ShipmentIds = ShipmentIds + a.DirectShipmentDraftId.ToString() + "," + 0 + "_" + "DirectBooking"; } //ShipmentIds = a.DirectShipmentDraftId.ToString() + "," + 0 + "_" + "DirectBooking"; i++; if (i == 5) { Process.Start(AppSettings.eCommerceUploadShipmentBatchProcess, ShipmentIds); ShipmentIds = ""; len = len - 5; i = 0; } } else { if (i < len - 1) { ShipmentIds = ShipmentIds + a.DirectShipmentDraftId.ToString() + "|"; } else if (i == len - 1) { ShipmentIds = ShipmentIds + a.DirectShipmentDraftId.ToString() + "," + 0 + "_" + "DirectBooking"; } i++; //Process.Start(AppSettings.eCommerceUploadShipmentBatchProcess, ShipmentIds); if (ShipmentIds.Contains("DirectBooking")) { Process.Start(AppSettings.eCommerceUploadShipmentBatchProcess, ShipmentIds); } } } } else { foreach (var a in Shipments) { int len = Shipments.Count; if (i < len - 1) { ShipmentIds = ShipmentIds + a.DirectShipmentDraftId.ToString() + "|"; } else if (i == len - 1) { ShipmentIds = ShipmentIds + a.DirectShipmentDraftId.ToString() + "," + 0 + "_" + "DirectBooking"; } i++; } Process.Start(AppSettings.eCommerceUploadShipmentBatchProcess, ShipmentIds); } int eCommerceShipmentId = 0; return(Ok(Shipments)); }
public Tuple <FrayteResult, DirectBookingShipmentDraftDetail, int> DBUploadShipmentParcelHubIntegration(FrayteUploadshipment res) { FrayteResult FR = new FrayteResult(); IntegrtaionResult result = new IntegrtaionResult(); var count = 0; int DirectShipmentid = 0; var directBookingDetail = new DirectBookingUploadShipmentRepository().DirectBookingObj(res); #region COLLECTION Date DateTime mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value; DateTime maxdatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(1); if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Sunday) { mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(1); } else if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Saturday) { mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(2); } directBookingDetail.ReferenceDetail.CollectionDate = mindatetime; #endregion //update customerratecard in draft new DirectShipmentRepository().SaveDirectShipmnetDetail(directBookingDetail); // Parcelhub Integration starts //Step 2: Shipment Integrations #region Parcel Hub Integration //Map Direct Booking object with parcel hub objects Frayte.Services.Models.ParcelHub.ParcelHubShipmentRequest request = new ParcelHubRepository().MapDirectBookingDetailToShipmentRequest(directBookingDetail); //Create shipment in Parcel hub Frayte.Services.Models.ParcelHub.ParcelHubResponse response = new ParcelHubRepository().CreateShipment(request); if (response.Error.IsMailSend) { if (directBookingDetail.Error.IsMailSend) { //Send error mail to developer new ShipmentEmailRepository().SendShipmentErrorMail(directBookingDetail, response.Error); } } else { //Mapping ShipmentResonse to IntegrtaionResult result = new ParcelHubRepository().MappingParcelHubToIntegrationResult(directBookingDetail, response, null); if (result.Status) { //Save Shipment Detail Into Our DB DirectShipmentid = new DirectShipmentRepository().SaveShipment(directBookingDetail, result); if (DirectShipmentid > 0) { var Id = new eCommerceUploadShipmentRepository().SaveBatchProcessProcessedShipment(1, directBookingDetail.CustomerId); } //Mapping ShipmentResult to IntegrtaionResult new ParcelHubRepository().MappingCourierPieceDetail(result, directBookingDetail, DirectShipmentid); //Save Package Label Tracking detail new ParcelHubRepository().SaveTrackingDetail(directBookingDetail, result, DirectShipmentid); //Start downloading the images from UPS server and making PDF FratyteError Error = new ParcelHubRepository().DownloadParcelHubPackageImage(directBookingDetail, result, DirectShipmentid); } else { if (result.Error.IsMailSend) { new eCommerceUploadShipmentRepository().SaveBatchProcessUnprocessedShipment(1, res.CustomerId); //Send error mail to developer new ShipmentEmailRepository().SendShipmentErrorMail(directBookingDetail, directBookingDetail.Error); } } } #endregion return(Tuple.Create(FR, directBookingDetail, DirectShipmentid)); }
public Tuple <FrayteResult, DirectBookingShipmentDraftDetail, int> DBUploadShipmentDHLIntegration(FrayteUploadshipment res) { IntegrtaionResult result = new IntegrtaionResult(); FrayteResult FR = new FrayteResult(); //string xsUserFolder = @"C:\FMS\" + "FrayteSchedularlog.txt"; string xsUserFolder = @"D:\ProjectFrayte\" + "FrayteScheduler.txt"; BaseLog.Instance.SetLogFile(xsUserFolder); Logger _log = Get_Log(); int DirectShipmentid = 0; var directBookingDetail = new DirectBookingUploadShipmentRepository().DirectBookingObj(res); #region COLLECTION Date DateTime mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value; DateTime maxdatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(1); if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Sunday) { mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(1); } else if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Saturday) { mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(2); } directBookingDetail.ReferenceDetail.CollectionDate = mindatetime; #endregion _log.Error("Get direct Booking Object"); //update customerratecard in draft new DirectShipmentRepository().SaveDirectShipmnetDetail(directBookingDetail); _log.Error("saved direct Booking Object"); //step1. Mapping With directBookingDetail to ShipmentRequestDto var shipmentRequestDto = new DHLRepository().MapDirectBookingDetailToDHLShipmentRequestDto(directBookingDetail); //Step 2. Create Xml var shipmentXML = new DHLRepository().CreateXMLForDHL(shipmentRequestDto); _log.Error("done xml dhl shipment"); _log.Error(shipmentXML); string xml_in = ""; try { xml_in = File.ReadAllText(shipmentXML); //xml_in = File.ReadAllText(@"C:\FMS\app.godemowithus.com\WebApi\UploadFiles\PDFGenerator\HTMLFile\tempDHLShipment.xml"); } catch (Exception e) { _log.Error(e.Message); _log.Error(e.InnerException); _log.Error(e.StackTrace); } _log.Error("reading xml dhl shipment"); //step 3. Create Shipment var DHLResponse = new DHLRepository().CreateShipment(xml_in, shipmentRequestDto); // _log.Error("done integration dhl shipment" + DHLResponse.Error.ErrorDescription.ToString()); //step 4. Mapping ShipmentResonse to IntegrtaionResult result = new DHLRepository().MapDHLIntegrationResponse(DHLResponse); if (result.Status) { //step2. After Shipment Create need to save the information in database DirectShipmentid = new DirectShipmentRepository().SaveShipment(directBookingDetail, result); if (DirectShipmentid > 0) { _log.Error("done save dhl shipment in db" + directBookingDetail.CustomerId); var Id = new eCommerceUploadShipmentRepository().SaveBatchProcessProcessedShipment(1, directBookingDetail.CustomerId); _log.Error(Id.ToString()); } _log.Error("done save dhl shipment in db"); if (directBookingDetail.CustomerRateCard.CourierName == FrayteCourierCompany.DHL) { //Step 1.1 Mapping ShipmentResult to IntegrtaionResult new DHLRepository().MappingCourierPieceDetail(result, directBookingDetail, DirectShipmentid); } //Step3 : Save Package Label Tracking detail new DHLRepository().SaveTrackingDetail(directBookingDetail, result, DirectShipmentid); //Step4: //Start downloading the images from UPS server and making PDF var count = 1; var totalpiece = result.PieceTrackingDetails.Count(); totalpiece = totalpiece - 1; foreach (var data in result.PieceTrackingDetails.Take(totalpiece)) { if (directBookingDetail.CustomerRateCard.CourierName == FrayteCourierCompany.DHL) { _log.Error("downloading shipment image"); //Step3.1 data.LabelName = new DHLRepository().DownloadDHLImage(data, totalpiece, count, DirectShipmentid); _log.Error("downloaded shipment image"); } //// Step3.2 //new DirectShipmentRepository().SavePackageDetail(data, result.CourierName); //_log.Error("saved package detail shipment image"); if (!data.PieceTrackingNumber.Contains("AirwayBillNumber_")) { // Step3.2 new DirectShipmentRepository().SavePackageDetail(data, result.CourierName); } count++; } var CourierPieceDetail = result.PieceTrackingDetails.Where(t => t.PieceTrackingNumber.Contains("AirwayBillNumber_")).FirstOrDefault(); if (CourierPieceDetail != null) { var data1 = new DHLRepository().DownloadDHLImage(CourierPieceDetail, totalpiece, 0, DirectShipmentid); } if (result != null) { directBookingDetail.Error = new FratyteError(); directBookingDetail.Error.Status = result.Status; } return(Tuple.Create(FR, directBookingDetail, DirectShipmentid)); } else { directBookingDetail.Error = result.Error; new eCommerceUploadShipmentRepository().SaveBatchProcessUnprocessedShipment(1, directBookingDetail.CustomerId); //Send mail to developer new ShipmentEmailRepository().SendShipmentErrorMail(directBookingDetail, directBookingDetail.Error); } return(Tuple.Create(FR, directBookingDetail, DirectShipmentid)); }
public Tuple <FrayteResult, DirectBookingShipmentDraftDetail, int> DBUploadShipmentUpsIntegration(FrayteUploadshipment res) { FrayteResult FR = new FrayteResult(); var count = 0; int DirectShipmentid = 0; var result1 = new DirectBookingUploadShipmentRepository().DirectBookingObj(res); #region COLLECTION Date DateTime mindatetime = result1.ReferenceDetail.CollectionDate.Value; DateTime maxdatetime = result1.ReferenceDetail.CollectionDate.Value.AddDays(1); if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Sunday) { mindatetime = result1.ReferenceDetail.CollectionDate.Value.AddDays(1); } else if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Saturday) { mindatetime = result1.ReferenceDetail.CollectionDate.Value.AddDays(2); } result1.ReferenceDetail.CollectionDate = mindatetime; #endregion //update customerratecard in draft new DirectShipmentRepository().SaveDirectShipmnetDetail(result1); //step1. Mapping With directBookingDetail to ShipmentRequestDto var shipmentRequestDto = new UPSRepository().MapDirectBookingDetailToShipmentRequestDto(result1); //Step2.Create Shipment var shipmentResult = new UPSRepository().CreateShipment(shipmentRequestDto, result1.ReferenceDetail); //step3 Mapping ShipmentResonse to IntegrtaionResult var result = new UPSRepository().MapUPSIntegrationResponse(shipmentResult); if (result.Status) { //step1. After Shipment Create need to save the information in database DirectShipmentid = new DirectShipmentRepository().SaveShipment(result1, result); if (DirectShipmentid > 0) { var Id = new eCommerceUploadShipmentRepository().SaveBatchProcessProcessedShipment(1, result1.CustomerId); } if (result.CourierName == FrayteCourierCompany.UPS) { //Step 1.1 Mapping ShipmentResult to IntegrtaionResult new UPSRepository().MappingCourierPieceDetail(result, result1, DirectShipmentid); } //Step2 : Save Package Label Tracking detail new UPSRepository().SaveTrackingDetail(result1, result, DirectShipmentid); //Step3: //Start downloading the images from UPS server and making PDF count = 1; foreach (var data in result.PieceTrackingDetails) { if (result.CourierName == FrayteCourierCompany.UPS) { //Step3.1 data.LabelName = new UPSRepository().DownloadUPSImage(data, result.PieceTrackingDetails.Count(), count, DirectShipmentid); } // Step3.2 new DirectShipmentRepository().SavePackageDetail(data, result.CourierName); count++; } result1.Error = new FratyteError() { Status = result.Status }; FR.Status = true; //FrayteShipmentResponse = new APIShipmentRepository().MappingFrayteShipmentResponse(directBookingDetail, result, DirectShipmentid.ToString(), ratecard, Request.RateCardId); } else { FR.Status = false; result1.Error = result.Error; new eCommerceUploadShipmentRepository().SaveBatchProcessUnprocessedShipment(1, res.CustomerId); //Send mail to developer new ShipmentEmailRepository().SendShipmentErrorMail(result1, result1.Error); } return(Tuple.Create(FR, result1, DirectShipmentid)); }
public Tuple <FrayteResult, DirectBookingShipmentDraftDetail, int, TNTResponseDto, List <FraytePackageTrackingDetail> > DBUploadShipmentTNTIntegration(FrayteUploadshipment res) { FrayteResult FR = new FrayteResult(); var count = 0; int DirectShipmentid = 0; //string xsUserFolder = @"C:\FMS\" + "FrayteSchedularlog.txt"; string xsUserFolder = @"D:\ProjectFrayte\" + "FrayteScheduler.txt"; BaseLog.Instance.SetLogFile(xsUserFolder); Logger _log = Get_Log(); _log.Error("entered in else tnt"); var directBookingDetail = new DirectBookingUploadShipmentRepository().DirectBookingObj(res); #region COLLECTION Date DateTime mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value; DateTime maxdatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(1); if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Sunday) { mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(1); } else if (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(mindatetime.DayOfWeek) == FraytePickUpDay.Saturday) { mindatetime = directBookingDetail.ReferenceDetail.CollectionDate.Value.AddDays(2); } directBookingDetail.ReferenceDetail.CollectionDate = mindatetime; #endregion _log.Error("entered in else tnt1"); //update customerratecard in draft new DirectShipmentRepository().SaveDirectShipmnetDetail(directBookingDetail); _log.Error("entered in else tnt2"); var shipmentPackageTrackingDetail = new List <FraytePackageTrackingDetail>(); // TNT Integration is for HK as we have account detail for HK only _log.Error("entered in else tnt3"); var TNTObj = new TNTRepository().MapDirectBookingObjToTNTobj(directBookingDetail); _log.Error("entered in else tnt4"); var TNTXml = new TNTRepository().CreateTNTXMl(TNTObj); _log.Error("entered in else tnt5"); var TNTResponse = new TNTRepository().CreateShipment(TNTXml, directBookingDetail.DirectShipmentDraftId); _log.Error("entered in else tnt6"); directBookingDetail.Error = TNTResponse.Error; //TNTIntegration(directBookingDetail, out DirectShipmentid); _log.Error("entered in else tnt7"); if (directBookingDetail.Error != null && directBookingDetail.Error.Status == true) { //Finally Save the Order Id too to get the information of multiple shpment in Tracking Detail page. DirectShipmentid = new DirectShipmentRepository().SaveShipment(directBookingDetail, TNTResponse.TNTShipmentResponse.TrackingCode, directBookingDetail.CustomerId, null, null); if (DirectShipmentid > 0) { var Id = new eCommerceUploadShipmentRepository().SaveBatchProcessProcessedShipment(1, directBookingDetail.CustomerId); } // save tracking code int increment = 0; foreach (var package in directBookingDetail.Packages) { var trackingDetail = new DirectShipmentRepository().SaveTNTTrackingDeatil(TNTResponse.TNTShipmentResponse.TrackingCode, DirectShipmentid, increment); if (trackingDetail != null) { foreach (var data in trackingDetail) { shipmentPackageTrackingDetail.Add(data); } } increment++; } if (directBookingDetail != null) { directBookingDetail.Error = new FratyteError(); directBookingDetail.Error.Status = directBookingDetail.Error.Status; } } else { new eCommerceUploadShipmentRepository().SaveBatchProcessUnprocessedShipment(1, res.CustomerId); } return(Tuple.Create(FR, directBookingDetail, DirectShipmentid, TNTResponse, shipmentPackageTrackingDetail)); }