Exemplo n.º 1
0
        public void SendNotificationsForState(Guid billDemandUid, WorkflowState state)
        {
            var billDemand = BillDemandBuinessService.GetBillDemand(billDemandUid);
            Action <BillDemand> action;

            if (_senders.TryGetValue(state, out action))
            {
                action.Invoke(billDemand);
            }
        }
        public void RaiseExport(Guid instanceId)
        {
            if (!BillDemandBuinessService.IsBillDemandSupportExport(instanceId))
            {
                throw new ImpossibleToExecuteCommandException("Отправка документа в систему \"ФУС БОСС\" невозможна, т.к. в договоре контрагент заказчик указан не наш банк!");
            }
            WorkflowSupportService.UpgradeWorkflow(Runtime, instanceId);
            var serviceIdentity = AuthenticationService.GetCurrentIdentity();

            BillDemandWorkflowService.RaiseExport(new WorkflowEventArgsWithInitiator(instanceId, serviceIdentity.Id, serviceIdentity.ImpersonatedId));
        }
Exemplo n.º 3
0
        public void CheckAndSendMail(Guid billDemandUid)
        {
            var dataLoadOptions = new DataLoadOptions();

            dataLoadOptions.LoadWith <BillDemand>(d => d.Author);
            dataLoadOptions.LoadWith <BillDemand>(d => d.Filial);

            var billDemand = BillDemandBuinessService.GetBillDemand(billDemandUid, dataLoadOptions);

            foreach (var item in _checkings.Values)
            {
                item.Invoke(billDemand);
            }
        }
 public void RewriteWorkflow(Guid instanceId, WorkflowState state)
 {
     if (state.Type.Id == WorkflowType.BillDemandWorkfow.Id)
     {
         BillDemandBuinessService.CreateBillDemandPreHistory(instanceId, state);
     }
     else if (state.Type.Id == WorkflowType.DemandWorkflow.Id)
     {
         DemandBusinessService.CreateDemandPreHistory(instanceId, state);
     }
     else if (state.Type.Id == WorkflowType.DemandAdjustmentWorkflow.Id)
     {
         DemandAdjustmentBusinessService.CreateDemandAdjustmentPreHistory(instanceId, state);
     }
 }
Exemplo n.º 5
0
        public void CheckAndSendMailForState(Guid billDemandUid, WorkflowState state)
        {
            var dataLoadOptions = new DataLoadOptions();

            dataLoadOptions.LoadWith <BillDemand>(d => d.Author);
            if (state == WorkflowState.BillDemandInAccountingWithExport)
            {
                dataLoadOptions.LoadWith <BillDemand>(d => d.Filial);
            }

            var billDemand = BillDemandBuinessService.GetBillDemand(billDemandUid, dataLoadOptions);
            Action <BillDemand> action;

            if (_checkings.TryGetValue(state, out action))
            {
                action.Invoke(billDemand);
            }
        }
Exemplo n.º 6
0
        private void CheckOnInputInAccountingWithExport(BillDemand billDemand)
        {
            if (BillDemandBuinessService.IsBillDemandSkipInAccountingState(billDemand.Id))
            {
                return;
            }
            if (!billDemand.FilialId.HasValue || !SecurityEntityService.CheckThatSomebodyHasRoleInFilial(BudgetRole.Accountant, billDemand.FilialId.Value, billDemand.BudgetId))
            {
                var parameters = GetDefaultParameters(billDemand);
                if (billDemand.FilialId.HasValue && billDemand.Filial != null)
                {
                    parameters.Add("$FILIALNAME$", billDemand.Filial.Name);
                }
                else
                {
                    parameters.Add("$FILIALNAME$", "Не определено");
                }

                EmailService.SendEmail("BD_NOT_FOUND_ACCOUNTANT", parameters);
            }
        }
        public void SetWorkflowState(Guid instanceId, ServiceIdentity serviceIdentity, string stateName, string comment)
        {
            var workflowState = WorkflowStateService.GetWorkflowState(instanceId);


            if (workflowState.WorkflowStateName != stateName || workflowState.IsInitial)
            //Для черновиков устанавливаем всегда это временно
            {
                WorkflowSupportService.TryUpgradeWorkflow(Runtime, instanceId);

                WorkflowParcelService.AddParcel(instanceId,
                                                new WorkflowSetStateParcel()
                {
                    Comment               = comment,
                    InitiatorId           = serviceIdentity.Id,
                    Command               = WorkflowCommand.Unknown,
                    PreviousWorkflowState = workflowState
                });
                bool isIdled = true;
                using (var sync = new WorkflowSync(Runtime, instanceId))
                {
                    if (!WorkflowSupportService.CreateWorkflowIfNotExists(Runtime, instanceId, workflowState.Type))
                    //Это ожидание создания воркфлоу
                    {
                        sync.WaitHandle.WaitOne(600000);
                        isIdled = sync.WasIdled;
                    }
                }
                //Если воркфлоу не стало идленым - то его необходимо удалить полностью и создать заново
                if (!isIdled)
                {
                    using (var context = this.CreateContext())
                    {
                        context.DeleteWorkflowInPesistenceStore(instanceId);
                        context.SubmitChanges();
                    }
                    using (var sync = new WorkflowSync(Runtime, instanceId))
                    {
                        if (!WorkflowSupportService.CreateWorkflowIfNotExists(Runtime, instanceId, workflowState.Type))
                        //Это ожидание создания воркфлоу
                        {
                            sync.WaitHandle.WaitOne(600000);
                        }
                    }
                }

                var instance         = new StateMachineWorkflowInstance(Runtime, instanceId);
                var newWorkflowState = WorkflowStateService.GetWorkflowState(instanceId);
                if (newWorkflowState.WorkflowStateName != stateName)
                {
                    using (var sync = new WorkflowSync(Runtime, instanceId))
                    //Это ожидание завершения установки состояния воркфлоу
                    {
                        instance.SetState(stateName);
                        sync.WaitHandle.WaitOne(600000);
                    }
                }
                WorkflowState state =
                    WorkflowState.AllStates.First(
                        ws => ws.WorkflowStateName == stateName && ws.Type.Id == workflowState.Type.Id);
                if (!state.IsFinal && !state.IsInitial)
                {
                    WorkflowSupportService.RewriteWorkflow(instanceId, state);
                }
                //Для РД удаляем историю согласования
                if (workflowState.Type == WorkflowType.BillDemandWorkfow)
                {
                    if (state == WorkflowState.BillLimitManagerSighting)
                    {
                        BillDemandBuinessService.LimitExecutorResetSights(instanceId);
                    }

                    BillDemandBuinessService.LimitExecutorResetSights(instanceId);
                    BillDemandBuinessService.LimitManagerResetSights(instanceId);
                }
            }
        }