示例#1
0
文件: StepTracer.cs 项目: mchnry/flow
 public StepTraceNode <ActivityProcess> TraceStep(StepTraceNode <ActivityProcess> parent, ActivityProcess value)
 {
     return(this.tracer.TraceNext(parent, value));
 }
示例#2
0
文件: StepTracer.cs 项目: mchnry/flow
 internal EngineStepTracer(ActivityProcess process)
 {
     this.tracer = new StepTracer <ActivityProcess>();
     this.Root   = this.CurrentStep = this.tracer.TraceFirst(process);
 }
示例#3
0
文件: StepTracer.cs 项目: mchnry/flow
 public StepTraceNode <ActivityProcess> TraceStep(ActivityProcess value)
 {
     return(this.tracer.TraceNext(this.CurrentStep, value));
 }
示例#4
0
        public FileResult ProcessData(string Identification, HttpPostedFileBase FileBase, int Case)
        {
            //Save uploaded file
            string mainPath = Server.MapPath("~/Files");

            if (FileBase != null && FileBase.ContentLength > 0)
            {
                var suportedTypes = new[] { "txt" };
                var fileExt       = Path.GetExtension(FileBase.FileName).Substring(1);

                if (!suportedTypes.Contains(fileExt))
                {
                    ModelState.AddModelError("file", "Invalid type. Only the following types (txt) are supported.");
                    return(null);
                }

                FileBase.SaveAs(Path.Combine(mainPath, "dataIn.txt"));
            }

            //Open file, verify data  and convert them into a list
            IList <int> DataList = FileHelper.OpenFile(Path.Combine(mainPath, "dataIn.txt"));
            int         WorkingDays;
            IList <int> ElementsQty;
            IList <int> ElementsWeight;
            IList <int> result;

            if (DataList.Count < 3)
            {
                //Can write a log file
                ModelState.AddModelError("file", "Invalid data file. Check data.");
                return(null);
            }

            //Split data into the different types: Working days, Elements quantity and Elements weights
            ListSplitter.Split(DataList, out WorkingDays, out ElementsQty, out ElementsWeight);

            if (WorkingDays == 0 || ElementsQty.Count == 0 || ElementsWeight.Count == 0)
            {
                ModelState.AddModelError("data", "Invalid quantity data in file");
                return(null);
            }

            //Process data
            if (WorkingDays == ElementsQty.Count)
            {
                result = ActivityProcess.Execute(WorkingDays, ElementsQty, ElementsWeight, Case);
                if (result.Count != WorkingDays)
                {
                    return(null);
                }

                if (FileHelper.CreateFile(result, Path.Combine(mainPath, "result.txt")) == FileHelper.State.Fail)
                {
                    return(null);
                }

                //Save to database
                DataBaseHelper.SaveTrace(Identification, Case, DataList, result);

                string fileName    = Path.Combine(mainPath, "result.txt");
                string contentType = "application/octet-stream";

                return(new FilePathResult(fileName, contentType));
            }

            return(null);
        }