コード例 #1
0
        /// <summary>
        /// Method to initiate publication request
        /// </summary>
        private void publish()
        {
            displayLogsTxtBox.Text = "";
            PublicationParams parameters = new PublicationParams();

            parameters.Password       = txtPassword.Text.Trim();
            parameters.UserName       = txtUsername.Text.Trim();
            parameters.ServerUrl      = txtServer.Text.Trim();
            parameters.Service        = txtService.Text.Trim();
            parameters.LogFilePath    = logFilePath;
            parameters.CurrentWorkDir = workDirectory;
            us.Params = parameters;
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            pr = new PublicationRequest(parameters);
            pr.determineEndPoint();
            try
            {
                IGxApplication catalog = null;

                if (ArcCatalog.Application != null)
                {
                    catalog = (IGxApplication)ArcCatalog.Application;
                }

                if (ArcMap.Application != null)
                {
                    catalog = (IGxApplication)ArcMap.Application;
                }
                IGxObject pGxObject      = catalog.Catalog.SelectedObject;
                String    category       = pGxObject.Category;
                String    parentCategory = pGxObject.Parent.Category;

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("************ Metadata Publishing started at   " + System.DateTime.Now + " ************");
                sb.AppendLine("Publication Parameters ");
                sb.AppendLine("============================================================");
                sb.AppendLine("Metadata Server Url           : " + parameters.ServerUrl);
                sb.AppendLine("Publish Metadata Service Name : " + parameters.Service);
                sb.AppendLine("Selected Workspace Name       : " + pGxObject.FullName);
                sb.AppendLine("Selected container category   : " + category);
                sb.AppendLine("============================================================");
                writeLogs(sb.ToString());

                publishMetadata(pGxObject, pr);

                //sb.AppendLine(displayLogsTxtBox.Text);
                writeLogs("************ Metadata Publishing completed at " + System.DateTime.Now + " ************");
                saveSettings();
                System.Windows.Forms.Cursor.Current = Cursors.Default;
                ShowSuccessMessageBox(StringMessages.PublishSuccessMsg + " " + logFilePath + StringMessages.LogFilePath);
            }
            catch (Exception ex)
            {
                PublishForm.ShowErrorMessageBox(StringMessages.PublishFailureMsg + " " + logFilePath + StringMessages.LogFilePath);
            }
        }
コード例 #2
0
ファイル: PublishForm.cs プロジェクト: k4th/geoportal-server
        /// <summary>
        /// Method to initiate publication request
        /// </summary>
        private void publish()
        {
            displayLogsTxtBox.Text = "";              
            PublicationParams parameters = new PublicationParams();
            parameters.Password = txtPassword.Text.Trim();
            parameters.UserName = txtUsername.Text.Trim();
            parameters.ServerUrl = txtServer.Text.Trim();
            parameters.Service = txtService.Text.Trim();
            parameters.LogFilePath = logFilePath;
            parameters.CurrentWorkDir = workDirectory;
            us.Params = parameters;
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            pr = new PublicationRequest(parameters);
            pr.determineEndPoint();
            try
            {
                IGxApplication catalog = null;
                IGxViewContainer viewContainer = null;
                if (ArcCatalog.Application != null)
                {
                    catalog = (IGxApplication)ArcCatalog.Application;
                    /*viewContainer = (IGxViewContainer)ArcCatalog.Application;
                    IEnumGxView views = viewContainer.Views;
                    IGxView gxView = views.Next();
                    while (gxView != null)
                    {
                        gxView = views.Next();
                    }*/

                }

                if (ArcMap.Application != null)
                {
                    catalog = (IGxApplication)ArcMap.Application;
                } 
                                                           
                IGxObject pGxObject = catalog.Catalog.SelectedObject;
                String category = pGxObject.Category;
                String parentCategory = pGxObject.Parent.Category;

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("************ Metadata Publishing started at   " + System.DateTime.Now + " ************");
                sb.AppendLine("Publication Parameters ");
                sb.AppendLine("============================================================");
                sb.AppendLine("Metadata Server Url           : " + parameters.ServerUrl);
                sb.AppendLine("Publish Metadata Service Name : " + parameters.Service);
                sb.AppendLine("Selected Workspace Name       : " + pGxObject.FullName);
                sb.AppendLine("Selected container category   : " + category);
                sb.AppendLine("============================================================");
                writeLogs(sb.ToString());
           
                publishMetadata(pGxObject, pr);

                //sb.AppendLine(displayLogsTxtBox.Text);
                writeLogs("************ Metadata Publishing completed at " + System.DateTime.Now + " ************");                
                saveSettings();
                System.Windows.Forms.Cursor.Current = Cursors.Default;
                ShowSuccessMessageBox(StringMessages.PublishSuccessMsg + " " + logFilePath + StringMessages.LogFilePath);

            }
            catch (Exception ex)
            {
                PublishForm.ShowErrorMessageBox(StringMessages.PublishFailureMsg + " " + logFilePath + StringMessages.LogFilePath);
            }
        }