答:参考下面示例说明。
示例:
(一)依据一个控件值进行筛选 H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); //构建过滤器 H3.Data.Filter.And andMatcher = new H3.Data.Filter.And(); //构造And匹配器 andMatcher.Add(new H3.Data.Filter.ItemMatcher("控件编码",H3.Data.ComparisonOperatorType.Equal,"筛选依据值")); //添加筛选条件 filter.Matcher = andMatcher;
(二)依据多个控件值进行筛选 1.“AND”关键字连接 H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); //构建过滤器 H3.Data.Filter.And andMatcher = new H3.Data.Filter.And(); //构造And匹配器 andMatcher.Add(new H3.Data.Filter.ItemMatcher("控件编码1",H3.Data.ComparisonOperatorType.Equal,"筛选依据值1")); //添加筛选条件 andMatcher.Add(new H3.Data.Filter.ItemMatcher("控件编码2",H3.Data.ComparisonOperatorType.Equal,"筛选依据值2")); //添加筛选条件 filter.Matcher = andMatcher;
2.“OR”关键字连接 H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); //构建过滤器 H3.Data.Filter.Or orMatcher = new H3.Data.Filter.Or(); //构造Or匹配器 orMatcher.Add(new H3.Data.Filter.ItemMatcher("控件编码1",H3.Data.ComparisonOperatorType.Equal,"筛选依据值1")); //添加筛选条件 orMatcher.Add(new H3.Data.Filter.ItemMatcher("控件编码2",H3.Data.ComparisonOperatorType.Equal,"筛选依据值2")); //添加筛选条件 filter.Matcher = orMatcher;
(三)依据字段进行排序 1.正序排序 H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); //构建过滤器 filter.AddSortBy("控件编码1", H3.Data.Filter.SortDirection.Ascending); //添加排序依据
2.倒序排序 H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); //构建过滤器 filter.AddSortBy("控件编码1", H3.Data.Filter.SortDirection.Descending); //添加排序依据
必要说明: (一)匹配器对象 H3.Data.Filter.And 相当于SQL中“AND”关键字 H3.Data.Filter.Or 相当于SQL中“OR”关键字
(二)筛选条件 H3.Data.ComparisonOperatorType.Equal 相当于SQL中“=” H3.Data.ComparisonOperatorType.NotEqual 相当于SQL中“!=” H3.Data.ComparisonOperatorType.Above 相当于SQL中“>” H3.Data.ComparisonOperatorType.NotBelow 相当于SQL中“>=” H3.Data.ComparisonOperatorType.Below 相当于SQL中“<” H3.Data.ComparisonOperatorType.NotAbove 相当于SQL中“<=” |
答:参考下面表格所示。
按钮名称 | ActionName编码 |
暂存 | Save |
提交 | Submit |
删除 | Remove |
撤回 | RetrieveInstance |
同意 | Submit |
不同意 | Reject |
作废 | CancelInstance |
打印 | |
二维码 | ViewQrCode |
全屏 | FullScreen |
关闭 | Close |
编辑 | Edit |
转交 | Forward |
已阅 | Read |
答:创建/更新大批量数据的时候,用commit可以提高效率。
示例:
H3.DataModel.BulkCommit commit = new H3.DataModel.BulkCommit(); |
答:对象子表以子对象数组形式存在,如果需要创建包含子表的对象或修改子表的值,需要构造或获取到子表对象数组,然后将子表对象数组赋值给主表的子表属性。
以下示例代码用于修改订单子表的某一列的值:
protected override void OnSubmit(string actionName,H3.SmartForm.SmartFormPostValue postValue,H3.SmartForm.SubmitSmartFormResponse response) { H3.DataModel.BizObject[] details = (H3.DataModel.BizObject[]) this.Request.BizObject["D00002SalesOrderDetail"]; //获取子表属性并强制转换为对象数组 if(details != null && details.Length > 0) { List < H3.DataModel.BizObject > lstObject = new List<H3.DataModel.BizObject>(); foreach(H3.DataModel.BizObject detail in details) { detail["WaitStockOutQuantity"] = detail["Quantity"];//修改子表列的属性 lstObject.Add(detail); } //将List转成对象数组,并重新赋值给主表 this.Request.BizObject["D00002SalesOrderDetail"] = lstObject.ToArray();
} } |
//获取一个Engine管理对象 H3.IEngine engine = this.Engine; //表单编码 string masterSchemaCode = "D00021testtable"; //表单数据Id string masterBoId = "bbc60153-19b8-4a57-b074-0c5b77367f8d"; //子表控件编码 string childSchemaCode = "D00021F7287906e76734bef8819176bc15a8763"; //Load出要修改数据的主表业务对象 H3.DataModel.BizObject masterBo = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, engine, masterSchemaCode, masterBoId, false); //获取子表结构体对象 H3.DataModel.BizObjectSchema childSchema = masterBo.Schema.GetChildSchema(childSchemaCode); //定义新的子表数据集合 List < H3.DataModel.BizObject > newChildBoList = new List<H3.DataModel.BizObject>(); //获取子表内已有数据 H3.DataModel.BizObject[] childBoArray = (H3.DataModel.BizObject[]) masterBo[childSchemaCode]; if(childBoArray != null && childBoArray.Length > 0) { foreach(H3.DataModel.BizObject itemBo in childBoArray) { //将子表内已有数据循环添加到新的子表数据集合里 newChildBoList.Add(itemBo); } } //new一个子表业务对象,并添加到子表数据第一行 H3.DataModel.BizObject childBo1 = new H3.DataModel.BizObject(engine, childSchema, H3.Organization.User.SystemUserId); childBo1["F0000002"] = "xxxxx"; newChildBoList.Insert(0, childBo1); //new一个子表业务对象,并添加到子表数据最后一行 H3.DataModel.BizObject childBo2 = new H3.DataModel.BizObject(engine, childSchema, H3.Organization.User.SystemUserId); childBo2["F0000002"] = "yyyyyy"; newChildBoList.Add(childBo2); //将新的子表数据集合赋值到子表控件 masterBo[childSchemaCode] = newChildBoList.ToArray(); //修改主表业务对象,系统会自动识别出上面子表数据被修改了,执行完Update方法,新的子表数据就会被保存到数据库 masterBo.Update(); |
//获取一个Engine管理对象 H3.IEngine engine = this.Engine; //表单编码 string masterSchemaCode = "D00021testtable"; //表单数据Id string masterBoId = "bbc60153-19b8-4a57-b074-0c5b77367f8d"; //子表控件编码 string childSchemaCode = "D00021F7287906e76734bef8819176bc15a8763"; //Load出要修改数据的主表业务对象 H3.DataModel.BizObject masterBo = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, engine, masterSchemaCode, masterBoId, false); //获取子表结构体对象 H3.DataModel.BizObjectSchema childSchema = masterBo.Schema.GetChildSchema(childSchemaCode); //定义新的子表数据集合 List < H3.DataModel.BizObject > newChildBoList = new List<H3.DataModel.BizObject>(); //获取子表内已有数据 H3.DataModel.BizObject[] childBoArray = (H3.DataModel.BizObject[]) masterBo[childSchemaCode]; if(childBoArray != null && childBoArray.Length > 0) { foreach(H3.DataModel.BizObject itemBo in childBoArray) { //取出子表内F0000002控件的值 string F0000002 = itemBo["F0000002"] + string.Empty; //判断F0000002控件的值是否为空,不为空时,才将当前子表行数据添加到新的子表数据集合中,相当于把F0000002控件的值是否为空的行数据删除了 if(!string.IsNullOrEmpty(F0000002)) { //将子表内已有数据循环添加到新的子表数据集合里 newChildBoList.Add(itemBo); } } } //将新的子表数据集合赋值到子表控件 masterBo[childSchemaCode] = newChildBoList.ToArray(); //修改主表业务对象,系统会自动识别出上面子表数据被修改了,执行完Update方法,新的子表数据就会被保存到数据库 masterBo.Update(); |
答:可序列化的虚业务对象可以直接返回到前台,由前台代码直接接收。以下示例代码用于在后台查询业务对象数组并添加到Response.ReturnData。由前台代码接收Response.ReturnData数据。
示例代码如下:
if(actionName == "BtnCheck") { string accountName = postValue.Data["AccountName"] + string.Empty; H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); H3.Data.Filter.And andMatcher = new H3.Data.Filter.And(); andMatcher.Add(new H3.Data.Filter.ItemMatcher("AccountName", H3.Data.ComparisonOperatorType.Contains, accountName)); filter.Matcher = andMatcher; int count = 0; Dictionary < string, H3.DataModel.BizObjectHeader > headers = null; Dictionary < string, string > userNames = null;
H3.Data.Serialization.VirtualObject[] objects = this.Request.Engine.BizObjectManager.GetList( H3.Organization.User.SystemUserId, "D00002Account", H3.DataModel.GetListScopeType.GlobalAll, filter, out count, true, out headers, out userNames ); //查询虚对象 response.ReturnData = new Dictionary<string, object>(); response.ReturnData.Add("Objects", objects); //将对象返回到前台 } |
答:氚云提供对表单所有数据的一键清除功能,该操作不受数据之间引用限制。
示例代码如下:
string schemaCode ="D00002Lead"; this.Request.Engine.BizObjectManager.Clear(schemaCode); //清除表单D00002Lead的所有数据。数据清除后不可恢复,请谨慎操作。 |
答:如果是带流程的表单,在创建业务对象时需要发起流程,需要调用Engine.Interactor.OriginateInstance接口发起流程。
示例代码如下:
H3.DataModel.BizObjectSchema schema =this.Request.Engine.BizObjectManager.GetPublishedSchema("D000001InspectIssue"); H3.DataModel.BizObject iReport = new H3.DataModel.BizObject(this.Request.Engine, schema,this.Request.UserContext.UserId, this.Request.UserContext.User.ParentId); iReport["IssueReportName"] = "关于****的整改报告"; string instanceId = System.Guid.NewGuid().ToString(); if (string.IsNullOrEmpty(iReport.WorkflowInstanceId)) iReport.WorkflowInstanceId = instanceId ; iReport.Create(); //创建对象 H3.Workflow.Instance.WorkflowInstance wfInstance =this.Request.Engine.WorkflowInstanceManager.GetWorkflowInstance(iReport.WorkflowInstanceId); if (wfInstance == null) { //启动流程 string workItemID = string.Empty; string errorMsg = string.Empty; H3.Workflow.Template.WorkflowTemplate wfTemp =this.Request.Engine.WorkflowTemplateManager.GetDefaultWorkflow(iReport.Schema.SchemaCode); this.Request.Engine.Interactor.OriginateInstance(this.Request.UserContext.UserId, iReport.Schema.SchemaCode, wfTemp.WorkflowVersion, iReport.ObjectId, iReport.WorkflowInstanceId, H3.Workflow.WorkItem.AccessMethod.Web, true, string.Empty, true, out workItemID, out errorMsg); }//第七个参数 false/true 为是否提交流程操作
|
示例代码:
H3.Organization.OrgRole role = new H3.Organization.OrgRole(); role.Code = "manager"; role.Name = "经理"; role.CompanyId = Engine.Organization.Company.CompanyId; Engine.Organization.AddUnit(role); //创建角色 H3.Acl.FunctionAcl acl = new H3.Acl.FunctionAcl(role.Code,"客户管理","createdby"); Engine.FunctionAclManager.AddAcl(acl); //给角色添加权限。 |
示例代码:
string customer = this.Request[“Customer”]+string.Empty; |
示例代码:
object value=response.ReturnData["dataField"]; |
示例代码:
H3.Organization.OrgRole[] _userRoles = this.Request.Engine.Organization.GetUserRoles(this.Request.UserContext.UserId, false);//获取当前登录人所有角色 bool _flag = false; if(_userRoles != null) { foreach(H3.Organization.OrgRole _userRole in _userRoles) { if(_userRole.Name == "系统管理员")//判断当前登录角色 { _flag = true; break; } } } if(_flag) { response.ReturnData["F0000001"].Visible = false; //设置字段不可见 response.ReturnData["F0000002"].Editable = false;//设置字段不可写 } |
示例代码:
H3.DataModel.BizObjectFileHeader[] files = (H3.DataModel.BizObjectFileHeader[]) this.Request.BizObject["F0000020"]; //附件控件 foreach(H3.DataModel.BizObjectFileHeader f in files) { string FileId = f.FileId + string.Empty; }//注意:新增的时候获取不了ID |
示例代码:
string fileInfo = ""; string[] ObjectDataId = { child.ObjectId }; //表单的objectid数组 H3.DataModel.BizObjectFileHeader[] fileobject = this.Request.Engine.BizObjectManager.GetBizObjectFileHeaders(ObjectDataId); if(fileobject != null && fileobject.Length > 0) { foreach(H3.DataModel.BizObjectFileHeader item in fileobject) { fileInfo += item.FileId + ";"; } }//注意:新增的时候获取不了ID |
示例代码:
string userId = this.Request.UserContext.UserId + string.Empty; //获取当前用户ID H3.Organization.OrgRole[] userRoles = this.Engine.Organization.GetUserRoles(userId, true); //根据用户ID,获取该用户所有的角色 for(int i = 0;i < userRoles.Length; i++) { if(userRoles[i].Name == "系统管理员") //判断是否为管理员 { response.Message = "true"; } } |
示例代码:
string Dianzhang = "";//角色ID H3.Organization.OrgRole[] allRoles = this.Engine.Organization.GetAllRoles(); //获取所有角色 foreach(H3.Organization.OrgRole allRole in allRoles) { if(allRole.Name == "公海提醒") { Dianzhang = allRole.ObjectId; } } string[] Renyuans = this.Engine.Organization.GetChildren(Dianzhang,H3.Organization.UnitType.User, true, H3.Organization.State.Active); //获取 公海提醒 角色的所有成员ID |
示例代码:
Dictionary < string, object > TaskObjects1 =(Dictionary<string, object>) response.ReturnData["D00021cChildTable"].Value; //获取子表数据 Dictionary < string, H3.SmartForm.SmartFormResponseDataItem > taskobject1 =(Dictionary<string, H3.SmartForm.SmartFormResponseDataItem>) TaskObjects1["T"]; foreach(string key in taskobject1.Keys) { if(key == "D00021cChildTable.ChildNumber") taskobject1[key].Visible = false; //设置子表‘ChildNumber’列隐藏 } |
答:调用CopyFiles()。
示例:
//主表内附件控件 复制到 主表内附件控件 上 this.Request.Engine.BizObjectManager.CopyFiles("原-主表编码", "", "原-主表内附件控件编码", "原-主表数据ObjectId", "新-主表编码","", "新-主表内附件控件编码", "新-主表数据ObjectId", true, true); //主表内附件控件 复制到 子表内附件控件 上 this.Request.Engine.BizObjectManager.CopyFiles("原-主表编码", "", "原-主表内附件控件编码", "原-主表数据ObjectId", "新-主表编码","新-子表编码", "新-子表内附件控件编码", "新-子表数据ObjectId", true, true); //子表内附件控件 复制到 主表内附件控件 上 this.Request.Engine.BizObjectManager.CopyFiles("原-主表编码", "原-子表编码", "原-子表内附件控件编码", "原-子表数据ObjectId", "新-主表编码","", "新-主表内附件控件编码", "新-主表数据ObjectId", true, true); //子表内附件控件 复制到 子表内附件控件 上 this.Request.Engine.BizObjectManager.CopyFiles("原-主表编码", "原-子表编码", "原-子表内附件控件编码", "原-子表数据ObjectId", "新-主表编码","新-子表编码", "新-子表内附件控件编码", "新-子表数据ObjectId", true, true); /* CopyFiles方法最后两个参数详解: 第一个true:本次复制附件到目标控件是覆盖还是添加,true为覆盖,false为添加 第二个true:若本次是覆盖模式,目标控件原先附件是否进行物理删除,true为物理删除,false为只删除记录 */ |
示例代码:
//获取图片缩略图url,FileId:附件Id string fileurl = this.Request.UserContext.GetThumbnailUrl(string FileId); //获取原图url,FileId:附件Id string url="https://www.h3yun.com/Form/DoPreview/?attachmentId="+FileId |
答:前端PostForm请求后端,后端返回前端的数据组,需要构建虚业务对象。
示例:
前端代码: var parent = this; $.SmartForm.PostForm("QueryStudentInfo",{ StudentId:"123"//学生ID },function(data){ if(data.Errors&&data.Errors.length){ $.IShowError("错误",JSON.stringify(data.Errors)); }else{ debugger; var result=data.ReturnData; if(result["StudentName"]){ //获取后端返回的 学生姓名 var StudentName=result["StudentName"]; //给当前表单的F0000010控件设置值 parent.F0000010.SetValue(StudentName); } if(result["ClassInfo"]){ //获取后端返回的 学生所在班级信息 var ClassName=result["ClassInfo"]["ValueTable"]; } if(result["LikeList"]){ //获取后端返回的 学生喜好 var LikeList=result["LikeList"]; } if(result["FamilyInfo"]){ //获取后端返回的 学生家庭信息 var FamilyInfo=result["FamilyInfo"]; } } },function(error){ $.IShowError("错误",JSON.stringify(error)); },false);
后端代码: protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response) { if(actionName=="QueryStudentInfo") { response.ReturnData=new Dictionary<string,object>(); //从请求对象中获取 学生ID string StudentId=this.Request["StudentId"]+string.Empty; if(StudentId=="123") { //将 学生姓名 添加到响应对象中 response.ReturnData.Add("StudentName","张三"); //将 学生所在班级信息 添加到响应对象中 H3.Data.Serialization.VirtualObject ClassInfo=new H3.Data.Serialization.VirtualObject(); ClassInfo.ValueTable["ClassName"]="大一"; response.ReturnData.Add("ClassInfo",ClassInfo); //将 学生喜好 添加到响应对象中 string[] LikeList=new string[3]; LikeList[0]="Rap"; LikeList[1]="跳舞"; LikeList[2]="打篮球"; response.ReturnData.Add("LikeList",LikeList); //将 学生家庭信息 添加到响应对象中 List<H3.Data.Serialization.VirtualObject> FamilyInfo=new List<H3.Data.Serialization.VirtualObject>(); //将 父亲信息 添加到响应对象中 H3.Data.Serialization.VirtualObject FatherInfo=new H3.Data.Serialization.VirtualObject(); FatherInfo.ValueTable["Name"]="李四"; FatherInfo.ValueTable["Age"]=41; FamilyInfo.Add(FatherInfo); //将 母亲信息 添加到响应对象中 H3.Data.Serialization.VirtualObject MotherInfo=new H3.Data.Serialization.VirtualObject(); MotherInfo.ValueTable["Name"]="王五"; MotherInfo.ValueTable["Age"]=41; FamilyInfo.Add(MotherInfo); response.ReturnData.Add("FamilyInfo",FamilyInfo); }else { //响应给前端一个异常信息 response.Errors.Add("未找到StudentId为“"+StudentId+"”的学生 信息!"); } } base.OnSubmit(actionName,postValue,response); } |
答:与主表业务对象更新类似。需要注意:子表的数据标题,如果配有主表字段控件则不可使用这样的更新写法。
示例:
string schemaCode = "";//子表控件编码 string detail = "";//子表ObjectId H3.DataModel.BizObject accountBo = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId,this.Request.Engine, schemaCode,detail,false); //Load对象 accountBo["CustomerName"] = "深圳氚云网络科技有限公司"; //修改对象属性值 accountBo["CustomerLevel"] = "已成交"; accountBo.Status = H3.DataModel.BizObjectStatus.Effective; // 将对象状态设为生效 accountBo.Update(); //更新对象 |
答:重写response.ReturnData数据集。
示例:
protected override void OnLoad(H3.SmartForm.LoadListViewResponse response) { base.OnLoad(response);
string isFormControl = this.Request["isFormControl"] == null ? "" : this.Request["isFormControl"].ToString(); //判断是否是在load列表数据时 if(isFormControl != "1" && isFormControl != "true") { H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); H3.Data.Filter.And andMatcher = new H3.Data.Filter.And(); //将系统自带的filter添加进来,否则系统自带的筛选将失效 andMatcher.Add(this.Request.Filter.Matcher); filter.Matcher = andMatcher; //获取当前表单业务对象模式 H3.DataModel.BizObjectSchema allTaskSchema = this.Request.Schema; //获取列表过滤后的业务对象 H3.DataModel.BizObject[] tasks = H3.DataModel.BizObject.GetList(this.Request.Engine, this.Request.UserContext.UserId, allTaskSchema, H3.DataModel.GetListScopeType.GlobalAll, filter);
//初始化一个集合,用来存储经过筛选后响应给前端的数据 List < Dictionary < string, object >> list=new List<Dictionary<string, object>>(); if(tasks != null && tasks.Length > 0) { //筛选需要显示的列表数据,例如筛选出状态为正常的数据 foreach(H3.DataModel.BizObject biz in tasks) { Dictionary < string, object > dic = new Dictionary<string, object>(); string obj = biz["ObjectId"] + string.Empty; //获取表单ID string state = biz["F0000002"] + string.Empty; //获取状态 if(state == "正常" && obj != "") { //构造当前表单业务对象 H3.DataModel.BizObject Client = new H3.DataModel.BizObject(this.Engine, this.Request.Schema, this.Request.UserContext.UserId); Client.ObjectId = obj; // 给对象ID赋值 Client.Load(); //根据ID加载业务对象 Dictionary < string, Dictionary < string, string >> dicdate =null; foreach(H3.DataModel.PropertySchema pro in this.Request.Schema.Properties) //给dic赋值 { //附件、图片不会显示在列表上,需要排除掉 if(pro.DataType == H3.Data.BizDataType.File || pro.DataType == H3.Data.BizDataType.Image || pro.DataType == H3.Data.BizDataType.BizObjectArray) { continue; } //F0000008控件为日期控件,在这个转成标准的日期表达字符串,用于改变列表对此列异常的显示 if(pro.Name == "F0000008") { dic.Add(pro.Name, Client[pro.Name] + string.Empty); } else { dic.Add(pro.Name, Client[pro.Name]); }
}
/*----Start 以下代码为构造手机端摘要信息----*/ string mobilesummary = null;//移动端摘要构造器所需 string pcsummary = null;//移动端摘要构造器所需 string telephone = null;//移动端摘要构造器所需 Client.GetSummary(out dicdate, out mobilesummary, out pcsummary, out telephone); //返回摘要信息
dic.Add("__MobileSummary", mobilesummary); dic.Add("__MobileDicData", dicdate); /*----End 以上代码为构造手机端摘要信息----*/
//将经过筛选后的数据对象 添加进集合中 list.Add(dic); } }
//赋值筛选后的列表数据 response.ReturnData = new List<Dictionary<string, object>>(); response.ReturnData = list; //由于我们改变了ReturnData集合,所以这里需要改变响应数据的条数 response.DataCount = list.Count; } } } |
答:提供C#的Newtonsoft.Json组件进行解析。
示例:
string value = this.Serialize(object value);//将对象序列化成json格式的字符串 T value = this.Deserialize<T>(string value);//将json格式的字符串反序列化成T类型的对象 |
答:例如获取子表中F0000001字段的值。先获取子表控制值,将其转化为对象数组,在循环遍历取值。
示例:
H3.DataModel.BizObject[] details = (H3.DataModel.BizObject[])this.Request.BizObject["D00002SalesOrderDetail"]; //获取子表属性并强制转换为对象数组 if(details != null && details.Length > 0) { foreach(H3.DataModel.BizObject detail in details) { string zz = detail["F0000001"] + string.Empty; //获取子表中F0000001的字段值 } } |
示例:
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response) { //Activity3节点审批同意时获取审批意见 if(actionName == "Submit" && this.Request.ActivityCode == "Activity3") { string comment = postValue.Comment.Text; } //Activity3节点审批不同意时获取审批意见 if(actionName == "Reject" && this.Request.ActivityCode == "Activity3") { string comment = postValue.Comment.Text; } base.OnSubmit(actionName, postValue, response); } |
示例:
H3.Workflow.Instance.IToken tok = this.Request.Engine.WorkflowInstanceManager.GetWorkflowInstance("流程id").GetLastToken(); /* tok.Activity:流程节点编码,string类型 tok.Approval:是否同意,H3.Data.BoolValue类型: H3.Data.BoolValue.True 是同意, H3.Data.BoolValue.False 是不同意, H3.Data.BoolValue.Unspecified 是未处理或节点被取消 tok.TokenId:流程步骤表(H_Token)ObjectId字段值,string类型 tok.Participants:流程审批人,string[]类型,每一个数组元素对应一个审批人用户ID tok.CreatedTime:流程节点创建时间,DateTime类型 tok.FinishedTime:流程节点结束事件,DateTime类型 tok.UsedTime:当前节点从开始到结束耗时,TimeSpan类型 */ |
示例:
System.Data.DataTable b = this.Engine.Query.QueryWorkItemDisplayAndParticipant(string[] InstanceIds, H3.Workflow.WorkItem.WorkItemState state); InstanceIds:流程实例id数组 H3.Workflow.WorkItem.WorkItemState: Waiting 处于等待的状态 Working 处于正在工作中的状态 Finished 处于完成状态 Canceled 已经被取消 Unfinished 这个并不属于WorkItem本身的状态,只是为了方便进行查询,他指Waiting或者Working状态 NotCanceled 这个并不属于WorkItem本身的状态,只是为了方便进行查询,未被取消的状态,指Waiting、Working或者Finished状态 Unspecified 未指定的状态,这个主要是为了方便查询 |
答:这种情况一般是你字段为不可写,然后通过代码SetValue的值,这种情况,你只需要在OnSubmit通过
this.Request.BizObject["字段"]=postValue.Data["字段"];
答:如果是提交的数据,在OnSubmit里面判断(因为编辑的时候他的数据的状态是生效的状态)
if(this.Request.BizObject.Status==H3.DataModel.BizObjectStatus.Draft)
{
//这里是新增提交的时候写的代码
}
if(this.Request.BizObject.Status==H3.DataModel.BizObjectStatus.Effective)
{
//这里是编辑的时候写的代码
}
//得到一个IEngine对象
H3.IEngine engine = this.Request.Engine;
//获取系统虚拟用户的人员Id(表单设计后端类、列表设计后端类、定时器类、自定义接口类中都可以获取)
string systemUserId = H3.Organization.User.SystemUserId;
//获取当前登录人的人员Id(只能在表单设计后端类、列表设计后端类中获取)
string currentUserId = this.Request.UserContext.UserId;
H3.DataModel.BizObject biz = H3.DataModel.BizObject.Load(currentUserId, engine, "D00021fbc02cce483842e6b65b3fb10dd64536", this.Request.BizObjectId + string.Empty, false);
//获取流水号并赋值
biz["F0000001"] = biz["SeqNo"] + string.Empty;
//流水号要在提交后获取
前端代码:
var parent=this;
this.F0000005.BindChange
("key", function(){
$.SmartForm.PostForm
("GetDays",{F0000005:parent.F0000005.GetValue().join(',')},
function(res){
parent.F0000004.SetValue(res.ReturnData.Data1);
},function(){
},false);
});
后端代码:
if(actionName == "GetDays")
{
string str = this.Request["F0000005"] + string.Empty;
string[] str1 = str.Split(',');
foreach(string str2 in str1)
{
H3.DataModel.BizObject biz=H3.DataModel.BizObject.Load(this.Request.UserContext.UserId,this.Engine,"D0002175521e4e872547d4b24098bd4ae17e3b",str2,false);//通过前端传回来的关联表单objectid,加载出业务对象
}
前端代码:
if(actionCode=="DataCopy"){
//点击复制按钮时检查是否选中数据
var objects=$.ListView.GetSelected();
if(objects==null||objects==undefined||objects==""){
$.IShowWarn("您还未勾选数据,请勾选!");
return;
}
//判断选中数据是否大于1条
else if(objects.length>1){
$.IShowWarn("不好意思,只能勾选一个采购单");
return;
}
else {
$.ListView.Post("DataCopy",{objectId:objects[0].ObjectId,str1:"123"},
function(data){
if(data.ReturnData==null||!data.ReturnData.Message){
//刷新列表
$.ListView.RefreshView();
$.IShowSuccess("复制完成!");
}
else if(data.ReturnData!=null&&data.ReturnData.Message){
$.IShowError(data.ReturnData.Message);
}
else{
$.IShowError("复制失败!");
}
},
function(data){
$.IShowError(data.Errors[0]);
},
false);
}
}
后端代码:
if(actionName == "DataCopy")
{
response.ReturnData = new Dictionary<string, object>();
string objectId = this.Request["objectId"];
string str1=this.Request["str1"];
if(!string.IsNullOrEmpty(objectId))
{
H3.DataModel.BizObject accountBo = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Engine, "D000213ef50cc75c5e4bac958ec64182d62d9d", objectId, false);
if(accountBo != null)
{
H3.DataModel.BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D000213ef50cc75c5e4bac958ec64182d62d9d");
H3.DataModel.BizObject obj = new H3.DataModel.BizObject(this.Request.Engine, schema, this.Request.UserContext.UserId); //主表对象
obj["F0000001"] = DateTime.Now;//需求日期
...
//附件
this.Request.Engine.BizObjectManager.CopyFiles("D000213ef50cc75c5e4bac958ec64182d62d9d", "", "F0000012", accountBo.ObjectId, "D000213ef50cc75c5e4bac958ec64182d62d9d", "", "F0000012", obj.ObjectId, true, true);
//子表数据不为空
if(accountBo["D00021Fe17972588372432381107d8bc67e9d50"] != null)
{
//得到子表数据
H3.DataModel.BizObject[] zibiao = (H3.DataModel.BizObject[]) accountBo["D00021Fe17972588372432381107d8bc67e9d50"];
//创建存新子表数据集合
List < H3.DataModel.BizObject > zibiaoList = new List<H3.DataModel.BizObject>();
//循环复制数据
foreach(H3.DataModel.BizObject zb in zibiao)
{
H3.DataModel.BizObjectSchema newSch = this.Request.Engine.BizObjectManager.GetPublishedSchema("D00021Fe17972588372432381107d8bc67e9d50");
H3.DataModel.BizObject newzb = new H3.DataModel.BizObject(this.Request.Engine, newSch, this.Request.UserContext.UserId);
newzb["F0000006"] = zb["F0000006"];
...
zibiaoList.Add(newzb);
}
obj["D00021Fe17972588372432381107d8bc67e9d50"] = zibiaoList.ToArray();
}
obj.Status = accountBo.Status;
if(string.IsNullOrEmpty(obj.WorkflowInstanceId))
obj.WorkflowInstanceId = System.Guid.NewGuid().ToString();
//创建对象
H3.ErrorCode createResult = obj.Create();
//判断是否成功创建数据对象
if(createResult != H3.ErrorCode.Success)
{
response.ReturnData.Add("Message", createResult.ToString());
} else
{
if(accountBo.Status == H3.DataModel.BizObjectStatus.Running)
{
obj.Status = H3.DataModel.BizObjectStatus.Draft;
H3.Workflow.Instance.WorkflowInstance wfInstance = this.Request.Engine.WorkflowInstanceManager.GetWorkflowInstance(obj.WorkflowInstanceId);
if(wfInstance == null)
{
//启动流程
string workItemID = string.Empty;
string errorMsg = string.Empty;
H3.Workflow.Template.WorkflowTemplate wfTemp = this.Request.Engine.WorkflowTemplateManager.GetDefaultWorkflow(obj.Schema.SchemaCode);
this.Request.Engine.Interactor.OriginateInstance(this.Request.UserContext.UserId, obj.Schema.SchemaCode, wfTemp.WorkflowVersion, obj.ObjectId, obj.WorkflowInstanceId, H3.Workflow.WorkItem.AccessMethod.Web, true, string.Empty, true, out workItemID, out errorMsg);
}
}
}
} else
{
response.ReturnData.Add("Message", "数据对象未获取到!");
}
} else
{
response.ReturnData.Add("Message", "无数据对象ID!");
}
}
1.获取公司所有角色H3.Organization.OrgRole[] allRoles = this.Request.Engine.Organization.GetAllRoles();
2.循环这个数组,找到你要的角色
3.获取所有用户 string[] userIds = this.Request.Engine.Organization.GetChildren(角色id, H3.Organization.UnitType.Role, true, H3.Organization.State.Active);
首先导入Excel会触发前端的填充,计算规则,不会触发OnSubmit事件,但是流程表单会触发流程结束事件,所以您需要在流程结束的回调时间中编写您的代码
protected override void OnWorkflowInstanceStateChanged(H3.Workflow.Instance.WorkflowInstanceState oldState, H3.Workflow.Instance.WorkflowInstanceState newState)
{
//流程审批结束事件(先执行业务规则,在执行该方法)。
if(oldState == H3.Workflow.Instance.WorkflowInstanceState.Running && newState == H3.Workflow.Instance.WorkflowInstanceState.Finished)
{
//执行业务代码逻辑
}
base.OnWorkflowInstanceStateChanged(oldState, newState);
}
需要注意,如果流程设置的是开始节点直接到结束节点,中间没有审批节点,或者审批节点全部符合自动审批通过逻辑,需要使用如下代码
protected override void OnWorkflowInstanceStateChanged(H3.Workflow.Instance.WorkflowInstanceState oldState, H3.Workflow.Instance.WorkflowInstanceState newState)
{
//流程审批结束事件(先执行业务规则,在执行该方法)。
if((oldState == H3.Workflow.Instance.WorkflowInstanceState.Running ||oldState == H3.Workflow.Instance.WorkflowInstanceState.Initiated) && newState == H3.Workflow.Instance.WorkflowInstanceState.Finished)
{
//执行业务代码逻辑
}
base.OnWorkflowInstanceStateChanged(oldState, newState);
}
排查以下内容
是否开启了氚云全员可见,如果没有,请先开启全员可见,然后点击手动同步,然后再设置回来
人员是否过多,如果组织机构超过1万人,会有几率出现这种情况,超过1万人使用的建议使用云枢进行交付
这种情况一般是由于关联了子表,主表left join子表的时候,如果子表是两行,那么join出来的结果会有两行,这样就会出现统计结果翻倍的情况,建议使用sql进行编写
sql报表如何进行权限控制
只要在查询结果中暴露出OwnerId和OwnerDepartId就行,并一定要要求OwnerId对应的字段是拥有者,如果select man as OwnerId from table (这里的man是一个人员单选).这样也能达到控制权限的目的
复选框本质就是一个单行文本,他的字数限制是200个字,如果复选框所选择的字加起来超过了总字数就会报错
{'Successful': False, 'ErrorMessage': '根据 SchemaCode 获取 BizObjectSchema 失败', 'Logined': False, 'ReturnData': {}, 'DataType': 0}
这种错误只可能有两种情况
1.EngineCode和EngineScrect填错了
2.SchemaCode填错了
注意:记得把EngineCode和EngineScrect写在Header里面
这种情况,一般是由于您的数据是通过业务规则插入的,而且没插数据标题,您虽然看到了数据标题,那是平台帮忙显示的,本质上数据标题(数据库Name值)是空的。这样情况您需要编辑提交一下数据就可以了。最一劳永逸的办法是您再插入业务规则的时候把数据标题也赋值一下