コード例 #1
0
        public T CreateWorkflowInstance <T>()
            where T : XrmWorkflowActivityInstanceBase, new()
        {
            var instance = new T();

            instance.XrmService        = XrmService;
            instance.LogController     = Controller;
            instance.InitiatingUserId  = XrmService.WhoAmI();
            instance.IsSandboxIsolated = true;
            return(instance);
        }
コード例 #2
0
ファイル: XrmTest.cs プロジェクト: wilku/XRM-Developer-Tool
        public T CreateWorkflowInstance <T>(Entity target = null)
            where T : XrmWorkflowActivityInstanceBase, new()
        {
            var instance = new T();

            instance.XrmService        = XrmService;
            instance.LogController     = Controller;
            instance.InitiatingUserId  = XrmService.WhoAmI();
            instance.IsSandboxIsolated = true;
            if (target != null)
            {
                instance.TargetId   = target.Id;
                instance.TargetType = target.LogicalName;
            }
            return(instance);
        }
コード例 #3
0
ファイル: XrmTest.cs プロジェクト: wilku/XRM-Developer-Tool
        /// <summary>
        /// If there is a separate user connection for the XrmService connection used for scripting limited security
        /// sets that connections user as a member of the teamId and removes them from any other team
        /// </summary>
        /// <param name="teamId">id of the team to set the test script user in</param>
        public void SetTestUserAsTeamMember(Guid teamId)
        {
            var testUserId  = XrmService.WhoAmI();
            var adminUserId = XrmServiceAdmin.WhoAmI();

            //if the same user for both the admin and standard connection then don't bother
            if (testUserId == adminUserId)
            {
                return;
            }

            //get the non-default teams th4e test user a member of
            var teamQuery = XrmServiceAdmin.BuildQuery(Entities.team,
                                                       fields: new string[0],
                                                       conditions: new[] { new ConditionExpression(Fields.team_.isdefault, ConditionOperator.NotEqual, true) });
            var memberJoin = teamQuery.AddLink(Relationships.team_.teammembership_association.EntityName, Fields.team_.teamid, Fields.team_.teamid);

            memberJoin.LinkCriteria.AddCondition(new ConditionExpression(Fields.systemuser_.systemuserid, ConditionOperator.Equal, testUserId));
            var teamsMemberships = XrmServiceAdmin.RetrieveAll(teamQuery);

            //if they are already only a member of the team then return
            if (teamsMemberships.Count() == 1 && teamsMemberships.First().Id == teamId)
            {
                return;
            }

            //remove them from the teams they are a member of
            foreach (var team in teamsMemberships)
            {
                if (!team.GetBoolean(Fields.team_.isdefault))
                {
                    var removeRequest = new RemoveMembersTeamRequest();
                    removeRequest.TeamId    = team.Id;
                    removeRequest.MemberIds = new[] { testUserId };
                    XrmService.Execute(removeRequest);
                }
            }

            //add them to the team
            var addRequest = new AddMembersTeamRequest();

            addRequest.TeamId    = teamId;
            addRequest.MemberIds = new[] { testUserId };
            XrmService.Execute(addRequest);
        }
コード例 #4
0
 public void Debug()
 {
     var me = XrmService.WhoAmI();
 }