//public string LogFileImport(string FileName, string Status, string ValidRecords, string InValidRecords, string ErrorFileName, string ImportFileHistory_PK) //{ // return _userDataAccess.LogFileImport(FileName, Status, ValidRecords, InValidRecords, ErrorFileName, ImportFileHistory_PK); //} public string UserFileImport(string FileName, string CallType) { int ValidRecords = 0; int InValidRecords = 0; try { accessfileName = FileName + SiteConfigurationManager.GetAppSettingKey("FileImportExtension"); fileName = ClaimHelper.CompanyId + "_" + FileName; FileName = fileName + SiteConfigurationManager.GetAppSettingKey("FileImportExtension"); string logImport = null; bool UserResult = false; string rootFolderPath = SiteConfigurationManager.GetAppSettingKey("TemplatePath") + "driverFile\\"; string destinationPath = rootFolderPath + "\\Archive\\"; string fullPathToExcel = rootFolderPath + accessfileName; string fullpathToArchive = destinationPath + accessfileName; LoggerDataAccess loggerDataAccess = new LoggerDataAccess(); logImport = loggerDataAccess.LogFileImport(FileName, "IMP_FL_INITIATED", ValidRecords.ToString(), InValidRecords.ToString(), null, null); ImportFileHistoryID = logImport; if (logImport == "File is already processed.") { return("File is already processed."); } if (string.IsNullOrEmpty(logImport)) { throw new Exception("Invalid response from Log File Import."); } if (new FileInfo(fullpathToArchive).Exists == false) { string connString = string.Format("Provider =Microsoft.ACE.OLEDB.12.0;Data Source=" + fullPathToExcel + ";Extended Properties='Excel 12.0;HDR=yes'", fullPathToExcel); DataTable dt = FileManager.GetDataTable("SELECT * FROM [Sheet1$]", connString); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB"); var date = DateTime.Now; IList <Country> PhoneCode = null; if (CallType == "User") { for (int i = 0; i < dt.Rows.Count; i++) { try { LogistikaUser User = new LogistikaUser() { BranchId = dt.Rows[i]["BranchId"].ToString(), FirstName = dt.Rows[i]["FirstName"].ToString(), MiddleName = dt.Rows[i]["MiddleName"].ToString(), LastName = dt.Rows[i]["LastName"].ToString(), DateOfBirth = Convert.ToDateTime(dt.Rows[i]["DateOfBirth"].ToString()), Designation = dt.Rows[i]["EmployeeRole"].ToString(), JobTitle = dt.Rows[i]["EmployeeTitle"].ToString(), Contact = new Contact() { Email = dt.Rows[i]["PrimaryEmail"].ToString(), Phone = dt.Rows[i]["Phone"].ToString(), Mobile = dt.Rows[i]["MobileNo"].ToString(), }, Password = dt.Rows[i]["Password"].ToString(), Gender = dt.Rows[i]["Gender"].ToString(), OtherInfo = new List <DropdownData> { new DropdownData() { Text = "LicenseNumber", Value = dt.Rows[i]["LicenseNumber"].ToString(), }, new DropdownData() { Text = "LicenceClass", Value = dt.Rows[i]["LicenceClass"].ToString(), }, new DropdownData() { Text = "Experience", Value = dt.Rows[i]["Experience"].ToString(), }, new DropdownData() { Text = "MonthlyWage", Value = dt.Rows[i]["MonthlyWage"].ToString(), } }, StartDate = Convert.ToDateTime(dt.Rows[i]["StartDate"].ToString()), EndDate = Convert.ToDateTime(dt.Rows[i]["EndDate"].ToString()), Active = Convert.ToBoolean(dt.Rows[i]["IsActive"].ToString()), Addresses = new List <Address> { new Address() { AddressLine1 = dt.Rows[i]["AddressLine1"].ToString(), Suite = dt.Rows[i]["SuiteNo"].ToString(), Locality = dt.Rows[i]["Locality"].ToString(), City = dt.Rows[i]["City"].ToString(), StateCode = dt.Rows[i]["State"].ToString(), PostalCode = dt.Rows[i]["PinCode"].ToString(), CountryCode = dt.Rows[i]["CountryCode"].ToString(), LandMark = dt.Rows[i]["LandMark"].ToString() } } }; PhoneCode = _userDataAccess.GetCountryInfo(dt.Rows[i]["CountryCode"].ToString()); if (User.Contact.Mobile.StartsWith("0")) { User.Contact.Mobile = User.Contact.Mobile.TrimStart('0'); User.Contact.Mobile = PhoneCode[0].PhoneCode + User.Contact.Mobile; } else if (!User.Contact.Mobile.StartsWith("0")) { User.Contact.Mobile = PhoneCode[0].PhoneCode + User.Contact.Mobile; } if (User.Contact.Phone.StartsWith("0")) { User.Contact.Phone = User.Contact.Phone.TrimStart('0'); User.Contact.Phone = PhoneCode[0].PhoneCode + User.Contact.Phone; } else if (!User.Contact.Phone.StartsWith("0")) { User.Contact.Phone = PhoneCode[0].PhoneCode + User.Contact.Phone; } UserResult = SaveUser(User, null); //var service = new UserBusinessComponent(new UserDataAccess()); if (UserResult) { ValidRecords = ValidRecords + 1; } if (!UserResult) { InValidRecords = InValidRecords + 1; } } catch (Exception ex) { logImport = loggerDataAccess.LogFileImport(FileName, "IMP_FL_FLD", ValidRecords.ToString(), InValidRecords.ToString(), ex.Message, ImportFileHistoryID); return(ex.Message); } } } //Console.ReadLine(); string[] fileList = Directory.GetFiles(rootFolderPath, FileName); if (Directory.Exists(rootFolderPath)) { foreach (string file in fileList) { FileInfo mFile = new FileInfo(file); if (new FileInfo(destinationPath + "\\" + mFile.Name).Exists == false) { mFile.MoveTo(destinationPath + "\\" + mFile.Name); } } } } else if (new FileInfo(fullpathToArchive).Exists == true) { return("File is already processed"); } if (UserResult) { logImport = loggerDataAccess.LogFileImport(FileName, "IMP_FL_SCCS", ValidRecords.ToString(), InValidRecords.ToString(), null, ImportFileHistoryID); return(FileName + ":- File imported successully."); } string eFileName; string errorFileName; LoggerDataAccess eloggerDataAccess = new LoggerDataAccess(); eFileName = "UserError_" + fileName + "_" + DateTime.Now.ToString("MMddyyyyHH"); errorFileName = "DriverFile\\error\\" + eFileName + ".error.txt"; string filePath = SiteConfigurationManager.GetAppSettingKey("TemplatePath") + errorFileName; var v = FileManager.FileErrorLog(filePath, "Incorrect File Layout/User already exists", "Error while processing file"); logImport = loggerDataAccess.LogFileImport(FileName, "IMP_FL_FLD", ValidRecords.ToString(), InValidRecords.ToString(), errorFileName, ImportFileHistoryID); return(FileName + ":- File import Failed."); } catch (Exception ex) { string eFileName; string errorFileName; eFileName = "UserError_" + fileName + "_" + DateTime.Now.ToString("MMddyyyyHH"); errorFileName = "DriverFile\\error\\" + eFileName + ".error.txt"; string filePath = SiteConfigurationManager.GetAppSettingKey("TemplatePath") + errorFileName; LoggerDataAccess eloggerDataAccess = new LoggerDataAccess(); if (!string.IsNullOrEmpty(fileName)) { var v = FileManager.FileErrorLog(filePath, ex.Message, "Error with File"); eloggerDataAccess.LogFileImport(FileName, "IMP_FL_FLD", ValidRecords.ToString(), InValidRecords.ToString(), errorFileName, ImportFileHistoryID); } return(FileName + ":- File import Failed."); } }
public bool SaveUser(LogistikaUser User, IList <Document> Documents) { string exceptionMessages = string.Empty; try { if (string.IsNullOrEmpty(User.BranchId)) { exceptionMessages = "BranchId is missing"; } if (string.IsNullOrEmpty(User.FirstName)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "First Name is missing" : exceptionMessages + ", " + "First Name is missing"; } if (string.IsNullOrEmpty(User.LastName)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Last Name is missing" : exceptionMessages + ", " + "Last Name is missing"; } if (User.DateOfBirth == null) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Date Of Birth is missing" : exceptionMessages + ", " + "Date Of Birth is missing"; } if (string.IsNullOrEmpty(User.Designation)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Employee Role is missing" : exceptionMessages + ", " + "Employee Role is missing"; } if (string.IsNullOrEmpty(User.JobTitle)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Employee Title is missing" : exceptionMessages + ", " + "Employee Title is missing"; } if (string.IsNullOrEmpty(User.Contact.Email)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Primary Email is missing" : exceptionMessages + ", " + "Primary Email is missing"; } if (string.IsNullOrEmpty(User.Password)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Password is missing" : exceptionMessages + ", " + "Password is missing"; } if (string.IsNullOrEmpty(User.Gender)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Gender is missing" : exceptionMessages + ", " + "Gender is missing"; } if (string.IsNullOrEmpty(User.Addresses.FirstOrDefault().AddressLine1)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "AddressLine1 is missing" : exceptionMessages + ", " + "AddressLine1 is missing"; } if (string.IsNullOrEmpty(User.Addresses.FirstOrDefault().Suite)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "House Number/Flat is missing" : exceptionMessages + ", " + "House Number/Flat is missing"; } if (string.IsNullOrEmpty(User.Addresses.FirstOrDefault().City)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "City is missing" : exceptionMessages + ", " + "City is missing"; } if (string.IsNullOrEmpty(User.Addresses.FirstOrDefault().StateCode)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "StateCode is missing" : exceptionMessages + ", " + "StateCode is missing"; } if (string.IsNullOrEmpty(User.Addresses.FirstOrDefault().PostalCode)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "PostalCode is missing" : exceptionMessages + ", " + "PostalCode is missing"; } if (string.IsNullOrEmpty(User.Contact.Phone)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Phone is missing" : exceptionMessages + ", " + "Phone is missing"; } if (string.IsNullOrEmpty(User.Contact.Mobile)) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Mobile phone is missing" : exceptionMessages + ", " + "Mobile phone is missing"; } if ((string.IsNullOrEmpty(User.OtherInfo.TryGet("LicenseNumber")) || string.IsNullOrEmpty(User.OtherInfo.TryGet("LicenseClass"))) && (User.Designation == "USR_DRV" || User.Designation == "Driver")) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "License Number and License Class is required" : exceptionMessages + ", " + "License Number and License Class is required"; } if ((string.IsNullOrEmpty(User.OtherInfo.TryGet("Experience")) || string.IsNullOrEmpty(User.OtherInfo.TryGet("MonthlyWage")))) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "Experience and MonthlyWage is required" : exceptionMessages + ", " + "Experience and MonthlyWage is required"; } if (User.StartDate == null) { exceptionMessages = string.IsNullOrEmpty(exceptionMessages) ? "StartDate is required" : exceptionMessages + ", " + "StartDate is required"; } if (!string.IsNullOrEmpty(exceptionMessages)) { throw new Exception(exceptionMessages); } string documentXml = string.Empty; if (Documents != null && Documents.Count > 0) { var r = Documents.Where(x => x.DocumentType.ToLower() == "photo").FirstOrDefault(); if (r != null) { User.Photo = r.DocumentUrl; Documents.Remove(r); } documentXml = Documents.ConvertToXmlWithoutNamespaces <Document>(); } return(_userDataAccess.SaveUser(User, documentXml)); } catch (Exception ex) { string eFileName; string errorFileName; eFileName = "UserError_" + fileName + "_" + DateTime.Now.ToString("MMddyyyyHH"); errorFileName = "DriverFile\\error\\" + eFileName + ".error.txt"; string filePath = SiteConfigurationManager.GetAppSettingKey("TemplatePath") + errorFileName; LoggerDataAccess eloggerDataAccess = new LoggerDataAccess(); if (!string.IsNullOrEmpty(fileName)) { fileName = fileName + SiteConfigurationManager.GetAppSettingKey("FileImportExtension"); if (string.IsNullOrEmpty(User.Contact.Email)) { User.Contact.Email = "Empty"; } var v = FileManager.FileErrorLog(filePath, ex.Message, User.Contact.Email); eloggerDataAccess.LogFileImport(fileName, "IMP_FL_FLD", null, null, errorFileName, ImportFileHistoryID); } return(false); } }
static void Main(string[] args) { string pwd1 = null; string pwd2 = null; //pwd1 = Logistika.Service.Common.Encryption.EncryptionManager.BasicEncrypt(User.Password); //pwd2 = Logistika.Service.Common.Encryption.EncryptionManager.Encrypt(User.Password, User.Contact.Email); ////--aHVycnlyMTI = pwd1 = Logistika.Service.Common.Encryption.EncryptionManager.BasicDecrypt("aHVycnlyMTI="); pwd2 = Logistika.Service.Common.Encryption.EncryptionManager.BasicDecrypt("aHVycnkxMg=="); Console.ReadKey(); return; string FileName = null; string rootFolderPath = @"C:\API\Logistika\LogistikaService\Test\Files\ToFiles\"; string destinationPath = @"C:\API\Logistika\LogistikaService\Test\Files\Archive\"; FileName = "USERS_05222018_1.xlsx"; string fullPathToExcel = rootFolderPath + FileName; //ie C:\Temp\YourExcel.xls string fullpathToArchive = destinationPath + FileName; //ie C:\Temp\YourExcel.xls if (new FileInfo(fullpathToArchive).Exists == false) { string connString = string.Format("Provider =Microsoft.ACE.OLEDB.12.0;Data Source=" + fullPathToExcel + ";Extended Properties='Excel 12.0;HDR=yes'", fullPathToExcel); DataTable dt = FileManager.GetDataTable("SELECT * FROM [Sheet1$]", connString); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB"); var date = DateTime.Now; var type = "user"; IList <Country> PhoneCode = null; if (type == "Order") { if (dt != null) { var distinctOrders = dt.AsEnumerable().Select(c => Convert.ToString(c["VendorOrderID"])).Distinct().ToList <string>(); foreach (var order in distinctOrders) { var orders = dt.AsEnumerable().Where(x => Convert.ToString(x["VendorOrderID"]) == order).ToList(); if (orders != null && orders.Count() > 0) { string pickupLatitude = null; string pickupLongitude = null; string dropoffLatitude = null; string dropoffLongitude = null; var first = orders[0]; //first["PICKUPHOUSE_FLATNO"].ToString() + first["PickupAddress"].ToString() + ", " + first["PICKUPCITY"].ToString() + ", " + first["PICKUPSTATE"].ToString() + " " + first["PICKUPPINCODE"].ToString() + ", " + first["PICKUPCOUNTRY"].ToString(), //AIzaSyB9PgorTUksSwiRCNNTkfEEu1gaHIGG0Rw string Pickupaddress = first["PickupAddress"].ToString() + ", " + first["PICKUPAREA_LOCALITY"].ToString() + ", " + first["PICKUPCITY"].ToString() + ", " + first["PICKUPSTATE"].ToString() + " " + first["PICKUPPINCODE"].ToString() + ", " + first["PICKUPCOUNTRY"].ToString(); string PickuprequestUri = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false?key=AIzaSyB9PgorTUksSwiRCNNTkfEEu1gaHIGG0Rw", Uri.EscapeDataString(Pickupaddress)); WebRequest request = WebRequest.Create(PickuprequestUri); WebResponse response = request.GetResponse(); System.Xml.Linq.XDocument xdoc = XDocument.Load(response.GetResponseStream()); XElement result = xdoc.Element("GeocodeResponse").Element("result"); if (result != null) { XElement locationElement = result.Element("geometry").Element("location"); XElement pickuplat = locationElement.Element("lat"); XElement pickuplng = locationElement.Element("lng"); pickupLatitude = pickuplat.Value; pickupLongitude = pickuplng.Value; } string DropOffaddress = first["DROPOFFADDRESS"].ToString() + ", " + first["DROPOFFAREA_LOCALITY"].ToString() + ", " + first["DROPOFFCITY"].ToString() + ", " + first["DROPOFFSTATE"].ToString() + " " + first["DROPOFFPINCODE"].ToString() + ", " + first["DROPOFFCOUNTRY"].ToString(); string DropoffrequestUri = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", Uri.EscapeDataString(DropOffaddress)); WebRequest requestD = WebRequest.Create(DropoffrequestUri); WebResponse responseD = requestD.GetResponse(); System.Xml.Linq.XDocument xdocD = XDocument.Load(responseD.GetResponseStream()); XElement resultD = xdocD.Element("GeocodeResponse").Element("result"); if (resultD != null) { XElement locationElementD = resultD.Element("geometry").Element("location"); XElement dropOfflat = locationElementD.Element("lat"); XElement dropOfflng = locationElementD.Element("lng"); dropoffLatitude = dropOfflat.Value; dropoffLongitude = dropOfflng.Value; } LogistikaOrderHeader tOrder = new LogistikaOrderHeader { //ClientOrderSource = "FileImport_" + first["ServiceCode"].ToString(), CallType = "Portal", ClientOrderSource = "FileImport_" + Convert.ToString(System.DateTime.Now), ServiceCode = first["ServiceCode"].ToString(), OrderType = first["OrderType"].ToString(), FreightType = first["FreightType"].ToString(), OrderByName = first["OrderByName"].ToString(), OrderByPhoneNumber = first["OrderByPhoneNumber"].ToString(), OrderByEmail = first["OrderByEmail"].ToString(), PickUpDate = Convert.ToDateTime(first["PickUpDate"].ToString()), VendorOrderID = first["VendorOrderID"].ToString(), Payment = new Payment { Amount = Convert.ToDouble(first["CHARGEDAMOUNT"].ToString()), PaymentMethod = first["PAYMENTMODE"].ToString() }, PickupAddress = new List <Address> { new Address() { AddressLine1 = first["PickupAddress"].ToString(), Suite = first["PICKUPHOUSE_FLATNO"].ToString(), Locality = first["PICKUPAREA_LOCALITY"].ToString(), City = first["PICKUPCITY"].ToString(), StateCode = first["PICKUPSTATE"].ToString(), PostalCode = first["PICKUPPINCODE"].ToString(), CountryCode = first["PICKUPCOUNTRY"].ToString(), LandMark = first["PICKUPLANDMARK"].ToString(), Instruction = first["PICKUPINSTRUCTION"].ToString(), Latitude = pickupLatitude, Longitude = pickupLongitude } }, DropoffAddress = new List <Address> { new Address() { AddressLine1 = first["DROPOFFADDRESS"].ToString(), Suite = first["DROPOFFHOUSE_FLATNO"].ToString(), Locality = first["DROPOFFAREA_LOCALITY"].ToString(), City = first["DROPOFFCITY"].ToString(), StateCode = first["DROPOFFSTATE"].ToString(), PostalCode = first["DROPOFFPINCODE"].ToString(), CountryCode = first["DROPOFFCOUNTRY"].ToString(), LandMark = first["DROPOFFLANDMARK"].ToString(), Instruction = first["DROPOFFINSTRUCTION"].ToString(), DropOffDate = Convert.ToDateTime(first["DropOffDate"].ToString()), Name = first["DROPOFFNAME"].ToString(), PhoneNumber = first["DROPOFFPHONE"].ToString(), Latitude = dropoffLatitude, Longitude = dropoffLongitude } } }; tOrder.LineItem = orders.Select(s => new LogistikaOrderLineItem { Item = s["ITEM"].ToString(), //ItemType_FK = Convert.ToInt32(s["ItemType_FK"].ToString()), ShipmentType = s["ShipmentType"].ToString(), GoodsType = s["GOODSTYPE"].ToString(), UOM = s["UOM"].ToString(), Quantity = Convert.ToInt32(s["NOOFITEMS"].ToString()), Weight = Convert.ToDouble(s["WEIGHT"].ToString()), Length = Convert.ToDouble(s["Length"].ToString()), Width = Convert.ToDouble(s["Width"].ToString()), Height = Convert.ToDouble(s["Height"].ToString()), IsPackagingRequiredFlag = Convert.ToBoolean(s["ISPACKAGINGREQUIRED?"].ToString()), IsPermitVerifiedFlag = Convert.ToBoolean(s["ISPERMITVERIFIED?"].ToString()) }).ToList(); var service = new OrderBusinessComponent(new Logistika.Service.Common.DataAccess.Config.OrderDataAccess()); service.createOrder(tOrder); } } } } if (type == "user") { for (int i = 0; i < dt.Rows.Count; i++) { LogistikaUser User = new LogistikaUser() { BranchId = dt.Rows[i]["BranchId"].ToString(), FirstName = dt.Rows[i]["FirstName"].ToString(), MiddleName = dt.Rows[i]["MiddleName"].ToString(), LastName = dt.Rows[i]["LastName"].ToString(), DateOfBirth = Convert.ToDateTime(dt.Rows[i]["DateOfBirth"].ToString()), Designation = dt.Rows[i]["EmployeeRole"].ToString(), JobTitle = dt.Rows[i]["EmployeeTitle"].ToString(), Contact = new Contact() { Email = dt.Rows[i]["PrimaryEmail"].ToString(), Phone = dt.Rows[i]["Phone"].ToString(), Mobile = dt.Rows[i]["MobileNo"].ToString(), }, Password = dt.Rows[i]["Password"].ToString(), Gender = dt.Rows[i]["Gender"].ToString(), OtherInfo = new List <DropdownData> { new DropdownData() { Text = "LicenseNumber", Value = dt.Rows[i]["LicenseNumber"].ToString(), }, new DropdownData() { Text = "LicenceClass", Value = dt.Rows[i]["LicenceClass"].ToString(), }, new DropdownData() { Text = "Experience", Value = dt.Rows[i]["Experience"].ToString(), }, new DropdownData() { Text = "MonthlyWage", Value = dt.Rows[i]["MonthlyWage"].ToString(), } }, StartDate = Convert.ToDateTime(dt.Rows[i]["StartDate"].ToString()), EndDate = Convert.ToDateTime(dt.Rows[i]["EndDate"].ToString()), Active = Convert.ToBoolean(dt.Rows[i]["IsActive"].ToString()), Addresses = new List <Address> { new Address() { AddressLine1 = dt.Rows[i]["AddressLine1"].ToString(), Suite = dt.Rows[i]["SuiteNo"].ToString(), //Locality = dt.Rows[i]["Locality"].ToString(), City = dt.Rows[i]["City"].ToString(), StateCode = dt.Rows[i]["State"].ToString(), PostalCode = dt.Rows[i]["PinCode"].ToString(), CountryCode = dt.Rows[i]["CountryCode"].ToString(), LandMark = dt.Rows[i]["LandMark"].ToString() } } }; var Pservice = new UserBusinessComponent(new UserDataAccess()); PhoneCode = Pservice.GetCountryInfo(dt.Rows[i]["CountryCode"].ToString()); //PhoneCode = _userDataAccess.GetCountryInfo(dt.Rows[i]["CountryCode"].ToString()); if (User.Contact.Mobile.StartsWith("0")) { User.Contact.Mobile = User.Contact.Mobile.TrimStart('0'); User.Contact.Mobile = PhoneCode[0].PhoneCode + User.Contact.Mobile; } else if (!User.Contact.Mobile.StartsWith("0")) { User.Contact.Mobile = PhoneCode[0].PhoneCode + User.Contact.Mobile; } if (User.Contact.Phone.StartsWith("0")) { User.Contact.Phone = User.Contact.Phone.TrimStart('0'); User.Contact.Phone = PhoneCode[0].PhoneCode + User.Contact.Phone; } else if (!User.Contact.Phone.StartsWith("0")) { User.Contact.Phone = PhoneCode[0].PhoneCode + User.Contact.Phone; } var service = new UserBusinessComponent(new UserDataAccess()); service.SaveUser(User, null); } } if (type == "fleet") { for (int i = 0; i < dt.Rows.Count; i++) { Fleet Fleet = new Fleet() { FleetID = dt.Rows[i]["FleetID"].ToString(), Make = dt.Rows[i]["Make"].ToString(), Model = dt.Rows[i]["Model"].ToString(), ModelYear = Convert.ToInt32(dt.Rows[i]["ModelYear"].ToString()), Colour = dt.Rows[i]["Colour"].ToString(), StartingMileage = Convert.ToInt32(dt.Rows[i]["StartingMileage"].ToString()), Payload = dt.Rows[i]["Payload"].ToString(), OwnerShipType = dt.Rows[i]["OwnerShipType"].ToString(), OverallLength = dt.Rows[i]["OverallLength"].ToString(), OverallWidth = dt.Rows[i]["OverallWidth"].ToString(), OverallHeight = dt.Rows[i]["OverallHeight"].ToString(), IsActive = Convert.ToBoolean(dt.Rows[i]["IsActive"].ToString()) }; var service = new UserBusinessComponent(new UserDataAccess()); service.SaveFleet(Fleet, null, "File"); } } //Console.ReadLine(); string[] fileList = Directory.GetFiles(rootFolderPath, "*.xlsx"); if (Directory.Exists(rootFolderPath)) { foreach (string file in fileList) { FileInfo mFile = new FileInfo(file); if (new FileInfo(destinationPath + "\\" + mFile.Name).Exists == false) { mFile.MoveTo(destinationPath + "\\" + mFile.Name); } } } } }