public bool InsertOperLog(CMSMStruct.OperStruct OperNew) { int recount = opa.InsertOperLog(OperNew); if (recount <= 0) { return(false); } return(true); }
public int InsertOperLog(CMSMStruct.OperStruct OperNew) { string sql1 = "insert into tbOperLog values('登录中心','" + OperNew.strOperID + "','" + OperNew.strDeptID + "',getdate(),'" + OperNew.strMacAddress + "')"; int recount = SqlHelper.ExecuteNonQuery(con, CommandType.Text, sql1); if (con.State == ConnectionState.Open) { con.Close(); } return(recount); }
protected void Button1_Click(object sender, System.EventArgs e) { string strLoginid = this.txtLoginID.Text.Trim(); if (strLoginid == "admin" || strLoginid == "orange") { string strpwd = this.txtPwd.Text.Trim(); if (strLoginid == "" || strpwd == "") { this.SetErrorMsgPage("请输入用户名和密码!"); } else { Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; Manager m1 = new Manager(strcons); CMSMStruct.LoginStruct ls1 = m1.GetLoginInfo(strLoginid); if (ls1 == null) { this.SetErrorMsgPage("对不起,用户不存在!"); Session["Login"] = null; } else { if (ls1.strPwd != strpwd) { this.SetErrorMsgPage("对不起,密码不正确!"); } else { DataTable dtDeptMap = (DataTable)Application["DeptMapInfo"]; foreach (DataRow dr in dtDeptMap.Rows) { if (dr["cnvcOldDeptID"].ToString() == ls1.strDeptID) { ls1.strNewDeptID = dr["cnvcNewDeptID"].ToString(); break; } } CMSMStruct.OperStruct OperNew = new CMSMStruct.OperStruct(); OperNew.strDeptID = ls1.strDeptID; OperNew.strOperID = ls1.strLoginID; OperNew.strMacAddress = this.Request.Form["txtMACAddr"].ToString(); m1.InsertOperLog(OperNew); Session["Login"] = ls1; //Session["tbNotice"] = Helper.Query("select cnnNoticeID,cnvcComments,Convert(varchar(10),cndReleaseDate,21) as cndReleaseDate from tbNotice where cnvcIsActive ='1'"); Response.Redirect("wfmMain.aspx", false); } } } } else { try { DataTable dtMac = (DataTable)Application["MAC"]; if (dtMac == null || dtMac.Rows.Count == 0) { Response.Redirect("sorry.htm"); return; } else { string strmac = this.Request.Form["txtMACAddr"].ToString(); AMSLog clog = new AMSLog(); clog.WriteLine("LoginID:" + strLoginid + "; Mac:" + strmac + ";"); if (strmac == "") { Response.Redirect("sorry.htm"); return; } else { bool okflag = false; if (strLoginid == "admin") { okflag = true; } else { for (int i = 0; i < dtMac.Rows.Count; i++) { if (dtMac.Rows[i][0].ToString() == strmac) { okflag = true; break; } } } if (!okflag) { Response.Redirect("nopromexplor.htm"); return; } else { // string strLoginid=this.txtLoginID.Text.Trim(); string strpwd = this.txtPwd.Text.Trim(); if (strLoginid == "" || strpwd == "") { this.SetErrorMsgPage("请输入用户名和密码!"); } else { Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; Manager m1 = new Manager(strcons); CMSMStruct.LoginStruct ls1 = m1.GetLoginInfo(strLoginid); if (ls1 == null) { this.SetErrorMsgPage("对不起,用户不存在!"); Session["Login"] = null; } else { if (ls1.strPwd != strpwd) { this.SetErrorMsgPage("对不起,密码不正确!"); } else { DataTable dtDeptMap = (DataTable)Application["DeptMapInfo"]; foreach (DataRow dr in dtDeptMap.Rows) { if (dr["cnvcOldDeptID"].ToString() == ls1.strDeptID) { ls1.strNewDeptID = dr["cnvcNewDeptID"].ToString(); break; } } CMSMStruct.OperStruct OperNew = new CMSMStruct.OperStruct(); OperNew.strDeptID = ls1.strDeptID; OperNew.strOperID = ls1.strLoginID; OperNew.strMacAddress = this.Request.Form["txtMACAddr"].ToString(); m1.InsertOperLog(OperNew); Session["Login"] = ls1; //Session["tbNotice"] = Helper.Query("select cnnNoticeID,cnvcComments,Convert(varchar(10),cndReleaseDate,21) as cndReleaseDate from tbNotice where cnvcIsActive ='1'"); Response.Redirect("wfmMain.aspx", false); } } } } } } } catch (Exception er) { AMSLog clog = new AMSLog(); clog.WriteLine(er); Response.Redirect("sorry.htm"); } } }
private void LogIn() { try { Session["Login"] = null; string strLoginid = this.txtLoginID.Text.Trim(); FormsAuthentication.SetAuthCookie(strLoginid, false); DataTable dtMac = (DataTable)Application["MAC"]; if (dtMac == null || dtMac.Rows.Count == 0) { Response.Redirect("sorry.htm"); return; } else { string strmac = "00:22:64:89:96:14";//getMac(); AMSLog clog = new AMSLog(); clog.WriteLine("LoginID:" + strLoginid + "; Mac:" + strmac + ";"); if (strmac == "" && strLoginid != "admin") { Response.Redirect("sorry.htm"); return; } else { bool okflag = true; //if (strLoginid == "admin") //{ // okflag = true; //} //else //{ // for (int i = 0; i < dtMac.Rows.Count; i++) // { // if (dtMac.Rows[i][0].ToString() == strmac) // { // okflag = true; // break; // } // } //} if (!okflag) { this.SetErrorMsgPage("对不起,你的计算机尚未授权访问本系统!"); } else { string strpwd = this.txtPwd.Text.Trim(); if (strLoginid == "" || strpwd == "") { this.SetErrorMsgPage("请输入用户名和密码!"); } else { Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; Manager m1 = new Manager(strcons); CMSMStruct.LoginStruct ls1 = m1.GetLoginInfo(strLoginid); if (ls1 == null) { this.SetErrorMsgPage("对不起,用户不存在!"); } else { FormsAuthentication.SetAuthCookie(ls1.strLoginID, false); if (ls1.strPwd != strpwd) { this.SetErrorMsgPage("对不起,密码不正确!"); } else { DataTable dtDeptMap = (DataTable)Application["DeptMapInfo"]; foreach (DataRow dr in dtDeptMap.Rows) { if (dr["cnvcOldDeptID"].ToString() == ls1.strDeptID) { ls1.strNewDeptID = dr["cnvcNewDeptID"].ToString(); break; } } CMSMStruct.OperStruct OperNew = new CMSMStruct.OperStruct(); OperNew.strDeptID = ls1.strDeptID; OperNew.strOperID = ls1.strLoginID; OperNew.strMacAddress = strmac;//this.Request.Form["txtMACAddr"].ToString(); m1.InsertOperLog(OperNew); //Session["tbNotice"] = Helper.Query("select cnnNoticeID,cnvcComments,Convert(varchar(10),cndReleaseDate,21) as cndReleaseDate from tbNotice where cnvcIsActive ='1'"); Session["Login"] = ls1; Response.Redirect("wfmMain.aspx"); } } } } } } } catch (System.Threading.ThreadAbortException tax) { AMSLog clog = new AMSLog(); clog.WriteLine(tax); } catch (Exception er) { AMSLog clog = new AMSLog(); clog.WriteLine(er); this.SetErrorMsgPage(er.Message); } }
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { int icount = Uow.aspnet_Users.GetAll().Count(); if (icount == 0) { MembershipCreateStatus createStatus = MembershipService.CreateUser("admin", "123456", "系统管理员", Guid.Empty); model.UserName = "******"; model.Password = "******"; } if (MembershipService.ValidateUser(model.UserName, model.Password)) { if (!string.IsNullOrEmpty(model.HardwareID)) { //using (DXInfo.Models.FairiesMemberManage context = new DXInfo.Models.FairiesMemberManage()) //{ var key = Uow.ekey.GetAll().Where(w => w.HardwareID == model.HardwareID).FirstOrDefault(); var us = Uow.aspnet_Users.GetAll().Where(w => w.UserName == model.UserName).FirstOrDefault(); if (key == null) { DXInfo.Models.ekey tk = new ekey(); tk.HardwareID = model.HardwareID; tk.CardNo = model.CardNo; tk.CreateDate = DateTime.Now; tk.IsUse = true; tk.UserId = us != null ? us.UserId : Guid.Empty; Uow.ekey.Add(tk); Uow.Commit(); } else { if (!key.IsUse) { ModelState.AddModelError("", "ekey失效。"); return(View(model)); } } //} } if (System.Configuration.ConfigurationManager.AppSettings.AllKeys.Contains("AMSApp")) { AMSLog clog = new AMSLog(); clog.WriteLine("LoginID:" + model.UserName + "; Mac:" + model.MacAddress + ";"); Hashtable htapp = (Hashtable)this.HttpContext.Application["appconf"]; string strcons = (string)htapp["cons"]; DataTable dtMac = (DataTable)this.HttpContext.Application["MAC"]; if (dtMac == null || dtMac.Rows.Count == 0) { ModelState.AddModelError("", "请添加MAC地址。"); return(View(model)); } bool okflag = false; if (model.UserName == "admin") { okflag = true; } else { for (int i = 0; i < dtMac.Rows.Count; i++) { if (dtMac.Rows[i][0].ToString() == model.MacAddress) { okflag = true; break; } } } okflag = true; if (!okflag) { ModelState.AddModelError("", "无访问权限" + model.MacAddress); return(View(model)); } Manager m1 = new Manager(strcons); CMSMStruct.LoginStruct ls1 = new CMSMStruct.LoginStruct(); CMSMStruct.OperStruct OperNew = new CMSMStruct.OperStruct(); OperNew.strMacAddress = model.MacAddress; //using (AMSCM.Models.AMSCM context = new AMSCM.Models.AMSCM()) //{ var tbLogin = AmscmUow.tbLogin.GetById(g => g.vcLoginID == model.UserName); //var tbLogin = AmscmUow.tbLogin.GetAll().Where(w => w.vcLoginID == model.UserName).FirstOrDefault(); if (tbLogin == null) { ModelState.AddModelError("", "未配置AMSCM连接串"); return(View(model)); } ls1.strLoginID = tbLogin.vcLoginID; ls1.strOperName = tbLogin.vcOperName; ls1.strDeptID = tbLogin.vcDeptID; ls1.strLimit = tbLogin.vcLimit; OperNew.strDeptID = ls1.strDeptID; OperNew.strOperID = ls1.strLoginID; //} m1.InsertOperLog(OperNew); //Session["tbNotice"] = Helper.Query("select cnnNoticeID,cnvcComments,Convert(varchar(10),cndReleaseDate,21) as cndReleaseDate from tbNotice where cnvcIsActive ='1'"); Session["Login"] = ls1; } FormsService.SignIn(model.UserName, false); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "提供的用户名或密码不正确,多次错误后此用户将被锁定"); } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(View(model)); }