Ejemplo n.º 1
0
        /// <summary>保存用户配置信息</summary>
        /// <param name="uc">用户信息</param>
        public static void SaveSysConfig(UserConfig uc)
        {
            string ulpath = wapp.AppList.SaveConfigPath + UserLoginTable.TableName + ".xml";
            string ucpath = wapp.AppList.SaveConfigPath + UserConifgTable.TableName + ".xml";

            if (File.Exists(ulpath))
            {
                File.Delete(ulpath);
            }
            if (File.Exists(ucpath))
            {
                File.Delete(ucpath);
            }
            for (int i = 0; i < UserLoginTable.Rows.Count; i++)
            {
                UserLoginTable.Rows[i]["IsUser"] = 0;
            }
            if (uc.UserName != "")
            {
                string    pwd = TripleDes.DesEn(uc.UserPwd.Trim(), wapp.AppList.DeKey).Trim();
                DataRow[] dr  = UserLoginTable.Select("UserName='******'");
                if (dr.Length > 0)
                {
                    dr[0]["UserPwd"] = pwd;
                    dr[0]["IsUser"]  = 1;
                }
                else
                {
                    DataRow newRow = UserLoginTable.NewRow();
                    newRow["UserName"] = uc.UserName;
                    newRow["UserPwd"]  = pwd;
                    newRow["IsUser"]   = 1;
                    UserLoginTable.Rows.Add(newRow);
                }
                DataRow[] drc = UserConifgTable.Select("UserName='******'");
                if (drc.Length > 0)
                {
                    drc[0]["IsSave"]    = uc.IsSave;
                    drc[0]["AutoStat"]  = uc.AutoStat;
                    drc[0]["AutoLogin"] = uc.AutoLogin;
                }
                else
                {
                    DataRow newRow = UserConifgTable.NewRow();
                    newRow["UserName"]  = uc.UserName;
                    newRow["IsSave"]    = uc.IsSave;
                    newRow["AutoStat"]  = uc.AutoStat;
                    newRow["AutoLogin"] = uc.AutoLogin;
                    UserConifgTable.Rows.Add(newRow);
                }
            }
            UserLoginTable.WriteXml(ulpath, XmlWriteMode.WriteSchema);
            UserConifgTable.WriteXml(ucpath, XmlWriteMode.WriteSchema);
        }
Ejemplo n.º 2
0
        /// <summary>根据筛选值返回默认用户配置信息</summary>
        /// <param name="sel">筛选值</param>
        /// <returns>根据筛选值返回默认用户配置信息</returns>
        public static UserConfig GetSelectUserConfig(string sel)
        {
            UserConfig uc = new UserConfig();

            if (UserLoginTable.Rows.Count > 0)
            {
                DataRow[] dr = UserLoginTable.Select(sel);
                if (dr.Length > 0)
                {
                    uc.UserName = dr[0]["UserName"].ToString().Trim();
                    uc.UserPwd  = TripleDes.DesDe(dr[0]["UserPwd"].ToString().Trim(), wapp.AppList.DeKey).Trim();
                    if (dr[0]["IsUser"].ToString().Trim() == "1")
                    {
                        uc.IsUser = 1;
                    }
                    if (UserConifgTable.Rows.Count > 0)
                    {
                        DataRow[] drc = UserConifgTable.Select("UserName='******'");
                        if (drc.Length > 0)
                        {
                            if (drc[0]["IsSave"].ToString().Trim() == "1")
                            {
                                uc.IsSave = 1;
                            }
                            if (drc[0]["AutoLogin"].ToString().Trim() == "1")
                            {
                                uc.AutoLogin = 1;
                            }
                            if (drc[0]["AutoStat"].ToString().Trim() == "1")
                            {
                                uc.AutoStat = 1;
                            }
                        }
                    }
                }
            }
            return(uc);
        }