예제 #1
0
        //*********************************************************************
        ///
        /// <summary>
        ///     This method returns a ScriptJob type
        /// </summary>
        /// <param name="scriptJob"></param>
        /// <param name="wapSubscriptionId"></param>
        /// <returns>ScriptJob</returns>
        ///
        //*********************************************************************

        public static ScriptJob SubmitScriptJob(ScriptJob scriptJob,
                                                string wapSubscriptionId)
        {
            if (scriptJob == null)
            {
                throw new ArgumentNullException("scriptJob");
            }

            if (wapSubscriptionId == null)
            {
                throw new ArgumentNullException("wapSubscriptionId");
            }

            try
            {
                var seqSpec = Convert(scriptJob);
                seqSpec = CmpClient.CmpScriptClient.ExecuteSmaScript(seqSpec);

                var sequenceRequest = new SequenceRequest
                {
                    Active           = true,
                    CmpRequestID     = 0,
                    Config           = seqSpec.Serialize(),
                    ExceptionMessage = null,
                    Id = 0,
                    LastStatusUpdate        = seqSpec.RunResult.LastUpdate,
                    ServiceProviderJobId    = seqSpec.RunResult.JobId,
                    ServiceProviderName     = seqSpec.SmaConfig.SmaServerUrl,
                    ServiceProviderTypeCode = seqSpec.Engine,
                    StatusCode        = seqSpec.RunResult.StatusCode,
                    StatusMessage     = seqSpec.RunResult.StatusMessage,
                    TagData           = seqSpec.TagData,
                    TagID             = 0,
                    TagOpName         = seqSpec.SmaConfig.RunbookName,
                    TargetName        = scriptJob.TargetName,
                    TargetTypeCode    = scriptJob.TargetTypeCode,
                    WapSubscriptionID = wapSubscriptionId,
                    Warnings          = null,
                    WhenRequested     = seqSpec.RunResult.WhenSubmitted,
                    WhoRequested      = null
                };

                var cdb = new CmpWapDb();
                sequenceRequest = cdb.InsertSequenceRequest(sequenceRequest);
                seqSpec.ID      = sequenceRequest.Id;

                return(Convert(seqSpec));
            }
            catch (Exception ex)
            {
                throw new Exception("ScriptInterface.SubmitScriptJob() : " +
                                    Utilities.UnwindExceptionMessages(ex));
            }
        }