예제 #1
0
 /// <summary>
 /// Sets the processing state of the script to done
 /// it will not be returned by the NextItem property.
 /// </summary>
 /// <param name="script">The script to set the stage for</param>
 public void SetState(ISourceScript script, ProcessStage stage)
 {
     if (IsIncluded(script))
     {
         doneState[IndexOfFile(script.GetKey())] = stage;
     }
 }
예제 #2
0
        public ActionResult Create(ProcessStageViewModel model, bool IsPopup)
        {
            if (ModelState.IsValid)
            {
                var ProcessStage = new ProcessStage();
                AutoMapper.Mapper.Map(model, ProcessStage);
                ProcessStage.IsDeleted      = false;
                ProcessStage.CreatedUserId  = WebSecurity.CurrentUserId;
                ProcessStage.ModifiedUserId = WebSecurity.CurrentUserId;
                ProcessStage.AssignedUserId = WebSecurity.CurrentUserId;
                ProcessStage.CreatedDate    = DateTime.Now;
                ProcessStage.ModifiedDate   = DateTime.Now;
                ProcessStageRepository.InsertProcessStage(ProcessStage);

                if (IsPopup)
                {
                    return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" }));
                }
                else
                {
                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                    return(RedirectToAction("Index"));
                }
            }
            return(View(model));
        }
        public void ValidateData()
        {
            switch (this._currentStage)
            {
            case ProcessStage.Start:
                throw new System.InvalidOperationException("Can't validate without initializing");

            case ProcessStage.Init:
                string fileContents = FileManager.ReadFile(this._formFile);

                DailyStockPrice[] parsedData;
                this.validationResult = ParseData(fileContents, out parsedData);
                if (this.validationResult.isValid)
                {
                    DailyStockPrice[] orderedData = parsedData.OrderBy(d => d.price).ToArray();
                    this.buyDayAndPrice  = orderedData.First();
                    this.sellDayAndPrice = orderedData.Last();
                }

                this._currentStage = ProcessStage.Validation;
                break;

            case ProcessStage.Validation:
            case ProcessStage.SaveFile:
            case ProcessStage.SaveReport:
            default:
                throw new System.InvalidOperationException("Validation done already");
            }
        }
예제 #4
0
        /// <summary>
        /// Runs the plugin stage with the specififed type
        /// </summary>
        /// <param name="type"></param>
        /// <param name="stage">The stage of the current processing</param>
        /// <param name="script">the script to be processed</param>
        /// <param name="sourceManager"></param>
        /// <param name="defTable">the definitions that are used</param>
        /// <returns>True if the operation completed successfully</returns>
        private bool RunPluginStage(PluginType type, ProcessStage stage, ISourceScript script,
                                    ISourceManager sourceManager, IDefinitions defTable)
        {
            List <AbstractPlugin> chain = AbstractPlugin.GetPluginsForStage(plugins, type, stage);


            bool ret = true;

            if (type == PluginType.FullScriptPlugin)
            {
                ret = RunFullScriptStage(chain, stage, script, sourceManager, defTable);
            }
            else if (type == PluginType.LinePluginBefore || type == PluginType.LinePluginAfter)
            {
                string[] src = script.GetSource();
                RunLineStage(chain, stage, src);
                script.SetSource(src);
            }
            if (!ret)
            {
                return(false);
            }


            return(true);
        }
예제 #5
0
        /// <summary>
        /// Runs the plugin stage with the specififed type
        /// </summary>
        /// <param name="type"></param>
        /// <param name="stage">The stage of the current processing</param>
        /// <param name="script">the script to be processed</param>
        /// <param name="sourceManager"></param>
        /// <param name="defTable">the definitions that are used</param>
        /// <returns>True if the operation completed successfully</returns>
        private bool RunPluginStage(PluginType type, ProcessStage stage, ISourceScript script, ISourceManager sourceManager, IDefinitions defTable)
        {
            List <AbstractPlugin> chain = AbstractPlugin.GetPluginsForStage(_plugins, type, stage);


            bool ret = true;

            if (type == PluginType.FULL_SCRIPT_PLUGIN)
            {
                ret = RunFullScriptStage(chain, stage, script, sourceManager, defTable);
            }
            else if (type == PluginType.LINE_PLUGIN_BEFORE || type == PluginType.LINE_PLUGIN_AFTER)
            {
                string[] src = script.GetSource();
                RunLineStage(chain, stage, src);
                script.SetSource(src);
            }
            if (!ret)
            {
                return(false);
            }


            return(true);
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fullScriptStage">The chain for this stage</param>
        /// <param name="stage">The stage of the current processing</param>
        /// <param name="script">The script to operate on</param>
        /// <param name="sourceManager">The sourcemanager used.</param>
        /// <param name="defTable">The definitions used</param>
        /// <returns></returns>
        private bool RunFullScriptStage(List <AbstractPlugin> fullScriptStage, ProcessStage stage, ISourceScript script,
                                        ISourceManager sourceManager, IDefinitions defTable)
        {
            foreach (AbstractPlugin abstractPlugin in fullScriptStage)
            {
                bool ret = true;
                Logger.Log(PPLogType.Log, Verbosity.Level3, "Running Plugin: {0}: {1} on file {2}", abstractPlugin,
                           stage, Path.GetFileName(script.GetFileInterface().GetKey()));
                if (stage == ProcessStage.OnLoadStage)
                {
                    ret = abstractPlugin.OnLoad_FullScriptStage(script, sourceManager, defTable);
                }
                else if (stage == ProcessStage.OnMain)
                {
                    ret = abstractPlugin.OnMain_FullScriptStage(script, sourceManager, defTable);
                }

                if (!ret)
                {
                    Logger.Log(PPLogType.Error, Verbosity.Level1, "Processing was aborted by Plugin: {0}",
                               abstractPlugin);
                    return(false);
                }
            }

            return(true);
        }
예제 #7
0
        /// <summary>
        ///     Runs the specified stage on the passed script
        /// </summary>
        /// <param name="stage">The stage of the current processing</param>
        /// <param name="script">the script to be processed</param>
        /// <param name="sourceManager"></param>
        /// <param name="defTable">the definitions that are used</param>
        /// <returns></returns>
        private static bool RunStages(
            PreProcessor pp,
            ProcessStage stage,
            ISourceScript script,
            ISourceManager sourceManager,
            IDefinitions defTable)
        {
            if (!pp.RunPluginStage(PluginType.LinePluginBefore, stage, script, sourceManager, defTable))
            {
                return(false);
            }

            if (stage != ProcessStage.OnFinishUp &&
                !pp.RunPluginStage(PluginType.FullScriptPlugin, stage, script, sourceManager, defTable))
            {
                return(false);
            }

            if (!pp.RunPluginStage(PluginType.LinePluginAfter, stage, script, sourceManager, defTable))
            {
                return(false);
            }

            return(true);
        }
예제 #8
0
        /// <summary>
        /// </summary>
        /// <param name="fullScriptStage">The chain for this stage</param>
        /// <param name="stage">The stage of the current processing</param>
        /// <param name="script">The script to operate on</param>
        /// <param name="sourceManager">The sourcemanager used.</param>
        /// <param name="defTable">The definitions used</param>
        /// <returns></returns>
        private bool RunFullScriptStage(
            List <AbstractPlugin> fullScriptStage, ProcessStage stage, ISourceScript script,
            ISourceManager sourceManager, IDefinitions defTable)
        {
            foreach (AbstractPlugin abstractPlugin in fullScriptStage)
            {
                bool ret = true;
                Logger.Log(LogType.Log, $"Running Plugin: {abstractPlugin}", 4);
                if (stage == ProcessStage.OnLoadStage)
                {
                    ret = abstractPlugin.OnLoad_FullScriptStage(script, sourceManager, defTable);
                }
                else if (stage == ProcessStage.OnMain)
                {
                    ret = abstractPlugin.OnMain_FullScriptStage(script, sourceManager, defTable);
                }

                if (!ret)
                {
                    Logger.Log(LogType.Error, $"Processing was aborted by Plugin: {abstractPlugin}", 1);
                    return(false);
                }
            }

            return(true);
        }
예제 #9
0
 /// <summary>
 /// Returns the plugins that are meant to be run at the specified stage
 /// </summary>
 /// <param name="plugins">All plugins loaded</param>
 /// <param name="type">The plugin type</param>
 /// <param name="stage">the process stage</param>
 /// <returns></returns>
 public static List <AbstractPlugin> GetPluginsForStage(List <AbstractPlugin> plugins, PluginType type,
                                                        ProcessStage stage)
 {
     return(plugins.Where(
                x => BitMask.IsContainedInMask((int)x.PluginTypeToggle, (int)type, true) &&
                BitMask.IsContainedInMask((int)x.ProcessStages, (int)stage, true)).ToList());
 }
예제 #10
0
        /// <summary>
        /// Sets the processing state of the script to done
        /// it will not be returned by the NextItem property.
        /// </summary>
        /// <param name="script"></param>
        public void SetState(ISourceScript script, ProcessStage stage)
        {
            if (IsIncluded(script))
            {
                _doneState[IndexOfFile(script.GetKey())] = stage;

                this.Log(DebugLevel.LOGS, Verbosity.LEVEL3, "Finished Script: {0}", Path.GetFileName(script.GetFilePath()));
            }
        }
예제 #11
0
        protected override void execthread()
        {
            foreach (MediaFile i in this.MediaFileItems.Items)
            {
                if (mnstopevent.WaitOne(0, true))
                {
                    mnhasstoppedevent.Set();
                    return;
                }

                SynchTitle(i.Preset.Name);

                Process nprocess = new Process();
                try {
                    nprocess.StartInfo.FileName               = this.Executable;
                    nprocess.StartInfo.Arguments              = i.BuildCommandLine();
                    nprocess.EnableRaisingEvents              = false;
                    nprocess.StartInfo.UseShellExecute        = false;
                    nprocess.StartInfo.CreateNoWindow         = true;
                    nprocess.StartInfo.RedirectStandardOutput = true;
                    nprocess.StartInfo.RedirectStandardError  = true;
                    nprocess.Start();
                    StreamReader d = nprocess.StandardError;
                    do
                    {
                        string s = d.ReadLine();
                        SynchOutputwindow(s);
                        if (s.Contains("Duration: "))
                        {
                            processstage = ProcessStage.Starting;
                        }
                        else
                        {
                            if (s.Contains("frame="))
                            {
                                processstage = ProcessStage.Processing;
                            }
                            else
                            {
                                processstage = ProcessStage.Error;
                            }
                        }

                        if (mnstopevent.WaitOne(0, true))
                        {
                            nprocess.Kill();
                            mnhasstoppedevent.Set();
                            return;
                        }
                    } while (!d.EndOfStream);
                    nprocess.WaitForExit();
                } finally {
                    nprocess.Close();
                }
            }
            SynchControls();
        }
예제 #12
0
        public override void Execute()
        {
            EntityReference crmRecord = _crmContext.RecordCache[_alias];

            ProcessStage actualStage     = GetCurrentStage(crmRecord);
            Guid?        expectedStageId = GetStageByName(actualStage.ProcessId, _expectedStage);

            Assert.AreEqual(expectedStageId, actualStage.StageId);
        }
        public FileViewModel()
        {
            this.originalFileName = "";
            this.tempFileName     = "";
            this.validationResult = new ValidationResult();
            this.buyDayAndPrice   = new DailyStockPrice();
            this.sellDayAndPrice  = new DailyStockPrice();

            this._currentStage = ProcessStage.Start;
        }
예제 #14
0
        /// <summary>
        /// Sets the processing state of the script to done
        /// it will not be returned by the NextItem property.
        /// </summary>
        /// <param name="script">The script to set the stage for</param>
        public void SetState(ISourceScript script, ProcessStage stage)
        {
            if (IsIncluded(script))
            {
                doneState[IndexOfFile(script.GetKey())] = stage;

                Logger.Log(PPLogType.Log, Verbosity.Level3, "Finished Script: {0}",
                           Path.GetFileName(script.GetFileInterface().GetKey()));
            }
        }
예제 #15
0
        private ProcessStage CreateStage(XElement xml, IEnumerable <Stage> mainPageStages, IEnumerable <PageStage> pages)
        {
            var obj = new ProcessStage(xml)
            {
                MainPage = mainPageStages.ToList(),
                Pages    = new List <PageStage>(pages),
            };

            return(obj);
        }
예제 #16
0
		public void UpdateProgress (AppleDocEventArgs e)
		{
			switch (e.Stage) {
			case ProcessStage.GettingManifest:
				currentStage = ProcessStage.GettingManifest;
				progressIndicator.Indeterminate = true;
				progressIndicator.StartAnimation (this);
				stageLabel.StringValue = "Getting Apple Documentation feed";
				extraStageInfoLabel.Hidden = true;
				break;
			case ProcessStage.Downloading:
				if (currentStage == ProcessStage.Downloading)
					progressIndicator.DoubleValue = e.Percentage;
				else {
					currentStage = ProcessStage.Downloading;
					progressIndicator.Indeterminate = false;
					progressIndicator.StartAnimation (this);
					stageLabel.StringValue = "Downloading Apple documentation";
					extraStageInfoLabel.Hidden = true;
				}
				break;
			case ProcessStage.Extracting:
				if (currentStage == ProcessStage.Extracting)
					extraStageInfoLabel.StringValue = e.CurrentFile;
				else {
					currentStage = ProcessStage.Extracting;
					progressIndicator.Indeterminate = true;
					progressIndicator.StartAnimation (this);
					stageLabel.StringValue = "Extracting Apple documentation";
					extraStageInfoLabel.Hidden = false;
				}
				break;
			case ProcessStage.Merging:
				if (currentStage == ProcessStage.Merging)
					extraStageInfoLabel.StringValue = e.CurrentFile;
				else {
					currentStage = ProcessStage.Merging;
					stageLabel.StringValue = "Merging MonoTouch documentation with Apple documentation";
					progressIndicator.Indeterminate = true;
					progressIndicator.StartAnimation (this);
					extraStageInfoLabel.Hidden = false;
					extraStageInfoLabel.StringValue = "Preparing merge";
				}
				break;
			case ProcessStage.Finished:
				currentStage = ProcessStage.Finished;
				stageLabel.StringValue = "Operation(s) ran successfully";
				progressIndicator.Hidden = true;
				extraStageInfoLabel.Hidden = true;
				break;
			default:
				break;
			}
		}
        public FileViewModel(IFormFile fl)
        {
            this._formFile = fl;

            this.originalFileName = this._formFile.FileName;
            this.tempFileName     = FileManager.GetTempFileName(this._formFile.FileName);
            this.validationResult = new ValidationResult();
            this.buyDayAndPrice   = new DailyStockPrice();
            this.sellDayAndPrice  = new DailyStockPrice();

            this._currentStage = ProcessStage.Init;
        }
예제 #18
0
        /// <summary>
        /// Fixes the order of the file tree if a script was being loaded and is now referenced (again)
        /// by removing it from the lower position and readding it at the top
        /// </summary>
        /// <param name="script">The script that got referenced.</param>
        public void FixOrder(ISourceScript script)
        {
            Logger.Log(LogType.Log,
                       "Fixing Build Order of file: {Path.GetFileName(script.GetFileInterface().GetKey())}", 3);
            int           idx = IndexOfFile(script.GetKey());
            ISourceScript a   = sources[idx];
            ProcessStage  ab  = doneState[idx];

            doneState.RemoveAt(idx);
            doneState.Add(ab);
            sources.RemoveAt(idx);
            AddFile(a, true);
        }
예제 #19
0
        protected override void execthread()
        {
            foreach (MediaFile i in this.MediaFileItems.Items) {
                if (mnstopevent.WaitOne(0, true)) {
                    mnhasstoppedevent.Set();
                    return;
                }

                SynchTitle(i.Preset.Name);

                Process nprocess = new Process();
                try {
                    nprocess.StartInfo.FileName = this.Executable;
                    nprocess.StartInfo.Arguments = i.BuildCommandLine();
                    nprocess.EnableRaisingEvents = false;
                    nprocess.StartInfo.UseShellExecute = false;
                    nprocess.StartInfo.CreateNoWindow = true;
                    nprocess.StartInfo.RedirectStandardOutput = true;
                    nprocess.StartInfo.RedirectStandardError = true;
                    nprocess.Start();
                    StreamReader d = nprocess.StandardError;
                    do {
                        string s = d.ReadLine();
                        SynchOutputwindow(s);
                        if (s.Contains("Duration: ")) {
                            processstage = ProcessStage.Starting;
                        } else {
                            if (s.Contains("frame=")) {
                                processstage = ProcessStage.Processing;
                            } else {
                                processstage = ProcessStage.Error;
                            }
                        }

                        if (mnstopevent.WaitOne(0, true)) {
                            nprocess.Kill();
                            mnhasstoppedevent.Set();
                            return;
                        }

                    } while (!d.EndOfStream);
                    nprocess.WaitForExit();
                } finally {
                    nprocess.Close();
                }
            }
            SynchControls();
        }
예제 #20
0
 /// <summary>
 /// Runs the specified stage on the passed script
 /// </summary>
 /// <param name="stage">The stage of the current processing</param>
 /// <param name="script">the script to be processed</param>
 /// <param name="sourceManager"></param>
 /// <param name="defTable">the definitions that are used</param>
 /// <returns></returns>
 private static bool RunStages(PreProcessor pp, ProcessStage stage, ISourceScript script, ISourceManager sourceManager,
                               IDefinitions defTable)
 {
     if (!pp.RunPluginStage(PluginType.LINE_PLUGIN_BEFORE, stage, script, sourceManager, defTable))
     {
         return(false);
     }
     if (stage != ProcessStage.ON_FINISH_UP && !pp.RunPluginStage(PluginType.FULL_SCRIPT_PLUGIN, stage, script, sourceManager, defTable))
     {
         return(false);
     }
     if (!pp.RunPluginStage(PluginType.LINE_PLUGIN_AFTER, stage, script, sourceManager, defTable))
     {
         return(false);
     }
     return(true);
 }
예제 #21
0
        public bool Update(ProcessStage entity)
        {
            var result = true;

            using (UnitOfWork.Build(_processStageRepository.DbContext))
            {
                result = _processStageRepository.Update(entity);
                //依赖于字段
                var st = new List <ProcessStep>().DeserializeFromJson(entity.Steps);
                if (st.NotEmpty())
                {
                    var attrNames  = st.Select(x => x.AttributeName).ToArray();
                    var attributes = _attributeFinder.FindByName(entity.EntityId, attrNames);
                    var attrIds    = attributes.Select(x => x.AttributeId).ToArray();
                    _dependencyService.Update(WorkFlowDefaults.ModuleName, entity.WorkFlowId, AttributeDefaults.ModuleName, attrIds);
                }
            }

            return(result);
        }
        public void SaveFile()
        {
            switch (this._currentStage)
            {
            case ProcessStage.Start:
            case ProcessStage.Init:
                throw new System.InvalidOperationException("Can't save file without validating");

            case ProcessStage.Validation:
                FileManager.SaveFile(this._formFile, this.tempFileName);

                this._currentStage = ProcessStage.SaveFile;

                break;

            case ProcessStage.SaveFile:
            case ProcessStage.SaveReport:
            default:
                throw new System.InvalidOperationException("File saved already");
            }
        }
예제 #23
0
 /// <summary>
 /// Wrapper that runs a list of line plugins based on the stage that is beeing run.
 /// </summary>
 /// <param name="lineStage">The chain for this stage</param>
 /// <param name="stage">The stage of the current processing</param>
 /// <param name="source">The source to operate on</param>
 private static void RunLineStage(List <AbstractPlugin> lineStage, ProcessStage stage, string[] source)
 {
     foreach (AbstractPlugin abstractPlugin in lineStage)
     {
         for (int i = 0; i < source.Length; i++)
         {
             if (stage == ProcessStage.OnLoadStage)
             {
                 source[i] = abstractPlugin.OnLoad_LineStage(source[i]);
             }
             else if (stage == ProcessStage.OnMain)
             {
                 source[i] = abstractPlugin.OnMain_LineStage(source[i]);
             }
             else if (stage == ProcessStage.OnFinishUp)
             {
                 source[i] = abstractPlugin.OnFinishUp_LineStage(source[i]);
             }
         }
     }
 }
예제 #24
0
 /// <summary>
 /// Wrapper that runs a list of line plugins based on the stage that is beeing run.
 /// </summary>
 /// <param name="lineStage">The chain for this stage</param>
 /// <param name="stage">The stage of the current processing</param>
 /// <param name="source">The source to operate on</param>
 private static void RunLineStage(List <AbstractPlugin> lineStage, ProcessStage stage, string[] source)
 {
     foreach (var abstractPlugin in lineStage)
     {
         for (int i = 0; i < source.Length; i++)
         {
             if (stage == ProcessStage.ON_LOAD_STAGE)
             {
                 source[i] = abstractPlugin.OnLoad_LineStage(source[i]);
             }
             else if (stage == ProcessStage.ON_MAIN)
             {
                 source[i] = abstractPlugin.OnMain_LineStage(source[i]);
             }
             else if (stage == ProcessStage.ON_FINISH_UP)
             {
                 source[i] = abstractPlugin.OnFinishUp_LineStage(source[i]);
             }
         }
     }
 }
예제 #25
0
 /// <summary>
 ///     Wrapper that runs a list of line plugins based on the stage that is beeing run.
 /// </summary>
 /// <param name="lineStage">The chain for this stage</param>
 /// <param name="stage">The stage of the current processing</param>
 /// <param name="source">The source to operate on</param>
 private void RunLineStage(List <AbstractPlugin> lineStage, ProcessStage stage, string[] source)
 {
     foreach (AbstractPlugin abstractPlugin in lineStage)
     {
         Logger.Log(LogType.Log, $"Running Plugin: {abstractPlugin}", 4);
         for (int i = 0; i < source.Length; i++)
         {
             if (stage == ProcessStage.OnLoadStage)
             {
                 source[i] = abstractPlugin.OnLoad_LineStage(source[i]);
             }
             else if (stage == ProcessStage.OnMain)
             {
                 source[i] = abstractPlugin.OnMain_LineStage(source[i]);
             }
             else if (stage == ProcessStage.OnFinishUp)
             {
                 source[i] = abstractPlugin.OnFinishUp_LineStage(source[i]);
             }
         }
     }
 }
예제 #26
0
 /// <summary>
 /// Wrapper that runs a list of line plugins based on the stage that is beeing run.
 /// </summary>
 /// <param name="_lineStage"></param>
 /// <param name="stage"></param>
 /// <param name="source"></param>
 private void RunLineStage(List <AbstractPlugin> _lineStage, ProcessStage stage, string[] source)
 {
     foreach (var abstractPlugin in _lineStage)
     {
         this.Log(DebugLevel.LOGS, Verbosity.LEVEL3, "Running Plugin: {0}: {1}", abstractPlugin, stage);
         for (int i = 0; i < source.Length; i++)
         {
             if (stage == ProcessStage.ON_LOAD_STAGE)
             {
                 source[i] = abstractPlugin.OnLoad_LineStage(source[i]);
             }
             else if (stage == ProcessStage.ON_MAIN)
             {
                 source[i] = abstractPlugin.OnMain_LineStage(source[i]);
             }
             else if (stage == ProcessStage.ON_FINISH_UP)
             {
                 source[i] = abstractPlugin.OnFinishUp_LineStage(source[i]);
             }
         }
     }
 }
        public void SaveReport()
        {
            switch (this._currentStage)
            {
            case ProcessStage.Start:
            case ProcessStage.Init:
            case ProcessStage.Validation:
                throw new System.InvalidOperationException("Can't save report without saving the file");

            case ProcessStage.SaveFile:
                string ReportData = JsonConvert.SerializeObject(this);

                FileManager.SaveReport(ReportData, this.tempFileName);

                this._currentStage = ProcessStage.SaveReport;

                break;

            case ProcessStage.SaveReport:
            default:
                throw new System.InvalidOperationException("Report saved already");
            }
        }
예제 #28
0
        /// <summary>
        ///
        /// </summary>

        /// <param name="fullScriptStage">The chain for this stage</param>
        /// <param name="stage">The stage of the current processing</param>
        /// <param name="script">The script to operate on</param>
        /// <param name="sourceManager">The sourcemanager used.</param>
        /// <param name="defTable">The definitions used</param>
        /// <returns></returns>
        private bool RunFullScriptStage(List <AbstractPlugin> fullScriptStage, ProcessStage stage, ISourceScript script, ISourceManager sourceManager, IDefinitions defTable)
        {
            foreach (var abstractPlugin in fullScriptStage)
            {
                bool ret = true;
                this.Log(DebugLevel.LOGS, Verbosity.LEVEL3, "Running Plugin: {0}: {1} on file {2}", abstractPlugin, stage, Path.GetFileName(script.GetFileInterface().GetKey()));
                if (stage == ProcessStage.ON_LOAD_STAGE)
                {
                    ret = abstractPlugin.OnLoad_FullScriptStage(script, sourceManager, defTable);
                }
                else if (stage == ProcessStage.ON_MAIN)
                {
                    ret = abstractPlugin.OnMain_FullScriptStage(script, sourceManager, defTable);
                }

                if (!ret)
                {
                    this.Error("Processing was aborted by Plugin: {0}", abstractPlugin);
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Executes the workflow activity.
        /// </summary>
        /// <param name="executionContext">The execution context.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            if (tracingService == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
            }

            tracingService.Trace("Entered QueryCurrentProcessStage.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
                                 executionContext.ActivityInstanceId,
                                 executionContext.WorkflowInstanceId);

            // Create the context
            IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>();

            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
            }

            tracingService.Trace("QueryCurrentProcessStage.Execute(), Correlation Id: {0}, Initiating User: {1}",
                                 context.CorrelationId,
                                 context.InitiatingUserId);

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                Entity target   = (Entity)context.InputParameters["Target"];
                Entity preImage = null;
                if (context.PreEntityImages.ContainsKey("PreBusinessEntity"))
                {
                    preImage = (Entity)context.PreEntityImages["PreBusinessEntity"];
                }

                Guid?stageid   = null;
                Guid?processid = null;
                if (target.Attributes.ContainsKey("stageid"))
                {
                    stageid = (Guid?)target["stageid"];
                }
                else if (preImage != null)
                {
                    stageid = (Guid?)preImage["stageid"];
                }
                if (target.Attributes.ContainsKey("processid"))
                {
                    processid = (Guid?)target["processid"];
                }
                else if (preImage != null)
                {
                    processid = (Guid?)preImage["processid"];
                }

                // Get the process and stage names
                string processName = "";
                string stageName   = "";
                if (processid != null)
                {
                    Workflow processStage = (Workflow)service.Retrieve(Workflow.EntityLogicalName, processid.Value, new ColumnSet("name"));
                    processName = processStage.Name;
                }
                if (stageid != null)
                {
                    ProcessStage processStage = (ProcessStage)service.Retrieve(ProcessStage.EntityLogicalName, stageid.Value, new ColumnSet("stagename"));
                    stageName = processStage.StageName;
                }
                ProcessName.Set(executionContext, processName);
                ProcessStageName.Set(executionContext, stageName);
            }
            catch (FaultException <OrganizationServiceFault> e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());

                // Handle the exception.
                throw;
            }

            tracingService.Trace("Exiting QueryCurrentProcessStage.Execute(), Correlation Id: {0}", context.CorrelationId);
        }
예제 #30
0
        private Node LoadIndividual(Node indiNode, GDMIndividualRecord indiRec, int order, int floor, ProcessStage stage)
        {
            Node result = indiNode ?? GetNode(indiRec);

            PrepareNode(result, order, floor);

            if (indiRec == null || IsProcessed(indiRec))
            {
                return(null);
            }

            result.LoadPerson();
            fProcessedRecords.Add(indiRec);

            if (stage != ProcessStage.Spouse && stage != ProcessStage.Child)
            {
                GDMIndividualRecord father, mother;
                Context.Tree.GetParents(indiRec, out father, out mother);
                if (father != null || mother != null)
                {
                    AddParents(result, father, mother);
                }
            }

            for (int i = 0; i < indiRec.SpouseToFamilyLinks.Count; i++)
            {
                var familyRec = Context.Tree.GetPtrValue <GDMFamilyRecord>(indiRec.SpouseToFamilyLinks[i]);
                GDMIndividualRecord spouse = Context.Tree.GetSpouseBy(familyRec, indiRec);

                Family family = null;
                if (stage != ProcessStage.Parent)
                {
                    family = AddSpouse(result, familyRec, spouse);
                }

                if (stage != ProcessStage.Parent && stage != ProcessStage.Spouse)
                {
                    for (int k = 0; k < familyRec.Children.Count; k++)
                    {
                        GDMIndividualRecord child = Context.Tree.GetPtrValue(familyRec.Children[k]);
                        if (child != null && !IsProcessed(child))
                        {
                            AddChild(result, family, child);
                        }
                    }
                }
            }

            return(result);
        }
예제 #31
0
 public static void SetProcessStage(ProgressBar bar, ProcessStage stage)
 {
     bar.SetValue(ProcessStagePropertyKey, stage);
 }
예제 #32
0
        public void UpdateProgress(AppleDocEventArgs e)
        {
            switch (e.Stage)
            {
            case ProcessStage.GettingManifest:
                currentStage = ProcessStage.GettingManifest;
                progressIndicator.Indeterminate = true;
                progressIndicator.StartAnimation(this);
                stageLabel.StringValue     = "Getting Apple Documentation feed";
                extraStageInfoLabel.Hidden = true;
                break;

            case ProcessStage.Downloading:
                if (currentStage == ProcessStage.Downloading)
                {
                    progressIndicator.DoubleValue   = e.Percentage;
                    extraStageInfoLabel.StringValue = e.Percentage + " %";
                }
                else
                {
                    currentStage = ProcessStage.Downloading;
                    progressIndicator.Indeterminate = false;
                    progressIndicator.StartAnimation(this);
                    stageLabel.StringValue     = "Downloading Apple documentation";
                    extraStageInfoLabel.Hidden = false;
                }
                break;

            case ProcessStage.Extracting:
                if (currentStage == ProcessStage.Extracting)
                {
                    extraStageInfoLabel.StringValue = e.CurrentFile ?? "(none)";
                }
                else
                {
                    currentStage = ProcessStage.Extracting;
                    progressIndicator.Indeterminate = true;
                    progressIndicator.StartAnimation(this);
                    stageLabel.StringValue          = "Extracting Apple documentation";
                    extraStageInfoLabel.Hidden      = false;
                    extraStageInfoLabel.StringValue = string.Empty;
                }
                break;

            case ProcessStage.Merging:
                if (currentStage == ProcessStage.Merging)
                {
                    extraStageInfoLabel.StringValue = e.CurrentFile;
                }
                else
                {
                    currentStage                    = ProcessStage.Merging;
                    stageLabel.StringValue          = "Merging MonoTouch documentation with Apple documentation";
                    progressIndicator.Indeterminate = true;
                    progressIndicator.StartAnimation(this);
                    extraStageInfoLabel.Hidden      = false;
                    extraStageInfoLabel.StringValue = "Preparing merge";
                }
                break;

            case ProcessStage.Finished:
                currentStage = ProcessStage.Finished;
                progressIndicator.StopAnimation(this);
                break;

            default:
                break;
            }
        }