public ActionResult Index(int id) { //lay url tu menu voi id ViewData["pagename"] = "Embed_Tableau"; ViewData["action_block"] = "Tableau/TableauView"; SetCommonData(); GetLanguage(); SetConnectionDB(); BI_Project.Models.UI.PageModel pageModel = new Models.UI.PageModel("Embed_Tableau"); // BI_Project.Models.UI.BlockModel blockModel = new BlockModel("TableauView"); pageModel.SetLanguage(this.LANGUAGE_OBJECT); //pageModel.H1Title = pageModel.GetElementByPath("page_excel.menu" + id + ".h1"); pageModel.Title = pageModel.GetElementByPath("title"); ViewData["page_model"] = pageModel; TableauModel param = new TableauModel(); ViewData["BlockData"] = param; MenuServices _menuServices = new MenuServices(DBConnection); EntityMenuModel _entityMenuModel = _menuServices.GetMenuModel(id.ToString()); UserServices _userServices = new UserServices(DBConnection); DepartmentServices _departmentServices = new DepartmentServices(DBConnection); EntityDepartmentModel _entityDepartmentModel = new EntityDepartmentModel(); //param.Site_Root = _entityMenuModel.Site_Root; param.Ticket = Helpers.TableauHelper.GetTicket(""); param.TableauUrl = _entityMenuModel.TableauUrl; param.Hidden = 1; param.username = Session["UserName"].ToString(); ViewBag.Id = id; var listFilter01 = _departmentServices.GetList().Select(x => x.Filter01).ToArray(); StringBuilder builderOrganization = new StringBuilder(); foreach (var _list in listFilter01) { builderOrganization.Append(_list).Append(','); } string _resultListOrganization = builderOrganization.ToString().TrimEnd(','); ViewBag.ListDepartment = _resultListOrganization; var getUser = _userServices.GetList(); var getUserCheck = getUser.FirstOrDefault(x => x.UserName == param.username); var getDepartment = _departmentServices.GetEntityById(getUserCheck.DeptId); if (getUserCheck.IsAdmin == false && (getDepartment.Filter01 != "PE" || getDepartment.Filter01 != "PA" || getDepartment.Filter01 != "PB" || getDepartment.Filter01 != "PC" || getDepartment.Filter01 != "PD")) { param.GetFilter(id); } //param.GetFilter(id); Random rd = new Random(); int item = rd.Next(100, 999); string log = DateTime.Now.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) + "_" + item; if (_menuServices.ERROR != null) { FileHelper.SaveFile(new { ERROR = _menuServices.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } FileHelper.SaveFile(_entityMenuModel, this.LOG_FOLDER + "/MenuModel_" + log + ".txt"); FileHelper.SaveFile(param.Ticket, this.LOG_FOLDER + "/Ticket_" + log + ".txt"); return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
public ActionResult Create(BlockDataRoleCreateModel model) { this.SaveAccessLog("create"); if (null == Session[this.SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } if (Session["IsAdmin"] == null) { return(RedirectToAction("Logout", "Home")); } this.SetConnectionDB(); RoleServices services = new RoleServices(this.DBConnection); int result = services.Create(model); if (services.ERROR != null) { FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } //*************************************XU LY VAN DE THONG BAO THANH CONG HAY THAT BAI******************** this.GetLanguage(); BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel(); blockLang.BlockName = "block_role_create"; blockLang.SetLanguage(this.LANGUAGE_OBJECT); Session["msg_text"] = blockLang.GetMessage(result); Session["msg_code"] = result; if (model.RoleId > 0 && result > 1) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_role_create.success_edit", this.LANGUAGE_OBJECT); } if (result == 0) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_role_create.error_business_1", this.LANGUAGE_OBJECT); //return RedirectToAction("Create?roleid=" + model.RoleId); } //*********************** INSERT OR EDIT SUCCESSFULLY************************************************** if (result > 0) { return(RedirectToAction("List")); } //************************************************************************* //BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel(); //BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_role_create", this.LANGUAGE_OBJECT, blockLang); //blockModel.DataModel = model; //ViewData["BlockData"] = blockModel; //return View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"); TempData["data"] = model; return(RedirectToAction("Create")); }
public ActionResult Create(int?roleId) { this.SaveAccessLog("create"); if (null == Session[this.SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } this.SetCommonData(); ViewData["pagename"] = "role_create"; ViewData["action_block"] = "Roles/block_role_create"; ViewData["data-form"] = TempData["data"]; string roleid = (Request.QueryString["roleid"] == null ? "0" : Request.QueryString["roleid"].ToString()); this.SetConnectionDB(); RoleServices services = new RoleServices(this.DBConnection); BlockDataRoleCreateModel model = new BlockDataRoleCreateModel(); if (ViewData["data-form"] != null) { model = (BlockDataRoleCreateModel)ViewData["data-form"]; } else { model = services.GetEntityById(Int32.Parse(roleid)); } //BlockDataRoleCreateModel model = services.GetEntityById(Int32.Parse(roleid)); this.GetLanguage(); if (model.RoleId > 0) { ViewData["pagename"] = "role_edit"; } Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection); ViewData["departments"] = departmentServices.GetList(); ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]); if (services.ERROR != null) { FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_role_create", this.LANGUAGE_OBJECT, blockLang); blockModel.DataModel = model; ViewData["BlockData"] = blockModel; ViewData["CurrentRoleId"] = roleId; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
public ActionResult Index(string id, BlockDataExcelUploadModel uiModel) { int noPages = 0, noRecords = 0; try { uiModel.CurrentPage = Int32.Parse(Request.Params["page"]); } catch (Exception) { uiModel.CurrentPage = 1; } this.CheckPermission(); ViewData["pagename"] = "upload_excel"; ViewData["action_block"] = "Excels/block_upload_excel"; this.SetCommonData(); this.GetLanguage(); //DECLARE PAGE MODEL BI_Project.Models.UI.PageModel pageModel = new Models.UI.PageModel("upload_excel"); pageModel.SetLanguage(this.LANGUAGE_OBJECT); pageModel.H1Title = pageModel.GetElementByPath("page_excel.menu" + id + ".h1"); pageModel.Title = pageModel.GetElementByPath("page_excel.menu" + id + ".title"); ViewData["page_model"] = pageModel; BlockLangExcelUpload blockLang = new BlockLangExcelUpload(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_upload_excel", this.LANGUAGE_OBJECT, blockLang); //BlockDataExcelUploadModel blockData = new BlockDataExcelUploadModel(); uiModel.PermissionID = id; ImporterServices services = new ImporterServices(this.DBConnection); string xmlConfigFilePath = this.CONFIG_FOLDER + "\\excel_format_" + uiModel.PermissionID.ToString() + ".xml"; uiModel.HelpDoc = BI_Project.Helpers.Utility.JTokenHelper.GetElementValue(xmlConfigFilePath, "excel_source.HelpDocumentPath"); uiModel.ListHistory = services.GetHistoryList(uiModel.CurrentPage, uiModel.PerPage, id, ref noPages, ref noRecords, uiModel.Month, uiModel.Year); uiModel.NumberPages = noPages; uiModel.NumberRecords = noPages; uiModel.CurrentPage = uiModel.CurrentPage; uiModel.FolderUpload = pageModel.GetElementByPath("page_excel.menu" + id + ".UploadedDirectory"); blockModel.DataModel = uiModel; //blockModel.DataModel = ViewData["block_menu_left_data"]; if (services.ERROR != null) { FileHelper.SaveFile(services.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } ViewData["BlockData"] = blockModel; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
public ActionResult Delete() { this.SaveAccessLog("delete"); if (Session["IsAdmin"] == null) { return(RedirectToAction("Logout", "Home")); } string id = this.HttpContext.Request["roleid"]; int output = 0; try { this.SetConnectionDB(); RoleServices services = new RoleServices(this.DBConnection); if (services.ERROR != null) { throw new Exception(services.ERROR); } output = services.Delete(Int32.Parse(id)); } catch (Exception ex) { FileHelper.SaveFile(new { data = id, ERROR = ex }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); output = -2; } //*************************************XU LY VAN DE THONG BAO THANH CONG HAY THAT BAI******************** this.GetLanguage(); BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel(); blockLang.BlockName = "block_role_list"; blockLang.SetLanguage(this.LANGUAGE_OBJECT); Session["msg_code"] = output; if (output > 1) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_role_list.success_delete", this.LANGUAGE_OBJECT); } return(RedirectToAction("List")); }
public ActionResult ChangePassword(BlockDataUserChangepwModel model) { Logging.WriteToLog(this.GetType().ToString() + "-changepw-submit()", LogType.Access); if (Session[this.SESSION_NAME_USERID] == null) { return(RedirectToAction("Logout", "Home")); } this.SetCommonData(); this.GetLanguage(); BlockLangUserChangepwModel blockLang = new BlockLangUserChangepwModel(); if (model.ConfirmPassword != model.Password) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_user_changepw.not_equalto", this.LANGUAGE_OBJECT); Session["msg_code"] = 0; return(RedirectToAction("ChangePassword")); } //Session["msg_code"] = output; this.SetConnectionDB(); UserServices services = new UserServices(this.DBConnection); model.UserId = (int)Session[this.SESSION_NAME_USERID]; int output = services.ChangePw(model); this.ERRORS = services.ERROR; if (services.ERROR != null) { FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } if (output == model.UserId) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_user_changepw.success", this.LANGUAGE_OBJECT); Session["msg_code"] = 1; } else { Session["msg_text"] = blockLang.GetLangByPath("messages.block_user_changepw.not_exist_user", this.LANGUAGE_OBJECT); Session["msg_code"] = 0; } return(RedirectToAction("ChangePassword")); }
public ActionResult Import(FileUploadModel model) { this.GetLanguage(); //DECLARE PAGE MODEL try { //************************** CHECK PERMISSION ************************** this.SetConnectionDB(); //var test = model.FileObj; //************************** GET CONFIG ImporterServices services = new ImporterServices(this.DBConnection, this.CONNECT_STRING_STAGING); string tablename = "", sheetActive = "", uploadFolder = "", fileNativeName = ""; string note = "", helpDocumentPath = ""; int startRow = 0, numberRow = 0, numberCell = 0; List <string> lstCellName = new List <string>(); string xmlFilePath = this.CONFIG_FOLDER + "\\excel_format_" + model.PermissionId.ToString() + ".xml"; List <MappingExcelDB> lstColumns = services.GetColumnList(xmlFilePath, ref uploadFolder, ref tablename, ref startRow, ref sheetActive, ref helpDocumentPath, ref note, ref fileNativeName, ref numberRow, ref numberCell, ref lstCellName); //************************** UPLOAD FILE TO THE UPLOAD FOLDER*********************************************** string excelfilename = BI_Project.Helpers.Utility.APIStringHelper.GenerateId() + Path.GetExtension(model.FileObj.FileName); string excelFilePath = System.Web.Hosting.HostingEnvironment.MapPath(this.EXCEL_UPLOAD_FOLDER) + uploadFolder + "/" + excelfilename; model.FileObj.SaveAs(excelFilePath); //************************ INSERT DATA TO DATABASE ******************** int userid = (int)Session[this.SESSION_NAME_USERID]; int uploadRoleId = model.PermissionId; //services.Import2Database(userid,excelFilePath, tablename, startRow, sheetActive,helpDocumentPath, // note,fileNativeName,fileNativeName,uploadRoleId, lstColumns,excelfilename); services.Import2Database(userid, excelFilePath, tablename, startRow, sheetActive, helpDocumentPath, note, fileNativeName, fileNativeName, uploadRoleId, lstColumns, excelfilename, numberRow, numberCell, lstCellName); if (services.ERROR != null) { throw new Exception(services.ERROR); } Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_upload_excel.success"); Session["msg_code"] = 1; } catch (Exception ex) { FileHelper.SaveFile(new { ERROR = ex }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_upload_excel.error"); Session["msg_code"] = -1; } return(RedirectToAction("Index/" + model.PermissionId)); }
public ActionResult List() { if (Session["IsAdmin"] == null || (bool)Session["IsAdmin"] == false) { return(RedirectToAction("Logout", "Home")); } this.SetCommonData(); ViewData["pagename"] = "user_list"; ViewData["action_block"] = "Users/block_user_list"; this.GetLanguage(); this.SetConnectionDB(); UserServices services = new UserServices(this.DBConnection); BlockLangUserListModel blockLang = new BlockLangUserListModel(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_user_list", this.LANGUAGE_OBJECT, blockLang); //Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection); //ViewData["departments"] = departmentServices.GetList(); if ((bool)Session["IsSuperAdmin"]) { blockModel.DataModel = services.GetList(); } else if ((bool)Session["IsAdmin"]) { blockModel.DataModel = services.GetList((int)Session["DepartIdUserLogin"]); } if (services.ERROR != null) { FileHelper.SaveFile(services.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } Logging.WriteToLog(this.GetType().ToString() + "-List()", LogType.Access); ViewData["BlockData"] = blockModel; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
public ActionResult Create(BlockDataUserCreateModel model) { Logging.WriteToLog(this.GetType().ToString() + "-create()", LogType.Access); if (null == Session[this.SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } if (Session["IsAdmin"] == null || (bool)Session["IsAdmin"] == false) { return(RedirectToAction("Logout", "Home")); } ViewData["data_form"] = TempData["data"]; // get language this.GetLanguage(); // validate du lieu if (!string.IsNullOrEmpty(model.Email)) { string emailRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; Regex re = new Regex(emailRegex); if (!re.IsMatch(model.Email)) { ModelState.AddModelError("Email", "Email is not valid"); Session["msg_code"] = -1; Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.error_email"); TempData["data"] = model; return(RedirectToAction("Create")); } } if (model.Password != model.ConfirmPassword) { Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.error_password"); TempData["data"] = model; return(RedirectToAction("Create")); } if (!string.IsNullOrEmpty(model.Phone)) { string phoneRegex = @"^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$"; Regex re = new Regex(phoneRegex); if (!re.IsMatch(model.Phone)) { ModelState.AddModelError("Phone", "Phone is not valid"); Session["msg_code"] = -1; Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.error_phone"); TempData["data"] = model; return(RedirectToAction("Create")); } } //if (model.LstSelectedRole.Count() == 0) //{ // ModelState.AddModelError("ListRoles", "Role is not valid"); // Session["msg_code"] = -1; // Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.error_Role"); // TempData["data"] = model; // return RedirectToAction("Create"); //} //**************** DATABASE PROCESS******************************************************* this.SetConnectionDB(); UserServices services = new UserServices(this.DBConnection); // check tài khoản đã tồn tại trong hệ thống hay chưa var checkUser = services.GetList(); EntityUserModel Usercheck = new EntityUserModel(); if (model.IsSuperAdmin == true) { var User = checkUser.FirstOrDefault(x => x.UserName == model.UserName && x.UserId != model.UserId); Usercheck = User; } else { var CodeUser = services.GetCodeByDeptId(model.DeptId); var User = checkUser.FirstOrDefault(x => x.UserName == model.UserName && x.UserId != model.UserId && (x.DeptId == model.DeptId || x.Code == CodeUser)); Usercheck = User; } if (Usercheck != null) { Session["msg_code"] = -1; Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.error_User"); TempData["data"] = model; return(RedirectToAction("Create")); } int result = services.Create(model); if (services.ERROR != null) { FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } //**************** GET LANGUAGE AND MESSAGE****************************************************************** //this.GetLanguage(); if (result > 0) { Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.success"); } else { Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.error_business_1"); } Session["msg_code"] = result; if (model.UserId > 0 && result > 1) { Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_create.success_edit"); } //***********************INSERT OR EDIT SUCCESSFULLY * ************************************************* if (result > 0) { return(RedirectToAction("List")); } TempData["data"] = model; //ViewBag.User = model; //this.SetCommonData(); //BlockLangUserCreateModel blockLang = new BlockLangUserCreateModel(); //BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_user_create", this.LANGUAGE_OBJECT, blockLang); //blockModel.DataModel = model; //ViewData["BlockData"] = blockModel; //ViewData["action_block"] = "Users/block_user_create"; return(RedirectToAction("Create")); //return View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"); //************************************************************************* //BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel(); //BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_role_create", this.LANGUAGE_OBJECT, blockLang); //blockModel.DataModel = model; //ViewData["BlockData"] = blockModel; //return View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"); //return RedirectToAction("Create?roleid="+model.RoleId); }
public ActionResult Delete() { string id = this.HttpContext.Request["id"]; Logging.WriteToLog(this.GetType().ToString() + "-delete(), id=" + id, LogType.Access); int output = 0; try { this.SetConnectionDB(); UserServices services = new UserServices(this.DBConnection); output = services.Delete(Int32.Parse(id)); if (services.ERROR != null) { throw new Exception(services.ERROR); } } catch (Exception ex) { this.ERRORS = ex.ToString(); FileHelper.SaveFile(ex, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); output = -2; } ////*************************************XU LY VAN DE THONG BAO THANH CONG HAY THAT BAI******************** this.GetLanguage(); if (output > 0) { Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_user_list.success_delete"); } else { Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "commons.messages.ServerError"); } Session["msg_code"] = output; return(RedirectToAction("List")); }
public ActionResult Delete() { if (Session["IsAdmin"] is false) { return(RedirectToAction("Logout", "Home")); } string id = this.HttpContext.Request["treeId"]; string fileName = this.HttpContext.Request["fileUpload"]; Logging.WriteToLog(this.GetType().ToString() + "-delete(), id=" + id + ", file name = " + fileName, LogType.Access); int output = 0; try { this.SetConnectionDB(); EVNImporterServices services = new EVNImporterServices(oracleConnection, DBConnection); int userid = (int)Session[this.SESSION_NAME_USERID]; output = services.Delete(fileName, userid); if (services.ERROR != null) { throw new Exception(services.ERROR); } } catch (Exception ex) { this.ERRORS = ex.ToString(); FileHelper.SaveFile(ex, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); output = -2; } ////*************************************XU LY VAN DE THONG BAO THANH CONG HAY THAT BAI******************** this.GetLanguage(); return(RedirectToAction("Index/" + id)); }
public ActionResult Create() { this.SaveAccessLog("create"); if (null == Session[this.SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } this.SetCommonData(); ViewData["pagename"] = "department_create"; ViewData["action_block"] = "Departments/block_department_create"; ViewData["data-form"] = TempData["data"]; string departId = (Request.QueryString["departid"] == null ? "0" : Request.QueryString["departid"].ToString()); this.SetConnectionDB(); DepartmentServices services = new DepartmentServices(this.DBConnection); EntityDepartmentModel model = new EntityDepartmentModel(); if (ViewData["data-form"] != null) { model = (EntityDepartmentModel)ViewData["data-form"]; } else { model = services.GetEntityById(Int32.Parse(departId)); } //EntityDepartmentModel modelResponse = services.GetEntityById(Int32.Parse(departId)); this.GetLanguage(); if (model.DepartId > 0) { ViewData["pagename"] = "department_edit"; } if (services.ERROR != null) { FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } BlockDepartmentCreateLangModel blockLang = new BlockDepartmentCreateLangModel(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_department_create", this.LANGUAGE_OBJECT, blockLang); blockModel.DataModel = model; ViewData["BlockData"] = blockModel; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
public ActionResult List() { if (null == Session[this.SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } if (Session["IsAdmin"] == null) { return(RedirectToAction("Logout", "Home")); } this.SetCommonData(); ViewData["pagename"] = "department_list"; ViewData["action_block"] = "Departments/block_department_list"; this.GetLanguage(); this.SetConnectionDB(); DepartmentServices services = new DepartmentServices(this.DBConnection); BlockDepartmentListLangModel blockLang = new BlockDepartmentListLangModel(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_department_list", this.LANGUAGE_OBJECT, blockLang); //blockModel.DataModel = ViewData["block_menu_left_data"]; if ((bool)Session["IsSuperAdmin"]) { ViewData["departments"] = services.GetList(); } else if ((bool)Session["IsAdmin"]) { ViewData["listdepartmentsadmin"] = services.GetListAdminLogin((string)Session["CodeIsAdmin"]); } blockModel.DataModel = services.GetList(); blockModel.Hidden = 0; if (services.ERROR != null) { FileHelper.SaveFile(services.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } this.SaveAccessLog("list"); ViewData["BlockData"] = blockModel; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
public async Task <FileResult> ExportPLExcel(FileUploadModel uploadModel) { var memory = new MemoryStream(); string xmlFilePath = this.CONFIG_FOLDER + "\\excel_export_format.xml"; string id = uploadModel.PermissionId.ToString(); ExcelHelper excelHelper = new ExcelHelper(); ExcelXmlModel model = excelHelper.GetUploadExcelXMLConfig(xmlFilePath, id); try { /**************************************EXPORT EXCEL OFFLINE***************************************/ if (Convert.ToBoolean(uploadModel.ExportOff) == true) { //Get last time write file string path = System.Web.Hosting.HostingEnvironment.MapPath(this.EXCEL_EXPORT_FOLDER) + model.ExcelXmlCommon.exportDirectory; string fileName = excelHelper.GetNewFile(path); if (fileName == null) { throw new Exception(); } string filePath = path + "\\" + fileName; using (var stream = new FileStream(filePath, FileMode.Open)) { await stream.CopyToAsync(memory); } memory.Position = 0; } /**************************************EXPORT EXCEL ONLINE***************************************/ else { this.SetConnectionDB(); EVNImporterServices services = new EVNImporterServices(this.oracleConnection, this.DBConnection); this.oracleConnection.OpenDBConnect(); string filePath = System.Web.Hosting.HostingEnvironment.MapPath(this.EXCEL_EXPORT_FOLDER) + model.ExcelXmlCommon.exportDirectory + "//" + model.ExcelXmlCommon.ExcelFileName + "_" + APIStringHelper.GenerateId() + ".xlsx"; memory = services.ExportExcelWithConfigReport(id, filePath, model); this.oracleConnection.CloseDBConnect(); } } catch (Exception ex) { this.ERRORS = ex.ToString(); } return(File(memory.ToArray(), "application/vnd.ms-excel", model.ExcelXmlCommon.ExcelFileName + ".xlsx")); }