Exemple #1
0
        public static bool createInPlan(string jobName, string special_spec = "")
        {
            bool res = false;

            ruleManager = app.RuleManager();
            flowRunner  = ruleManager.FlowRunner("PostJobHook", "PostJobHook:PostJobMain");
            flowRunner.AddInterfaceParameter("CurrentJob", theJob);
            flowRunner.Run();
            checkStatus(flowRunner, "Job");

            string cust_code = "";

            if (jobName.Length >= 12)
            {
                cust_code = jobName.Substring(4, 3);
            }
            else
            {
                cust_code = "000";
            }

            ISpecManager specManager = app.SpecManager();
            Array        specInfos   = specManager.SpecInfos();

            for (int i = 0; i < specInfos.Length; i++)
            {
                ISpecInfo specInfo  = (ISpecInfo)specInfos.GetValue(i);
                string    spec_name = specInfo.Name();
                if (special_spec != "")
                {
                    if (spec_name == special_spec)
                    {
                        jobManager.AttachSpecToJob(theJob, specInfo);
                        break;
                    }
                }
                else if (spec_name.Contains(cust_code))
                {
                    jobManager.AttachSpecToJob(theJob, specInfo);
                    break;
                }
            }

            jobManager.SetJobBySpecs(theJob);

            jobManager.SaveJob(theJob);

            res = true;
            return(res);
        }