Exemple #1
0
        private void GetUserData_DoAction(User user, DateTime date)
        {
            // 先判斷是否要invoke
            if (this.Dispatcher.CheckAccess() == false)
            {
                // 這裡是下載事件處理,優先權設定為ContextIdle => 列舉值為 3。 幕後作業完成後,會處理作業。
                this.Dispatcher.BeginInvoke(new Action <User, DateTime>(GetUserData_DoAction), user, date);
            }
            else
            {
                if (user != null)
                {
                    //if (user.MeetingList.Length < 1)
                    //    txtNothing.Visibility = Visibility.Visible;
                    InitUI(user.MeetingList, date);

                    DataTable dt = MSCE.GetDataTable("select ListDate from UserData where UserID =@1 and ListDate =@2"
                                                     , user.ID
                                                     , DateTool.MonthFirstDate(date).ToString("yyyyMMdd"));

                    if (dt.Rows.Count > 0)
                    {
                        MSCE.ExecuteNonQuery(@"UPDATE [UserData] SET 
                                                 [ListDate] = @1
		                                        ,[UserJson] = @2
		                                         where UserID = @3 and ListDate =@4"
                                             , DateTool.MonthFirstDate(date).ToString("yyyyMMdd")
                                             , JsonConvert.SerializeObject(user)
                                             , user.ID
                                             , DateTool.MonthFirstDate(date).ToString("yyyyMMdd"));
                    }
                    else
                    {
                        MSCE.ExecuteNonQuery(@"INSERT INTO [UserData] ([UserID],[ListDate],UserJson)
                                                            VALUES (@1,@2,@3)"
                                             , user.ID
                                             , DateTool.MonthFirstDate(date).ToString("yyyyMMdd")
                                             , JsonConvert.SerializeObject(user));
                    }

                    // 會議列表的上下一頁不要複寫Buton的JSON了
                    // HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList);
                }
                else
                {
                    AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
                }
                MouseTool.ShowArrow();
            }
        }
Exemple #2
0
    public static void AsyncPOST(string UserID, string UserPWD, DateTime date, Action <User, DateTime> DoAction, Action ErrorAction = null)
    {
        Action <HttpWebResponse> action = null;
        Action action2 = null;
        _003C_003Ec__DisplayClass4 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass4();

        _003C_003Ec__DisplayClass.date        = date;
        _003C_003Ec__DisplayClass.DoAction    = DoAction;
        _003C_003Ec__DisplayClass.ErrorAction = ErrorAction;
        try
        {
            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, UserID, UserPWD, DateTool.MonthFirstDate(_003C_003Ec__DisplayClass.date).ToString("yyyyMMdd"), DateTool.MonthLastDate(_003C_003Ec__DisplayClass.date).ToString("yyyyMMdd"));
            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>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__0);
            }
            Action <HttpWebResponse> responseAction = action;
            if (action2 == null)
            {
                action2 = new Action(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__1);
            }
            HttpTool.DoWithResponse(httpWebRequest, responseAction, action2);
        }
        catch (Exception ex)
        {
            if (_003C_003Ec__DisplayClass.ErrorAction != null)
            {
                _003C_003Ec__DisplayClass.ErrorAction();
            }
            AutoClosingMessageBox.Show(ex.Message);
            LogTool.Debug(ex);
        }
    }
Exemple #3
0
        private void CheckLogin(User user)
        {
            try
            {
                if (user != null)
                {
                    switch (user.State)
                    {
                    case "0":
                        string HomeUserButtonAryJSON = JsonConvert.SerializeObject(user.EnableButtonList);
                        string UTC = user.UTC == null?DateTool.GetCurrentTimeInUnixMillis().ToString() : 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
                                                              , UTC
                                                              , deltaUTC.ToString()
                                                              , cbRemeberLogin.IsChecked == true ?"true":"false");


                        if (success < 1)
                        {
                            LogTool.Debug(new Exception(@"DB失敗: " + SQL));
                            return;
                        }


                        try
                        {
                            //DB操作更新
                            DataTable dt = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1"
                                                             , user.ID);

                            if (dt.Rows.Count > 0)
                            {
                                MSCE.ExecuteNonQuery(@"UPDATE [LoginInfo] SET 
                                                 [UserID] = @1
		                                        ,[UserPWD] = @2
                                                ,UserJson = @3
		                                         where UserID=@4"
                                                     , user.ID
                                                     , tbUserPWD.Password.Trim()
                                                     , JsonConvert.SerializeObject(user)
                                                     , user.ID);
                            }
                            else
                            {
                                MSCE.ExecuteNonQuery(@"INSERT INTO [LoginInfo] ([UserID],[UserPWD],UserJson)
                                                            VALUES (@1,@2,@3)"
                                                     , user.ID
                                                     , tbUserPWD.Password.Trim()
                                                     , JsonConvert.SerializeObject(user));
                            }

                            dt = MSCE.GetDataTable("select ListDate from UserData where UserID =@1 and ListDate =@2"
                                                   , user.ID
                                                   , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"));

                            if (dt.Rows.Count > 0)
                            {
                                MSCE.ExecuteNonQuery(@"UPDATE [UserData] SET 
                                                             [ListDate] = @1
		                                                    ,[UserJson] = @2
		                                                     where UserID = @3 and ListDate =@4"
                                                     , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd")
                                                     , JsonConvert.SerializeObject(user)
                                                     , user.ID
                                                     , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"));
                            }
                            else
                            {
                                MSCE.ExecuteNonQuery(@"INSERT INTO [UserData] ([UserID],[ListDate],UserJson)
                                                                        VALUES (@1,@2,@3)"
                                                     , user.ID
                                                     , DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd")
                                                     , JsonConvert.SerializeObject(user));
                            }
                        }
                        catch (Exception ex)
                        {
                            LogTool.Debug(ex);
                        }



                        this.Hide();
                        Home f2 = new Home(user, tbUserPWD.Password.Trim());
                        f2.Show();
                        App.IsChangeWindow = true;
                        this.Close();

                        break;

                    case "1":
                        AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入");
                        break;

                    case "2":
                        AutoClosingMessageBox.Show("帳號密碼錯誤或帳號已被鎖定");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
            canLogin = true;
            MouseTool.ShowArrow();
        }
Exemple #4
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;
            }
        }
Exemple #5
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));
            }
        }
Exemple #6
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();
            }
        }
        private void CheckLogin(User user)
        {
            try
            {
                if (user != null)
                {
                    switch (user.State)
                    {
                    case "0":
                    {
                        string text  = JsonConvert.SerializeObject(user.EnableButtonList);
                        string text2 = (user.UTC == null) ? DateTool.GetCurrentTimeInUnixMillis().ToString() : user.UTC.ToString();
                        long   num   = 0L;
                        try
                        {
                            num = DateTool.GetCurrentTimeInUnixMillis() - long.Parse(text2);
                        }
                        catch (Exception ex)
                        {
                            LogTool.Debug(ex);
                        }
                        string   text3 = "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(),
                            text,
                            user.Email,
                            text2,
                            num.ToString(),
                            null
                        };
                        bool?isChecked = cbRemeberLogin.IsChecked;
                        array[7] = ((isChecked.GetValueOrDefault() && isChecked.HasValue) ? "true" : "false");
                        int num2 = MSCE.ExecuteNonQuery(text3, array);
                        if (num2 < 1)
                        {
                            LogTool.Debug(new Exception("DB失敗: " + text3));
                            return;
                        }
                        try
                        {
                            DataTable dataTable = MSCE.GetDataTable("select UserID from LoginInfo where UserID =@1", user.ID);
                            if (dataTable.Rows.Count > 0)
                            {
                                MSCE.ExecuteNonQuery("UPDATE [LoginInfo] SET \r\n                                                 [UserID] = @1\r\n\t\t                                        ,[UserPWD] = @2\r\n                                                ,UserJson = @3\r\n\t\t                                         where UserID=@4", user.ID, tbUserPWD.Password.Trim(), JsonConvert.SerializeObject(user), user.ID);
                            }
                            else
                            {
                                MSCE.ExecuteNonQuery("INSERT INTO [LoginInfo] ([UserID],[UserPWD],UserJson)\r\n                                                            VALUES (@1,@2,@3)", user.ID, tbUserPWD.Password.Trim(), JsonConvert.SerializeObject(user));
                            }
                            dataTable = MSCE.GetDataTable("select ListDate from UserData where UserID =@1 and ListDate =@2", user.ID, DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"));
                            if (dataTable.Rows.Count > 0)
                            {
                                MSCE.ExecuteNonQuery("UPDATE [UserData] SET \r\n                                                             [ListDate] = @1\r\n\t\t                                                    ,[UserJson] = @2\r\n\t\t                                                     where UserID = @3 and ListDate =@4", DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"), JsonConvert.SerializeObject(user), user.ID, DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"));
                            }
                            else
                            {
                                MSCE.ExecuteNonQuery("INSERT INTO [UserData] ([UserID],[ListDate],UserJson)\r\n                                                                        VALUES (@1,@2,@3)", user.ID, DateTool.MonthFirstDate(DateTime.Now).ToString("yyyyMMdd"), JsonConvert.SerializeObject(user));
                            }
                        }
                        catch (Exception ex2)
                        {
                            LogTool.Debug(ex2);
                        }
                        Hide();
                        Home home = new Home(user, tbUserPWD.Password.Trim());
                        home.Show();
                        Close();
                        break;
                    }

                    case "1":
                        AutoClosingMessageBox.Show("無此使用者帳號,請重新輸入");
                        break;

                    case "2":
                        AutoClosingMessageBox.Show("帳號密碼錯誤或帳號已被鎖定");
                        break;
                    }
                }
            }
            catch (Exception ex3)
            {
                LogTool.Debug(ex3);
            }
            canLogin = true;
            MouseTool.ShowArrow();
        }
        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;
            }
        }