void LoadWaitTasks() { if (_taskIds == null) { DbTableDmlMgr dmlMgr = _daMgr.DbCatalogGetTableDmlMgr(DataAccess.Constants.SCHEMA_CORE , TaskProcessing.Constants.TaskProcessingQueue , TaskProcessing.Constants.TaskQueueCode , TaskProcessing.Constants.TaskId); dmlMgr.SetWhereCondition(w => w.Column(TaskProcessing.Constants.TaskQueueCode) != w.Parameter(TaskProcessing.Constants.TaskQueueCode)); DbCommand dbCmd = _daMgr.BuildSelectDbCommand(dmlMgr, null); dbCmd.Parameters[_daMgr.BuildParamName(TaskProcessing.Constants.TaskQueueCode)].Value = _taskQueueCode; _taskIds = _daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]; foreach (DataRow taskId in _taskIds.Rows) { cmbWaitTasks.Items.Add(string.Format("{0}:{1}" , taskId[TaskProcessing.Constants.TaskQueueCode] , taskId[TaskProcessing.Constants.TaskId])); if (_taskQueueItem != null && taskId[TaskProcessing.Constants.TaskQueueCode].ToString() == _taskQueueItem[TaskProcessing.Constants.WaitTaskQueueCode].ToString()) { cmbWaitTasks.SelectedIndex = cmbWaitTasks.Items.Count - 1; } } } }
#pragma warning restore 1591 // restore the xmlComments warning /// <summary> /// Returns the entire data table of application session records in the /// database based on the given enumeration. /// </summary> /// <param name="daMgr">DataAccessMgr object</param> /// <param name="tpqList">Enumeration indicating what type of session records to return</param> /// <returns>DataTable of Task Processing Queue records</returns> public static DataTable TaskProcessingQueueList(DataAccessMgr daMgr, ListEnum tpqList) { DbCommand dbCmd; switch (tpqList) { case ListEnum.Queued: dbCmd = daMgr.DbCmdCacheGetOrAdd("BuildCmdGetTPQListByWaitDateTime" , BuildCmdGetTPQListByWaitDateTime); dbCmd.Parameters[daMgr.BuildParamName(Constants.StatusCode)].Value = Convert.ToByte(tpqList); break; case ListEnum.Failed: case ListEnum.Succeeded: case ListEnum.InProcess: case ListEnum.NotQueued: dbCmd = daMgr.DbCmdCacheGetOrAdd("BuildCmdGetTPQListByStatusDateTime" , BuildCmdGetTPQListByStatusDateTime); dbCmd.Parameters[daMgr.BuildParamName(Constants.StatusCode)].Value = Convert.ToByte(tpqList); break; default: dbCmd = daMgr.DbCmdCacheGetOrAdd("BuildCmdGetTPQListByTaskId", BuildCmdGetTPQListByTaskId); break; } return(daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]); }
/// <summary> /// Returns the list of registered tasks as a datatable /// </summary> /// <param name="daMgr">DataAccess manager object</param> /// <returns></returns> public static DataTable GetRegisteredTasks(DataAccessMgr daMgr) { DbCommand dbCmd = daMgr.DbCmdCacheGetOrAdd(Constants.TaskRegistrationList , BuildCmdGetRegisteredTasksList); return(daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]); }
/// <summary> /// Loads the access control rules for the given user's access control group /// </summary> /// <returns>Access control rules for the given user's access control group</returns> AccessControlGroupStructure LoadAccessControl() { if (!_accessControlCache.Exists(_userSignon.DefaultAccessGroupCode.ToString())) { AccessControlGroupStructure accessControlGroup = new AccessControlGroupStructure(); accessControlGroup.AccessGroupCode = _userSignon.DefaultAccessGroupCode; CacheMgr <bool> accessControlRules = new CacheMgr <bool>(); DbCommand dbCmd = _daMgr.DbCmdCacheGetOrAdd(Constants.AccessControlGroupRules, BuildCmdGetAccessControlRulesList); dbCmd.Parameters[_daMgr.BuildParamName(Constants.AccessControlGroupCode)].Value = _userSignon.DefaultAccessGroupCode; DataTable accessRules = _daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]; foreach (DataRow accessRule in accessRules.Rows) { accessControlGroup.DefaultAccessDenied = Convert.ToBoolean( accessRule[Constants.DefaultAccessDenied]); accessControlGroup.AccessGroupName = accessRule[Constants.AccessControlGroupName].ToString(); if (accessRule[Constants.UIControlCode] != DBNull.Value) { Int32 uiControlCode = Convert.ToInt32(accessRule[Constants.UIControlCode]); bool accessDenied = Convert.ToBoolean(accessRule[Constants.AccessDenied]); accessControlRules.Set(uiControlCode.ToString(), accessDenied); } accessControlGroup.AccessControlRules = accessControlRules; } _accessControlCache.Set(_userSignon.DefaultAccessGroupCode.ToString(), accessControlGroup); } return(_accessControlCache.Get(_userSignon.DefaultAccessGroupCode.ToString())); }
/// <summary> /// Builds the DbCommand to get a list of the given task's dependency records /// </summary> /// <param name="daMgr">DataAccessMgr object</param> /// <param name="taskQueueCode">Unique identifier of the task whose dependencies will be returned</param> /// <returns>DateTable of the given task's dependencies</returns> public static DataTable TaskDependenciesList(DataAccessMgr daMgr, Int32 taskQueueCode) { DbCommand dbCmd = daMgr.DbCmdCacheGetOrAdd("BuildCmdGetTaskDependencies" , BuildCmdGetTaskDependencies); dbCmd.Parameters[daMgr.BuildParamName(Constants.TaskQueueCode)].Value = taskQueueCode; return(daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]); }
/// <summary> /// The only constructor. /// </summary> /// <param name="daMgr">DataAccessMgr object</param> internal SignonControl(DataAccessMgr daMgr) { _daMgr = daMgr; DataTable dt = _daMgr.ExecuteDataSet(_daMgr.BuildSelectDbCommand( "select * from " + DataAccess.Constants.SCHEMA_CORE + "." + Constants.SignonControl , null), null, null).Tables[0]; Refresh(dt); }
/// <summary> /// Returns the set of dependency relationships where the given task is the dependent task /// </summary> /// <param name="daMgr">DbAccessMgr object instance</param> /// <param name="waitTaskQueueCode">The taskQueueCode that other tasks may be dependent on</param> /// <returns>The DataTable of dependency relationhips</returns> public static DataTable GetDependentTasks(DataAccessMgr daMgr , Int32 waitTaskQueueCode) { DbCommand dbCmd = daMgr.DbCmdCacheGetOrAdd("GetDependentTasksCmd", GetDependentTasksCmd); dbCmd.Parameters[daMgr.BuildParamName(TaskProcessing.Constants.WaitTaskQueueCode)].Value = waitTaskQueueCode; return(daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]); }
void LoadTaskIds() { if (_taskIds == null) { DbTableDmlMgr dmlMgr = _daMgr.DbCatalogGetTableDmlMgr(DataAccess.Constants.SCHEMA_CORE , TaskProcessing.Constants.TaskRegistrations, TaskProcessing.Constants.TaskId); _taskIds = _daMgr.ExecuteDataSet(_daMgr.BuildSelectDbCommand(dmlMgr, null), null, null).Tables[0]; foreach (DataRow taskId in _taskIds.Rows) { cmbTaskId.Items.Add(taskId[TaskProcessing.Constants.TaskId].ToString()); } } }
#pragma warning restore 1591 // restore the xmlComments warning /// <summary> /// Returns the entire data table of user session records in the /// database based on the given enumeration. /// </summary> /// <param name="daMgr">DataAccessMgr object</param> /// <param name="userSessionList">Enumeration indicating what type of session records to return</param> /// <returns>DataTable of application session records</returns> public static DataTable UserSessions(DataAccessMgr daMgr, UserSessionListEnum userSessionList) { DbCommand dbCmd; if (userSessionList == UserSessionListEnum.AllUserSessions) { dbCmd = daMgr.DbCmdCacheGetOrAdd(userSessionList.ToString(), BuildCmdGetAllUserSessionsList); } else if (userSessionList == UserSessionListEnum.ActiveUserSessions) { dbCmd = daMgr.DbCmdCacheGetOrAdd(userSessionList.ToString(), BuildCmdGetActiveUserSessionsList); } else { dbCmd = daMgr.DbCmdCacheGetOrAdd(userSessionList.ToString(), BuildCmdGetInActiveUserSessionsList); } return(daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]); }
/// <summary> /// Constructor for a new application session which verifies AppId. /// <para>To begin a new session, the Start method must be called.</para> /// </summary> /// <param name="daMgr">DataAccessMgr object</param> /// <param name="appId">Application's unique string identifier</param> /// <param name="appVersion">Application's version string</param> /// <param name="appName">Applications's name</param> /// <param name="heartBeatStatusHdlr">The application's delegate to call during every heartbeat to get the status</param> public AppSession(DataAccessMgr daMgr , string appId , string appVersion , string appName , HeartbeatStatusHandler heartBeatStatusHdlr) { _daMgr = daMgr; _appId = appId; _appName = appName; _appVersion = appVersion; _heartbeatStatusHdlr = heartBeatStatusHdlr; _signonControl = new SignonControl(_daMgr); DbTableDmlMgr dmlSelectMgr = _daMgr.DbCatalogGetTableDmlMgr(DataAccess.Constants.SCHEMA_CORE , Constants.AppMaster, Constants.AppCode, Constants.AllowMultipleSessions); dmlSelectMgr.SetWhereCondition((j) => j.Column(Constants.AppId) == j.Parameter(dmlSelectMgr.MainTable.SchemaName , dmlSelectMgr.MainTable.TableName , Constants.AppId , _daMgr.BuildParamName(Constants.AppId))); DbCommand cmdSelect = _daMgr.BuildSelectDbCommand(dmlSelectMgr, null); cmdSelect.Parameters[_daMgr.BuildParamName(Constants.AppId)].Value = appId; DataTable appMaster = _daMgr.ExecuteDataSet(cmdSelect, null, null).Tables[0]; if (appMaster.Rows.Count == 0) { throw new ExceptionEvent(enumExceptionEventCodes.AppCodeNotFound , string.Format("AppId: {0}", appId)); } _appCode = Convert.ToInt32(appMaster.Rows[0][Constants.AppCode]); _allowMultipleSessions = Convert.ToBoolean(appMaster.Rows[0][Constants.AllowMultipleSessions]); if (!_allowMultipleSessions) { _appSessionCode = 0; } else { _appSessionCode = _daMgr.GetNextSequenceNumber(Constants.MultipleSessionCode); } }
/// <summary> /// Executes the given DbCommand and returns the result. /// If a DbException is raised and a logger class had been provided, /// the method will attempt to Log a debug text version of the dbCommand /// that is backend specific or just log the exception. /// In either case, the exception will be thrown. /// If the string[] of TableNames is provided, then the tables in the /// resulting dataset will be renamed appropriately. /// </summary> /// <param name="dbCommand">Database Command Object to execute.</param> /// <param name="tableNames">List of table names for that tables of the dataset.</param> /// <returns>Returns Dataset with named tables.</returns> private DataSet ExecuteDataSet(DbCommand dbCommand, List <string> tableNames) { return(_daMgr.ExecuteDataSet(dbCommand, dbCommand.Transaction, tableNames, null)); }
DataTable GetSessionControlData() { return(_daMgr.ExecuteDataSet(_daMgr.BuildSelectDbCommand("select * from B1.AppSessionControl", null), null, null).Tables[0]); }