internal static string ProvideSetting(string settingKey) { string returnValue = string.Empty; string sqlQuery = "select APPSETNG_VALUE,ADS_DEF_VALUE from APP_SETTINGS where APPSETNG_KEY= N'" + settingKey + "'"; using (OsaDirectEAManager.Database dbSetting = new OsaDirectEAManager.Database()) { DbCommand cmdSetting = dbSetting.GetSqlStringCommand(sqlQuery); DbDataReader drSettings = dbSetting.ExecuteReader(cmdSetting, CommandBehavior.CloseConnection); if (drSettings.HasRows) { drSettings.Read(); returnValue = drSettings["APPSETNG_VALUE"].ToString(); if (string.IsNullOrEmpty(returnValue)) { returnValue = drSettings["ADS_DEF_VALUE"].ToString(); } } if (drSettings != null && drSettings.IsClosed == false) { drSettings.Close(); } } return(returnValue); }
public static bool isCostCenter(string costCenter) { bool returnValue = false; string sqlQuery = "select COSTCENTER_ID from M_COST_CENTERS where COSTCENTER_ID = " + costCenter + " "; using (OsaDirectEAManager.Database dbSetting = new OsaDirectEAManager.Database()) { DbCommand cmdSetting = dbSetting.GetSqlStringCommand(sqlQuery); DbDataReader drSettings = dbSetting.ExecuteReader(cmdSetting, CommandBehavior.CloseConnection); if (drSettings.HasRows) { returnValue = true; } else { returnValue = false; } if (drSettings != null && drSettings.IsClosed == false) { drSettings.Close(); } } return(returnValue); }
public static int ValidatePrintUser(string printUser, out string userCostCenter) { int printUserAccountID = 100; // Annonymous Print User string userGroup = ""; using (OsaDirectEAManager.Database database = new OsaDirectEAManager.Database()) { string sqlQuery = string.Format("select USR_ACCOUNT_ID, USR_SOURCE, USR_PASSWORD,USR_COSTCENTER from M_USERS where USR_ID ='{0}' order by USR_SOURCE", printUser); DbDataReader drUserDetails = database.ExecuteReader(database.GetSqlStringCommand(sqlQuery)); if (drUserDetails.HasRows) { drUserDetails.Read(); string accountID = drUserDetails["USR_ACCOUNT_ID"].ToString(); string userPassword = drUserDetails["USR_PASSWORD"].ToString(); string userSource = drUserDetails["USR_SOURCE"].ToString(); userGroup = drUserDetails["USR_COSTCENTER"].ToString(); if (!string.IsNullOrEmpty(accountID)) { printUserAccountID = int.Parse(accountID); } } if (drUserDetails != null && drUserDetails.IsClosed == false) { drUserDetails.Close(); } } userCostCenter = userGroup; return(printUserAccountID); }
public static bool ProviceOverDraftStatus(string selectedID, string limitsOn) { bool returnValue = false; string query = "select ALLOW_OVER_DRAFT from M_USERS where USR_ACCOUNT_ID='" + selectedID + "'"; if (limitsOn == "0") { query = "select ALLOW_OVER_DRAFT from M_COST_CENTERS where COSTCENTER_ID='" + selectedID + "'"; } using (OsaDirectEAManager.Database dbOverDraft = new OsaDirectEAManager.Database()) { DbDataReader drOverDraft = dbOverDraft.ExecuteReader(dbOverDraft.GetSqlStringCommand(query)); while (drOverDraft.Read()) { string value = drOverDraft["ALLOW_OVER_DRAFT"].ToString(); if (!string.IsNullOrEmpty(value)) { returnValue = bool.Parse(value); } } if (drOverDraft != null && drOverDraft.IsClosed == false) { drOverDraft.Close(); } } return(returnValue); }
/// <summary> /// Provides the job setting. /// </summary> /// <param name="settingKey">The setting key.</param> /// <returns></returns> /// <remarks> /// Sequence Diagram:<br/> /// <img src="SequenceDiagrams/SD_OsaDataProvider.Device.ProvideJobSetting.jpg"/> /// </remarks> public static bool ProvideJobSetting(string settingKey) { bool returnValue = false; string sqlQuery = "select * from JOB_CONFIGURATION where JOBSETTING_KEY=N'" + settingKey + "'"; using (OsaDirectEAManager.Database dbSetting = new OsaDirectEAManager.Database()) { DbCommand cmdSetting = dbSetting.GetSqlStringCommand(sqlQuery); DbDataReader drSettings = dbSetting.ExecuteReader(cmdSetting, CommandBehavior.CloseConnection); if (drSettings.HasRows) { drSettings.Read(); if (drSettings["JOBSETTING_VALUE"].ToString() == "Disable") { returnValue = false; } else { returnValue = true; } } if (drSettings != null && drSettings.IsClosed == false) { drSettings.Close(); } } return(returnValue); }
public static int ValidatePrintUser(string printUser, string printPassword, out string userCostCenter) { int printUserAccountID = 100; string userGroup = ""; using (OsaDirectEAManager.Database database = new OsaDirectEAManager.Database()) { string sqlQuery = string.Format("select USR_ACCOUNT_ID, USR_SOURCE, USR_PASSWORD,USR_COSTCENTER from M_USERS where USR_ID ='{0}' order by USR_SOURCE", printUser); DbDataReader drUserDetails = database.ExecuteReader(database.GetSqlStringCommand(sqlQuery)); while (drUserDetails.Read()) { string accountID = drUserDetails["USR_ACCOUNT_ID"].ToString(); string userPassword = drUserDetails["USR_PASSWORD"].ToString(); string userSource = drUserDetails["USR_SOURCE"].ToString(); userGroup = drUserDetails["USR_COSTCENTER"].ToString(); if (userSource == "DB") { if (userPassword == Protector.ProvideEncryptedPassword(printPassword)) { if (!string.IsNullOrEmpty(accountID)) { printUserAccountID = int.Parse(accountID); } } } else { string userDomain = ProvideDomainName(); if (!string.IsNullOrEmpty(userDomain)) { if (AppLibrary.AppAuthentication.isValidUser(printUser, printPassword, userDomain, userSource)) { if (!string.IsNullOrEmpty(accountID)) { printUserAccountID = int.Parse(accountID); } } } } } if (drUserDetails != null && drUserDetails.IsClosed == false) { drUserDetails.Close(); } } userCostCenter = userGroup; return(printUserAccountID); }
/// <summary> /// Gets the user details. /// </summary> /// <remarks> /// Sequence Diagram:<br/> /// <img src="SequenceDiagrams/SD_DataManager.Provider.Users.GetUserDetails.jpg" /> /// </remarks> /// <param name="authenticationType">Type of the authentication.</param> /// <param name="authenticationValue">The authentication value.</param> /// <returns>DbDataReader</returns> public static DbDataReader ProvideUserDetails(AuthenticationType authenticationType, string authenticationValue) { // TODO>> Get Device Authentication Type and return the user Details DbDataReader drUserdetails = null; string sqlQuery = "select * from M_USERS where ("; switch (authenticationType) { case AuthenticationType.UserSystemId: sqlQuery += string.Format(CultureInfo.CurrentCulture, " USR_ACCOUNT_ID = N'{0}' ", authenticationValue); break; case AuthenticationType.UserId: sqlQuery += string.Format(CultureInfo.CurrentCulture, " USR_ID = N'{0}' ", authenticationValue); break; case AuthenticationType.CardId: sqlQuery += string.Format(CultureInfo.CurrentCulture, " USR_CARD_ID = '{0}' ", authenticationValue); break; case AuthenticationType.PinNumber: sqlQuery += string.Format(CultureInfo.CurrentCulture, " USR_PIN = N'{0}' ", authenticationValue); break; case AuthenticationType.AnyOfThem: int validAccountID = 0; bool isValidAccountIDResult = int.TryParse(authenticationValue, out validAccountID); if (validAccountID != 0) { sqlQuery += string.Format(CultureInfo.CurrentCulture, " USR_ACCOUNT_ID = N'{0}' or USR_ID = N'{0}' or USR_CARD_ID = N'{0}' or USR_PIN =N'{0}'", authenticationValue); } else { sqlQuery += string.Format(CultureInfo.CurrentCulture, " USR_ID = N'{0}' or USR_CARD_ID = N'{0}' or USR_PIN =N'{0}'", authenticationValue); } break; default: sqlQuery += string.Format(CultureInfo.CurrentCulture, " USR_ACCOUNT_ID = '{0}' ", authenticationValue); break; } sqlQuery += ")"; OsaDirectEAManager.Database dbUserDetails = new OsaDirectEAManager.Database(); DbCommand cmdUserDetails = dbUserDetails.GetSqlStringCommand(sqlQuery); drUserdetails = dbUserDetails.ExecuteReader(cmdUserDetails); return(drUserdetails); }
/// <summary> /// Determines whether [is current job exist] [the specified file name]. /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns> /// <c>true</c> if [is current job exist] [the specified file name]; otherwise, <c>false</c>. /// </returns> public static bool IsCurrentJobExist(string fileName) { bool isCurrentJobExist = false; string query = "select * from T_CURRENT_JOBS where JOB_NAME = '" + fileName.Replace("'", "''") + "'"; using (OsaDirectEAManager.Database dbJobExist = new OsaDirectEAManager.Database()) { DbCommand cmdJob = dbJobExist.GetSqlStringCommand(query); DbDataReader drJobExist = dbJobExist.ExecuteReader(cmdJob, CommandBehavior.CloseConnection); if (drJobExist.HasRows) { isCurrentJobExist = true; } } return(isCurrentJobExist); }
/// <summary> /// Gets the departments by ID. /// </summary> /// <remarks> /// Sequence Diagram:<br/> /// <img src="SequenceDiagrams/SD_DataManager.Provider.Users.GetDepartmentsByID.jpg" /> /// </remarks> /// <param name="userID">The User ID.</param> /// <param name="authenticationType">The Authentication Type.</param> /// <returns>DataSet</returns> public static string ProvideUserDepartment(string userID, string authenticationType) { string sqlQuery = "select DEPT_NAME from M_DEPARTMENTS where DEPT_SOURCE = N'" + authenticationType + "' and REC_SLNO in (select USR_DEPARTMENT from M_USERS where USR_ID = N'" + userID + "' and USR_SOURCE = N'" + authenticationType + "')"; string returnValue = string.Empty; using (OsaDirectEAManager.Database dbDepartments = new OsaDirectEAManager.Database()) { DbCommand cmdDepartments = dbDepartments.GetSqlStringCommand(sqlQuery); DbDataReader drDepartment = dbDepartments.ExecuteReader(cmdDepartments); if (drDepartment.HasRows) { drDepartment.Read(); returnValue = drDepartment["DEPT_NAME"] as string; } if (drDepartment != null && drDepartment.IsClosed == false) { drDepartment.Close(); } } return(returnValue); }
/// <summary> /// Provides the name of the domain. /// </summary> /// <returns>string</returns> /// <remarks> /// Sequence Diagram:<br/> /// <img src="SequenceDiagrams/SD_DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideDomainName.jpg"/> /// </remarks> public static string ProvideDomainName() { string authenticationType = string.Empty; string sqlQuery = "select * from AD_SETTINGS where AD_SETTING_KEY = N'DOMAIN_NAME'"; using (OsaDirectEAManager.Database dbDomain = new OsaDirectEAManager.Database()) { DbCommand cmdDomain = dbDomain.GetSqlStringCommand(sqlQuery); DbDataReader drAuthType = dbDomain.ExecuteReader(cmdDomain, CommandBehavior.CloseConnection); if (drAuthType.HasRows) { drAuthType.Read();//APPSETNG_VALUE authenticationType = drAuthType["AD_SETTING_VALUE"].ToString(); } if (drAuthType != null && drAuthType.IsClosed == false) { drAuthType.Close(); } } return(authenticationType); }
/// <summary> /// Provides Authentication Type of specific device /// </summary> /// <param name="deviceIP">The Device IP.</param> /// <returns></returns> public static string ProvideDeviceAuthenticationType(string deviceIP) { string sqlQuery = "select MFP_LOGON_AUTH_SOURCE from M_MFPS where MFP_IP = N'" + deviceIP + "'"; string returnValue = string.Empty; using (OsaDirectEAManager.Database dbMfpDetails = new OsaDirectEAManager.Database()) { DbCommand cmdMfpDetails = dbMfpDetails.GetSqlStringCommand(sqlQuery); DbDataReader drDeviceAuthenticationType = dbMfpDetails.ExecuteReader(cmdMfpDetails, CommandBehavior.CloseConnection); if (drDeviceAuthenticationType.HasRows) { drDeviceAuthenticationType.Read(); returnValue = drDeviceAuthenticationType["MFP_LOGON_AUTH_SOURCE"] as string; } if (drDeviceAuthenticationType != null && drDeviceAuthenticationType.IsClosed == false) { drDeviceAuthenticationType.Close(); } } return(returnValue); }