Exemple #1
0
        internal void UpdateTaskRecord(TaskEntity updateTask, string tableName)
        {
            var table = tableClient.GetTableReference(tableName);

            TableQuery <AzureTaskEntity> query = new TableQuery <AzureTaskEntity>().Where(TableQuery.GenerateFilterCondition("CrmId", QueryComparisons.Equal, updateTask.CrmId.ToString()));

            var azureEntity = table.ExecuteQuery(query).FirstOrDefault();

            if (azureEntity != null)
            {
                if (!string.IsNullOrEmpty(updateTask.Subject))
                {
                    azureEntity.Subject = updateTask.Subject;
                }
                if (!string.IsNullOrEmpty(updateTask.Body))
                {
                    azureEntity.Body = updateTask.Body;
                }
                if (!string.IsNullOrEmpty(updateTask.DuoDate.ToString()))
                {
                    azureEntity.DuoDate = updateTask.DuoDate.ToString();
                }
                if (!string.IsNullOrEmpty(updateTask.OutlookId))
                {
                    azureEntity.OutlookId = updateTask.OutlookId;
                }
                if (updateTask.NewTaskOwnerId != Guid.Empty)
                {
                    azureEntity.NewTaskOwnerId = updateTask.NewTaskOwnerId.ToString();
                }
                if (updateTask.OwnerId != Guid.Empty)
                {
                    azureEntity.OwnerId = updateTask.OwnerId.ToString();
                }

                TableOperation updateOperation = TableOperation.Replace(azureEntity);
                table.Execute(updateOperation);
            }
        }
        internal string UpdateOutlookTask(TaskEntity taskEntity)
        {
            Trace.TraceInformation("UpdateOutlokTask");

            Task outlookTask = Task.Bind(exchangeService, new ItemId(taskEntity.OutlookId));

            if (!string.IsNullOrEmpty(taskEntity.Subject))
            {
                outlookTask.Subject = taskEntity.Subject;
            }
            if (!string.IsNullOrEmpty(taskEntity.Body))
            {
                outlookTask.Body = taskEntity.Body;
            }
            if (taskEntity.DuoDate != null)
            {
                outlookTask.DueDate = taskEntity.DuoDate;
            }

            outlookTask.Update(ConflictResolutionMode.NeverOverwrite);
            return("Update success");
        }
Exemple #3
0
        internal bool IsTaskNeedUpdate(TaskEntity outlookTask)
        {
            QueryExpression queryExpression = new QueryExpression()
            {
                EntityName = outlookTask.CrmEntityLogicalName,
                Criteria   =
                {
                    FilterOperator = LogicalOperator.And,
                    Conditions     =
                    {
                        new ConditionExpression("subject",       ConditionOperator.Equal, outlookTask.Subject),
                        new ConditionExpression("scheduledend",  ConditionOperator.On,    outlookTask.DuoDate),
                        new ConditionExpression("description",   ConditionOperator.Equal, GetStringWithoutTags(outlookTask.Body)),
                        new ConditionExpression("ylv_outlookid", ConditionOperator.Equal, outlookTask.OutlookId),
                        new ConditionExpression("statecode",     ConditionOperator.Equal, (int)outlookTask.TaskStatus)
                    }
                }
            };

            var task = organizationService.RetrieveMultiple(queryExpression).Entities.FirstOrDefault();

            return(task == null ? true : false);
        }
Exemple #4
0
        internal string UpdateCrmTask(TaskEntity newTask)
        {
            Trace.TraceInformation("UpdateCrmTask");

            try
            {
                Entity updCrmTask = new Entity(newTask.CrmEntityLogicalName);
                updCrmTask.Id = newTask.CrmId;
                if (newTask.TaskStatus != null)
                {
                    updCrmTask["statecode"] = new OptionSetValue((int)newTask.TaskStatus);
                }
                if (!string.IsNullOrEmpty(newTask.Subject))
                {
                    updCrmTask["subject"] = newTask.Subject;
                }
                if (!string.IsNullOrEmpty(newTask.Body))
                {
                    updCrmTask["description"] = GetStringWithoutTags(newTask.Body);
                }
                if (newTask.DuoDate != null)
                {
                    updCrmTask["scheduledend"] = newTask.DuoDate;
                }
                if (!string.IsNullOrEmpty(newTask.OutlookId))
                {
                    updCrmTask["ylv_outlookid"] = newTask.OutlookId;
                }

                organizationService.Update(updCrmTask);
                return("Success update");
            }
            catch (Exception ex)
            {
                return("Update fail\n" + ex.Message);
            }
        }