public bool ExportToDb() { ErrorMessages.Clear(); try { bool IsSucceeded = false; List <T> list = this.ImportFile(ref IsSucceeded); if (IsSucceeded == false) { return(false); } CanonDataContext db = Cdb.Instance; // Create ImportDistributor ImportDistributor importDistributor = new ImportDistributor(); importDistributor.IDDistributor = DistributorId; importDistributor.IDUser = WebVariables.LoggedUserId; importDistributor.FileName = _OriginalFilename; importDistributor.DateImported = DateTime.Now; importDistributor.DateFrom = DateTime.Now; importDistributor.DateTo = importDistributor.DateFrom.AddDays(30); importDistributor.ErrorMessage = string.Empty; importDistributor.Succeeded = true; importDistributor.IsDeleted = false; CanonImportDistributor.InsertImportDistributor(importDistributor); // import Distributor records foreach (T record in list) { try { record.ImportDistributor = importDistributor; record.InsertImportDistributorRecord(); } catch (Exception ex) { //add message about error ErrorMessages.Add(new ImportErrorMessage("GeneralRecordImportError", new string[] { "Reseller", record.ResellerIdentificationNumber + "_" + record.ResellerName })); //into log WebVariables.Logger.Error(string.Format("File {0}, general import error", _filename), ex); } } } catch (Exception ex) { ErrorMessages.Add(new ImportErrorMessage("GeneralFileImportError")); //into log WebVariables.Logger.Error(string.Format("File {0} ", _filename), ex); return(false); } return(true); }
protected void gridDistributors_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { if (e.Parameters != null && e.Parameters.StartsWith("RemoveDistributor")) { string value = e.Parameters.Replace("RemoveDistributor", ""); int ID; if (int.TryParse(value, out ID) == true) { CanonImportDistributor.RemoveImportDistributor(ID); this.BindData(); } } }