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); } } }
// Extract data field by field private void ExtractImportedSheetRow(ProductDto product, ExcelSheetRow excelRow) { product.Name = excelRow.GetValue(Col_Name); product.Description = excelRow.GetValue(Col_Description); product.UnitPrice = Convert.ToDecimal(excelRow.GetValue(Col_UnitPrice)); product.UnitOfMeasure = excelRow.GetValue(Col_UnitOfMeasure); product.Packaging = excelRow.GetValue(Col_Packaging); string categoryId = excelRow.GetValue(Col_CategoryId); if (categoryId != null && categoryId.TrimHasValue()) { product.CategoryId = Convert.ToInt32(excelRow.GetValue(Col_CategoryId)); } }
// Extract data field by field private void ExtractImportedSheetRow(SupplierDto Supplier, ExcelSheetRow excelRow) { Supplier.Name = excelRow.GetValue(Col_Name); Supplier.AddressLine1 = excelRow.GetValue(Col_Address); Supplier.City = excelRow.GetValue(Col_City); Supplier.Country = excelRow.GetValue(Col_Country); Supplier.ZipCode = excelRow.GetValue(Col_ZipCode); Supplier.ContactPerson = excelRow.GetValue(Col_ContactPerson); Supplier.ContactPhone = excelRow.GetValue(Col_ContactPhone); Supplier.ContactFax = excelRow.GetValue(Col_ContactFax); Supplier.ContactEmail = excelRow.GetValue(Col_ContactEmail); Supplier.Website = excelRow.GetValue(Col_Website); string categoryId = excelRow.GetValue(Col_Category); if (categoryId != null && categoryId.TrimHasValue()) { Supplier.CategoryId = Convert.ToInt32(categoryId); } }
// Extract data field by field private void ExtractImportedSheetRow(ContactDto contact, ExcelSheetRow excelRow) { contact.FullName = excelRow.GetValue(Col_FullName); contact.FamilyName = excelRow.GetValue(Col_FamilyName); }