public ActionResult Index(Login admin) { if (ModelState.IsValid) { var _admin = _kullaniciRepostory.Login(admin.EPosta, admin.Sifre); if (_admin != null) { HttpCookie yonetici = new HttpCookie("MicroOptikAdmin"); yonetici.Values.Add("yoneticiId", _admin.Id.ToString()); yonetici.Values.Add("yoneticiIsim", _admin.AdiSoyadi); Response.Cookies.Add(HttpSecureCookie.Encode(yonetici)); return(RedirectToAction("Index", "Arayuz")); } else { ModelState.AddModelError("", "Lütfen kullanıcı bilgilerinizi kontrol ediniz."); } } else { ModelState.AddModelError("", "Lütfen kullanıcı bilgilerinizi kontrol ediniz."); } return(View()); }
/// <summary> /// 获取全部小区信息 /// </summary> /// <returns></returns> private List <CommunityInfoModel> GetAllCommunity() { List <CommunityInfoModel> communitylist = null; HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; if (CacheHelper.GetCache("community") == null) { communitylist = community_bll.GetCommunity(" and isdel=0 ", int.Parse(uid)).OrderBy(o => o.communityID).ToList(); if (communitylist != null) { //在缓存中保存24小时 CacheHelper.SetCache("community", communitylist, 24); } } else { communitylist = CacheHelper.GetCache("community") as List <CommunityInfoModel>; } } return(communitylist); }
/// <summary> /// 获取某物业公司所有小区 /// </summary> /// <returns></returns> private List <CommunityInfoModel> GetPropertyCommunity(string propertyMId, string pCityID) { List <CommunityInfoModel> communitylist = null; HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; if (CacheHelper.GetCache("getpropertycommunity") == null) { communitylist = community_bll.GetProperCommunity(propertyMId, pCityID, int.Parse(uid)); if (communitylist != null) { //在缓存中保存24小时 //CacheHelper.SetCache("getpropertycommunity", communitylist, 24); } } else { communitylist = CacheHelper.GetCache("getpropertycommunity") as List <CommunityInfoModel>; } } return(communitylist); }
/// <summary> /// 更新用户 /// </summary> private string UpdateUser(HttpContext context) { //================必填===================== string userid = context.Request.Params["uid"]; string loginName = context.Request.Params["loginName"]; //string password = context.Request.Params["password"]; string nickName = context.Request.Params["nickName"]; string headimg = context.Request.Params["headimg"]; string mobile = context.Request.Params["mobile"]; string companyName = context.Request.Params["property"]; string departmentName = context.Request.Params["departmentName"]; string remark = context.Request.Params["remark"]; //角色信息 string radioRole = context.Request.Params["radio_role"]; //授权小区 string authcommunity = context.Request.Params["authcommunity"]; var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "修改用户失败", RedirectUrl = "" }; try { //新用户 HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; var newuser = new UserInfoModel() { uid = Convert.ToInt32(userid), loginName = loginName, //password = COMMON.ConvertHelper.StringToMD5(password), nickName = nickName, mobile = mobile, headimg = headimg, companyName = companyName, departmentName = departmentName, remark = remark }; if (user_bll.Update(newuser, radioRole, authcommunity, int.Parse(uid))) { jr.IsSucceed = true; jr.Msg = "修改用户成功"; } } return(JsonConvert.SerializeObject(jr)); } catch (Exception err) { LogHelper.Debug("添加新用户(UpdateUser)---" + err.Message); throw err; } }
private void GetUserInfo() { HttpCookie cookie = Request.Cookies["EccmUserinfo"]; if (cookie != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cookie); //显示用户登录名 string loginname = decodeCookie.Values["loginname"]; //lbl_user.Text = loginname; string UserID = decodeCookie.Values["userid"].ToString(); //权限菜单 if (loginname == "admin") { menus = menu_bll.GetMenuList(string.Empty); } else { menus = menu_bll.GetRoleMenuByUserId(UserID); } } else { Response.Redirect("/login.html"); } }
/// <summary> /// 获取城市小区集合 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetCommunity(HttpContext context) { var jr = new JsonResultModel <List <CommunityInfoModel> >() { IsSucceed = false, Data = new List <CommunityInfoModel>(), Msg = "获取小区信息失败", RedirectUrl = string.Empty }; //int userid = string.IsNullOrEmpty(context.Request.Params["userID"]) ? 0 : Convert.ToInt32(context.Request.Params["userID"]); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string userid = decodeCookie.Values["userid"]; List <CommunityInfoModel> communitylist = GetAllCommunity(); string _cid = context.Request.Params["cid"]; int cid = -1; if (!string.IsNullOrEmpty(_cid)) { int.TryParse(_cid, out cid); } if (communitylist != null && communitylist.Count > 0) { jr.IsSucceed = true; jr.Data = communitylist.Where(c => c.pCityID == cid).ToList(); jr.Msg = "获取小区成功"; } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 新增报修工单 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddRepairOrder(HttpContext context) { var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "新增失败", RedirectUrl = string.Empty }; string equCodes = context.Request.Params["equCodes"]; string termtime = context.Request.Params["termtime"]; string reason = context.Request.Params["reason"]; int communityID = string.IsNullOrEmpty(context.Request.Params["communityID"]) ? 0 : int.Parse(context.Request.Params["communityID"]); string orderSn = OrderHelp.GetOrderSN("WX"); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; if (_reqairBLL.AddRepairOrder(orderSn, equCodes, communityID, reason, Convert.ToDateTime(termtime), Convert.ToInt32(uid))) { jr.IsSucceed = true; jr.Msg = "新增成功"; } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 派单 /// </summary> /// <param name="context"></param> /// <returns></returns> private string SendRepairOrder(HttpContext context) { var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "派单失败", RedirectUrl = string.Empty }; int orderID = string.IsNullOrEmpty(context.Request.Params["orderID"]) ? 0 : int.Parse(context.Request.Params["orderID"]); int userID = string.IsNullOrEmpty(context.Request.Params["userID"]) ? 0 : int.Parse(context.Request.Params["userID"]); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"];//派单人 if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string dispatch = decodeCookie.Values["userid"]; if (orderID > 0 && userID > 0) { if (_reqairBLL.SendRepairOrder(orderID, userID, Convert.ToInt32(dispatch))) { jr.IsSucceed = true; jr.Msg = "派单成功"; } } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 获取省市小区选项树 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetCPOE(HttpContext context) { System.Text.StringBuilder opts = new System.Text.StringBuilder(); var jr = new JsonResultModel <string>() { IsSucceed = false, Data = string.Empty, Msg = "获取省市小区选项树失败", RedirectUrl = string.Empty }; int pid = string.IsNullOrEmpty(context.Request.Params["propertyID"]) ? 0 : Convert.ToInt32(context.Request.Params["propertyID"]); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); int id = Convert.ToInt32(decodeCookie.Values["userid"]); //string uid = context.Request.Cookies.AllKeys['userinfo']; //System.Text.RegularExpressions.Regex.IsMatch(uid, "^\\d+$"); var citylist = GetAllCity(); var communitylist = GetAllCommunity(); if (pid > 0) { communitylist = communitylist.Where(s => s.propertyMId == pid).ToList(); } #region 取得城市信息 foreach (var pp in citylist.Where(p => p.pID == 0)) { //省份 opts.AppendFormat("<option value='{0}' data-level='1' disabled>{1}</option>", pp.areaID, pp.areaName); foreach (var cc in citylist.Where(c => c.pID == pp.areaID)) { if (communitylist.Count(cmc => cmc.pCityID == cc.areaID) > 0) { //城市 opts.AppendFormat("<option data-level='2' value='{0}' disabled parent='{1}'>{2}</option>", cc.areaID, pp.areaID, cc.areaName); foreach (var cmy in communitylist.Where(cm => cm.pCityID == cc.areaID)) { //小区 opts.AppendFormat("<option data-level='3' data-value='{0}' parent='{1}'>{2}</option>", cmy.communityID, cc.areaID, cmy.communityName); } } else { //城市 opts.AppendFormat("<option data-level='2' disabled parent='{1}'>{0}</option>", cc.areaName, pp.areaID); } } } #endregion } if (!string.IsNullOrEmpty(opts.ToString())) { jr.IsSucceed = true; jr.Data = opts.ToString(); jr.Msg = "获取省市小区选项树成功"; } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 获取某个小区信息 /// </summary> /// <returns></returns> private string GetCommunityById(HttpContext context) { var jr = new JsonResultModel <List <CommunityInfoModel> >() { IsSucceed = false, Data = new List <CommunityInfoModel>(), Msg = "获取小区信息失败", RedirectUrl = string.Empty }; int communityid = string.IsNullOrEmpty(context.Request.Params["communityid"]) ? 0 : Convert.ToInt32(context.Request.Params["communityid"]); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; List <CommunityInfoModel> commlist = community_bll.GetCommunityById(communityid, int.Parse(uid)); if (commlist != null && commlist.Count > 0) { jr.IsSucceed = true; jr.Data = commlist.ToList(); jr.Msg = "获取小区信息成功"; } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// 获取用户报修订单列表 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetRepairUserOrderList(HttpContext context) { #region 分页参数 int pagesize = 1; int pageindex = 1; string _pindex = context.Request.Params["pageNumber"]; string _psize = context.Request.Params["pageSize"]; if (!string.IsNullOrEmpty(_pindex)) { pageindex = int.Parse(_pindex); } if (!string.IsNullOrEmpty(_psize)) { pagesize = int.Parse(_psize); } #endregion #region 查询条件 int communityID = string.IsNullOrEmpty(context.Request.Params["communityID"]) ? 0 : int.Parse(context.Request.Params["communityID"]); string timespan = context.Request.Params["timeSpan"]; string status = context.Request.Params["status"]; int uid = 0;// int.Parse(context.Request.Cookies["EccmUserinfo"].Values["userid"]); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); uid = int.Parse(decodeCookie.Values["userid"]); } var ts = System.Text.RegularExpressions.Regex.Matches(timespan, "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}"); DateTime begintime = DateTime.Parse(ts[0].Value); DateTime endtime = DateTime.Parse(ts[1].Value).AddDays(1); StringBuilder strWhere = new StringBuilder(); strWhere.AppendFormat(" and r.r_stime>'{0}' and r.r_stime<'{1}'", begintime, endtime); strWhere.AppendFormat(" and community_id={0} ", communityID); strWhere.AppendFormat(" and ru.uid_receiver={0} ", uid); strWhere.AppendFormat(" and ru.receiver_type={0} ", 3);//1巡检2维保3维修 if (!string.IsNullOrEmpty(status)) { strWhere.AppendFormat(" and r_state={0} ", status); } if (strWhere.Length > 0) { strWhere.Remove(0, 4); } #endregion int rowcount = 0; var pr = new PagingResultModel <List <EccmRepairOrderModel> >() { total = 0, rows = new List <EccmRepairOrderModel>() }; pr.rows = _reqairBLL.GetRepairUserOrderList(strWhere.ToString(), pageindex, pagesize, out rowcount); pr.total = rowcount; return(JsonConvert.SerializeObject(pr)); }
/// <summary> /// 添加巡检实施 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddInspectionImplement(HttpContext context) { var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "添加失败", RedirectUrl = string.Empty }; //获取传递参数 string orderid = context.Request.Params["orderid"]; string ordersn = context.Request.Params["ordersn"]; string content = context.Request.Params["content"]; HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; string imgurl = context.Request.Params["imgurl"]; string type = context.Request.Params["type"];//1巡检2维保3维修 //给对象赋值 EccmInspectionOrderImplementModel model = new EccmInspectionOrderImplementModel(); model.order_id = int.Parse(orderid); model.equCode = "";//该处没有设备编码 model.implement_content = content; model.implement_time = DateTime.Now; model.uid_handle = int.Parse(uid); EccmInspectionOrderImplementBLL bll = new EccmInspectionOrderImplementBLL(); int id = bll.Add(model); //插入并获取id if (id > 0) //实施内容插入成功 { EccmImplementImgModel img_model = new EccmImplementImgModel(); img_model.implement_id = id; img_model.img_path = imgurl; img_model.img_type = int.Parse(type);; //1巡检2维保3维修 EccmImplementImgBLL img_bll = new EccmImplementImgBLL(); if (img_bll.Add(img_model)) //插入实施图片 { EccmInspectionOrderModel inspection_model = new EccmInspectionOrderModel(); inspection_model.order_id = int.Parse(orderid); inspection_model.order_stats = 4;//0未派单1已派单2已接单3处理中4完成 inspection_model.order_finish_time = DateTime.Now; EccmInspectionOrderBLL inspection_bll = new EccmInspectionOrderBLL(); inspection_bll.UpdateStates(inspection_model);//更改订单为完成 jr.IsSucceed = true; jr.Msg = "添加成功"; } } } return(JsonConvert.SerializeObject(jr)); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (requestContext.HttpContext.Request.Cookies["MicroOptikAdmin"] != null) { HttpCookie cookie = requestContext.HttpContext.Request.Cookies["MicroOptikAdmin"]; cookie = HttpSecureCookie.Decode(cookie); ViewData["Admin"] = cookie["yoneticiIsim"]; } base.Initialize(requestContext); }
/// <summary> /// 添加能耗数据 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Add(HttpContext context) { var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "添加能耗数据失败", RedirectUrl = string.Empty }; string pms = context.Request.Params["PMS"];//hd_communityID=1&sym=2017-02&t9=12&t10=12&t11=12 var match = Regex.Match(pms, "hd_communityID=(.+?)&sym=(.+?)&(.+)"); int communityID = string.IsNullOrEmpty(match.Groups[1].Value) ? 0 : Convert.ToInt32(match.Groups[1].Value); if (!string.IsNullOrEmpty(match.Groups[2].Value)) { string[] date = match.Groups[2].Value.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); int _year = Convert.ToInt32(date[0]); int _month = Convert.ToInt32(date[1]); if (!string.IsNullOrEmpty(match.Groups[3].Value)) { var modellist = match.Groups[3].Value.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries).Select(s => new EnergyInfoModel() { communityID = communityID, typeID = int.Parse(s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[0].Substring(1)), year = _year, month = _month, engValue = decimal.Parse(s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1]), insertTime = DateTime.Now }); if (modellist != null && modellist.Count() > 0) { int addcount = energyinfo_bll.Add(modellist.ToList()); if (addcount > 0) { jr.IsSucceed = true; jr.Data = addcount / 2; jr.Msg = "成功添加能耗数据!"; HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; userlog_bll.addUserLog(int.Parse(uid), "添加能耗数据"); } } } } } return(JsonConvert.SerializeObject(jr)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); this.userID.Value = decodeCookie.Values["userid"]; } } }
public static void CreateEncryptedCookie(bool remember) { HttpCookie cookie = new HttpCookie(cookiesNombre.cookieNombre); if (remember) { cookie.Expires = DateTime.Now.AddDays(30); } HttpCookie encodedCookie = HttpSecureCookie.Encode(cookie, CookieProtection.Encryption); HttpContext.Current.Response.AppendCookie(encodedCookie); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpCookie cookie = Request.Cookies["EccmUserinfo"]; if (cookie != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cookie); //显示用户登录名 string loginname = decodeCookie.Values["loginname"]; //lbl_user.Text = loginname; UserID = Convert.ToInt32(decodeCookie.Values["userid"]); } //menus = menu_bll.GetMenuList(string.Empty); propertyList = new PropertyInfoBLL().GetAuthorizePropertyinfo(UserID); if (propertyList.Rows.Count == 0) { propertyList.Columns.Add("propertyID"); propertyList.Columns.Add("propertyName"); DataRow dr = propertyList.NewRow(); dr["propertyID"] = "0"; dr["propertyName"] = "未选择"; propertyList.Rows.InsertAt(dr, 0); } else { this.property.DataSource = propertyList; this.property.DataValueField = "propertyID"; this.property.DataTextField = "propertyName"; this.property.DataBind(); } this.mID.Value = Request.Params["mid"]; int mid = string.IsNullOrEmpty(Request.Params["mid"]) ? 0 : Convert.ToInt32(Request.Params["mid"]); this.devhouseID.Value = Request.Params["devhouseID"]; this.systypeID.Value = Request.Params["systypeID"]; this.communityID.Value = Request.Params["communityID"]; this.pageUrls.Value = Request.Params["pageUrls"]; footerContent = moncontent_bll.GetFooterContent(mid); } }
public static void AddCookieValue(string key, string value) { HttpCookie decodedCookie = null; HttpCookie encodedCookie = HttpContext.Current.Request.Cookies[cookiesNombre.cookieNombre]; try { decodedCookie = HttpSecureCookie.Decode(encodedCookie, CookieProtection.Encryption); } catch { return; } decodedCookie.Values.Set(key, value); encodedCookie = HttpSecureCookie.Encode(decodedCookie, CookieProtection.Encryption); HttpContext.Current.Response.Cookies.Set(encodedCookie); }
/// <summary> /// 新增维保工单 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddMaintenanceOrder(HttpContext context) { var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "新增失败", RedirectUrl = string.Empty }; //获取传递参数 string equCodes = context.Request.Params["equCodes"]; string termtime = context.Request.Params["termtime"]; //string reason = context.Request.Params["reason"]; int communityID = string.IsNullOrEmpty(context.Request.Params["communityID"]) ? 0 : int.Parse(context.Request.Params["communityID"]); string orderSn = OrderHelp.GetOrderSN("WB"); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; //给对象赋值 EccmMaintenanceOrderModel model = new EccmMaintenanceOrderModel(); model.order_sn = orderSn; model.order_stats = 0; model.order_time = DateTime.Now; model.order_type = 0; model.term_order = DateTime.Parse(termtime); model.community_id = communityID; model.uid = int.Parse(uid); model.plan_id = 0;//手动增加工单时,该字段为0 if (_bll.Add(model, equCodes)) { jr.IsSucceed = true; jr.Msg = "新增成功"; } } return(JsonConvert.SerializeObject(jr)); }
public static void AddCookieValues(Dictionary <string, string> keyValues) { HttpCookie decodedCookie = null; HttpCookie encodedCookie = HttpContext.Current.Request.Cookies[cookiesNombre.cookieNombre]; try { decodedCookie = HttpSecureCookie.Decode(encodedCookie, CookieProtection.Encryption); } catch { return; } foreach (KeyValuePair <string, string> entry in keyValues) { decodedCookie.Values.Set(entry.Key, entry.Value); } encodedCookie = HttpSecureCookie.Encode(decodedCookie, CookieProtection.Encryption); HttpContext.Current.Response.Cookies.Set(encodedCookie); }
private void writeCookies() { if (this.chkRemember.Checked) { HttpCookie c = new HttpCookie("NetSqlAzManWebConsole"); c.Expires = DateTime.Now.AddDays(15); c["DataSource"] = this.cmbDataSources.SelectedValue; c["IntegratedAuthentication"] = this.rbIntegrated.Checked.ToString(); c["UserId"] = this.txtUserId.Text; c["Password"] = this.txtPassword.Text; c["InitialCatalog"] = this.cmbDatabases.SelectedValue; c["OtherSettings"] = this.txtOtherSettings.Text; c["RememberConnectionInfo"] = this.chkRemember.Checked.ToString(); HttpCookie encodedCookie = HttpSecureCookie.Encode(c); this.Response.Cookies.Add(encodedCookie); } else { HttpCookie c = this.Response.Cookies["NetSqlAzManWebConsole"]; c.Expires = DateTime.Now.AddDays(-2); } }
public static string GetCookieValue(string key) { HttpCookie decodedCookie = null; HttpCookie encodedCookie = HttpContext.Current.Request.Cookies[cookiesNombre.cookieNombre]; try { decodedCookie = HttpSecureCookie.Decode(encodedCookie, CookieProtection.Encryption); } catch { FormsAuthentication.SignOut(); HttpContext.Current.Session.Abandon(); //HttpContext.Current.Response.Redirect("~/"); } if (decodedCookie[key] == null) { return(null); } return(decodedCookie[key].ToString()); }
/// <summary> /// Sets the account cookies. /// </summary> /// <param name="account">The account.</param> /// <param name="member">The member.</param> /// <param name="role">The role.</param> /// <param name="expires">The expires.</param> protected void SetAccountCookies(string account, string member, string role, int expires) { HttpCookie cookie_acc = new HttpCookie("acc", account); cookie_acc.Expires = DateTime.Now.AddHours(expires); HttpCookie encodedCookie_acc = HttpSecureCookie.Encode(cookie_acc); Response.Cookies.Add(encodedCookie_acc); HttpCookie cookie_mem = new HttpCookie("mem", member); cookie_mem.Expires = DateTime.Now.AddHours(expires); HttpCookie encodedCookie_mem = HttpSecureCookie.Encode(cookie_mem); Response.Cookies.Add(encodedCookie_mem); HttpCookie cookie_role = new HttpCookie("role", role); cookie_role.Expires = DateTime.Now.AddHours(expires); HttpCookie encodedCookie_role = HttpSecureCookie.Encode(cookie_role); Response.Cookies.Add(encodedCookie_role); }
private string readThemeCookie() { HttpCookie cookie = this.Request.Cookies["NetSqlAzManWebConsole-Theme"]; if (cookie != null) { HttpCookie c; try { c = HttpSecureCookie.Decode(cookie); } catch { //Cookie tampered return("Default"); } if (c != null) { return(c["Theme"]); } } return("Default"); }
/// <summary> /// 添加计划 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddPlan(HttpContext context) { var jr = new JsonResultModel <int>() { IsSucceed = false, Data = 0, Msg = "添加失败", RedirectUrl = string.Empty }; #region 递参数处理为对象 //获取传递参数 string plancycle = context.Request.Params["plancycle"]; string planrole = context.Request.Params["planrole"]; string executionfrequency = context.Request.Params["executionfrequency"]; string term_day = context.Request.Params["term_day"]; string planstime = context.Request.Params["planstime"]; string planetime = context.Request.Params["planetime"]; string communityID = context.Request.Params["communityID"]; string planstats = context.Request.Params["planstats"]; string choosetype = context.Request.Params["choosetype"]; string plantype = context.Request.Params["plantype"]; string Codes = context.Request.Params["Codes"]; EccmPlanModel model = new EccmPlanModel(); model.plan_cycle = int.Parse(plancycle); model.plan_role = planrole; model.execution_frequency = int.Parse(executionfrequency); model.term_day = int.Parse(term_day); model.plan_stime = DateTime.Parse(planstime); if (planetime != "") { model.plan_etime = DateTime.Parse(planetime); } model.communityID = int.Parse(communityID); model.plan_stats = int.Parse(planstats); model.choose_type = int.Parse(choosetype); model.plan_type = int.Parse(plantype); model.plan_creat_time = DateTime.Now; model.is_delete = 0; #endregion HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); string uid = decodeCookie.Values["userid"]; //给对象赋值 model.uid = int.Parse(uid); } EccmPlanBLL bll = new EccmPlanBLL(); int id = bll.Add(model); //添加计划并获取id if (id > 0) //添加计划成功 { if (model.choose_type == 0) //设备类型 { EccmPlanDevicetypeModel pdt_model = new EccmPlanDevicetypeModel(); pdt_model.community_id = model.communityID; pdt_model.plan_id = id; pdt_model.system_type_code = Codes; EccmPlanDevicetypeBLL pdt_bll = new EccmPlanDevicetypeBLL(); if (pdt_bll.Add(pdt_model)) { jr.IsSucceed = true; jr.Msg = "添加成功"; } } else if (model.choose_type == 1)//设备 { EccmPlanDeviceModel pd_model = new EccmPlanDeviceModel(); pd_model.community_id = model.communityID; pd_model.plan_id = id; pd_model.equCode = Codes; EccmPlanDeviceBLL pd_bll = new EccmPlanDeviceBLL(); if (pd_bll.Add(pd_model)) { jr.IsSucceed = true; jr.Msg = "添加成功"; } } } return(JsonConvert.SerializeObject(jr)); }
/// <summary> /// Checks the member login. /// </summary> /// <returns>Check Member login</returns> public bool CheckMemberlogin() { string mem = string.Empty; string role = string.Empty; ////get session if (this.Session["mem"] != null) { mem = this.Session["mem"].ToString(); } if (this.Session["role"] != null) { role = this.Session["role"].ToString(); } ////if session null get from cookies and set session if (mem == string.Empty || role == string.Empty) { HttpCookie cookie = this.Request.Cookies["mem"]; if (cookie != null) { HttpCookie decodedCookie = HttpSecureCookie.Decode(cookie); if (decodedCookie != null && decodedCookie.Value != null) { UserModels sv = new UserModels(); C_User it = new C_User(); C_UserInfo iit = new C_UserInfo(); it = sv.GetUserbyUserName(decodedCookie.Value); if (it != null && it.Role == 2) { iit = sv.GetUserInforByEmail(it.Username); this.Session["mem"] = iit.FName; this.Session["role"] = it.Role.ToString(); this.Session["acc"] = it.Username; } } else { mem = string.Empty; role = string.Empty; } } } ////HttpCookie cookie = new HttpCookie("UserName", "Terminator"); ////cookie.Expires = DateTime.Now.AddDays(1); ////HttpCookie encodedCookie = HttpSecureCookie.Encode(cookie); ////Response.Cookies.Add(encodedCookie); ////HttpCookie cookie = Request.Cookies["UserName"]; ////lblDisplayBefore.Text = cookie.Value; ////HttpCookie decodedCookie = HttpSecureCookie.Decode(cookie); if (mem != string.Empty && role == "2") { return(true); } else { return(false); } }
/// <summary> /// Checks the admin login. /// </summary> /// <returns>Check Admin login</returns> public bool CheckAdminlogin() { string mem = string.Empty; string role = string.Empty; if (this.Session["mem"] != null) { mem = this.Session["mem"].ToString(); } if (this.Session["role"] != null) { role = this.Session["role"].ToString(); } ////if session null get from cookies and set session if (mem == string.Empty || role == string.Empty) { HttpCookie cookie = Request.Cookies["mem"]; if (cookie != null) { HttpCookie decodedCookie = HttpSecureCookie.Decode(cookie); if (decodedCookie != null && decodedCookie.Value != null) { UserModels sv = new UserModels(); C_User it = new C_User(); it = sv.GetUserbyUserName(decodedCookie.Value); if (it != null) { if (it.Role == 1) { this.Session["mem"] = it.Username; this.Session["role"] = it.Role.ToString(); this.Session["acc"] = it.Username; } else { mem = string.Empty; role = string.Empty; } } else { mem = string.Empty; role = string.Empty; } } else { mem = string.Empty; role = string.Empty; } } } if (mem != string.Empty && role == "1") { return(true); } else { return(false); } }
/// <summary> /// 验证登录 /// </summary> /// <param name="context"></param> /// <returns></returns> private string CheckLogin(HttpContext context) { var jr = new JsonResultModel <string>() { IsSucceed = false, Data = string.Empty, Msg = string.Empty, RedirectUrl = "../Views/Home/Home.aspx" }; if (context.Session["vcode"] == null || context.Session["vcode"].ToString() != context.Request.Params["txtcode"].ToString()) { jr.Msg = "验证码错误"; } else { string loginname = context.Request.Params["txtusername"]; string password = context.Request.Params["txtpassword"]; if (!string.IsNullOrEmpty(loginname) && !string.IsNullOrEmpty(password)) { UserInfoModel model = null; //登录成功 if (ui_bll.CheckLogin(loginname, password, out model)) { HttpCookie cookie = new HttpCookie("EccmUserinfo"); cookie.Values.Add("loginname", model.loginName.ToString()); cookie.Values.Add("userid", model.uid.ToString()); cookie.Values.Add("userpwd", model.password.ToString()); //cookie.Domain = "eccm.fxzhj.com"; //cookie.Path = "/ECMM"; //cookie.Secure = true; //把用户ID保存在cookie中 if (!string.IsNullOrEmpty(context.Request.Params["reb"])) { //7天过期 cookie.Expires = DateTime.Now.AddDays(7); } else { //缓存用户ID,关闭网站失效 cookie.Expires = DateTime.Now.AddDays(1); } //cookie.Value = HttpUtility.UrlEncode(cookie.Value); //HttpSecureCookie.Encode(cookie.Value); //context.Response.Cookies.Add(cookie); //加密Cookie HttpCookie encodeCookie = HttpSecureCookie.Encode(cookie); context.Response.Cookies.Add(encodeCookie); //把用户信息保存在session中 context.Session["EccmUserinfo"] = model; jr.IsSucceed = true; jr.Msg = "登录成功"; } else { jr.IsSucceed = false; jr.Msg = "账号或密码错误"; } } } return(JsonConvert.SerializeObject(jr)); }
private void readCookies() { HttpCookie cookie = this.Request.Cookies["NetSqlAzManWebConsole"]; if (cookie != null) { HttpCookie c; try { c = HttpSecureCookie.Decode(cookie); } catch { //Cookie tampered c = null; } if (c != null) { bool remember = false; if (bool.TryParse(c["RememberConnectionInfo"], out remember) && remember) { ListItem li = null; foreach (ListItem li2 in this.cmbDataSources.Items) { if (String.Compare(li2.Text.Trim(), c["DataSource"].Trim(), true) == 0) { li = li2; } } if (li == null) { li = new ListItem(c["DataSource"]); this.cmbDataSources.Items.Add(li); } li.Selected = true; this.rbIntegrated.Checked = bool.Parse(c["IntegratedAuthentication"]); this.rbSql.Checked = !this.rbIntegrated.Checked; this.rbAuthentication_CheckedChanged(this, EventArgs.Empty); if (!this.rbIntegrated.Checked) { this.txtUserId.Text = c["UserId"]; this.txtPassword.Text = c["Password"]; this.txtPassword.Focus(); } li = null; foreach (ListItem li2 in this.cmbDatabases.Items) { if (String.Compare(li2.Text.Trim(), c["InitialCatalog"].Trim(), true) == 0) { li = li2; } } if (li == null) { li = new ListItem(c["InitialCatalog"]); this.cmbDatabases.Items.Add(li); } li.Selected = true; this.txtOtherSettings.Text = c["OtherSettings"]; this.chkRemember.Checked = true; } } } }
/// <summary> /// 根据用户id,获取所有小区 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetCommunityByUser(HttpContext context) { var jr = new JsonResultModel <string>() { IsSucceed = false, Data = "", Msg = "获取小区信息失败", RedirectUrl = string.Empty }; System.Text.StringBuilder opts = new System.Text.StringBuilder(); List <CommunityInfoModel> communitylist = new List <CommunityInfoModel>(); HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"]; if (cook != null) { //解密Cookie HttpCookie decodeCookie = HttpSecureCookie.Decode(cook); int userid = Convert.ToInt32(decodeCookie.Values["userid"]); if (userid > 0) { communitylist = community_bll.GetCommunityByUser(userid); } } if (communitylist.Count > 0) { var citylist = GetAllCity(); foreach (var pp in citylist.Where(p => p.pID == 0)) { //省份 opts.AppendFormat("<option value='{0}' data-level='1' disabled>{1}</option>", pp.areaID, pp.areaName); foreach (var cc in citylist.Where(c => c.pID == pp.areaID)) { if (communitylist.Count(cmc => cmc.pCityID == cc.areaID) > 0) { //城市 opts.AppendFormat("<option data-level='2' value='{0}' disabled parent='{1}'>{2}</option>", cc.areaID, pp.areaID, cc.areaName); foreach (var cmy in communitylist.Where(cm => cm.pCityID == cc.areaID)) { //小区 opts.AppendFormat("<option data-level='3' data-value='{0}' parent='{1}'>{2}</option>", cmy.communityID, cc.areaID, cmy.communityName); } } else { //城市 opts.AppendFormat("<option data-level='2' disabled parent='{1}'>{0}</option>", cc.areaName, pp.areaID); } } } jr.IsSucceed = true; jr.Data = opts.ToString(); jr.Msg = "获取小区选项树成功"; } else { jr.IsSucceed = false; jr.Msg = "该用户没有绑定小区"; } return(JsonConvert.SerializeObject(jr)); }