示例#1
0
        public WizardResult EditProjectConnector(IDataItem item)
        {
            try
            {
                WizardStory wizard = new WizardStory();
                wizard.WizardWindowTitle = ServiceManagerLocalization.GetStringFromManagementPack("strEditConnector");
                ProjectConnectorData data = new ProjectConnectorData(item);

                //setup wizard
                data.WizardMode   = WizardMode.Wizard;
                wizard.WizardData = data;

                //add the wizard pages here...
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strGeneral"), typeof(GeneralWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strPWAConnectionPage"), typeof(PWAWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strSchedulePage"), typeof(ScheduleWizardPage), wizard.WizardData));

                PropertySheetDialog psd = new PropertySheetDialog(wizard);

                //window properties
                psd.ShowInTaskbar         = true;
                psd.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                psd.Icon = BitmapFrame.Create(System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Microsoft.EnterpriseManagement.ServiceManager.ProjectServer.ConsoleTasks;component/Icons/Image.Cireson.16x16.ico", UriKind.RelativeOrAbsolute)).Stream);
                psd.ShowDialog();
                return(data.WizardResult);
            }
            catch (Exception ex)
            {
                ConsoleContextHelper.Instance.ShowErrorDialog(ex, string.Empty, ConsoleJobExceptionSeverity.Error);
                return(WizardResult.Failed);
            }
        }
示例#2
0
        internal static string GetFrequencyUnit(ManagementPackRule mpr)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(mpr.DataSourceCollection[0].Configuration);

                foreach (XmlNode node in xmlDoc.ChildNodes[0].ChildNodes[0])
                {
                    if (node.Name == "Interval")
                    {
                        if (node.Attributes["Unit"].Value.ToString() == "Hours")
                        {
                            return(ServiceManagerLocalization.GetStringFromManagementPack("strHours"));
                        }
                        else
                        {
                            return(ServiceManagerLocalization.GetStringFromManagementPack("strMinutes"));
                        }
                    }
                }
                return(string.Empty);
            }
            catch
            {
                return(string.Empty);
            }
        }
示例#3
0
        public bool DeleteProjectConnector(IDataItem item)
        {
            try
            {
                //get the connector class.  Later we will get the type projection so we can delete related objects.
                //item = ConsoleContextHelper.Instance.GetInstance((Guid)item["$Id$"]);

                //get type projection of the connector (Cireson.ProjectAutomation.ConnectorRelatesToProjects.ProjectionType) (34e516cf-644f-11b7-be02-6c886ec0573b)
                item = ConsoleContextHelper.Instance.GetProjectionInstance((Guid)item["$Id$"], new Guid("34e516cf-644f-11b7-be02-6c886ec0573b"));
                //add in some sort of confirmation on delete... later.
                if (MessageBox.Show(
                        String.Format(ServiceManagerLocalization.GetStringFromManagementPack("strConfirmDelete") + " {0}", item["DisplayName"]),
                        ServiceManagerLocalization.GetStringFromManagementPack("strDeleteConnector"), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return(false);
                }
                var emg          = ConsoleContext.GetConsoleEMG();
                var emoConnector = emg.EntityObjects.GetObject <EnterpriseManagementObject>((Guid)item["$Id$"], ObjectQueryOptions.Default);
                var iddRemove    = new IncrementalDiscoveryData();

                // (Cireson.ProjectAutomation.Library) (System.ProjectConfigItemRelatesToProjectConnector) (da061582-3f6c-d7b7-d17d-0a91b8a51ace)
                ManagementPackRelationship mprConnectorHasProject = emg.EntityTypes.GetRelationshipClass(new Guid("da061582-3f6c-d7b7-d17d-0a91b8a51ace"));

                //remove the related project CIs.
                foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> obj in
                         emg.EntityObjects.GetRelationshipObjectsWhereSource <EnterpriseManagementObject>(emoConnector.Id, mprConnectorHasProject, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default))
                {
                    iddRemove.Remove(obj.TargetObject);
                }



                //remove workflow rule for the connector
                try
                {
                    //Cireson Project Server Automation Library Configuration (Cireson.ProjectAutomation.Library.Configuration) (19b2a173-bea9-9e50-0709-1470424916f2)
                    ManagementPack mpConnectorWorkflow = emg.ManagementPacks.GetManagementPack(new Guid("19b2a173-bea9-9e50-0709-1470424916f2"));
                    //Project Server Connector (Cireson.ProjectAutomation.Library) (Microsoft.SystemCenter.Connector.ProjectServer) (d581d2d6-b6cd-b558-7ac7-db233a7c82ec)
                    ManagementPackClass mpcConnector    = emg.EntityTypes.GetClass(new Guid("d581d2d6-b6cd-b558-7ac7-db233a7c82ec"));
                    string             sConnectorRuleId = string.Format("{0}.{1}", "Cireson.ProjectServer.Automation", new Guid(emoConnector[mpcConnector, "Id"].Value.ToString()).ToString("N"));
                    ManagementPackRule mprConnector     = mpConnectorWorkflow.GetRule(sConnectorRuleId);
                    mprConnector.Status = ManagementPackElementStatus.PendingDelete;

                    mpConnectorWorkflow.AcceptChanges();
                }
                catch
                { }

                iddRemove.Remove(emoConnector);
                iddRemove.Commit(emg);
                return(true);
            }
            catch (Exception ex)
            {
                ConsoleContextHelper.Instance.ShowErrorDialog(ex, string.Empty, ConsoleJobExceptionSeverity.Error);
                return(false);
            }
        }
 object IValueConverter.Convert(object value, Type target, object parameter, CultureInfo culture)
 {
     try
     {
         var strId = (string)parameter;
         return(ServiceManagerLocalization.GetStringFromManagementPack(strId));
     }
     catch
     {
         return(value as string);
     }
 }
示例#5
0
        internal static void SetIntervalSchedule(ref ManagementPackDataSourceModule module, string unit, int interval)
        {
            try
            {
                if (unit == ServiceManagerLocalization.GetStringFromManagementPack("strHours"))
                {
                    unit = "Hours";
                }
                else
                {
                    unit = "Minutes";
                }

                string sScheduleXML = String.Format(@"
                              <Scheduler>
                                 <SimpleReccuringSchedule>
                                     <Interval Unit=""{0}"">{1}</Interval>
                                 </SimpleReccuringSchedule>
                                <ExcludeDates />
                            </Scheduler>", unit, interval);
                module.Configuration = sScheduleXML;
            }
            catch { }
        }
示例#6
0
        public ProjectConnectorData CreateProjectConnector()
        {
            try
            {
                WizardStory wizard = new WizardStory();
                //set the SCSM default connector icon here...
                wizard.WizardWindowTitle = ServiceManagerLocalization.GetStringFromManagementPack("strCreateConnector");
                ProjectConnectorData data = new ProjectConnectorData();

                //set the data.
                data.WizardMode   = WizardMode.Wizard;
                wizard.WizardData = data;

                //pages
                //add the connector setup pages here.
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strGeneral"), typeof(GeneralWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strPWAConnectionPage"), typeof(PWAWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strSchedulePage"), typeof(ScheduleWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strResults"), typeof(ResultsWizardPage), wizard.WizardData));

                WizardWindow wizardWindow = new WizardWindow(wizard);
                ElementHost.EnableModelessKeyboardInterop(wizardWindow);

                //window properties
                wizardWindow.ShowInTaskbar         = true;
                wizardWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                wizardWindow.Icon = BitmapFrame.Create(System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Microsoft.EnterpriseManagement.ServiceManager.ProjectServer.ConsoleTasks;component/Icons/Image.Cireson.16x16.ico", UriKind.RelativeOrAbsolute)).Stream);
                wizardWindow.ShowDialog();
                return(data);
            }
            catch (Exception ex)
            {
                ConsoleContextHelper.Instance.ShowErrorDialog(ex, string.Empty, ConsoleJobExceptionSeverity.Error);
                return(null);
            }
        }