Esempio n. 1
0
        private void ParsePageJson()
        {
            // {"scale":null,"animations":null,"bookmark":null,"animation":null,"bookId":"cAF40-V","execTime":"1406304980594","actionTime":"00:00:30.697","pageIndex":null,"annotation":null,"spline":null,"hide":null,"page":null,"action":"pause","y":null,"x":null}
            Dictionary <string, object> dictPageJson = JsonConvert.DeserializeObject <Dictionary <string, object> >(pageJson);
            Dictionary <string, object> dictMsg      = JsonConvert.DeserializeObject <Dictionary <string, object> >(dictPageJson["msg"].ToString());

            //play、pause、stop
            string action     = dictMsg["action"].ToString();
            string execTime   = dictMsg["execTime"].ToString();
            string actionTime = dictMsg["actionTime"].ToString();

            switch (action)
            {
            case "play":
                long ec            = long.Parse(execTime);
                long nowServerTime = 0;
                //快慢無所謂,減掉DeltaUTC,就是Server現在時間
                nowServerTime = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC;

                long playTime = nowServerTime - ec;
                mediaPlayer.Position = TimeSpan.Parse(actionTime) + new TimeSpan(0, 0, 0, 0, (int)playTime);
                mediaPlayer.Play();
                IsAlwaysShowHeaderFooter = false;

                break;

            case "pause":
                mediaPlayer.Play();
                mediaPlayer.Position = TimeSpan.Parse(actionTime);
                mediaPlayer.Pause();
                IsAlwaysShowHeaderFooter = true;
                break;
            }
        }
Esempio n. 2
0
        private void ParsePageJson()
        {
            Dictionary <string, object> dictionary  = JsonConvert.DeserializeObject <Dictionary <string, object> >(pageJson);
            Dictionary <string, object> dictionary2 = JsonConvert.DeserializeObject <Dictionary <string, object> >(dictionary["msg"].ToString());
            string text = dictionary2["action"].ToString();
            string s    = dictionary2["execTime"].ToString();
            string s2   = dictionary2["actionTime"].ToString();

            switch (text)
            {
            case "play":
            {
                long num  = long.Parse(s);
                long num2 = 0L;
                num2 = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC;
                long num3 = num2 - num;
                mediaPlayer.Position = TimeSpan.Parse(s2) + new TimeSpan(0, 0, 0, 0, (int)num3);
                mediaPlayer.Play();
                IsAlwaysShowHeaderFooter = false;
                break;
            }

            case "pause":
                mediaPlayer.Play();
                mediaPlayer.Position = TimeSpan.Parse(s2);
                mediaPlayer.Pause();
                IsAlwaysShowHeaderFooter = true;
                break;
            }
        }
Esempio n. 3
0
        private void SentToOther(string function)
        {
            _003C_003Ec__DisplayClass22 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass22();

            _003C_003Ec__DisplayClass.function          = function;
            _003C_003Ec__DisplayClass._003C_003E4__this = this;
            _003C_003Ec__DisplayClass.ecTime            = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC;
            if (IsInSync && IsSyncOwner)
            {
                _003C_003Ec__DisplayClass24 _003C_003Ec__DisplayClass2 = new _003C_003Ec__DisplayClass24();
                _003C_003Ec__DisplayClass2.CS_0024_003C_003E8__locals23 = _003C_003Ec__DisplayClass;
                _003C_003Ec__DisplayClass2.mydate = new DateTime(mediaPlayer.Position.Ticks);
                Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass2._003CSentToOther_003Eb__21));
            }
        }
Esempio n. 4
0
        private void SentToOther(string function)
        {
            long ecTime = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC;

            if (IsInSync == true && IsSyncOwner == true)
            {
                DateTime mydate = new DateTime(mediaPlayer.Position.Ticks);

                Task.Factory.StartNew(() =>
                {
                    SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, true);
                    if (socketClient != null && socketClient.GetIsConnected() == true)
                    {
                        socketClient.broadcast("{\"execTime\":" + ecTime.ToString() + ",\"action\":\"" + function + "\",\"actionTime\":\"" + mydate.ToString("HH:mm:ss.fff") + "\",\"cmd\":\"R.SV\"}");
                    }
                    else
                    {
                        //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步");
                    }
                });
            }
        }
Esempio n. 5
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();
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
0
        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();
        }
Esempio n. 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;
            }
        }