Exemple #1
0
        /// <summary>
        /// generate events asyncronously with random delay
        /// </summary>
        public void Working()
        {
            int n = rnd.Next(5, 10);      //adding more randomness

            StartWork?.Invoke(textBox);
            Thread.Sleep(rnd.Next(30 - n, 40 + n) * 100);

            int m = rnd.Next(20, 50);

            while (!IsClicked)
            {
                switch (rnd.Next(1, 5))
                {
                case 1: { FirstEvent?.Invoke(textBox); break; }

                case 2: { SecondEvent?.Invoke(textBox); break; }

                case 3: { ThirdEvent?.Invoke(textBox); break; }

                case 4: { FourthEvent?.Invoke(textBox); break; }

                default: break;
                }
                Thread.Sleep(rnd.Next(100 - n, 100 + m) * 100);
            }
            //StopWork?.Invoke(textBox);
            StopCalled = true;
        }
Exemple #2
0
 public CofactorWorker(double[,] ic, long i, long j)
 {
     _myMinor    = ic;
     RowIndex    = i;
     ColumnIndex = j;
     Id          = Guid.NewGuid();
     _workLoad   = DoMyWork;
     _workLoad.BeginInvoke(CallBack, Id);
 }
Exemple #3
0
    /// <summary>
    /// add location_img to list
    /// </summary>
    /// <param name="name_work"></param>
    /// <param name="description_work"></param>
    public override void AddObject(string name_work, string description_work, Item item_to_mine, int count_item_per_mine)
    {
        GameObject go   = Instantiate(_objectImg_prefab, _parent_obj);
        StartWork  work = go.GetComponent <StartWork>();

        work.SetParams(name_work, description_work);
        work.AddMineItem(item_to_mine, count_item_per_mine);
        works_list.Add(go);
    }
Exemple #4
0
        public void StartWork()
        {
            var startWorkCommand = new StartWork
            {
                TimeyTaskId = Guid.NewGuid(),
                WorkId      = Guid.NewGuid()
            };

            Assert.IsInstanceOf <WorkStarted>(new WorkHandler().Handle(startWorkCommand, Guid.NewGuid()).First());
        }
Exemple #5
0
 private WorkStarted RaiseEvent(StartWork command, string userId)
 {
     return(new WorkStarted
     {
         Id = command.WorkId,
         TimeyTaskId = command.TimeyTaskId,
         UserId = userId,
         StartTime = DateTime.UtcNow
     });
 }
Exemple #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string[] args = Environment.GetCommandLineArgs();
            if (args.Length > 1)
            {
                if (!Directory.Exists(args[1]))
                {
                    Close();
                }

                if (args.Contains("-oc"))
                {
                    if (Directory.Exists($"{args[1]}\\{CollectionStore.DataDirectoryName}"))
                    {
                        TaskProgressWindow taskProgressWindow = new TaskProgressWindow(TaskType.OpenCollections, new object[] { args[1] });
                        taskProgressWindow.ShowDialog();
                        RefreshAfterOpening();
                    }
                    else
                    {
                        Classes.UI.MessageBox.Show("Папка, содержащая данные о коллекциях не обнаружена. Продолжение операции невозможно.",
                                                   App.Name, MessageBoxButton.OK, MessageBoxImage.Warning);

                        Close();
                    }
                }
                else
                {
                    OpenFolderShell(args[1]);
                }
            }
            else
            {
                StartWindow startWindow = new StartWindow();
                startWindow.ShowDialog();
                StartWork work = startWindow.StartWork;
                if (work == StartWork.OpenFolder)
                {
                    MenuItem_OpenFolder_Click(null, null);
                }
                else if (work == StartWork.OpenCollection)
                {
                    MenuItem_OpenCollections_Click(null, null);
                }
                else if (work == StartWork.LastOpenCollection)
                {
                    ProgramSettings settings = ProgramSettings.GetInstance();
                    OpenCollectionsShell(settings.LastOpenCollection);
                }
            }
        }
Exemple #7
0
        public void StartWorkCheckValues()
        {
            var now    = DateTime.UtcNow;
            var userId = Guid.NewGuid();

            var startWorkCommand = new StartWork
            {
                TimeyTaskId = Guid.NewGuid(),
                WorkId      = Guid.NewGuid()
            };

            var workStarted = new WorkHandler().Handle(startWorkCommand, userId.ToString()).First() as WorkStarted;

            Assert.NotNull(workStarted);
            Assert.AreEqual(startWorkCommand.WorkId, workStarted.Id);
            Assert.AreEqual(startWorkCommand.TimeyTaskId, workStarted.TimeyTaskId);
            Assert.AreEqual(userId, workStarted.UserId);
            Assert.IsTrue(now < workStarted.StartTime);
        }
Exemple #8
0
        public async Task StartNoUIWork(string title, int totalCount, Func <IAsyncActionWithProgress <uint> > actionFactory)
        {
            StartWork?.Invoke(title, (uint)totalCount);

            var progressHandler = new Progress <uint>((x) => ProgressWork?.Invoke(x));

            using (var cancelSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)))
            {
                await actionFactory().AsTask(cancelSource.Token, progressHandler);

                await Task.Delay(500);

                if (cancelSource.IsCancellationRequested)
                {
                    CancelWork?.Invoke();
                }
                else
                {
                    CompleteWork?.Invoke();
                }
            }
        }
Exemple #9
0
        public async Task StartNoUIWork(string title, Func <IAsyncAction> actionFactory)
        {
            StartWork?.Invoke(title, 1);

            using (var cancelSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)))
            {
                await actionFactory().AsTask(cancelSource.Token);

                ProgressWork?.Invoke(1);

                await Task.Delay(1000);

                if (cancelSource.IsCancellationRequested)
                {
                    CancelWork?.Invoke();
                }
                else
                {
                    CompleteWork?.Invoke();
                }
            }
        }
Exemple #10
0
        public IEnumerable <EventBase> Handle(StartWork command, string userId)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            if (command.TimeyTaskId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(command.TimeyTaskId));
            }
            if (command.WorkId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(command.WorkId));
            }
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException(nameof(userId));
            }

            return(new List <EventBase> {
                RaiseEvent(command, userId)
            });
        }
Exemple #11
0
 private void Button_LastOpenCollections_Click(object sender, RoutedEventArgs e)
 {
     StartWork = StartWork.LastOpenCollection;
     Close();
 }
Exemple #12
0
 private void Button_OpenFolder_Click(object sender, RoutedEventArgs e)
 {
     StartWork = StartWork.OpenFolder;
     Close();
 }
Exemple #13
0
 internal static void Start(int fileCount)
 {
     FileCount = fileCount;
     StartWork?.Invoke(null, EventArgs.Empty);
     ChangeState?.Invoke(null, EventArgs.Empty);
 }
Exemple #14
0
        private void SetState()
        {
            try
            {
                this.Btn_ComeBackFlow.Enabled       = false;
                this.Btn_DeleteFlowByFlag.Enabled   = false;
                this.Btn_DeleteWFByRealReal.Enabled = false;
                this.Btn_StopWorkFlow.Enabled       = false;
                Int64 workId = Int64.Parse(this.Request.QueryString["WorkID"]);
                //int nodeId=int.Parse(this.Request.QueryString["WorkID"]);
                string flowNo = this.Request.QueryString["FK_Flow"];
                if (workId == 0)
                {
                    this.Alert("@您没有选择流程,操作无效。", false);
                    this.WinClose();
                    return;
                }
                WorkFlow wf = new WorkFlow(new Flow(flowNo), workId);
                if (wf.IsComplete)
                {
                    this.Alert("@流程已经完成,操作无效。", false);
                    this.WinClose();
                    return;
                }
                GenerWorkFlow gwf = new GenerWorkFlow();
                //workId,flowNo
                gwf.WorkID  = workId;
                gwf.FK_Flow = flowNo;
                if (gwf.IsExits == false)
                {
                    wf.DoDeleteWorkFlowByReal(true);
                    throw new Exception("系统出现错误,请与管理员联系:错误原因是当前的流程[" + flowNo + " id=" + workId + "],没有完成,但是流程表里已经不存在这此信息,此流程已经成为无效的流程,可能是测试信息,系统已经删除它。");
                }
                else
                {
                    gwf.Retrieve();
                }

                if (gwf.WFState == WFState.Complete)
                {
                    this.Alert("@流程已经完成,不能够对此操作.", false);
                    this.WinClose();
                    return;
                }
                else if (gwf.WFState == 0)
                {
                    this.Btn_DeleteFlowByFlag.Enabled = true;
                    this.Btn_StopWorkFlow.Enabled     = true;
                }
                else
                {
                    throw new Exception("error ");
                }
                this.Label1.Text = "当前流程状态:" + gwf.WFState;

                Flow fl = new Flow(gwf.FK_Flow);
                //显示日志信息
                StartWork sw = (StartWork)fl.HisStartNode.HisWork;
                sw.OID = workId;
                if (sw.IsExits == false)
                {
                    gwf.Delete();
                    throw new Exception("@开始节点已经物理删除.流程出现错误, 此条流程已经失效, 请你关闭窗口返回系统,刷新记录.");
                }
                sw.Retrieve();


                // 判断流程能不能够删除的权限.

                /*
                 * 如果是  4 涉税审批流程.
                 * 就让征收科室来处理,
                 * 否则让mdg 处理.
                 * */
                if (fl.FK_FlowSort == "4")
                {
                    /* 法征科 */
                    if (WebUser.FK_Dept == "000003")
                    {
                        this.Btn_DeleteWFByRealReal.Enabled = true;
                    }
                }
                else
                {
                    if (WebUser.FK_Dept == "000001")
                    {
                        this.Btn_DeleteWFByRealReal.Enabled = true;
                    }
                }
                //this.UCWFRpt1.BindDataV2(wf);
            }
            catch (Exception ex)
            {
                this.Alert(ex);
                this.WinClose();
            }
        }