Esempio n. 1
0
        private void ThreadMethod()
        {
            m_running = true;
                while (m_running)
                {
                    if(!connected)
                    {
                        try
                        {
                            ((MainForm) GlobalCache.Instance().MainForm).ServiceStatus.Text = " Đang kết nối ...";
                            //ClientUtility.Log(logger, ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text);
                            serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding);
                            serverService.JoinDistributingGroup(CurrentDepartment.Get());
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = "Kết nối với dịch vụ.";
                            //ClientUtility.Log(logger, ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text);
                        }
                        catch (Exception)
                        {

                        }
                        Thread.Sleep(100);
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                }
        }
Esempio n. 2
0
        private void ThreadMethod()
        {
            m_running = true;
                while (m_running)
                {
                    if(!connected)
                    {
                        try
                        {

                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Đang kết nối ...";
                            serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding);
                            serverService.JoinDistributingGroup(CurrentDepartment.Get());
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Kết nối với dịch vụ.";
                            Thread.Sleep(100);

                        }
                        catch (Exception ex)
                        {
                            //ClientUtility.Log(logger,ex.Message);
                        }

                    }
                    else
                    {
                        try
                        {
                            // Wait until thread is stopped
                            if (!IsDoingStockOut)
                            {
                                ((MainForm) GlobalCache.Instance().MainForm).ServiceStatus.Text =
                                    " Yêu cầu thông tin ... ";
                                //serverService.RequestDepartmentStockOut(CurrentDepartment.Get().DepartmentId);
                                ((MainForm) GlobalCache.Instance().MainForm).ServiceStatus.Text = " Chờ lệnh ... ";
                            }
                            Thread.Sleep(SleepTime);
                        }
                        catch (Exception)
                        {
                            if(serverService.State == CommunicationState.Faulted
                               || serverService.State == CommunicationState.Closed)
                            {
                                connected = false;
                                serverService = null;
                            }
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Thất bại ... ";
                            //ClientUtility.Log(logger, ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text);
                            Thread.Sleep(1000 * 3);
                            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Xử lý lại ... ";
                        }

                    }
                }
        }