コード例 #1
0
        private static string GetExecutor(ProtectionDocWithCurentUserId pdWithUserid)
        {
            try
            {
                var result = "";
                //return "А. Ашенова";
                //if (AmbientContext
                //        .Current
                //        .Resolver
                //        .ResolveObject<IExecutor>()
                //        .GetCommand<CheckProtectionDocParallelWorkflowOnFinishedCommand>()
                //        .Process(r => r.Execute(pdWithUserid.ProtectionDoc.Id)))
                //    return pdWithUserid.ProtectionDoc.CurrentWorkflowId.HasValue ? pdWithUserid.ProtectionDoc.CurrentWorkflow.CurrentUser.NameRu : string.Empty;
                var resolver = AmbientContext.Current.Resolver;
                var Executor = resolver.ResolveObject <IExecutor>();
                var command  = Executor.GetCommand <CheckProtectionDocParallelWorkflowOnFinishedCommand>();
                var val1     = command.Process(r => r.Execute(pdWithUserid.ProtectionDoc.Id));

                if (val1)
                {
                    result = pdWithUserid.ProtectionDoc.CurrentWorkflowId.HasValue ? pdWithUserid.ProtectionDoc.CurrentWorkflow.CurrentUser.NameRu : string.Empty;
                    return(result);
                }

                var resolver1 = AmbientContext.Current.Resolver;
                var Executor1 = resolver1.ResolveObject <IExecutor>();
                var command1  = Executor1.GetCommand <GetProtectionDocWorkflowFromParalleByOwnerIdCommand>();
                var workflow  = command1.Process(r => r.Execute(pdWithUserid.ProtectionDoc.Id, pdWithUserid.UserId));

                //var workflow = AmbientContext
                //    .Current
                //    .Resolver
                //    .ResolveObject<IExecutor>()
                //    .GetCommand<GetProtectionDocWorkflowFromParalleByOwnerIdCommand>()
                //    .Process(r => r.Execute(pdWithUserid.ProtectionDoc.Id, pdWithUserid.UserId));
                result = workflow == null ?
                         string.Empty
                    : workflow.CurrentUserId.HasValue ?
                         workflow.CurrentUser.NameRu
                        : string.Empty;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        private static string GetCurrentStageValue(ProtectionDocWithCurentUserId pdWithUserid)
        {
            try
            {
                var result = "";
                //return "Присвоение номера регистрации ТЗ";
                var pd = pdWithUserid.ProtectionDoc;

                if (pd.CurrentWorkflowId.HasValue && pd.CurrentWorkflow != null && pd.CurrentWorkflow.CurrentStageId.HasValue)
                {
                    if (pd.CurrentWorkflow.CurrentStage.Code == RouteStageCodes.ODParallel)
                    {
                        var resolver = AmbientContext.Current.Resolver;
                        var Executor = resolver.ResolveObject <IExecutor>();
                        var command  = Executor.GetCommand <GetProtectionDocWorkflowValueByParallelIdCommand>();

                        var paralletStagesValue = command.Process(r => r.Execute(pd.Id));

                        //var paralletStagesValue = AmbientContext
                        //                              .Current
                        //                              .Resolver
                        //                              .ResolveObject<IExecutor>()
                        //                              .GetCommand<GetProtectionDocWorkflowValueByParallelIdCommand>()
                        //                              .Process(r => r.Execute(pd.Id));
                        if (!string.IsNullOrEmpty(paralletStagesValue))
                        {
                            result = paralletStagesValue;
                            return(result);
                        }
                        //return paralletStagesValue;
                    }
                    else
                    {
                        var resolver = AmbientContext.Current.Resolver;
                        var Executor = resolver.ResolveObject <IExecutor>();
                        var command  = Executor.GetCommand <CheckProtectionDocParallelWorkflowOnFinishedCommand>();
                        var val1     = command.Process(r => r.Execute(pd.Id));
                        //if (AmbientContext
                        //    .Current
                        //    .Resolver
                        //    .ResolveObject<IExecutor>()
                        //    .GetCommand<CheckProtectionDocParallelWorkflowOnFinishedCommand>()
                        //    .Process(r => r.Execute(pd.Id)))
                        //{
                        if (val1)
                        {
                            if (!string.IsNullOrEmpty(pd.CurrentWorkflow.CurrentStage.NameRu))
                            {
                                result = pd.CurrentWorkflow.CurrentStage.NameRu;
                                return(result);
                            }
                            //return pd.CurrentWorkflow.CurrentStage.NameRu;
                        }
                        else
                        {
                            var resolver1 = AmbientContext.Current.Resolver;
                            var Executor1 = resolver1.ResolveObject <IExecutor>();
                            var command1  = Executor1.GetCommand <GetProtectionDocWorkflowValueByParallelIdCommand>();

                            var paralletStagesValue = command1.Process(r => r.Execute(pd.Id));


                            //var paralletStagesValue = AmbientContext
                            //                          .Current
                            //                          .Resolver
                            //                          .ResolveObject<IExecutor>()
                            //                          .GetCommand<GetProtectionDocWorkflowValueByParallelIdCommand>()
                            //                          .Process(r => r.Execute(pd.Id));

                            if (string.IsNullOrEmpty(paralletStagesValue))
                            {
                                result = pd.CurrentWorkflow.CurrentStage.NameRu;
                                return(result);
                            }
                            else
                            {
                                result = string.Join(" | ", pd.CurrentWorkflow.CurrentStage.NameRu, paralletStagesValue);
                                return(result);
                            }
                        }
                    }
                }

                return(string.Empty);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }