Пример #1
0
        private Workbench GetWorkbench()
        {
            Workbench workbench = GetWorkbenchFromTitle(Seller);

            if (workbench != null)
            {
                workbench.IsAlreadyExist = true;
            }
            int         cnt  = 0;
            Func <bool> func = null;;

            while (cnt < 3 && workbench == null)
            {
                Automator.OpenWorkbench();
                Func <bool> pred;
                if ((pred = func) == null)
                {
                    pred = (func = () =>
                    {
                        workbench = GetWorkbenchFromTitle(Seller);
                        return(workbench != null);
                    });
                }
                Util.WaitFor(pred, 1000, 100, true);
                cnt++;
            }
            return(workbench);
        }
Пример #2
0
        public async void NavWithWorkbenchAsync(string url)
        {
            if (_workbench == null || !_workbench.IsAlive)
            {
                Workbench workbench = await Task.Factory.StartNew <Workbench>(() => GetWorkbench(), TaskCreationOptions.LongRunning);

                _workbench = workbench;
                workbench  = null;
            }
            bool isok = false;

            if (_workbench != null)
            {
                isok = await Task.Factory.StartNew <bool>(() => _workbench.Nav(url, null));
            }
            if (!isok)
            {
                Util.Nav(url);
            }
            else
            {
                if (_workbench != null)
                {
                    _workbench.BringTop();
                }
            }
        }
Пример #3
0
        public async void ShowDeskFromWorkBenchWhenDeskUIDisabled()
        {
            try
            {
                bool isWbAlive = _workbench != null && _workbench.IsAlive;
                if (!isWbAlive)
                {
                    _workbench = null;
                }
                if (_workbench == null)
                {
                    Workbench workbench = await Task.Factory.StartNew <Workbench>(GetWorkbench, TaskCreationOptions.LongRunning);

                    _workbench = workbench;
                    workbench  = null;
                }
                if (_workbench != null)
                {
                    if (_workbench.IsAlreadyExist)
                    {
                        WaitOpenChatDesk(_workbench);
                    }
                    else
                    {
                        _workbench.HideWorkbench();
                        WaitOpenChatDesk(_workbench);
                        _workbench.CloseWorkbench();
                    }
                }
            }
            catch (Exception exp)
            {
                Log.Exception(exp);
            }
        }
Пример #4
0
        private Workbench GetWorkbenchFromTitle(string seller)
        {
            Workbench workbench = null;
            int       hWnd      = GetHwndFromWorkbenchTitle(seller);

            if (hWnd != 0)
            {
                workbench = new Workbench(hWnd, seller);
            }
            return(workbench);
        }
Пример #5
0
 private void WaitOpenChatDesk(Workbench workbench)
 {
     for (int i = 0; i < 3; i++)
     {
         workbench.OpenChatDesk();
         Util.WaitFor(new Func <bool>(() => { return(Automator.IsControlVisible()); }), 1000, 100, false);
         if (Automator.IsControlVisible())
         {
             break;
         }
     }
 }