/// <summary> /// /// </summary> /// <param name="ids"></param> /// <returns>无法删除的ID列表</returns> public string[] Delete(string[] ids) { StringBuilder strBuilder = new StringBuilder(); List <string> result = new List <string>(); foreach (string id in ids) { if (CheckScheduleInJob(id)) { result.Add(id); continue; } WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); whereBuilder.AppendItem("SCHEDULE_ID", id); whereBuilder.AppendTenantCode(typeof(JobSchedule)); strBuilder.Append(DELETE_JOB_SCHEDULE_DEF_SQL_CLAUSE); strBuilder.Append(whereBuilder.ToSqlString(TSqlBuilder.Instance)); strBuilder.Append(TSqlBuilder.Instance.DBStatementSeperator); } if (!string.IsNullOrEmpty(strBuilder.ToString())) { using (TransactionScope tran = TransactionScopeFactory.Create()) { DbHelper.RunSqlWithTransaction(strBuilder.ToString(), GetConnectionName()); tran.Complete(); } } return(result.ToArray()); }
/// <summary> /// 按照ResourceID来更新数据 /// </summary> /// <param name="resourceID"></param> /// <param name="assignees"></param> public virtual void Update(string resourceID, TTaskAssigneeCollection assignees) { resourceID.CheckStringIsNullOrEmpty("resourceID"); assignees.NullCheck("assignees"); StringBuilder strB = new StringBuilder(); ORMappingItemCollection mappings = GetMappingInfo(new Dictionary <string, object>()); WhereSqlClauseBuilder wBuilder = new WhereSqlClauseBuilder(); wBuilder.AppendItem("RESOURCE_ID", resourceID); wBuilder.AppendTenantCode(); strB.AppendFormat("DELETE {0} WHERE {1}", mappings.TableName, wBuilder.ToSqlString(TSqlBuilder.Instance)); foreach (TTaskAssignee assignee in assignees) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); InsertSqlClauseBuilder builder = ORMapping.GetInsertSqlClauseBuilder(assignee, mappings); strB.AppendFormat("INSERT INTO {0}{1}", mappings.TableName, builder.ToSqlString(TSqlBuilder.Instance)); } DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); }
public int Delete(string[] ids) { InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("JOB_ID"); inBuilder.AppendItem(ids); int result = 0; if (inBuilder.Count > 0) { ConnectiveSqlClauseCollection builder = new ConnectiveSqlClauseCollection(inBuilder, new WhereSqlClauseBuilder().AppendTenantCode(typeof(InvokeWebServiceJob))); string where = builder.ToSqlString(TSqlBuilder.Instance); StringBuilder sqlString = new StringBuilder(); sqlString.AppendFormat("DELETE FROM WF.JOB_SCHEDULES WHERE {0} ", where); sqlString.Append(TSqlBuilder.Instance.DBStatementSeperator); sqlString.AppendFormat("DELETE FROM WF.JOB_INVOKE_SERVICE WHERE {0} ", where); sqlString.Append(TSqlBuilder.Instance.DBStatementSeperator); sqlString.AppendFormat("DELETE FROM WF.JOB_START_WORKFLOW WHERE {0} ", where); sqlString.Append(TSqlBuilder.Instance.DBStatementSeperator); sqlString.AppendFormat("DELETE WF.JOBS WHERE {0} ", where); result = DbHelper.RunSqlWithTransaction(sqlString.ToString()); } return(result); }
private static int SendBlockUserTasks(UserTaskCollection tasks, int startIndex, int count) { StringBuilder strB = new StringBuilder(2408); int i = startIndex; while (i < tasks.Count && i - startIndex < count) { UserTask userTask = tasks[i]; if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } strB.Append(GetUserTaskInsertSql(userTask)); i++; } if (strB.Length > 0) { DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); } return(i); }
/// <summary> /// 解锁 /// </summary> /// <param name="lockEntity">锁实体</param> public static void Unlock(params Lock[] lockEntity) { ExceptionHelper.FalseThrow <ArgumentNullException>(lockEntity != null, "lockEntity"); StringBuilder strWhere = new StringBuilder(255); for (int i = 0; i < lockEntity.Length; i++) { if (strWhere.Length > 0) { strWhere.Append(" OR "); } WhereSqlClauseBuilder objWCB = new WhereSqlClauseBuilder(); objWCB.AppendItem("LOCK_ID", lockEntity[i].LockID); objWCB.AppendItem("LOCK_PERSON_ID", lockEntity[i].PersonID); objWCB.AppendTenantCode(); strWhere.AppendFormat("({0})", objWCB.ToSqlString(TSqlBuilder.Instance)); } if (strWhere.Length > 0) { string sql = string.Format("DELETE FROM WF.LOCK WHERE {0}", strWhere.ToString()); DbHelper.RunSqlWithTransaction(sql); } }
public void Update(WfAclItemCollection aclItems) { aclItems.NullCheck("aclItems"); WfAclItemCollection existedAcl = GetAclFromAclResourceIDs(aclItems); StringBuilder strB = new StringBuilder(); foreach (WfAclItem item in aclItems) { if (existedAcl.Exists(a => string.Compare(a.ResourceID, item.ResourceID, true) == 0 && string.Compare(a.ObjectID, item.ObjectID, true) == 0) == false) { if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } strB.Append(ORMapping.GetInsertSql(item, TSqlBuilder.Instance)); } } if (strB.Length > 0) { DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); } }
public void Push(params T[] tasks) { if (tasks != null) { StringBuilder strB = new StringBuilder(); foreach (T task in tasks) { if (task != null) { if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } strB.Append(this.GetInsertSql(task, this.GetMappingInfo(), GetFixedContext(), StringExtension.EmptyStringArray)); } } if (strB.Length > 0) { DbHelper.RunSqlWithTransaction(strB.ToString(), this.GetConnectionName()); } } }
public int Delete(string[] ids) { InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("JOB_ID"); inBuilder.AppendItem(ids); int result = 0; if (inBuilder.Count > 0) { string where = inBuilder.ToSqlString(TSqlBuilder.Instance); StringBuilder sqlString = new StringBuilder(); sqlString.AppendFormat("DELETE FROM WF.JOB_SCHEDULES WHERE {0} ", where); sqlString.Append(TSqlBuilder.Instance.DBStatementSeperator); sqlString.AppendFormat("DELETE FROM WF.JOB_INVOKE_SERVICE WHERE {0} ", where); sqlString.Append(TSqlBuilder.Instance.DBStatementSeperator); sqlString.AppendFormat("DELETE FROM WF.JOB_START_WORKFLOW WHERE {0} ", where); sqlString.Append(TSqlBuilder.Instance.DBStatementSeperator); sqlString.AppendFormat("DELETE WF.JOBS WHERE {0} ", where); result = DbHelper.RunSqlWithTransaction(sqlString.ToString(), this.GetConnectionName()); } return(result); }
public void UpdateProcessStatus(IEnumerable <IWfProcess> processes) { processes.NullCheck("processes"); StringBuilder strB = new StringBuilder(); foreach (IWfProcess process in processes) { if (process.SearchID.IsNotEmpty()) { if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder(); builder.AppendItem("RESOURCE_ID", process.SearchID); builder.AppendTenantCode(typeof(AppCommonInfo)); strB.AppendFormat("UPDATE WF.APPLICATIONS_COMMON_INFO SET COMPLETED_FLAG = {0} WHERE {1}", (int)AppCommonInfo.ConvertProcessStatusToCompletedFlag(process.Status), builder.ToSqlString(TSqlBuilder.Instance)); } } if (strB.Length > 0) { DbHelper.RunSqlWithTransaction(strB.ToString(), this.GetConnectionName()); } }
private static void eventContainer_SetUserTasksAccomplished(UserTaskCollection tasks, Dictionary <object, object> context) { ExceptionHelper.FalseThrow <ArgumentNullException>(tasks != null, "tasks"); //需要删除的待办的ID InSqlClauseBuilder deleteTaskIDs = new InSqlClauseBuilder(); StringBuilder strB = new StringBuilder(); ORMappingItemCollection mapping = ORMapping.GetMappingInfo <UserTask>().Clone(); string userTaskTableName = mapping.TableName; mapping.TableName = "WF.USER_ACCOMPLISHED_TASK"; foreach (UserTask task in tasks) { UserTask clonedUserTask = GetClonedAccomplishedUserTask(task); if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } WhereSqlClauseBuilder builder = GetDeleteAccomplishedUserTaskWhereBuilder(task); //删除已办 strB.AppendFormat("DELETE {0} WHERE {1}", mapping.TableName, builder.ToSqlString(TSqlBuilder.Instance)); strB.Append(TSqlBuilder.Instance.DBStatementSeperator); strB.Append(GetUserTaskInsertSql(clonedUserTask, mapping, "Category", "TopFlag")); strB.Append(TSqlBuilder.Instance.DBStatementSeperator); deleteTaskIDs.AppendItem(task.TaskID); } if (strB.Length > 0 && deleteTaskIDs.IsEmpty == false) { //删除待办 strB.AppendFormat("DELETE {0} WHERE TASK_GUID {1}", userTaskTableName, deleteTaskIDs.ToSqlStringWithInOperator(TSqlBuilder.Instance)); } if (strB.Length > 0) { DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); } }
internal void SetStartJobStatus(JobBase data) { WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder(); builder.AppendItem("JOB_ID", data.JobID); DbHelper.RunSqlWithTransaction(string.Format("UPDATE WF.JOBS SET LAST_START_EXE_TIME = {0}, JOB_STATUS = {1} WHERE {2}", TSqlBuilder.Instance.FormatDateTime(data.LastStartExecuteTime.Value), (int)data.Status, builder.ToSqlString(TSqlBuilder.Instance)), this.GetConnectionName()); }
/// <summary> /// 删除待办箱分类 /// </summary> /// <param name="categoryGuid">处理夹ID</param> public void DeleteCategory(string categoryID) { WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder(); builder.AppendItem("CATEGORY_GUID", categoryID); builder.AppendTenantCode(typeof(TaskCategory)); string strSql = "UPDATE USER_TASK SET CATEGORY_GUID = NULL WHERE " + builder.ToSqlString(TSqlBuilder.Instance) + ";"; strSql += " DELETE WF.USER_TASK_CATEGORY WHERE " + builder.ToSqlString(TSqlBuilder.Instance); DbHelper.RunSqlWithTransaction(strSql, ConnectionDefine.DBConnectionName); }
public void Insert(IEnumerable <EmailMessage> messages) { messages.NullCheck("messages"); messages.ForEach(m => m.Attachments.ForEach(ea => ea.PrepareContent())); StringBuilder strB = new StringBuilder(2048); using (StringWriter writer = new StringWriter(strB)) { messages.ForEach(m => WriteInsertMessageSql(writer, m)); } DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); }
/// <summary> /// 强制解锁 /// </summary> /// <param name="lockIDs">锁ID</param> public static void ForceUnlock(params string[] lockIDs) { ExceptionHelper.FalseThrow <ArgumentNullException>(lockIDs != null, "lockID"); InSqlClauseBuilder builder = new InSqlClauseBuilder("LOCK_ID"); for (int i = 0; i < lockIDs.Length; i++) { builder.AppendItem(lockIDs[i]); } if (builder.Count > 0) { string sql = string.Format("DELETE FROM WF.LOCK WHERE {0}", builder.AppendTenantCodeSqlClause().ToSqlString(TSqlBuilder.Instance)); DbHelper.RunSqlWithTransaction(sql); } }
public void BulkAdd(InvalidAssignessUrlCollection data) { ORMappingItemCollection mappings = ORMapping.GetMappingInfo <InvalidAssigneeUrl>(); StringBuilder sqlStrB = new StringBuilder(); foreach (InvalidAssigneeUrl item in data) { if (sqlStrB.Length > 0) { sqlStrB.Append(TSqlBuilder.Instance.DBStatementSeperator); } sqlStrB.Append(ORMapping.GetInsertSql(item, mappings, TSqlBuilder.Instance)); } DbHelper.RunSqlWithTransaction(sqlStrB.ToString(), this.GetConnectionName()); }
public void Update(CommonInfoMappingCollection cimItems) { cimItems.NullCheck("cimItems"); string sqlString = string.Empty; StringBuilder strB = new StringBuilder(); ConnectiveSqlClauseCollection connective = new ConnectiveSqlClauseCollection(LogicOperatorDefine.Or); foreach (CommonInfoMapping cim in cimItems) { if (cim.ResourceID.IsNotEmpty() && cim.ProcessID.IsNotEmpty()) { if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } WhereSqlClauseBuilder wBuilder = new WhereSqlClauseBuilder(); wBuilder.AppendItem("RESOURCE_ID", cim.ResourceID); wBuilder.AppendItem("PROCESS_ID", cim.ProcessID); wBuilder.AppendTenantCode(typeof(CommonInfoMapping)); connective.Add(wBuilder); strB.Append(TSqlBuilder.Instance.DBStatementSeperator); strB.Append(ORMapping.GetInsertSql(cim, TSqlBuilder.Instance)); } } if (connective.Count > 0) { sqlString = string.Format("DELETE WF.COMMON_INFO_MAPPING WHERE {0}", connective.ToSqlString(TSqlBuilder.Instance)); sqlString += strB.ToString(); } if (sqlString.Length > 0) { DbHelper.RunSqlWithTransaction(sqlString, WorkflowSettings.GetConfig().ConnectionName); } }
/// <summary> /// 删除EmailMessage /// </summary> /// <param name="action"></param> public void Delete(Action <WhereSqlClauseBuilder> action) { action.NullCheck("action"); WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder(); action(builder); builder.AppendTenantCode(); StringBuilder strB = new StringBuilder(); using (StringWriter writer = new StringWriter(strB)) { WriteDeleteEmailAddressesSql(writer, builder); WriteDeleteEmailAttachmentsSql(writer, builder); writer.WriteLine("DELETE MSG.EMAIL_MESSAGES WHERE {0}", builder.ToSqlString(TSqlBuilder.Instance)); } DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); }
/// <summary> /// 更新相关的数据。先删除某个ResouceID和ClassName下相关的数据,然后再插入集合中的数据 /// </summary> /// <typeparam name="TRelative"></typeparam> /// <param name="resourceID"></param> /// <param name="className"></param> /// <param name="dataCollection"></param> public virtual void UpdateRelativeData <TRelative>(string resourceID, string className, IEnumerable <TRelative> dataCollection) where TRelative : GenericFormRelativeData { resourceID.CheckStringIsNullOrEmpty("resourceID"); className.CheckStringIsNullOrEmpty("className"); WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder(); builder.AppendItem("RESOURCE_ID", resourceID).AppendItem("CLASS", className); builder.AppendTenantCode(typeof(TRelative)); StringBuilder strB = new StringBuilder(); strB.AppendFormat("DELETE WF.GENERIC_FORM_RELATIVE_DATA WHERE {0}", builder.ToSqlString(TSqlBuilder.Instance)); int i = 0; foreach (TRelative data in dataCollection) { data.ResourceID = resourceID; data.Class = className; strB.Append(TSqlBuilder.Instance.DBStatementSeperator); InsertSqlClauseBuilder insertBuilder = ORMapping.GetInsertSqlClauseBuilder(data, "ResourceID", "Class", "SortID", "XmlContent"); data.SortID = i++; insertBuilder.AppendItem("RESOURCE_ID", resourceID).AppendItem("CLASS", className).AppendItem("SORT_ID", data.SortID); XmlDocument xdoc = XmlHelper.SerializeObjectToXml(data); data.XmlContent = xdoc.OuterXml; insertBuilder.AppendItem("XML_CONTENT", xdoc.OuterXml); strB.AppendFormat("INSERT WF.GENERIC_FORM_RELATIVE_DATA{0}", insertBuilder.ToSqlString(TSqlBuilder.Instance)); } DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); }
public void Delete(string roleID) { roleID.CheckStringIsNullOrEmpty("roleID"); StringBuilder strB = new StringBuilder(1024); strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_ROWS WHERE {0}", roleID.ToRoleIDCriteria()); strB.Append(TSqlBuilder.Instance.DBStatementSeperator); strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_CELLS WHERE {0}", roleID.ToRoleIDCriteria()); strB.Append(TSqlBuilder.Instance.DBStatementSeperator); strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_USER_CONTAINERS WHERE {0}", roleID.ToRoleIDCriteria()); DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); CacheNotifyData notifyData = new CacheNotifyData(typeof(SOARolePropertiesCache), roleID.ToRoleIDCacheKey(), CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
public int Delete(string[] ids) { StringBuilder strBuilder = new StringBuilder(); InSqlClauseBuilder builder = new InSqlClauseBuilder("JOB_ID"); builder.AppendItem(ids); int result = 0; if (builder.Count > 0) { strBuilder.AppendFormat("{0} {1}", DELETE_JOBS_SQL_CLAUSE, builder.AppendTenantCodeSqlClause().ToSqlString(TSqlBuilder.Instance)); strBuilder.Append(GetJobSchedulesDeleteClause(ids)); result = DbHelper.RunSqlWithTransaction(strBuilder.ToString(), GetConnectionName()); } return(result); }
public int Delete(string[] ids) { InSqlClauseBuilder builder = new InSqlClauseBuilder("JOB_ID"); builder.AppendItem(ids); int result = 0; if (builder.Count > 0) { string sql = string.Format("{0} {1}", DELETE_JOB_START_WORKFLOW_SQL_CLAUSE, builder.ToSqlString(TSqlBuilder.Instance)); using (TransactionScope tran = TransactionScopeFactory.Create()) { JobBaseAdapter.Instance.Delete(ids); result = DbHelper.RunSqlWithTransaction(sql, GetConnectionName()); tran.Complete(); } } return(result); }
/// <summary> /// 替换已经存在的相关子对象数据 /// </summary> /// <typeparam name="TRelative"></typeparam> /// <param name="dataCollection"></param> public virtual void ReplaceRelativeData <TRelative>(IEnumerable <TRelative> dataCollection) where TRelative : GenericFormRelativeData { dataCollection.NullCheck("dataCollection"); StringBuilder strB = new StringBuilder(); foreach (TRelative data in dataCollection) { if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } UpdateSqlClauseBuilder updateBuilder = ORMapping.GetUpdateSqlClauseBuilder(data, "ResourceID", "Class", "SortID", "XmlContent"); updateBuilder.AppendItem("RESOURCE_ID", data.ResourceID).AppendItem("CLASS", data.Class).AppendItem("SORT_ID", data.SortID); XmlDocument xdoc = XmlHelper.SerializeObjectToXml(data); data.XmlContent = xdoc.OuterXml; updateBuilder.AppendItem("XML_CONTENT", xdoc.OuterXml); WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); whereBuilder.AppendItem("RESOURCE_ID", data.ResourceID).AppendItem("CLASS", data.Class).AppendItem("SORT_ID", data.SortID); whereBuilder.AppendTenantCode(typeof(TRelative)); strB.AppendFormat("UPDATE WF.GENERIC_FORM_RELATIVE_DATA SET {0} WHERE {1}", updateBuilder.ToSqlString(TSqlBuilder.Instance), whereBuilder.ToSqlString(TSqlBuilder.Instance)); } if (strB.Length > 0) { DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName()); } }
/// <summary> /// 更新待办箱分类 /// </summary> /// <param name="taskCategory">处理夹对象</param> public void UpdateCategory(TaskCategory taskCategory) { string strSql = ORMapping.GetUpdateSql(taskCategory, TSqlBuilder.Instance); DbHelper.RunSqlWithTransaction(strSql, ConnectionDefine.DBConnectionName); }
/// <summary> /// 添加待办箱分类 /// </summary> /// <param name="taskCategory">处理夹对象</param> public void InsertCategory(TaskCategory taskCategory) { string strSql = ORMapping.GetInsertSql(taskCategory, TSqlBuilder.Instance); DbHelper.RunSqlWithTransaction(strSql); }