Пример #1
0
        private void btnDownload_btnPausing_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;

            // 先撈一次MeetingData
            MouseTool.ShowLoading();
            //GetMeetingData.AsyncPOST(userMeeting.ID, UserID, UserPWD, (md) => { GetMeetingData_DoAction(md,(Image)sender); });
            if (NetworkTool.CheckNetwork() > 0)
            {
                GetMeetingData.AsyncPOST(userMeeting.ID, UserID, UserPWD, (md) => { GetMeetingData_DoAction(md, (Image)sender); });
            }
            else
            {
                //DB查詢登入
                DataTable dt = MSCE.GetDataTable("select MeetingJson from MeetingData where MeetingID=@1 and UserID =@2"
                                                 , userMeeting.ID
                                                 , UserID);

                if (dt.Rows.Count > 0)
                {
                    MeetingData md = JsonConvert.DeserializeObject <MeetingData>(dt.Rows[0]["MeetingJson"].ToString());
                    GetMeetingData_DoAction(md, (Image)sender);
                }
                else
                {
                    AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
                    MouseTool.ShowArrow();
                }
            }
        }
Пример #2
0
        private void InitUI()
        {
            Action <LawData> action = null;

            MouseTool.ShowLoading();
            LawCT_Title.Text = Settings.Default.LawButtonName;
            new HttpRequest();
            if (NetworkTool.CheckNetwork() > 0)
            {
                if (action == null)
                {
                    action = new Action <LawData>(_003CInitUI_003Eb__1b);
                }
                GetLawData.AsyncPOST(action);
                return;
            }
            DataTable dataTable = MSCE.GetDataTable("select LawJson from LawData");

            if (dataTable.Rows.Count > 0)
            {
                LawData ld = JsonConvert.DeserializeObject <LawData>(dataTable.Rows[0]["LawJson"].ToString());
                GetLawData_DoAction(ld);
            }
            else
            {
                AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
                MouseTool.ShowArrow();
            }
        }
        private void btnDownload_btnPausing_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Action <MeetingData>        action = null;
            _003C_003Ec__DisplayClass21 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass21();

            _003C_003Ec__DisplayClass.sender            = sender;
            _003C_003Ec__DisplayClass._003C_003E4__this = this;
            e.Handled = true;
            MouseTool.ShowLoading();
            if (NetworkTool.CheckNetwork() > 0)
            {
                string iD      = userMeeting.ID;
                string userID  = UserID;
                string userPWD = UserPWD;
                if (action == null)
                {
                    action = new Action <MeetingData>(_003C_003Ec__DisplayClass._003CbtnDownload_btnPausing_MouseLeftButtonDown_003Eb__1f);
                }
                GetMeetingData.AsyncPOST(iD, userID, userPWD, action);
            }
            else
            {
                DataTable dataTable = MSCE.GetDataTable("select MeetingJson from MeetingData where MeetingID=@1 and UserID =@2", userMeeting.ID, UserID);
                if (dataTable.Rows.Count > 0)
                {
                    MeetingData md = JsonConvert.DeserializeObject <MeetingData>(dataTable.Rows[0]["MeetingJson"].ToString());
                    GetMeetingData_DoAction(md, (Image)_003C_003Ec__DisplayClass.sender);
                }
                else
                {
                    AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
                    MouseTool.ShowArrow();
                }
            }
        }
Пример #4
0
        private void InitUI()
        {
            MouseTool.ShowLoading();
            //LawCT_Title.Text = MyPL.Properties.Settings.Default.LawButtonName;
            txtTitle.Text = ButtonName;
            //Network.HttpRequest hr = new Network.HttpRequest();
            if (1 == 1 || NetworkTool.CheckNetwork() > 0)
            {
                // 非同步POST方法
                //GetLawData.AsyncPOST((ld) => { GetLawData_DoAction(ld); });
                GetUserFolder.AsyncPOST(UserID, UserPWD, (fd) => { GetUserFolder_DoAction(fd); });
                //, () => { this.Dispatcher.BeginInvoke(new Action(() => { AutoClosingMessageBox.Show("無法取得資料,請稍後再試"); })); });
            }
            else
            {
                DataTable dt = MSCE.GetDataTable("select LawJson from LawData");


                if (dt.Rows.Count > 0)
                {
                    LawData ld = JsonConvert.DeserializeObject <LawData>(dt.Rows[0]["LawJson"].ToString());
                    GetLawData_DoAction(ld);
                }
                else
                {
                    AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
                    MouseTool.ShowArrow();
                }
            }



            #region  步POST
            //LawData lawData = GetLawData.POST();

            //if (lawData != null)
            //{
            //    int i=0;
            //    foreach (LawDataLaw item in lawData.LawList)
            //    {
            //        i++;
            //        bool IsLastRow= (i==lawData.LawList.Length);
            //        LawRowSP.Children.Add(new LawRow(item,IsLastRow, LawListCT_HangTheDownloadEvent_Callback));
            //    }
            //}
            //else
            //{
            //    AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
            //}
            #endregion
        }
Пример #5
0
        private void CallLigon()
        {
            canLogin = false;
            MouseTool.ShowLoading();
            try
            {
                string UserID        = tbUserID.Text.Trim();
                string UserPWD       = tbUserPWD.Password.Trim();
                string UserDateBegin = DateTool.MonthFirstDate(DateTime.Today).ToString("yyyyMMdd");              //"20190101";
                string UserDateEnd   = DateTool.MonthFirstDate(DateTime.Today.AddMonths(1)).ToString("yyyyMMdd"); //"20190101";


                //Network.HttpRequest hr = new Network.HttpRequest();
                if (NetworkTool.CheckNetwork() > 0)
                {
                    string url     = WsTool.GetUrl();
                    string xmlData = "<?xml version=\"1.0\"?><UserInfo><UserID><![CDATA[{0}]]></UserID><UserPW><![CDATA[{1}]]></UserPW><UserDevice>1</UserDevice><UserDateBegin>{2}</UserDateBegin><UserDateEnd>{3}</UserDateEnd></UserInfo>";
                    xmlData = string.Format(xmlData, UserID, UserPWD, UserDateBegin, UserDateEnd);
                    Dictionary <string, string> postData = new Dictionary <string, string>();
                    postData["XmlDoc"] = xmlData;
                    //LogTool.Debug(xmlData);
                    HttpWebRequest request = HttpTool.GetHttpWebRequest(url + "/UserData", "POST", postData);

                    // init your request...then:   //lambda
                    //呼叫方法,第二個是lambda匿名方法
                    DoWithResponse(request, (response) =>
                    {
                        //這裡面是不同的執行序;
                        User user = null;

                        try
                        {
                            string data = new StreamReader(response.GetResponseStream()).ReadToEnd();
                            //LogTool.Debug(data);
                            user = XmlHelper.XmlDeserialize <User>(data, Encoding.UTF8);
                        }
                        catch (Exception ex)
                        {
                            this.Dispatcher.BeginInvoke(new Action(() => { AutoClosingMessageBox.Show("登入失敗,請重新登入"); }));
                            LogTool.Debug(ex);
                        }
                        this.Dispatcher.BeginInvoke(new Action <User>(CheckLogin), user);
                    });
                }
                else
                {
                    //DB查詢登入
                    DataTable dt = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1", UserID);
                    if (dt.Rows.Count > 0)
                    {
                        dt = MSCE.GetDataTable("select UserJson from LoginInfo where UserID =@1 and UserPWD=@2"
                                               , UserID
                                               , UserPWD);

                        if (dt.Rows.Count > 0)
                        {
                            User   user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString());
                            string HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList);
                            string UTC      = user.UTC.ToString();
                            long   deltaUTC = 0;
                            try
                            {
                                deltaUTC = DateTool.GetCurrentTimeInUnixMillis() - long.Parse(UTC);
                            }
                            catch (Exception ex)
                            {
                                LogTool.Debug(ex);
                            }
                            string SQL     = @"Update NowLogin set UserID=@1,UserName=@2,UserPWD=@3,MeetingListDate=getdate(),HomeUserButtonAryJSON=@4,UserEmail=@5,UTC=@6,DeltaUTC=@7,RemeberLogin=@8";
                            int    success = MSCE.ExecuteNonQuery(SQL
                                                                  , user.ID
                                                                  , user.Name
                                                                  , tbUserPWD.Password.Trim()
                                                                  , HomeUserButtonAryJSON
                                                                  , user.Email
                                                                  , DateTool.GetCurrentTimeInUnixMillis().ToString()
                                                                  , deltaUTC.ToString()
                                                                  , cbRemeberLogin.IsChecked == true ? "true" : "false");


                            if (success < 1)
                            {
                                LogTool.Debug(new Exception(@"DB失敗: " + SQL));
                                return;
                            }
                            this.Dispatcher.BeginInvoke(new Action <User>(CheckLogin), user);
                        }
                        else
                        {
                            MouseTool.ShowArrow();
                            AutoClosingMessageBox.Show("您的密碼錯誤");
                            canLogin = true;
                        }
                    }
                    else
                    {
                        MouseTool.ShowArrow();
                        AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入");
                        canLogin = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MouseTool.ShowArrow();
                AutoClosingMessageBox.Show("登入失敗");
                canLogin = true;
            }
        }
Пример #6
0
        //
        private void btnLastNext_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            SV.ScrollToVerticalOffset(1);
            Image img = sender as Image;

            if (img.Name.Equals("btnLast"))
            {
                MeetingListDate = MeetingListDate.AddMonths(-1);
            }
            else
            {
                MeetingListDate = MeetingListDate.AddMonths(1);
            }


            // 非同步POST方法
            MouseTool.ShowLoading();


            //檢查是否有網路連線
            Network.HttpRequest hr = new Network.HttpRequest();
            if (NetworkTool.CheckNetwork() > 0)
            {
                Task.Factory.StartNew(() =>
                {
                    //無快取機制
                    //GetUserData.AsyncPOST(UserID, UserPWD
                    //                          , MeetingListDate
                    //                          , (userObj, dateTime) => GetUserData_DoAction(userObj, dateTime));

                    //有快取機制
                    if (PreLoadLastNextMonthDict.ContainsKey(MeetingListDate) == true)
                    {
                        GetUserData_DoAction(PreLoadLastNextMonthDict[MeetingListDate], MeetingListDate);
                        //預載上一個月和下一個月
                        PreLoadLastNextMonth();
                    }
                    else
                    {
                        GetUserData.AsyncPOST(UserID, UserPWD
                                              , MeetingListDate
                                              , (userObj, dateTime) =>
                        {
                            GetUserData_DoAction(userObj, dateTime);
                            //預載上一個月和下一個月
                            PreLoadLastNextMonth();
                        });
                    }
                });
                //}).ContinueWith(task =>
                //{
                //    //預載上一個月
                //    //Thread.Sleep(100);
                //    //GetUserData.AsyncPOST(UserID, UserPWD
                //    //                                 , MeetingListDate.AddMonths(-1)
                //    //                                 , (userObj, dateTime) => { LastNextDict[dateTime] = userObj; });

                //}).ContinueWith(task =>
                //{
                //    //預載下一個月
                //    //Thread.Sleep(100);
                //    //GetUserData.AsyncPOST(UserID, UserPWD
                //    //                                 , MeetingListDate.AddMonths(1)
                //    //                                 , (userObj, dateTime) => { LastNextDict[dateTime] = userObj; });
                //});
            }
            else
            {
                //DB查詢日期
                DataTable dt = MSCE.GetDataTable("select UserJson from UserData where UserID =@1 and ListDate=@2"
                                                 , UserID
                                                 , DateTool.MonthFirstDate(MeetingListDate).ToString("yyyyMMdd"));

                User user = new User();
                if (dt.Rows.Count > 0)
                {
                    user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString());
                }
                else
                {
                    dt = MSCE.GetDataTable("select top 1 UserJson from UserData where UserID =@1"
                                           , UserID);

                    if (dt.Rows.Count > 0)
                    {
                        user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString());
                    }
                    user.MeetingList = new UserMeeting[0];
                }

                GetUserData_DoAction(user, MeetingListDate);
            }

            //, () => { this.Dispatcher.BeginInvoke(new Action(() => { AutoClosingMessageBox.Show("無法取得資料,請稍後再試"); })); });


            #region  步POST方法
            //User user=GetUserData.POST(UserID, UserPWD,
            //                           DateTool.MonthFirstDate(MeetingListDate).ToString("yyyyMMdd"),
            //                           DateTool.MonthLastDate(MeetingListDate).ToString("yyyyMMdd"));
            //if (user != null)
            //{
            //    if (user.MeetingList.Length < 1)
            //        txtNothing.Visibility = Visibility.Visible;
            //    InitUI(user.MeetingList, MeetingListDate);
            //    // 會議列表的上下一頁不要複寫Buton的JSON了
            //    // HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList);
            //}
            //else
            //{
            //    AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
            //}
            #endregion

            // 先做UI,再把按鈕的JSON存下來
            string SQL     = @"update NowLogin Set MeetingListDate=@1";                         //,HomeUserButtonAryJSON=@2
            int    success = MSCE.ExecuteNonQuery(SQL, MeetingListDate.ToString("yyyy/MM/dd")); //, HomeUserButtonAryJSON);
            if (success < 1)
            {
                LogTool.Debug(new Exception(@"DB失敗: " + SQL));
            }
        }
Пример #7
0
        private void GetNewMeeting_DoAction(string dataString)
        {
            // 先判斷是否要invoke
            if (this.Dispatcher.CheckAccess() == false)
            {
                // 這裡是下載事件處理,優先權設定為ContextIdle => 列舉值為 3。 幕後作業完成後,會處理作業。
                this.Dispatcher.BeginInvoke(new Action <string>(GetNewMeeting_DoAction), dataString);
            }
            else
            {
                try
                {
                    string    CourseOrMeeting_String = PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String;
                    XDocument xml   = null;
                    string    State = "";
                    try
                    {
                        xml   = XDocument.Parse(dataString);
                        State = xml.Element("User").Attribute("State").Value.Trim();
                    }
                    catch (Exception ex)
                    {
                        LogTool.Debug(ex);
                    }
                    switch (State)
                    {
                    case "0":
                        string   NewAddMeetingID = xml.Element("User").Element("MeetingData").Attribute("ID").Value.Trim();
                        string   BeginTime       = xml.Element("User").Element("MeetingData").Attribute("BeginTime").Value.Trim();
                        DateTime date            = DateTime.Now;
                        bool     IsValid         = DateTime.TryParse(BeginTime, out date);
                        if (IsValid == false)
                        {
                            date = DateTime.Now;
                        }
                        // 先做UI,再把按鈕的JSON存下來
                        //string SQL = @"update NowLogin Set MeetingListDate=@1,NewAddMeetingID=@2";//,HomeUserButtonAryJSON=@2
                        //int success = MSCE.ExecuteNonQuery(SQL, date.ToString("yyyy/MM/dd"),NewAddMeetingID);//, HomeUserButtonAryJSON);
                        //if (success < 1)
                        //    LogTool.Debug(new Exception(@"DB失敗: " + SQL));
                        this.NewAddMeetingID = NewAddMeetingID;
                        // 非同步POST方法
                        MouseTool.ShowLoading();
                        //GetUserData.AsyncPOST(UserID, UserPWD
                        //   , date
                        //   , (userObj, dateTime) => GetUserData_DoAction(userObj, dateTime));

                        if (NetworkTool.CheckNetwork() > 0)
                        {
                            GetUserData.AsyncPOST(UserID, UserPWD
                                                  , date
                                                  , (userObj, dateTime) => GetUserData_DoAction(userObj, dateTime));
                        }
                        else
                        {
                            //DB查詢日期
                            DataTable dt = MSCE.GetDataTable("select UserJson from UserData where UserID =@1 and ListDate=@2"
                                                             , UserID
                                                             , DateTool.MonthFirstDate(MeetingListDate).ToString("yyyyMMdd"));

                            User user = new User();
                            if (dt.Rows.Count > 0)
                            {
                                user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString());
                            }
                            else
                            {
                                dt = MSCE.GetDataTable("select top 1 UserJson from UserData where UserID =@1"
                                                       , UserID);

                                if (dt.Rows.Count > 0)
                                {
                                    user = JsonConvert.DeserializeObject <User>(dt.Rows[0]["UserJson"].ToString());
                                }
                                user.MeetingList = new UserMeeting[0];
                            }

                            GetUserData_DoAction(user, MeetingListDate);
                        }

                        AutoClosingMessageBox.Show(string.Format("成功加入{0}", CourseOrMeeting_String));

                        //重整列表
                        break;

                    case "1":
                        //AutoClosingMessageBox.Show(string.Format("該機關非{0}人員", CourseOrMeeting_String));
                        AutoClosingMessageBox.Show(string.Format("本{0}未邀請貴機關單位參與", CourseOrMeeting_String));
                        //AutoClosingMessageBox.Show("該機關非與會人員");
                        break;

                    case "2":
                        AutoClosingMessageBox.Show("已加入過");
                        break;

                    case "3":
                        AutoClosingMessageBox.Show(string.Format("{0}不存在", CourseOrMeeting_String));
                        break;

                    case "4":
                        AutoClosingMessageBox.Show(string.Format("{0}尚未發佈", CourseOrMeeting_String));
                        break;

                    case "5":
                        AutoClosingMessageBox.Show("無此使用者");
                        break;

                    case "6":
                        AutoClosingMessageBox.Show("加入失敗");
                        break;

                    case "7":
                        AutoClosingMessageBox.Show("機密會議");
                        break;

                    case "8":
                        AutoClosingMessageBox.Show("會議已取消");
                        break;

                    default:
                        AutoClosingMessageBox.Show("新增錯誤,請聯絡系統管理人員");
                        break;
                    }
                }
                catch (Exception ex)
                {
                    AutoClosingMessageBox.Show("新增錯誤,請聯絡系統管理人員");
                    LogTool.Debug(ex);
                }
                txtPinCode.Text = "";
                MouseTool.ShowArrow();
            }
        }
Пример #8
0
        private void CallLigon()
        {
            Action <HttpWebResponse> action = null;

            canLogin = false;
            MouseTool.ShowLoading();
            try
            {
                string text  = tbUserID.Text.Trim();
                string text2 = tbUserPWD.Password.Trim();
                string text3 = DateTool.MonthFirstDate(DateTime.Today).ToString("yyyyMMdd");
                string text4 = DateTool.MonthFirstDate(DateTime.Today.AddMonths(1)).ToString("yyyyMMdd");
                if (NetworkTool.CheckNetwork() > 0)
                {
                    string url    = WsTool.GetUrl();
                    string format = "<?xml version=\"1.0\"?><UserInfo><UserID><![CDATA[{0}]]></UserID><UserPW><![CDATA[{1}]]></UserPW><UserDevice>1</UserDevice><UserDateBegin>{2}</UserDateBegin><UserDateEnd>{3}</UserDateEnd></UserInfo>";
                    format = string.Format(format, text, text2, text3, text4);
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    dictionary["XmlDoc"] = format;
                    HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/UserData", "POST", dictionary);
                    if (action == null)
                    {
                        action = new Action <HttpWebResponse>(_003CCallLigon_003Eb__10);
                    }
                    DoWithResponse(httpWebRequest, action);
                }
                else
                {
                    DataTable dataTable = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1", text);
                    if (dataTable.Rows.Count > 0)
                    {
                        dataTable = MSCE.GetDataTable("select UserJson from LoginInfo where UserID =@1 and UserPWD=@2", text, text2);
                        if (dataTable.Rows.Count > 0)
                        {
                            User   user  = JsonConvert.DeserializeObject <User>(dataTable.Rows[0]["UserJson"].ToString());
                            string text5 = JsonConvert.SerializeObject(user.EnableButtonList);
                            string s     = user.UTC.ToString();
                            long   num   = 0L;
                            try
                            {
                                num = DateTool.GetCurrentTimeInUnixMillis() - long.Parse(s);
                            }
                            catch (Exception ex)
                            {
                                LogTool.Debug(ex);
                            }
                            string   text6 = "Update NowLogin set UserID=@1,UserName=@2,UserPWD=@3,MeetingListDate=getdate(),HomeUserButtonAryJSON=@4,UserEmail=@5,UTC=@6,DeltaUTC=@7,RemeberLogin=@8";
                            string[] array = new string[8]
                            {
                                user.ID,
                                user.Name,
                                tbUserPWD.Password.Trim(),
                                text5,
                                user.Email,
                                DateTool.GetCurrentTimeInUnixMillis().ToString(),
                                num.ToString(),
                                null
                            };
                            bool?isChecked = cbRemeberLogin.IsChecked;
                            array[7] = ((isChecked.GetValueOrDefault() && isChecked.HasValue) ? "true" : "false");
                            int num2 = MSCE.ExecuteNonQuery(text6, array);
                            if (num2 < 1)
                            {
                                LogTool.Debug(new Exception("DB失敗: " + text6));
                            }
                            else
                            {
                                base.Dispatcher.BeginInvoke(new Action <User>(CheckLogin), user);
                            }
                        }
                        else
                        {
                            MouseTool.ShowArrow();
                            AutoClosingMessageBox.Show("您的密碼錯誤");
                            canLogin = true;
                        }
                    }
                    else
                    {
                        MouseTool.ShowArrow();
                        AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入");
                        canLogin = true;
                    }
                }
            }
            catch (Exception)
            {
                MouseTool.ShowArrow();
                AutoClosingMessageBox.Show("登入失敗");
                canLogin = true;
            }
        }