Exemple #1
0
        public static ProcessBatch CreateProcessBatch(List <string> rawfiles)
        {
            var processBatch = new ProcessBatch()
            {
                Id        = Guid.NewGuid(),
                UserId    = "me",
                Name      = "My process batch",
                Path      = @"C:\Prototype\diagramTest\TestData",
                Extension = ".test",
                ExtraInfo = new Collection <ExtraProcessInfo>()
                {
                    new ExtraProcessInfo()
                    {
                        Key = "file", Value = "path"
                    }
                }
            };

            string       rawFilePath = @"C:\SimSourceData";
            var          jobs        = CreateProcessJobs(rawFilePath, rawfiles);
            ProcessGroup group       = new ProcessGroup();

            {
            };

            List <ProcessGroup> seqs = new List <ProcessGroup>()
            {
            };

            //seqs.Add(seq);

            // processBatch.Sequences = seqs;
            return(processBatch);
        }
Exemple #2
0
        public ActionResult Create(ProcessGroup processGroup)
        {
            try
            {
                var username          = User.Identity.Name;
                var existProcessGroup = db.ProcessGroups.Where(x => x.Name == processGroup.Name).SingleOrDefault();

                if (existProcessGroup != null)
                {
                    ViewBag.ProcessGroupExist = "Process Group already exist";
                    return(View());
                }
                else
                {
                    processGroup.Created        = DateTime.Now;
                    processGroup.CreatedBy      = username;
                    processGroup.LastModified   = DateTime.Now;
                    processGroup.LastModifiedBy = username;
                    db.ProcessGroups.Add(processGroup);
                    db.SaveChanges();

                    ViewBag.Message = "Success";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ViewBag.Exception    = ex;
                ViewBag.ErrorMessage = "An error occured, please check your data input and try again";
            }
            return(View("Error"));
        }
        private ProcessBatch CreateProcessBatch(Guid batchId, List <IdNamePair> measurements)
        {
            var processBatch = new ProcessBatch()
            {
                Id        = batchId,
                UserId    = "me", //jlin how about user id?
                Name      = "Post upload batch",
                Path      = "",
                Extension = ".batch",
                ExtraInfo = new Collection <ExtraProcessInfo>()
                {
                    new ExtraProcessInfo()
                    {
                        Key = "file", Value = "path"
                    }
                }
            };

            string            rawFilePath = "";
            List <ProcessJob> jobs        = CreateProcessJobs(measurements);
            ProcessGroup      group       = new ProcessGroup()
            {
                Name = "post upload group",
                Jobs = jobs
            };

            processBatch.Groups.Add(group);
            return(processBatch);
        }
Exemple #4
0
        /// <summary>
        /// Method Delete berfungsi untuk menghapus data process group
        /// </summary>
        /// <param name="id">parameter id yang merupakan id dari process group</param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            ProcessGroup processGroup = db.ProcessGroups.Find(id);

            try
            {
                if (processGroup.MasterProcesses.Count() > 0)
                {
                    ViewBag.ErrorMessage = processGroup.Name + " " + "can't be deleted, because there are some process on this process group";
                    return(View("Error"));
                }
                else
                {
                    db.ProcessGroups.Remove(processGroup);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "ProcessGroup"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "An error occured, please check your data input and try again";
                ViewBag.Exception    = ex;
            }
            return(View("Error"));
        }
Exemple #5
0
        private static IEnumerable <ComponentNode> ExcuteComplexStartNode(List <ComponentNode> paramList,
                                                                          ComponentNode startNode,
                                                                          ICollection <ExtraProcessInfo> extraProcessInfos,
                                                                          INotificationCallback callback,
                                                                          ProcessBatch batch,
                                                                          ProcessGroup group,
                                                                          ProcessJob job)
        {
            Guid zero = new Guid();
            IEnumerable <ComponentNode> childParams = from p in paramList where (p.ParentIdList.FirstOrDefault(pl => pl == startNode.Id) != zero) select p;
            IExecuteStartupComponent    component   = ProcessObjectLocator.LocateStartComponentProcess(startNode.CompopnentExcutionName);

            if (component != null)
            {
                //do waht ever client initiation here
                IResultForNextNode obj = component.ExecuteStartupComponent(batch, group, job, extraProcessInfos,
                                                                           paramList, startNode, callback);
                //since startup node takes raw file usually open it
                foreach (var param in paramList)
                {
                    //set iRaw Data to each ComponentParameters
                    param.StartupResult          = obj;
                    param.TreeExecutionTag       = startNode.TreeExecutionTag;
                    param.ParentComponentResults = new List <IResultForNextNode>();
                    param.ParentComponentResults.Add(obj);
                    param.ProcessedParentCount = 0;
                }
            }
            return(childParams);
        }
Exemple #6
0
        public ActionResult Edit(int id, ProcessGroup processGroup)
        {
            try
            {
                var username          = User.Identity.Name;
                var existProcessGroup = db.ProcessGroups.Where(x => x.ID != processGroup.ID && x.Name == processGroup.Name).FirstOrDefault();

                if (existProcessGroup != null)
                {
                    ViewBag.ProcessGroupExist = "Process Group already exist";
                    return(View());
                }
                else
                {
                    // TODO: Edit ProcessGroup
                    var processGroupData = db.ProcessGroups.Find(id);
                    processGroupData.Name           = processGroup.Name;
                    processGroupData.LastModified   = DateTime.Now;
                    processGroupData.LastModifiedBy = username;
                    db.SaveChanges();

                    ViewBag.Message = "success";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ViewBag.Exception    = ex;
                ViewBag.ErrorMessage = "An error occured, please check your data input and try again";
            }
            return(View("Error"));
        }
Exemple #7
0
 private void AnimateCells(Dictionary <Entity, int> offsettedCells, Entity requestEntity)
 {
     if (offsettedCells.Count > 0)
     {
         var animationGroup = new ProcessGroup <AnimationComponent, GravityAnimationMarker>(EntityManager, Entities);
         animationGroup.OnCompleted     += OnAnimationCompleted;
         animationGroup.OnItemCompleted += OnCellAnimationCompleted;
         foreach (var cell in offsettedCells.Keys)
         {
             CellPosition position        = EntityManager.GetComponentData <CellPosition>(cell);
             int          offset          = offsettedCells[cell];
             Entity       animationEntity = animationGroup.Add(
                 new AnimationComponent(position, new Vector2(position.x, position.y + offset), 0.2f),
                 new GravityAnimationMarker {
                 Cell = cell
             });
             EntityManager.AddComponent <ToWorldPositionMarker>(animationEntity);
             EntityManager.SetComponentData(animationEntity, new ToWorldPositionMarker {
                 Entity = cell
             });
             position.y += offset;
             EntityManager.SetComponentData(cell, position);
         }
         _requestByAnimation.Add(animationGroup, requestEntity);
     }
     else
     {
         EntityManager.SetComponentData(requestEntity, new GravityRequest {
             Status = 2
         });
     }
 }
Exemple #8
0
        public ServiceResponse UpdateGroup(ProcessGroup group, int currentUserID, string currentUsername)
        {
            ServiceResponse res = new ServiceResponse();

            if (group == null || (group != null && group.ProcessGroupName == null))
            {
                res.OnError("Data empty");
                return(res);
            }
            var processGrp = _processGroupRepository.GetSingleById(group.ProcessGroupId);

            if (processGrp == null)
            {
                res.OnError("Group not exist");
                return(res);
            }

            if (!_processGroupRepository.CheckContains(x => x.ProcessGroupName == group.ProcessGroupName))
            {
                DateTime now = DateTime.Now;

                processGrp.ProcessGroupName = group.ProcessGroupName;
                processGrp.ModifiedBy       = currentUsername;
                processGrp.ModifiedDate     = now;

                _processGroupRepository.Update(processGrp);
                res.OnSuccess(processGrp);
                this.Save();
            }
            else
            {
                res.OnError("Duplicate group");
            }
            return(res);
        }
Exemple #9
0
        public ServiceResponse AddGroup(ProcessGroup group, int currentUserID, string currentUsername)
        {
            ServiceResponse res = new ServiceResponse();

            if (group == null || (group != null && group.ProcessGroupName == null))
            {
                res.OnError("Data empty");
                return(res);
            }

            if (!_processGroupRepository.CheckContains(x => x.ProcessGroupName == group.ProcessGroupName))
            {
                DateTime now = DateTime.Now;

                group.CreatedBy    = currentUsername;
                group.CreatedDate  = now;
                group.ModifiedBy   = currentUsername;
                group.ModifiedDate = now;

                var userGrpAdd = _processGroupRepository.Add(group);
                res.OnSuccess(userGrpAdd);

                this.Save();
            }
            else
            {
                res.OnError("Duplicate group");
            }
            return(res);
        }
Exemple #10
0
 private Expression ThresholdEqualExpression(ProcessGroup group, int threshold)
 {
     return
         (Expression.Equal(
              Expression.Property(
                  Expression.Constant(group), "RegisteredMembers"),
              Expression.Constant(threshold)));
 }
        public void Invoke()
        {
            CreateProcessGroup createProcessGroup = new CreateProcessGroup();

            createProcessGroup.ProcessGroup = this.m_ProcessGroup;
            createProcessGroup.Insert();
            this.m_ProcessGroup = createProcessGroup.ProcessGroup;
        }
Exemple #12
0
        private static ComponentNode ExcuteComplexComponentNode(List <ComponentNode> paramList,
                                                                ComponentNode thisNode,
                                                                INotificationCallback callback,
                                                                ProcessBatch batch,
                                                                ProcessGroup group,
                                                                ProcessJob job)
        {
            ComponentNode nextNode = null;

            if (thisNode.CompNodeValidation == NodeValidationType.Group)
            {
                return(thisNode);
            }

            Debug.WriteLine(thisNode.ComponentName);
            thisNode.ProcessedParentCount++;
            if (thisNode.ProcessedParentCount != thisNode.ParentIdList.Count)
            {
                //    _excutableInWait.Add(thisNode);
                return(null);
            }
            Guid zero           = new Guid();
            var  childrenParams = (from p in paramList
                                   where (p.ParentIdList.FirstOrDefault(pl => pl == thisNode.Id) != zero)
                                   select p).ToList();

            //            IEnumerable<ComponentNode> childrenParams = from p in paramList where p.ParentId == thisNode.Id select p;
            //IExcuteComponent component = ProcessObjectLocator.LocateComponentProcess(thisNode.CompopnentExcutionName);
            Type tp = ProcessRunTimeLocator.GetExecutableType(thisNode.CompopnentExcutionName);

            if (tp == null)
            {
                return(null);
            }
            IExcuteComponent component = (IExcuteComponent)Activator.CreateInstance(tp);

            if (component != null)
            {
                IResultForNextNode ret = component.ExcuteThermoComponent(paramList, thisNode, callback, batch, group, job);
                if (ret != null)
                {
                    ret.ThisNodeId = thisNode.Id;
                    foreach (var param in childrenParams)
                    {
                        param.ParentComponentResults.Add(ret);
                    }
                }
            }
            thisNode.ParentComponentResults.Clear();

            //_excutableInWait.Remove(thisNode);
            thisNode.ProcessedParentCount = 0;
            foreach (var childrenParam in childrenParams)
            {
                nextNode = ExcuteComplexComponentNode(paramList, childrenParam, callback, batch, group, job);
            }
            return(nextNode);
        }
Exemple #13
0
 private void OnAnimationCompleted(ProcessGroup <AnimationComponent, GravityAnimationMarker> animation)
 {
     if (_requestByAnimation.TryGetValue(animation, out var requestEntity))
     {
         EntityManager.SetComponentData(requestEntity, new GravityRequest {
             Status = 2
         });
     }
 }
Exemple #14
0
        public ProcessBatch Create2SequenceProcessBatch(MnemeBatch batch)
        {
            string path         = System.IO.Path.Combine(batch.Path, batch.Name + batch.Extension);
            var    processBatch = new ProcessBatch()
            {
                Id          = batch.Id,
                UserId      = "me",
                Name        = batch.Name,
                Path        = batch.Path,
                Description = "test batch",
                Extension   = batch.Extension,
                ExtraInfo   = new Collection <ExtraProcessInfo>()
                {
                    new ExtraProcessInfo()
                    {
                        Key = "file", Value = path
                    }
                }
            };
            List <string> processes = new List <string>();

            for (int i = 0; i < 10; i++)
            {
                processes.Add("TestProcess1");
            }
            string       rawFilePath = @"C:\SimSourceData";
            var          jobs        = CreateProcessJobs(rawFilePath, processes);
            ProcessGroup seq         = new ProcessGroup()
            {
                Name = "sequence 1",
                EndOfSequenceProcess = "ClientEndOfSequenceProcess",
                Jobs        = jobs,
                Description = "group test"
            };
            List <ProcessGroup> seqs = new List <ProcessGroup>()
            {
            };

            seqs.Add(seq);


            var          jobs2 = CreateProcessJobs(rawFilePath, processes);
            ProcessGroup seq2  = new ProcessGroup()
            {
                Name = "sequence 2",
                EndOfSequenceProcess = "ClientEndOfSequenceProcess",
                Jobs = jobs2,
            };

            seqs.Add(seq2);

            processBatch.Groups   = seqs;
            processBatch.AppBatch = this;

            return(processBatch);
        }
Exemple #15
0
        private XElement MakeProcessGroupElement(string groupName, ProcessGroup group)
        {
            var element = new XElement("ProcessGroup");

            element.SetAttributeValue("name", groupName);
            element.SetAttributeValue("targetNumberOfProcesses", group.targetNumberOfProcesses);
            foreach (var p in group.registration.Where(r => r.Value != null))
            {
                element.Add(MakeProcessElement(p.Key, p.Value));
            }
            return(element);
        }
Exemple #16
0
 private static void LaunchRobots(ProcessGroup processGroup)
 {
     foreach (var robotConfig in processGroup.Where(r => r.Enabled))
     {
         try
         {
             LaunchRobot(Program.Configuration.Load <Program, Global>().RobotsDirectoryName, robotConfig);
         }
         catch (Exception ex)
         {
             LogEntry.New().Error().Exception(ex).Message($"Error starting '{robotConfig.FileName}'.").Log(Logger);
             break;
         }
     }
 }
Exemple #17
0
        public ProcessGroupModel(String name, ProcessGroup group)
        {
            Name = name;

            Start  = DateTime.MaxValue;
            Finish = DateTime.MinValue;

            Children = new List <Timeline.IGroup>();

            if (group.Processes.Count > 0)
            {
                Start  = group.Processes.Min(p => p.Start);
                Finish = group.Processes.Max(p => p.Finish);
            }

            if (group.Counters != null)
            {
                for (int i = 0; i < group.Counters.Descriptions.Count; ++i)
                {
                    ProcessCountersGroup countersGroup = new ProcessCountersGroup(Start, Finish, group.Counters, i);
                    countersGroup.Start  = Start;
                    countersGroup.Finish = Finish;
                    Children.Add(countersGroup);
                }
            }

            foreach (ProcessData process in group.Processes)
            {
                Add(process);
            }

            foreach (Timeline.IGroup g in Children)
            {
                Height = Height + g.Height;

                if (g.Start < Start)
                {
                    Start = g.Start;
                }

                if (g.Finish > Finish)
                {
                    Finish = g.Finish;
                }
            }

            Height = Children.Sum(c => c.Height);
        }
Exemple #18
0
        public void LoadCapture(String file)
        {
            if (file != null && File.Exists(file))
            {
                using (Stream stream = File.OpenRead(file))
                {
                    ProcessGroup group = Serializer.Load <ProcessGroup>(stream);
                    Collector.Group = group;

                    ProcessList.DataContext = null;
                    ProcessList.DataContext = Collector;

                    Timeline.Board = new ProcessGroupModel(file, group);
                }
            }
        }
Exemple #19
0
        public Form1()
        {
            InitializeComponent();
            _process                    = new ProcessGroup();
            ui                          = new UI.UI(this);
            InfoShow.DoubleClick       += InfoShow_DoubleClick;
            InfoShow.Icon               = this.Icon;
            InfoShow.BalloonTipClicked += Program.ResponseNoticeClick;
            Program.Running             = true;

            var bound = RegUtil.GetFormPos(this);

            this.Load += (x, xx) => { SetBounds(bound[0], bound[1], bound[2], bound[3]); };

            //OptShow.CallBack["ShowTomato"] = ActionBase.ShowTomato;
            //OptShow.CallBack["ExitInst"] = () => { Program.ExitProgram(); };
        }
        public ServiceResponse AddProcessToGroup(ProcessGroup processGroup)
        {
            ServiceResponse result = new ServiceResponse();

            try
            {
                var currentUserID   = GetCurrentUser.GetUserID(User.Claims.ToList());
                var currentUsername = User.Identity.Name;
                result = _processService.AddProcessToGroup(processGroup, currentUserID, currentUsername);
            }
            catch (Exception ex)
            {
                result.OnExeption(ex);
            }


            return(result);
        }
Exemple #21
0
        public ProcessBatch GetProcessBatch()
        {
            var processBatch = new MnemeBatch()
            {
                Id        = Guid.NewGuid(),
                UserId    = "me",
                Name      = BatchName,
                Path      = @"C:\Prototype\WorkflowTest\TestData",
                Extension = ".test",
                ExtraInfo = new Collection <ExtraProcessInfo>()
                {
                    new ExtraProcessInfo()
                    {
                        Key = "file", Value = "path"
                    }
                }
            };
            List <ProcessGroup> seqs = new List <ProcessGroup>()
            {
            };
            string rawFilePath = @"C:\SimSourceData";
            int    count       = 0;

            foreach (var item in UiProcessBatch)
            {
                var jobs = CreateProcessJobs(item, rawFilePath);
                if (jobs.Count > 0)
                {
                    ProcessGroup seq = new ProcessGroup()
                    {
                        Id   = Guid.NewGuid(),//item.Id,
                        Name = item.Name,
                        Jobs = jobs
                    };

                    count++;
                    seqs.Add(seq);
                }
            }


            processBatch.Groups = seqs;
            return(processBatch);
        }
Exemple #22
0
 public void ScheduleRobots(ProcessGroup scheme)
 {
     if (scheme.Enabled)
     {
         if (_robots.TryGetValue(scheme, out ProcessGroup currentScheme))
         {
             RescheduleJob(scheme, scheme.Schedule.Trim(), scheme.StartImmediately);
             _robots.TryUpdate(scheme, scheme, currentScheme);
         }
         else
         {
             ScheduleJob <RobotLaucher>(scheme, scheme.Schedule.Trim(), scheme.StartImmediately);
             _robots.TryAdd(scheme, scheme);
         }
     }
     else
     {
         UnscheduleJob(scheme);
         _robots.TryRemove(scheme, out ProcessGroup removedScheme);
     }
 }
Exemple #23
0
 public void RefreshData(ProcessGroup process)
 {
     try
     {
         int sumTime = 0;
         foreach (var p in process.Process)                //刷新
         {
             ProcessData target = null;
             if (Data.ContainsKey(p.ProcessAliasName))
             {
                 target = Data[p.ProcessAliasName];
             }
             else
             {
                 brushs.Add(new SolidBrush(p.AppInfo.IconMainColor));
                 target = new ProcessData()
                 {
                     ColorIndex = brushs.Count - 1, Rank = nowNum++
                 };
                 Data.Add(p.ProcessAliasName, target);
             }
             target.time = Program.ProcessData[p.ProcessAliasName].TodayWasteTime;
             sumTime    += target.time;
         }
         if (sumTime == 0)
         {
             sumTime = 10;
         }
         foreach (var data in Data)                //重新规划
         {
             data.Value.targetValue = 100f * data.Value.time / sumTime;
         }
         ProcessData.RefreshRank(ref this.Data);
     }
     catch (Exception)
     {
     }
 }
Exemple #24
0
        public ServiceResponse AddProcessToGroup(ProcessGroup group, int currentUserID, string currentUsername)
        {
            ServiceResponse res = new ServiceResponse();

            if (group == null || (group != null && group.ProcessGroupName == null))
            {
                res.OnError("Data empty");
                return(res);
            }
            var processGrp = _processGroupRepository.GetSingleById(group.ProcessGroupId);

            if (processGrp == null)
            {
                res.OnError("Group not exist");
                return(res);
            }

            processGrp.Processes = group.Processes;

            _processGroupRepository.Update(processGrp);
            res.OnSuccess(processGrp);
            this.Save();
            return(res);
        }
Exemple #25
0
        //complex solver
        internal static ComponentNode SolveComplexComponentTree(this ComponentSolver solver,
                                                                List <ComponentNode> paramList,
                                                                ComponentNode startNode,
                                                                ICollection <ExtraProcessInfo> extraProcessInfos,
                                                                INotificationCallback callback,
                                                                ProcessBatch batch,
                                                                ProcessGroup group,
                                                                ProcessJob job)
        {
            ComponentNode nextComponent          = null;
            IEnumerable <ComponentNode> children = ExcuteComplexStartNode(paramList, startNode,
                                                                          extraProcessInfos,
                                                                          callback, batch, group, job);

            foreach (var componentParam in children)
            {
                var comparam = ExcuteComplexComponentNode(paramList, componentParam, callback, batch, group, job);
                if (nextComponent == null)
                {
                    nextComponent = comparam;
                }
            }
            return(nextComponent);
        }
Exemple #26
0
        public static ChartRow GenerateCoreChart(FrameGroup group)
        {
            if (group.Synchronization == null || group.Synchronization.Events.Count == 0)
            {
                return(null);
            }

            group.Synchronization.Events.Sort();

            int eventsCount = group.Synchronization.Events.Count;

            List <Tick> timestamps = new List <Tick>(eventsCount);

            ChartRow.Entry currProcess = new ChartRow.Entry(eventsCount)
            {
                Fill = Colors.LimeGreen, Name = "Current Process"
            };
            ChartRow.Entry otherProcess = new ChartRow.Entry(eventsCount)
            {
                Fill = Colors.Tomato, Name = "Other Process"
            };

            List <bool> isCoreInUse = new List <bool>(group.Board.CPUCoreCount);

            int currCores  = 0;
            int otherCores = 0;

            foreach (SyncEvent ev in group.Synchronization.Events)
            {
                ProcessGroup prevGroup = GetProcessGroup(group, ev.OldThreadID);
                ProcessGroup currGroup = GetProcessGroup(group, ev.NewThreadID);

                while (isCoreInUse.Count <= ev.CPUID)
                {
                    isCoreInUse.Add(false);
                }

                if ((prevGroup != currGroup) || !isCoreInUse[ev.CPUID])
                {
                    timestamps.Add(ev.Timestamp);

                    if (isCoreInUse[ev.CPUID])
                    {
                        switch (prevGroup)
                        {
                        case ProcessGroup.CurrentProcess:
                            --currCores;
                            break;

                        case ProcessGroup.OtherProcess:
                            --otherCores;
                            break;
                        }
                    }

                    isCoreInUse[ev.CPUID] = true;
                    switch (currGroup)
                    {
                    case ProcessGroup.CurrentProcess:
                        ++currCores;
                        break;

                    case ProcessGroup.OtherProcess:
                        ++otherCores;
                        break;
                    }

                    currProcess.Values.Add((double)currCores);
                    otherProcess.Values.Add((double)otherCores);
                }
            }

            ChartRow chart = new ChartRow("CPU", timestamps, new List <ChartRow.Entry>()
            {
                currProcess, otherProcess
            }, isCoreInUse.Count);

            return(chart);
        }
Exemple #27
0
 internal void RefreshData(ProcessGroup process)
 {
     up.饼图.RefreshData(process);
     center.apps.RefreshData(process);
 }
Exemple #28
0
 public bool TryGetProcessGroup(string name, out ProcessGroup scheme) => _robots.TryGetValue(name, out scheme);