public InvokeWebServiceJob LoadSingleData(IConnectiveSqlClause whereClause) { InvokeWebServiceJob result = null; if (whereClause.IsEmpty == false) { using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(string.Format(SingleData_InvokeWebService, whereClause.ToSqlString(TSqlBuilder.Instance)), GetConnectionName())) { while (dr.Read()) { result = new InvokeWebServiceJob(); ORMapping.DataReaderToObject(dr, result); break; } } if (result != null) { XElementFormatter formatter = new XElementFormatter(); formatter.OutputShortType = WorkflowSettings.GetConfig().OutputShortType; XElement root = XElement.Parse(result.XmlData); result.SvcOperationDefs = (WfServiceOperationDefinitionCollection)formatter.Deserialize(root); result.InitJobBaseData(JobBaseAdapter.Instance.LoadSingleDataByJobID(whereClause)); } } } return(result); }
/// <summary> /// 获得指定ID的Material /// </summary> /// <param name="materialID">指定ID</param> /// <returns>MaterialList</returns> public MaterialList LoadMaterialByMaterialID(string materialID) { ExceptionHelper.CheckStringIsNullOrEmpty(materialID, "materialID"); MaterialList materials = new MaterialList(); WhereSqlClauseBuilder wBuilder = new WhereSqlClauseBuilder(); wBuilder.AppendItem("ID", materialID); wBuilder.AppendTenantCode(typeof(Material)); string sql = "SELECT * FROM WF.MATERIAL WHERE " + wBuilder.ToSqlString(TSqlBuilder.Instance); using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(sql, GetConnectionName())) { while (dr.Read()) { Material material = new Material(); ORMapping.DataReaderToObject(dr, material); materials.Add(material); } } } DecorateMaterials(materials); return(materials); }
public MaterialList LoadVersionMaterialsBySceneKey(string resourceID, string wfActivityName) { MaterialList copyVersionMaterials = new MaterialList(); WhereSqlClauseBuilder whereSqlClause = new WhereSqlClauseBuilder(); whereSqlClause.AppendItem("RESOURCE_ID", resourceID); whereSqlClause.AppendItem("VERSION_TYPE", Convert.ToInt16(MaterialVersionType.CopyVersion).ToString()); whereSqlClause.AppendItem("WF_ACTIVITY_NAME", wfActivityName); whereSqlClause.AppendTenantCode(typeof(Material)); string sql = string.Format("SELECT * FROM WF.MATERIAL WHERE {0}", whereSqlClause.ToSqlString(TSqlBuilder.Instance)); using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(sql, GetConnectionName())) { while (dr.Read()) { Material material = new Material(); ORMapping.DataReaderToObject(dr, material); copyVersionMaterials.Add(material); } } } DecorateMaterials(copyVersionMaterials); return(copyVersionMaterials); }
/// <summary> /// 没有TenantCode查找单一Job /// </summary> /// <param name="whereClause"></param> /// <returns></returns> public JobBase LoadSingleDataByJobID(IConnectiveSqlClause whereClause) { JobBase result = null; if (whereClause.IsEmpty == false) { using (DbContext context = DbHelper.GetDBContext(GetConnectionName())) { //using (IDataReader dr = DbHelper.RunSqlReturnDR(string.Format(SINGLEATA_JOB, // whereClause.AppendTenantCodeSqlClause(typeof(JobBase)).ToSqlString(TSqlBuilder.Instance)), GetConnectionName())) //{ // while (dr.Read()) // { // result = new JobBase(); // ORMapping.DataReaderToObject(dr, result); // break; // } //} using (IDataReader dr = DbHelper.RunSqlReturnDR(string.Format(SINGLE_DATA_JOB, whereClause.ToSqlString(TSqlBuilder.Instance)), GetConnectionName())) { while (dr.Read()) { result = new JobBase(); ORMapping.DataReaderToObject(dr, result); break; } } } } return(result); }
public StartWorkflowJob LoadSingleData(IConnectiveSqlClause whereClause) { StartWorkflowJob result = null; if (whereClause.IsEmpty == false) { using (DbContext context = DbHelper.GetDBContext(GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(string.Format(SingleData_StartWorkflowJob, whereClause.AppendTenantCodeSqlClause(typeof(StartWorkflowJob)).ToSqlString(TSqlBuilder.Instance)), GetConnectionName())) { while (dr.Read()) { result = new StartWorkflowJob(); ORMapping.DataReaderToObject(dr, result); break; } } if (result != null) { result.InitJobBaseData(JobBaseAdapter.Instance.LoadSingleDataByJobID(whereClause)); } } } return(result); }
/// <summary> /// 获得指定附件的副本 /// </summary> /// <param name="materials">附件集合</param> /// <returns>指定附件对应的副本集合</returns> internal MaterialList LoadCopyVersionMaterial(MaterialList materials) { ExceptionHelper.TrueThrow <ArgumentNullException>(materials == null, "materials"); MaterialList copyVersionMaterials = new MaterialList(); if (materials.Count != 0) { ConnectiveSqlClauseCollection orClause = new ConnectiveSqlClauseCollection(LogicOperatorDefine.Or); foreach (Material material in materials) { WhereSqlClauseBuilder whereSqlClause = new WhereSqlClauseBuilder(); whereSqlClause.AppendItem("PARENT_ID", material.ID); whereSqlClause.AppendItem("WF_ACTIVITY_ID", material.WfActivityID); whereSqlClause.AppendItem("VERSION_TYPE", (int)MaterialVersionType.CopyVersion); orClause.Add(whereSqlClause); } string sql = string.Format("SELECT * FROM WF.MATERIAL WHERE {0}", orClause.AppendTenantCodeSqlClause(typeof(Material)).ToSqlString(TSqlBuilder.Instance)); using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(sql, GetConnectionName())) { while (dr.Read()) { Material material = new Material(); ORMapping.DataReaderToObject(dr, material); copyVersionMaterials.Add(material); } } } DecorateMaterials(copyVersionMaterials); } return(copyVersionMaterials); }
/// <summary> /// 获得指定ID的副本 和 它之前的一切副本 按照时间正排序 /// </summary> /// <param name="id">id</param> /// <returns>MaterialList</returns> public MaterialList GetPreMaterialsCopyVersion(string id) { ExceptionHelper.CheckStringIsNullOrEmpty(id, "id"); WhereSqlClauseBuilder whereSqlClause = new WhereSqlClauseBuilder(); whereSqlClause.AppendItem("PARENT_ID", string.Format("(SELECT PARENT_ID FROM WF.MATERIAL WHERE ID = {0})", TSqlBuilder.Instance.CheckQuotationMark(id, true)), "=", true); whereSqlClause.AppendItem("MODIFY_TIME", string.Format("(SELECT MODIFY_TIME FROM WF.MATERIAL WHERE ID = {0})", TSqlBuilder.Instance.CheckQuotationMark(id, true)), "<=", true); whereSqlClause.AppendTenantCode(typeof(Material)); OrderBySqlClauseBuilder orderBySqlClause = new OrderBySqlClauseBuilder(); orderBySqlClause.AppendItem("MODIFY_TIME", FieldSortDirection.Ascending); string sql = string.Format(@"SELECT * FROM WF.MATERIAL WHERE {0} AND VERSION_TYPE = {1} ORDER BY {2}" , whereSqlClause.ToSqlString(TSqlBuilder.Instance), Convert.ToInt16(MaterialVersionType.CopyVersion), orderBySqlClause.ToSqlString(TSqlBuilder.Instance)); MaterialList materials = new MaterialList(); using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(sql, GetConnectionName())) { while (dr.Read()) { Material material = new Material(); ORMapping.DataReaderToObject(dr, material); materials.Add(material); } } } return(materials); }
/// <summary> /// 由资源ID查询 /// </summary> /// <param name="resourceIDs">资源ID</param> /// <returns>查询结果</returns> public MaterialList LoadMaterialsByResourceID(params string[] resourceIDs) { ExceptionHelper.TrueThrow <ArgumentNullException>(resourceIDs == null, "resourceIDs"); MaterialList result = new MaterialList(); if (resourceIDs.Length != 0) { InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("RESOURCE_ID"); inBuilder.AppendItem(resourceIDs); OrderBySqlClauseBuilder orderClause = new OrderBySqlClauseBuilder(); orderClause.AppendItem("SORT_ID", FieldSortDirection.Ascending); string sql = string.Format("SELECT * FROM WF.MATERIAL WHERE {0} AND VERSION_TYPE = '{1}' ORDER BY {2}", inBuilder.AppendTenantCodeSqlClause(typeof(Material)).ToSqlString(TSqlBuilder.Instance), Convert.ToInt32(MaterialVersionType.Normal).ToString(), orderClause.ToSqlString(TSqlBuilder.Instance)); using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(sql, GetConnectionName())) { while (dr.Read()) { Material material = new Material(); ORMapping.DataReaderToObject(dr, material); result.Add(material); } } } DecorateMaterials(result); } return(result); }