Пример #1
0
 public void DeleteMyToday()
 {
     foreach (var entityType in EntitiesToDelete)
     {
         var userIds = new List <Guid>()
         {
             CurrentUserId
         };
         if (CurrentUserId != CurrentUserIdAdmin)
         {
             userIds.Add(CurrentUserIdAdmin);
         }
         foreach (var userId in userIds)
         {
             var query = XrmService.BuildQuery(entityType, new string[] { },
                                               new[]
             {
                 new ConditionExpression("createdby", ConditionOperator.Equal, userId),
                 new ConditionExpression("createdon", ConditionOperator.Today)
             }, null);
             var entities = XrmServiceAdmin.RetrieveAll(query);
             foreach (var entity in entities)
             {
                 try
                 {
                     XrmServiceAdmin.Delete(entity);
                 }
                 catch (Exception)
                 {
                 }
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Returns a query containing all the fields, and required joins for all the given fields
        /// field examples are "did_contactid.firstname" or "customerid|contact.lastname"
        public static QueryExpression BuildSourceQuery(this XrmService xrmService, string sourceType, IEnumerable <string> fields)
        {
            var query = XrmService.BuildQuery(sourceType, new string[0], null, null);

            foreach (var field in fields)
            {
                xrmService.AddRequiredQueryJoins(query, field);
            }
            return(query);
        }
Пример #3
0
        public bool IsInTeam(Guid userId, Guid teamId)
        {
            var query = XrmService.BuildQuery("teammembership", new string[0],
                                              new[]
            {
                new ConditionExpression("systemuserid", ConditionOperator.Equal, userId),
                new ConditionExpression("teamid", ConditionOperator.Equal, teamId),
            }, null);

            return(XrmService.RetrieveFirst(query) != null);
        }
Пример #4
0
        public void DeleteMyToday(string entityType)
        {
            var query = XrmService.BuildQuery(entityType, new string[] { },
                                              new[]
            {
                new ConditionExpression("createdby", ConditionOperator.Equal, CurrentUserId),
                new ConditionExpression("createdon", ConditionOperator.Today)
            }, null);
            var entities = XrmServiceAdmin.RetrieveAll(query);

            foreach (var entity in entities)
            {
                try
                {
                    XrmServiceAdmin.Delete(entity);
                }
                catch (Exception)
                {
                }
            }
        }