Пример #1
0
        public static void WriteHistoryToFile(string key)
        {
            string strLine = "", Line = "";

            try
            {
                key = MyEncrypt.EncryptA(key);
                string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                dir = dir + "\\sys\\a\\";
                string       inFile = dir + "Log2.dat";
                StreamReader sr     = new StreamReader(inFile);
                strLine = sr.ReadLine();
                while (strLine != null && strLine.Length > 7520)
                {
                    Line   += strLine + "\r\n";
                    strLine = sr.ReadLine();
                }
                sr.Close();
                strLine = MyEncrypt.GetStrByLength(3295) + key + MyEncrypt.GetStrByLength(4215);
                FileStream   aFile = new FileStream(inFile, FileMode.OpenOrCreate);
                StreamWriter sw    = new StreamWriter(aFile);
                Line += strLine + "\r\n";
                sw.WriteLine(Line);
                sw.Close();;
            }
            catch (IOException ex)
            {
            }
        }
Пример #2
0
        public static void WriteLogsToFile(string key)
        {
            string strLine = "";

            try
            {
                string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                dir = dir + "\\sys\\a\\";
                string inFile = dir + "Log.dat";
                key     = MyEncrypt.EncryptA(key);
                strLine = MyEncrypt.GetStrByLength(5295) + key + MyEncrypt.GetStrByLength(5215);
                FileStream   aFile = new FileStream(inFile, FileMode.OpenOrCreate);
                StreamWriter sw    = new StreamWriter(aFile);
                sw.WriteLine(strLine);
                sw.Close();;
            }
            catch (IOException ex)
            {
            }
        }
Пример #3
0
        public static string CreateKey(string info, string s)
        {
            string     mw16 = MyEncrypt.GetMd5_16(info, true);
            string     mw32 = MyEncrypt.GetMD5(info);
            List <int> i41  = MyEncrypt.GenerateNumber(4, 16);
            List <int> i42  = MyEncrypt.GenerateNumber(4, 32);

            mw16 = MyEncrypt.getRjCode(i41, MyEncrypt.split(mw16));
            mw32 = MyEncrypt.getRjCode(i42, MyEncrypt.split(mw32));
            string date = DateTime.Now.Year + bu0(DateTime.Now.Month) + bu0(DateTime.Now.Day);

            return(ListToString(i41) + MyEncrypt.FanZhuan(MyEncrypt.getNumChar(s)) + ListToString(i42) + MyEncrypt.FanZhuan(MyEncrypt.EncryptA(date)) + mw16 + mw32);
        }
Пример #4
0
        public static void SaveConfig()
        {
            Program.mainForm.ShowMessage("正在保存系统配置...", false);
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(xmlPath);
            XmlElement root = xmlDoc.DocumentElement;

            root.RemoveAll();

            XmlElement one = xmlDoc.CreateElement("library");
            XmlElement two = null;

            /** 特征库设置 **/
            foreach (Libaray lib in libarays)
            {
                two = xmlDoc.CreateElement("lib");
                two.SetAttribute("id", lib.id);
                two.SetAttribute("status", "" + lib.status);
                two.InnerText = lib.name;
                one.AppendChild(two);
            }
            //在节点中添加元素
            root.AppendChild(one);

            /** 用户设置 **/
            one = xmlDoc.CreateElement("users");
            ArrayList userArray = new ArrayList(userTable.Keys);
            User      user      = null;

            foreach (String acc in userArray)
            {
                user = (User)userTable[acc];
                two  = xmlDoc.CreateElement("user");
                two.SetAttribute("acc", user.Acc);
                two.SetAttribute("pwd", MyEncrypt.EncryptA(user.Pwd));
                two.SetAttribute("status", "" + user.Status);
                two.InnerText = user.Name;
                one.AppendChild(two);
            }
            //在节点中添加元素
            root.AppendChild(one);

            /** 皮肤设置 **/
            one           = xmlDoc.CreateElement("skin");
            one.InnerText = skin;
            //在节点中添加元素
            root.AppendChild(one);

            /** 是否开机启动设置 **/
            one           = xmlDoc.CreateElement("start");
            one.InnerText = startType;
            //在节点中添加元素
            root.AppendChild(one);

            /** 更新设置 **/
            one           = xmlDoc.CreateElement("update");
            one.InnerText = updateType;
            //在节点中添加元素
            root.AppendChild(one);

            /** 算法设置 **/
            one           = xmlDoc.CreateElement("algorithm");
            one.InnerText = algorithm;
            //在节点中添加元素
            root.AppendChild(one);

            /** 购票成功后是否报警设置 **/
            one           = xmlDoc.CreateElement("isAutoBaojing");
            one.InnerText = Convert.ToString(isAutoBaojing);
            //在节点中添加元素
            root.AppendChild(one);

            /** 是否自动输入验证码设置 **/
            one           = xmlDoc.CreateElement("isAutoWriterVerify");
            one.InnerText = Convert.ToString(isAutoWriterVerify);
            //在节点中添加元素
            root.AppendChild(one);

            /** 失败N次数后改为手动输入验证码设置 **/
            one           = xmlDoc.CreateElement("failedTimes");
            one.InnerText = Convert.ToString(failedTimes);
            //在节点中添加元素
            root.AppendChild(one);

            if (fromCity != null && !fromCity.Equals(""))
            {
                /** 出发站设置 **/
                one           = xmlDoc.CreateElement("fromCity");
                one.InnerText = fromCity;
                //在节点中添加元素
                root.AppendChild(one);
            }
            if (toCity != null && !toCity.Equals(""))
            {
                /** 到达站设置 **/
                one           = xmlDoc.CreateElement("toCity");
                one.InnerText = toCity;
                //在节点中添加元素
                root.AppendChild(one);
            }
            if (islocalhost)
            {
                /** 设置 **/
                one           = xmlDoc.CreateElement("islocalhost");
                one.InnerText = Convert.ToString(islocalhost);
                //在节点中添加元素
                root.AppendChild(one);
            }

            if (currVersion != null)
            {
                /** 版本号设置 **/
                one           = xmlDoc.CreateElement("currVersion");
                one.InnerText = currVersion;
                //在节点中添加元素
                root.AppendChild(one);
            }

            if (!String.IsNullOrEmpty(bbsUser))
            {
                /** bbs用户名设置 **/
                one           = xmlDoc.CreateElement("bbsUser");
                one.InnerText = bbsUser;
                //在节点中添加元素
                root.AppendChild(one);
            }

            if (!String.IsNullOrEmpty(bbsPwd))
            {
                /** bbs密码设置 **/
                one           = xmlDoc.CreateElement("bbsPwd");
                one.InnerText = MyEncrypt.EncryptA(bbsPwd);
                //在节点中添加元素
                root.AppendChild(one);
            }

            //保存
            xmlDoc.Save(xmlPath);
            Program.mainForm.ShowMessage("完成");
        }