Пример #1
0
        public void LoadWorkflow(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            ClearItems();

            // remove listeners here to prevent deletion of loaded items
            m_SceneItemRegistry.itemAdded.RemoveListener(OnSceneItemRegistered);
            m_SceneItemRegistry.itemRemoved.RemoveListener(OnSceneItemRemoved);

            string       stringData = File.ReadAllText(filePath);
            WorkflowData data       = JsonUtility.FromJson <WorkflowData>(stringData);

            foreach (WorkflowStepData stepData in data.steps)
            {
                IStepItem item = m_StepFactory.Create(stepData, m_StepItemPrefab);
                m_StepItems.Add(item);
                foreach (ISceneItem sceneItem in item.sceneItems)
                {
                    sceneItem.itemTransform.gameObject.SetActive(false);
                }
            }

            // add listeners again
            m_SceneItemRegistry.itemAdded.AddListener(OnSceneItemRegistered);
            m_SceneItemRegistry.itemRemoved.AddListener(OnSceneItemRemoved);

            m_CurrentWorkflow = Path.GetFileNameWithoutExtension(filePath);

            stepsChanged.Invoke(m_StepItems);
            workflowLoaded.Invoke();
        }
Пример #2
0
        async Task BuildTransition <T>(WorkflowData workflow, T source, T target, Transition data, Func <T, IInstanceNode> nodegetter)
        {
            IScript condition = string.IsNullOrEmpty(data.Condition) ? null : await compiler.CompileCodeAsync(data.Condition, data.Language ?? workflow.Language ?? ScriptLanguage.NCScript);

            List <InstanceTransition> transitions;

            switch (data.Type)
            {
            case TransitionType.Standard:
                transitions = nodegetter(source).Transitions;
                break;

            case TransitionType.Error:
                transitions = nodegetter(source).ErrorTransitions;
                break;

            case TransitionType.Loop:
                transitions = nodegetter(source).LoopTransitions;
                break;

            default:
                throw new ArgumentException($"Invalid type '{data.Type}'");
            }

            transitions.Add(new InstanceTransition {
                Target    = nodegetter(target),
                Condition = condition,
                Log       = string.IsNullOrEmpty(data.Log) ? null : await compiler.CompileCodeAsync(data.Log, data.Language ?? workflow.Language ?? ScriptLanguage.NCScript)
            });
        }
Пример #3
0
        public void LoadWorkflow(string fileName = null)
        {
            string filePath = workflowDirectory + "/" + fileName;

            if (!File.Exists(filePath))
            {
                return;
            }
            m_ItemRegistry.ClearRegistry();

            string stringData = File.ReadAllText(filePath);

            WorkflowData data = JsonUtility.FromJson <WorkflowData>(stringData);

            foreach (WorkflowStepData stepData in data.steps)
            {
                foreach (SceneItemData itemData in stepData.items)
                {
                    ISceneItem item = m_SceneItemFactory.Create(itemData);
                    item.itemTransform.gameObject.SetActive(false);
                }
            }

            m_WorkflowService.SetWorkflowData(data);
            m_WorkflowService.StartWork();
        }
        public WorkflowPicker(Dictionary <int, WorkflowData> workflows, MigrationEngineWrapper migrationEngine)
        {
            _workflows       = workflows;
            _migrationEngine = migrationEngine;
            SelectedWorkflow = null;

            InitializeComponent();
        }
Пример #5
0
        public bool Read(int id, out WorkflowData workflow)
        {
            string str = this._api.SendRequest("POST", string.Format("/Workflow/Read/{0}", id), "");
            WorkflowReadByIdResponse workflowReadByIdResponse = JsonConvert.DeserializeObject <WorkflowReadByIdResponse>(str);

            workflow = workflowReadByIdResponse.workflow;
            return(workflowReadByIdResponse.IsSuccessful);
        }
Пример #6
0
        public void WriteWorkflow()
        {
            string       workflowFilePath = Path.Combine(workflowDirectory, CurrentWorkflow + ".work");
            WorkflowData data             = m_WorkflowDataFactory.Create(m_StepItems);
            string       jsonData         = JsonUtility.ToJson(data, true);

            File.WriteAllText(workflowFilePath, jsonData);
        }
Пример #7
0
        public void OnEvent(WorkflowStepEndedArgs args)
        {
            //update title
            WorkflowData wf = m_WorkflowService.currentWorkflowData;

            UpdateTitle(wf.name, m_WorkflowService.currentStep + 1, wf.numTotalSteps);
            //check for completion
            OnWorkflowCompleted();
        }
Пример #8
0
        void AddWorkflowToScenario(string nameString, WorkflowData wfData)
        {
            var localResource = localHost.ResourceRepository.FindSingle(p => p.ResourceName.Equals(nameString, StringComparison.InvariantCultureIgnoreCase)) as ResourceModel;

            var localResourceVersion = CreateNewVersionResourceModel(localResource);

            localResourceVersion.WorkflowXaml = new System.Text.StringBuilder(wfData.Different);
            localResourceVersion.VersionInfo  = wfData.VersionInfo;

            _scenarioContext.Add(localResourceVersionString, localResourceVersion);
        }
Пример #9
0
        private void InitializeForm()
        {
            this.WorkflowData            = ServiceManagerFactory.GetServiceManager(this.SiteSetting.SiteSettingType).GetWorkflowDataForItem(this.SiteSetting, this.Item);
            WorkflowListView.ItemsSource = this.WorkflowData.TemplateData.WorkflowTemplates;

            CollectionViewSource cvs = new CollectionViewSource();

            cvs.Source = this.WorkflowData.ActiveWorkflowsData.Workflows;
            cvs.GroupDescriptions.Add(new PropertyGroupDescription("ActivenessGroupName"));
            ActiveWorkflowsListView.ItemsSource = cvs.View;
        }
Пример #10
0
        public void OnEvent(WorkflowLoadArgs args)
        {
            WorkflowData wf = m_WorkflowService.currentWorkflowData;

            m_WorkflowCompleted = false;
            if (wf == null)
            {
                return;
            }

            // Update title
            UpdateTitle(wf.name, m_WorkflowService.currentStep + 1, wf.numTotalSteps);
        }
Пример #11
0
        private void OnWorkflowCompleted()
        {
            WorkflowData wf = m_WorkflowService.currentWorkflowData;

            try
            {
                if (m_WorkflowService.currentStep == wf.numTotalSteps)
                {
                    m_WorkflowCompleted = true;
                    m_Text.text         = m_LocalizationManager.GetLocalized("{{workflow_completed}}");
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
        public override void Executed(WorkflowData data)
        {
            try
            {
                EntityReference agreementRef = AgreementReference.Get(data.Context);

                AgreementService service = new AgreementService(data.OrganizationService);

                IsHasRelatedInvoices.Set(data.Context, service.IsHasRelatedInvoices(agreementRef));
                IsHasRelatedInvoicesWithPaidState.Set(data.Context, service.IsHasRelatedInvoicesWithPaidState(agreementRef));
                IsHasRelatedInvoicesWithCommonType.Set(data.Context, service.IsHasRelatedInvoicesWithCommonType(agreementRef));
            }
            catch (Exception ex)
            {
                data.TracingService.Trace(ex.ToString());

                throw new InvalidWorkflowException(ex.Message);
            }
        }
        /// <inheritdoc />
        public void SetWorkflowData(WorkflowData data)
        {
            if (m_IsRunning)
            {
                StopWork();
            }

            m_CurrentWorkflowData = data;

            m_CurrentStep = m_CurrentDataStep = m_CurrentRepetition = m_RepeatHandle = 0;
            m_TimeTrackingRepo.currentTime = new TimeTrackingData(m_CurrentWorkflowData.numTotalSteps);
            m_TimeProvider.Reset(true);
            m_TimeProvider.paused = true;

            // publish workflow loaded event
            m_EventBroker?.Invoke(new WorkflowLoadArgs()
            {
                msg = m_CurrentWorkflowData.name
            });
        }
Пример #14
0
        public IActionResult StartStep([FromBody] WorkflowData data)
        {
            var instance = this._persistence.GetWorkflowInstance(data.WorkflowId).Result;

            if (instance.Status == WorkflowStatus.Suspended)
            {
                this._host.ResumeWorkflow(data.WorkflowId);
                return(new JsonResult("resume step"));
            }
            if (instance.Status == WorkflowStatus.Complete)
            {
                return(new JsonResult("complete steps"));
            }
            if (instance.Status == WorkflowStatus.Terminated)
            {
                return(new JsonResult("teminate step"));
            }

            return(new JsonResult("step running"));
        }
        public override void Executed(WorkflowData data)
        {
            try
            {
                EntityReference        agreementRef = AgreementReference.Get(data.Context);
                Entities.new_agreement entity       = data.Target.ToEntity <Entities.new_agreement>();

                AgreementService service = new AgreementService(data.OrganizationService);

                service.DeleteRelatedInvoicesWithAutoType(agreementRef);
                service.CreatePaymentSchedule(entity);
                service.UpdateAgreementScheduleDate(entity);
            }
            catch (Exception ex)
            {
                data.TracingService.Trace(ex.ToString());

                throw new InvalidWorkflowException(ex.Message);
            }
        }
Пример #16
0
        protected override void Execute(CodeActivityContext context)
        {
            //======= Variables =======

            var xmlWorkflowData = WorkflowData.Get(context);
            var xmlStructData   = new XDocument();
            var dtIssueList     = new DataTable();
            var dtStatList      = new DataTable();


            //======= Analyze XAML Data =======

            // To be implemented


            //======= Set Output =======

            StructData.Set(context, xmlStructData);
            IssueList.Set(context, dtIssueList);
            StatList.Set(context, dtStatList);
        }
Пример #17
0
        public async void HandleJob(IJobClient jobClient, IJob job)
        {
            // business logic
            var jobKey = job.Key;

            Console.WriteLine("Handling job: " + job);

            Thread.Sleep(3000);

            var connection = new HubConnectionBuilder()
                             .WithUrl("https://localhost:5001/signalrhub", (opts) =>
            {
                opts.HttpMessageHandlerFactory = (message) =>
                {
                    if (message is HttpClientHandler clientHandler)
                    {
                        // bypass SSL certificate
                        clientHandler.ServerCertificateCustomValidationCallback +=
                            (sender, certificate, chain, sslPolicyErrors) => { return(true); }
                    }
                    ;
                    return(message);
                };
            })
                             .Build();

            await connection.StartAsync();

            WorkflowData variables = JsonConvert.DeserializeObject <WorkflowData>(job.Variables);

            await connection.InvokeCoreAsync("WorkflowStepDone", typeof(void), new object[] { job.WorkflowInstanceKey.ToString(), variables.connectionid, job.Type.ToString() });

            jobClient.NewCompleteJobCommand(jobKey)
            .Variables("")
            .Send()
            .GetAwaiter()
            .GetResult();
        }
Пример #18
0
        public void Scenario()
        {
            var data = new WorkflowData()
            {
                Iterations = new List <LoopIteration>(new[]
                {
                    new LoopIteration()
                    {
                        ToAdd = 3
                    },
                    new LoopIteration()
                    {
                        ToAdd = 4
                    },
                    new LoopIteration()
                    {
                        ToAdd = 5
                    }
                })
            };

            var workflowId = StartWorkflow(data);

            WaitForWorkflowToComplete(workflowId, TimeSpan.FromSeconds(30));

            var result = GetData(workflowId);

            result.Sum.Should().Be(3 + 4 + 5);
            result.Iterations[0].Result.Should().Be(3);
            result.Iterations[1].Result.Should().Be(3 + 4);
            result.Iterations[2].Result.Should().Be(3 + 4 + 5);

            result.GreaterThree.Should().Be(2);

            GetStatus(workflowId).Should().Be(WorkflowStatus.Complete);
            UnhandledStepErrors.Count.Should().Be(0);
        }
Пример #19
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     SelectedWorkflow = _workflows[(int)comboBox1.SelectedValue];
     DialogResult     = DialogResult.OK;
     Close();
 }
Пример #20
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     SelectedWorkflow = null;
     DialogResult     = DialogResult.Cancel;
     Close();
 }
Пример #21
0
 protected object[] makeWFHistRow(List <string> statuses, WorkflowData wd)
 {
     return(statuses.Select(x => x == wd.Status ? (object)wd.AgeInt : null).ToArray());
 }
Пример #22
0
        public ULODBEntities SetUpEntityMocks()
        {
            var genericUloList             = UloData.GenerateData(10, ULOID, USERDATA);
            var regionUloList              = UloData.GenerateRegionData(10, 4);
            var uloList                    = genericUloList.Concat(regionUloList).AsQueryable();
            var workflowList               = WorkflowData.GenerateData(10, WORKFLOWID, USERDATA, PERSONUSERID, WORKFLOWKEY, CURRENTWORKFLOWACTIVITYKEY, regionUloList).AsQueryable();
            var userUsersList              = UserUsersData.GenerateData(1, USERDATA.FirstOrDefault(u => u.Id == GROUPUSERID), GROUPUSERID).AsQueryable();
            var requestForReassignmentList = RequestForReassignmentData.GenerateData(10, REQUESTFORREASSIGNMENTID, WORKFLOWID, PERSONUSERID).AsQueryable();

            USERDATA.AddParentUser(PERSONUSERID, userUsersList.ToList()[0]);
            var userList = USERDATA.AsQueryable();
            var unliqudatedObjectsWorkflowQuestionsList          = UnliqudatedObjectsWorkflowQuestionsData.GenerateData(20);
            var unliqudatedObjectsWorkflowQuestionsListQueryable = unliqudatedObjectsWorkflowQuestionsList.AsQueryable();
            var documentsList     = DocumentData.GenerateData(10, PERSONUSERID, documentId: DOCUMENTID, documentTypeId: DOCUMENTTYPEID).AsQueryable();
            var documentTypesList = DocumentTypesData.GenerateData(5, "Contract", DOCUMENTTYPEID).AsQueryable();

            var claimsListPerson = AspNetUserClaimsData.GenerateData(10, PERSONUSERID);
            var claimsListGroup  = AspNetUserClaimsData.GenerateData(5, GROUPUSERID);

            var claimsList = claimsListPerson.Concat(claimsListGroup).AsQueryable();
            var aspnetUserApplicationPermissionClaimsViewList =
                AspnetUserApplicationPermissionClaimsViewData.GenerateData(
                    claimsList.Where(c => c.ClaimType == ApplicationPermissionClaimValue.ClaimType).ToList()).AsQueryable();

            var aspnetUserSubjectCategoryClaimsViewList = AspnetUserSubjectCategoryClaimViewData.GenerateData(
                claimsList.Where(c => c.ClaimType == SubjectCatagoryClaimValue.ClaimType).ToList()).AsQueryable();
            //var notesList = NotesData.GenerateData(3, ULOID, userData).AsQueryable();

            var mockUloSet = new Mock <DbSet <UnliquidatedObligation> >();

            mockUloSet.As <IDbAsyncEnumerable <UnliquidatedObligation> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <UnliquidatedObligation>(uloList.GetEnumerator()));
            mockUloSet.As <IQueryable <UnliquidatedObligation> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <UnliquidatedObligation>(uloList.Provider));
            mockUloSet.As <IQueryable <UnliquidatedObligation> >().Setup(m => m.Expression).Returns(uloList.Expression);
            mockUloSet.As <IQueryable <UnliquidatedObligation> >().Setup(m => m.ElementType).Returns(uloList.ElementType);
            mockUloSet.As <IQueryable <UnliquidatedObligation> >().Setup(m => m.GetEnumerator()).Returns(uloList.GetEnumerator());
            mockUloSet.Setup(m => m.Include(It.IsAny <string>())).Returns(mockUloSet.Object);

            var mockWorkflowSet = new Mock <DbSet <Workflow> >();

            mockWorkflowSet.As <IDbAsyncEnumerable <Workflow> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <Workflow>(workflowList.GetEnumerator()));
            mockWorkflowSet.As <IQueryable <Workflow> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <Workflow>(workflowList.Provider));
            mockWorkflowSet.As <IQueryable <Workflow> >().Setup(m => m.Expression).Returns(workflowList.Expression);
            mockWorkflowSet.As <IQueryable <Workflow> >().Setup(m => m.ElementType).Returns(workflowList.ElementType);
            mockWorkflowSet.As <IQueryable <Workflow> >().Setup(m => m.GetEnumerator()).Returns(workflowList.GetEnumerator());
            mockWorkflowSet.Setup(m => m.Include(It.IsAny <string>())).Returns(mockWorkflowSet.Object);

            var mockUserUsersSet = new Mock <DbSet <UserUser> >();

            mockUserUsersSet.As <IDbAsyncEnumerable <UserUser> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <UserUser>(userUsersList.GetEnumerator()));
            mockUserUsersSet.As <IQueryable <Workflow> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <UserUser>(userUsersList.Provider));
            mockUserUsersSet.As <IQueryable <UserUser> >().Setup(m => m.Expression).Returns(userUsersList.Expression);
            mockUserUsersSet.As <IQueryable <UserUser> >().Setup(m => m.ElementType).Returns(userUsersList.ElementType);
            mockUserUsersSet.As <IQueryable <UserUser> >().Setup(m => m.GetEnumerator()).Returns(userUsersList.GetEnumerator());
            mockUserUsersSet.Setup(m => m.Include(It.IsAny <string>())).Returns(mockUserUsersSet.Object);

            var mockRequestForReassignmentSet = new Mock <DbSet <RequestForReassignment> >();

            mockRequestForReassignmentSet.As <IDbAsyncEnumerable <RequestForReassignment> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <RequestForReassignment>(requestForReassignmentList.GetEnumerator()));
            mockRequestForReassignmentSet.As <IQueryable <RequestForReassignment> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <RequestForReassignment>(requestForReassignmentList.Provider));
            mockRequestForReassignmentSet.As <IQueryable <RequestForReassignment> >().Setup(m => m.Expression).Returns(requestForReassignmentList.Expression);
            mockRequestForReassignmentSet.As <IQueryable <RequestForReassignment> >().Setup(m => m.ElementType).Returns(requestForReassignmentList.ElementType);
            mockRequestForReassignmentSet.As <IQueryable <RequestForReassignment> >().Setup(m => m.GetEnumerator()).Returns(requestForReassignmentList.GetEnumerator());

            var mockUserSet = new Mock <DbSet <AspNetUser> >();

            mockUserSet.As <IDbAsyncEnumerable <AspNetUser> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <AspNetUser>(userList.GetEnumerator()));
            mockUserSet.As <IQueryable <AspNetUser> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <AspNetUser>(userList.Provider));
            mockUserSet.As <IQueryable <AspNetUser> >().Setup(m => m.Expression).Returns(userList.Expression);
            mockUserSet.As <IQueryable <AspNetUser> >().Setup(m => m.ElementType).Returns(userList.ElementType);
            mockUserSet.As <IQueryable <AspNetUser> >().Setup(m => m.GetEnumerator()).Returns(userList.GetEnumerator());

            var mockQuestionsSet = new Mock <DbSet <UnliqudatedObjectsWorkflowQuestion> >();

            mockQuestionsSet.As <IDbAsyncEnumerable <UnliqudatedObjectsWorkflowQuestion> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <UnliqudatedObjectsWorkflowQuestion>(unliqudatedObjectsWorkflowQuestionsListQueryable.GetEnumerator()));
            mockQuestionsSet.As <IQueryable <UnliqudatedObjectsWorkflowQuestion> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <UnliqudatedObjectsWorkflowQuestion>(unliqudatedObjectsWorkflowQuestionsListQueryable.Provider));
            mockQuestionsSet.As <IQueryable <UnliqudatedObjectsWorkflowQuestion> >().Setup(m => m.Expression).Returns(unliqudatedObjectsWorkflowQuestionsListQueryable.Expression);
            mockQuestionsSet.As <IQueryable <UnliqudatedObjectsWorkflowQuestion> >().Setup(m => m.ElementType).Returns(unliqudatedObjectsWorkflowQuestionsListQueryable.ElementType);
            mockQuestionsSet.As <IQueryable <UnliqudatedObjectsWorkflowQuestion> >().Setup(m => m.GetEnumerator()).Returns(unliqudatedObjectsWorkflowQuestionsListQueryable.GetEnumerator());
            mockQuestionsSet.Setup(d => d.Add(It.IsAny <UnliqudatedObjectsWorkflowQuestion>())).Callback <UnliqudatedObjectsWorkflowQuestion>((s) => unliqudatedObjectsWorkflowQuestionsList.Add(s));

            var mockDocumentSet = new Mock <DbSet <Document> >();

            mockDocumentSet.As <IDbAsyncEnumerable <Document> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <Document>(documentsList.GetEnumerator()));
            mockDocumentSet.As <IQueryable <Document> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <Document>(documentsList.Provider));
            mockDocumentSet.As <IQueryable <Document> >().Setup(m => m.Expression).Returns(documentsList.Expression);
            mockDocumentSet.As <IQueryable <Document> >().Setup(m => m.ElementType).Returns(documentsList.ElementType);
            mockDocumentSet.As <IQueryable <Document> >().Setup(m => m.GetEnumerator()).Returns(documentsList.GetEnumerator());
            //mockRequestForReassignmentSet.Setup(m => m.Include(It.IsAny<string>())).Returns(mockRequestForReassignmentSet.Object);

            var mockDocumentTypeSet = new Mock <DbSet <DocumentType> >();

            mockDocumentTypeSet.As <IDbAsyncEnumerable <DocumentType> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <DocumentType>(documentTypesList.GetEnumerator()));
            mockDocumentTypeSet.As <IQueryable <DocumentType> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <DocumentType>(documentTypesList.Provider));
            mockDocumentTypeSet.As <IQueryable <DocumentType> >().Setup(m => m.Expression).Returns(documentTypesList.Expression);
            mockDocumentTypeSet.As <IQueryable <DocumentType> >().Setup(m => m.ElementType).Returns(documentTypesList.ElementType);
            mockDocumentTypeSet.As <IQueryable <DocumentType> >().Setup(m => m.GetEnumerator()).Returns(documentTypesList.GetEnumerator());

            var mockClaimsSet = new Mock <DbSet <AspNetUserClaim> >();

            mockClaimsSet.As <IDbAsyncEnumerable <AspNetUserClaim> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <AspNetUserClaim>(claimsList.GetEnumerator()));
            mockClaimsSet.As <IQueryable <AspNetUserClaim> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <AspNetUserClaim>(claimsList.Provider));
            mockClaimsSet.As <IQueryable <AspNetUserClaim> >().Setup(m => m.Expression).Returns(claimsList.Expression);
            mockClaimsSet.As <IQueryable <AspNetUserClaim> >().Setup(m => m.ElementType).Returns(claimsList.ElementType);
            mockClaimsSet.As <IQueryable <AspNetUserClaim> >().Setup(m => m.GetEnumerator()).Returns(claimsList.GetEnumerator());

            var mockaspnetUserApplicationPermissionClaimsViewSet = new Mock <DbSet <AspnetUserApplicationPermissionClaim> >();

            mockaspnetUserApplicationPermissionClaimsViewSet.As <IDbAsyncEnumerable <AspnetUserApplicationPermissionClaim> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <AspnetUserApplicationPermissionClaim>(aspnetUserApplicationPermissionClaimsViewList.GetEnumerator()));
            mockaspnetUserApplicationPermissionClaimsViewSet.As <IQueryable <AspnetUserApplicationPermissionClaim> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <AspnetUserApplicationPermissionClaim>(aspnetUserApplicationPermissionClaimsViewList.Provider));
            mockaspnetUserApplicationPermissionClaimsViewSet.As <IQueryable <AspnetUserApplicationPermissionClaim> >().Setup(m => m.Expression).Returns(aspnetUserApplicationPermissionClaimsViewList.Expression);
            mockaspnetUserApplicationPermissionClaimsViewSet.As <IQueryable <AspnetUserApplicationPermissionClaim> >().Setup(m => m.ElementType).Returns(aspnetUserApplicationPermissionClaimsViewList.ElementType);
            mockaspnetUserApplicationPermissionClaimsViewSet.As <IQueryable <AspnetUserApplicationPermissionClaim> >().Setup(m => m.GetEnumerator()).Returns(aspnetUserApplicationPermissionClaimsViewList.GetEnumerator());

            //AspnetUserSubjectCategoryClaimViewData
            var mockaspnetUserSubjectCategoryClaimViewSet = new Mock <DbSet <AspnetUserSubjectCategoryClaim> >();

            mockaspnetUserSubjectCategoryClaimViewSet.As <IDbAsyncEnumerable <AspnetUserSubjectCategoryClaim> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <AspnetUserSubjectCategoryClaim>(aspnetUserSubjectCategoryClaimsViewList.GetEnumerator()));
            mockaspnetUserSubjectCategoryClaimViewSet.As <IQueryable <AspnetUserSubjectCategoryClaim> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <AspnetUserSubjectCategoryClaim>(aspnetUserSubjectCategoryClaimsViewList.Provider));
            mockaspnetUserSubjectCategoryClaimViewSet.As <IQueryable <AspnetUserSubjectCategoryClaim> >().Setup(m => m.Expression).Returns(aspnetUserSubjectCategoryClaimsViewList.Expression);
            mockaspnetUserSubjectCategoryClaimViewSet.As <IQueryable <AspnetUserSubjectCategoryClaim> >().Setup(m => m.ElementType).Returns(aspnetUserSubjectCategoryClaimsViewList.ElementType);
            mockaspnetUserSubjectCategoryClaimViewSet.As <IQueryable <AspnetUserSubjectCategoryClaim> >().Setup(m => m.GetEnumerator()).Returns(aspnetUserSubjectCategoryClaimsViewList.GetEnumerator());

            var mockULODBEntities = new Mock <ULODBEntities>();

            mockULODBEntities.Setup(c => c.UnliquidatedObligations).Returns(mockUloSet.Object);
            mockULODBEntities.Setup(c => c.Workflows).Returns(mockWorkflowSet.Object);
            mockULODBEntities.Setup(c => c.UserUsers).Returns(mockUserUsersSet.Object);
            mockULODBEntities.Setup(c => c.RequestForReassignments).Returns(mockRequestForReassignmentSet.Object);
            mockULODBEntities.Setup(c => c.AspNetUsers).Returns(mockUserSet.Object);
            mockULODBEntities.Setup(c => c.UnliqudatedObjectsWorkflowQuestions).Returns(mockQuestionsSet.Object);
            mockULODBEntities.Setup(c => c.Documents).Returns(mockDocumentSet.Object);
            mockULODBEntities.Setup(c => c.DocumentTypes).Returns(mockDocumentTypeSet.Object);
            mockULODBEntities.Setup(c => c.AspNetUserClaims).Returns(mockClaimsSet.Object);
            mockULODBEntities.Setup(c => c.AspnetUserApplicationPermissionClaims).Returns(mockaspnetUserApplicationPermissionClaimsViewSet.Object);
            mockULODBEntities.Setup(c => c.AspnetUserSubjectCategoryClaims).Returns(mockaspnetUserSubjectCategoryClaimViewSet.Object);
            return(mockULODBEntities.Object);
        }
Пример #23
0
        public static object RetrieveObjectDefinition(IOrganizationService service, SolutionComponentBase component)
        {
            var componentId = component.ObjectId;

            if (component.Type == SolutionComponentType.Entity)
            {
                return(GetEntityMetadata(service, componentId));
            }
            else if (component.Type == SolutionComponentType.Field)
            {
                return(GetAttributeMetadata(service, component.ParentSolutionComponent.LogicalName, componentId));
            }
            else if (component.Type == SolutionComponentType.Relationship)
            {
                return(GetRelationshipMetadata(service, componentId));
            }
            else if (component.Type == SolutionComponentType.OptionSet)
            {
                return(GetOptionSetMetadata(service, componentId));
            }
            else if (component.Type == SolutionComponentType.EntityKey)
            {
                return(GetEntityKeyMetadata(service, component.ParentSolutionComponent.LogicalName, componentId));
            }
            else if (component.Type == SolutionComponentType.Role)
            {
                var logicalName = new RoleData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToRoleData());
            }
            else if (component.Type == SolutionComponentType.RolePrivilege)
            {
                var logicalName = new RolePrivilegeData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToRolePrivilegeData());
            }
            else if (component.Type == SolutionComponentType.View)
            {
                var logicalName = new ViewData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToViewData());
            }
            else if (component.Type == SolutionComponentType.Workflow)
            {
                var logicalName = new WorkflowData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToWorkflowData());
            }
            else if (component.Type == SolutionComponentType.EmailTemplate)
            {
                var logicalName = new EmailTemplateData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToEmailTemplateData());
            }
            else if (component.Type == SolutionComponentType.Ribbon)
            {
                var logicalName = new RibbonData().EntityLogicalName;
                var data        = GetRibbonData(service, componentId);
                return(data.ToRibbonData());
            }
            else if (component.Type == SolutionComponentType.Chart)
            {
                var logicalName = new ChartData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToChartData());
            }
            else if (component.Type == SolutionComponentType.Form)
            {
                var logicalName = new FormData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToFormData());
            }
            else if (component.Type == SolutionComponentType.WebResource)
            {
                var logicalName = new WebResourceData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToWebResourceData());
            }
            else if (component.Type == SolutionComponentType.Sitemap)
            {
                var logicalName = new SiteMapData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToSiteMap());
            }
            else if (component.Type == SolutionComponentType.ConnectionRole)
            {
                var logicalName = new ConnectionRoleData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToConnectionRoleData());
            }
            else if (component.Type == SolutionComponentType.HierarchyRule)
            {
                var logicalName = new HierarchyRuleData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToHierarchyRuleData());
            }
            else if (component.Type == SolutionComponentType.App)
            {
                var logicalName = new AppData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToAppData());
            }
            else if (component.Type == SolutionComponentType.PluginAssembly)
            {
                var logicalName = new PluginAssemblyData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToPluginAssemblyData());
            }
            else if (component.Type == SolutionComponentType.PluginStep)
            {
                var logicalName = new PluginStepData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToPluginStepData());
            }
            else if (component.Type == SolutionComponentType.RoutingRule)
            {
                var logicalName = new RoutingRuleData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToRoutingRuleData());
            }
            else if (component.Type == SolutionComponentType.ConvertRule)
            {
                var logicalName = new ConvertRuleData().EntityLogicalName;
                return(GetGenericData(service, logicalName, componentId)
                       .ToConvertRuleData());
            }
            return(null);
        }