/// <summary> /// 保存配置 /// </summary> public void save() { List <FCGridColumn> columns = m_columns; int columnsSize = columns.Count; String sortStr = ""; for (int i = 0; i < columnsSize; i++) { FCGridColumn column = columns[i]; if (column == m_orderColumn) { sortStr += "1"; } else if (column == m_nameColumn) { sortStr += "2"; } else if (column == m_valueColumn) { sortStr += "3"; } else if (column == m_enNameColumn) { sortStr += "4"; } } UserCookie cookie = new UserCookie(); cookie.m_key = "PROPERTYGRIDCOLUMNS"; cookie.m_value = sortStr; DataCenter.UserCookieService.AddCookie(cookie); }
/// <summary> /// 保存信息 /// </summary> public void save() { UserCookie cookie = new UserCookie(); cookie.m_key = "USERSECURITY"; cookie.m_value = JsonConvert.SerializeObject(m_codes); UserCookieService cookieService = DataCenter.UserCookieService; cookieService.addCookie(cookie); }
/// <summary> /// 设置COOKIE /// </summary> /// <param name="var">变量</param> /// <returns>结果</returns> private double SETCOOKIE(CVariable var) { String cookieName = m_indicator.getText(var.m_parameters[0]); UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); cookie.m_key = cookieName; cookie.m_value = m_indicator.getText(var.m_parameters[1]); return(cookieService.AddCookie(cookie)); }
/// <summary> /// 更新会话 /// </summary> /// <param name="cookie">会话</param> /// <returns>状态</returns> public int UpdateCookie(UserCookie cookie) { String sql = String.Format("UPDATE USERCOOKIE SET VALUE = '{0}' WHERE USERID = {1} AND KEY = '{2}'", getDBString(cookie.m_value), m_userID, getDBString(cookie.m_key)); SQLiteConnection conn = new SQLiteConnection(m_connectStr); SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandText = sql; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return(1); }
/// <summary> /// 获取COOKIE /// </summary> /// <param name="var">变量</param> /// <returns>状态</returns> private double GETCOOKIE(CVariable var) { String cookieName = m_indicator.getText(var.m_parameters[1]); UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); if (cookieService.GetCookie(cookieName, ref cookie) > 0) { CVariable newVar = new CVariable(m_indicator); newVar.m_expression = "'" + cookie.m_value + "'"; m_indicator.setVariable(var.m_parameters[0], newVar); return(1); } return(0); }
/// <summary> /// 添加用户Cookie /// </summary> /// <param name="cookie">消息</param> /// <returns>状态</returns> public int AddCookie(UserCookie cookie) { UserCookie oldCookie = new UserCookie(); if (GetCookie(cookie.m_key, ref oldCookie) > 0) { UpdateCookie(cookie); } else { String sql = String.Format("INSERT INTO USERCOOKIE(USERID, KEY, VALUE, MODIFYTIME, CREATETIME) values ({0}, '{1}', '{2}','1970-1-1','1970-1-1')", m_userID, getDBString(cookie.m_key), getDBString(cookie.m_value)); SQLiteConnection conn = new SQLiteConnection(m_connectStr); conn.Open(); SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandText = sql; cmd.ExecuteNonQuery(); conn.Close(); } return(1); }
/// <summary> /// 创建服务 /// </summary> public UserSecurityService() { UserCookie cookie = new UserCookie(); UserCookieService cookieService = DataCenter.UserCookieService; if (cookieService.getCookie("USERSECURITY", ref cookie) > 0) { try { m_codes = JsonConvert.DeserializeObject <List <UserSecurity> >(cookie.m_value); } catch (Exception ex) { } if (m_codes == null) { try { m_codes = JsonConvert.DeserializeObject <List <UserSecurity> >(cookie.m_value); } catch (Exception ex) { } } } }
/// <summary> /// 获取用户Cookie /// </summary> /// <param name="key">键</param> /// <param name="cookie">会话</param> /// <returns>状态</returns> public int GetCookie(String key, ref UserCookie cookie) { int state = 0; String sql = String.Format("SELECT * FROM USERCOOKIE WHERE USERID = {0} AND KEY = '{1}'", m_userID, getDBString(key)); SQLiteConnection conn = new SQLiteConnection(m_connectStr); SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandText = sql; conn.Open(); SQLiteDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { cookie.m_userID = reader.GetInt32(0); cookie.m_key = reader.GetString(1); cookie.m_value = reader.GetString(2); state = 1; } reader.Close(); conn.Close(); return(state); }
/// <summary> /// 添加控件方法 /// </summary> public override void onLoad() { base.onLoad(); String sortStr = "1432"; UserCookie cookie = new UserCookie(); if (DataCenter.UserCookieService.GetCookie("PROPERTYGRIDCOLUMNS", ref cookie) > 0) { sortStr = cookie.m_value; } foreach (char ch in sortStr) { switch (ch) { case '1': //创建序号列 if (m_orderColumn == null) { m_orderColumn = new GridColumnEx(); m_orderColumn.TextColor = FCDraw.FCCOLORS_TEXTCOLOR; m_orderColumn.Font = new FCFont("微软雅黑", 12, false, false, false); m_orderColumn.Text = "序号"; m_orderColumn.Name = "NO"; m_orderColumn.Width = 30; m_orderColumn.AllowResize = true; m_orderColumn.AllowSort = false; m_orderColumn.AllowDrag = true; m_orderColumn.BackColor = FCDraw.FCCOLORS_BACKCOLOR; addColumn(m_orderColumn); } break; case '2': //创建名称列 if (m_nameColumn == null) { m_nameColumn = new GridColumnEx(); m_nameColumn.TextColor = FCDraw.FCCOLORS_TEXTCOLOR; m_nameColumn.Font = new FCFont("微软雅黑", 12, false, false, false); m_nameColumn.Text = "属性名称"; m_nameColumn.Name = "PROPERTYNAME"; m_nameColumn.Width = 120; m_nameColumn.AllowResize = true; m_nameColumn.AllowDrag = true; m_nameColumn.BackColor = FCDraw.FCCOLORS_BACKCOLOR; addColumn(m_nameColumn); } break; case '3': //创建属性值列 if (m_valueColumn == null) { m_valueColumn = new GridColumnEx(); m_valueColumn.TextColor = FCDraw.FCCOLORS_TEXTCOLOR; m_valueColumn.Font = new FCFont("微软雅黑", 12, false, false, false); m_valueColumn.Text = "属性值"; m_valueColumn.Name = "PROPERTYVALUE"; m_valueColumn.Width = 120; m_valueColumn.AllowResize = true; m_valueColumn.AllowDrag = true; m_valueColumn.BackColor = FCDraw.FCCOLORS_BACKCOLOR; addColumn(m_valueColumn); } break; case '4': //创建英文属性列 if (m_enNameColumn == null) { m_enNameColumn = new GridColumnEx(); m_enNameColumn.TextColor = FCDraw.FCCOLORS_TEXTCOLOR; m_enNameColumn.Font = new FCFont("微软雅黑", 12, false, false, false); m_enNameColumn.Text = "英文名称"; m_enNameColumn.Name = "ENNAME"; m_enNameColumn.Width = 120; m_enNameColumn.AllowResize = true; m_enNameColumn.AllowDrag = true; m_enNameColumn.BackColor = FCDraw.FCCOLORS_BACKCOLOR; addColumn(m_enNameColumn); } break; } } }