/// <summary>
        /// 加载数据,返回类型及显示名称
        /// </summary>
        /// <param name="WorkflowCode"></param>
        /// <param name="ActivityCode"></param>
        /// <param name="ItemName"></param>
        /// <param name="Value"></param>
        /// <returns></returns>
        public JsonResult Load(string WorkflowCode, string ActivityCode, string ItemName, string Value)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult(false);
                BizObjectSchema Schema = null;
                OThinker.H3.WorkflowTemplate.WorkflowClause Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode);
                if (Clause != null)
                {
                    Schema = this.Engine.BizObjectManager.GetPublishedSchema(Clause.BizSchemaCode);
                }
                else
                {
                    result.Message = "Simulation.EditSimulation_Mssg3";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }


                PropertySchema PropertySchema = null;
                if (Schema != null)
                {
                    PropertySchema = Schema.GetProperty(ItemName);
                }
                else
                {
                    result.Message = "Simulation.EditSimulation_Mssg3";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                //string[] values = null;
                //try
                //{
                //    values = (string[])JsonConvert.DeserializeObject(Value, typeof(string[]));
                //}
                //catch { }
                var DisplayName = "";
                var LogicTypeDisplay = "";
                var LogicType = "";

                if (PropertySchema != null)
                {
                    DisplayName = PropertySchema.DisplayName;
                    LogicTypeDisplay = OThinker.H3.Data.DataLogicTypeConvertor.ToLogicTypeName(PropertySchema.LogicType);
                    LogicType = PropertySchema.LogicType.ToString();
                    //前端处理
                    ////选择参与者
                    //if (PropertySchema.LogicType == OThinker.H3.Data.DataLogicType.SingleParticipant || this.PropertySchema.LogicType == OThinker.H3.Data.DataLogicType.MultiParticipant)
                    //{
                    //    usParticipants.Visible = true;
                    //    usParticipants.SelectedUsers = values;
                    //}
                    //逻辑型
                    //else if (this.PropertySchema.LogicType == OThinker.H3.Data.DataLogicType.Bool)
                    //{
                    //    chk.Visible = true;
                    //    if (values != null && values.Length > 0 && (values[0] + string.Empty).ToLower() == "true")
                    //    {
                    //        chk.Checked = true;
                    //    }
                    //}
                    //逻辑型
                    //else if (this.PropertySchema.LogicType == OThinker.H3.Data.DataLogicType.DateTime)
                    //{
                    //    st.Visible = true;
                    //    DateTime time = DateTime.Now;
                    //    if (values != null && values.Length > 0 && DateTime.TryParse(values[0], out time))
                    //    {
                    //        st.TimeValue = time;
                    //    }
                    //}
                    //else
                    //{
                    //    txtValues.Visible = true;
                    //    if (values != null && values.Length > 0)
                    //    {
                    //        txtValues.Text = string.Join(";", values);
                    //    }
                    //}
                }
                else if (!string.IsNullOrEmpty(ActivityCode))
                {
                    OThinker.H3.WorkflowTemplate.WorkflowDocument document = this.Engine.WorkflowManager.GetPublishedTemplate(WorkflowCode, this.Engine.WorkflowManager.GetWorkflowDefaultVersion(WorkflowCode));
                    foreach (OThinker.H3.WorkflowTemplate.Activity activity in document.Activities)
                    {
                        if (activity.ActivityCode == ActivityCode)
                        {
                            DisplayName = activity.DisplayName;
                            LogicType = string.Empty;
                        }
                    }
                }
                else
                {
                    result.Message = "Simulation.EditSimulationData_Mssg1";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                result.Success = true;
                result.Extend = new { DisplayName = DisplayName, LogicTypeDisplay = LogicTypeDisplay, LogicType = LogicType };
                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }
Пример #2
0
        public JsonResult LoadSimulation(string simulationID, string workflowCode)
        {
            return(ExecuteFunctionRun(() => {
                EditSimulationViewModel model = new EditSimulationViewModel();
                ActionResult result = new ActionResult(true);

                DataModel.BizObjectSchema Schema = null;
                OThinker.H3.WorkflowTemplate.WorkflowClause Clause = null;
                InstanceSimulation Simulation = null;

                if (!string.IsNullOrEmpty(workflowCode))
                {
                    Clause = this.Engine.WorkflowManager.GetClause(workflowCode);
                }
                if (Clause != null)
                {
                    Schema = this.Engine.BizObjectManager.GetPublishedSchema(Clause.BizSchemaCode);
                }

                if (Schema == null)
                {
                    result.Success = false;
                    result.Message = "EditBizObjectSchema.Msg0";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                WorkflowTemplate.PublishedWorkflowTemplate tempalte = this.Engine.WorkflowManager.GetDefaultWorkflow(workflowCode);
                if (tempalte == null)
                {
                    result.Success = false;
                    result.Message = "StartInstance.StartInstance_Msg1";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }


                if (string.IsNullOrEmpty(simulationID))
                {
                    model.WorkflowCode = workflowCode;
                    model.WorkflowName = this.Engine.WorkflowManager.GetClauseDisplayName(workflowCode);

                    ShowDataItems(workflowCode, Schema, null, null, model);
                }
                else
                {
                    Simulation = this.Engine.SimulationManager.GetSimulation(simulationID);
                    if (Simulation == null)
                    {
                        result.Success = false;
                        result.Message = "Simulation.SimulationDetail_Mssg1";
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        if (Clause != null)
                        {
                            model.WorkflowName = Clause.WorkflowName + "[" + workflowCode + "]";
                        }

                        model.UseCaseName = Simulation.InstanceName;
                        model.Creator = JsonConvert.SerializeObject(Simulation.Originators);

                        //DataItems
                        ShowDataItems(workflowCode, Schema, Simulation, null, model);
                    }
                }
                result.Extend = model;
                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }
Пример #3
0
        public JsonResult Save(string SimulationListID, string SimulationListCode, string WorkflowCode, string SimulationIDS)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult(false, "");
                InstanceSimulationList SimulationList = null;
                OThinker.H3.WorkflowTemplate.WorkflowClause Clause = null;

                Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode);

                if (string.IsNullOrEmpty(SimulationListID))
                {
                    SimulationList = new InstanceSimulationList()
                    {
                        WorkflowCode = WorkflowCode
                    };
                }
                else
                {
                    SimulationList = this.Engine.SimulationManager.GetSimulationList(SimulationListID);
                }

                if (SimulationList == null)
                {
                    //编辑的模拟不存在
                    result.Message = "Simulation.SimulationDetail_Mssg4";

                    return Json(result);
                }
                //编码必须以字母开始
                //System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^[A-Za-z][A-Za-z0-9_]*$");
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^[a-zA-Z\\u4e00-\\u9fa5][0-9a-zA-Z\\u4e00-\\u9fa5_]*$");
                if (!regex.Match(SimulationListCode).Success)
                {
                    result.Message = "Simulation.ObjectSchemaProperty_Mssg4";
                    return Json(result);
                }


                SimulationList.Simulations = (SimulationIDS + string.Empty).Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                SimulationList.SimulationListCode = SimulationListCode;
                SimulationList.WorkflowCode = WorkflowCode;

                if (string.IsNullOrEmpty(SimulationList.SimulationListCode))
                {
                    //编辑的模拟不存在
                    // WriteResponse(false, this.PortalResource.GetString("SimulationDetail_Mssg3"));
                    result.Message = "Simulation.SimulationDetail_Mssg3";
                    return Json(result);
                }
                if (SimulationList.Simulations == null || SimulationList.Simulations.Length < 1)
                {
                    //编辑的模拟不存在

                    result.Message = "Simulation.SimulationDetail_Mssg5";
                    return Json(result);
                }

                if (!string.IsNullOrEmpty(SimulationListID))
                {
                    result.Success = this.Engine.SimulationManager.UpdateSimulationList(SimulationList);
                }
                else
                {
                    result.Success = this.Engine.SimulationManager.AddSimulationList(SimulationList);
                }
                if (result.Success)
                {
                    result.Message = "msgGlobalString.SaveSucced";
                }
                else
                {
                    result.Message = "msgGlobalString.SaveFailed";
                }
                return Json(result);
            }));
        }
Пример #4
0
        public JsonResult ImportSimulation(string SquenceNo, string WorkflowCode)
        {
            return(ExecuteFunctionRun(() => {
                ActionResult result = new ActionResult(false, "");

                DataModel.BizObjectSchema Schema = null;
                OThinker.H3.WorkflowTemplate.WorkflowClause Clause = null;

                EditSimulationViewModel model = new EditSimulationViewModel();
                model.WorkflowCode = WorkflowCode;
                if (!string.IsNullOrEmpty(WorkflowCode))
                {
                    Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode);
                }
                if (Clause != null)
                {
                    Schema = this.Engine.BizObjectManager.GetPublishedSchema(Clause.BizSchemaCode);
                }

                string[] conditions = null;
                string seqCondition = OThinker.H3.Instance.InstanceContext.TableName + "." + OThinker.H3.Instance.InstanceContext.PropertyName_SequenceNo + " ='" + SquenceNo + "'";
                conditions = OThinker.Data.ArrayConvertor <string> .AddToArray(conditions, seqCondition);
                DataTable dt = this.Engine.Query.QueryInstance(conditions, 0, 1);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string InstanceId = dt.Rows[0][1] + string.Empty;
                    InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(InstanceId);
                    if (context != null)
                    {
                        if (context.WorkflowCode == WorkflowCode)
                        {
                            InstanceData dataitems = new InstanceData(this.Engine, InstanceId, this.UserValidator.UserID);
                            Dictionary <string, object> valuetable = dataitems.BizObject.ValueTable;

                            OThinker.Organization.User Originator = this.Engine.Organization.GetUnit(context.Originator) as OThinker.Organization.User;
                            if (Originator != null)
                            {
                                model.Originator = new { ObjectID = Originator.ObjectID, Name = Originator.Name };
                            }


                            string[] workitemIds = this.Engine.Query.QueryWorkItems(InstanceId, -1, WorkItem.WorkItemType.Unspecified, WorkItem.WorkItemState.Unspecified, OThinker.Data.BoolMatchValue.Unspecified);
                            if (workitemIds != null || workitemIds.Length > 0)
                            {
                                foreach (string workitemId in workitemIds)
                                {
                                    WorkItem.WorkItem workItem = this.Engine.WorkItemManager.GetWorkItem(workitemId);
                                    if (!valuetable.ContainsKey(workItem.ActivityCode))
                                    {
                                        valuetable.Add(workItem.ActivityCode, workItem.Participant);
                                    }
                                }
                            }

                            model.WorkflowName = context.InstanceName;
                            ShowDataItems(WorkflowCode, Schema, null, valuetable, model);
                        }
                        else
                        {
                            result.Message = "Simulation.EditSimulation_Mssg1";
                            return Json(result, JsonRequestBehavior.AllowGet);
                        }
                    }
                }
                else
                {
                    result.Message = "Simulation.EditSimulation_Mssg2";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                result.Success = true;
                result.Extend = model;
                result.Message = "msgGlobalString.ImportSucceed";
                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }
Пример #5
0
        public JsonResult Load(string SimulationListID, string WorkflowCode)
        {
            return(ExecuteFunctionRun(() => {
                ActionResult result = new ActionResult(false, "");

                InstanceSimulationList SimulationList = null;
                OThinker.H3.WorkflowTemplate.WorkflowClause Clause = null;

                Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode);
                SimulationList = this.Engine.SimulationManager.GetSimulationList(SimulationListID);

                var WorkflowName = "";
                var SimulationListCode = "";
                string simulation = string.Empty;      //当前测试集的测试用例ID
                var Simulations = new List <object>(); //当前流程测试用例集合

                //ID非空为编辑模式
                if (!string.IsNullOrEmpty(SimulationListID))
                {
                    if (SimulationList != null)
                    {
                        if (Clause != null)
                        {
                            WorkflowName = Clause.WorkflowName + "[" + WorkflowCode + "]";
                        }

                        SimulationListCode = SimulationList.SimulationListCode;

                        if (SimulationList.Simulations != null && SimulationList.Simulations.Length > 0)
                        {
                            foreach (string id in SimulationList.Simulations)
                            {
                                simulation += id + ";";
                            }
                            simulation = simulation.TrimEnd(';');
                        }
                        // ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "simulation", "var simulation=\"" + simulation + "\";", true);
                    }
                    else
                    {
                        result.Message = "Simulation.SimulationDetail_Mssg1";
                        //打开失败
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                }
                //ID为空,为新增模式
                else
                {
                    WorkflowName = this.Engine.WorkflowManager.GetClauseDisplayName(WorkflowCode);
                }

                InstanceSimulation[] SimulationsObject = this.Engine.SimulationManager.GetSimulationByWorkflow(WorkflowCode);
                if (SimulationsObject != null && SimulationsObject.Length > 0)
                {
                    List <object> lstSimulations = new List <object>();
                    foreach (InstanceSimulation sim in SimulationsObject)
                    {
                        lstSimulations.Add(new
                        {
                            ObjectID = sim.ObjectID,
                            InstanceName = sim.InstanceName
                        });
                    }
                    Simulations = lstSimulations;
                }

                var returnObject = new
                {
                    WorkflowName = WorkflowName,
                    SimulationListCode = SimulationListCode,
                    SimulationIDS = simulation,
                    Simulations = CreateLigerUIGridData(Simulations.ToArray())
                };

                result.Success = true;
                result.Message = "";
                result.Extend = returnObject;

                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }