public ActionResult DeskLogin(string returnUrl) { ViewBag.ReturnUrl = returnUrl; ViewData["Version"] = AppConfig.Version; //从调度台登陆 string name = Request.QueryString["Name"]; //登录名或者TPerson人员编码 string pwd = Request.QueryString["passWord"]; //密码 if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(pwd)) { BLL.Organize.Worker bllWorker = new BLL.Organize.Worker(); B_WORKER worker = bllWorker.DeskLogin(name, pwd); if (worker != null) { FormsAuthentication.SetAuthCookie(worker.ID.ToString() + "|" + worker.Name + "|" + name, true); if (Regex.IsMatch(pwd, CodeRule.Replace("/", ""))) { return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("ChangePassword", "Home")); } } } return(View()); }
public ActionResult WorkerEdit(string workerId) { BLL.Organize.Worker worker = new BLL.Organize.Worker(); if (string.IsNullOrEmpty(workerId)) { B_WORKER wo = worker.GetWorkerById(null); ViewData["workerId"] = wo.ID; ViewData["entity"] = wo; ViewData["title"] = null; ViewData["IsQuota"] = null; this.ViewData["type"] = "add"; } else { int intWorkerId = int.Parse(workerId); //去掉"Worker-"前缀 B_WORKER wo = worker.GetWorkerById(intWorkerId); ViewData["entity"] = wo; ViewData["workerId"] = intWorkerId; ViewData["title"] = wo.TitleTechnicalID; ViewData["JobLevel"] = wo.JobLevel; ViewData["IsQuota"] = wo.IsQuota; this.ViewData["type"] = "update"; } ViewData["display"] = AppConfig.GetStringConfigValue("WorkerExtendedAttribute") == "N" ? "display: none" : ""; return(View()); }
//public ActionResult WorkerPersonnel() //{ // var result = CommonData.GetDataByType("Personnel"); // return Json(result); //} //public ActionResult WorkerPost() //{ // BLL.Organize.Position position = new BLL.Organize.Position(); // var result = position.LoadAllPost(); // return Json(result); //} public ActionResult WorkerSave(B_WORKER entity) { entity.Sex = Request.Form["sex"]; //entity.IsQuota = Request.Form["quota"]; entity.IsActive = Request.Form["active"]; entity.IsAllowInternetAccess = Request.Form["isAllowInternetAccess"]; entity.LoginName = entity.Name; BLL.Organize.Worker worker = new BLL.Organize.Worker(); if (ModelState.IsValid) { entity.ID = worker.Save(entity); if (entity.ID > 0) { return(Json(new { IsSuccess = true, WorkerId = entity.ID, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, WorkerId = entity.ID, Message = "保存失败" }, "text/html", JsonRequestBehavior.AllowGet)); } } return(View()); }
public B_WORKER Login(string loginName, string passWord) { IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; HashEncrypt he = new HashEncrypt(); //解密前台DES加密的密码 //loginName = he.DESDecrypt(loginName, "", ""); //passWord = he.DESDecrypt(passWord, "", ""); B_WORKER entity = DAL.Organize.Worker.Login(loginName); if (entity == null) { return(null); } //根据后台配置加密密码 string temp = encrypt.Encrypt(entity.ID, passWord); if (entity.PassWord == temp) { return(entity); } else { return(null); } }
public static void SendSms(object sender, ApproveEventArgs args) { ISMS sms = ctx["SMS"] as ISMS; IWorker worker = ctx["Worker"] as IWorker; //string title = string.Format("{0}(表单号:{1})被否决", args.FlowName, args.FlowNo); string content = string.Format("您于{0}申请的{1}(表单号:{2})已经被否决。", args.BeginDate.ToString("yyyy/MM/dd HH:mm"), args.FlowName, args.FlowNo); B_WORKER w = worker.GetWorkerById(args.ApplyerId); if (w != null && !string.IsNullOrEmpty(w.Mobile)) { sms.SendSMG(new List <string> { w.Mobile }, content, "99999"); //if (!innerCommBLL.SendSMG(new List<string> { w.Mobile }, content, "99999")) //{ // throw new Exception(string.Format("短信发送失败,flowId{0},flowNo{1},AppValue{2}", args.FlowId, args.FlowNo, args.AppValue)); //} } }
public static string GetTelByWorkerID(int id) { using (MainDataContext dbContext = new MainDataContext()) { B_WORKER entity = dbContext.B_WORKER.FirstOrDefault(t => t.ID == id); string tel = entity.Mobile; return(tel); } }
public B_WORKER GetWorkerById(int?userId) { //IApplicationContext ctx = ContextRegistry.GetContext(); //IPrimaryKeyCreater prikey = ctx["PrimaryKeyCreater"] as IPrimaryKeyCreater; B_WORKER entity = DAL.Organize.Worker.GetWorkerById(userId); //if (entity.ID == 0) //{ // entity.ID = prikey.getIntPrimaryKey("B_WORKER"); //} return(entity); }
//判断登录名是否已经存在 public ActionResult IsExistName(string name, int workerId) { BLL.Organize.Worker worker = new BLL.Organize.Worker(); B_WORKER result = worker.GetAllWorker().FirstOrDefault(t => t.Name == name && t.ID != workerId); if (result == null) { return(Json(new { IsSuccess = false })); } else { return(Json(new { IsSuccess = true })); } }
/// <summary> /// 调度台或者回访程序登录 /// </summary> /// <param name="loginName">TPerson编码</param> /// <param name="passWord"></param> /// <returns></returns> public static B_WORKER DeskLogin(string loginName) { using (MainDataContext dbContext = new MainDataContext()) { try { B_WORKER entity = (from w in dbContext.B_WORKER join o in dbContext.B_WORKER_ROLE on w.ID equals o.WorkerID into workerRole from o in workerRole.DefaultIfEmpty() where w.IsActive == "Y" && o.TPerson编码 == loginName select w).FirstOrDefault();; return(entity); } catch (Exception e) { Log4Net.LogError("Anchor.FA.DAL.Organize/Login()", e.Message); return(null); } } }
/// <summary> /// 调度台或者回访程序登录 /// </summary> /// <param name="loginName">TPerson编码</param> /// <param name="passWord"></param> /// <returns></returns> public B_WORKER DeskLogin(string loginName, string passWord) { IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; B_WORKER entity = DAL.Organize.Worker.DeskLogin(loginName); if (entity == null) { return(null); } string temp = encrypt.Encrypt(entity.ID, passWord); if (entity.PassWord == temp) { return(entity); } else { return(null); } }
public static bool UpdatePassword(int workerId, string newPassword) { using (MainDataContext dbContext = new MainDataContext()) { using (MainDataContext dsContext = new MainDataContext(AppConfig.ConnectionStringDispatch)) { IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; B_WORKER worker = dbContext.B_WORKER.FirstOrDefault(v => v.ID == workerId); if (worker != null) { worker.PassWord = encrypt.Encrypt(workerId, newPassword); List <B_WORKER_ROLE> listWR = dbContext.B_WORKER_ROLE.Where(t => t.WorkerID == workerId).ToList(); foreach (B_WORKER_ROLE wr in listWR) { if (!string.IsNullOrEmpty(wr.EmpNo)) { TPerson tp = dsContext.TPerson.SingleOrDefault(t => t.工号 == wr.EmpNo); if (tp != null) { tp.口令 = new HashEncrypt().Encrypt(workerId, newPassword);; } } } } dbContext.SubmitChanges(); dsContext.SubmitChanges(); return(true); } } }
public static B_WORKER GetWorkerById(int?id) { using (MainDataContext dbContext = new MainDataContext()) { B_WORKER entity = null; if (id != null) { entity = dbContext.B_WORKER.FirstOrDefault(t => t.ID == id); } entity = entity ?? new B_WORKER { ID = Anchor.FA.Utility.PrimaryKeyUtility.GetID("B_WORKER"), EntryDate = DateTime.Now, LoginName = string.Empty, Name = string.Empty, PassWord = string.Empty, Sex = "1", //IsQuota = "N", IsActive = "Y", IsAllowInternetAccess = "N" }; return(entity); } }
public ActionResult Login(string userName, string passWord, string validateCode) { BLL.Organize.Worker bllWorker = new BLL.Organize.Worker(); BLL.Organize.Action action = new BLL.Organize.Action(); if (ModelState.IsValid) { //检查登录失败次数 if (FailCount >= FailedLogin) { return(Json(new { IsSuccess = false, Message = string.Format("您登录失败{0}次,{1}分钟内不能再登陆!", FailedLogin, NoLoginTime) }, "text/html", JsonRequestBehavior.AllowGet)); } //检查验证码 if (Session["ValidateCode"] != null && validateCode != Session["ValidateCode"].ToString()) { FailCount++; return(Json(new { IsSuccess = false, Message = "验证码错误!" }, "text/html", JsonRequestBehavior.AllowGet)); } //B_WORKER worker = bllWorker.Login(HttpUtility.UrlDecode(userName), HttpUtility.UrlDecode(passWord)); B_WORKER worker = bllWorker.Login(userName, passWord); if (worker != null) { if (FailCount > 0) { FailCount = 0; } //判断登陆者有无权限 List <C_MENU_TREE> isAuth = action.GetMenu("0", worker.ID.ToString()); if (isAuth == null) { return(Json(new { IsSuccess = false, Message = "您没有任何权限,请联系管理员!" })); } //判断是否是Internet访问并且允许此人Internet访问 //bool isInternetAccess = Convert.ToBoolean(ConfigurationManager.AppSettings["IsInternetAccess"]); //if (isInternetAccess && worker.IsAllowInternetAccess.ToUpper() == "N") //{ // return Json(new { IsSuccess = false, Message = "您没有Internet访问权限,请联系管理员!" }, "text/html", JsonRequestBehavior.AllowGet); //} //写登录日志 BLL.Organize.Worker w = new BLL.Organize.Worker(); B_LOGIN_LOG log = new B_LOGIN_LOG(); log.Name = userName; log.IP = Request.UserHostAddress; log.LoginTime = DateTime.Now; w.LoginLog(log); //登录成功,写cookie FormsAuthentication.SetAuthCookie(worker.ID.ToString() + "|" + worker.Name + "|" + userName, true); Session.Remove("ValidateCode"); return(Json(new { IsSuccess = true, Message = "登录成功" }, "text/html", JsonRequestBehavior.AllowGet)); } else { FailCount++; return(Json(new { IsSuccess = false, Message = "账号或密码错误,请联系管理员!" }, "text/html", JsonRequestBehavior.AllowGet)); } } return(View()); }
public static bool SaveWorkerRole(B_WORKER_ROLE entity) { using (MainDataContext dbContext = new MainDataContext()) { using (MainDataContext dsContext = new MainDataContext(AppConfig.ConnectionStringDispatch)) { try { //同步Tperson if (!string.IsNullOrEmpty(entity.EmpNo)) { B_WORKER worker = GetWorkerById(entity.WorkerID); B_ORGANIZATION unit = Organize.GetUnit(entity.OrgID); if (dsContext.TPerson.Count(t => t.编码 == entity.TPerson编码) == 0) { //string empNo = GetCoding(); IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; TPerson person = new TPerson(); person.编码 = entity.TPerson编码; person.单位编码 = unit.Type == (int)OrgType.Branch ? unit.编码 : "-1"; person.通话号码 = worker.Tel ?? string.Empty; person.短信号码 = worker.Mobile ?? string.Empty; person.分站编码 = unit.Type == (int)OrgType.Station ? unit.编码 : AppConfig.GetStringConfigValue("VirtualCode"); person.类型编码 = entity.RoleID; person.姓名 = worker.Name; person.工号 = entity.EmpNo; person.口令 = new HashEncrypt().DESEncrypt(encrypt.Decrypt(worker.PassWord), ""); person.次操作时间 = DateTime.Now; person.顺序号 = int.Parse(entity.TPerson编码); person.是否有效 = true; dsContext.TPerson.InsertOnSubmit(person); } else { var tp = dsContext.TPerson.FirstOrDefault(t => t.编码 == entity.TPerson编码); tp.单位编码 = unit.Type == (int)OrgType.Branch ? unit.编码 : "-1"; tp.分站编码 = unit.Type == (int)OrgType.Station ? unit.编码 : AppConfig.GetStringConfigValue("VirtualCode"); tp.类型编码 = entity.RoleID; tp.工号 = entity.EmpNo; } } //人员 if (entity.ID == 0) { var list = from a in dbContext.B_WORKER_ROLE select a.ID; long total = list.LongCount(); if (total == 0) { entity.ID = 1; } else { entity.ID = dbContext.B_WORKER_ROLE.Max(a => a.ID) + 1; } entity.EmpNo = entity.EmpNo ?? string.Empty; entity.TPerson编码 = entity.TPerson编码 ?? string.Empty; dbContext.B_WORKER_ROLE.InsertOnSubmit(entity); } else { var model = dbContext.B_WORKER_ROLE.FirstOrDefault(b => b.ID == entity.ID); model.OrgID = entity.OrgID; model.WorkerID = entity.WorkerID; model.RoleID = entity.RoleID; model.EmpNo = entity.EmpNo ?? string.Empty; model.ID = entity.ID; model.TPerson编码 = entity.TPerson编码 ?? string.Empty; } dbContext.SubmitChanges(); dsContext.SubmitChanges(); return(true); } catch (Exception ex) { Log4Net.LogError("SaveWorkerRole", ex.ToString()); return(false); } } } }
//public static List<C_ORGANIZE_TREE> GetWorkerTree(int id) //{ // using (MainDataContext dbContext = new MainDataContext()) // { // List<C_ORGANIZE_TREE> listTree = new List<C_ORGANIZE_TREE>(); // var list = from ra in dbContext.B_WORKER_ORGANIZATION // join r in dbContext.B_WORKER on ra.WorkerID equals r.ID // where ra.OrgID == id // select new // { // OrgID = ra.OrgID, // WorkerID = ra.WorkerID, // WorkerName = r.Name, // }; // foreach (var td in list) // { // C_ORGANIZE_TREE lw = new C_ORGANIZE_TREE(); // lw.id = td.WorkerID.ToString(); // lw.text = td.WorkerName; // lw.ParentID = td.OrgID.ToString(); // listTree.Add(lw); // } // return listTree; // } //} public static int Save(B_WORKER entity) { using (MainDataContext dbContext = new MainDataContext()) { using (MainDataContext dsContext = new MainDataContext(AppConfig.ConnectionStringDispatch)) { StringBuilder sb = new StringBuilder(); List <SqlParameter> paramArray = new List <SqlParameter>(); try { //人员 if (dbContext.B_WORKER.Count(t => t.ID == entity.ID) == 0) { //var list = from a in dbContext.B_WORKER select a.ID; //long total = list.LongCount(); //if (total == 0) //{ // entity.ID = 1; //} //else //{ // entity.ID = dbContext.B_WORKER.Max(a => a.ID) + 1; //} IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; entity.PassWord = encrypt.Encrypt(entity.ID, entity.PassWord); dbContext.B_WORKER.InsertOnSubmit(entity); } else { B_WORKER worker = dbContext.B_WORKER.Single(t => t.ID == entity.ID); worker.LoginName = entity.LoginName; worker.Name = entity.Name; worker.Sex = entity.Sex; worker.EntryDate = entity.EntryDate; worker.TitleTechnicalID = entity.TitleTechnicalID; worker.IsActive = entity.IsActive; worker.IsQuota = entity.IsQuota; worker.Mobile = entity.Mobile; worker.Tel = entity.Tel; worker.IsAllowInternetAccess = entity.IsAllowInternetAccess; worker.JobLevel = entity.JobLevel; } //调度台TPerson List <B_WORKER_ROLE> listWorkerRole = dbContext.B_WORKER_ROLE.Where(t => t.WorkerID == entity.ID && t.EmpNo != null && t.EmpNo != "").ToList(); foreach (B_WORKER_ROLE workerRole in listWorkerRole) { TPerson person = dsContext.TPerson.FirstOrDefault(t => t.工号 == workerRole.EmpNo); person.通话号码 = entity.Tel ?? string.Empty; person.短信号码 = entity.Mobile ?? string.Empty; person.是否有效 = entity.IsActive == "Y" ? true : false; person.姓名 = entity.Name; } dbContext.SubmitChanges(); dsContext.SubmitChanges(); return(entity.ID); } catch (Exception ex) { Log4Net.LogError("Save Worker", ex.Message); return(-1); } } } }
public int Save(B_WORKER entity) { return(DAL.Organize.Worker.Save(entity)); }