/// <summary>
        /// This method was introduced in order to run jobs synchronously for Unit Testing purposes.
        /// It should only be called from the test harness.
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="_arg"></param>
        /// <returns></returns>
        public ErrorCode RunJobXmlSynchronously(NbIdentity identity, object _arg)
        {
            try
            {
                string arg = _arg.ToString();
                if (arg.ToString().IndexOf('|') == -1)
                    return ErrorCode.UNABLE_TO_BUILD_JOB_FROM_SPEC;

                string jobName = arg.ToString().Substring(0, arg.IndexOf('|'));
                string jobSpecXml = arg.ToString().Substring(arg.IndexOf('|') + 1);
                jobSpecXml = jobName.StartsWith("ADHOC_") ? ConfigUtils.MetaTagReplacer(jobSpecXml) : jobSpecXml;
                userWatchedJobLogs[String.Format("{0}|{1}", identity.Machinename, identity.Username)] = jobName;

                log.InfoFormat("Running job {0}.  Requested by {1}\\{2} on {3}", jobName, identity.AppDomain, identity.Username, identity.Machinename);
                JobDetails jd = new JobDetails(jobName, jobSpecXml);
                jd.AdapterType = "Bits.FileManagerNS.Adapters.JobAdapter";
                return ExecutionEngine.InstanceOf().ExecuteJob(jd);
            }
            catch (Exception Exception)
            {
                log.Warn(Exception);
                return ErrorCode.MODULE_FAILED;
            }
        }
 public Object UnloadAssembly(NbIdentity identity, object arg)
 {
     string assyName = arg.ToString();
     AdapterRegistration.UnloadAssembly(assyName);
     return null;
 }
        public Object RunJobXml(NbIdentity identity, object _arg)
        {
            try
            {
                string arg = _arg.ToString();
                if (arg.ToString().IndexOf('|') == -1)
                    return false;

                string jobName = arg.ToString().Substring(0, arg.IndexOf('|'));
                string jobSpecXml = arg.ToString().Substring(arg.IndexOf('|') + 1);
                jobSpecXml = jobName.StartsWith("ADHOC_") ? ConfigUtils.MetaTagReplacer(jobSpecXml) : jobSpecXml;
                userWatchedJobLogs[String.Format("{0}|{1}", identity.Machinename, identity.Username)] = jobName;

                log.InfoFormat("Running job {0}.  Requested by {1}\\{2} on {3}", jobName, identity.AppDomain, identity.Username, identity.Machinename);
                JobDetails jd = new JobDetails(jobName, jobSpecXml);
                jd.AdapterType = "Bits.FileManagerNS.Adapters.JobAdapter";
                ExecutionEngine.InstanceOf().QueueExecuteJob(jd);
            }
            catch (Exception Exception)
            {
                log.Warn(Exception);
                return false;
            }
            return true;
        }
 public Object GetStartUpJobsInstant(NbIdentity identity, object arg)
 {
     ArrayList listStartUpJobs = new ArrayList();
     try
     {
         XmlDocument doc = new XmlDocument();
         doc = LoadBitsShellXmlConfigFile();
         XmlNode nodeConfiguration = doc.SelectSingleNode("configuration");
         foreach (XmlNode node in nodeConfiguration.ChildNodes)
         {
             if (node.Name.Contains("StartupJobs"))
             {
                 foreach (XmlNode nodeStartUpJob in node.ChildNodes)
                 {
                     if (nodeStartUpJob.Attributes != null && nodeStartUpJob.Attributes["spec"].Value != null)
                     {
                         JobDetails jd = new JobDetails();
                         jd.Name = nodeStartUpJob.Attributes["spec"].Value.ToString().Replace(".xml", "");
                         jd.ReferencePath = nodeStartUpJob.Attributes["spec"].Value;
                         jd.isEditable = true;
                         listStartUpJobs.Add(jd);
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         log.Warn(exception);
     }
     return listStartUpJobs;
 }
 public Object MonitorJobLog(NbIdentity identity, object arg)
 {
     string userWatchedJobsKey = String.Format("{0}|{1}", identity.Machinename, identity.Username);
     userWatchedJobLogs[userWatchedJobsKey] = arg.ToString();
     return null;
 }
        public Object SetAsStartUpJob(NbIdentity identity, object arg)
        {
            try
            {
                string startUpJobName = arg.ToString();

                XmlDocument doc = new XmlDocument();
                doc = LoadBitsShellXmlConfigFile();

                XmlNode nodeConfiguration = doc.SelectSingleNode("configuration");

                foreach (XmlNode node in nodeConfiguration.ChildNodes)
                {
                    if (node.Name.Contains("StartupJobs"))
                    {
                        bool isFoundStartUpJob = false;
                        foreach (XmlNode nodeStartUpJob in node.ChildNodes)
                        {
                            if (nodeStartUpJob.Attributes != null && nodeStartUpJob.Attributes["spec"].Value == startUpJobName + ".xml")
                            {
                                isFoundStartUpJob = true;
                            }
                        }
                        if (!isFoundStartUpJob)
                        {
                            XmlNode newStartUpJob = doc.CreateNode(XmlNodeType.Element, "Job", null);
                            XmlAttribute newStartUpAttribute = doc.CreateAttribute("spec");

                            string jobname = startUpJobName + ".xml";
                            newStartUpAttribute.Value = jobname;
                            newStartUpJob.Attributes.Append(newStartUpAttribute);

                            node.AppendChild(newStartUpJob);
                        }
                    }
                }
                doc.Save(GetBitsShellConfigFilePath);

            }
            catch (Exception exception)
            {

                log.Warn(exception);
            }
            return true;
        }
        public Object RemoveStartUpJob(NbIdentity identity, object arg)
        {
            try
            {
                string startUpJobName = arg.ToString();

                XmlDocument doc = new XmlDocument();
                doc = LoadBitsShellXmlConfigFile();

                XmlNode nodeConfiguration = doc.SelectSingleNode("configuration");
                XmlNode nodeToRemove = null;
                foreach (XmlNode node in nodeConfiguration.ChildNodes)
                {
                    if (node.Name.Contains("StartupJobs"))
                    {
                        bool isFoundStartUpJob = false;
                        foreach (XmlNode nodeStartUpJob in node.ChildNodes)
                        {
                            if (nodeStartUpJob.Attributes != null && nodeStartUpJob.Attributes["spec"].Value == startUpJobName + ".xml")
                            {
                                isFoundStartUpJob = true;
                                nodeToRemove = nodeStartUpJob;
                            }
                        }
                        if (isFoundStartUpJob && nodeToRemove != null)
                        {
                            node.RemoveChild(nodeToRemove);
                        }
                    }
                }
                doc.Save(GetBitsShellConfigFilePath);
            }
            catch (Exception exception)
            {

                log.Warn(exception);
            }
            return true;
        }
 public Object GetSystemLog(NbIdentity identity, object arg)
 {
     return GetLogEntries(null);
 }
 public Object GetUserWatchedJob(NbIdentity identity, object arg)
 {
     if (jobKeyCodes.ContainsKey(arg.ToString()))
         return GetLogEntries(jobKeyCodes[arg.ToString()]);
     return null;
 }
Exemple #10
0
	    /// <summary>
        /// Top level of job execution
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="_arg"></param>
        /// <returns></returns>
		public Object RunJobXml(NbIdentity identity, object arg, JobDetails jobDetail)
		{
			try
			{
			    if (jobDetail == null)
			    {
                    try
                    {
                        //form the job from the input
                        var jobName = arg.ToString().Substring(0, arg.ToString().IndexOf('|'));
                        var jobSpecXml = arg.ToString().Substring(arg.ToString().IndexOf('|') + 1);
                    
                        //VJ No longer needed?
                        //jobSpecXml = jobName.StartsWith("ADHOC_") ?
                        //   ConfigUtils.MetaTagReplacer(jobSpecXml, ConfigUtils.MetatagMode.Environment) :
                        //    jobSpecXml;
                        jobDetail = new JobDetails(jobName, jobSpecXml);
                        jobDetail.AdapterType = "Bits.FileManagerNS.Adapters.JobAdapter";

                        //gui support
                        userWatchedJobLogs[String.Format("{0}|{1}", identity.Machinename, identity.Username)] = jobName;
                    }
                    catch
                    {
                        throw new ApplicationException(String.Format("Malformed request to RunJobXml [{0}]", arg));
                    }
			    }

                log.InfoFormat("Running job {0}.  Requested by {1}\\{2} on {3}", jobDetail.Name, identity.AppDomain, identity.Username, identity.Machinename);
                ExecutionEngine.InstanceOf().QueueExecuteJob(jobDetail);
			}
			catch (Exception ex)
			{
				log.Error(ex);
				return false;
			}
			return true;
		}
Exemple #11
0
 /// <summary>
 /// Main entry point from NB
 /// </summary>
 /// <param name="identity"></param>
 /// <param name="_arg"></param>
 /// <returns></returns>
 public Object RunJobXml(NbIdentity identity, object arg)
 {
     return RunJobXml(identity, arg, null);
 }
Exemple #12
0
        private void ReloadJob(string jobName)
        {
            ExecutionEngine.InstanceOf().RemoveJob(jobName, true);

           NbIdentity nbIdentity = new NbIdentity(AppDomain.CurrentDomain.FriendlyName,"","");
            object arg = String.Format("{0}.xml|{1}",jobName, globalConfig.Hierarchy.GetValueAtLevel("BITS_JOB_SPEC",jobName.Replace("_Job",""), ""));
            ExecutionEngine.InstanceOf().RunJobXml( nbIdentity, arg);
        }