コード例 #1
0
        public void HandleShowingWebResourcesDependentComponents(List <SelectedFile> selectedFiles)
        {
            CommonConfiguration commonConfig = CommonConfiguration.Get();

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

            var connectionData = crmConfig.CurrentConnectionData;

            if (connectionData != null && commonConfig != null && selectedFiles.Count > 0)
            {
                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.ShowingWebResourcesDependentComponents(connectionData, commonConfig, selectedFiles);
                                }
                                catch (Exception ex)
                                {
                                    WriteErrorToOutput(connectionData, ex);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DTEHelper.WriteExceptionToOutput(connectionData, ex);
                    }
                });

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

                thread.Start();
            }
        }
コード例 #2
0
        public void HandleXsdSchemaExport(string[] fileNamesColl)
        {
            CommonConfiguration commonConfig = CommonConfiguration.Get();

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

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

                            commonConfig.Save();

                            ActivateOutputWindow(null);
                            WriteToOutputEmptyLines(null, commonConfig);

                            try
                            {
                                foreach (var fileName in fileNamesColl)
                                {
                                    Uri uri = FileOperations.GetSchemaResourceUri(fileName);
                                    StreamResourceInfo info = Application.GetResourceStream(uri);

                                    var doc = XDocument.Load(info.Stream);
                                    info.Stream.Dispose();

                                    var filePath = Path.Combine(commonConfig.FolderForExport, fileName);

                                    doc.Save(filePath, SaveOptions.OmitDuplicateNamespaces);

                                    this.WriteToOutput(null, string.Empty);
                                    this.WriteToOutput(null, string.Empty);
                                    this.WriteToOutput(null, string.Empty);

                                    this.WriteToOutput(null, "{0} exported.", fileName);

                                    this.WriteToOutput(null, string.Empty);

                                    this.WriteToOutputFilePathUri(null, filePath);

                                    PerformAction(null, filePath, true);
                                }
                            }
                            catch (Exception ex)
                            {
                                WriteErrorToOutput(null, ex);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DTEHelper.WriteExceptionToOutput(null, ex);
                    }
                });

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

                thread.Start();
            }
        }
コード例 #3
0
        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();
            }
        }