public ActionResult AutoImport() { CheckUserRole(false); AutoImportModel model = new AutoImportModel(); AdminBl.AutoImport(model); return View(model); }
public ActionResult AutoExport(string month) { CheckUserRole(false); AutoImportModel model = new AutoImportModel(); if (!ParseMonth(model, month)) return View(model); AdminBl.AutoExport(model); return View(model); }
public void AutoExport(AutoImportModel model) { model.Result = ExportFileInternal(model); model.ExportMonth = GetMonth(model.Month); }
public void AutoImport(AutoImportModel model) { model.Result = ImportFileInternal(model); }
public bool ParseMonth(AutoImportModel model,string month) { if(string.IsNullOrEmpty(month)) { model.Error = "Отсутствует месяц выгрузки"; return false; } if(month.Length != 6) { model.Error = "Неправильный месяц выгрузки"; return false; } string strMonth = month.Substring(0, 2); int monthNum; if(!int.TryParse(strMonth,out monthNum)) { model.Error = "Неправильный месяц выгрузки"; return false; } string strYear = month.Substring(2); int year; if (!int.TryParse(strYear, out year)) { model.Error = "Неправильный месяц выгрузки"; return false; } try { DateTime monthDate = new DateTime(year,monthNum,1); model.Month = monthDate; } catch (Exception) { model.Error = "Неправильный месяц выгрузки"; return false; } return true; }