示例#1
0
        public static List<ConfigList> ReadConfigFromDisk_ConfigList(string file)
        {
            try
            {
                using (Stream stream = File.Open(file, FileMode.Open))
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    List<ConfigList> lst=formatter.Deserialize(stream) as List<ConfigList>;

                    DesCryption dc = new DesCryption();

                    List<ConfigList> tmpList = new List<ConfigList>();
                    foreach (ConfigList v in lst)
                    {
                        ConfigList cl = v;
                        System.Collections.Hashtable ht = new System.Collections.Hashtable();
                        foreach (var x in v.Passengers.Keys)
                        {
                            string tmp = x.ToString();
                            tmp = dc.DecryptString(x.ToString(), "A1B3C5D7");
                            aNyoNe.GetInfoFrom12306.Nomal_Passengers pd = new aNyoNe.GetInfoFrom12306.Nomal_Passengers();
                            pd = (aNyoNe.GetInfoFrom12306.Nomal_Passengers)(v.Passengers[x]);
                            pd.Passenger_id_no = dc.DecryptString(pd.Passenger_id_no, "A1B3C5D7");
                            pd.Passenger_name = dc.DecryptString(pd.Passenger_name, "A1B3C5D7");
                            ht.Add(tmp, pd);
                        }
                        cl.Passengers = ht;
                        tmpList.Add(cl);
                    }

                    return tmpList;
                }
            }
            catch
            {
                return new List<ConfigList>();
            }
        }
示例#2
0
        public static List <ConfigList> ReadConfigFromDisk_ConfigList(string file)
        {
            try
            {
                using (Stream stream = File.Open(file, FileMode.Open))
                {
                    BinaryFormatter   formatter = new BinaryFormatter();
                    List <ConfigList> lst       = formatter.Deserialize(stream) as List <ConfigList>;

                    DesCryption dc = new DesCryption();

                    List <ConfigList> tmpList = new List <ConfigList>();
                    foreach (ConfigList v in lst)
                    {
                        ConfigList cl = v;
                        System.Collections.Hashtable ht = new System.Collections.Hashtable();
                        foreach (var x in v.Passengers.Keys)
                        {
                            string tmp = x.ToString();
                            tmp = dc.DecryptString(x.ToString(), "A1B3C5D7");
                            aNyoNe.GetInfoFrom12306.Nomal_Passengers pd = new aNyoNe.GetInfoFrom12306.Nomal_Passengers();
                            pd = (aNyoNe.GetInfoFrom12306.Nomal_Passengers)(v.Passengers[x]);
                            pd.Passenger_id_no = dc.DecryptString(pd.Passenger_id_no, "A1B3C5D7");
                            pd.Passenger_name  = dc.DecryptString(pd.Passenger_name, "A1B3C5D7");
                            ht.Add(tmp, pd);
                        }
                        cl.Passengers = ht;
                        tmpList.Add(cl);
                    }

                    return(tmpList);
                }
            }
            catch
            {
                return(new List <ConfigList>());
            }
        }
示例#3
0
        private void formLogin_Load(object sender, EventArgs e)
        {
            try
            {
                string path = Environment.SystemDirectory + "\\drivers\\etc\\hosts";
                if (System.IO.File.Exists(path))
                {
                    var hostAction = new HostAction(path);
                    hostAction.RestoreHosts();
                }
                else
                {
                    this.btnSwitchServer.Enabled = false;
                    formSelectTicket.hostEnable  = false;
                    MessageBox.Show("没有找到hosts文件,请新建后重新启动本程序以恢复自动切换功能,否则切换功能将不可用.", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex) {
                formSelectTicket.hostEnable = false;
                MessageBox.Show(string.Format("由于加载Hosts文件失败,失败原因:{0}\r\n可能导致软件的IP切换功能无效,如果想启用,请允许程序访问Hosts文件或者去除Hosts文件的保护,然后重新启动本程序", ex.Message), "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            GetAutoCompleteSource();
            if (_nameSource != null)
            {
                cboName.Items.AddRange(_nameSource);
            }


            var dc = new DesCryption();

            cboName.Text = ConfigInfo.conf.username;
            if (cboName.Text != string.Empty)
            {
                txtPwd.Text = dc.DecryptString(ConfigInfo.conf.password, ConfigInfo.conf.username);
            }
        }