/// <summary> /// 上传外部单位附件 /// </summary> /// <param name="para"></param> /// <param name="trans"></param> /// <param name="objectID"></param> /// <param name="content"></param> /// <returns></returns> public string UploadAttachFileToResource(SessionPara para, SQLTransaction trans, string objectID, string content) { string retStr = ""; if (!string.IsNullOrEmpty(objectID) && !string.IsNullOrEmpty(content)) { StringBuilder sb = new StringBuilder(); var fileDataList = JsonConvert.DeserializeObject <List <FileInformation> >(content); foreach (var file in fileDataList) { var newObj = ObjectFactoryUtility.CreateInstance(para, trans, "TESTATTACH"); newObj.SetObjectDBValue("ENAME", file.FileName); newObj.SetObjectDBValue("PATH", file.Path); newObj.SetObjectDBValue("MASTERID", objectID); newObj.SetObjectDBValue("UPLOADUSER", para.UserID); newObj.SetObjectDBValue("UPLOADTIME", DatetimeUtil.GetInternalTicksByDateTime(DateTime.Now)); newObj.SetObjectDBValue("FILEINFO", JsonConvert.SerializeObject(new List <FileInformation>() { file })); newObj.SaveObject(para, trans); sb.Append(";" + newObj.ObjectID); } if (sb.Length > 0) { retStr = sb.ToString().Substring(1); } } return(retStr); }
/// <summary> /// 批量设置对象的属性值 /// </summary> /// <param name="para"></param> /// <param name="trans"></param> /// <param name="objectId">对象id集合</param> /// <param name="fieldName">属性名称集合</param> /// <param name="value">值</param> /// <returns></returns> public bool SetObjectValueByFiledName(SessionPara para, SQLTransaction trans, string objectId, string fieldName, string value) { bool result = false; if (!string.IsNullOrEmpty(objectId) && !string.IsNullOrEmpty(fieldName)) { var objList = ObjectFactoryUtility.GetObjListByIdList(para, trans, objectId.Split(';')); var fields = fieldName.Split(';'); var values = value.Split(';'); if (fields.Length == values.Length) { foreach (var curObj in objList) { for (int i = 0; i < fields.Length; i++) { var tempField = fields[i]; var tempValue = values[i]; curObj.SetObjectDBValue(tempField, tempValue); } curObj.SaveObject(para, trans); } result = true; } } return(result); }
public TreeChildData GetTestTaskPlanChildTreeNode(TreeViewPara para, SQLTransaction trans) { TreeChildData childData = new TreeChildData(); childData.ExpandPermission = true; childData.ChildData = new List <TreeNodeObject>(); var nodeType = ObjectFactoryUtility.TypeFromID(para.Value1); if (nodeType == "PMSPROJECT") { ObjectQuery query = new ObjectQuery("PROJECTSTAGE"); query.FilterString = " PROJECTID ='" + para.Value1 + "' "; var stageList = query.ExecObjectQuery(para, trans); foreach (var stage in stageList) { var tempName = stage.GetObjectDBValue(ObjectInfoConst.EntityName).ToString(); var tempNodeType = stage.ObjType.Name; var tempImg = ServiceUtility.ToWebIconPath(stage.ObjType.IconPath); var tempNode = ServiceUtility.GetTreeNodeObject(tempName, stage.ObjectID, "", tempNodeType, "1", tempImg, tempNodeType, true); tempNode.ContentPermission = true; childData.ChildData.Add(tempNode); } } else if (nodeType == "PROJECTSTAGE") { var stageObj = ObjectFactoryUtility.CreateInstance(para, trans, para.Value1, false); if (stageObj != null) { var projectId = stageObj.GetObjectDBValue("PROJECTID").ToString(); ObjectQuery query = new ObjectQuery("TESTPLANTASK"); query.FilterString = " PROJECT ='" + projectId + "' AND STAGE='" + para.Value1 + "' "; var testPlanTaskList = query.ExecObjectQuery(para, trans); foreach (var planTask in testPlanTaskList) { var tempName = planTask.GetObjectDBValue(ObjectInfoConst.EntityName).ToString(); var tempNodeType = planTask.ObjType.Name; var tempImg = ServiceUtility.ToWebIconPath(planTask.ObjType.IconPath); var tempNode = ServiceUtility.GetTreeNodeObject(tempName, planTask.ObjectID, "", tempNodeType, "1", tempImg, tempNodeType, true); tempNode.ContentPermission = true; childData.ChildData.Add(tempNode); } } } else { //如果当前用户有权限,则加载下级节点 } return(childData); }
/// <summary> /// 根据关系id移除关系 /// </summary> /// <param name="para"></param> /// <param name="trans"></param> /// <param name="linkIds"></param> /// <returns></returns> public bool RemoveLinkObject(SessionPara para, SQLTransaction trans, string linkIds) { bool result = false; if (!string.IsNullOrEmpty(linkIds)) { var objList = ObjectFactoryUtility.GetObjListByIdList(para, trans, linkIds.Split(';')); foreach (var obj in objList) { obj.DeleteObject(para, trans); } result = true; } return(result); }
/// <summary> /// 通过关系名称父子级id建立关系 /// </summary> /// <param name="para"></param> /// <param name="trans"></param> /// <param name="linkTypeName"></param> /// <param name="peid"></param> /// <param name="ceids"></param> /// <returns></returns> public bool AddLinkByObjectIdAndLinkTypeName(SessionPara para, SQLTransaction trans, string linkTypeName, string peid, string ceids) { bool result = false; if (!string.IsNullOrEmpty(linkTypeName) && !string.IsNullOrEmpty(peid) && !string.IsNullOrEmpty(ceids)) { var ids = ceids.Split(';'); var objList = ObjectFactoryUtility.GetObjListByIdList(para, trans, ids); foreach (var cid in ceids.Split(';')) { ObjectFactoryUtility.AddLink(para, trans, linkTypeName, peid, cid); } result = true; } return(result); }
/// <summary> /// 批量更改试验能力组织 /// </summary> /// <param name="para"></param> /// <param name="trans"></param> /// <param name="objectID"></param> /// <param name="fieldName"></param> /// <param name="value"></param> /// <returns></returns> public bool ChangeCapabilityOrg(SessionPara para, SQLTransaction trans, string objectID, string value) { bool result = false; if (!string.IsNullOrEmpty(objectID)) { var objList = ObjectFactoryUtility.GetObjListByIdList(para, trans, objectID.Split(';')); List <string> list = new List <string>(); //获取试验能力所在的组织集合 foreach (var obj in objList) { var orgStr = obj.GetObjectDBValue("ORG").ToString(); if (!list.Contains(orgStr)) { list.Add(orgStr); } } ObjectQuery query = new ObjectQuery("TESTCAPABILITY"); query.FilterString = " ORG IN(" + list.Select(d => "'" + d + "'").Aggregate((a, b) => a + "," + b) + ")"; var queryResult = query.ExecObjectQuery(para, trans); List <string> objIdList = new List <string>(); foreach (var obj in objList) { var curOrg = obj.GetObjectDBValue("ORG").ToString(); //更改的数据与之前的相同则不再处理 if (curOrg == value || objIdList.Contains(obj.ObjectID)) { continue; } var parentProject = obj.GetObjectDBValue("TESTPROJECT").ToString(); //存在父级且父级不在此次更改组织的范围内,清空父级项目 if (!string.IsNullOrEmpty(parentProject)) { if (!objList.Any(t => t.ObjectID == parentProject)) { obj.SetObjectDBValue("TESTPROJECT", DBNull.Value); obj.SaveObject(para, trans); } else { continue; } } else if (string.IsNullOrEmpty(parentProject)) { parentProject = obj.ObjectID; } List <BaseObject> tempList = new List <BaseObject>(); tempList.Add(obj); DeepGetChildCapabilityObj(parentProject, tempList, queryResult); foreach (var item in tempList) { item.SetObjectDBValue("ORG", value); item.SaveObject(para, trans); objIdList.Add(item.ObjectID); } } result = true; } return(result); }
/// <summary> /// 保存试验能力,并且创建试验资源、知识的关系 /// </summary> /// <param name="para"></param> /// <param name="trans"></param> /// <param name="baseData"></param> /// <param name="knowledgeId"></param> /// <param name="resourceId"></param> /// <param name="objectId"></param> /// <returns></returns> public string SaveCapabilityData(SessionPara para, SQLTransaction trans, string baseData, string knowledgeId, string resourceId, string objectId) { string ret = ""; if (!string.IsNullOrEmpty(baseData)) { BaseObject abilityObj = null; BaseObject projectObj = null; if (!string.IsNullOrEmpty(objectId)) { abilityObj = ObjectFactoryUtility.CreateInstance(para, trans, objectId, false); ObjectFactoryUtility.DeleteObjByTypeAndFilter(para, trans, "TESTABILITIYTORESOUCE", " AND PEID ='" + objectId + "'"); ObjectFactoryUtility.DeleteObjByTypeAndFilter(para, trans, "TESTABILITYTOKNOWLEDGE", " AND PEID ='" + objectId + "'"); } else { abilityObj = ObjectFactoryUtility.CreateInstance(para, trans, "TESTCAPABILITY"); } abilityObj.FromJsonString(para, baseData); var objName = abilityObj.GetObjectDBValue("ENAME").ToString(); if (!string.IsNullOrEmpty(objName)) { //根据前端传过来的项目数据判断是id还是名称,如果是名称则编辑是否已经存在相同名称的项目,否则新建项目 var objTypeName = ObjectFactoryUtility.TypeFromID(objName); if (DataModels.Instance.GetEntityType(objTypeName) == null) { ObjectQuery query = new ObjectQuery("TESTPROJECT"); var projectList = query.ExecObjectQuery(para, trans); projectObj = projectList.FirstOrDefault(d => d.GetObjectDBValue(ObjectInfoConst.EntityName).ToString() == objName); if (projectObj == null) { projectObj = ObjectFactoryUtility.CreateInstance(para, trans, "TESTPROJECT"); projectObj.SetObjectDBValue("ENAME", abilityObj.GetObjectDBValue("ENAME")); projectObj.SetObjectDBValue("ECODE", abilityObj.GetObjectDBValue("ECODE")); projectObj.SetObjectDBValue("STANDARDCODE", abilityObj.GetObjectDBValue("STANDARDCODE")); projectObj.SetObjectDBValue("STANDARDNAME", abilityObj.GetObjectDBValue("STANDARDNAME")); projectObj.SetObjectDBValue("TYPE", abilityObj.GetObjectDBValue("TYPE")); projectObj.SetObjectDBValue("SCHEDULETYPE", abilityObj.GetObjectDBValue("SCHEDULETYPE")); projectObj.SetObjectDBValue("ABILITYORDER", abilityObj.GetObjectDBValue("ABILITYORDER")); projectObj.SetObjectDBValue("ISCNAS", abilityObj.GetObjectDBValue("ISCNAS")); //根据父级试验能力设置项目的父级项目 var pCapabilityId = abilityObj.GetObjectDBValue("TESTPROJECT").ToString(); if (!string.IsNullOrEmpty(pCapabilityId)) { var pCapability = ObjectFactoryUtility.CreateInstance(para, trans, pCapabilityId, false); if (pCapability != null) { projectObj.SetObjectDBValue("TESTPROJECT", pCapability.GetObjectDBValue(ObjectInfoConst.EntityName)); } } projectObj.SaveObject(para, trans); } abilityObj.SetObjectDBValue("ENAME", projectObj.ObjectID); } } abilityObj.SaveObject(para, trans); if (!string.IsNullOrEmpty(knowledgeId)) { var kIds = JsonConvert.DeserializeObject <List <string> >(knowledgeId); foreach (var kid in kIds) { ObjectFactoryUtility.AddLink(para, trans, "TESTABILITYTOKNOWLEDGE", abilityObj.ObjectID, kid); } } if (!string.IsNullOrEmpty(resourceId)) { var resIds = JsonConvert.DeserializeObject <List <string> >(resourceId); foreach (var resid in resIds) { ObjectFactoryUtility.AddLink(para, trans, "TESTABILITIYTORESOUCE", abilityObj.ObjectID, resid); } } ret = abilityObj.ObjectID; } return(ret); }