Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据TaskGuid得到UserAccomplishedTask
        /// </summary>
        /// <param name="strTaskGuid"></param>
        /// <returns></returns>
        public UserTaskCollection GetUserAccomplishedTasks(params string[] strTaskGuid)
        {
            UserTaskCollection utc = new UserTaskCollection();

            if (strTaskGuid.Length > 0)
            {
                InSqlClauseBuilder builder = new InSqlClauseBuilder();
                builder.AppendItem(strTaskGuid);

                string strSql = "SELECT * FROM WF.USER_ACCOMPLISHED_TASK WHERE (TASK_GUID " + builder.ToSqlStringWithInOperator(TSqlBuilder.Instance) + ")";
                using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName()))
                {
                    Database db = DatabaseFactory.Create(dbi);

                    using (IDataReader dr = db.ExecuteReader(CommandType.Text, strSql))
                    {
                        while (dr.Read())
                        {
                            UserTask ut = new UserTask();

                            ORMapping.DataReaderToObject(dr, ut);

                            utc.Add(ut);
                        }
                    }
                }
            }

            return(utc);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 窥视下一个可用计数值
        /// </summary>
        /// <param name="counterID">计数器ID</param>
        /// <returns>新计数值</returns>
        public static int PeekCountValue(string counterID)
        {
            ExceptionHelper.CheckStringIsNullOrEmpty(counterID, "counterID");

            using (DbContext dbi = DbHelper.GetDBContext(ConnectionDefine.DBConnectionName))
            {
                Database db = DatabaseFactory.Create(dbi);
                return((int)db.ExecuteScalar("WF.PeekCountValue", PrepareParameters(counterID)));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 设置计数器的计数值
        /// </summary>
        /// <param name="counterID">计数器ID</param>
        /// <param name="countValue">计数值</param>
        /// 在并发情况下设置计数器值可能会造成冲突
        public static void SetCountValue(string counterID, int countValue)
        {
            ExceptionHelper.CheckStringIsNullOrEmpty(counterID, "counterID");
            ExceptionHelper.TrueThrow(countValue < 0, "计数值不能小于零");

            using (DbContext dbi = DbHelper.GetDBContext(ConnectionDefine.DBConnectionName))
            {
                Database db = DatabaseFactory.Create(dbi);
                db.ExecuteScalar("WF.SetCountValue", PrepareParameters(counterID, countValue));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取当前用户待办和待阅数量
        /// </summary>
        /// <param name="userID">用户的ID</param>
        /// <returns>查询结果</returns>
        public UserTaskCount GetUserTaskCount(string userID)
        {
            using (DbContext context = DbHelper.GetDBContext(ConnectionDefine.DBConnectionName))
            {
                Database db = DatabaseFactory.Create(context);

                DataTable table = db.ExecuteDataSet("WF.QueryUserTaskCount", userID).Tables[0];

                return(new UserTaskCount(table));
            }
        }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获得materialID对应的附件对象的所有版本和本身形成的树
        /// 对应的存储过程GetMaterialVersions不存在
        /// </summary>
        /// <param name="mainMaterialID">主版本ID</param>
        /// <returns>以主版本为跟节点各版本为子节点的树</returns>
        //[Obsolete("对应的存储过程GetMaterialVersions不存在")]
        public MaterialTreeNode LoadMaterialVersionsByMaterialID(string mainMaterialID)
        {
            ExceptionHelper.CheckStringIsNullOrEmpty(mainMaterialID, "mainMaterialID");

            MaterialList materials = new MaterialList();

            using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName()))
            {
                Database db = DatabaseFactory.Create(dbi);

                using (SqlCommand dbc = new SqlCommand())
                {
                    SqlParameter sqlParameter = new SqlParameter();
                    sqlParameter.Value         = mainMaterialID;
                    sqlParameter.SqlDbType     = SqlDbType.NVarChar;
                    sqlParameter.Size          = 36;
                    sqlParameter.ParameterName = "@mainMaterialID";
                    sqlParameter.SourceColumn  = "@mainMaterialID";
                    sqlParameter.Direction     = ParameterDirection.InputOutput;

                    dbc.CommandType = CommandType.StoredProcedure;
                    dbc.CommandText = "GetMaterialVersions";
                    dbc.Parameters.Add(sqlParameter);

                    using (IDataReader dr = db.ExecuteReader(dbc))
                    {
                        while (dr.Read())
                        {
                            Material material = new Material();

                            ORMapping.DataReaderToObject(dr, material);

                            materials.Add(material);
                        }
                    }

                    mainMaterialID = sqlParameter.Value.ToString();
                }
            }

            return(GenerateMaterialVersionTree(materials, mainMaterialID));
        }
Exemplo n.º 13
0
        /// <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);
        }
Exemplo n.º 14
0
        public UserTaskCollection GetUserAccomplishedTasks(UserTaskIDType idType, UserTaskFieldDefine returnFields, bool nolock, params string[] ids)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(ids != null, "ids");

            UserTaskCollection utc = new UserTaskCollection();

            if (ids.Length > 0)
            {
                ORMappingItem keyItem = GetMappingItemFromIDType(idType);

                InSqlClauseBuilder iBuilder = new InSqlClauseBuilder();

                iBuilder.AppendItem(ids);

                string sql = string.Format("SELECT {0} FROM WF.USER_ACCOMPLISHED_TASK{1} WHERE {2} {3}",
                                           GetUserTaskSelectFields(returnFields),
                                           nolock ? "(NOLOCK)" : string.Empty,
                                           GetMappingItemFromIDType(idType).DataFieldName,
                                           iBuilder.ToSqlStringWithInOperator(TSqlBuilder.Instance));

                using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName()))
                {
                    Database db = DatabaseFactory.Create(dbi);

                    using (IDataReader dr = db.ExecuteReader(CommandType.Text, sql))
                    {
                        while (dr.Read())
                        {
                            UserTask ut = new UserTask();

                            ORMapping.DataReaderToObject(dr, ut);

                            utc.Add(ut);
                        }
                    }
                }
            }

            return(utc);
        }