public QuerySaleTime()
 {
     InitializeComponent();
     this.webBrowser.LoadCompleted += WebBrowser_LoadCompleted;
     //加载车站数据源
     try
     {
         TrainTicketManage.LoadedUserControlStation(this.tb_SaleStation);
         var dict = SystemCache.GetCache().GetObjByKey(Constant.AllSaleStation) as Dictionary <String, List <String> >;
         if (dict != null)
         {
             cbxSaleTime.ItemsSource = dict.Keys;
         }
         popStartStation.MouseEnter   += PopStartStation_MouseEnter;
         cbQueryItem.SelectionChanged += cbQuery_SelectionChanged;
         cbxSaleTime.SelectionChanged += cbxSaleTime_SelectionChanged;
         tkCurDate.Text = String.Format("今天是: {0}  [农历] {1}", DateTime.Now.ToString("yyyy-MM-dd dddd"), CalendarHelper.GetLunarDate(DateTime.Now));
         DateTime deadTime = Convert.ToDateTime(SystemCache.GetCache().GetObjByKey(Constant.OtherMaxdate));
         //DateTime deadTime = DateTime.Now.AddDays(30);
         tkDeadDate.Text = String.Format("暂售至: {0}  [农历] {1}", deadTime.ToString("yyyy-MM-dd dddd"), CalendarHelper.GetLunarDate(deadTime));
     }
     catch (Exception ex)
     {
         LogHelper.Error("加载失败!", ex);
     }
 }
 //根据输入车站名称模糊匹配站点
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (cbQueryItem.SelectedIndex == 2)//车次查询
     {
         //模拟浏览器页面导航
         string url = StringHelper.GetConfigValByKey(Constant.QueryTrainByNumber, false) + tb_TrainNo.Text.Trim();
         this.webBrowser.Navigate(new Uri(url));
         this.webBrowser.Height          = 600;
         stackTrainNumberInfo.Visibility = Visibility.Visible;
     }
     else
     {
         var dict = SystemCache.GetCache().GetObjByKey(Constant.AllSaleStation) as Dictionary <String, List <String> >;
         if (dict != null)
         {
             Station startStation = SystemCache.GetCache().GetTrainStation(tb_SaleStation.Text);
             if (startStation != null)
             {
                 StringBuilder sb    = new StringBuilder();
                 string        value = tb_SaleStation.Text.Trim();
                 List <String> list;
                 Dictionary <String, List <String> > dictTemp = new Dictionary <String, List <String> >();
                 bool has = false;
                 foreach (var itst in dict)
                 {
                     list = new List <string>();
                     foreach (var it in itst.Value)
                     {
                         if (it.Contains(value))
                         {
                             has = true;
                             list.Add(it);
                         }
                     }
                     if (has)
                     {
                         dictTemp.Add(itst.Key, list);
                     }
                     has = false;
                 }
                 foreach (var itemx in dictTemp)
                 {
                     foreach (var item in itemx.Value)
                     {
                         sb.AppendFormat("{0}:{1}   ", item, itemx.Key);
                     }
                 }
                 tkStationText.Text = sb.ToString();
             }
             else
             {
                 MessageBox.Show("站点不存在,请重新输入!", "信息", MessageBoxButton.OK, MessageBoxImage.Asterisk);
             }
         }
     }
 }
        //根据选择的时间段加载车站列表
        private void cbxSaleTime_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var dict = SystemCache.GetCache().GetObjByKey(Constant.AllSaleStation) as Dictionary <String, List <String> >;

            if (dict != null)
            {
                string[] stationArr = dict[cbxSaleTime.SelectedValue.ToString()].ToArray();
                stackSaleTimeTextCont.Text = String.Join("、", stationArr);
            }
        }
        public ActionResult RemoveRowToCached(string mrId, string itemId)
        {
            //读取缓存的数据
            List <string> ids = _systemCache.GetCache(mrId) as List <String>;

            if (ids == null)
            {
                ids = new List <string>();
            }
            ids.Add(itemId);
            _systemCache.SetCache(mrId, ids, new TimeSpan(1, 1, 0));
            return(Success("成功!"));
        }
        private void MyContract_Loaded(object sender, RoutedEventArgs e)
        {
            List <Passenger> passengerList = SystemCache.GetCache().GetObjByKey(Constant.PassengerList) as List <Passenger>;

            if (passengerList == null)
            {
                return;
            }
            foreach (var item in passengerList)
            {
                item.PassengerIDNo = StringHelper.ReplaceWithSpecialChar(item.PassengerIDNo, 6, 4, '*');
            }
            this.dataGridContracts.ItemsSource = passengerList;
        }
Пример #6
0
        public ActionResult FindCacheItem(string id)
        {
            var theData = _systemCache.GetCache <Sto_Material>(id);

            if (theData == null)
            {
                theData = new Sto_Material();
            }
            else
            {
                //清除缓存
                _systemCache.RemoveCache(id);
            }

            return(Content(theData.ToJson()));
        }
Пример #7
0
        public ActionResult FindCacheItem(string id)
        {
            id = "12345";
            var theData = _systemCache.GetCache <Pro_TemplateItem>(id);

            if (theData == null)
            {
                theData = new Pro_TemplateItem();
            }
            else
            {
                //清除缓存
                _systemCache.RemoveCache(id);
            }

            return(Content(theData.ToJson()));
        }
Пример #8
0
        private void Test_Loaded(object sender, RoutedEventArgs e)
        {
            List <Object> list = new List <object>();

            list.Add(new { dateTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") });
            list.Add(new { dateTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") });
            list.Add(new { dateTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") });
            list.Add(new { dateTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") });
            dataGrid.ItemsSource = list;


            string   url  = StringHelper.GetConfigValByKey(Constant.StartSaleTime, false);
            HttpItem item = new HttpItem()
            {
                URL = url
            };
            string ret  = TrainCommon.HttpRequest.HttpGet(item).ToString();
            string retx = StringHelper.GetValueBetween(ret, "<div id=\"pretime\">", "</div>");
            string temp = retx.Replace("<p>", "").Replace("</p>", "").Replace("<b>", "").Replace("</b>", "").Replace("&nbsp;", "").Replace("<br />", "").Trim();

            string[] tempArr = temp.Split('。');
            for (int i = 0; i < tempArr.Length - 1; i++)
            {
                string[] tempArr2 = tempArr[i].Trim().Replace("\n", "").Replace("起售车站", "$").Trim().Split('$');
                Dictionary <String, List <String> > dict = SystemCache.GetCache().GetObjByKey(Constant.AllSaleStation) as Dictionary <String, List <String> >;
                if (dict == null)
                {
                    dict = new Dictionary <String, List <String> >();
                }
                dict.Add(tempArr2[0].Trim(), tempArr2[1].Trim().Split('、').ToList());
                SystemCache.SetSysObj(Constant.AllSaleStation, dict);
            }

            Dictionary <String, List <String> > dict2 = SystemCache.GetCache().GetObjByKey(Constant.AllSaleStation) as Dictionary <String, List <String> >;

            cb1.ItemsSource       = dict2.Keys.ToList();
            cb1.SelectionChanged += Cb1_SelectionChanged;
        }
Пример #9
0
        private void Cb1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Dictionary <String, List <String> > dict2 = SystemCache.GetCache().GetObjByKey(Constant.AllSaleStation) as Dictionary <String, List <String> >;

            //string value = cb1.SelectedValue.ToString();
            //List<String> list2;
            //Dictionary<String, List<String>> dict3 = new Dictionary<String, List<String>>();
            //bool has = false;
            //foreach (var itst in dict2)
            //{
            //    list2 = new List<string>();
            //    foreach (var it in itst.Value)
            //    {
            //        if (it.Contains(value))
            //        {
            //            has = true;
            //            list2.Add(it);
            //        }
            //    }
            //    if (has) dict3.Add(itst.Key, list2);
            //    has = false;
            //}
            //StringBuilder sb = new StringBuilder();
            //foreach (var itemx in dict3)
            //{
            //    foreach (var itemm in itemx.Value)
            //    {
            //        sb.AppendFormat("{0}: {1}  ", itemx.Key, itemm);
            //    }
            //}
            //tkStationText.Text = sb.ToString();

            string[] stationArr = dict2[cb1.SelectedValue.ToString()].ToArray();
            string   ret2       = String.Join("、", stationArr);

            tkStationText.Text = ret2;
        }
Пример #10
0
        private void InitAllSaleStation()
        {
            string   url  = StringHelper.GetConfigValByKey(Constant.StartSaleTime, false);
            HttpItem item = new HttpItem()
            {
                URL = url
            };
            string ret  = TrainCommon.HttpRequest.HttpGet(item).ToString();
            string retx = StringHelper.GetValueBetween(ret, "<div id=\"pretime\">", "</div>");
            string temp = retx.Replace("<p>", "").Replace("</p>", "").Replace("<b>", "").Replace("</b>", "").Replace("&nbsp;", "").Replace("<br />", "").Trim();

            string[] tempArr = temp.Split('。');
            for (int i = 0; i < tempArr.Length - 1; i++)
            {
                string[] tempArr2 = tempArr[i].Trim().Replace("\n", "").Replace("起售车站", "$").Trim().Split('$');
                Dictionary <String, List <String> > dict = SystemCache.GetCache().GetObjByKey(Constant.AllSaleStation) as Dictionary <String, List <String> >;
                if (dict == null)
                {
                    dict = new Dictionary <String, List <String> >();
                }
                dict.Add(tempArr2[0].Trim(), tempArr2[1].Trim().Split('、').ToList());
                SystemCache.SetSysObj(Constant.AllSaleStation, dict);
            }
        }
Пример #11
0
        /// <summary>
        /// 异步登录验证
        /// </summary>
        private async void Process()
        {
            try
            {
                _timer.Start();
                string url  = StringHelper.GetConfigValByKey(Constant.VerifyCodeUrl, false) + "&" + new Random().NextDouble().ToString() + new Random().Next(0, 10);
                string path = StringHelper.VirtualPath;
                //path = client.HttpGet(url, path).ToString();
                path = HttpRequest.HttpGet(url, path).ToString();
                VerifyCode verifyForm = new VerifyCode(path)
                {
                    _loginWindow = this
                };
                verifyForm.ChangeTextEvent += VerifyForm_ChangeTextEvent;
                bool?close = verifyForm.ShowDialog();
                if (close != null && ((Boolean)close && callBack)) //仅仅点击提交按钮并且验证通过表示登录成功
                {
                    _loginStatus = "正在登录";
                    Dictionary <String, String> parames = new Dictionary <string, string>()
                    {
                        { "username", UserName },
                        { "password", Password },
                        { "appid", "otn" }
                    };
                    string loginUrl = StringHelper.GetConfigValByKey("LOGINURL", false);
                    //string ret = client.HttpPost(loginUrl, parames).ToString();
                    await Task.Run(() =>
                    {
                        HttpItem item = new HttpItem()
                        {
                            URL      = loginUrl,
                            PostData = parames,
                            Cookie   = HttpRequest.BeforLoginCookie
                        };
                        string ret    = HttpRequest.HttpPost(item).ToString();
                        BackData back = JsonConvert.DeserializeObject <BackData>(ret);

                        /**************************************************************************************************************
                         * { "result_message":"密码输入错误。如果输错次数超过4次,用户将被锁定。","result_code":1 }
                         * { "result_message":"登录名不存在。","result_code":1 }
                         * { "result_message":"登录成功","result_code":0,"uamtk":"tWDQtPie_z22IWMknmFOymUpDRzvLE4CfzREJBzS9NwrwL2L0" }
                         *************************************************************************************************************/
                        if (back == null)//校验失败
                        {
                            back = new BackData()
                            {
                                result_code = "-1", result_message = "校验失败", uamtk = "ABCD"
                            };
                        }

                        if (back.result_code == "0") //登录成功
                        {
                            _timer.Stop(); _timer.Dispose();
                            if (SystemCache.GetCache().GetObjByKey(Constant.AppToken) == null)
                            {
                                this.AuthClient(back.uamtk); //初始化验证信息
                            }
                            if (SystemCache.GetCache().GetObjByKey(Constant.JSessionCookieID) == null)
                            {
                                this.MakeClientJSession();
                            }
                            if (SystemCache.GetCache().GetObjByKey(Constant.LeftTicketQueryUrl) == null)
                            {
                                this.InitLeftTicketQueryUrl();
                            }

                            Dispatcher.Invoke(() =>
                            {
                                this.btnLogin.Content = "登 录 成 功";
                                this.Hide();
                                MainWindow main   = new MainWindow();
                                main._loginWindow = this;
                                main.Show();
                                this.UserName = this.tbUserName.Text.Trim();
                                this.Password = this.tbPassword.Password.Trim();
                            });
                            //缓存用户名密码
                            StringHelper.SetConfig(Constant.UserName, UserName);
                            StringHelper.SetConfig(Constant.Password, Password);
                            LogHelper.Log(new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name, back.result_message);
                        }
                        else //登录失败
                        {
                            _timer.Stop(); _timer.Dispose();
                            MessageBox.Show(back.result_message, "信息", MessageBoxButton.OK, MessageBoxImage.Warning);
                            Dispatcher.Invoke(() =>
                            {
                                this.btnLogin.Content    = "登    录";
                                this.btnLogin.Foreground = Brushes.Black;
                            });
                        }
                    });

                    ChangeUserNameReadOnly(false);
                }
                //仅仅手动关闭验证码窗口
                if (close != null && ((Boolean)close) && !callBack && isManualClose)
                {
                    Dispatcher.Invoke(() => ChangeUserNameReadOnly(false));
                }
            }
            catch (Exception ex)
            {
                //登录失败
                MessageBox.Show(ex.Message, "信息", MessageBoxButton.OK, MessageBoxImage.Warning);
                Process();

                LogHelper.Error(ex);
            }
        }