Esempio n. 1
0
        public static void WriteConfigToDisk(string file, List <ConfigList> cookieJar)
        {
            DesCryption dc = new DesCryption();

            List <ConfigList> tmpList = new List <ConfigList>();

            foreach (ConfigList v in cookieJar)
            {
                ConfigList cl = v;
                System.Collections.Hashtable ht = new System.Collections.Hashtable();
                foreach (var x in v.Passengers.Keys)
                {
                    string tmp = x.ToString();
                    tmp = dc.EncryptString(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.EncryptString(pd.Passenger_id_no, "A1B3C5D7");
                    pd.Passenger_name  = dc.EncryptString(pd.Passenger_name, "A1B3C5D7");
                    ht.Add(tmp, pd);
                }
                cl.Passengers = ht;
                tmpList.Add(cl);
            }
            using (Stream stream = File.Create(file))
            {
                try
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(stream, tmpList);
                }
                catch
                {
                }
            }
        }
Esempio n. 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>());
            }
        }
Esempio n. 3
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>();
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public static void WriteConfigToDisk(string file, List<ConfigList> cookieJar)
        {
            DesCryption dc=new DesCryption();

            List<ConfigList> tmpList = new List<ConfigList>();
            foreach (ConfigList v in cookieJar)
            {
                ConfigList cl = v;
                System.Collections.Hashtable ht = new System.Collections.Hashtable();
                foreach (var x in v.Passengers.Keys)
                {
                    string tmp=x.ToString();
                    tmp = dc.EncryptString(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.EncryptString(pd.Passenger_id_no, "A1B3C5D7");
                    pd.Passenger_name = dc.EncryptString(pd.Passenger_name, "A1B3C5D7");
                    ht.Add(tmp, pd);
                }
                cl.Passengers = ht;
                tmpList.Add(cl);
            }
            using (Stream stream = File.Create(file))
            {
                try
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(stream, tmpList);
                }
                catch
                {
                }
            }
        }
Esempio n. 6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            lblInfomation.Text = "";
            if (cboName.Text.Length < 4)
            {
                return;
            }
            if (txtPwd.Text.Length < 4)
            {
                return;
            }
            if (txtRandCode.TextLength < 4)
            {
                return;
            }
            btnLogin.Enabled = false;
            btnLogin.Text    = "正在登录";
            Application.DoEvents();
            string name     = cboName.Text;
            string pwd      = txtPwd.Text;
            var    htmlTran = new HTML_Translation();

            //采用同步方式登录
            _la.PostData = string.Format(@"loginUserDTO.user_name={0}&userDTO.password={1}&randCode={2}",
                                         name, pwd, txtRandCode.Text);
            var    strHash = _la.BeginLogin();
            string strHtml = "";
            var    cookie  = new CookieContainer();

            if (strHash == null)
            {
                MessageBox.Show("难道12306又挂了?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                return;
            }
            foreach (var v in strHash.Keys)
            {
                cookie  = (CookieContainer)v;
                strHtml = strHash[v].ToString();
                break;
            }
            if (strHtml == "")
            {
                lblInfomation.Text = "登录失败!";
                btnLogin.Enabled   = true;
                btnLogin.Text      = "登录";
                txtRandCode.Focus();
                GetRandCodeImg();
                return;
            }
            try
            {
                var returnString = htmlTran.TranslationHtmlEx(strHtml);
                if (returnString["messages"].Any())
                {
                    GetRandCodeImg();
                    DeterMineCall(() =>
                    {
                        lblInfomation.Text = returnString["messages"][0].ToString();
                        this.BeginInvoke(new Action(FormShake));
                        txtRandCode.Text = "";
                        btnLogin.Enabled = true;
                        btnLogin.Text    = "登录";
                        txtRandCode.Focus();
                        Application.DoEvents();
                    });
                    return;
                }
                //var loginCheck = returnString["data"] as JavaScriptObject;
                if (returnString["data"] != null && returnString["data"]["loginCheck"].ToString() == "Y")
                {
                    if (chkUserInfo.Checked)
                    {
                        var dc = new DesCryption();
                        ConfigInfo.conf.username = name;
                        ConfigInfo.conf.password = dc.EncryptString(pwd, name);

                        ConfigInfo.savetofile(ConfigInfo.conf.username);
                        string path = AppDomain.CurrentDomain.BaseDirectory + "data\\" + name;
                        if (!System.IO.Directory.Exists(path))
                        {
                            System.IO.Directory.CreateDirectory(path);
                        }
                        LocalCookie.WriteCookiesToDisk(path + "\\usrCookie.cfg", LoginAction.cookieContainer);
                    }

                    btnLogin.Enabled = true;
                    btnLogin.Text    = "登录";
                    this.Hide();
                    //                MessageBox.Show(@"温馨提示:
                    //
                    //1. 自2013年1月4日起,火车票互联网、电话订票预售期延长至20天(含当日),代售点和车站部分售票窗口预售期延长至18天(含当日)。
                    //
                    //2. 自2013年1月1日起,通过电话预订车票的旅客可凭订票时乘车人有效身份证件,到全国任一车站窗口或代售点换取已订车票。当日12:00前已订车票于第二日12:00前取有效;当日12:00后已订车票于第二日24:00前取有效。
                    //
                    //
                    //请广大旅客注意电话订票取票时间和范围、互联网和电话订票起售时间、火车票预售期的变化,合理安排好购票计划。", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    var selectForm = new formSelectTicket(cookie)
                    {
                        ThisCookie = cookie,
                        /*formSelectTicket.cookieContainer = cookie;*/
                        UserName = cboName.Text
                    };
                    selectForm.Show();
                }
                else
                {
                    GetRandCodeImg();
                    lblInfomation.Text = "登录失败";
                    txtRandCode.Text   = "";
                    btnLogin.Enabled   = true;
                    btnLogin.Text      = "登录";
                    txtRandCode.Focus();
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("23:00至07:00为系统维护时间!", "温馨提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            finally { }
        }