public void TerminateWorkflow(string tableName, string tableKey) { DynEntity dynEntity = null; dynEntity = GatewayFactory.Default.Find(tableName, Convert.ToInt32(tableKey)); dynEntity["Comment"] = "已通过"; GatewayFactory.Default.Save(dynEntity); }
public void AppRelationModule(int moduleID) { DynEntity applicationModule = new DynEntity("ApplicationModule"); applicationModule["ApplicationID"] = SelectedApplication.ApplicationID; applicationModule["ModuleID"] = moduleID; SystemService.AddDynEntity(applicationModule); }
public bool EditNamespace() { DynEntity namespaceDynEntity = SystemService.GetDynEntityByID("Namespace", Namespace.NamespaceID); namespaceDynEntity["NamespaceName"] = Namespace.NamespaceName; namespaceDynEntity["Description"] = Namespace.Description; SystemService.ModifyDynEntity(namespaceDynEntity); return(true); }
private int GetNextID(string typeName) { DynEntity dbEntity = GatewayFactory.Default.Find("ObjType", _.P("ObjType", "Name") == typeName.Trim()); int nextID = (int)dbEntity["NextID"]; dbEntity["NextID"] = nextID + 1; GatewayFactory.Default.Save(dbEntity); return(nextID); }
public DesignApplication(DynEntity application) { if (application != null && application.EntityType.Name == "Application") { this.ApplicationID = (int)application["ApplicationID"]; this.ApplicationName = application["ApplicationName"] as string; this.Description = application["Description"] as string; } }
public ApplicationModule(DynEntity module) { if (module != null && module.EntityType.Name == "Module") { this.ModuleID = (int)module["ModuleID"]; this.ModuleName = module["ModuleName"] as string; this.Description = module["Description"] as string; } }
public int GetNextID(string typeName) { Check.Require(!string.IsNullOrEmpty(typeName), "获取NextID的对象名称不允许为空!"); DynEntity dbEntity = GatewayFactory.Default.Find("ObjType", _.P("ObjType", "Name") == typeName.Trim()); int nextID = (int)dbEntity["NextID"]; dbEntity["NextID"] = nextID + 1; GatewayFactory.Default.Save(dbEntity); return(nextID); }
public DynObject GetRelationFormByID(int relationFormID) { DynObject result = null; DynEntity relationForm = GatewayFactory.Default.Find("RelationForm", relationFormID); if (relationForm != null) { result = DynObjectTransverter.JsonToDynObject(relationForm["Model"] as string); } return(result); }
public DynObject GetDictFormByID(int dictFormID) { DynObject result = null; DynEntity dictForm = GatewayFactory.Default.Find("DictForm", dictFormID); if (dictForm != null) { result = DynObjectTransverter.JsonToDynObject(dictForm["Model"] as string); } return(result); }
public DynObject GetBillListFormByID(int billListFormID) { DynObject result = null; DynEntity billListForm = GatewayFactory.Default.Find("BillListForm", billListFormID); if (billListForm != null) { result = DynObjectTransverter.JsonToDynObject(billListForm["Model"] as string); } return(result); }
public void AddTreeForm(DynObject treeForm) { Check.Require(treeForm != null, "TreeForm对象不允许为空!"); DynEntity treeFormEntity = new DynEntity("TreeForm"); treeFormEntity["TreeFormID"] = treeForm["TreeFormID"]; treeFormEntity["TreeFormName"] = treeForm["TreeFormName"]; treeFormEntity["ModelType"] = treeForm["ModelType"]; treeFormEntity["ModelTypeName"] = treeForm["ModelTypeName"]; treeFormEntity["ReferTypes"] = treeForm["ReferTypes"]; treeFormEntity["ColumnCount"] = treeForm["ColumnCount"]; treeFormEntity["Comment"] = treeForm["Comment"]; treeFormEntity["Model"] = DynObjectTransverter.DynObjectToJson(treeForm); GatewayFactory.Default.Save(treeFormEntity); }
private void workflowAborted(WorkflowApplicationAbortedEventArgs e) { string objType = ExecuteScalar("select [ObjType] from [WorkflowInstance] where [InstanceGUID] = '" + e.InstanceId + "'"); string objID = ExecuteScalar("select [ObjID] from [WorkflowInstance] where [InstanceGUID] = '" + e.InstanceId + "'"); DynEntity log = new DynEntity("Log"); log["LogID"] = GetNextID("Log"); log["LogType"] = "工作流失败"; log["ObjType"] = objType; log["ObjID"] = objID; log["Comment"] = e.Reason.Message + "实例为:" + e.InstanceId; log["OperateTime"] = DateTime.Now; log["OperaterName"] = "system"; log["OperaterID"] = 0; GatewayFactory.Default.Save(log); }
public void ModifyDictForm(DynObject dictForm) { Check.Require(dictForm != null, "DictForm对象不允许为空!"); DynEntity dictFormEntity = GatewayFactory.Default.Find("DictForm", dictForm["DictFormID"]); Check.Require(dictFormEntity != null, "DictForm在数据库中不存在无法修改!"); dictFormEntity["DictFormName"] = dictForm["DictFormName"]; dictFormEntity["ModelType"] = dictForm["ModelType"]; dictFormEntity["ModelTypeName"] = dictForm["ModelTypeName"]; dictFormEntity["ReferTypes"] = dictForm["ReferTypes"]; dictFormEntity["ColumnCount"] = dictForm["ColumnCount"]; dictFormEntity["Comment"] = dictForm["Comment"]; dictFormEntity["Model"] = DynObjectTransverter.DynObjectToJson(dictForm); //dictFormEntity["Script"] = GenerateDictFormJsCode(dictForm); GatewayFactory.Default.Save(dictFormEntity); }
public void AddRelationForm(DynObject relationForm) { Check.Require(relationForm != null, "RelationForm对象不允许为空!"); DynEntity relationFormEntity = new DynEntity("RelationForm"); relationFormEntity["RelationFormID"] = relationForm["RelationFormID"]; relationFormEntity["RelationFormName"] = relationForm["RelationFormName"]; relationFormEntity["RelationType"] = relationForm["RelationType"]; relationFormEntity["MasterType"] = relationForm["MasterType"]; relationFormEntity["SlaveType"] = relationForm["SlaveType"]; relationFormEntity["MasterTypeName"] = relationForm["MasterTypeName"]; relationFormEntity["SlaveTypeName"] = relationForm["SlaveTypeName"]; relationFormEntity["ColumnCount"] = relationForm["ColumnCount"]; relationFormEntity["Comment"] = relationForm["Comment"]; relationFormEntity["Model"] = DynObjectTransverter.DynObjectToJson(relationForm); GatewayFactory.Default.Save(relationFormEntity); }
public void AddBillListForm(DynObject billListForm) { Check.Require(billListForm != null, "BillListForm对象不允许为空!"); DynEntity billListFormEntity = new DynEntity("BillListForm"); billListFormEntity["BillListFormID"] = billListForm["BillListFormID"]; billListFormEntity["BillListFormName"] = billListForm["BillListFormName"]; billListFormEntity["MasterType"] = billListForm["MasterType"]; billListFormEntity["DetailType"] = billListForm["DetailType"]; billListFormEntity["ReferTypes"] = billListForm["ReferTypes"]; billListFormEntity["BillName"] = billListForm["BillName"]; billListFormEntity["DetailMainReferType"] = billListForm["DetailMainReferType"]; billListFormEntity["DetailMainReferName"] = billListForm["DetailMainReferName"]; billListFormEntity["Comment"] = billListForm["Comment"]; billListFormEntity["Model"] = DynObjectTransverter.DynObjectToJson(billListForm); GatewayFactory.Default.Save(billListFormEntity); }
public bool EditModule() { DynEntity moduleDynEntity = SystemService.GetDynEntityByID("Module", Module.ModuleID); moduleDynEntity["ModuleID"] = Module.ModuleID; moduleDynEntity["ModuleName"] = Module.ModuleName; moduleDynEntity["Description"] = Module.Description; try { SystemService.ModifyDynEntity(moduleDynEntity); return(true); } catch (Exception ex) { throw (ex); } }
public bool EditDesignApplication() { DynEntity applicationDynEntity = SystemService.GetDynEntityByID("Application", DesignApplication.ApplicationID); applicationDynEntity["ApplicationID"] = DesignApplication.ApplicationID; applicationDynEntity["ApplicationName"] = DesignApplication.ApplicationName; applicationDynEntity["Description"] = DesignApplication.Description; try { SystemService.ModifyDynEntity(applicationDynEntity); return(true); } catch (Exception) { return(false); } }
//删除已经上传的文档 public void DeleteUploadFile(int uploadFileID) { DynEntity uploadFile = GatewayFactory.Default.Find("UploadFile", uploadFileID); if (uploadFile != null) { string sqlString = "select UploadFileID from [UploadFile] where UploadFile.ServerFileName = '" + uploadFile["ServerFileName"] + "'"; DataTable dataTable = GatewayFactory.Default.Db.ExecuteDataSet(CommandType.Text, sqlString).Tables[0]; if (dataTable.Rows.Count == 1) { GatewayFactory.Default.Delete("UploadFile", uploadFileID); File.Delete(uploadFile["ServerFilePath"] + "\\" + uploadFile["ServerFileName"]); } else { GatewayFactory.Default.Delete("UploadFile", uploadFileID); } } }
public void ModifyBillListForm(DynObject billListForm) { Check.Require(billListForm != null, "BillListForm对象不允许为空!"); DynEntity billListFormEntity = GatewayFactory.Default.Find("BillListForm", billListForm["BillListFormID"]); Check.Require(billListFormEntity != null, "BillListForm在数据库中不存在无法修改!"); billListFormEntity["BillListFormName"] = billListForm["BillListFormName"]; billListFormEntity["MasterType"] = billListForm["MasterType"]; billListFormEntity["DetailType"] = billListForm["DetailType"]; billListFormEntity["ReferTypes"] = billListForm["ReferTypes"]; billListFormEntity["BillName"] = billListForm["BillName"]; billListFormEntity["DetailMainReferType"] = billListForm["DetailMainReferType"]; billListFormEntity["DetailMainReferName"] = billListForm["DetailMainReferName"]; billListFormEntity["Comment"] = billListForm["Comment"]; billListFormEntity["Model"] = DynObjectTransverter.DynObjectToJson(billListForm); //billListFormEntity["Script"] = GenerateBillListFormJsCode(billListForm); GatewayFactory.Default.Save(billListFormEntity); }
public void ModifyRelationForm(DynObject relationForm) { Check.Require(relationForm != null, "RelationForm对象不允许为空!"); DynEntity relationFormEntity = GatewayFactory.Default.Find("RelationForm", relationForm["RelationFormID"]); Check.Require(relationFormEntity != null, "RelationForm在数据库中不存在无法修改!"); relationFormEntity["RelationFormName"] = relationForm["RelationFormName"]; relationFormEntity["RelationType"] = relationForm["RelationType"]; relationFormEntity["MasterType"] = relationForm["MasterType"]; relationFormEntity["SlaveType"] = relationForm["SlaveType"]; relationFormEntity["MasterTypeName"] = relationForm["MasterTypeName"]; relationFormEntity["SlaveTypeName"] = relationForm["SlaveTypeName"]; relationFormEntity["ColumnCount"] = relationForm["ColumnCount"]; relationFormEntity["Comment"] = relationForm["Comment"]; relationFormEntity["Model"] = DynObjectTransverter.DynObjectToJson(relationForm); //relationFormEntity["Script"] = GenerateRelationFormJsCode(relationForm); GatewayFactory.Default.Save(relationFormEntity); }
public void Cancel() { if (DesignClass.ClassID > 0) { DynEntity classEntity = ApplicationDesignService.GetClassEntity(DesignClass.ClassID); string dynAtrributeStr = classEntity["Attributes"] as string; List <DynObject> dynAttributes = DynObjectTransverter.JsonToDynObjectList(dynAtrributeStr); foreach (var item in dynAttributes) { switch (item.DynClass.Name) { case "Persistable": DesignClass.IsPersistable = true; break; } } DesignClass.DisplayName = classEntity["Description"] as string; DesignClass.Description = classEntity["DisplayName"] as string; DesignClass.NamespaceID = Convert.ToInt32(classEntity["NamespaceID"]); DesignerViewModel.CurrentDesignClass = DesignClass; } }
private UnhandledExceptionAction workflowUnhandledException(WorkflowApplicationUnhandledExceptionEventArgs e) { string objType = ExecuteScalar("select [ObjType] from [WorkflowInstance] where [InstanceGUID] = '" + e.InstanceId + "'"); string objID = ExecuteScalar("select [ObjID] from [WorkflowInstance] where [InstanceGUID] = '" + e.InstanceId + "'"); DynEntity log = new DynEntity("Log"); log["LogID"] = GetNextID("Log"); log["LogName"] = e.ExceptionSource.DisplayName; log["LogType"] = "工作流异常"; log["ObjType"] = objType; log["ObjID"] = objID; log["Comment"] = e.UnhandledException.Message + "实例为:" + e.InstanceId; log["OperateTime"] = DateTime.Now; log["OperaterName"] = e.ExceptionSource.Id; log["OperaterID"] = 0; ////将工作流对应的对象状态置为异常终止,可以重新启动 //string updateSql = "update " + objType + "set State = '异常终止' where " + objType + "ID = " + objID; //ExcuteNoneReturnQuery(updateSql); GatewayFactory.Default.Save(log); return(UnhandledExceptionAction.Cancel); }
public string GetBillNO(string billType) { Check.Require(!string.IsNullOrEmpty(billType), "获取编码的单据类型不允许为空!"); DynEntity dbEntity = GatewayFactory.Default.Find("Bill", _.P("Bill", "BillType") == billType.Trim()); string prefix = dbEntity["Prefix"].ToString(); string availableBillNO = dbEntity["AvailableBillNO"].ToString(); DateTime lastDate = (DateTime)dbEntity["LastDate"]; if (lastDate.Date == DateTime.Now.Date) { availableBillNO = availableBillNO == "" ? "1" : availableBillNO; } else { dbEntity["LastDate"] = DateTime.Now.Date; availableBillNO = "1"; } dbEntity["AvailableBillNO"] = int.Parse(availableBillNO) + 1; GatewayFactory.Default.Save(dbEntity); return(String.Concat(prefix, DateTime.Now.ToString("yyyyMMdd"), availableBillNO.PadLeft(4, '0'))); }
public bool AddDesignApplication() { DynEntity applicationDynEntity = new DynEntity("Application"); DesignApplication.ApplicationID = SystemService.GetNextID("Application"); applicationDynEntity["ApplicationID"] = DesignApplication.ApplicationID; applicationDynEntity["ApplicationName"] = DesignApplication.ApplicationName; applicationDynEntity["Description"] = DesignApplication.Description; //applicationDynEntity["LocalVersion"] = 1; //applicationDynEntity["CascadeVersion"] = 1; //applicationDynEntity["ReleaseVersion"] = "1"; try { SystemService.AddDynEntity(applicationDynEntity); ApplicationManagerViewModel.ApplicationSource.Add(DesignApplication); return(true); } catch (Exception ex) { throw(ex); } }
public bool AddModule() { DynEntity moduleDynEntity = new DynEntity("Module"); Module.ModuleID = SystemService.GetNextID("Module"); moduleDynEntity["ModuleID"] = Module.ModuleID; moduleDynEntity["ModuleName"] = Module.ModuleName; moduleDynEntity["Description"] = Module.Description; //moduleDynEntity["LocalVersion"] = 1; //moduleDynEntity["CascadeVersion"] = 1; //moduleDynEntity["ReleaseVersion"] = "1"; try { SystemService.AddDynEntity(moduleDynEntity); ModuleManagerViewModel.ModuleSouce.Add(Module); return(true); } catch (Exception) { return(false); } }
public bool AddNamespace() { DynEntity namespaceDynEntity = new DynEntity("Namespace"); Namespace.NamespaceID = SystemService.GetNextID("Namespace"); namespaceDynEntity["NamespaceID"] = Namespace.NamespaceID; namespaceDynEntity["NamespaceName"] = Namespace.NamespaceName; namespaceDynEntity["Description"] = Namespace.Description; try { SystemService.AddDynEntity(namespaceDynEntity); NamespaceManagerViewModel.NamespaceSource.Add(Namespace); if (!NamespaceManagerViewModel.NamespaceSource.Contains(Namespace)) { ApplicationDesignCache.NamespaceSource.Add(Namespace); } return(true); } catch (Exception ex) { throw (ex); } }
private void workflowCompleted(WorkflowApplicationCompletedEventArgs e) { DynEntity workflowInstance = GatewayFactory.Default.Find("WorkflowInstance", _.P("WorkflowInstance", "InstanceGUID") == e.InstanceId); DynEntity log = new DynEntity("Log"); log["LogID"] = GetNextID("Log"); log["LogType"] = "工作流完成"; log["ObjType"] = workflowInstance["ObjType"]; log["ObjID"] = workflowInstance["ObjID"]; log["Comment"] = "工作流执行完成实例为:" + e.InstanceId + "完成状态为:" + e.CompletionState.ToString(); //if (e.TerminationException != null) //{ // log["Comment"] = "工作流执行完成实例为:" + e.InstanceId + "完成状态为:" + e.CompletionState.ToString() + "消息:" + e.TerminationException.Message; //} //else //{ // log["Comment"] = "工作流执行完成实例为:" + e.InstanceId + "完成状态为:" + e.CompletionState.ToString(); //} log["OperateTime"] = DateTime.Now; log["OperaterName"] = "system"; log["OperaterID"] = 0; if (e.CompletionState == ActivityInstanceState.Faulted) { workflowInstance["State"] = "已终止"; } else { workflowInstance["State"] = "已完成"; } using (TransactionScope trans = new TransactionScope()) { GatewayFactory.Default.Save(log); GatewayFactory.Default.Save(workflowInstance); trans.Complete(); } }
protected override void Execute(NativeActivityContext context) { DesignService designService = new DesignService(); //启动事务 using (TransactionScope trans = new TransactionScope()) { //添加工作流活动实例 DynEntity workflowfActivityInstance = new DynEntity("WorkflowActivityInstance"); workflowfActivityInstance["WorkflowActivityInstanceID"] = designService.GetNextID("WorkflowActivityInstance"); workflowfActivityInstance["WorkflowInstanceID"] = context.GetValue(WorkflowInstanceID); workflowfActivityInstance["WorkflowActivityID"] = WorkflowActivityID; workflowfActivityInstance["WorkflowActivityInstanceName"] = DisplayName; workflowfActivityInstance["State"] = "已退回"; workflowfActivityInstance["StartTime"] = DateTime.Now; designService.AddDynEntity(workflowfActivityInstance); //获取工作流实例 DynEntity workflowInstance = designService.GetDynEntityByID("WorkflowInstance", context.GetValue(WorkflowInstanceID)); int workflowID; if (workflowInstance != null) { workflowID = Convert.ToInt32(workflowInstance["WorkflowID"]); } else { throw new ApplicationException(string.Format("{0}实例下的活动{1},根据工作流实例ID获取工作流实例不正常", context.GetValue(WorkflowInstanceID), DisplayName)); } //添加待做任务清单 DynEntity task = new DynEntity("WorkflowToDoList"); task["WorkflowToDoListID"] = designService.GetNextID("WorkflowToDoList"); task["Type"] = context.GetValue(Type).ToString(); task["Item"] = context.GetValue(Item).ToString(); task["Position"] = context.GetValue(Position).ToString(); task["FirstActor"] = context.GetValue(FirstActor); task["LastActor"] = context.GetValue(LastActor); string command = context.GetValue(Command); Dictionary <string, object> inParams = this.ExchangeParams.Get(context) as Dictionary <string, object>; foreach (string key in inParams.Keys) { if (inParams[key] != null) { command = command.Replace("@" + key + "@", inParams[key].ToString()); } } task["WorkflowToDoListName"] = DisplayName; task["WorkflowID"] = workflowID; task["WorkflowInstanceID"] = context.GetValue(WorkflowInstanceID); task["WorkflowActivityInstanceID"] = workflowfActivityInstance["WorkflowActivityInstanceID"]; task["Expression"] = context.GetValue(Expression); task["BookmarkName"] = workflowfActivityInstance["WorkflowActivityInstanceID"].ToString(); task["Command"] = command; task["Comment"] = context.GetValue(Description); task["State"] = "已退回"; if (inParams.ContainsKey("TableName")) { task["TableName"] = inParams["TableName"].ToString(); } if (inParams.ContainsKey("TableKey")) { task["TableKey"] = inParams["TableKey"].ToString(); } designService.AddDynEntity(task); if (inParams.ContainsKey("TableName") && inParams.ContainsKey("TableKey")) { designService.TerminateWorkflow(inParams["TableName"].ToString(), inParams["TableKey"].ToString()); } workflowInstance["EndTime"] = DateTime.Now; workflowInstance["State"] = "已结束"; designService.ModifyDynEntity(workflowInstance); trans.Complete(); } }
protected override void Execute(NativeActivityContext context) { DesignService designService = new DesignService(); //启动事务 using (TransactionScope trans = new TransactionScope()) { //获取传入的参数集合 Dictionary <string, object> inParams = this.ExchangeParams.Get(context) as Dictionary <string, object>; //添加工作流活动实例 DynEntity workflowfActivityInstance = new DynEntity("WorkflowActivityInstance"); workflowfActivityInstance["WorkflowActivityInstanceID"] = designService.GetNextID("WorkflowActivityInstance"); workflowfActivityInstance["WorkflowInstanceID"] = context.GetValue(WorkflowInstanceID); workflowfActivityInstance["WorkflowActivityID"] = WorkflowActivityID; workflowfActivityInstance["WorkflowActivityInstanceName"] = DisplayName; if (inParams.ContainsKey("ObjType")) { workflowfActivityInstance["ObjType"] = inParams["ObjType"].ToString(); } if (inParams.ContainsKey("ObjID")) { workflowfActivityInstance["ObjID"] = inParams["ObjID"].ToString(); } workflowfActivityInstance["State"] = "正在执行"; workflowfActivityInstance["StartTime"] = DateTime.Now; designService.AddDynEntity(workflowfActivityInstance); //获取工作流实例 DynEntity workflowInstance = designService.GetDynEntityByID("WorkflowInstance", context.GetValue(WorkflowInstanceID)); int workflowID; if (workflowInstance != null) { workflowID = Convert.ToInt32(workflowInstance["WorkflowID"]); } else { throw new ApplicationException(string.Format("{0}实例下的活动{1},根据工作流实例ID获取工作流实例不正常", context.GetValue(WorkflowInstanceID), DisplayName)); } //添加待做任务清单 DynEntity task = new DynEntity("WorkflowToDoList"); task["WorkflowToDoListID"] = designService.GetNextID("WorkflowToDoList"); //task["Actor"] = context.GetValue(Actor); task["WorkflowToDoListName"] = DisplayName; task["WorkflowID"] = workflowID; task["WorkflowInstanceID"] = context.GetValue(WorkflowInstanceID); task["WorkflowActivityInstanceID"] = workflowfActivityInstance["WorkflowActivityInstanceID"]; task["BookmarkName"] = workflowfActivityInstance["WorkflowActivityInstanceID"].ToString(); task["State"] = "待处理"; if (inParams.ContainsKey("ObjType")) { task["ObjType"] = inParams["ObjType"].ToString(); } if (inParams.ContainsKey("ObjID")) { task["ObjID"] = inParams["ObjID"].ToString(); } designService.AddDynEntity(task); context.CreateBookmark(workflowfActivityInstance["WorkflowActivityInstanceID"].ToString(), new BookmarkCallback(BookmarkCallbackMethod)); trans.Complete(); } }
public void ModifyDynEntity(DynEntity dynEntity) { Check.Require(dynEntity != null, "修改的实体不允许为空!"); GatewayFactory.Default.Save(dynEntity, null); }