public ActionResult SetCustomerTypeManymore(ImportO2SModel model) { try { return View("ImportManyMore", model); } catch (Exception ex) { Log.AppendException(ex); ViewBag.Error = LanguageData.GetContent("erreur_selection_type_import"); } return View("ImportManyMore"); }
/// <summary> /// Needs refactoring later. Never cathc Exception here, ALWAYSSSSS THROW /// </summary> /// <param name="row"></param> /// <param name="isUpdate"></param> private void ProcessRow_old(DataRow row, ImportO2SModel model, bool isUpdate, bool isUsedByManymore = false, Dictionary<string, Guid> fieldsMatching = null) { //if (!model.IsUpdateMode) // utiliser plutôt le param if (!isUpdate) //--> cas de l'initialisation { this.InsertProcess(row, model, isUsedByManymore, fieldsMatching); } else { string nom = this.GetNomClient(row, model.Nom); string prenom = this.GetPrenomClient(row, model.Prenom); string email = this.GetEmailClient(row, model.Email); string mobilePhone = this.GetPhoneClient(row, model.TelephoneMobile); //TODO: Verifier format du numero phone bool isPersonnePhysique = this.IsPersonnePhysique(row, model.TypePersonne); bool isCustomer = Convert.ToBoolean(model.IsCustomer);// this.IsCustomer(row, model.IsCustomer); string dateNaissance = this.GetDate(row, model.DateNaissance); string weddingDate = this.GetDate(row, model.WeddingDate); string PrivatePhone = this.GetPhoneClient(row, model.Telephone); //TODO: Verifier format du numero phone string ProfessionalPhone = this.GetPhoneClient(row, model.TelephoneProfessionnel); //TODO: Verifier format du numero phone string fax = !string.IsNullOrEmpty(model.Fax) ? this.CleanString(row[model.Fax].ToString()) : string.Empty; // string nationality = this if (string.IsNullOrEmpty(email)) email = string.Empty;//string.Format("{0}@{1}", (nom + prenom).Replace(" ", ""), User.DEFAULT_MAIL_DOMAIN);//supprimer espace //mobile phone if (string.IsNullOrEmpty(mobilePhone)) mobilePhone = User.DEFAULT_MOBILEPHONE; CustomerProspect pCustomerProspect = CustomerProspectBL.GetCustomerProspectByName(model.FirmInstitution.idFirmInstitution, prenom, nom); if (pCustomerProspect == null) //TODO { this.InsertProcess(row, model, isUsedByManymore, fieldsMatching); } else { User CustomerProspectCreator = new User(); Guid idUserCreator = Guid.Empty; //Conseiller principal for Admin User if (fieldsMatching != null && fieldsMatching.Count > 0) { string conseiller = this.CleanString(row[CONSEILLER_PRINCIPAL].ToString()); if (!string.IsNullOrEmpty(conseiller) && fieldsMatching.ContainsKey(conseiller)) idUserCreator = fieldsMatching[conseiller]; } //Conseiller principal for Not Manymore //markage else if (/*isUsedByManymore && */!string.IsNullOrEmpty(model.ColumnConseillerPrincipal) && !String.IsNullOrEmpty(row[model.ColumnConseillerPrincipal].ToString())) { string conseiller = row[model.ColumnConseillerPrincipal].ToString().Trim(); CustomerProspectCreator = this.GetAdviser(conseiller, model.FirmInstitution); if (CustomerProspectCreator != null) idUserCreator = CustomerProspectCreator.idUser; } //Conseiller principal Manymore simple User or Not Manymore with non specified Adviser //Or Take current User as Default Adviser if userCreated is empty if (pCustomerProspect.idUserCreated == Guid.Empty) idUserCreator = SessionManager.GetUserSession().idUser; //check the owner if (pCustomerProspect.idUserCreated == SessionManager.GetUserSession().idUser || pCustomerProspect.idUserCreated == idUserCreator) { if (idUserCreator != Guid.Empty) pCustomerProspect.idUserCreated = idUserCreator; //common parts from import pCustomerProspect.User.UserName = nom; pCustomerProspect.User.UserFirstName = prenom; pCustomerProspect.User.UserEmail = email;//can change mail rght now pCustomerProspect.User.UserMobilePhone = mobilePhone; pCustomerProspect.ProfessionalPhone = ProfessionalPhone; pCustomerProspect.PrivatePhone = PrivatePhone; pCustomerProspect.Fax = fax; //Default value personne physique if model.TypePersonne is null pCustomerProspect.IsCorporation = false; if (!string.IsNullOrEmpty(model.TypePersonne)) { pCustomerProspect.IsCorporation = !isPersonnePhysique; //IF PM, set companyName = UserName if (!isPersonnePhysique) pCustomerProspect.CompanyName = nom; } pCustomerProspect.IsCustomer = isCustomer; if (!string.IsNullOrEmpty(dateNaissance)) { pCustomerProspect.DateOfBirth = Convert.ToDateTime(dateNaissance); pCustomerProspect.User.DateOfBirth = Convert.ToDateTime(dateNaissance); } if (!string.IsNullOrEmpty(weddingDate)) { pCustomerProspect.WeddingDate = Convert.ToDateTime(weddingDate); } pCustomerProspect.MobilePhone = mobilePhone; try { pCustomerProspect.Title = this.CleanString(row[model.Title].ToString()); } catch { } try { pCustomerProspect.PlaceOfBirth = this.CleanString(row[model.LieuNaissance].ToString()); } catch { } try { string adress2 = !string.IsNullOrEmpty(model.Adresse2) ? this.CleanString(row[model.Adresse2].ToString()) : string.Empty; pCustomerProspect.Adress = this.CleanString(row[model.Adresse].ToString()); if (!string.IsNullOrEmpty(adress2)) { pCustomerProspect.Adress += Environment.NewLine + adress2; } } catch { } try { string resident = this.CleanString(row[model.Resident].ToString()).ToLower().Replace("é", "e").Replace("ç", "c"); if (resident == "francais" || resident == "resident" || resident == "r") { pCustomerProspect.IsResident = true; } if (resident == "non resident" || resident == "resident" || resident.ToLower() == "non r") { pCustomerProspect.IsResident = false; } } catch { } try { pCustomerProspect.RefExtConjoint = this.CleanString(row[model.RefExtConjoint].ToString()); } catch { } try { pCustomerProspect.MarriageSettlement = this.CleanString(row[model.MarriageSettlement].ToString()); } catch { } try { pCustomerProspect.Liberality = this.CleanString(row[model.Liberalites].ToString()); } catch { } try { pCustomerProspect.MaidenName = this.CleanString(row[model.MaidenName].ToString()); } catch { } try { pCustomerProspect.City = this.CleanString(row[model.Ville].ToString()); } catch { } try { string country = this.CleanString(row[model.Pays].ToString()); if (country.ToUpper() == "FR") country = "France"; pCustomerProspect.Country = country; } catch { } try { pCustomerProspect.ZipCode = this.CleanString(row[model.CodePostal].ToString()); } catch { } try { string maritalStatus = this.CleanString(row[model.MaritalStatus].ToString()); pCustomerProspect.MaritalStatus = maritalStatus; } catch { } try { pCustomerProspect.Nationality = this.CleanString(row[model.Nationality].ToString()); } catch { } try { pCustomerProspect.NumSIREN = this.CleanString(row[model.NumSIREN].ToString()); } catch { } try { if (pCustomerProspect.IsCorporation == true) { //Cabinet //SC - Société civile //Non définie //SAS - Société anonyme par actions simplifiée //SC - Société civile //SARL - Société à responsabilité limitée string legalForm = this.CleanString(row[model.LegalForm].ToString()).ToUpper(); string fiscalPlan = model.FiscalPlan == null ? string.Empty : this.CleanString(row[model.FiscalPlan].ToString()).ToUpper(); if (legalForm.Contains("EURL")) pCustomerProspect.LegalForm = "EURL"; else if (legalForm.Contains("SARL") || legalForm.Contains("S.A.R.L.")) pCustomerProspect.LegalForm = "SARL"; else if (legalForm.Contains("SAS") || legalForm.Contains("S.A.S.")) pCustomerProspect.LegalForm = "SAS"; else if (legalForm.Contains("SA") || legalForm.Contains("S.A.")) pCustomerProspect.LegalForm = "SA"; else if (legalForm.Contains("ASSOCIATION")) { if (fiscalPlan.Contains("IR")) pCustomerProspect.LegalForm = "Association_IR"; //Association - IR else if (fiscalPlan.Contains("IS")) pCustomerProspect.LegalForm = "Association_IS";//Association - IS else pCustomerProspect.LegalForm = "Association"; } else if ((legalForm.Contains("SC") || legalForm.Contains("S.C.")) && !legalForm.Contains("S.C.I.")) { //#4303 if (fiscalPlan.Contains("IR")) pCustomerProspect.LegalForm = "SC_IR"; //societe civile - impot sur le revenu else if (fiscalPlan.Contains("IS")) pCustomerProspect.LegalForm = "SC_IS";//societe civile - IS else pCustomerProspect.LegalForm = "SC"; } //Autre else { if (fiscalPlan.Contains("IR")) pCustomerProspect.LegalForm = "Autre_IR"; //Autre - IR else if (fiscalPlan.Contains("IS")) pCustomerProspect.LegalForm = "Autre_IS";//Autre - IS else pCustomerProspect.LegalForm = "Autre"; pCustomerProspect.LegalForm_Autre = this.CleanString(row[model.LegalForm].ToString()); //legalForm is upper :) } } } catch { } try { string date = this.GetDate(row, model.RelationshipBeginingDate); if (!string.IsNullOrEmpty(date)) pCustomerProspect.RelationshipBeginingDate = Convert.ToDateTime(date); } catch { } try { pCustomerProspect.RiskProfile = this.CleanString(row[model.RiskProfile].ToString()); } catch { } try { string legalCapacity = this.CleanString(row[model.LegalCapacity].ToString()); pCustomerProspect.LegalCapacity = legalCapacity; } catch { } try { pCustomerProspect.Profession = this.CleanString(row[model.Profession].ToString()); } catch { } try { pCustomerProspect.RefExt = this.CleanString(row[model.RefExt].ToString()); } catch { } UserBL.UpdateUser(pCustomerProspect.User); CustomerProspectBL.Update(pCustomerProspect); } else { //throw new Exception(string.Format("{0} {1} - User existant et appartenant à un autre CGP ", nom, prenom)); //Update : A customer may be assigned to many Advisors, so insert it ? this.InsertProcess(row, model, isUsedByManymore, fieldsMatching); } } } }
public int ImportProcessing(ImportO2SModel model, out int TotalLigne, out IList<ImportErrorModel> errorsList, string sheetName = null, bool isUsedByManymore = false, char delimiter = CSV.DEFAULT_DELIMITER, Dictionary<string, Guid> fieldsMatching = null) { errorsList = new List<ImportErrorModel>(); string fullFileName = model.FullFilePath; model.FirmInstitution = FirmInstitutionBL.GetFirmInstitutionByIdFirmInstitution(model.idFirmInstitution.HasValue ? model.idFirmInstitution.Value : SessionManager.GetFirmInstitutionSession().idFirmInstitution); model.idUserProfile = UserProfileBL.GetAllUserProfiles().Where(up => up.UserProfileName.ToLower().Equals("end-user")).FirstOrDefault().idUserProfile; try { DataTable clientsData; if (isUsedByManymore) clientsData = this.ReadClientDataTableCSV(fullFileName, delimiter); else clientsData = this.ReadClientDataTableXLS(fullFileName, sheetName); //todo: RM 4606 #region : Initialisation : suppression données existants avant import if ((ImportO2SModel.ModeOfImport)model.ImportMode == ImportO2SModel.ModeOfImport.Initialisation) { //Delete all prospect if (!string.IsNullOrEmpty(model.ColumnConseillerPrincipal)) { //let s suppose that we have a list of adviser in a file. var conseillerLists = (from myRow in clientsData.AsEnumerable() select myRow.Field<string>(model.ColumnConseillerPrincipal)).Distinct(); foreach (var conseiller in conseillerLists) { if (conseiller != null) { User adviser = this.GetAdviser(conseiller, model.FirmInstitution); if (adviser != null) if (!CustomerProspectBL.DeleteAllProspectForCGP(adviser.idUser, model.IsCustomer)) throw new Exception("DeleteAllProspectForCGP failed");//if one fail, would be better to stop ALL } }; } else { if (fieldsMatching != null && fieldsMatching.Count > 0) { foreach (string conseiller in fieldsMatching.Keys) { if (conseiller != null) { User adviser = this.GetAdviserById(fieldsMatching[conseiller]); if (adviser != null) if (!CustomerProspectBL.DeleteAllProspectForCGP(adviser.idUser, model.IsCustomer)) throw new Exception("DeleteAllProspectForCGP failed");//if one fail, would be better to stop ALL } } } else { if (!CustomerProspectBL.DeleteAllProspectForCGP(SessionManager.GetUserSession().idUser, model.IsCustomer)) throw new Exception("DeleteAllProspectForCGP failed"); } } } #endregion //complete data var rows = clientsData.Select(); //HACK:hmmm improve ..... if (!isUsedByManymore && !SessionManager.GetUserSession().IsAdmin() && model.DataConseillerPrincipal != "value") { //filtered data rows = (from data in clientsData.AsEnumerable() where data.Field<string>(CONSEILLER_PRINCIPAL) == model.DataConseillerPrincipal select data).ToArray(); } int compteur = 0; //int line = 0; int line = 1; TotalLigne = rows.Length; foreach (DataRow row in rows) { line++; string nom = string.Empty; string prenom = string.Empty; string email = string.Empty; string phone = string.Empty; bool insert; try { nom = this.GetNomClient(row, model.Nom); prenom = this.GetPrenomClient(row, model.Prenom); email = this.GetEmailClient(row, model.Email); phone = this.GetPhoneClient(row, model.Telephone); //TODO: Verifier format du numero phone if (nom + prenom == string.Empty || (nom + prenom).ToLower() == "total") //remove the test with total later if the file will not contain it { //Report error to view errorsList.Add(new ImportErrorModel() { LineNumber = line, Name = nom, FirstName = prenom, Email = email, Phone = phone, Error = "Nom et prénom non fournis" }); continue; } this.ProcessRow(row, model, out insert, isUsedByManymore, fieldsMatching); } catch (Exception ex) { Log.AppendException(ex); //Report error to view errorsList.Add(new ImportErrorModel() { LineNumber = line, Name = nom, FirstName = prenom, Email = email, Phone = phone, Error = ex.Message }); continue; } if ((ImportO2SModel.ModeOfImport)model.ImportMode == ImportO2SModel.ModeOfImport.InsertOnly && insert) compteur++; else { if ((ImportO2SModel.ModeOfImport)model.ImportMode == ImportO2SModel.ModeOfImport.Initialisation || (ImportO2SModel.ModeOfImport)model.ImportMode == ImportO2SModel.ModeOfImport.Update) compteur++; } } return compteur; } catch (Exception e) { Log.AppendException(e); throw e; } }
/// <summary> /// /// </summary> /// <param name="model"></param> private void InsertProcess(DataRow row, ImportO2SModel model, bool isUsedByManymore = false, Dictionary<string, Guid> fieldsMatching = null) { string nom = this.GetNomClient(row, model.Nom); string prenom = this.GetPrenomClient(row, model.Prenom); string email = this.GetEmailClient(row, model.Email); string mobilePhone = this.GetPhoneClient(row, model.TelephoneMobile); //TODO: Verifier format du numero phone string privatePhone = this.GetPhoneClient(row, model.Telephone); //TODO: Verifier format du numero phone string professionalPhone = this.GetPhoneClient(row, model.TelephoneProfessionnel); //TODO: Verifier format du numero phone string fax = !string.IsNullOrEmpty(model.Fax) ? this.CleanString(row[model.Fax].ToString()) : string.Empty; bool isPersonnePhysique = this.IsPersonnePhysique(row, model.TypePersonne); bool isCustomer = Convert.ToBoolean(model.IsCustomer);// this.IsCustomer(row, model.IsCustomer); string dateNaissance = this.GetDate(row, model.DateNaissance); string weddingDate = this.GetDate(row, model.WeddingDate); if (string.IsNullOrEmpty(email)) email = string.Empty; // string.Format("{0}@{1}", (nom + prenom).Replace(" ", ""), User.DEFAULT_MAIL_DOMAIN); if (string.IsNullOrEmpty(mobilePhone)) mobilePhone = User.DEFAULT_MOBILEPHONE; CustomerProspect pCustomerProspect = new CustomerProspect(); pCustomerProspect.User = new User(); pCustomerProspect.User.idUser = Business.Utility.GuidHelper.GenerateGuid(); pCustomerProspect.User.idUserProfile = model.idUserProfile; pCustomerProspect.User.DateCreated = DateTime.Now; pCustomerProspect.User.IsActive = true; pCustomerProspect.idFirmInstitution = !model.idFirmInstitution.HasValue ? SessionManager.GetFirmInstitutionSession().idFirmInstitution : model.idFirmInstitution.Value;// model.idFirmInstitution.Value;//SessionManager.GetFirmInstitutionSession().idFirmInstitution; pCustomerProspect.User.UserPassword = ""; //Temporary set pCustomerProspect.idCustomer = Business.Utility.GuidHelper.GenerateGuid(); //common parts from import pCustomerProspect.User.UserName = nom; pCustomerProspect.User.UserFirstName = prenom; pCustomerProspect.User.UserEmail = email; pCustomerProspect.User.UserLogin = email; pCustomerProspect.User.UserMobilePhone = mobilePhone; //default value personne physique if model.TypePersonne is Empty or Null pCustomerProspect.IsCorporation = false; if (!string.IsNullOrEmpty(model.TypePersonne)) { pCustomerProspect.IsCorporation = !isPersonnePhysique; //IF PM, set companyName = UserName if (!isPersonnePhysique) pCustomerProspect.CompanyName = nom; } if (!string.IsNullOrEmpty(dateNaissance)) { pCustomerProspect.DateOfBirth = Convert.ToDateTime(dateNaissance); pCustomerProspect.User.DateOfBirth = Convert.ToDateTime(dateNaissance); } pCustomerProspect.User = UserBL.CreateUser(pCustomerProspect.User, pCustomerProspect.User.UserPassword); pCustomerProspect.IdUser = pCustomerProspect.User.idUser; pCustomerProspect.IsCustomer = isCustomer; pCustomerProspect.MobilePhone = mobilePhone; pCustomerProspect.ProfessionalPhone = professionalPhone; pCustomerProspect.PrivatePhone = privatePhone; pCustomerProspect.Fax = fax; //Conseiller principal for Admin User if (fieldsMatching != null && fieldsMatching.Count > 0) { string conseiller = this.CleanString(row[CONSEILLER_PRINCIPAL].ToString()); if (!string.IsNullOrEmpty(conseiller) && fieldsMatching.ContainsKey(conseiller)) pCustomerProspect.idUserCreated = fieldsMatching[conseiller]; } //Conseiller principal for Not Manymore //markage else if (/*isUsedByManymore &&*/ !string.IsNullOrEmpty(model.ColumnConseillerPrincipal) && !String.IsNullOrEmpty(row[model.ColumnConseillerPrincipal].ToString())) { string conseiller = row[model.ColumnConseillerPrincipal].ToString().Trim(); User CustomerProspectCreator = this.GetAdviser(conseiller, model.FirmInstitution); if (CustomerProspectCreator != null) pCustomerProspect.idUserCreated = CustomerProspectCreator.idUser; } //Conseiller principal Manymore simple User or Not Manymore with non specified Adviser //Or Take current User as Default Adviser if userCreated is empty if (pCustomerProspect.idUserCreated == Guid.Empty) pCustomerProspect.idUserCreated = SessionManager.GetUserSession().idUser; try { string title = this.CleanString(row[model.Title].ToString()); if (title == "M") { title = "Monsieur"; } else if (title == "F") { title = "Madame"; } pCustomerProspect.Title = title; } catch { } try { pCustomerProspect.PlaceOfBirth = this.CleanString(row[model.LieuNaissance].ToString()); } catch { } try { string adress2 = !string.IsNullOrEmpty(model.Adresse2) ? this.CleanString(row[model.Adresse2].ToString()) : string.Empty; pCustomerProspect.Adress = this.CleanString(row[model.Adresse].ToString()); if (!string.IsNullOrEmpty(adress2)) { pCustomerProspect.Adress += Environment.NewLine + adress2; } } catch { } try { string resident = this.CleanString(row[model.Resident].ToString()).ToLower().Replace("é", "e").Replace("ç", "c"); if (resident == "francais" || resident == "resident" || resident == "r") { pCustomerProspect.IsResident = true; } if (resident == "non resident" || resident.ToLower() == "non r") { pCustomerProspect.IsResident = false; } } catch { } try { pCustomerProspect.RefExtConjoint = this.CleanString(row[model.RefExtConjoint].ToString()); } catch { } try { pCustomerProspect.MarriageSettlement = this.CleanString(row[model.MarriageSettlement].ToString()); } catch { } try { pCustomerProspect.Liberality = this.CleanString(row[model.Liberalites].ToString()); } catch { } try { pCustomerProspect.MaidenName = this.CleanString(row[model.MaidenName].ToString()); } catch { } try { pCustomerProspect.City = this.CleanString(row[model.Ville].ToString()); } catch { } try { string country = this.CleanString(row[model.Pays].ToString()); if (country.ToUpper() == "FR") country = "France"; pCustomerProspect.Country = country; } catch { } try { pCustomerProspect.ZipCode = this.CleanString(row[model.CodePostal].ToString()); } catch { } try { string maritalStatus = this.CleanString(row[model.MaritalStatus].ToString()); if (maritalStatus.ToLower().StartsWith("c")) { maritalStatus = "Célibataire"; } else if (maritalStatus.ToLower().StartsWith("d")) { maritalStatus = "Divorcé"; } else if (maritalStatus.ToLower().StartsWith("m")) { maritalStatus = "Marié"; } else if (maritalStatus.ToLower().StartsWith("v")) { maritalStatus = "Veuf"; } else if (maritalStatus.ToLower().StartsWith("p")) { maritalStatus = "Pacsé"; } if (!maritalStatus.ToLower().Contains("non défini")) pCustomerProspect.MaritalStatus = maritalStatus; } catch { } try { pCustomerProspect.Nationality = this.CleanString(row[model.Nationality].ToString()); } catch { } try { pCustomerProspect.NumSIREN = this.CleanString(row[model.NumSIREN].ToString()); } catch { } try { if (pCustomerProspect.IsCorporation == true) { //Cabinet //SC - Société civile //Non définie //SAS - Société anonyme par actions simplifiée //SC - Société civile //SARL - Société à responsabilité limitée string legalForm = this.CleanString(row[model.LegalForm].ToString()).ToUpper(); string fiscalPlan = model.FiscalPlan == null ? string.Empty : this.CleanString(row[model.FiscalPlan].ToString()).ToUpper(); if (legalForm.Contains("EURL")) pCustomerProspect.LegalForm = "EURL"; else if (legalForm.Contains("SARL") || legalForm.Contains("S.A.R.L.")) pCustomerProspect.LegalForm = "SARL"; else if (legalForm.Contains("SAS") || legalForm.Contains("S.A.S.")) pCustomerProspect.LegalForm = "SAS"; else if (legalForm.Contains("SA") || legalForm.Contains("S.A.")) pCustomerProspect.LegalForm = "SA"; else if (legalForm.Contains("ASSOCIATION")) { if (fiscalPlan.Contains("IR")) pCustomerProspect.LegalForm = "Association_IR"; //Association - IR else if (fiscalPlan.Contains("IS")) pCustomerProspect.LegalForm = "Association_IS";//Association - IS else pCustomerProspect.LegalForm = "Association"; } else if ((legalForm.Contains("SC") || legalForm.Contains("S.C.")) && !legalForm.Contains("S.C.I.")) { //#4303 if (fiscalPlan.Contains("IR")) pCustomerProspect.LegalForm = "SC_IR"; //societe civile - impot sur le revenu else if (fiscalPlan.Contains("IS")) pCustomerProspect.LegalForm = "SC_IS";//societe civile - IS else pCustomerProspect.LegalForm = "SC"; } //Autre else { if (fiscalPlan.Contains("IR")) pCustomerProspect.LegalForm = "Autre_IR"; //Autre - IR else if (fiscalPlan.Contains("IS")) pCustomerProspect.LegalForm = "Autre_IS";//Autre - IS else pCustomerProspect.LegalForm = "Autre"; pCustomerProspect.LegalForm_Autre = legalForm; } } } catch { } try { string date = this.GetDate(row, model.RelationshipBeginingDate); if (!string.IsNullOrEmpty(date)) pCustomerProspect.RelationshipBeginingDate = Convert.ToDateTime(date); } catch { } try { pCustomerProspect.RiskProfile = this.CleanString(row[model.RiskProfile].ToString()); } catch { } try { string legalCapacity = this.CleanString(row[model.LegalCapacity].ToString()); pCustomerProspect.LegalCapacity = legalCapacity; } catch { } try { pCustomerProspect.Profession = this.CleanString(row[model.Profession].ToString()); } catch { } try { pCustomerProspect.RefExt = this.CleanString(row[model.RefExt].ToString()); } catch { } /*new*/ try { string numerorcs = this.CleanString(row[model.NumeroRCS].ToString()); pCustomerProspect.NumRCS = numerorcs; } catch { } try { string lieurcs = this.CleanString(row[model.LieuRCS].ToString()); pCustomerProspect.NumRCS = lieurcs; } catch { } try { string originerelation = this.CleanString(row[model.Originerelation].ToString()); if (originerelation.ToLower().Trim().Equals("recommandation") || originerelation.ToLower().Trim().Equals("prescription") || originerelation.ToLower().Trim().Equals("lien familial")) { originerelation = "contactparrecommandation"; } else if (originerelation.ToLower().Trim().Equals("client historique")) { originerelation = "clientdepuis"; } else { originerelation = "autre"; } pCustomerProspect.RelationshipType = originerelation; } catch { } try { string clientdepuis = this.GetDate(row, model.Clientdepuis); if (!string.IsNullOrEmpty(clientdepuis)) { pCustomerProspect.RelationshipBeginingDate = Convert.ToDateTime(clientdepuis); pCustomerProspect.RelationshipType = "clientdepuis"; } } catch { } string maritalStatusTest = string.Empty; try { maritalStatusTest = this.CleanString(row[model.MaritalStatus].ToString()); } catch { } string datepacs = string.Empty; try { datepacs = this.GetDate(row, model.Datepacs); } catch { } string datedivorce = string.Empty; try { datedivorce = this.GetDate(row, model.Datedivorce); } catch { } try { if (!string.IsNullOrEmpty(datepacs) && string.IsNullOrEmpty(maritalStatusTest)) { pCustomerProspect.WeddingDate = Convert.ToDateTime(datepacs); pCustomerProspect.MaritalStatus = "Pacsé"; } } catch { } try { if (!string.IsNullOrEmpty(datedivorce) && string.IsNullOrEmpty(maritalStatusTest) && string.IsNullOrEmpty(datepacs)) { pCustomerProspect.WeddingDate = Convert.ToDateTime(datedivorce); pCustomerProspect.MaritalStatus = "Divorcé"; } } catch { } try { if (!string.IsNullOrEmpty(weddingDate) && string.IsNullOrEmpty(maritalStatusTest) && string.IsNullOrEmpty(datepacs) && string.IsNullOrEmpty(datedivorce)) { pCustomerProspect.WeddingDate = Convert.ToDateTime(weddingDate); pCustomerProspect.MaritalStatus = "Marié"; } } catch { } try { string residencefiscal = this.CleanString(row[model.Residencefiscale].ToString()); pCustomerProspect.FiscalAddrress = residencefiscal; } catch { } /*end new*/ CustomerProspectBL.CreateCustomerForImport(pCustomerProspect); }
public int ImportManyMore(string fullFileName, ImportO2SModel model, bool isUpdate, out int TotalLigne, char delimiter = CSV.DEFAULT_DELIMITER) { try { DataTable clientsData = this.ReadClientDataTableCSV(fullFileName, delimiter); int compteur = 0; TotalLigne = clientsData.Rows.Count; bool insert; foreach (DataRow row in clientsData.Rows) { try { string nom = this.GetNomClient(row, model.Nom); string prenom = this.GetPrenomClient(row, model.Prenom); string email = this.GetEmailClient(row, model.Email); string phone = this.GetPhoneClient(row, model.Telephone); //TODO: Verifier format du numero phone if (nom + prenom == string.Empty) { //Console.Write("required fields ôoo!"); continue; } this.ProcessRow(row, model, out insert, isUpdate); } catch (Exception ex) { Log.AppendException(ex); continue; } compteur++; } return compteur; } catch (Exception e) { Log.AppendException(e); throw e; } }
public ActionResult SetCustomerTypeXlsCsv(ImportO2SModel model) { try { if (!string.IsNullOrEmpty(Request.Params["idFirmInstitution"])) { model.idFirmInstitution = new Guid(Request.Params["idFirmInstitution"]); model.FirmInstitutionName = FirmInstitutionBL.GetFirmInstitutionByIdFirmInstitution(model.idFirmInstitution.Value).FirmInstitutionName; } return View("XlsCsv", model); } catch (Exception ex) { Log.AppendException(ex); ViewBag.Error = LanguageData.GetContent("erreur_selection_type_import"); } return View("XlsCsv"); }
public ActionResult LoadXlsCsv(HttpPostedFileBase idUploadFile, ImportO2SModel model) { var path = string.Empty; try { //If user has already customers, set IsUpdateMode to true by default if (CustomerProspectBL.GetCustomerByIdUserCreated(SessionManager.GetUserSession().idUser).Count() > 0) { //model.IsUpdateMode = true; model.ImportMode = (int)ImportO2SModel.ModeOfImport.Update; } // if (ModelState.IsValid) { // Verify that the user selected a file if (idUploadFile != null && idUploadFile.ContentLength > 0) { // extract only the fielname var fileName = string.Format("{0}-{1}", DateTime.Now.ToString("ddMMyyyy"), Path.GetFileName(idUploadFile.FileName)); path = Path.Combine(Server.MapPath("~/uploads"), fileName); if (!Directory.Exists(Server.MapPath("~/uploads"))) Directory.CreateDirectory(Server.MapPath("~/uploads")); if (Path.GetExtension(path).Equals(".xlsx") || Path.GetExtension(path).Equals(".xls")) { idUploadFile.SaveAs(path); ImportHelper pImportHelper = new ImportHelper(); // pImportHelper.Load(path); model.SheetNames = new ImportHelper().GetSheetNames(path); if (model.SheetNames.Count == 1) { model.SelectedSheetName = model.SheetNames[0].Value; model.ColumnNames = new ImportHelper().GetUsableColumnNames(path, model.SelectedSheetName); model.Source = ImportO2SModel.FileSource.Excel; } } else if (Path.GetExtension(path).ToLower() == ".csv") { idUploadFile.SaveAs(path); model.Source = ImportO2SModel.FileSource.CSV; //if (model.Delimiter == "DEFAULT_DELIMITER") // model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(path, CSV.DEFAULT_DELIMITER); //else // model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(path, CSV.SEMI_COLON_DELIMITER); } else { //2014-07-29 : Error File not supported ViewBag.Error = LanguageData.GetContent("seul_excel_csv_autorise"); } model.FullFilePath = path; return View("XlsCsv", model); } else { ViewBag.Error = LanguageData.GetContent("verifier_fichier_a_uploader"); return View("XlsCsv", model); } } // ViewBag.Error = "Veuillez vérifier les champs obligatoires."; } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = string.Format("{0} : {1}", LanguageData.GetContent("erreur_import"), ex.Message); } return View("XlsCsv"); }
public ActionResult Load(HttpPostedFileBase idUploadFile, ImportO2SModel model) { var path = string.Empty; try { ImportHelper pImportHelper = new ImportHelper(); //If user has already customers, set IsUpdateMode to true by default if (CustomerProspectBL.GetCustomerByIdUserCreated(SessionManager.GetUserSession().idUser).Count() > 0) { //model.IsUpdateMode = true; model.ImportMode = (int)ImportO2SModel.ModeOfImport.Update; } // if (ModelState.IsValid) { // Verify that the user selected a file if (idUploadFile != null && idUploadFile.ContentLength > 0) { // extract only the fielname var fileName = string.Format("{0}-{1}", DateTime.Now.ToString("ddMMyyyy"), Path.GetFileName(idUploadFile.FileName)); path = Path.Combine(Server.MapPath("~/uploads"), fileName); if (!Directory.Exists(Server.MapPath("~/uploads"))) Directory.CreateDirectory(Server.MapPath("~/uploads")); // ImportHelper pImportHelper = new ImportHelper(); //pImportHelper.TestGetByName(); // pImportHelper.Load(path); //2014-07-29 : Check file extension if (Path.GetExtension(path).Equals(".xlsx") || Path.GetExtension(path).Equals(".xls")) { idUploadFile.SaveAs(path); // ViewData["FileFullPath"] = path; model.SheetNames = pImportHelper.GetSheetNames(path); if (model.SheetNames.Count == 1) { model.SelectedSheetName = model.SheetNames[0].Value; model.ColumnNames = pImportHelper.GetUsableColumnNames(path, model.SelectedSheetName); } model.FullFilePath = path; //prendre la liste des conseillers principaux model.ListAdvisers = pImportHelper.GetListConseillerPrincicpal(model.FullFilePath, model.SelectedSheetName); //prendre et charger la liste de tous ces **** de client if (SessionManager.GetUserSession().CanViewAdvisersList()) { bool filterAdvisersByUserFirm = (SessionManager.GetUserSession().IsAdministrativeAssistant()) ? true : false; var lstAdvisers = Business.Configuration.FirmInstitutionAdviserBL.GetAdvisersByIdFirmParent(SessionManager.GetFirmInstitutionSession(), SessionManager.GetUserSession(), filterAdvisersByUserFirm, false) .GroupBy(a => a.idUser) .Select(ad => ad.First()) .OrderBy(a => a.User.UserName) .ToList<FirmInstitutionAdviser>(); //List<FirmInstitutionAdviser> lstAdvisers = FirmInstitutionAdviserBL.GetAdvisers(SessionManager.GetFirmInstitutionSession(), false); model.ListAdvisersFromDatabase = new List<SelectListItem>(); //add vide model.ListAdvisersFromDatabase.Add(new SelectListItem() { Text = "", Value = "" }); foreach (var adviser in lstAdvisers) { model.ListAdvisersFromDatabase.Add(new SelectListItem() { Text = string.Format("{0}, {1}, {2}", adviser.User.UserName, adviser.User.UserFirstName, adviser.User.UserEmail), Value = adviser.User.idUser.ToString() }); } } else { bool isEmpty = CustomerProspectBL.IsProspectForCGPEmpty(SessionManager.GetUserSession().idUser, model.IsCustomer); model.InitilizationModeChecked = isEmpty;//utilisé ?? model.UpdateModeChecked = !isEmpty; //utilisé ?? if (isEmpty) model.ImportMode = (int)ImportO2SModel.ModeOfImport.Initialisation; else model.ImportMode = (int)ImportO2SModel.ModeOfImport.Update; } } else { //2014-07-29 : Error File not supported ViewBag.Error = LanguageData.GetContent("seul_excel_autorise"); } return View("ImportO2Harvest", model); } else { ViewBag.Error = LanguageData.GetContent("verifier_fichier_a_uploader"); return View("ImportO2Harvest", model); } } // ViewBag.Error = "Veuillez vérifier les champs obligatoires."; } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = string.Format("{0} : {1}", LanguageData.GetContent("erreur_import"), ex.Message); } return View("ImportO2Harvest"); }
public ActionResult LoadSeparator(ImportO2SModel model) { try { //If user has already customers, set IsUpdateMode to true by default if (CustomerProspectBL.GetCustomerByIdUserCreated(SessionManager.GetUserSession().idUser).Count() > 0) { //model.IsUpdateMode = true; model.ImportMode = (int)ImportO2SModel.ModeOfImport.Update; } model.Source = ImportO2SModel.FileSource.CSV; if (model.Delimiter == "DEFAULT_DELIMITER") model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(model.FullFilePath, CSV.DEFAULT_DELIMITER); else model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(model.FullFilePath, CSV.SEMI_COLON_DELIMITER); return View("XlsCsv", model); } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = string.Format("{0} : {1}", LanguageData.GetContent("erreur_import"), ex.Message); } return View("XlsCsv"); }
public ActionResult ProcessManymoreXlsCsv(ImportO2SModel model) { model.Source = ImportO2SModel.FileSource.CSV; // char delimiter = CSV.SEMI_COLON_DELIMITER; ImportHelper pImportHelper = new ImportHelper(); try { if (ModelState.IsValid && !string.IsNullOrEmpty(model.FullFilePath)) { int total = 0, vita = 0; IList<ImportErrorModel> errorsList = new List<ImportErrorModel>(); vita = pImportHelper.ImportProcessing(model, out total, out errorsList, null, true, /*delimiter*/model.Separator); //if (model.IsUpdateMode) //{ // // ImportHelper pImportHelper = new ImportHelper(); // vita = pImportHelper.ImportManyMore(model.FullFilePath.ToString(), model, true, out total, delimiter); //} //else //{ // //TODO:delete test // if (!CustomerProspectBL.DeleteAllProspectForCGP(SessionManager.GetUserSession().idUser)) // throw new Exception("DeleteAllProspectForCGP"); // // pImportHelper = new ImportHelper(); // vita = pImportHelper.ImportManyMore(model.FullFilePath.ToString(), model, false, out total, delimiter); //} ViewBag.Message = string.Format("{0} {1} / {2}", LanguageData.GetContent("nb_ligne_importées"), vita, total); if (errorsList.Count > 0) { ViewBag.Errors = errorsList; } model.CanImportNewFile = true; return View("XlsCsv", model); } else ViewBag.Error = LanguageData.GetContent("verifier_champs_obligatoires"); } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = LanguageData.GetContent("erreur_import"); } if (model.Delimiter == "DEFAULT_DELIMITER") model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(model.FullFilePath, CSV.DEFAULT_DELIMITER); else model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(model.FullFilePath, CSV.SEMI_COLON_DELIMITER); return View("XlsCsv", model); }
public ActionResult LoadCSV(HttpPostedFileBase idUploadFile, ImportO2SModel model) { var path = string.Empty; try { //If user has already customers, set IsUpdateMode to true by default if (CustomerProspectBL.GetCustomerByIdUserCreated(SessionManager.GetUserSession().idUser).Count() > 0) { //model.IsUpdateMode = true; model.ImportMode = (int)ImportO2SModel.ModeOfImport.Update; } if (idUploadFile != null && idUploadFile.ContentLength > 0) { // extract only the fielname var fileName = string.Format("{0}-{1}", DateTime.Now.ToString("ddMMyyyy"), Path.GetFileName(idUploadFile.FileName)); path = Path.Combine(Server.MapPath("~/uploads"), fileName); if (!Directory.Exists(Server.MapPath("~/uploads"))) Directory.CreateDirectory(Server.MapPath("~/uploads")); //Check extension if (Path.GetExtension(path).ToLower() == ".csv") { idUploadFile.SaveAs(path); model.FullFilePath = path; ImportHelper helper = new ImportHelper(); if (model.Delimiter == "DEFAULT_DELIMITER") model.ColumnNames = helper.GetCSVUsableColumnNames(path, CSV.DEFAULT_DELIMITER); else model.ColumnNames = helper.GetCSVUsableColumnNames(path, CSV.SEMI_COLON_DELIMITER); //TODO: REMOVE //prendre la liste des conseillers principaux //model.ListAdvisers = helper.GetListConseillerPrincicpal(model.FullFilePath,null,true, model.Separator); ////prendre et charger la liste de tous ces **** de client //if (SessionManager.GetUserSession().IsAdmin()) //{ // var lstAdvisers = Business.Configuration.FirmInstitutionAdviserBL.GetAdvisersByIdParent(SessionManager.GetFirmInstitutionSession(), false) // .GroupBy(a => a.idUser) // .Select(ad => ad.First()) // .OrderBy(a => a.User.UserName) // .ToList<FirmInstitutionAdviser>(); // //List<FirmInstitutionAdviser> lstAdvisers = FirmInstitutionAdviserBL.GetAdvisers(SessionManager.GetFirmInstitutionSession(), false); // model.ListAdvisersFromDatabase = new List<SelectListItem>(); // //add vide // model.ListAdvisersFromDatabase.Add(new SelectListItem() { Text = "", Value = "" }); // foreach (var adviser in lstAdvisers) // { // model.ListAdvisersFromDatabase.Add(new SelectListItem() { Text = string.Format("{0}, {1}, {2}", adviser.User.UserName, adviser.User.UserFirstName, adviser.User.UserEmail), Value = adviser.User.idUser.ToString() }); // } //} //radio button } else { //2014-07-29 : Error File not supported ViewBag.Error = LanguageData.GetContent("seul_csv_autorise"); } return View("ImportManyMore", model); } else { ViewBag.Error = LanguageData.GetContent("verifier_fichier_a_uploader"); return View("ImportManyMore", model); } } catch (ArgumentException ex) { Log.AppendException(ex); if (ex.Message.Contains("Conseiller principal")) ViewBag.Error = LanguageData.GetContent("verifier_presence_colonne"); else ViewBag.Error = ex.Message; } catch (Exception ex) { Log.AppendException(ex); ViewBag.Error = LanguageData.GetContent("erreur_import_contacter_admin"); } return View("ImportManyMore"); }
public ActionResult ProcessManymore(ImportO2SModel model) { //char delimiter = CSV.SEMI_COLON_DELIMITER; try { int mode = Convert.ToInt32(Request["ImportMode"]); model.ImportMode = mode; ImportHelper helper = new ImportHelper(); //TODO:REMOVE //correspondance des advisers //Dictionary<string, Guid> dicAdvisers = new Dictionary<string, Guid>(); //if (SessionManager.GetUserSession().IsAdmin()) //{ // //prendre et charger la liste de tous ces **** de client // List<FirmInstitutionAdviser> lstAdvisers = FirmInstitutionAdviserBL.GetAdvisers(SessionManager.GetFirmInstitutionSession(), false); // model.ListAdvisersFromDatabase = new List<SelectListItem>(); // foreach (var adviser in lstAdvisers) // { // model.ListAdvisersFromDatabase.Add(new SelectListItem() { Text = string.Format("{0}, {1}, {2}", adviser.User.UserName, adviser.User.UserFirstName, adviser.User.UserEmail), Value = adviser.User.idUser.ToString() }); // } // model.ListAdvisers = helper.GetListConseillerPrincicpal(model.FullFilePath,null,true, model.Separator); // //TODO : Otran ts mety ilay samy dropdown a // //prendre la correspondance des advisers selon l'admin // foreach (var importAdvisers in model.ListAdvisers) // { // string adviserKey = "Advisers_" + importAdvisers.Value.Replace(" ", "_"); // string adviserFromDatabaseKey = "AdvisersFromDatabase_" + importAdvisers.Value.Replace(" ", "_"); // if (!string.IsNullOrEmpty(Request.Params[adviserKey].ToString()) && !string.IsNullOrEmpty(Request.Params[adviserFromDatabaseKey].ToString())) // { // dicAdvisers.Add(/*importAdvisers.Value*/Request.Params[adviserKey], new Guid(Request.Params[adviserFromDatabaseKey])); // } // } //} if (ModelState.IsValid && !string.IsNullOrEmpty(model.FullFilePath)) { int total = 0, vita = 0; IList<ImportErrorModel> errorsList = new List<ImportErrorModel>(); //TODO:REMOVE DIC vita = helper.ImportProcessing(model, out total, out errorsList, null, true, /*delimiter*/model.Separator/*, dicAdvisers*/); ViewBag.Message = string.Format("{0} {1} / {2}", LanguageData.GetContent("nb_ligne_importées"), vita, total); if (errorsList.Count > 0) { ViewBag.Errors = errorsList; } model.CanImportNewFile = true; return View("ImportManyMore", model); } else { var errors = ModelState.Values.SelectMany(v => v.Errors); ViewBag.Error = LanguageData.GetContent("verifier_champs_obligatoires"); } } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = string.Format("{0} : {1}", LanguageData.GetContent("erreur_import"), ex.Message); } if (model.Delimiter == "DEFAULT_DELIMITER") model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(model.FullFilePath, CSV.DEFAULT_DELIMITER); else model.ColumnNames = new ImportHelper().GetCSVUsableColumnNames(model.FullFilePath, CSV.SEMI_COLON_DELIMITER); return View("ImportManyMore", model); }
public ActionResult ProcessImportExcel(ImportO2SModel model) { try { if (ModelState.IsValid && !string.IsNullOrEmpty(model.FullFilePath)) { int total = 0, vita = 0; int mode = Convert.ToInt32(Request["ImportMode"]); model.ImportMode = mode; IList<ImportErrorModel> errorsList = new List<ImportErrorModel>(); ImportHelper pImportHelper = new ImportHelper(); vita = pImportHelper.ImportProcessing(model, out total, out errorsList, model.SelectedSheetName); ViewBag.Message = string.Format("{0} {1} / {2}", LanguageData.GetContent("nb_ligne_importées"), vita, total); if (errorsList.Count > 0) { ViewBag.Errors = errorsList; } model.CanImportNewFile = true; return View("XlsCsv", model); } else ViewBag.Error = LanguageData.GetContent("verifier_champs_obligatoires"); } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = string.Format("{0} : {1}", LanguageData.GetContent("erreur_import"), ex.Message); } model.ColumnNames = new ImportHelper().GetUsableColumnNames(model.FullFilePath, model.SelectedSheetName); model.SheetNames = new ImportHelper().GetSheetNames(model.FullFilePath); model.IsSheetNameSelection = true; return View("XlsCsv", model); }
public ActionResult ProcessImportO2Harvest(ImportO2SModel model) { try { ImportHelper pImportHelper = new ImportHelper(); //correspondance des advisers Dictionary<string, Guid> dicAdvisers = new Dictionary<string, Guid>(); if (SessionManager.GetUserSession().IsAdmin()) { //prendre et charger la liste de tous ces **** de client List<FirmInstitutionAdviser> lstAdvisers = FirmInstitutionAdviserBL.GetAdvisers(!model.idFirmInstitution.HasValue ? SessionManager.GetFirmInstitutionSession() : FirmInstitutionBL.GetFirmInstitutionByIdFirmInstitution(model.idFirmInstitution.Value), false); model.ListAdvisersFromDatabase = new List<SelectListItem>(); foreach (var adviser in lstAdvisers) { model.ListAdvisersFromDatabase.Add(new SelectListItem() { Text = string.Format("{0}, {1}, {2}", adviser.User.UserName, adviser.User.UserFirstName, adviser.User.UserEmail), Value = adviser.User.idUser.ToString() }); } model.ListAdvisers = pImportHelper.GetListConseillerPrincicpal(model.FullFilePath, model.SelectedSheetName); //TODO : Otran ts mety ilay samy dropdown a //prendre la correspondance des advisers selon l'admin foreach (var importAdvisers in model.ListAdvisers) { string adviserKey = "Advisers_" + importAdvisers.Value.Replace(" ", "_"); string adviserFromDatabaseKey = "AdvisersFromDatabase_" + importAdvisers.Value.Replace(" ", "_"); if (!string.IsNullOrEmpty(Request.Params[adviserKey].ToString()) && !string.IsNullOrEmpty(Request.Params[adviserFromDatabaseKey].ToString())) { dicAdvisers.Add(/*importAdvisers.Value*/Request.Params[adviserKey], new Guid(Request.Params[adviserFromDatabaseKey])); } } } if (ModelState.IsValid && !string.IsNullOrEmpty(model.FullFilePath)) { int mode = Convert.ToInt32(Request["ImportMode"]); model.ImportMode = mode; int total = 0, vita = 0; IList<ImportErrorModel> errorsList = new List<ImportErrorModel>(); //TODO:add DIC vita = pImportHelper.ImportProcessing(model, out total, out errorsList, model.SelectedSheetName, false, CSV.DEFAULT_DELIMITER, dicAdvisers); ViewBag.Message = string.Format("{0} {1} / {2}", LanguageData.GetContent("nb_ligne_importées"), vita, total); if (errorsList.Count > 0) { ViewBag.Errors = errorsList; } model.CanImportNewFile = true; return View("ImportO2Harvest", model); } else ViewBag.Error = LanguageData.GetContent("verifier_champs_obligatoires"); } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = string.Format("{0} : {1}", LanguageData.GetContent("erreur_import"), ex.Message); } model.ColumnNames = new ImportHelper().GetUsableColumnNames(model.FullFilePath, model.SelectedSheetName); model.SheetNames = new ImportHelper().GetSheetNames(model.FullFilePath); model.IsSheetNameSelection = true; return View("ImportO2Harvest", model); }
public ActionResult HandleColumnselectionXlsCsv(ImportO2SModel model) { try { ImportHelper helper = new ImportHelper(); int mode = Convert.ToInt32(Request["ImportMode"]); model.ImportMode = mode; model.IsSheetNameSelection = true; model.ColumnNames = helper.GetUsableColumnNames(model.FullFilePath, model.SelectedSheetName); return View("XlsCsv", model); } catch (Exception ex) { Log.AppendException(ex); ; ViewBag.Error = LanguageData.GetContent("erreur_obtention_nom_colonne"); } return View("XlsCsv"); }
public ActionResult HandleSheetSelection(ImportO2SModel model) { try { int mode = Convert.ToInt32(Request["ImportMode"]); model.ImportMode = mode; ImportHelper helper = new ImportHelper(); DataTable dt = helper.ReadClientDataTableXLS(model.FullFilePath, model.SelectedSheetName, 20); model.Datashot = dt; model.SheetNames = helper.GetSheetNames(model.FullFilePath); return View("ImportO2Harvest", model); } catch (Exception ex) { Log.AppendException(ex); ViewBag.Error = LanguageData.GetContent("erreur_selection_feuille"); } return View("ImportO2Harvest"); }