/// <summary> /// 依赖项目检测 /// </summary> /// <param name="dependSet"></param> /// <returns></returns> private bool CheckDepend(HashSet <int> dependSet) { if (dependSet == null) { return(true); //无依赖项目,流程初始化的第一个测试项目 } FlowControl flowControl = FlowControl.Instance; foreach (int id in dependSet) { FlowItem flowItem = flowControl.GetFlowItem(id); if (flowItem == null) { return(false); } else if (flowItem.Item.Property.Disable) { if (!CheckDepend(flowItem.DependSet)) { return(false); } } else if (flowItem.Status != FlowItem.STATUS_FINISH) { return(false); } } return(true); }
public bool ItemPut(Collider table) { if (!liftItem) { return(false); } //どのテーブルに置くのか Vector3 workPos = handObj.transform.position; Lane lanec = table.gameObject.GetComponent <Lane>(); if (lanec.laneVelocity.x != 0.0f) { workPos.z = table.gameObject.transform.position.z; } else if (lanec.laneVelocity.z != 0.0f) { workPos.x = table.gameObject.transform.position.x; } else { Debug.Log("Error"); } liftItem.Put(workPos); liftItem = null; return(true); }
/// <summary> /// 在主线程中运行的测试项完成事件响应函数 /// </summary> /// <param name="flowItem"></param> private void ItemExecuteCompleteHandler(FlowItem flowItem) { Log.Debug("Item[" + flowItem.Id + "] " + flowItem.Item.Property.Name + " ItemExecuteCompleteHandler"); flowItem.Status = FlowItem.STATUS_FINISH; UpdatePhoneInfo(flowItem); UpdateFinish(flowItem); if (!flowItem.IsPass() && flowItem.SwitchType > 0) //检查是否需要switch { Switch(flowItem); } else if (!flowItem.IsPass() && flowItem.AlarmType > 0) //检查是否需要alarm { } else { NextFlowItem(flowItem); toolStripProgressBar.PerformStep(); } if (FlowComplete()) { FlowCompleteHandler(); } }
/// <summary> /// 开始测试一个Item项目 /// </summary> /// <param name="flowItem"></param> private void StartFlowItem(FlowItem flowItem) { if (flowItem != null && !flowItem.Item.Property.Disable) { if (!flowItem.IsSkip()) { FlowItemExecutor executor = new FlowItemExecutor(flowItem); executor.ExecuteFinish += ItemExecuteFinish; ThreadPool.QueueUserWorkItem(new WaitCallback(executor.ThreadProc));//将Item注入线程池,排队执行 flowItem.Status = FlowItem.STATUS_RUNNING; UpdateRunning(flowItem); } else { //此项不需要执行,直接跳过执行,并将实测值赋值为Skip,测试结果赋值为失败 if (flowItem.SpecValueList != null && flowItem.SpecValueList.Count > 0) { foreach (SpecValue specValue in flowItem.SpecValueList) { specValue.MeasuredValue = "Skip"; specValue.JudgmentResult = CommonString.RESULT_FAILURE; } } flowItem.Status = FlowItem.STATUS_FINISH; UpdateFinish(flowItem); NextFlowItem(flowItem); } } }
public void CreateFlow(Dictionary <int, FlowStepDTO> steps) { using (VehicleTrackingDbContext context = new VehicleTrackingDbContext()) { foreach (FlowItem flowItem in context.FlowItems) { context.FlowItems.Remove(flowItem); } foreach (int key in steps.Keys) { FlowItem flowItem = new FlowItem(); flowItem.StepNumber = key; flowItem.Id = Guid.NewGuid(); string stepName = steps[key].Name; var query = from f in context.FlowSteps where f.Name == stepName select f; FlowStep flowStep = query.ToList().FirstOrDefault(); flowItem.FlowStep = flowStep; context.FlowItems.Add(flowItem); } context.SaveChanges(); } }
public bool ItemLiftUp(Collider item) { if (liftItem) { return(false); } liftItem = item.gameObject.GetComponent <FlowItem>(); return(true); }
/// <summary> /// 更新执行状态,主要更新控件状态 /// </summary> /// <param name="flowItem"></param> private void UpdateRunning(FlowItem flowItem) { if (flowItem.Status == FlowItem.STATUS_RUNNING && !flowItem.Item.Property.Hide) { DataGridViewCell cell = flowGridView.Rows[flowItem.RowIndex].Cells[COLUMN_ITEM_STATUS]; if (cell != null) { cell.Value = "测试中"; cell.Style.BackColor = Color.Lime; } } }
/// <summary> /// 获取已提交的答案缓存(自动判断是否是自判或流程所在阶段) /// </summary> /// <param name="flow">当前流程</param> /// <param name="stepNumber">指定流程(不指定,将自动判断是否是自判或流程所在阶段)</param> /// <returns></returns> public static string[] ReadAnswer(FlowItem flow, int?stepNumber = null) { var step = stepNumber.HasValue ? stepNumber.Value : APP.StudySession.IsSelfJudgment ? 0 : flow.StepNumber; if (mAnswerCache.ContainsKey(flow.StudentId)) { if (mAnswerCache[flow.StudentId].ContainsKey(step)) { return(mAnswerCache[flow.StudentId][step]); } } return(new string[0]); }
private static void AddTimer(FlowItem flow) { lock (mFlowTimer) { RemoveTimer(flow.StudentId); var timer = new Timer((state) => { var _flow = state as FlowItem; _flow.WatiNextFlow = 0; RunFlows(_flow.PenKey); }, flow, flow.WatiNextFlow * 1000, Timeout.Infinite); mFlowTimer.Add(flow.StudentId, timer); } }
/// <summary> /// 执行下一条流程 /// </summary> /// <param name="flowItem"></param> private void NextFlowItem(FlowItem flowItem) { if (flowItem.BedependSet != null) { FlowControl flowControl = FlowControl.Instance; foreach (int id in flowItem.BedependSet) { FlowItem bedependItem = flowControl.GetFlowItem(id); if (bedependItem != null && bedependItem.Status == FlowItem.STATUS_INIT && CheckDepend(bedependItem.DependSet)) { StartFlowItem(bedependItem); } } } }
private static FlowItem CreateOrGet(string pName) { if (items.ContainsKey(pName)) { return(items[pName]); } var flowItem = new FlowItem { Name = pName, Required = new List <FlowItem>(), Complete = false }; items.Add(pName, flowItem); return(flowItem); }
/// <summary> /// 在UI线程中更新控件并更新FlowControl数据 /// </summary> /// <param name="flowItem"></param> private void UpdateData(FlowItem flowItem) { switch (flowItem.Status) { case FlowItem.STATUS_RUNNING: UpdateRunning(flowItem); break; case FlowItem.STATUS_FINISH: UpdateFinish(flowItem); break; default: break; } }
private void setCurrentFlow(int index, TrainUI.TrainMode mode) { if (currentFlowItem != null) { currentFlowItem.name.color = Color.white; currentFlowItem.arrow.SetActive(false); currentFlowItem.obj.GetComponent <UISprite>().spriteName = "gaoliangxuanzhe-liebiaofenge"; currentFlowItem.obj.GetComponent <UIButton>().normalSprite = "gaoliangxuanzhe-liebiaofenge"; } flows[index].name.color = currentFlowColor; flows[index].arrow.SetActive(true); flows[index].obj.GetComponent <UISprite>().spriteName = currentFlowImg[(int)mode]; flows[index].obj.GetComponent <UIButton>().normalSprite = currentFlowImg[(int)mode]; foldFlowMenuName.color = foldFlowMenuColor[(int)mode]; foldFlowMenuIcon.spriteName = foldFlowmenuIcon[(int)mode]; currentFlowItem = flows[index]; }
/// <summary> /// switch后的处理函数 /// </summary> /// <returns></returns> private void Switch(FlowItem flowItem) { if (flowItem.SwitchType > 0 && !flowItem.IsPass()) { StopFlowTest(); if (flowItem.SwitchType == FlowItem.SWITCH_TYPE_SWITCH) { FlowControl.Instance.FlowCompleteReason = FlowControl.FLOW_COMPLETE_SWITCH; FlowControl.Instance.FlowResult = FlowControl.FLOW_RESULT_FAIL; } else if (flowItem.SwitchType == FlowItem.SWITCH_TYPE_STOP) { FlowControl.Instance.FlowCompleteReason = FlowControl.FLOW_COMPLETE_STOP; FlowControl.Instance.FlowResult = FlowControl.FLOW_RESULT_EXCEPTION; } } }
/// <summary> /// 测试完成后数据更新 /// </summary> /// <param name="flowItem"></param> private void UpdateFinish(FlowItem flowItem) { if (flowItem.Status == FlowItem.STATUS_FINISH && !flowItem.Item.Property.Hide) { if (flowItem.SpecValueList != null) { int rowOffset = 0; for (int i = 0; i < flowItem.SpecValueList.Count; i++) { if (!flowItem.SpecValueList[i].Disable) { DataGridViewCell valueCell = flowGridView.Rows[flowItem.RowIndex + rowOffset].Cells[COLUMN_ITEM_VALUE]; if (valueCell != null) { valueCell.Value = flowItem.SpecValueList[i].MeasuredValue; } DataGridViewCell resultCell = flowGridView.Rows[flowItem.RowIndex + rowOffset].Cells[COLUMN_ITEM_RESULT]; if (resultCell != null) { resultCell.Value = flowItem.SpecValueList[i].JudgmentResult; if (!CommonString.RESULT_SUCCEED.Equals(flowItem.SpecValueList[i].JudgmentResult)) { resultCell.Style.BackColor = Color.Red; } } rowOffset++; } } } DataGridViewCell statusCell = flowGridView.Rows[flowItem.RowIndex].Cells[COLUMN_ITEM_STATUS]; if (statusCell != null) { statusCell.Value = "完成"; statusCell.Style.BackColor = flowGridView.DefaultCellStyle.BackColor; } DataGridViewCell durationCell = flowGridView.Rows[flowItem.RowIndex].Cells[COLUMN_ITEM_DURATION]; if (durationCell != null) { durationCell.Value = Convert.ToString(flowItem.Duration) + "ms"; } } }
/// <summary> /// 添加或下次要执行的流程 /// </summary> /// <param name="flow">待执行的流程</param> private static void UpdateFlow(FlowItem flow) { if (flow == null) { return; } lock (mFlowList) { if (mFlowList.ContainsKey(flow.PenDevice.StudentId)) { mFlowList[flow.PenDevice.StudentId] = flow; } else { mHandwritingTimeout.Add(flow.StudentId, DateTime.Now); mFlowList.Add(flow.PenDevice.StudentId, flow); } } }
public void initFlowMenu(Action <int> action, TrainUI.TrainMode currentTrainMode) { if (!isShowGrid) { showGrid(); } isCircuit = false; isShowToolMenu = false; showFlowMenu(); flows = new Dictionary <int, FlowItem>(); rest(); this.action = action; this.currentTrainMode = currentTrainMode; TrainingBigFlow bigFlow = TrainingManager.getTrainingBigFlow(UIManager.getInstance().trainUI.CurrentTrainFlow); for (int i = 0; i < bigFlow.getFlowIndexs().Count; i++) { TrainingFlow flow = bigFlow.getTrainingFlow(i); GameObject obj = ResourceManager.getInstance().loadUISpawnPool(flowItemPrefab, null); obj.transform.position = Vector3.zero; obj.name = i.ToString(); grid.AddChild(obj.transform); UIEventListener.Get(obj).onClick = flowItemClick; FlowItem flowItem = new FlowItem(); flowItem.index = i; flowItem.obj = obj; flowItem.arrow = obj.transform.Find("arrow").gameObject; flowItem.arrow.gameObject.SetActive(false); flowItem.name = obj.transform.Find("name").GetComponent <UILabel>(); flowItem.name.text = flow.name; flows.Add(i, flowItem); setCurrentFlow(0, currentTrainMode); } flowOperateTitle.spriteName = getFlowTitleSprite(currentTrainMode, isShowToolMenu); flowOperateTitle.GetComponent <UIButton>().normalSprite = flowOperateTitle.spriteName; scrollView.gameObject.SetActive(false); scrollView.gameObject.SetActive(true); grid.repositionNow = true; grid.Reposition(); scrollBar.value = 0; scrollView.GetComponent <UIPanel>().Invalidate(true); }
/// <summary> /// 更新手机状态信息 /// </summary> /// <param name="flowItem"></param> private void UpdatePhoneInfo(FlowItem flowItem) { if (flowItem.Name == "SN") { //更新SN if (flowItem.SpecValueList != null && flowItem.SpecValueList.Count == 1) { AppInfo.PhoneInfo.SN = flowItem.SpecValueList[0].MeasuredValue; ShowSN(AppInfo.PhoneInfo.SN); } } else if (flowItem.Name == "IP") { //更新IP if (flowItem.SpecValueList != null && flowItem.SpecValueList.Count == 1) { AppInfo.PhoneInfo.IP = flowItem.SpecValueList[0].MeasuredValue; PhoneIpManager.Instance.Add(AppInfo.PhoneInfo.IP); } } }
/// <summary> /// 缓存已提交答案 /// </summary> /// <param name="studentId"></param> /// <param name="keys"></param> public static void UpdateAnswer(FlowItem flow, string[] keys) { var step = APP.StudySession.IsSelfJudgment ? 0 : flow.StepNumber; if (mAnswerCache.ContainsKey(flow.StudentId)) { if (mAnswerCache[flow.StudentId].ContainsKey(step)) { mAnswerCache[flow.StudentId][step] = keys; } else { mAnswerCache[flow.StudentId].Add(step, keys); } } else { var answers = new Dictionary <int, string[]>(); answers.Add(step, keys); mAnswerCache.Add(flow.StudentId, answers); } }
private void OnTriggerStay(Collider other) { if (pressPosNumber != setItemNum) { return; } string layerName = LayerMask.LayerToName(other.gameObject.layer); if (layerName != "Item") { return; } FlowItem classItem = other.gameObject.GetComponent <FlowItem>(); Vector3 vel = classItem.moveLaneVelocity; Vector3 posOther = other.transform.position; if ((vel.x > 0.0f && posOther.x >= selfTrans.position.x) || (vel.x < 0.0f && posOther.x <= selfTrans.position.x) || (vel.z > 0.0f && posOther.z >= selfTrans.position.z) || (vel.z < 0.0f && posOther.z <= selfTrans.position.z)) { posOther.x = selfTrans.position.x; posOther.z = selfTrans.position.z; other.transform.position = posOther; classItem.moveLaneVelocity = Vector3.zero; classItem.goalFlag = true; setItemNum++; itemUiClass.ItemGoal(classItem.GetItemType()); if (setItemNum >= 4) { pressMachineClass.Press(); setItemNum = 0; } return; } }
// Token: 0x060015BF RID: 5567 RVA: 0x0004DD44 File Offset: 0x0004BF44 protected override FindFlowConversationItemResponse InternalExecute() { QueryFilter flowConversationFilter = GetFlowConversation.GetFlowConversationFilter(this.folderId, base.MailboxIdentityMailboxSession); IdAndSession folderIdAndSession = GetFlowConversation.GetFolderIdAndSession(this.folderId, base.MailboxIdentityMailboxSession, base.IdConverter); SortBy sortBy = new SortBy(ItemSchema.ReceivedTime, SortOrder.Descending); List <FlowItem> list = new List <FlowItem>(); ConversationFactory conversationFactory = new ConversationFactory(base.MailboxIdentityMailboxSession); using (Folder folder = Folder.Bind((MailboxSession)folderIdAndSession.Session, folderIdAndSession.Id)) { using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, flowConversationFilter, new SortBy[] { sortBy }, FindFlowConversationItem.requiredProperties)) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10000); foreach (IStorePropertyBag storePropertyBag in propertyBags) { if ((long)list.Count == this.requestedItemCount) { break; } string text = this.GenerateParticipantsHash(storePropertyBag); if (text.Equals(this.flowConversationId)) { FlowItem flowItem = new FlowItem(); ExDateTime valueOrDefault = storePropertyBag.GetValueOrDefault <ExDateTime>(ItemSchema.ReceivedTime, ExDateTime.Now); bool valueOrDefault2 = storePropertyBag.GetValueOrDefault <bool>(MessageItemSchema.IsRead, true); IParticipant valueOrDefault3 = storePropertyBag.GetValueOrDefault <IParticipant>(ItemSchema.From, null); VersionedId valueOrDefault4 = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null); ConversationId valueOrDefault5 = storePropertyBag.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null); flowItem.ItemId = IdConverter.ConvertStoreItemIdToItemId(valueOrDefault4, base.MailboxIdentityMailboxSession); flowItem.Sender = FindFlowConversationItem.ConvertParticipantToEmailAddressWrapper(valueOrDefault3); flowItem.IsRead = valueOrDefault2; flowItem.ReceivedTimeUtc = ExDateTimeConverter.ToSoapHeaderTimeZoneRelatedXsdDateTime(valueOrDefault); Conversation key = conversationFactory.CreateConversation(valueOrDefault5, FindFlowConversationItem.ConversationCreatorRelevantProperties); if (!this.conversationMap.ContainsKey(key)) { this.conversationMap[key] = new List <StoreObjectId>(); } this.conversationMap[key].Add(valueOrDefault4.ObjectId); this.flowItemsMap[valueOrDefault4.ObjectId] = flowItem; list.Add(flowItem); } } } } foreach (KeyValuePair <Conversation, List <StoreObjectId> > keyValuePair in this.conversationMap) { Conversation key2 = keyValuePair.Key; List <StoreObjectId> value = keyValuePair.Value; key2.LoadItemParts(value); foreach (StoreObjectId storeObjectId in value) { ItemPart itemPart = key2.GetItemPart(storeObjectId); this.flowItemsMap[storeObjectId].ItemBody = itemPart.BodyPart; } } return(new FindFlowConversationItemResponse { Items = list.ToArray() }); }
/// <summary> /// 创建答题流程 /// </summary> public static void CreateAnswerFlows(Func <FlowItem, FlowItem> action) { mHandwritingTimeout.Clear(); mFlowList.Clear(); mAnswerCache.Clear(); foreach (var studentId in APP.StudySession.StudentIds) { var pen = PenController.Instance.GetPen(studentId); if (pen != null) { var flow = new FlowItem(pen, FlowCommand.答题_开始) { RunAction = action }; //二阶认知程度反馈-课堂实时反馈做题页面 var flow_a_1 = new FlowItem(pen, FlowCommand.答题_二阶_1) { RunAction = action, IsHandwriting = true }; var flow_a_2 = new FlowItem(pen, FlowCommand.答题_二阶_2) { RunAction = action, IsHandwriting = true }; var flow_a_3 = new FlowItem(pen, FlowCommand.答题_二阶_3) { RunAction = action }; //var flow_a_4 = new FlowItem(pen, FlowCommand.答题_二阶_4) { RunAction = action }; flow_a_1.AddFlow(flow_a_2); flow_a_2.AddFlow(flow_a_3); flow_a_3.AddFlow(flow_a_1); //flow_a_4.AddFlow(flow_a_2); //二阶认知理由反馈、三阶和四阶试题的第1阶-课堂实时反馈做题页面 var flow_b_1 = new FlowItem(pen, FlowCommand.答题_多阶_1) { RunAction = action, IsHandwriting = true }; var flow_b_2 = new FlowItem(pen, FlowCommand.答题_多阶_2) { RunAction = action, IsHandwriting = true }; flow_b_1.AddFlow(flow_b_2); flow_b_2.AddFlow(flow_b_1); //自判 var flow_s_1 = new FlowItem(pen, FlowCommand.自判) { RunAction = action }; flow_s_1.AddFlow(flow_s_1); flow.AddFlow(flow_a_1); flow.AddFlow(flow_b_1); flow.AddFlow(flow_s_1); var nextFlow = flow.Run(); if (nextFlow != null) { UpdateFlow(nextFlow); } } } }
/// <summary> /// 将FlowItem加载到DataGridView中 /// </summary> private void LoadFlowItemList() { FlowControl flowControl = FlowControl.Instance; flowGridView.ColumnCount = COLUMN_ITEM_MAX; //flowGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy; //flowGridView.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; //flowGridView.ColumnHeadersDefaultCellStyle.Font = // new Font(flowGridView.Font, FontStyle.Bold); flowGridView.Columns[COLUMN_ITEM_COUNT].Name = "测试项"; flowGridView.Columns[COLUMN_ITEM_NAME].Name = "测试项名称"; flowGridView.Columns[COLUMN_ITEM_CONTENT].Name = "测试内容"; flowGridView.Columns[COLUMN_ITEM_SPEC].Name = "规格值"; flowGridView.Columns[COLUMN_ITEM_VALUE].Name = "实测值"; flowGridView.Columns[COLUMN_ITEM_RESULT].Name = "结果"; flowGridView.Columns[COLUMN_ITEM_STATUS].Name = "状态"; flowGridView.Columns[COLUMN_ITEM_DURATION].Name = "测试时间"; for (int i = 0; i < COLUMN_ITEM_MAX; i++) { flowGridView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } flowGridView.Columns[COLUMN_ITEM_COUNT].DefaultCellStyle = flowGridView.ColumnHeadersDefaultCellStyle; flowGridView.Columns[COLUMN_ITEM_NAME].DefaultCellStyle = flowGridView.ColumnHeadersDefaultCellStyle; flowGridView.Columns[COLUMN_ITEM_CONTENT].DefaultCellStyle = flowGridView.ColumnHeadersDefaultCellStyle; flowGridView.Columns[COLUMN_ITEM_SPEC].DefaultCellStyle = flowGridView.ColumnHeadersDefaultCellStyle; if (flowControl.FlowItemList != null) { int itemCount = 1; for (int i = 0; i < flowControl.FlowItemList.Count; i++) { FlowItem flowItem = flowControl.FlowItemList[i]; flowItem.RowIndex = flowGridView.RowCount; if (!flowItem.Item.Property.Hide && !flowItem.Item.Property.Disable) { if (flowItem.SpecValueList != null) { foreach (SpecValue specValue in flowItem.SpecValueList) { if (!specValue.Disable) { List <string> rowValueList = new List <string>(); rowValueList.Add(Convert.ToString(itemCount)); rowValueList.Add(flowItem.Name); rowValueList.Add(specValue.SpecDescription); rowValueList.Add(specValue.Spec); rowValueList.Add(string.IsNullOrEmpty(specValue.MeasuredValue) ? "" : specValue.MeasuredValue); rowValueList.Add(string.IsNullOrEmpty(specValue.JudgmentResult) ? "" : specValue.JudgmentResult); rowValueList.Add(""); rowValueList.Add(""); flowGridView.Rows.Add(rowValueList.ToArray()); } } if (flowGridView.RowCount - flowItem.RowIndex > 1) { flowGridView.Merge(flowItem.RowIndex, COLUMN_ITEM_COUNT, flowGridView.RowCount - flowItem.RowIndex, 1); flowGridView.Merge(flowItem.RowIndex, COLUMN_ITEM_NAME, flowGridView.RowCount - flowItem.RowIndex, 1); flowGridView.Merge(flowItem.RowIndex, COLUMN_ITEM_STATUS, flowGridView.RowCount - flowItem.RowIndex, 1); flowGridView.Merge(flowItem.RowIndex, COLUMN_ITEM_DURATION, flowGridView.RowCount - flowItem.RowIndex, 1); } } else { List <string> rowValueList = new List <string>(); rowValueList.Add(Convert.ToString(itemCount)); rowValueList.Add(flowItem.Name); rowValueList.Add(""); rowValueList.Add(""); rowValueList.Add(""); rowValueList.Add(""); rowValueList.Add(""); rowValueList.Add(""); flowGridView.Rows.Add(rowValueList.ToArray()); } itemCount++; } } } }