Example #1
0
        public void Writer_Restore_SelfRestore()
        {
            #region hell

            var writer =
                new HashWriter(new HashMapConfiguration("TestRestore", HashMapCreationMode.CreateNew, 2, 1,
                                                        HashFileType.Distributor));
            writer.CreateMap();
            writer.SetServer(0, "localhost", storageServer1, 157);
            writer.SetServer(1, "localhost", storageServer2, 157);
            writer.Save();

            var common = new CommonConfiguration(1, 100);

            var storageNet1   = new StorageNetConfiguration("localhost", storageServer1, 157, "testService", 10);
            var storageConfig = new StorageConfiguration("TestRestore", 1, 10, TimeSpan.FromMilliseconds(10000),
                                                         TimeSpan.FromMilliseconds(200), TimeSpan.FromHours(1), TimeSpan.FromHours(1), false);

            var factory  = new TestInMemoryDbFactory();
            var storage1 = new WriterApi(storageNet1, storageConfig, common);

            #endregion

            _proxy.Start();
            _distr.Start();

            _proxy.Int.SayIAmHere("localhost", distrServer1);

            storage1.Build();
            storage1.AddDbModule(factory);
            storage1.Start();

            const int count = 50;

            for (int i = 0; i < count; i++)
            {
                var wait = _proxy.Int.CreateSync(i, i);

                if (wait.IsError)
                {
                    wait = _proxy.Int.CreateSync(i, i);
                }

                Assert.AreEqual(RequestState.Complete, wait.State);
            }

            Assert.AreEqual(count, factory.Db.Local + factory.Db.Remote);

            writer =
                new HashWriter(new HashMapConfiguration("TestRestore", HashMapCreationMode.CreateNew, 1, 1,
                                                        HashFileType.Distributor));
            writer.CreateMap();
            writer.SetServer(0, "localhost", storageServer1, 157);
            writer.Save();

            storage1.Api.UpdateModel();
            storage1.Api.Restore(new ServerAddress("localhost", distrServer12), true);

            Thread.Sleep(1000);

            Assert.AreEqual(count, factory.Db.Local);

            _proxy.Dispose();
            _distr.Dispose();
            storage1.Dispose();
        }
Example #2
0
 public void ConfigureServices(IDotvvmServiceCollection options)
 {
     CommonConfiguration.ConfigureServices(options);
 }
        private async Task DifferenceSiteMapXml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, SiteMap siteMap)
        {
            string siteMapXml = siteMap.SiteMapXml;

            string fieldTitle = SiteMap.Schema.Headers.sitemapxml;

            string fileTitle2 = EntityFileNameFormatter.GetSiteMapFileName(service.ConnectionData.Name, siteMap.SiteMapNameUnique, siteMap.Id, fieldTitle, FileExtension.xml);
            string filePath2  = FileOperations.GetNewTempFilePath(Path.GetFileNameWithoutExtension(fileTitle2), Path.GetExtension(fileTitle2));

            if (string.IsNullOrEmpty(siteMapXml))
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SiteMap.Schema.EntityLogicalName, siteMap.SiteMapNameUnique, fieldTitle);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
                return;
            }

            try
            {
                siteMapXml = ContentComparerHelper.FormatXmlByConfiguration(
                    siteMapXml
                    , commonConfig
                    , XmlOptionsControls.SiteMapXmlOptions
                    , schemaName: AbstractDynamicCommandXsdSchemas.SiteMapXmlSchema
                    , siteMapUniqueName: siteMap.SiteMapNameUnique ?? string.Empty
                    );

                File.WriteAllText(filePath2, siteMapXml, new UTF8Encoding(false));

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, SiteMap.Schema.EntityLogicalName, siteMap.SiteMapNameUnique, fieldTitle, filePath2);
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);
            }

            string fileLocalPath  = filePath;
            string fileLocalTitle = Path.GetFileName(filePath);

            await this._iWriteToOutput.ProcessStartProgramComparerAsync(service.ConnectionData, fileLocalPath, filePath2, fileLocalTitle, fileTitle2);

            service.TryDispose();
        }
 private Task GetCurrentSystemFormXmlAsync(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, SystemForm systemForm)
 {
     return(Task.Run(() => GetCurrentSystemFormXml(service, commonConfig, systemForm)));
 }
        private async Task GetCurrentFormDescription(IOrganizationServiceExtented service, CommonConfiguration commonConfig, SystemForm systemForm)
        {
            string formXml = systemForm.FormXml;

            if (string.IsNullOrEmpty(formXml))
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SystemForm.Schema.EntityLogicalName, systemForm.Name, SystemForm.Schema.Headers.formxml);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
                return;
            }

            commonConfig.CheckFolderForExportExists(this._iWriteToOutput);

            var descriptor = new SolutionComponentDescriptor(service);

            descriptor.SetSettings(commonConfig);

            var handler = new FormDescriptionHandler(descriptor, new DependencyRepository(service));

            string fileName = EntityFileNameFormatter.GetSystemFormFileName(service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name, "FormDescription", FileExtension.txt);
            string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));

            try
            {
                XElement doc = XElement.Parse(formXml);

                string desc = await handler.GetFormDescriptionAsync(doc, systemForm.ObjectTypeCode, systemForm.Id, systemForm.Name, systemForm.FormattedValues[SystemForm.Schema.Attributes.type]);

                File.WriteAllText(filePath, desc, new UTF8Encoding(false));

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, SystemForm.Schema.EntityLogicalName, systemForm.Name, "FormDescription", filePath);

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

                service.TryDispose();
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);
            }
        }
 public async Task ExecuteCopingToClipboardSystemFormCurrentTabsAndSections(ConnectionData connectionData, CommonConfiguration commonConfig, JavaScriptObjectType jsObjectType, string entityName, Guid formId, int formType)
 {
     await ConnectAndExecuteActionAsync(connectionData
                                        , Properties.OperationNames.CopingToClipboardSystemFormCurrentTabsAndSections
                                        , (service) => CopingToClipboardSystemFormCurrentTabsAndSections(service, commonConfig, jsObjectType, entityName, formId, formType)
                                        );
 }
        private async Task <Tuple <bool, SystemForm> > GetSystemFormByAttribute(IOrganizationServiceExtented service, CommonConfiguration commonConfig, string systemFormId)
        {
            var repositorySystemForm = new SystemFormRepository(service);

            var systemForm = await repositorySystemForm.GetByIdAsync(Guid.Parse(systemFormId), ColumnSetInstances.AllColumns);

            if (systemForm == null)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionSystemFormWasNotFoundFormat2, service.ConnectionData.Name, systemFormId);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);

                WindowHelper.OpenSystemFormExplorer(_iWriteToOutput, service, commonConfig, systemFormId);
            }

            return(Tuple.Create(systemForm != null, systemForm));
        }
Example #8
0
 /// <summary>Configures common measurement settings for the personality.</summary>
 /// <param name="lte">Specifies the LTE signal to configure.</param>
 /// <param name="commonConfig">Specifies the common settings to apply.</param>
 /// <param name="selectorString">Pass an empty string. The signal name that is passed when creating the signal configuration is used.
 /// See the RFmx help for more documention of this parameter.</param>
 public static void ConfigureCommon(RFmxLteMX lte, CommonConfiguration commonConfig, string selectorString = "")
 {
     lte.SetSelectedPorts(selectorString, commonConfig.SelectedPorts);
     lte.ConfigureRF(selectorString, commonConfig.CenterFrequency_Hz, commonConfig.ReferenceLevel_dBm, commonConfig.ExternalAttenuation_dB);
     lte.ConfigureDigitalEdgeTrigger(selectorString, commonConfig.DigitalTriggerSource, RFmxLteMXDigitalEdgeTriggerEdge.Rising, commonConfig.TriggerDelay_s, commonConfig.TriggerEnabled);
 }
Example #9
0
        private void HandleOpenPluginStepsExplorerInternal(ConnectionData connectionData, CommonConfiguration commonConfig, SelectedFile selectedFile)
        {
            string pluginType = string.Empty;

            if (selectedFile != null)
            {
                pluginType = CSharpCodeHelper.GetClassInFileBySyntaxTree(selectedFile.FilePath);

                this.WriteToOutput(connectionData, Properties.OutputStrings.GettingClassTypeFullNameFromFileFormat2, selectedFile.FilePath, pluginType);
                this.ActivateOutputWindow(connectionData);
            }

            Controller.StartShowingPluginStepsExplorer(connectionData, commonConfig, string.Empty, pluginType, string.Empty);
        }
        public void HandleCheckingWorkflowsUsedEntities(ConnectionData connectionData, bool openExplorer)
        {
            CommonConfiguration commonConfig = CommonConfiguration.Get();

            if (connectionData == null)
            {
                if (!HasCurrentCrmConnection(out ConnectionConfiguration crmConfig))
                {
                    return;
                }

                connectionData = crmConfig.CurrentConnectionData;
            }

            if (connectionData != null && commonConfig != null)
            {
                CheckWishToChangeCurrentConnection(connectionData);

                var thread = new System.Threading.Thread(() =>
                {
                    try
                    {
                        var form = new WindowSelectFolderForExport(connectionData, commonConfig.FolderForExport, commonConfig.DefaultFileAction);

                        if (form.ShowDialog().GetValueOrDefault())
                        {
                            commonConfig.FolderForExport   = form.SelectedFolder;
                            commonConfig.DefaultFileAction = form.GetFileAction();

                            connectionData = form.GetConnectionData();

                            if (connectionData != null)
                            {
                                commonConfig.Save();

                                ActivateOutputWindow(connectionData);
                                WriteToOutputEmptyLines(connectionData, commonConfig);

                                CheckWishToChangeCurrentConnection(connectionData);

                                try
                                {
                                    Controller.StartCheckingWorkflowsUsedEntities(connectionData, commonConfig, openExplorer);
                                }
                                catch (Exception ex)
                                {
                                    WriteErrorToOutput(connectionData, ex);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DTEHelper.WriteExceptionToOutput(connectionData, ex);
                    }
                });

                thread.SetApartmentState(System.Threading.ApartmentState.STA);

                thread.Start();
            }
        }
Example #11
0
        public static void ConfigureCommon(ref RFmxInstrMX sessionHandle, ref RFmxSpecAnMX specAnSignal, CommonConfiguration commonConfig,
                                           AutoLevelConfiguration autoLevelConfig, string selectorString = "")
        {
            sessionHandle.ConfigureFrequencyReference("", commonConfig.FrequencyReferenceSource, 10e6);
            sessionHandle.SetLOSource("", commonConfig.LOSource);
            sessionHandle.SetDownconverterFrequencyOffset("", commonConfig.LOOffset);
            specAnSignal.ConfigureDigitalEdgeTrigger(selectorString, commonConfig.DigitalEdgeSource, commonConfig.DigitalEdgeType, commonConfig.TriggerDelay_s, commonConfig.EnableTrigger);
            specAnSignal.ConfigureFrequency(selectorString, commonConfig.CenterFrequency_Hz);
            specAnSignal.Spectrum.Configuration.ConfigureSpan(selectorString, commonConfig.Span_Hz);
            specAnSignal.ConfigureExternalAttenuation(selectorString, commonConfig.ExternalAttenuation_dB);

            if (autoLevelConfig.AutoLevelReferenceLevel)
            {
                specAnSignal.AutoLevel(selectorString, commonConfig.Span_Hz, autoLevelConfig.AutoLevelMeasureTime_s, out _);
            }
            else
            {
                specAnSignal.ConfigureReferenceLevel(selectorString, commonConfig.ReferenceLevel_dBm);
            }
        }
 public BaseTest()
 {
     Fixture = CommonConfiguration.CreateFixture();
     //Container = new WebHostBuilder().UseStartup<StartupTest>().Build().Services;
 }
 public async Task ExecuteShowingSecurityRolesExplorer(ConnectionData connectionData, CommonConfiguration commonConfig, string selection)
 {
     await ConnectAndExecuteActionAsync(connectionData
                                        , Properties.OperationNames.OpeningSecurityRolesExplorerFormat1
                                        , (service) => WindowHelper.OpenRolesExplorer(this._iWriteToOutput, service, commonConfig, selection)
                                        );
 }
Example #14
0
        public static void RegisterDependencies(IServiceCollection services)
        {
            CommonConfiguration.RegisterDependencies(services);

            services.AddTransient <IUnitOfWork, UnitOfWork>();
        }
 public async Task ExecuteOpeningLinkedSystemForm(ConnectionData connectionData, CommonConfiguration commonConfig, ActionOnComponent actionOnComponent, string entityName, Guid formId, int formType)
 {
     await ConnectAndExecuteActionAsync(connectionData
                                        , Properties.OperationNames.ActionOnComponentFormat3
                                        , (service) => OpeningLinkedSystemForm(service, commonConfig, actionOnComponent, entityName, formId, formType)
                                        , "Linked " + SystemForm.EntitySchemaName
                                        , EnumDescriptionTypeConverter.GetEnumNameByDescriptionAttribute(ActionOnComponent.OpenInWeb)
                                        );
 }
Example #16
0
        private async Task <Tuple <bool, Workflow> > GetWorkflowByAttribute(IOrganizationServiceExtented service, CommonConfiguration commonConfig, string workflowId)
        {
            var repositoryWorkflow = new WorkflowRepository(service);

            var workflow = await repositoryWorkflow.GetByIdAsync(Guid.Parse(workflowId), ColumnSetInstances.AllColumns);

            if (workflow == null)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionWorkflowWasNotFoundFormat2, service.ConnectionData.Name, workflowId);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);

                WindowHelper.OpenWorkflowExplorer(_iWriteToOutput, service, commonConfig, workflowId);
            }

            return(Tuple.Create(workflow != null, workflow));
        }
 public async Task ExecuteChangingLinkedSystemFormInEntityEditor(ConnectionData connectionData, CommonConfiguration commonConfig, string entityName, Guid formId, int formType)
 {
     await ConnectAndExecuteActionAsync(connectionData
                                        , Properties.OperationNames.ChangingLinkedSystemFormInEntityEditorFormat1
                                        , (service) => WindowHelper.OpenEntityEditor(_iWriteToOutput, service, commonConfig, SystemForm.EntityLogicalName, formId)
                                        );
 }
Example #18
0
        private async Task DifferenceWorkflowXaml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, Workflow workflow)
        {
            string workflowXaml = workflow.Xaml;

            string fieldTitle = Workflow.Schema.Headers.xaml;

            string fileTitle2 = EntityFileNameFormatter.GetWorkflowFileName(service.ConnectionData.Name, workflow.PrimaryEntity, workflow.FormattedValues[Workflow.Schema.Attributes.category], workflow.Name, fieldTitle, FileExtension.xml);
            string filePath2  = FileOperations.GetNewTempFilePath(Path.GetFileNameWithoutExtension(fileTitle2), Path.GetExtension(fileTitle2));

            if (string.IsNullOrEmpty(workflowXaml))
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, Workflow.Schema.EntityLogicalName, workflow.Name, fieldTitle);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
                return;
            }

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

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

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

            string fileLocalPath  = filePath;
            string fileLocalTitle = Path.GetFileName(filePath);

            await this._iWriteToOutput.ProcessStartProgramComparerAsync(service.ConnectionData, fileLocalPath, filePath2, fileLocalTitle, fileTitle2);

            service.TryDispose();
        }
        private async Task CopingToClipboardSystemFormCurrentTabsAndSections(IOrganizationServiceExtented service, CommonConfiguration commonConfig, JavaScriptObjectType jsObjectType, string entityName, Guid formId, int formType)
        {
            var repositorySystemForm = new SystemFormRepository(service);

            var systemForm = await repositorySystemForm.GetByIdAsync(formId, ColumnSetInstances.AllColumns);

            string formXml = systemForm.FormXml;

            if (string.IsNullOrEmpty(formXml))
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SystemForm.Schema.EntityLogicalName, systemForm.Name, SystemForm.Schema.Headers.formxml);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
                return;
            }

            try
            {
                var fileGenerationOptions = FileGenerationConfiguration.GetFileGenerationOptions();

                var config = new CreateFileJavaScriptConfiguration(fileGenerationOptions);

                var doc = XElement.Parse(formXml);

                var descriptor = new SolutionComponentDescriptor(service);

                descriptor.SetSettings(commonConfig);

                var handler = new FormDescriptionHandler(descriptor, new DependencyRepository(service));

                FormInformation formInfo = handler.GetFormInformation(doc);

                var stringBuilder = new StringBuilder();

                using (var writer = new StringWriter(stringBuilder))
                {
                    var handlerCreate = new CreateFormTabsJavaScriptHandler(writer, config, jsObjectType, service);

                    handlerCreate.WriteContentOnlyForm(formInfo);
                }

                ClipboardHelper.SetText(stringBuilder.ToString().Trim(' ', '\r', '\n'));

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.CopyingEntityJavaScriptContentOnFormCompletedFormat2, systemForm.ObjectTypeCode, systemForm.Name);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);

                service.TryDispose();
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);
            }
        }
Example #20
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();
        }
        private async Task UpdateSystemFormXml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, SystemForm systemForm)
        {
            {
                string fieldTitle = SystemForm.Schema.Headers.formxml;

                string formXml = systemForm.FormXml;

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

                    string fileNameBackUp = EntityFileNameFormatter.GetSystemFormFileName(service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name, fieldTitle + " BackUp", FileExtension.xml);
                    string filePathBackUp = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileNameBackUp));

                    try
                    {
                        formXml = ContentComparerHelper.FormatXmlByConfiguration(
                            formXml
                            , commonConfig
                            , XmlOptionsControls.FormXmlOptions
                            , schemaName: AbstractDynamicCommandXsdSchemas.FormXmlSchema
                            , formId: systemForm.Id
                            , entityName: systemForm.ObjectTypeCode
                            );

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

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

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

            var updateEntity = new SystemForm
            {
                Id = systemForm.Id,
            };

            updateEntity.Attributes[SystemForm.Schema.Attributes.formxml] = newText;

            await service.UpdateAsync(updateEntity);

            var repositoryPublish = new PublishActionsRepository(service);

            _iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionPublishingSystemFormFormat3, service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name);
            await repositoryPublish.PublishDashboardsAsync(new[] { systemForm.Id });

            if (systemForm.ObjectTypeCode.IsValidEntityName())
            {
                _iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionPublishingEntitiesFormat2, service.ConnectionData.Name, systemForm.ObjectTypeCode);
                await repositoryPublish.PublishEntitiesAsync(new[] { systemForm.ObjectTypeCode });
            }

            service.TryDispose();
        }
Example #22
0
 private Task GetCurrentWorkflowXamlAsync(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, Workflow workflow)
 {
     return(Task.Run(() => GetCurrentWorkflowXaml(service, commonConfig, doc, filePath, workflow)));
 }
        private async Task GetCurrentEntityDescription(IOrganizationServiceExtented service, CommonConfiguration commonConfig, SystemForm systemForm)
        {
            commonConfig.CheckFolderForExportExists(this._iWriteToOutput);

            string fileName = EntityFileNameFormatter.GetSystemFormFileName(service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name, EntityFileNameFormatter.Headers.EntityDescription, FileExtension.txt);
            string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));

            try
            {
                await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, systemForm, service.ConnectionData);

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedEntityDescriptionFormat3
                                                   , service.ConnectionData.Name
                                                   , systemForm.LogicalName
                                                   , filePath
                                                   );
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);
            }

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

            service.TryDispose();
        }
        public async Task ExecuteGetSystemFormCurrentXml(ConnectionData connectionData, CommonConfiguration commonConfig, SelectedFile selectedFile)
        {
            string operation = string.Format(Properties.OperationNames.GettingSystemFormCurrentXmlFormat1, connectionData?.Name);

            this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation);

            try
            {
                if (ParseXmlDocument(connectionData, selectedFile, out var doc))
                {
                    await CheckAttributeValidateGetSystemFormExecuteAction(connectionData, commonConfig, doc, selectedFile.FilePath, null, GetCurrentSystemFormXmlAsync);
                }
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(connectionData, ex);
            }
            finally
            {
                this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation);
            }
        }
Example #25
0
        /// <summary>
        /// Get the right configuration for the module
        /// Should be managed in setting window
        /// </summary>
        /// <param name="cm"></param>
        /// <returns></returns>
        private CommonConfiguration Configuration(CommunicationModule cm)
        {
            CommonConfiguration conf = null;

            switch (cm.TransportType)
            {
            case TransportEnum.OPEN_DDS:
                OpenDDSConfiguration oddsConfiguration = new OpenDDSConfiguration()
                {
                    OpenDDSArgs = new OpenDDSConfiguration.OpenDDSArgsConfiguration()
                    {
                        DCPSConfigFile          = "dds_tcp_conf.ini",
                        DCPSTransportDebugLevel = 10,
                    },
                    DCPSInfoRepo = new OpenDDSConfiguration.DCPSInfoRepoConfiguration()
                    {
                        Autostart   = StartServer,
                        ORBEndpoint = "iiop://localhost:12345",
                    }
                };
                OpenDDSChannelConfiguration oddsChannelConf = new OpenDDSChannelConfiguration(oddsConfiguration)
                {
                    TopicQos = new TopicQosConfiguration()
                    {
                        TopicDataQosPolicy = new TopicDataQosPolicyConfiguration()
                        {
                            Value = new byte[] { 100, 23 }
                        },
                        DurabilityQosPolicy = new DurabilityQosPolicyConfiguration()
                        {
                            Kind = DurabilityQosPolicyConfiguration.DurabilityQosPolicyKind.PERSISTENT_DURABILITY_QOS
                        },
                        DurabilityServiceQosPolicy = new DurabilityServiceQosPolicyConfiguration()
                        {
                            HistoryDepth = 100,
                            Kind         = DurabilityServiceQosPolicyConfiguration.HistoryQosPolicyKind.KEEP_ALL_HISTORY_QOS,
                        },
                        ReliabilityQosPolicy = new ReliabilityQosPolicyConfiguration()
                        {
                            Kind = ReliabilityQosPolicyConfiguration.ReliabilityQosPolicyKind.RELIABLE_RELIABILITY_QOS
                        }
                    },
                    SubscriberQos = new SubscriberQosConfiguration()
                    {
                        EntityFactoryQosPolicy = new EntityFactoryQosPolicyConfiguration()
                        {
                            AutoenableCreatedEntities = true
                        },
                    }
                };
                conf = oddsChannelConf;
                break;

            case TransportEnum.KAFKA:
                KafkaConfiguration kConfiguration = new KafkaConfiguration()
                {
                };
                KafkaChannelConfiguration kChannelConfiguration = new KafkaChannelConfiguration(kConfiguration)
                {
                    AutoOffsetReset  = (cm.ChannelName == "users") ? AutoOffsetResetType.beginning : AutoOffsetResetType.latest,
                    InitialOffset    = (cm.ChannelName == "users") ? InitialOffsetTypes.Beginning : InitialOffsetTypes.Stored,
                    ClientId         = "chat" + cm.ChannelName + cm.Id.ToString(),
                    GroupId          = "chatGrp" + cm.Id.ToString(),
                    BootstrapBrokers = "206.189.214.143:9093",
                };
                conf = kChannelConfiguration;
                break;
            }
            return(conf);
        }
 public async Task ExecuteGetSystemFormCurrentAttribute(ConnectionData connectionData, CommonConfiguration commonConfig, Guid formId, ActionOnComponent actionOnComponent, string fieldName, string fieldTitle)
 {
     await ConnectAndExecuteActionAsync(connectionData
                                        , Properties.OperationNames.GettingSystemFormCurrentAttributeFormat2
                                        , (service) => GettingSystemFormCurrentAttribute(service, commonConfig, formId, actionOnComponent, fieldName, fieldTitle)
                                        , fieldTitle
                                        );
 }
        private async Task <Tuple <bool, SiteMap> > GetSiteMapByAttribute(IOrganizationServiceExtented service, CommonConfiguration commonConfig, string siteMapNameUnique)
        {
            var repositorySiteMap = new SiteMapRepository(service);

            var siteMap = await repositorySiteMap.FindByExactNameAsync(siteMapNameUnique ?? string.Empty, ColumnSetInstances.AllColumns);

            if (siteMap == null)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionSiteMapWasNotFoundFormat2, service.ConnectionData.Name, SiteMap.Schema.EntityLogicalName, siteMapNameUnique);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);

                WindowHelper.OpenExportSiteMapExplorer(_iWriteToOutput, service, commonConfig, siteMapNameUnique);
            }

            return(Tuple.Create(siteMap != null, siteMap));
        }
        private async Task GettingSystemFormCurrentAttribute(IOrganizationServiceExtented service, CommonConfiguration commonConfig, Guid formId, ActionOnComponent actionOnComponent, string fieldName, string fieldTitle)
        {
            var repositorySystemForm = new SystemFormRepository(service);

            var systemForm = await repositorySystemForm.GetByIdAsync(formId, ColumnSetInstances.AllColumns);

            if (actionOnComponent == ActionOnComponent.SingleXmlField)
            {
                if (string.Equals(fieldName, SystemForm.Schema.Attributes.formxml, StringComparison.InvariantCultureIgnoreCase))
                {
                    GetCurrentSystemFormXml(service, commonConfig, systemForm);
                }
            }
            else if (actionOnComponent == ActionOnComponent.SingleField)
            {
                if (string.Equals(fieldName, SystemForm.Schema.Attributes.formjson, StringComparison.InvariantCultureIgnoreCase))
                {
                    GetCurrentSystemFormJson(service, commonConfig, systemForm);
                }
            }
            else if (actionOnComponent == ActionOnComponent.EntityDescription)
            {
                await GetCurrentEntityDescription(service, commonConfig, systemForm);
            }
            else if (actionOnComponent == ActionOnComponent.Description)
            {
                await GetCurrentFormDescription(service, commonConfig, systemForm);
            }
        }
 private Task GetCurrentSiteMapXmlAsync(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, SiteMap siteMap)
 {
     return(Task.Run(() => GetCurrentSiteMapXml(service, commonConfig, doc, filePath, siteMap)));
 }
        public async Task ExecuteShowingTeamsExplorer(string selection, ConnectionData connectionData, CommonConfiguration commonConfig)
        {
            if (connectionData == null)
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.NoCurrentCRMConnection);
                return;
            }

            string operation = string.Format(Properties.OperationNames.OpeningTeamsExplorerFormat1, connectionData?.Name);

            this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation);

            try
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectingToCRM);

                this._iWriteToOutput.WriteToOutput(connectionData, connectionData.GetConnectionDescription());

                // Подключаемся к CRM.
                var service = await QuickConnection.ConnectAsync(connectionData);

                if (service == null)
                {
                    _iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectionFailedFormat1, connectionData.Name);
                    return;
                }

                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.CurrentServiceEndpointFormat1, service.CurrentServiceEndpoint);

                WindowHelper.OpenTeamsExplorer(this._iWriteToOutput, service, commonConfig, selection);
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(connectionData, ex);
            }
            finally
            {
                this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation);
            }
        }