示例#1
0
        /// <summary>
        /// 生成下拉选择语言列表
        /// </summary>
        /// <returns>生成下拉选择语言列表</returns>
        public static string cboLangList()
        {
            string  LangConfigFile     = LangPath + "langConfig.inf";
            IniFile ini                = new IniFile(LangConfigFile);
            string  DefaultLang        = ini.ReadValue("Language", "DefaultLang");
            string  CookiesDefaultLang = ini.ReadValue("Language", "CookiesDefaultLang");

            string _value = string.Empty;

            if (DefaultLang.Equals("Cookies"))
            {
                DefaultLang = Cookie2.Get("Lang", "Default").Trim().Base64Decode();
                if (DefaultLang.Trim().Equals(string.Empty))
                {
                    DefaultLang = CookiesDefaultLang;
                }
                _value = "<select name=\"cboLangList\" onchange=\"window.location='changeLang.aspx?lang=' + this.value\">";
                string[] LangArr = GetLangList();
                for (int i = 1; i < LangArr.Length; i++)
                {
                    _value += "<option value=\"" + LangArr[i] + "\" " + Selected(DefaultLang, LangArr[i]) + ">" + LangArr[i] + "</option>";
                }
                _value += "</select>";
            }
            return(_value);
        }
示例#2
0
        /// <summary>
        /// 判断是否在指定多少秒内提交数据,来达到判断是否刷新页面的目的
        /// </summary>
        /// <param name="seconds">多少秒内</param>
        /// <returns>是/否</returns>
        public static bool IsRefresh(int seconds)
        {
            string _sysTime = Cookie2.Get("__sysTime");

            if (_sysTime.Trim() == "")
            {
                return(true);
            }
            if (!_sysTime.IsDateTime())
            {
                return(true);
            }
            DateTime _startTime = DateTime.Parse(_sysTime);
            DateTime _endTime   = DateTime.Now;
            TimeSpan _value     = _startTime.GetTimeSpan(_endTime);

            if (_value.Seconds >= seconds)
            {
                return(false);
            }
            else
            {
                Js.Alert("不允许刷新,或快速提交数据,请" + seconds.ToString() + "秒后提交数据。");
                return(true);
            }
        }
示例#3
0
        /// <summary>
        /// 返回消息
        /// </summary>
        /// <param name="frmName">WINFORM</param>
        /// <param name="section">section</param>
        /// <param name="key">key</param>
        /// <returns>返回消息</returns>
        public static string Msg(string frmName, string section, string key)
        {
            if (frmName.Equals(string.Empty))
            {
                return(string.Empty);
            }
            string  LangConfigFile     = LangPath + "langConfig.inf";
            IniFile ini                = new IniFile(LangConfigFile);
            string  DefaultLang        = ini.ReadValue("Language", "DefaultLang");
            string  CookiesDefaultLang = ini.ReadValue("Language", "CookiesDefaultLang");

            if (DefaultLang.Equals("Cookies"))
            {
                DefaultLang = Cookie2.Get("Lang", "Default").Trim().Base64Decode();
            }
            if (DefaultLang.Trim().Equals(string.Empty))
            {
                LangConfigFile = LangPath + CookiesDefaultLang + "\\" + frmName + ".ini";
            }
            else
            {
                LangConfigFile = LangPath + DefaultLang + "\\" + frmName + ".ini";
            }
            //Pub.Class.Msg.Write(LangConfigFile);
            ini = new IniFile(LangConfigFile);
            string msgValue = ini.ReadValue("system", "msgExit");

            return(msgValue);
        }
示例#4
0
        /// <summary>
        /// 取得运算随机字符串,并设置Session值
        /// </summary>
        public static void IdentifyCode2()
        {
            string[] number1 = new string[] { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" };
            string[] number2 = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
            string[] operate = new string[] { "加", "减" };
            string[] equals  = new string[] { "=", "等于" };

            IList <string[]> number = new List <string[]>();

            number.Add(number1);
            number.Add(number2);

            Random r      = new Random();
            int    num1   = r.Next(1, 11);
            int    num2   = r.Next(1, 11);
            int    result = 0;

            int operation = r.Next(0, 2);

            if (operation == 0)
            {
                result = num1 + num2;
            }
            else
            {
                if (num1 < num2)
                {
                    int num3 = 0;

                    num3 = num1;
                    num1 = num2;
                    num2 = num3;
                }
                result = num1 - num2;
            }

            string checkCode = string.Empty;

            checkCode  = ((string[])number[r.Next(0, 2)])[num1 - 1];
            checkCode += operate[operation];
            checkCode += ((string[])number[r.Next(0, 2)])[num2 - 1];
            checkCode += equals[r.Next(0, 2)];
            checkCode += "?";

            Cookie2.Set("IdentifyCode", result.ToString());

            DrawIdentifyCode2(checkCode);
        }
示例#5
0
        /// <summary>
        /// 返回所有语言文件列表 0为当前使用的语言
        /// </summary>
        /// <returns>返回所有语言文件列表 0为当前使用的语言</returns>
        public static string[] GetLangList()
        {
            DirectoryInfo Folder = new DirectoryInfo(LangPath);

            FileInfo[] subFiles = Folder.GetFiles();
            string     fileList = string.Empty;

            string  LangConfigFile = LangPath + "langConfig.inf";
            IniFile ini            = new IniFile(LangConfigFile);
            string  DefaultLang    = ini.ReadValue("Language", "DefaultLang");
            string  firstLang      = string.Empty;

            for (int j = 0; j < subFiles.Length; j++)
            {
                if (subFiles[j].Extension.ToLower().Equals(".ini"))
                {
                    firstLang = subFiles[0].Name.Substring(0, subFiles[0].Name.Length - 4);
                    fileList += subFiles[j].Name.Substring(0, subFiles[j].Name.Length - 4) + "|";
                }
            }

            if (DefaultLang.Equals("Cookies"))
            {
                DefaultLang = Cookie2.Get("Lang", "Default").Trim().Base64Decode();
                if (!DefaultLang.Equals(string.Empty))
                {
                    fileList = DefaultLang + "|" + fileList;
                }
                else
                {
                    fileList = firstLang + "|" + fileList;
                }
            }
            else
            {
                fileList = DefaultLang + "|" + fileList;
            }
            return(fileList.TrimEnd('|').Split('|'));
        }
示例#6
0
        //#endregion
        //#region IdentifyCode
        /// <summary>
        /// 取得随机字符串,并设置Session值
        /// </summary>
        /// <example>
        /// <code>
        ///     string strIdentifyCode = Pub.Class.Identify.IdentifyCode(4);
        ///     Pub.Class.Identify.DrawIdentifyCode(strIdentifyCode, 50, 100);
        ///     Response.End();
        ///     在登录页面引用此文件:&lt;img src="Valid.aspx"  border="0" />
        ///     Session["IdentifyCode"]
        /// </code>
        /// </example>
        /// <param name="intLength">长</param>
        /// <returns>取得随机字符串</returns>
        public static string IdentifyCode(int intLength)
        {
            int    intNumber;
            char   chrCode;
            string strIdentifyCode = String.Empty;
            Random rndRandom       = new Random();

            for (int i = 0; i < intLength; i++)
            {
                intNumber = rndRandom.Next();
                if (intNumber % 2 == 0)
                {
                    chrCode = (char)('0' + (char)(intNumber % 10));//如果随机数是偶数 取余
                }
                else
                {
                    chrCode = (char)('A' + (char)(intNumber % 26));//如果随机数是奇数 选择从[A-Z]
                }
                strIdentifyCode += chrCode.ToString();
            }
            Cookie2.Set("IdentifyCode", strIdentifyCode);
            return(strIdentifyCode);
        }
示例#7
0
 //#endregion
 //#region COOKIES防刷新页面代码
 /// <summary>
 /// 设置打开页面的时间
 /// </summary>
 public static void SetDateTime()
 {
     Cookie2.Set("__sysTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
 }