private void SaveAsSystemPhrases(ExcelImportEventArgs arg) { ExcelSheet excelSheet = arg.Result; // Extract data from imported Excel sheet List <LanguagePhraseDto> languagePhrases = new List <LanguagePhraseDto>(); for (int index = excelSheet.DataStartRowIndex; index < excelSheet.Rows.Count; index++) { ExcelSheetRow excelRow = excelSheet.Rows[index]; LanguagePhraseDto languagePhrase = new LanguagePhraseDto(); languagePhrases.Add(languagePhrase); languagePhrase.PhraseKey = excelRow.GetValue(Col_Key); languagePhrase.PhraseValue = excelRow.GetValue(Col_Value); } // Save batch using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey)) { LanguageFacade facade = new LanguageFacade(uow); IFacadeUpdateResult <LanguagePhraseData> result = facade.SaveSystemPhrases(SelectedLanguageId, languagePhrases); if (result.IsSuccessful) { arg.IsSuccessful = true; arg.Message = string.Format("Batch save done. \\nTotal {0} rows.", languagePhrases.Count); } else { arg.IsSuccessful = false; // Deal with Update result ProcUpdateResult(result.ValidationResult, result.Exception); } } }
private void PerformSave(ExcelImportEventArgs arg) { ExcelSheet excelSheet = arg.Result; // Extract data from imported Excel sheet List <ProductDto> products = new List <ProductDto>(); for (int index = excelSheet.DataStartRowIndex; index < excelSheet.Rows.Count; index++) { ExcelSheetRow excelRow = excelSheet.Rows[index]; ProductDto product = new ProductDto(); ExtractImportedSheetRow(product, excelRow); product.SupplierId = SupplierId; products.Add(product); } // Save batch using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey)) { ProductFacade facade = new ProductFacade(uow); IFacadeUpdateResult <ProductData> result = facade.SaveProducts(products); if (result.IsSuccessful) { arg.IsSuccessful = true; arg.Message = string.Format("Batch save done. \\nTotal {0} rows.", products.Count); } else { arg.IsSuccessful = false; // Deal with Update result ProcUpdateResult(result.ValidationResult, result.Exception); } } }
private bool SubmitResultSheet() { ExcelImportEventArgs arg = new ExcelImportEventArgs(); if (CurrentSelectedSheet.IsValid) { arg.Result = CurrentSelectedSheet; if (ExcelImported != null) { ExcelImported(this, arg); } AlertMessages(arg.Message); if (!arg.Result.IsValid) { DisplayImportedExcelSheet(arg.Result); } } else { AlertMessages(string.Format("Invalid data found: {0} rows. \\nPlease fix the errors and import again. ", CurrentSelectedSheet.InvalidRowCount)); } return(arg.IsSuccessful); }
private void PerformSave(ExcelImportEventArgs arg) { ExcelSheet excelSheet = arg.Result; // Extract data from imported Excel sheet List <ContactDto> contacts = new List <ContactDto>(); foreach (ExcelSheetRow excelRow in excelSheet.Rows) { ContactDto contact = new ContactDto(); ExtractImportedSheetRow(contact, excelRow); contact.EmployeeId = CurrentUserContext.User.MatchId; contacts.Add(contact); } // Save batch using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey)) { ContactFacade facade = new ContactFacade(uow); IFacadeUpdateResult <ContactData> result = facade.SaveContacts(contacts); if (result.IsSuccessful) { arg.Message = string.Format("Batch save done. \\nTotal {0} rows.", contacts.Count); } else { // Deal with Update result ProcUpdateResult(result.ValidationResult, result.Exception); } } }
protected void ucExcelImport_ExcelImported(object sender, ExcelImportEventArgs e) { if (IsDataPhrase) { SaveAsDataPhrases(e); } else { SaveAsSystemPhrases(e); } }
protected void ucExcelImport_ExcelImported(object sender, ExcelImportEventArgs e) { PerformSave(e); }