Beispiel #1
0
        public async Task <Guid> AddUserToRecordAccessTeamAsync(Guid idTeamTemplate, EntityReference record, Guid idUser)
        {
            var teamId = await this.FindRecordAccessTeamIdAsync(record.Id, idTeamTemplate);

            if (teamId.HasValue)
            {
                if (await IsUserTeamMemberAsync(idUser, teamId.Value))
                {
                    return(teamId.Value);
                }
            }

            var request = new AddUserToRecordTeamRequest()
            {
                TeamTemplateId = idTeamTemplate,
                Record         = record,
                SystemUserId   = idUser,
            };

            var response = await _service.ExecuteAsync <AddUserToRecordTeamResponse>(request);

            StoreRecordAccessGroupCacheValue(idTeamTemplate, record.Id, response.AccessTeamId);

            return(response.AccessTeamId);
        }
        public async Task <string> GetFormattedResultsAsync(Guid idImportJob)
        {
            var importLogRequest = new RetrieveFormattedImportJobResultsRequest
            {
                ImportJobId = idImportJob
            };

            var importLogResponse = await _service.ExecuteAsync <RetrieveFormattedImportJobResultsResponse>(importLogRequest);

            return(importLogResponse.FormattedResults);
        }
Beispiel #3
0
        private async Task UpdateWorkflowXaml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, Workflow workflow)
        {
            string fieldTitle = Workflow.Schema.Headers.xaml;

            {
                string workflowXaml = workflow.Xaml;

                if (!string.IsNullOrEmpty(workflowXaml))
                {
                    commonConfig.CheckFolderForExportExists(this._iWriteToOutput);

                    string fileNameBackUp = EntityFileNameFormatter.GetWorkflowFileName(service.ConnectionData.Name, workflow.PrimaryEntity, workflow.FormattedValues[Workflow.Schema.Attributes.category], workflow.Name, fieldTitle + " BackUp", FileExtension.xml);
                    string filePathBackUp = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileNameBackUp));

                    try
                    {
                        workflowXaml = ContentComparerHelper.FormatXmlByConfiguration(
                            workflowXaml
                            , commonConfig
                            , XmlOptionsControls.WorkflowXmlOptions
                            , workflowId: workflow.Id
                            );

                        File.WriteAllText(filePathBackUp, workflowXaml, new UTF8Encoding(false));

                        this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, Workflow.Schema.EntityLogicalName, workflow.Name, fieldTitle, filePathBackUp);
                    }
                    catch (Exception ex)
                    {
                        this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);
                    }
                }
                else
                {
                    this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, Workflow.Schema.EntityLogicalName, workflow.Name, fieldTitle);
                    this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
                }
            }

            if (workflow.StateCodeEnum == Workflow.Schema.OptionSets.statecode.Activated_1)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionDeactivatingWorkflowFormat2, service.ConnectionData.Name, workflow.Name);

                await service.ExecuteAsync <SetStateResponse>(new SetStateRequest()
                {
                    EntityMoniker = workflow.ToEntityReference(),
                    State         = new OptionSetValue((int)Workflow.Schema.OptionSets.statecode.Draft_0),
                    Status        = new OptionSetValue((int)Workflow.Schema.OptionSets.statuscode.Draft_0_Draft_1),
                });
            }

            this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionUpdatingFieldFormat2, service.ConnectionData.Name, Workflow.Schema.Headers.xaml);

            var newText = doc.ToString(SaveOptions.DisableFormatting);

            var updateEntity = new Workflow
            {
                Id = workflow.Id,
            };

            updateEntity.Attributes[Workflow.Schema.Attributes.xaml] = newText;

            await service.UpdateAsync(updateEntity);

            if (workflow.StateCodeEnum == Workflow.Schema.OptionSets.statecode.Activated_1)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionActivatingWorkflowFormat2, service.ConnectionData.Name, workflow.Name);

                await service.ExecuteAsync <SetStateResponse>(new SetStateRequest()
                {
                    EntityMoniker = workflow.ToEntityReference(),
                    State         = new OptionSetValue((int)Workflow.Schema.OptionSets.statecode.Activated_1),
                    Status        = new OptionSetValue((int)Workflow.Schema.OptionSets.statuscode.Activated_1_Activated_2),
                });
            }

            service.TryDispose();
        }