private static string GetCreateDescriptionName(PluginTreeViewItem item)
        {
            if (item == null)
            {
                return("Create Description");
            }

            if (item.MessageList != null && item.MessageList.Any())
            {
                return("Create Message Description");
            }

            if (item.MessageFilterList != null && item.MessageFilterList.Any())
            {
                return("Create Message Filter Description");
            }

            if (item.StepId.HasValue)
            {
                return("Create Step Description");
            }

            if (item.StepImageId.HasValue)
            {
                return("Create Image Description");
            }

            return("Create Description");
        }
 private async Task AddMessageFilterToSolution(PluginTreeViewItem nodeItem, bool withSelect, string solutionUniqueName)
 {
     if (nodeItem.MessageFilterList != null && nodeItem.MessageFilterList.Any())
     {
         await AddComponentsToSolution(ComponentType.SdkMessageFilter, nodeItem.MessageFilterList, null, withSelect, solutionUniqueName);
     }
 }
        private async void mIOpenDependentComponentsInExplorer_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null)
            {
                return;
            }

            var service = await GetService();

            if (service == null)
            {
                return;
            }

            ComponentType?componentType = nodeItem.ComponentType;
            Guid?         id            = nodeItem.GetId();

            _commonConfig.Save();

            if (componentType.HasValue && id.HasValue)
            {
                WindowHelper.OpenSolutionComponentDependenciesExplorer(_iWriteToOutput, service, null, _commonConfig, (int)nodeItem.ComponentType.Value, id.Value, null);
            }
        }
        private void FillTreeByEntity(IEnumerable <SdkMessageFilter> result)
        {
            var groupsByEnity = result.GroupBy(ent => ent.PrimaryObjectTypeCode).OrderBy(gr => gr.Key);

            foreach (var grEntity in groupsByEnity)
            {
                PluginTreeViewItem nodeEntity = CreateNodeEntity(grEntity.Key, null, grEntity);

                var groupsByMessages = grEntity.GroupBy(ent => ent.MessageName).OrderBy(mess => mess.Key, MessageComparer.Comparer);

                foreach (var mess in groupsByMessages)
                {
                    PluginTreeViewItem nodeMessage = CreateNodeMessage(grEntity.Key, mess.Key, mess);

                    AddTreeNode(nodeEntity, nodeMessage);

                    nodeMessage.IsExpanded = true;
                }

                this.Dispatcher.Invoke(() =>
                {
                    _messageTree.Add(nodeEntity);
                });
            }
        }
        private async Task AddEntityToSolution(RoutedEventArgs e, bool withSelect, string solutionUniqueName, SolutionComponent.Schema.OptionSets.rootcomponentbehavior rootComponentBehavior)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null ||
                !nodeItem.EntityLogicalName.IsValidEntityName()
                )
            {
                return;
            }

            if (!this.IsControlsEnabled)
            {
                return;
            }

            ConnectionData connectionData = GetSelectedConnection();

            if (connectionData == null)
            {
                return;
            }

            var idMetadata = connectionData.GetEntityMetadataId(nodeItem.EntityLogicalName);

            if (!idMetadata.HasValue)
            {
                return;
            }

            await AddComponentsToSolution(ComponentType.Entity, new[] { idMetadata.Value }, rootComponentBehavior, withSelect, solutionUniqueName);
        }
        private void miOpenEntityDependentComponentsInWeb_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null ||
                !nodeItem.EntityLogicalName.IsValidEntityName()
                )
            {
                return;
            }

            if (!this.IsControlsEnabled)
            {
                return;
            }

            ConnectionData connectionData = GetSelectedConnection();

            if (connectionData == null)
            {
                return;
            }

            var idMetadata = connectionData.GetEntityMetadataId(nodeItem.EntityLogicalName);

            if (!idMetadata.HasValue)
            {
                return;
            }

            connectionData.OpenSolutionComponentDependentComponentsInWeb(ComponentType.Entity, idMetadata.Value);
        }
 private bool CanCreateDescription(PluginTreeViewItem item)
 {
     return((item.MessageList != null && item.MessageList.Any()) ||
            (item.MessageFilterList != null && item.MessageFilterList.Any()) ||
            item.StepId.HasValue ||
            item.StepImageId.HasValue
            );
 }
        private async Task AddToSolution(PluginTreeViewItem nodeItem, bool withSelect, string solutionUniqueName)
        {
            ComponentType?componentType = nodeItem.ComponentType;
            var           idList        = nodeItem.GetIdEnumerable();

            if (componentType.HasValue && idList.Any())
            {
                await AddComponentsToSolution(componentType.Value, idList, null, withSelect, solutionUniqueName);
            }
        }
        private void mICollapseNodes_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null)
            {
                return;
            }

            ChangeExpandedInTreeViewItems(new[] { nodeItem }, false);
        }
        private async void AddMessageFilterToCrmSolution_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null)
            {
                return;
            }

            await AddMessageFilterToSolution(nodeItem, true, null);
        }
        private PluginTreeViewItem GetSelectedEntity()
        {
            PluginTreeViewItem result = null;

            if (this.trVMessageTree.SelectedItem != null &&
                this.trVMessageTree.SelectedItem is PluginTreeViewItem
                )
            {
                result = this.trVMessageTree.SelectedItem as PluginTreeViewItem;
            }

            return(result);
        }
        private PluginTreeViewItem CreateNodeEntity(string entityName, string messageName, IEnumerable <SdkMessageFilter> filters)
        {
            var nodeMessage = new PluginTreeViewItem(ComponentType.SdkMessageFilter)
            {
                Name  = entityName,
                Image = _imageEntity,

                EntityLogicalName = entityName,
                MessageName       = messageName,
            };

            nodeMessage.MessageFilterList.AddRange(filters.Where(s => s.SdkMessageFilterId.HasValue).Select(s => s.SdkMessageFilterId.Value).Distinct());

            return(nodeMessage);
        }
        private async void miOpenEntitySolutionsContainingComponentInExplorer_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null ||
                !nodeItem.EntityLogicalName.IsValidEntityName()
                )
            {
                return;
            }

            if (!this.IsControlsEnabled)
            {
                return;
            }

            ConnectionData connectionData = GetSelectedConnection();

            if (connectionData == null)
            {
                return;
            }

            var idMetadata = connectionData.GetEntityMetadataId(nodeItem.EntityLogicalName);

            if (!idMetadata.HasValue)
            {
                return;
            }

            var service = await GetService();

            if (service == null)
            {
                return;
            }

            _commonConfig.Save();

            WindowHelper.OpenExplorerSolutionExplorer(
                _iWriteToOutput
                , service
                , _commonConfig
                , (int)ComponentType.Entity
                , idMetadata.Value
                , null
                );
        }
        private async void btnPublishEntity_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null ||
                !nodeItem.EntityLogicalName.IsValidEntityName()
                )
            {
                return;
            }

            if (!this.IsControlsEnabled)
            {
                return;
            }

            var service = await GetService();

            if (service == null)
            {
                return;
            }

            var entityName = nodeItem.EntityLogicalName;

            this._iWriteToOutput.WriteToOutputStartOperation(service.ConnectionData, Properties.OperationNames.PublishingEntitiesFormat2, service.ConnectionData.Name, entityName);

            ToggleControls(service.ConnectionData, false, Properties.OutputStrings.InConnectionPublishingEntitiesFormat2, service.ConnectionData.Name, entityName);

            try
            {
                var repository = new PublishActionsRepository(service);

                await repository.PublishEntitiesAsync(new[] { entityName });

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.InConnectionPublishingEntitiesCompletedFormat2, service.ConnectionData.Name, entityName);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.InConnectionPublishingEntitiesFailedFormat2, service.ConnectionData.Name, entityName);
            }

            this._iWriteToOutput.WriteToOutputEndOperation(service.ConnectionData, Properties.OperationNames.PublishingEntitiesFormat2, service.ConnectionData.Name, entityName);
        }
        private async void AddMessageFilterToCrmSolutionLast_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null)
            {
                return;
            }

            if (sender is MenuItem menuItem &&
                menuItem.Tag != null &&
                menuItem.Tag is string solutionUniqueName
                )
            {
                await AddMessageFilterToSolution(nodeItem, false, solutionUniqueName);
            }
        }
        private void mIOpenEntityListInWeb_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null ||
                !nodeItem.EntityLogicalName.IsValidEntityName()
                )
            {
                return;
            }

            ConnectionData connectionData = GetSelectedConnection();

            if (connectionData != null)
            {
                connectionData.OpenEntityInstanceListInWeb(nodeItem.EntityLogicalName);
            }
        }
        private async void mICreateDescription_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null)
            {
                return;
            }

            if (!CanCreateDescription(nodeItem))
            {
                return;
            }

            _commonConfig.CheckFolderForExportExists(_iWriteToOutput);

            await CreateDescription(nodeItem);
        }
        private async void miOpenSolutionsContainingComponentInExplorer_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null)
            {
                return;
            }

            ConnectionData connectionData = GetSelectedConnection();

            if (connectionData == null)
            {
                return;
            }

            ComponentType?componentType = nodeItem.ComponentType;
            Guid?         id            = nodeItem.GetId();

            if (componentType.HasValue && id.HasValue)
            {
                var service = await GetService();

                if (service == null)
                {
                    return;
                }

                _commonConfig.Save();

                WindowHelper.OpenExplorerSolutionExplorer(
                    _iWriteToOutput
                    , service
                    , _commonConfig
                    , (int)componentType
                    , id.Value
                    , null
                    );
            }
        }
        private void ContextMenu_Opened(object sender, RoutedEventArgs e)
        {
            if (!(sender is ContextMenu contextMenu))
            {
                return;
            }

            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            var items = contextMenu.Items.OfType <Control>();

            bool isEntity = nodeItem.EntityLogicalName.IsValidEntityName();

            bool isMessage       = nodeItem.MessageList != null && nodeItem.MessageList.Any() && nodeItem.ComponentType == ComponentType.SdkMessage;
            bool isMessageFilter = nodeItem.MessageFilterList != null && nodeItem.MessageFilterList.Any() && nodeItem.ComponentType == ComponentType.SdkMessageFilter;

            bool showDependentComponents = nodeItem.GetId().HasValue&& nodeItem.ComponentType.HasValue;

            ConnectionData connectionData = GetSelectedConnection();

            ActivateControls(items, CanCreateDescription(nodeItem), "contMnCreateDescription");
            SetControlsName(items, GetCreateDescriptionName(nodeItem), "contMnCreateDescription");

            ActivateControls(items, isMessage || isMessageFilter, "contMnAddToSolution", "contMnAddToSolutionLast");
            FillLastSolutionItems(connectionData, items, isMessage || isMessageFilter, AddToCrmSolutionLast_Click, "contMnAddToSolutionLast");

            ActivateControls(items, !isMessageFilter && nodeItem.MessageList != null && nodeItem.MessageList.Any(), "contMnAddToSolutionMessageFilter", "contMnAddToSolutionMessageFilterLast");
            FillLastSolutionItems(connectionData, items, !isMessageFilter && nodeItem.MessageList != null && nodeItem.MessageList.Any(), AddMessageFilterToCrmSolutionLast_Click, "contMnAddToSolutionMessageFilterLast");

            ActivateControls(items, showDependentComponents, "contMnDependentComponents");

            ActivateControls(items, isEntity, "contMnEntity");
            FillLastSolutionItems(connectionData, items, isEntity, AddEntityToCrmSolutionLastIncludeSubcomponents_Click, "contMnAddEntityToSolutionLastIncludeSubcomponents");
            FillLastSolutionItems(connectionData, items, isEntity, AddEntityToCrmSolutionLastDoNotIncludeSubcomponents_Click, "contMnAddEntityToSolutionLastDoNotIncludeSubcomponents");
            FillLastSolutionItems(connectionData, items, isEntity, AddEntityToCrmSolutionLastIncludeAsShellOnly_Click, "contMnAddEntityToSolutionLastIncludeAsShellOnly");
            ActivateControls(items, connectionData.LastSelectedSolutionsUniqueName != null && connectionData.LastSelectedSolutionsUniqueName.Any(), "contMnAddEntityToSolutionLast");

            CheckSeparatorVisible(items);
        }
        private void FillTreeByMessage(IEnumerable <SdkMessage> result)
        {
            var groupsByMessage = result.GroupBy(ent => ent.Name).OrderBy(mess => mess.Key, new MessageComparer());

            foreach (var grMessage in groupsByMessage)
            {
                var nodeMessage = CreateNodeMessage(null, grMessage.Key, grMessage);

                var groupsByEntity = grMessage.GroupBy(ent => ent.PrimaryObjectTypeCodeName).OrderBy(e => e.Key);

                foreach (var grEntity in groupsByEntity)
                {
                    PluginTreeViewItem nodeEntity = CreateNodeEntity(grEntity.Key, grMessage.Key, grEntity);

                    AddTreeNode(nodeMessage, nodeEntity);
                }

                this.Dispatcher.Invoke(() =>
                {
                    _messageTree.Add(nodeMessage);
                });
            }
        }
        private void mIOpenDependentComponentsInWeb_Click(object sender, RoutedEventArgs e)
        {
            PluginTreeViewItem nodeItem = GetItemFromRoutedDataContext <PluginTreeViewItem>(e);

            if (nodeItem == null)
            {
                return;
            }

            ConnectionData connectionData = GetSelectedConnection();

            if (connectionData == null)
            {
                return;
            }

            ComponentType?componentType = nodeItem.ComponentType;
            Guid?         id            = nodeItem.GetId();

            if (componentType.HasValue && id.HasValue)
            {
                connectionData.OpenSolutionComponentDependentComponentsInWeb(componentType.Value, id.Value);
            }
        }
        private async Task LoadLocalAssemblyAsync(string assemblyPath)
        {
            this.Dispatcher.Invoke(() =>
            {
                _assemblyLoad = null;

                _listLocalAssembly.Clear();
                _listMissingCrm.Clear();

                txtBLoadedAssemblyPath.Text           = string.Empty;
                txtBLoadedAssemblyName.Text           = string.Empty;
                txtBLoadedAssemblyVersion.Text        = string.Empty;
                txtBLoadedAssemblyCulture.Text        = string.Empty;
                txtBLoadedAssemblyPublicKeyToken.Text = string.Empty;
            });

            if (string.IsNullOrEmpty(assemblyPath) ||
                !File.Exists(assemblyPath)
                )
            {
                UpdateStatus(Properties.OutputStrings.FileNotExists);
                return;
            }

            if (!IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.LoadingAssemblyFromPathFormat1, assemblyPath);

            AssemblyReaderResult assemblyCheck = null;

            using (var reader = new AssemblyReader())
            {
                assemblyCheck = reader.ReadAssembly(assemblyPath);
            }

            if (assemblyCheck == null)
            {
                ToggleControls(true, Properties.OutputStrings.LoadingAssemblyFromPathFailedFormat1, assemblyPath);
                return;
            }

            assemblyCheck.Content = File.ReadAllBytes(assemblyPath);

            this._assemblyLoad     = assemblyCheck;
            cmBAssemblyToLoad.Text = this._assemblyLoad.FilePath;

            txtBLoadedAssemblyPath.Text           = this._assemblyLoad.FilePath;
            txtBLoadedAssemblyName.Text           = this._assemblyLoad.Name;
            txtBLoadedAssemblyVersion.Text        = this._assemblyLoad.Version;
            txtBLoadedAssemblyCulture.Text        = this._assemblyLoad.Culture;
            txtBLoadedAssemblyPublicKeyToken.Text = this._assemblyLoad.PublicKeyToken;

            var fileInfo = new FileInfo(assemblyPath);

            txtBLoadedAssemblyDateModified.Text = fileInfo.LastWriteTime.ToString(EntityFileNameFormatter.dateFormatYearMonthDayHourMinuteSecond);

            if (PluginAssembly.Id == Guid.Empty)
            {
                txtBFileNameOnServer.Text = this._assemblyLoad.FileName;
            }

            txtBWorkflowActivityGroupName.Text = string.Format("{0} ({1})", this._assemblyLoad.Name, this._assemblyLoad.Version);

            var crmPlugins   = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
            var crmWorkflows = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);

            if (this.PluginAssembly != null && this.PluginAssembly.Id != Guid.Empty)
            {
                var repositoryType = new PluginTypeRepository(_service);
                var pluginTypes    = await repositoryType.GetPluginTypesAsync(this.PluginAssembly.Id);

                foreach (var item in pluginTypes.Where(e => !e.IsWorkflowActivity.GetValueOrDefault()).Select(e => e.TypeName))
                {
                    crmPlugins.Add(item);
                }

                foreach (var item in pluginTypes.Where(e => e.IsWorkflowActivity.GetValueOrDefault()).Select(e => e.TypeName))
                {
                    crmWorkflows.Add(item);
                }
            }

            HashSet <string> assemblyPlugins   = new HashSet <string>(_assemblyLoad.Plugins, StringComparer.InvariantCultureIgnoreCase);
            HashSet <string> assemblyWorkflows = new HashSet <string>(_assemblyLoad.Workflows, StringComparer.InvariantCultureIgnoreCase);

            var pluginsOnlyInCrm  = crmPlugins.Except(assemblyPlugins, StringComparer.InvariantCultureIgnoreCase);
            var workflowOnlyInCrm = crmWorkflows.Except(assemblyWorkflows, StringComparer.InvariantCultureIgnoreCase);

            var pluginsOnlyInLocalAssembly  = assemblyPlugins.Except(crmPlugins, StringComparer.InvariantCultureIgnoreCase);
            var workflowOnlyInLocalAssembly = assemblyWorkflows.Except(crmWorkflows, StringComparer.InvariantCultureIgnoreCase);

            List <PluginTreeViewItem> listLocalAssembly = new List <PluginTreeViewItem>();
            List <PluginTreeViewItem> listMissingCrm    = new List <PluginTreeViewItem>();

            foreach (var pluginTypeName in pluginsOnlyInLocalAssembly.OrderBy(s => s))
            {
                var nodeType = new PluginTreeViewItem(ComponentType.PluginType)
                {
                    Name  = pluginTypeName,
                    Image = _imagePluginType,
                };

                listLocalAssembly.Add(nodeType);
            }

            foreach (var pluginTypeName in workflowOnlyInLocalAssembly.OrderBy(s => s))
            {
                var nodeType = new PluginTreeViewItem(ComponentType.PluginType)
                {
                    Name  = pluginTypeName,
                    Image = _imageWorkflowActivity,

                    IsWorkflowActivity = true,
                };

                listLocalAssembly.Add(nodeType);
            }

            foreach (var pluginTypeName in pluginsOnlyInCrm.OrderBy(s => s))
            {
                var nodeType = new PluginTreeViewItem(ComponentType.PluginType)
                {
                    Name  = pluginTypeName,
                    Image = _imagePluginType,
                };

                listMissingCrm.Add(nodeType);
            }

            foreach (var pluginTypeName in workflowOnlyInCrm.OrderBy(s => s))
            {
                var nodeType = new PluginTreeViewItem(ComponentType.PluginType)
                {
                    Name  = pluginTypeName,
                    Image = _imageWorkflowActivity,

                    IsWorkflowActivity = true,
                };

                listMissingCrm.Add(nodeType);
            }

            this.Dispatcher.Invoke(() =>
            {
                foreach (var item in listLocalAssembly)
                {
                    _listLocalAssembly.Add(item);
                }
                this.trVPluginTreeNew.UpdateLayout();

                foreach (var item in listMissingCrm)
                {
                    _listMissingCrm.Add(item);
                }
                this.trVPluginTreeMissing.UpdateLayout();
            });

            ToggleControls(true, Properties.OutputStrings.LoadingAssemblyFromPathCompletedFormat1, assemblyPath);
        }
 private void AddTreeNode(PluginTreeViewItem node, PluginTreeViewItem childNode)
 {
     node.Items.Add(childNode);
     childNode.Parent = node;
 }
        private async Task CreateDescription(PluginTreeViewItem node)
        {
            if (!CanCreateDescription(node))
            {
                return;
            }

            var service = await GetService();

            if (service == null)
            {
                return;
            }

            this._iWriteToOutput.WriteToOutputStartOperation(service.ConnectionData, Properties.OperationNames.CreatingFileWithDescriptionFormat1);

            ToggleControls(service.ConnectionData, false, Properties.OutputStrings.CreatingDescription);

            StringBuilder result = new StringBuilder();

            string fileName = string.Empty;

            if (node.MessageList != null && node.MessageList.Any())
            {
                var repository = new SdkMessageRepository(service);
                List <SdkMessage> listMessages = await repository.GetMessageByIdsAsync(node.MessageList.ToArray());

                if (string.IsNullOrEmpty(fileName))
                {
                    fileName = EntityFileNameFormatter.GetMessageFileName(service.ConnectionData.Name, node.Name, "Description");

                    if (result.Length > 0)
                    {
                        result.AppendLine().AppendLine().AppendLine();
                    }
                    result.AppendLine(service.ConnectionData.GetConnectionInfo());
                }

                foreach (var message in listMessages)
                {
                    string desc = await EntityDescriptionHandler.GetEntityDescriptionAsync(message, service.ConnectionData);

                    if (!string.IsNullOrEmpty(desc))
                    {
                        if (result.Length > 0)
                        {
                            result.AppendLine().AppendLine().AppendLine();
                        }

                        result.AppendLine(desc);
                    }
                }
            }

            if (node.MessageFilterList != null && node.MessageFilterList.Any())
            {
                var repository = new SdkMessageFilterRepository(service);
                List <SdkMessageFilter> listMessages = await repository.GetMessageFiltersByIdsAsync(node.MessageFilterList.ToArray());

                if (string.IsNullOrEmpty(fileName))
                {
                    fileName = EntityFileNameFormatter.GetMessageFilterFileName(service.ConnectionData.Name, node.Name, "Description");

                    if (result.Length > 0)
                    {
                        result.AppendLine().AppendLine().AppendLine();
                    }
                    result.AppendLine(service.ConnectionData.GetConnectionInfo());
                }

                foreach (var message in listMessages)
                {
                    string desc = await EntityDescriptionHandler.GetEntityDescriptionAsync(message, service.ConnectionData);

                    if (!string.IsNullOrEmpty(desc))
                    {
                        if (result.Length > 0)
                        {
                            result.AppendLine().AppendLine().AppendLine();
                        }

                        result.AppendLine(desc);
                    }
                }
            }

            if (!string.IsNullOrEmpty(fileName))
            {
                string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));

                File.WriteAllText(filePath, result.ToString(), new UTF8Encoding(false));

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);
            }

            ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingDescriptionCompleted);

            this._iWriteToOutput.WriteToOutputEndOperation(service.ConnectionData, Properties.OperationNames.CreatingFileWithDescriptionFormat1, service.ConnectionData.Name);
        }