Exemplo n.º 1
0
    public static bool POST(string MeetingID, string UserID, string AgendaID, string AgendaStatus)
    {
        bool result = false;

        try
        {
            string url    = WsTool.GetUrl();
            string format = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><UserInfo><MeetingID>{0}</MeetingID><UserID><![CDATA[{1}]]></UserID><UpdateList><UpdateAgenda><AgendaID>{2}</AgendaID><AgendaStatus>{3}</AgendaStatus></UpdateAgenda></UpdateList></UserInfo>";
            format = string.Format(format, MeetingID, UserID, AgendaID, AgendaStatus);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            dictionary["XmlDoc"] = format;
            string text = HttpTool.CreateRequest(url + "/ProgressUpload", "POST", dictionary);
            if (!text.Contains("</succes>"))
            {
                return(result);
            }
            result = true;
            return(result);
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
            return(result);
        }
    }
    public static void AsyncPOST(string UserID, string PinCode, Action <string> DoAction, Action ErrorAction = null)
    {
        Action <HttpWebResponse>   action = null;
        _003C_003Ec__DisplayClass2 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass2();

        _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><PinCode>{1}</PinCode></UserInfo>";
            format = string.Format(format, UserID, PinCode);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            dictionary["XmlDoc"] = format;
            HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/NewMeeting", "POST", dictionary);
            if (action == null)
            {
                action = new Action <HttpWebResponse>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__0);
            }
            HttpTool.DoWithResponse(httpWebRequest, action);
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
        }
    }
    public static void AsyncPOST(string MeetingID, string AttachID, string Email, string Text, string FilePath, Action <AnnotationUpload> DoAction, Action ErrorAction = null)
    {
        _003C_003Ec__DisplayClass2 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass2();

        _003C_003Ec__DisplayClass.DoAction    = DoAction;
        _003C_003Ec__DisplayClass.ErrorAction = ErrorAction;
        string url    = WsTool.GetUrl();
        string format = "<?xml version=\"1.0\"?><UserInfo><MeetingID>{0}</MeetingID><AttachID>{1}</AttachID><Email>{2}</Email><Text>{3}</Text></UserInfo>";

        format = string.Format(format, MeetingID, AttachID, Email, Text);
        UploadFile uploadFile = new UploadFile();
        FileInfo   fileInfo   = new FileInfo(FilePath);

        uploadFile.Name        = fileInfo.Name.Split('.')[0];
        uploadFile.Filename    = fileInfo.Name;
        uploadFile.ContentType = "image/jpg";
        uploadFile.Stream      = File.Open(FilePath, FileMode.Open);
        NameValueCollection nameValueCollection = new NameValueCollection();

        nameValueCollection.Add("XmlDoc", format);
        NameValueCollection values = nameValueCollection;

        UploadFile[] files = new UploadFile[1]
        {
            uploadFile
        };
        HttpWebRequest httpWebRequestWithFile = HttpTool.GetHttpWebRequestWithFile(url + "/AnnotationUpload", files, values);

        HttpTool.DoWithResponse(httpWebRequestWithFile, new Action <HttpWebResponse>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__1));
    }
    public static SigninDataUpload POST(string MeetingID, string UserID, string DeptId, string filePath)
    {
        SigninDataUpload result = null;

        try
        {
            string url    = WsTool.GetUrl();
            string format = "<?xml version=\"1.0\"?><UserInfo><MeetingID>{0}</MeetingID><UserID><![CDATA[{1}]]></UserID><DeptId><![CDATA[{2}]]></DeptId></UserInfo>";
            format = string.Format(format, MeetingID, UserID, DeptId);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            dictionary["XmlDoc"] = format;
            string text = HttpTool.CreateRequestWithFile(url + "/SigninDataUpload", "", filePath);
            if (text.Equals(""))
            {
                return(result);
            }
            result = XmlHelper.XmlDeserialize <SigninDataUpload>(text, Encoding.UTF8);
            return(result);
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
            return(result);
        }
    }
Exemplo n.º 5
0
 public static int CheckNetwork()
 {
     if (!Settings.Default.HasOfflineMode)
     {
         return(1);
     }
     try
     {
         HttpRequest httpRequest = new HttpRequest();
         string      text        = "";
         string      text2       = "";
         text  = WsTool.GetUrl();
         text2 = new Uri(text).DnsSafeHost;
         if (!GetDomainNameIP(text2, 1000).Equals("") && httpRequest.checkNetworkStatus("", text) == NetworkStatusCode.OK)
         {
             return(1);
         }
         return(0);
     }
     catch (Exception ex)
     {
         LogTool.Debug(ex);
         return(1);
     }
 }
Exemplo n.º 6
0
        private void btnOpen_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MouseTool.ShowLoading();

            try
            {
                //string AppPath = AppDomain.CurrentDomain.BaseDirectory;
                string filePath = ClickOnceTool.GetFilePath();

                //string _bookPath = System.IO.Path.Combine(AppPath, lawItem.UnZipFilePath);
                string _bookPath      = lawItem.UnZipFilePath;
                string _bookId        = "";
                string _account       = "";
                string _userName      = "";
                string _email         = "";
                string _meetingId     = "";
                string _watermark     = "";
                string _dbPath        = System.IO.Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.bookInfo_Path);
                bool   _isSync        = false;
                bool   _isSyncOwner   = false;
                string _webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
                string _socketMessage = "";


                // 呼叫一個事件取得 BookVMs
                //Dictionary<string, BookVM> cbBooksData = new Dictionary<string, BookVM>();
                //if (LawListCT_GetBookVMs_ByMeetingFileCate_Event != null)
                //    cbBooksData = LawListCT_GetBookVMs_ByMeetingFileCate_Event(lawItem);

                Dictionary <string, BookVM> cbBooksData = null;
                Home Home_Window = Application.Current.Windows.OfType <Home>().FirstOrDefault();

                Home_Window.CloseAllWindow("", true);
                Task.Factory.StartNew(() =>
                {
                    this.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        ReadWindow rw = new ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                                                       , _userName, _email, _meetingId
                                                       , _watermark, _dbPath, _isSync
                                                       , _isSyncOwner, _webServiceUrl, _socketMessage, null);
                        rw.HideCollectFile = true;
                        rw.WindowStyle = WindowStyle.None;
                        rw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        rw.WindowState = WindowState.Maximized;
                        if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                        {
                            //rw.WindowStyle = WindowStyle.SingleBorderWindow;
                        }
                        rw.Show();
                    }));
                });
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }

            MouseTool.ShowArrow();
        }
Exemplo n.º 7
0
 private void btnOpen_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     MouseTool.ShowLoading();
     try
     {
         _003C_003Ec__DisplayClass14 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass14();
         _003C_003Ec__DisplayClass._003C_003E4__this = this;
         ClickOnceTool.GetFilePath();
         _003C_003Ec__DisplayClass._bookPath      = lawItem.UnZipFilePath;
         _003C_003Ec__DisplayClass._bookId        = "";
         _003C_003Ec__DisplayClass._account       = "";
         _003C_003Ec__DisplayClass._userName      = "";
         _003C_003Ec__DisplayClass._email         = "";
         _003C_003Ec__DisplayClass._meetingId     = "";
         _003C_003Ec__DisplayClass._watermark     = "";
         _003C_003Ec__DisplayClass._dbPath        = Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.bookInfo_Path);
         _003C_003Ec__DisplayClass._isSync        = false;
         _003C_003Ec__DisplayClass._isSyncOwner   = false;
         _003C_003Ec__DisplayClass._webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
         _003C_003Ec__DisplayClass._socketMessage = "";
         _003C_003Ec__DisplayClass.cbBooksData    = null;
         _003C_003Ec__DisplayClass.Home_Window    = Enumerable.FirstOrDefault(Enumerable.OfType <Home>(Application.Current.Windows));
         _003C_003Ec__DisplayClass.Home_Window.CloseAllWindow("", true);
         Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass._003CbtnOpen_MouseLeftButtonDown_003Eb__12));
     }
     catch (Exception ex)
     {
         LogTool.Debug(ex);
     }
     MouseTool.ShowArrow();
 }
    public static void AsyncPOST(string MeetingID, string UserID, string DeptId, string FilePath, Action <SigninDataUpload> DoAction, Action ErrorAction = null)
    {
        _003C_003Ec__DisplayClass2 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass2();

        _003C_003Ec__DisplayClass.DoAction    = DoAction;
        _003C_003Ec__DisplayClass.ErrorAction = ErrorAction;
        string url    = WsTool.GetUrl();
        string format = "<?xml version=\"1.0\"?><UserInfo><MeetingID>{0}</MeetingID><UserID><![CDATA[{1}]]></UserID><DeptId><![CDATA[{2}]]></DeptId></UserInfo>";

        format = string.Format(format, MeetingID, UserID, DeptId);
        UploadFile uploadFile = new UploadFile();
        FileInfo   fileInfo   = new FileInfo(FilePath);

        uploadFile.Name        = fileInfo.Name.Split('.')[0];
        uploadFile.Filename    = fileInfo.Name;
        uploadFile.ContentType = "image/png";
        uploadFile.Stream      = File.Open(FilePath, FileMode.Open);
        NameValueCollection nameValueCollection = new NameValueCollection();

        nameValueCollection.Add("XmlDoc", format);
        NameValueCollection values = nameValueCollection;

        UploadFile[] files = new UploadFile[1]
        {
            uploadFile
        };
        HttpWebRequest httpWebRequestWithFile = HttpTool.GetHttpWebRequestWithFile(url + "/SigninDataUpload", files, values);

        HttpTool.DoWithResponse(httpWebRequestWithFile, new Action <HttpWebResponse>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__1));
    }
Exemplo n.º 9
0
    public static User POST(string UserID, string UserPWD, string UserDateBegin, string UserDateEnd)
    {
        User result = null;

        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, UserDateBegin, UserDateEnd);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            dictionary["XmlDoc"] = format;
            string text = HttpTool.CreateRequest(url + "/UserData", "POST", dictionary);
            if (text.Equals(""))
            {
                return(result);
            }
            result = XmlHelper.XmlDeserialize <User>(text, Encoding.UTF8);
            return(result);
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
            return(result);
        }
    }
Exemplo n.º 10
0
    public static SigninData POST(string meetingID)
    {
        SigninData result = null;

        try
        {
            string url    = WsTool.GetUrl();
            string format = "<?xml version=\"1.0\"?><UserInfo><MeetingID>{0}</MeetingID></UserInfo>";
            format = string.Format(format, meetingID);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            dictionary["XmlDoc"] = format;
            string text = HttpTool.CreateRequest(url + "/SigninData", "POST", dictionary);
            if (text.Equals(""))
            {
                return(result);
            }
            result = XmlHelper.XmlDeserialize <SigninData>(text, Encoding.UTF8);
            return(result);
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
            return(result);
        }
    }
    public static MeetingData POST(string UserID, string PinCode)
    {
        MeetingData result = null;

        try
        {
            string url    = WsTool.GetUrl();
            string format = "<?xml version=\"1.0\"?><UserInfo><UserID><![CDATA[{0}]]></UserID><PinCode>{1}</PinCode></UserInfo>";
            format = string.Format(format, UserID, PinCode);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            dictionary["XmlDoc"] = format;
            string text = HttpTool.CreateRequest(url + "/NewMeeting", "POST", dictionary);
            if (text.Equals(""))
            {
                return(result);
            }
            result = XmlHelper.XmlDeserialize <MeetingData>(text, Encoding.UTF8);
            return(result);
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
            return(result);
        }
    }
Exemplo n.º 12
0
    public static void AsyncPOST(Action <LawData> DoAction, Action ErrorAction = null)
    {
        _003C_003Ec__DisplayClass1 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass1();

        _003C_003Ec__DisplayClass.DoAction    = DoAction;
        _003C_003Ec__DisplayClass.ErrorAction = ErrorAction;
        string         url            = WsTool.GetUrl();
        HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/LawData", "POST");

        HttpTool.DoWithResponse(httpWebRequest, new Action <HttpWebResponse>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__0));
    }
Exemplo n.º 13
0
    public static void AsyncPOST(string MeetingID, string UserID, string AgendaID, string AgendaStatus, Action <bool> DoAction, Action ErrorAction = null)
    {
        _003C_003Ec__DisplayClass1 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass1();

        _003C_003Ec__DisplayClass.DoAction    = DoAction;
        _003C_003Ec__DisplayClass.ErrorAction = ErrorAction;
        string url    = WsTool.GetUrl();
        string format = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><UserInfo><MeetingID>{0}</MeetingID><UserID><![CDATA[{1}]]></UserID><UpdateList><UpdateAgenda><AgendaID>{2}</AgendaID><AgendaStatus>{3}</AgendaStatus></UpdateAgenda></UpdateList></UserInfo>";

        format = string.Format(format, MeetingID, UserID, AgendaID, AgendaStatus);
        Dictionary <string, string> dictionary = new Dictionary <string, string>();

        dictionary["XmlDoc"] = format;
        HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/ProgressUpload", "POST", dictionary);

        HttpTool.DoWithResponse(httpWebRequest, new Action <HttpWebResponse>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__0));
    }
Exemplo n.º 14
0
    public static void AsyncPOST(string meetingID, Action <SigninData> DoAction, Action ErrorAction = null)
    {
        _003C_003Ec__DisplayClass1 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass1();

        _003C_003Ec__DisplayClass.DoAction    = DoAction;
        _003C_003Ec__DisplayClass.ErrorAction = ErrorAction;
        string url    = WsTool.GetUrl();
        string format = "<?xml version=\"1.0\"?><UserInfo><MeetingID>{0}</MeetingID></UserInfo>";

        format = string.Format(format, meetingID);
        Dictionary <string, string> dictionary = new Dictionary <string, string>();

        dictionary["XmlDoc"] = format;
        HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/SigninData", "POST", dictionary);

        HttpTool.DoWithResponse(httpWebRequest, new Action <HttpWebResponse>(_003C_003Ec__DisplayClass._003CAsyncPOST_003Eb__0));
    }
Exemplo n.º 15
0
    public static LawData POST()
    {
        LawData result = null;

        try
        {
            string url  = WsTool.GetUrl();
            string text = HttpTool.CreateRequest(url + "/LawData", "POST");
            if (text.Equals(""))
            {
                return(result);
            }
            result = XmlHelper.XmlDeserialize <LawData>(text, Encoding.UTF8);
            return(result);
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
            return(result);
        }
    }
Exemplo n.º 16
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);
        }
    }
Exemplo n.º 17
0
        private void Login_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                // Enables WPF to mark edit field as supporting text pattern (Automation Concept)
                //System.Windows.Automation.AutomationElement asForm = System.Windows.Automation.AutomationElement.FromHandle(new WindowInteropHelper(this).Handle);

                // Windows 8 API to enable touch keyboard to monitor for focus tracking in this WPF application
                //InputPanelConfigurationLib.InputPanelConfiguration inputPanelConfig = new InputPanelConfigurationLib.InputPanelConfiguration();
                //inputPanelConfig.EnableFocusTracking();
            }
            catch (Exception ex)
            {
            }

            Task.Factory.StartNew(() =>
            {
                InitSelectDB();
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        InitUI();
                        InitEvent();
                    }
                    catch (Exception ex)
                    {
                        LogTool.Debug(ex);
                    }
                    MouseTool.ShowArrow();
                }));

                //先發出一個request,加快登入時間
                //不然啟動時登入會很慢
                HttpTool.GetResponseLength(WsTool.GetUrl() + "/UserData?XmlDoc=");
            });
        }
    public static void AsyncPOST(string MeetingID, string UserID, string UserPWD, Action <MeetingData> DoAction, Action ErrorAction = null)
    {
        Action <HttpWebResponse> action = null;
        Action action2 = null;
        _003C_003Ec__DisplayClass4 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass4();

        _003C_003Ec__DisplayClass.DoAction    = DoAction;
        _003C_003Ec__DisplayClass.ErrorAction = ErrorAction;
        try
        {
            string url    = WsTool.GetUrl();
            string format = "<?xml version=\"1.0\"?><UserInfo><MeetingID>{0}</MeetingID><UserID><![CDATA[{1}]]></UserID><UserPW><![CDATA[{2}]]></UserPW></UserInfo>";
            format = string.Format(format, MeetingID, UserID, UserPWD);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            dictionary["XmlDoc"] = format;
            HttpWebRequest httpWebRequest = HttpTool.GetHttpWebRequest(url + "/MeetingData", "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);
        }
    }
Exemplo n.º 19
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;
            }
        }
Exemplo n.º 20
0
 private void _003CLogin_Loaded_003Eb__0()
 {
     InitSelectDB();
     base.Dispatcher.BeginInvoke(new Action(_003CLogin_Loaded_003Eb__1));
     HttpTool.GetResponseLength(WsTool.GetUrl() + "/UserData?XmlDoc=");
 }
Exemplo n.º 21
0
        public void InitSyncCenter(string dbPath, string bookId, string account, string meetingId)
        {
            if (PaperLess_Emeeting.Properties.Settings.Default.HasSyncCenterModule == true)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        SyncCenter syncCenter  = new SyncCenter();
                        syncCenter.bookManager = new BookManager(dbPath);
                        int userBookSno        = getBookPath(dbPath, bookId, account, meetingId);
                        Dictionary <String, Object> cloudSyncingClsList = new Dictionary <String, Object>()
                        {
                            { "SBookmark", new BookMarkData() }, { "SAnnotation", new NoteData() }, { "SSpline", new StrokesData() }, { "SLastPage", new LastPageData() }
                        };

                        foreach (KeyValuePair <String, Object> syncType in cloudSyncingClsList)
                        {
                            string className = syncType.Key;
                            Type openType    = typeof(SyncManager <>);
                            Type actualType  = openType.MakeGenericType(new Type[] { syncType.Value.GetType() });

                            //AbstractSyncManager sm = (AbstractSyncManager)Activator.CreateInstance(actualType, account, meetingId, bookId, userBookSno, className, 0, "0", WsTool.GetAbstractSyncCenter_BASE_URL());
                            AbstractSyncManager sm = (AbstractSyncManager)Activator.CreateInstance(actualType, account, "free", bookId, userBookSno, className, 0, "0", WsTool.GetAbstractSyncCenter_BASE_URL());
                            syncCenter.addSyncConditions(className, sm);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogTool.Debug(ex);
                    }
                });
            }
        }
Exemplo n.º 22
0
        private void CallOpenBook(bool HasOpenFinishedFileVersion = false)
        {
            MouseTool.ShowLoading();
            try
            {
                Home Home_Window = Application.Current.Windows.OfType <Home>().FirstOrDefault();

                if (Home_Window.IsInSync == true && Home_Window.IsSyncOwner == false)
                {
                    AutoClosingMessageBox.Show("同步中需由主控人員進行操作");
                    return;
                }


                //

                string filePath = ClickOnceTool.GetFilePath();

                //string _bookPath = System.IO.Path.Combine(filePath, fileItem.UnZipFilePath);
                string UnZipFileFolder = PaperLess_Emeeting.Properties.Settings.Default.File_UnZipFileFolder;
                //string _bookPath = filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\"+ fileItem.ID +"\\"+fileItem.FileVersion.ToString();
                // 等於上面那個路徑
                string _bookPath = fileItem.UnZipFilePath;

                // 從資料庫查詢上一次完成的檔案版本
                if (HasOpenFinishedFileVersion == true)
                {
                    DataTable dt = MSCE.GetDataTable("SELECT FinishedFileVersion FROM FileRow where ID=@1 and UserID=@2 and MeetingID=@3"
                                                     , meetingDataDownloadFileFile.ID
                                                     , UserID
                                                     , MeetingID);
                    if (dt.Rows.Count > 0)
                    {
                        _bookPath = filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + fileItem.ID + "\\" + dt.Rows[0]["FinishedFileVersion"].ToString();
                    }
                }
                string _bookId    = fileItem.ID;
                string _account   = UserID;
                string _userName  = UserName;
                string _email     = UserEmail;
                string _meetingId = MeetingID;
                string _watermark = "";
                if (MeetingDataCT_GetWatermark_Event != null)
                {
                    _watermark = MeetingDataCT_GetWatermark_Event();
                }
                string _dbPath        = System.IO.Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.bookInfo_Path);
                bool   _isSync        = Home_Window.IsInSync;
                bool   _isSyncOwner   = Home_Window.IsSyncOwner;
                string _webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
                string _socketMessage = "";


                SocketClient _socket   = null;
                SocketClient tmpSocket = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, Home_Window.IsInSync);

                if (tmpSocket != null && tmpSocket.GetIsConnected() == true)
                {
                    _socket = tmpSocket;
                }

                //if (_socket.GetIsConnected() == false)
                //    _socket = null;
                //if (Home_Window.IsInSync == false)
                //    _socket = null;

                // 呼叫一個事件取得 BookVMs
                Dictionary <string, BookVM> cbBooksData = new Dictionary <string, BookVM>();
                if (MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event != null)
                {
                    cbBooksData = MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event(fileItem);
                }
                // debug
                //BooksData["cAF6-P"] = new BookVM("cAF6-P", filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + "cAF6-P");
                //BooksData["cAF3-P"] = new BookVM("cAF3-P", filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + "cAF3-P");

                Home_Window.CloseAllWindow("", true);

                switch (fileItem.FileCate)
                {
                case MeetingFileCate.電子書:

                    InitSyncCenter(_dbPath, _bookId, _account, _meetingId);

                    Task.Factory.StartNew(() =>
                    {
                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            byte[] ReaderKey = new byte[1];

                            try
                            {
                                if (fileItem.EncryptionKey.Equals("") == false)
                                {
                                    ReaderKey = ReaderDecodeTool.GetReaderKey(fileItem.EncryptionKey);
                                }
                            }
                            catch (Exception ex)
                            {
                                LogTool.Debug(ex);
                            }
                            ReadWindow rw = new ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                                                           , _userName, _email, _meetingId
                                                           , _watermark, _dbPath, _isSync
                                                           , _isSyncOwner, _webServiceUrl, ReaderKey, _socketMessage, _socket);

                            //ReadWindow rw = new ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                            //                      , _userName, _email, _meetingId
                            //                      , _watermark, _dbPath, _isSync
                            //                      , _isSyncOwner, _webServiceUrl, _socketMessage, _socket);
                            rw.FolderID = this.FolderID;
                            rw.WindowStyle = WindowStyle.None;
                            rw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            rw.WindowState = WindowState.Maximized;
                            if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                            {
                                //rw.WindowStyle = WindowStyle.SingleBorderWindow;
                            }
                            rw.Show();
                        }));
                    });


                    break;

                case MeetingFileCate.Html5投影片:
                    _bookPath = _bookPath + @"\" + new FileInfo(Directory.GetFiles(_bookPath)[0]).Name;

                    InitSyncCenter(_dbPath, _bookId, _account, _meetingId);

                    Task.Factory.StartNew(() =>
                    {
                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            HTML5ReadWindow Html5rw = new HTML5ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                                                                          , _userName, _email, _meetingId
                                                                          , _watermark, _dbPath, _isSync
                                                                          , _isSyncOwner, _webServiceUrl, _socketMessage, _socket);
                            Html5rw.FolderID = this.FolderID;
                            Html5rw.WindowStyle = WindowStyle.None;
                            Html5rw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            Html5rw.WindowState = WindowState.Maximized;
                            if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                            {
                                //Html5rw.WindowStyle = WindowStyle.SingleBorderWindow;
                            }
                            Html5rw.Show();
                        }));
                    });


                    break;

                case MeetingFileCate.影片檔:
                    _bookPath = _bookPath + @"\" + new FileInfo(Directory.GetFiles(_bookPath)[0]).Name;

                    Task.Factory.StartNew(() =>
                    {
                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            MVWindow mvWindow = new MVWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId);
                            mvWindow.WindowStyle = WindowStyle.None;
                            mvWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            mvWindow.WindowState = WindowState.Maximized;
                            if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                            {
                                //mvWindow.WindowStyle = WindowStyle.SingleBorderWindow;
                            }
                            mvWindow.Show();
                        }));
                    });

                    break;
                }

                if (Home_Window.IsInSync == true && Home_Window.IsSyncOwner == true)
                {
                    SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, Home_Window.IsInSync);
                    Task.Factory.StartNew(() =>
                    {
                        if (socketClient != null && socketClient.GetIsConnected() == true)
                        {
                            string OB = "{\"bookId\":\"" + meetingDataDownloadFileFile.ID + "\",\"cmd\":\"R.OB\"}";
                            socketClient.broadcast(OB);
                        }
                        else
                        {
                            //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步");
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }

            MouseTool.ShowArrow();
        }
Exemplo n.º 23
0
        // 外界只能使用靜態方法取得實例
        public static SocketClient GetInstance(string _MeetingID, string _UserID, string _UserName, bool InitToSync)
        {
            bool SyncServerIsIP = false;

            IPAddress ip = default(IPAddress);

            IPAddress.TryParse(new Uri(WsTool.GetSyncServer_URL()).DnsSafeHost, out ip);
            if (IPAddress.Equals(default(IPAddress), ip) == false)
            {
                SyncServerIsIP = true;
            }



            if (SyncServerIsIP == false && NetworkTool.GetDomainNameIP(WsTool.GetSyncServer_URL(), 1000).Equals("") == true && NetworkTool.GetDomainNameIP(WsTool.GetSyncServerImp_URL(), 1000).Equals("") == true)
            {
                return(null);
            }

            // 先判斷目前有沒有實例,沒有的話才開始 lock,
            // 此次的判斷,是避免在有實例的情況,也執行 lock ,影響效能
            if (instance == null)
            {
                // 避免多執行緒可能會產生兩個以上的實例,所以 lock
                lock (thisLock)
                {
                    // lock 後,再判斷一次目前有無實例
                    // 此次的判斷,是避免多執行緒,同時通過前一次的 null == instance 判斷
                    if (instance == null)
                    {
                        Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                    }
                    else
                    {
                        if (MeetingID.Equals(_MeetingID) == false)
                        {
                            Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                        }
                        else
                        {
                            int i = 1;
                            while (i <= 10)
                            {
                                bool IsConnected = instance.GetIsConnected();
                                if (instance != null && IsConnected == true)
                                {
                                    break;
                                }
                                else if (i == 10)
                                {
                                    Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                                }

                                Thread.Sleep(10);
                                i++;
                            }
                        }
                    }
                }
            }
            else
            {
                lock (thisLock)
                {
                    // lock 後,再判斷一次目前有無實例
                    // 此次的判斷,是避免多執行緒,同時通過前一次的 null == instance 判斷
                    if (instance == null)
                    {
                        Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                    }
                    else
                    {
                        if (MeetingID.Equals(_MeetingID) == false)
                        {
                            Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                        }
                        else
                        {
                            //if (instance.GetIsConnected() == false)
                            //    Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);

                            int i = 1;
                            while (i <= 10)
                            {
                                bool IsConnected = instance.GetIsConnected();
                                if (instance != null && IsConnected == true)
                                {
                                    break;
                                }
                                else if (i == 10)
                                {
                                    Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                                }

                                Thread.Sleep(10);
                                i++;
                            }
                        }
                    }
                }
            }

            //Thread.Sleep(100);
            return(instance);
        }
Exemplo n.º 24
0
        private void CallOpenBook(bool HasOpenFinishedFileVersion = false)
        {
            MouseTool.ShowLoading();
            try
            {
                Action action  = null;
                Action action2 = null;
                Action action3 = null;
                _003C_003Ec__DisplayClass2a _003C_003Ec__DisplayClass2a = new _003C_003Ec__DisplayClass2a();
                _003C_003Ec__DisplayClass2a._003C_003E4__this = this;
                _003C_003Ec__DisplayClass2a.Home_Window       = Enumerable.FirstOrDefault(Enumerable.OfType <Home>(Application.Current.Windows));
                if (_003C_003Ec__DisplayClass2a.Home_Window.IsInSync && !_003C_003Ec__DisplayClass2a.Home_Window.IsSyncOwner)
                {
                    AutoClosingMessageBox.Show("同步中需由主控人員進行操作");
                    return;
                }
                string filePath             = ClickOnceTool.GetFilePath();
                string file_UnZipFileFolder = Settings.Default.File_UnZipFileFolder;
                _003C_003Ec__DisplayClass2a._bookPath = fileItem.UnZipFilePath;
                if (HasOpenFinishedFileVersion)
                {
                    DataTable dataTable = MSCE.GetDataTable("SELECT FinishedFileVersion FROM FileRow where ID=@1 and UserID=@2 and MeetingID=@3", meetingDataDownloadFileFile.ID, UserID, MeetingID);
                    if (dataTable.Rows.Count > 0)
                    {
                        _003C_003Ec__DisplayClass2a._bookPath = filePath + "\\" + file_UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + fileItem.ID + "\\" + dataTable.Rows[0]["FinishedFileVersion"].ToString();
                    }
                }
                _003C_003Ec__DisplayClass2a._bookId    = fileItem.ID;
                _003C_003Ec__DisplayClass2a._account   = UserID;
                _003C_003Ec__DisplayClass2a._userName  = UserName;
                _003C_003Ec__DisplayClass2a._email     = UserEmail;
                _003C_003Ec__DisplayClass2a._meetingId = MeetingID;
                _003C_003Ec__DisplayClass2a._watermark = "";
                if (MeetingDataCT_GetWatermark_Event != null)
                {
                    _003C_003Ec__DisplayClass2a._watermark = MeetingDataCT_GetWatermark_Event();
                }
                _003C_003Ec__DisplayClass2a._dbPath        = Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.bookInfo_Path);
                _003C_003Ec__DisplayClass2a._isSync        = _003C_003Ec__DisplayClass2a.Home_Window.IsInSync;
                _003C_003Ec__DisplayClass2a._isSyncOwner   = _003C_003Ec__DisplayClass2a.Home_Window.IsSyncOwner;
                _003C_003Ec__DisplayClass2a._webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
                _003C_003Ec__DisplayClass2a._socketMessage = "";
                _003C_003Ec__DisplayClass2a._socket        = null;
                SocketClient instance = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, _003C_003Ec__DisplayClass2a.Home_Window.IsInSync);
                if (instance != null && instance.GetIsConnected())
                {
                    _003C_003Ec__DisplayClass2a._socket = instance;
                }
                _003C_003Ec__DisplayClass2a.cbBooksData = new Dictionary <string, BookVM>();
                if (MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event != null)
                {
                    _003C_003Ec__DisplayClass2a.cbBooksData = MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event(fileItem);
                }
                _003C_003Ec__DisplayClass2a.Home_Window.CloseAllWindow("", true);
                switch (fileItem.FileCate)
                {
                case MeetingFileCate.電子書:
                {
                    InitSyncCenter(_003C_003Ec__DisplayClass2a._dbPath, _003C_003Ec__DisplayClass2a._bookId, _003C_003Ec__DisplayClass2a._account, _003C_003Ec__DisplayClass2a._meetingId);
                    TaskFactory factory2 = Task.Factory;
                    if (action == null)
                    {
                        action = new Action(_003C_003Ec__DisplayClass2a._003CCallOpenBook_003Eb__20);
                    }
                    factory2.StartNew(action);
                    break;
                }

                case MeetingFileCate.Html5投影片:
                {
                    _003C_003Ec__DisplayClass2a._bookPath = _003C_003Ec__DisplayClass2a._bookPath + "\\" + new FileInfo(Directory.GetFiles(_003C_003Ec__DisplayClass2a._bookPath)[0]).Name;
                    InitSyncCenter(_003C_003Ec__DisplayClass2a._dbPath, _003C_003Ec__DisplayClass2a._bookId, _003C_003Ec__DisplayClass2a._account, _003C_003Ec__DisplayClass2a._meetingId);
                    TaskFactory factory3 = Task.Factory;
                    if (action2 == null)
                    {
                        action2 = new Action(_003C_003Ec__DisplayClass2a._003CCallOpenBook_003Eb__22);
                    }
                    factory3.StartNew(action2);
                    break;
                }

                case MeetingFileCate.影片檔:
                {
                    _003C_003Ec__DisplayClass2a._bookPath = _003C_003Ec__DisplayClass2a._bookPath + "\\" + new FileInfo(Directory.GetFiles(_003C_003Ec__DisplayClass2a._bookPath)[0]).Name;
                    TaskFactory factory = Task.Factory;
                    if (action3 == null)
                    {
                        action3 = new Action(_003C_003Ec__DisplayClass2a._003CCallOpenBook_003Eb__24);
                    }
                    factory.StartNew(action3);
                    break;
                }
                }
                if (_003C_003Ec__DisplayClass2a.Home_Window.IsInSync && _003C_003Ec__DisplayClass2a.Home_Window.IsSyncOwner)
                {
                    _003C_003Ec__DisplayClass2c _003C_003Ec__DisplayClass2c = new _003C_003Ec__DisplayClass2c();
                    _003C_003Ec__DisplayClass2c.CS_0024_003C_003E8__locals2b = _003C_003Ec__DisplayClass2a;
                    _003C_003Ec__DisplayClass2c.socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, _003C_003Ec__DisplayClass2a.Home_Window.IsInSync);
                    Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass2c._003CCallOpenBook_003Eb__26));
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
            MouseTool.ShowArrow();
        }
Exemplo n.º 25
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;
            }
        }
Exemplo n.º 26
0
 public void _003CInitSyncCenter_003Eb__1c()
 {
     try
     {
         SyncCenter syncCenter = new SyncCenter();
         syncCenter.bookManager = new BookManager(dbPath);
         int bookPath = _003C_003E4__this.getBookPath(dbPath, bookId, account, meetingId);
         Dictionary <string, object> dictionary = new Dictionary <string, object>();
         dictionary.Add("SBookmark", new BookMarkData());
         dictionary.Add("SAnnotation", new NoteData());
         dictionary.Add("SSpline", new StrokesData());
         dictionary.Add("SLastPage", new LastPageData());
         Dictionary <string, object> dictionary2 = dictionary;
         foreach (KeyValuePair <string, object> item in dictionary2)
         {
             string key                      = item.Key;
             Type   typeFromHandle           = typeof(SyncManager <>);
             Type   type                     = typeFromHandle.MakeGenericType(item.Value.GetType());
             AbstractSyncManager syncManager = (AbstractSyncManager)Activator.CreateInstance(type, account, "free", bookId, bookPath, key, 0, "0", WsTool.GetAbstractSyncCenter_BASE_URL());
             syncCenter.addSyncConditions(key, syncManager);
         }
     }
     catch (Exception ex)
     {
         LogTool.Debug(ex);
     }
 }
Exemplo n.º 27
0
 public static SocketClient GetInstance(string _MeetingID, string _UserID, string _UserName, bool InitToSync)
 {
     if (NetworkTool.GetDomainNameIP(WsTool.GetSyncServer_URL(), 1000).Equals("") && NetworkTool.GetDomainNameIP(WsTool.GetSyncServerImp_URL(), 1000).Equals(""))
     {
         return(null);
     }
     if (instance != null)
     {
         lock (thisLock)
         {
             if (instance == null)
             {
                 Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
             }
             else if (!MeetingID.Equals(_MeetingID))
             {
                 Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
             }
             else
             {
                 for (int i = 1; i <= 10; i++)
                 {
                     bool isConnected = instance.GetIsConnected();
                     if (instance != null && isConnected)
                     {
                         break;
                     }
                     if (i == 10)
                     {
                         Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                     }
                     Thread.Sleep(10);
                 }
             }
         }
     }
     else
     {
         lock (thisLock)
         {
             if (instance == null)
             {
                 Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
             }
             else if (!MeetingID.Equals(_MeetingID))
             {
                 Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
             }
             else
             {
                 for (int j = 1; j <= 10; j++)
                 {
                     bool isConnected2 = instance.GetIsConnected();
                     if (instance != null && isConnected2)
                     {
                         break;
                     }
                     if (j == 10)
                     {
                         Init_Instance(_MeetingID, _UserID, _UserName, InitToSync);
                     }
                     Thread.Sleep(10);
                 }
             }
         }
     }
     return(instance);
 }