public List <DeptModel> GetDeptTreeView() { try { using (var db = new PORTALEntities()) { var list = (from u in db.HrDeptMasters where u.Parent == null from mm in db.HrDeptMasters.Where(m => m.Id == u.Parent && m.IsDelete == false).DefaultIfEmpty() select new DeptModel { Id = u.Id.ToString(), EnName = u.EnName, HasChildren = db.HrDeptMasters.Any(m => m.Parent == u.Id), DeptCode = u.Code }).ToList(); return(list.OrderBy(c => c.Code).ToList()); } } catch (Exception ex) { LogHelper.Error("DeptRepository GetDeptTreeView: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public MenuModel GetMenu(string id) { try { using (var db = new PORTALEntities()) { var model = (from u in db.SysMenus where u.ID.ToString() == id from mm in db.SysMenus.Where(m => m.ID == u.ParentID).DefaultIfEmpty() orderby u.Sequence select new MenuModel { ID = u.ID.ToString(), Name = u.Name, Controller = u.Controller, Action = u.Action, Sequence = u.Sequence, ParentID = u.ParentID.ToString(), Param = u.Param, ParentName = mm.Name, Icon = u.Icon, Actived = u.Actived, MasterMenu = u.MasterMenu.ToString() }).FirstOrDefault(); return(model); } } catch (Exception ex) { LogHelper.Error("MenuRepository GetMenu: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public IEnumerable <LogHistoryModel> GetByDeptId(int deptCode) { try { using (var db = new PORTALEntities()) { var list = (from l in db.SP_SYS_GET_LOG_BY_DEPTID(deptCode) select new LogHistoryModel() { UserId = l.UserId, IpAddress = l.IpAddress, LogTime = l.LogTime, DeptName = l.DeptName, PlantName = l.PlantName, OrganizeName = l.OrganizationName, SectionName = l.SectName, Name = l.LocalName }).ToList(); if (list.Count == 0) { return(null); } foreach (var item in list) { item.StringIpAddress = Util.INT2IP(item.IpAddress ?? 0); } return(list); } }catch (Exception ex) { LogHelper.Error("NoticesRepository GetNotices: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public IEnumerable <AttachFileModel> GetAttachment(string moduleId, int masterId) { try { using (var db = new PORTALEntities()) { var list = (from l in db.Attachments where l.ModuleId == new Guid(moduleId) && l.MasterId == masterId select new AttachFileModel() { AttachId = l.AttachId, ModuleId = l.ModuleId, MasterId = l.MasterId, FileName = l.FileName, FilePath = l.FilePath }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("FormTemplateRepository GetAttachmet: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public IEnumerable <MenuTreeViewModel> GetMenuTreeView(string id) { try { using (var db = new PORTALEntities()) { var list = (from u in db.SysMenus where u.ParentID == null && u.MasterMenu.ToString() == id from mm in db.SysMenus.Where(m => m.ID == u.ParentID).DefaultIfEmpty() orderby u.Sequence select new MenuTreeViewModel { Id = u.ID.ToString(), Name = u.Name, HasChildren = db.SysMenus.Any(m => m.ParentID == u.ID), Controller = u.Controller, Action = u.Action, Sequence = u.Sequence, ParentID = u.ParentID.ToString(), Param = u.Param, ParentName = mm.Name }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("MenuRepository GetMenu: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public bool InformationSystemInsert(InformationSystemModel models) { try { if (models == null) { return(false); } using (var db = new PORTALEntities()) { var item = new InformationSystem { MasterId = models.MasterId, System = models.System, Seriousness = models.Seriousness, Explanation = models.Explanation //EmpId = models.EmpIp }; db.InformationSystems.Add(item); db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository InformationSystemInsert Insert: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public List <NetClientPolicyModel> GetInforNetClientPolicy(int masterId) { try { using (var db = new PORTALEntities()) { var list = (from s in db.SP_APPLICATION_NETCLIENTPOLICY_GETDETAIL(masterId) select new NetClientPolicyModel() { Id = s.Id, MasterId = s.MasterId, IsAllowance = s.IsAllowance, IpAddress = s.Ip, AssetNo = s.AssetNo, FromDate = s.FromDate, ToDate = s.ToDate, Reason = s.Reason }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository NetClientPolicy: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(null); } }
public IEnumerable <NoticesModel> GetTop10() { try { using (var db = new PORTALEntities()) { var list = (from l in db.SP_SYS_NOTICES_GET_TOP_10() select new NoticesModel() { Id = l.Id, Subject = l.Subject, AttachFile = l.IsAttachFile, UpdateDate = l.UpdateDate ?? l.CreateDate, UpdateName = l.LocalName, IsSubmit = l.IsSubmit, Reason = l.Reason, SubmitDate = l.ConfirmDate, Active = l.IsAcive }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("NoticesRepository GetTop10: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public bool ApplicationDelete(int id, string userId) { try { using (var db = new PORTALEntities()) { var item = (from d in db.ApplicationMasters where d.Id == id select d).FirstOrDefault(); if (item == null) { return(false); } item.DeleteDate = DateTime.Now; item.DeleteUid = userId; db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository ApplicationDelete: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public IEnumerable <NoticesModel> GetAll(string subject, string userId, string creator, int?id, DateTime?dateFrom, DateTime?dateTo) { try { using (var db = new PORTALEntities()) { var list = (from l in db.SP_SYS_NOTICES_GET(subject, userId, creator, id, dateFrom, dateTo) select new NoticesModel() { Id = l.Id, Subject = l.Subject, Descript = l.Descript, AttachFile = l.IsAttachFile, UpdateUid = l.CreateUid, UpdateDate = l.CreateDate, UpdateName = l.LocalName, Active = l.IsAcive, Writer = l.CreateUid }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("NoticesRepository GetNotices: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public bool DeleteNotices(NoticesModel model) { try { using (var db = new PORTALEntities()) { var item = (from c in db.SysNotices where c.Id == model.Id select c).FirstOrDefault(); if (item == null) { return(false); } item.IsDelete = true; item.DeleteDate = model.UpdateDate; item.DeleteUid = model.UpdateUid; db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("CategoryRepository Update Category: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public bool DeleteFileAttachment(AttachFileModel model) { try { using (var db = new PORTALEntities()) { var item = (from c in db.Attachments where c.AttachId == model.AttachId select c).FirstOrDefault(); db.Attachments.Remove(item); db.SaveChanges(); //return true; } //kiem tra neu khong con file dinh kem nao nua thi cap nhat lai ben formtemplate if (GetList(model.MasterId, model.ModuleId).Any()) return true; using (var db = new PORTALEntities()) { var item = (from c in db.CmsFormTemplates where c.Id == model.MasterId select c).FirstOrDefault(); if(item == null) return false; item.IsAttachFile = false; db.SaveChanges(); return true; } } catch (Exception ex) { LogHelper.Error("FileAttacmentRepository DeleteFileAttachment: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return false; } }
public bool InsertFileAttachment(List<AttachFileModel> model) { try { if (model == null) return false; using (var db = new PORTALEntities()) { foreach (var item in model.Select(attachFileModel => new Models.Attachment() { //AttachId = attachFileModel.AttachId, FileName = attachFileModel.FileName, FilePath = attachFileModel.FilePath, ModuleId = attachFileModel.ModuleId, MasterId = attachFileModel.MasterId })) { db.Attachments.Add(item); db.SaveChanges(); } return true; } } catch (Exception ex) { LogHelper.Error("FileAttacmentRepository Insert AttachmentFile: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return false; } }
public IEnumerable<AttachFileModel> GetList(int masterId, Guid moduleId) { try { using (var db = new PORTALEntities()) { var item = (from l in db.Attachments where l.MasterId == masterId && l.ModuleId == moduleId select new AttachFileModel() { AttachId = l.AttachId, ModuleId = l.ModuleId, MasterId = l.MasterId, FileName = l.FilePath, FilePath = l.FilePath }).ToList(); return item; } } catch (Exception ex) { LogHelper.Error("Attachmentfilereportsitory GetList: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return null; } }
public bool ItEquipmentInsert(List <ItEquipmentModel> models) { try { if (models == null) { return(false); } using (var db = new PORTALEntities()) { foreach (var model in models) { var item = new ItEquipment { MasterId = model.MasterId, ItemName = model.ItemName, OS = model.Operator, Qty = model.Quantity, Version = model.Version, Remark = model.Remark }; db.ItEquipments.Add(item); db.SaveChanges(); } return(true); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository ItEquipment Insert: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public IEnumerable <ApprovalHistoryModel> ApprovalHistoryGetList(string userId, int applicationId) { try { using (var db = new PORTALEntities()) { var list = (from d in db.SP_APPROVAL_HISTORY(userId, applicationId) select new ApprovalHistoryModel() { Id = d.Id, ApprovalLine = d.ApprovalLine, ApprovalLineJson = d.ApprovalLineJson, CreateDate = d.CreateDate, MasterId = d.MasterId, ApplicationMasterName = d.ApplicationMasterName, ApplicationSubject = d.ApplicationSubject, ApplicationId = d.ApplicationId }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository SystemRole Insert: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(null); } }
public InformationSystemModel GetInforInformationSystem(int masterId) { try { using (var db = new PORTALEntities()) { var list = (from s in db.SP_APPLICATION_INFORMATIONSYSTEM_GETDETAIL(masterId) select new InformationSystemModel() { Id = s.ID, MasterId = s.MasterId, System = s.System, SystemName = s.SystemName, Seriousness = s.Seriousness, SeriousName = s.SeriousName, EmpIp = s.EmpId, EmpName = s.EmpName, NumDays = s.NumDays, Solution = s.Solution, Explanation = s.Explanation }).FirstOrDefault(); return(list); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository GetInforInformationSystem: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(null); } }
public IEnumerable <ApprovalLineModel> ApprovalLineGetList(int masterId, int applicationId) { try { using (var db = new PORTALEntities()) { var list = (from s in db.SP_APPLICATION_APPROVAL_GETLIST(masterId, applicationId) select new ApprovalLineModel() { EmpId = s.EmpId, ApproverType = s.ApproverType, ApproverTypeName = s.ApproverTypeName, IsApprove = s.IsApprove, DateApprove = s.DateApprove, Comment = s.Comment, DeptFullName = s.DeptFullName, EmpName = s.EmpName }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository GetInforSystemRole: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(null); } }
public bool InformationSystemUpdateApprove(InformationSystemModel models) { try { if (models == null) { return(false); } using (var db = new PORTALEntities()) { var masterId = models.Id; var list = (from d in db.InformationSystems where d.Id == masterId select d).FirstOrDefault(); list.Solution = models.Solution; list.NumDays = models.NumDays; list.EmpId = models.EmpIp; db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository InformationSystemUpdateApprove: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public List <SystemRoleModel> GetInforSystemRole(int masterId) { try { using (var db = new PORTALEntities()) { var list = (from s in db.SP_APPLICATION_SYSTEMROLE_GETDETAIL(masterId) select new SystemRoleModel() { Id = s.Id, MasterId = s.MasterId, EmpId = s.EmpId, EmpName = s.EmpName, DeptId = s.DeptId, DeptName = s.DeptName, EmpNameSameRole = s.EmpNameSameRole, EmpIdSameRole = s.EmpIdSameRole, Module = s.Module, ModuleName = s.ModuleName, Remark = s.Remark }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository GetInforSystemRole: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(null); } }
public bool ApproveFormTemplate(FormTemplateModel model) { try { using (var db = new PORTALEntities()) { var item = (from c in db.CmsFormTemplates where c.Id == model.Id select c).FirstOrDefault(); if (item == null) { return(false); } item.ApproveDate = model.UpdateDate; item.ApproveUid = model.UpdateUid; item.IsApprove = model.IsApprove; item.Reason = model.Reason; db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("CategoryRepository Update Category: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public bool SystemRoleInsert(List <SystemRoleModel> models) { try { if (models == null) { return(false); } using (var db = new PORTALEntities()) { foreach (var model in models) { var item = new SystemRole { MasterId = model.MasterId, EmpId = model.EmpId, DeptId = model.DeptId, Module = model.Module, EmpIdSameRole = model.EmpIdSameRole, Remark = model.Remark }; db.SystemRoles.Add(item); db.SaveChanges(); } return(true); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository SystemRole Insert: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public bool UpdateMenu(MenuModel model) { try { using (var db = new PORTALEntities()) { var mn = db.SysMenus.FirstOrDefault(m => m.ID.ToString() == model.ID); mn.Name = model.Name; mn.MasterMenu = new Guid(model.MasterMenu); if (model.ParentID != null) { mn.ParentID = new Guid(model.ParentID); } mn.Sequence = model.Sequence; mn.Controller = model.Controller; mn.Action = model.Action; mn.Actived = true; mn.ModifyUID = new Guid(model.ModifyUID); mn.ModifyDate = DateTime.Now; mn.Icon = model.Icon; mn.Param = model.Param; db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("MenuRepository insert: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(false); } }
public List <EmailRequestModel> GetInforEmailRequest(int masterId) { try { using (var db = new PORTALEntities()) { var list = (from s in db.SP_APPLICATION_EMAILREQUEST_GETDETAIL(masterId) select new EmailRequestModel() { Id = s.Id, MasterId = s.MasterId, EmpId = s.EmpId, EmpName = s.EmpName, DeptId = s.DeptId, DeptName = s.DeptName, Request = s.Request, RequestName = s.RequestName, Reason = s.Reason, TimesPerMonth = s.TimesPerMonth }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository GetInforSystemRole: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(null); } }
public IEnumerable <MenuModel> GetActiveMenuViaMasterMenuUser(string id, string role) { if (string.IsNullOrEmpty(id)) { return(null); } try { using (var db = new PORTALEntities()) { var list = (from u in db.SP_GetMenu_Via_MasterMenu_User(id, role) select new MenuModel { ID = u.ID.ToString(), Name = u.Name, Action = u.Action, Controller = u.Controller, Param = u.Param, Icon = u.Icon, ParentID = u.ParentID.ToString(), Sequence = u.Sequence }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("MenuRepository GetActiveMenuViaMasterMenuUser: "******" Inner Exception: " + ex.InnerException.Message); return(null); } }
public bool EmailRequestInsert(List <EmailRequestModel> models) { try { if (models == null) { return(false); } using (var db = new PORTALEntities()) { foreach (var model in models) { var item = new EmailAddress { MasterId = model.MasterId, EmpId = model.EmpId, DeptId = model.DeptId, Request = model.Request, TimesPerMonth = model.TimesPerMonth, Reason = model.Reason }; db.EmailAddresses.Add(item); db.SaveChanges(); } return(true); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository SystemRole Insert: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public bool InsertMenu(MenuModel model) { try { using (var db = new PORTALEntities()) { var mn = new SysMenu { ID = Guid.NewGuid(), Name = model.Name, MasterMenu = new Guid(model.MasterMenu) }; if (model.ParentID != null) { mn.ParentID = new Guid(model.ParentID); } mn.Sequence = model.Sequence; mn.Controller = model.Controller; mn.Action = model.Action; mn.Actived = true; mn.CreateUID = new Guid(model.ModifyUID); mn.CreateDate = DateTime.Now; mn.Icon = model.Icon; mn.Param = model.Param; db.SysMenus.Add(mn); db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("MenuRepository insert: " + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(false); } }
public List <ItEquipmentModel> GetInforItEquipment(int masterId) { try { using (var db = new PORTALEntities()) { var list = (from s in db.SP_APPLICATION_ITEQUIPMENT_GETDETAIL(masterId) select new ItEquipmentModel() { Id = s.Id, MasterId = s.MasterId, ItemName = s.ItemName, Operator = s.OS, Version = s.Version, Quantity = s.Qty, Remark = s.Remark }).ToList(); return(list); } } catch (Exception ex) { LogHelper.Error("ApplicationMasterRepository ItEquipment: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(null); } }
public bool InsertLog(LogHistoryModel model) { try { if (model == null) { return(false); } using (var db = new PORTALEntities()) { var obj = new SysLogHistory { UserId = model.UserId, IpAddress = model.IpAddress, LogTime = DateTime.Now, OperatingSystem = model.OperatingSystem, PcName = model.PcName, PcBrowser = model.PcBrowser, //ControllerName = model.ControllerName, //ActionName = model.ActionName }; db.SysLogHistories.Add(obj); db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("Log Repository Insert Log: " + ex.Message + " Inner exception: " + ex.InnerException.Message); return(false); } }
public UserModel GetUser(string id) { try { using (var db = new PORTALEntities()) { var item = (from u in db.SysUsers from u1 in db.SysUsers.Where(u1 => u1.LoginID == u.CreateUid || u1.LoginID == u.UpdateUid).DefaultIfEmpty() where u.Deleted == false && u.LoginID == id select new UserModel { //ID = u.ID, LoginID = u.LoginID, Password = u.Password, //IMG = u.IMG, Name = u.Name, Email = u.Email, Mobile = u.Mobile, Actived = u.Actived, ModifyDate = u.UpdateDate ?? u.CreateDate, ModifyUID = u.UpdateUid ?? u.CreateUid, ModifyName = u1.Name }).FirstOrDefault(); return(item); } } catch (Exception ex) { LogHelper.Error("UserRepository: GetUser: "******" Exception: " + ex.InnerException.Message); return(null); } }