Example #1
0
        private void editResourceByNameFromConfig(Part evaPart, string matchName, ConfigNode config)
        {
            PartResource resource = this.matchFirstResourceByName(evaPart, matchName);

            if (resource != null)
            {
                if (config.HasValue("name"))
                {
                    config = this.mergeConfigs(resource, config);

                    GameObject.Destroy(resource);

                    this.LogDebug("EVA resource {0} marked for destruction.", resource.resourceName);

                    ConfigAction copyAction = new ConfigAction(empty, RESOURCE, empty, config);

                    this.passQueue.Add(copyAction);

                    Logging.PostDebugMessage(
                        this,
                        "EVA resource {0} marked for insertion\n(action: {1})",
                        config.GetValue("name"),
                        copyAction
                        );
                }
                else
                {
                    this.assignFieldsFromConfig(resource, config);
                }
            }
        }
Example #2
0
        internal async Task <Tuple <bool, string> > ConfigureAgentOperator(
            string ownerUri,
            AgentOperatorInfo operatorInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("operator", operatorInfo.Name);

                    using (AgentOperatorActions actions = new AgentOperatorActions(dataContainer, operatorInfo, configAction))
                    {
                        ExecuteAction(actions, runType);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #3
0
        }         // proc CompileTypeActions

        private DEConfigAction CompileTypeAction(ref ConfigAction ca)
        {
            var exprLambda = CompileMethodAction(ca.Method);

            // Erzeuge die Action
            return(new DEConfigAction(ca.Attribute.SecurityToken, ca.Description, exprLambda.Compile(), ca.Attribute.IsSafeCall, ca.Method));
        }         // func CompileTypeAction
Example #4
0
        private void editModuleByNameFromConfig(Part evaPart, string matchName, ConfigNode config)
        {
            PartModule module = this.matchFirstModuleByName(evaPart, matchName);

            if (module != null)
            {
                if (config.HasValue("name"))
                {
                    config = this.mergeConfigs(module, config);

                    GameObject.Destroy(module);

                    this.LogDebug("EVA module {0} marked for destruction.", module.GetType().Name);

                    ConfigAction copyAction = new ConfigAction(empty, MODULE, empty, config);

                    this.passQueue.Add(copyAction);

                    Logging.PostDebugMessage(
                        this,
                        "EVA module {0} marked for insertion\n(action: {1})",
                        config.GetValue("name"),
                        copyAction
                        );
                }
                else
                {
                    this.assignFieldsFromConfig(module, config);
                }
            }
        }
Example #5
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJobStep(
            string ownerUri,
            AgentJobStepInfo stepInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(stepInfo.JobName))
                    {
                        return new Tuple <bool, string>(false, "JobId cannot be null");
                    }

                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, stepInfo.JobName, out dataContainer, out jobData);

                    using (var jobStep = new JobStepsActions(dataContainer, jobData, stepInfo, configAction))
                    {
                        var executionHandler = new ExecutonHandler(jobStep);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    // log exception here
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #6
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, jobInfo.Name, out dataContainer, out jobData, jobInfo);

                    using (JobActions jobActions = new JobActions(dataContainer, jobData, configAction))
                    {
                        var executionHandler = new ExecutonHandler(jobActions);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #7
0
        /// <summary>
        /// Build action handler
        /// </summary>
        /// <param name="configAction"></param>
        /// <returns></returns>
        private AbstractAction BuildAction(ConfigAction configAction)
        {
            if (configAction == null) return null;

            switch (configAction.type)
            {
                case "service_start":
                    return new ServiceStartAction(configAction.arguments);
                case "service_stop":
                    return new ServiceStopAction(configAction.arguments);
                case "service_restart":
                    return new ServiceRestartAction(configAction.arguments);
                case "service_install":
                    return new ServiceInstallAction(configAction.arguments);
                case "service_uninstall":
                    return new ServiceUninstallAction(configAction.arguments);
                case "run":
                    return new RunAction(configAction.arguments);
                case "exit":
                    return new ExitAction(configAction.arguments);
                case "sequence":
                    return new SequenceAction(configAction.arguments);
                default:
                    //TODO unknown action type message
                    return null;
            }
        }
Example #8
0
        private void CreateJobData(
            string ownerUri,
            string jobName,
            out CDataContainer dataContainer,
            out JobData jobData,
            ConfigAction configAction = ConfigAction.Create,
            AgentJobInfo jobInfo      = null)
        {
            ConnectionInfo connInfo;

            ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
            dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);

            XmlDocument jobDoc = CreateJobXmlDocument(dataContainer.Server.Name.ToUpper(), jobName);

            dataContainer.Init(jobDoc.InnerXml);

            STParameters param        = new STParameters(dataContainer.Document);
            string       originalName = jobInfo != null && !string.Equals(jobName, jobInfo.Name) ? jobName : string.Empty;

            param.SetParam("job", configAction == ConfigAction.Update ? jobName : string.Empty);
            param.SetParam("jobid", string.Empty);

            jobData = new JobData(dataContainer, jobInfo, configAction);
        }
Example #9
0
        internal async Task <Tuple <bool, string> > ConfigureAgentSchedule(
            string ownerUri,
            AgentScheduleInfo schedule,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <bool> .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, schedule.JobName, out dataContainer, out jobData);

                    const string UrnFormatStr = "Server[@Name='{0}']/JobServer[@Name='{0}']/Job[@Name='{1}']/Schedule[@Name='{2}']";
                    string serverName = dataContainer.Server.Name.ToUpper();
                    string scheduleUrn = string.Format(UrnFormatStr, serverName, jobData.Job.Name, schedule.Name);

                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("urn", scheduleUrn);

                    using (JobSchedulesActions actions = new JobSchedulesActions(dataContainer, jobData, schedule, configAction))
                    {
                        var executionHandler = new ExecutonHandler(actions);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #10
0
        internal async Task <Tuple <bool, string> > ConfigureAgentProxy(
            string ownerUri,
            string accountName,
            AgentProxyInfo proxy,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <bool> .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("proxyaccount", accountName);

                    using (AgentProxyAccountActions agentProxy = new AgentProxyAccountActions(dataContainer, proxy, configAction))
                    {
                        var executionHandler = new ExecutonHandler(agentProxy);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
        internal async Task <Tuple <bool, string> > ConfigureCredential(
            string ownerUri,
            CredentialInfo credential,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);

                    using (CredentialActions actions = new CredentialActions(dataContainer, credential, configAction))
                    {
                        var executionHandler = new ExecutonHandler(actions);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #12
0
        public SkylineBatchConfigForm(IMainUiControl mainControl, SkylineBatchConfig config, ConfigAction action, bool isBusy)
        {
            InitializeComponent();

            _action         = action;
            _initialCreated = config?.Created ?? DateTime.MinValue;
            _newReportList  = new List <ReportInfo>();

            _mainControl            = mainControl;
            _isBusy                 = isBusy;
            _canEditSkylineSettings = !Installations.HasLocalSkylineCmd;

            InitSkylineTab();
            InitInputFieldsFromConfig(config);

            lblConfigRunning.Hide();

            if (isBusy)
            {
                lblConfigRunning.Show();
                btnSaveConfig.Hide(); // save and cancel buttons are replaced with OK button
                btnCancelConfig.Hide();
                btnOkConfig.Show();
                AcceptButton = btnOkConfig;
                DisableUserInputs();
            }

            ActiveControl = textConfigName;
        }
        public JobStepsActions(
            CDataContainer dataContainer,
            JobData jobData,
            AgentJobStepInfo stepInfo,
            ConfigAction configAction)
        {
            this.configAction  = configAction;
            this.DataContainer = dataContainer;
            this.jobData       = jobData;

            if (configAction == ConfigAction.Create)
            {
                this.data = new JobStepData(jobData.JobSteps);
            }
            else
            {
                JobStep jobStep = GetJobStep(this.jobData, stepInfo.StepName);
                this.data = new JobStepData(jobStep, jobData.JobSteps);
            }

            // load properties from AgentJobStepInfo
            this.data.ID        = stepInfo.Id;
            this.data.Name      = stepInfo.StepName;
            this.data.Command   = stepInfo.Command;
            this.data.Subsystem = AgentUtilities.ConvertToAgentSubSytem(stepInfo.SubSystem);
        }
        /// <summary>
        /// Main constructor. Creates all pages and adds them
        /// to the tree control.
        /// </summary>
        public AgentProxyAccountActions(CDataContainer dataContainer, AgentProxyInfo proxyInfo, ConfigAction configAction)
        {
            this.DataContainer = dataContainer;
            this.proxyInfo     = proxyInfo;
            this.configAction  = configAction;

            if (configAction != ConfigAction.Drop)
            {
                // Create data structures
                int length = Enum.GetValues(typeof(ProxyPrincipalType)).Length;
                this.principals = new ArrayList[length];
                for (int i = 0; i < length; ++i)
                {
                    this.principals[i] = new ArrayList();
                }

                if (configAction == ConfigAction.Update)
                {
                    RefreshData();
                }
            }

            // Find out if we are creating a new proxy account or
            // modifying an existing one.
            GetProxyAccountName(dataContainer, ref this.proxyAccountName, ref this.duplicate);
        }
Example #15
0
        internal async Task <Tuple <bool, string> > ConfigureAgentAlert(
            string ownerUri,
            AgentAlertInfo alert,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("alert", alert.JobName);

                    if (alert != null && !string.IsNullOrWhiteSpace(alert.JobName))
                    {
                        using (AgentAlertActions agentAlert = new AgentAlertActions(dataContainer, alert, configAction))
                        {
                            var executionHandler = new ExecutonHandler(agentAlert);
                            executionHandler.RunNow(runType, this);
                        }
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #16
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            string originalJobName,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, originalJobName, out dataContainer, out jobData, configAction, jobInfo);

                    using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
                    {
                        ExecuteAction(actions, runType);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #17
0
 public void Deserialize(byte[] bytes, ref int offset)
 {
     this.action  = (ConfigAction)ByteSerializer.DeserializeInt(bytes, ref offset);
     this.userCap = ByteSerializer.DeserializeInt(bytes, ref offset);
     this.acceptingConnections = ByteSerializer.DeserializeBool(bytes, ref offset);
     this.newPassword          = ByteSerializer.DeserializeString(bytes, ref offset);
     this.lobbyMode            = (LobbyMode)ByteSerializer.DeserializeInt(bytes, ref offset);
 }
Example #18
0
 /// <summary>
 /// Default constructor that will be used to create dialog
 /// </summary>
 /// <param name="dataContainer"></param>
 public AgentAlertActions(
     CDataContainer dataContainer, string originalAlertName,
     AgentAlertInfo alertInfo, ConfigAction configAction)
 {
     this.originalAlertName = originalAlertName;
     this.alertInfo         = alertInfo;
     this.DataContainer     = dataContainer;
     this.configAction      = configAction;
 }
Example #19
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            string originalJobName,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(async() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, originalJobName, out dataContainer, out jobData, configAction, jobInfo);

                    using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
                    {
                        ExecuteAction(actions, runType);
                    }

                    // Execute step actions if they exist
                    if (jobInfo.JobSteps != null && jobInfo.JobSteps.Length > 0)
                    {
                        foreach (AgentJobStepInfo step in jobInfo.JobSteps)
                        {
                            await ConfigureAgentJobStep(ownerUri, step, configAction, runType);
                        }
                    }

                    // Execute schedule actions if they exist
                    if (jobInfo.JobSchedules != null && jobInfo.JobSchedules.Length > 0)
                    {
                        foreach (AgentScheduleInfo schedule in jobInfo.JobSchedules)
                        {
                            await ConfigureAgentSchedule(ownerUri, schedule, configAction, runType);
                        }
                    }

                    // Execute alert actions if they exist
                    if (jobInfo.Alerts != null && jobInfo.Alerts.Length > 0)
                    {
                        foreach (AgentAlertInfo alert in jobInfo.Alerts)
                        {
                            alert.JobId = jobData.Job.JobID.ToString();
                            await ConfigureAgentAlert(ownerUri, alert.Name, alert, configAction, runType);
                        }
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Example #20
0
 internal void FireFinalSelection(ConfigAction action, IList <string> changedOptions)
 {
     if (frmConfigurationDlg.Instance != null && _finalSelection != null)
     {
         ConfigEventArgs args = new ConfigEventArgs();
         args.action         = action;
         args.ChangedOptions = changedOptions;
         _finalSelection(this, args);
     }
 }
Example #21
0
        /// <summary>
        /// Runs the specified application using the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public void Run(string[] args)
        {
            Logging.Log("Started the Server Registration Manager.");

            //  Show the welcome.
            ShowWelcome();

            //  If we have no verb or target or our verb is help, show the help.
            if (args.Length == 0 || args.First() == VerbHelp)
            {
                ShowHelpAction.Execute(outputService);
                return;
            }

            //  Get the architecture.
            var registrationType = Environment.Is64BitOperatingSystem ? RegistrationType.OS64Bit : RegistrationType.OS32Bit;

            //  Get the verb, target and parameters.
            var verb       = args[0];
            var target     = args.Length > 1 ? args[1] : null; // TODO tidy this up.
            var parameters = args.Skip(1).ToArray();

            //Allow user to override registrationType with -os32 or -os64
            if (parameters.Any(p => p.Equals(ParameterOS32, StringComparison.InvariantCultureIgnoreCase)))
            {
                registrationType = RegistrationType.OS32Bit;
            }
            else if (parameters.Any(p => p.Equals(ParameterOS64, StringComparison.InvariantCultureIgnoreCase)))
            {
                registrationType = RegistrationType.OS64Bit;
            }

            //  Based on the verb, perform the action.
            if (verb == VerbInstall)
            {
                InstallServer(target, registrationType, parameters.Any(p => p == ParameterCodebase));
            }
            else if (verb == VerbUninstall)
            {
                UninstallServer(target, registrationType);
            }
            else if (verb == VerbConfig)
            {
                ConfigAction.Execute(outputService, parameters);
            }
            else if (verb == VerbEnableEventLog)
            {
                EnableEventLogAction.Execute(outputService);
            }
            else
            {
                ShowHelpAction.Execute(outputService);
            }
        }
Example #22
0
        /// <summary>
        /// required when loading from Object Explorer context
        /// </summary>
        /// <param name="context"></param>
        public CredentialActions(
            CDataContainer context,
            CredentialInfo credential,
            ConfigAction configAction)
        {
            this.DataContainer = context;
            this.credential    = credential;
            this.configAction  = configAction;

            this.credentialData = new CredentialData(context, credential);
            this.credentialData.Initialize();
        }
Example #23
0
    private void RaiseFinalSelectionEvent( ConfigAction action )
    {
      if (_onFinalSelection != null)
      {
        ConfigEventArgs args = new ConfigEventArgs();
        args.action = action;
        args.content = _configContent;
        args.ChangedOptions = _changedOptions;
        _onFinalSelection(this, args);
				
				frmConfigurationDlg.ConficSvc.FireFinalSelection(action, _changedOptions);
			}
    }
Example #24
0
        /// <summary>
        /// Determines whether the specified action can be performed.
        /// </summary>
        public virtual bool AllowAction(ConfigAction action, object button, TreeNode selectedNode)
        {
            return(action switch
            {
                ConfigAction.MoveUp =>
                TreeViewExtensions.MoveUpIsEnabled(selectedNode, TreeNodeBehavior.WithinParent),

                ConfigAction.MoveDown =>
                TreeViewExtensions.MoveDownIsEnabled(selectedNode, TreeNodeBehavior.WithinParent),

                ConfigAction.Delete => selectedNode != null,

                _ => true
            });
 /// <summary>
 /// Default constructor that will be used to create dialog
 /// </summary>
 /// <param name="dataContainer"></param>
 public AgentAlertActions(
     CDataContainer dataContainer, string originalAlertName,
     AgentAlertInfo alertInfo, ConfigAction configAction,
     JobData jobData = null)
 {
     this.originalAlertName = originalAlertName;
     this.alertInfo         = alertInfo;
     this.DataContainer     = dataContainer;
     this.configAction      = configAction;
     if (jobData != null)
     {
         this.jobData = jobData;
     }
 }
Example #26
0
        /// <summary>
        /// Runs the specified application using the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public void Run(string[] args)
        {
            Logging.Log("Started the Server Registration Manager.");

            //  Show the welcome.
            ShowWelcome();

            //  If we have no verb or target or our verb is help, show the help.
            if (args.Length == 0 || args.First() == VerbHelp)
            {
                ShowHelpAction.Execute(outputService);
                return;
            }

            //  Get the architecture.
            var registrationType = RegistrationType.OS64Bit;

#if WIN32
            registrationType = RegistrationType.OS32Bit;
#endif

            //  Get the verb, target and parameters.
            var verb       = args[0];
            var target     = args.Length > 1 ? args[1] : (string)null; // TODO tidy this up.
            var parameters = args.Skip(1);

            //  Based on the verb, perform the action.
            if (verb == VerbInstall)
            {
                InstallServer(target, registrationType, parameters.Any(p => p == ParameterCodebase));
            }
            else if (verb == VerbUninstall)
            {
                UninstallServer(target, registrationType);
            }
            else if (verb == VerbConfig)
            {
                ConfigAction.Execute(outputService, parameters);
            }
            else if (verb == VerbEnableEventLog)
            {
                EnableEventLogAction.Execute(outputService);
            }
            else
            {
                ShowHelpAction.Execute(outputService);
            }
        }
Example #27
0
        internal async Task <Tuple <bool, string> > ConfigureAgentAlert(
            string ownerUri,
            string alertName,
            AgentAlertInfo alert,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    CDataContainer dataContainer;
                    JobData jobData = null;
                    // If the alert is being created outside of a job
                    if (string.IsNullOrWhiteSpace(alert.JobName))
                    {
                        ConnectionInfo connInfo;
                        ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                        dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    }
                    else
                    {
                        // If the alert is being created inside a job
                        CreateJobData(ownerUri, alert.JobName, out dataContainer, out jobData);
                    }
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("alert", alertName);
                    if (alert != null)
                    {
                        using (AgentAlertActions actions = new AgentAlertActions(dataContainer, alertName, alert, configAction, jobData))
                        {
                            ExecuteAction(actions, runType);
                        }
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
        public JobSchedulesActions(CDataContainer dataContainer, JobData data, AgentScheduleInfo scheduleInfo, ConfigAction configAction)
        {
            this.DataContainer            = dataContainer;
            this.data                     = data;
            this.configAction             = configAction;
            this.scheduleInfo             = scheduleInfo;
            this.sharedSchedulesSupported = this.DataContainer.Server.Information.Version.Major >= 9;

            if (configAction == ConfigAction.Create)
            {
                this.scheduleData = new JobScheduleData(this.data.Job);
                this.scheduleData.SetJobSchedule(new JobSchedule());
            }
            else
            {
                // get the JobScheduleData from the urn
                string       urn        = null;
                STParameters parameters = new STParameters();
                parameters.SetDocument(this.DataContainer.Document);
                parameters.GetParam("urn", ref urn);

                JobSchedule jobStep = this.data.Job.Parent.Parent.GetSmoObject(urn) as JobSchedule;
                if (jobStep != null)
                {
                    this.scheduleData = new JobScheduleData(jobStep);
                }

                if (configAction == ConfigAction.Update && this.scheduleData == null)
                {
                    throw new Exception("Schedule urn parameter cannot be null");
                }
            }

            // copy properties from AgentScheduelInfo
            if (this.scheduleData != null)
            {
                this.scheduleData.Name = scheduleInfo.Name;
            }
        }
        /// <summary>
        /// Load the given configuration at a path and perform an action on each Config contained within it
        /// </summary>
        /// <param name="path"></param>
        /// <param name="fileDescription"></param>
        /// <param name="action"></param>
        private static void LoadFromFile(string path, string fileDescription, ConfigAction action)
        {
            if (File.Exists(path))
            {
                try
                {
                    XmlConfigSource source = new XmlConfigSource(path);

                    for (int i = 0; i < source.Configs.Count; i++)
                    {
                        action(source.Configs[i], path);
                    }
                }
                catch (XmlException e)
                {
                    m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e);
                }
            }
            else
            {
                m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path);
            }
        }
Example #30
0
            }             // ctor

            public bool GetConfigAction(string sAction, out ConfigAction action)
            {
                // Suuche die Action
                if (actions != null)
                {
                    int iIdx = Array.FindIndex(actions, cur => String.Compare(cur.Attribute.ActionName, sAction, true) == 0);
                    if (iIdx >= 0)
                    {
                        action = actions[iIdx];
                        return(true);
                    }
                }

                if (prev != null)
                {
                    return(prev.GetConfigAction(sAction, out action));
                }
                else
                {
                    action = new ConfigAction();
                    return(false);
                }
            }             // func GetConfigAction
Example #31
0
        /// <summary>
        /// Load the given configuration at a path and perform an action on each Config contained within it
        /// </summary>
        /// <param name="path"></param>
        /// <param name="fileDescription"></param>
        /// <param name="action"></param>
        private static void LoadFromFile(string path, string fileDescription, ConfigAction action)
        {
            if (File.Exists(path))
            {
                try
                {
                    XmlConfigSource source = new XmlConfigSource(path);

                    for (int i = 0; i < source.Configs.Count; i++)
                    {
                        action(source.Configs[i], path);
                    }
                }
                catch (XmlException e)
                {
                    m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e);
                }
            }
            else
            {
                m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path);
            }
        }
        /// <summary>
        /// Load the given configuration at a path and perform an action on each Config contained within it
        /// </summary>
        /// <param name="path"></param>
        /// <param name="fileDescription"></param>
        /// <param name="action"></param>
        void LoadFromFile(string path, string fileDescription, ConfigAction action)
        {
            if (File.Exists(path))
            {
                try
                {
                    var source = new XmlConfigSource(path);

                    for (int i = 0; i < source.Configs.Count; i++)
                        action(source.Configs[i], path);
                }
                catch (XmlException e)
                {
                    MainConsole.Instance.ErrorFormat("[InventoryXMLLoader]: Error loading {0} : {1}", path, e);
                }
            } else
                MainConsole.Instance.ErrorFormat("[InventoryXMLLoader]: {0} file {1} does not exist!", fileDescription, path);
        }