public int Add() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); _applicationID = lwDataAccess.ApplicationAdd(this); return(_applicationID); }
/// <summary> /// Dismiss this alert /// </summary> public void Dismiss() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); Status = AlertStatus.dismissed; lwDataAccess.AlertSetStatus(this); }
/// <summary> /// Add this group to the database (only applicable to user locations) /// </summary> /// <returns></returns> public int Add() { // If this Location already exists then call the update instead if (_groupID != 0) { return(Update(null)); } // If we have not specified a parent but do have a full name then we have a problem in that we // do not necessarily have a parent location in the database and in any case we do not know the ID // of our parent so should look for it now... if ((ParentID == 0) && (_fullname.Contains(@"\"))) { _groupID = ValidateParentPath(_fullname); } else { // Add the location to the database AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); int groupID = lwDataAccess.GroupAdd(this); if (groupID != 0) { AuditChanges(null); _groupID = groupID; } } return(0); }
/// <summary> /// Delete the current Alert from the database /// </summary> public void Delete() { // Delete from the database AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); lwDataAccess.AlertDelete(this); }
/// <summary> /// Check the username/password pair and recover the full details of the logged in user (if any) /// </summary> /// <returns></returns> public User UserCheckPassword(string aUsername, string aPassword) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } User loggedUser = null; if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT _USERID FROM USERS WHERE _LOGIN = @cLogin AND _PASSWORD = @cPassword"; SqlCeParameter[] spParams = new SqlCeParameter[2]; spParams[0] = new SqlCeParameter("@cLogin", aUsername); spParams[1] = new SqlCeParameter("@cPassword", AES.Encrypt(aPassword)); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); object result = command.ExecuteScalar(); if ((result != null) && (result.GetType() != typeof(DBNull))) { loggedUser = GetUserDetails((int)result); } } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); loggedUser = lAuditWizardDataAccess.UserCheckPassword(aUsername, aPassword); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(loggedUser); }
/// <summary> /// Update the definition stored for the specified User /// </summary> /// <param name="theAsset"></param> /// <returns></returns> public int UserUpdate(User aUser) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "UPDATE USERS SET " + "_LOGIN = @cLogin ,_FIRSTNAME = @cFirstName ,_LASTNAME = @cLastName " + ",_ACCESSLEVEL = @nAccessLevel ,_ROOTLOCATION = @nRootLocation " + "WHERE _USERID = @nUserID"; SqlCeParameter[] spParams = new SqlCeParameter[6]; spParams[0] = new SqlCeParameter("@nUserID", aUser.UserID); spParams[1] = new SqlCeParameter("@cLogin", aUser.Logon); spParams[2] = new SqlCeParameter("@cFirstName", aUser.FirstName); spParams[3] = new SqlCeParameter("@cLastName", aUser.LastName); spParams[4] = new SqlCeParameter("@nAccessLevel", (int)aUser.AccessLevel); spParams[5] = new SqlCeParameter("@nRootLocation", aUser.RootLocationID); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); command.ExecuteNonQuery(); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lAuditWizardDataAccess.UserUpdate(aUser); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(0); }
private void InsertTableDataExpress(SqlConnection conn, string tableName) { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); tableName = "dbo." + tableName; lbProgressStage.Text = "inserting data into table : " + tableName; this.Refresh(); try { SqlBulkCopy sbc = new SqlBulkCopy(conn, SqlBulkCopyOptions.KeepIdentity, null); using (SqlConnection cConn = lAuditWizardDataAccess.CreateOpenConnection()) { SqlCommand cmd = new SqlCommand("SELECT * FROM " + tableName, cConn); SqlDataReader rdr = cmd.ExecuteReader(); sbc.DestinationTableName = tableName; sbc.BulkCopyTimeout = 120; sbc.WriteToServer(rdr); } progressBar1.PerformStep(); this.Refresh(); } catch (Exception ex) { throw ex; } }
public void PopulateAliases() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); DataTable applicationsTable = lwDataAccess.GetAliasedApplications(); LoadFromTable(applicationsTable); }
/// <summary> /// Return a list of changes between this object and an old version /// For suppliers we really aren't that interested in changes to these details just adding /// and deletion of suppliers /// </summary> /// <param name="oldObject"></param> /// <returns></returns> public List <AuditTrailEntry> AuditChanges(Supplier oldObject) { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); // Construct the return list List <AuditTrailEntry> listChanges = new List <AuditTrailEntry>(); // Is this a new item or an update to an existing one if (SupplierID == 0) { AuditTrailEntry ate = new AuditTrailEntry(); ate.Date = DateTime.Now; ate.Class = AuditTrailEntry.CLASS.supplier; ate.Type = AuditTrailEntry.TYPE.added; ate.Key = _name; ate.AssetID = 0; ate.AssetName = ""; ate.Username = System.Environment.UserName; listChanges.Add(ate); } // Add all of these changes to the Audit Trail foreach (AuditTrailEntry entry in listChanges) { lwDataAccess.AuditTrailAdd(entry); } // Return the constructed list return(listChanges); }
/// <summary> /// Delete this note from the database /// </summary> /// <returns></returns> public int Delete() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); lwDataAccess.NoteDelete(this); return(0); }
/// <summary> /// Add a new asset to the database (or possibly update an existing item) /// </summary> /// <returns></returns> public int Add() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); if (AssetID == 0) { // Add the asset to the database _assetID = lwDataAccess.AssetAdd(this); // ...and log this event in the audit trail AuditTrailEntry ate = new AuditTrailEntry(); ate.Date = DateTime.Now; ate.Class = AuditTrailEntry.CLASS.asset; ate.Type = AuditTrailEntry.TYPE.added; ate.Key = _name; ate.AssetID = _assetID; ate.AssetName = _name; ate.Username = System.Environment.UserName; lwDataAccess.AuditTrailAdd(ate); } else { lwDataAccess.AssetUpdate(this); } return(0); }
/// <summary> /// Load all of the hardware / system items audited for this asset /// </summary> /// <returns>Count of items added to the list</returns> public int PopulateAuditedItems() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); _listAuditedItems = new AuditedItemList(lwDataAccess.GetAuditedItems(AssetID, "", true)); return(_listAuditedItems.Count); }
/// <summary> /// Load all of the File Systems audited for this asset /// </summary> /// <returns>Count of items added to the list</returns> public int PopulateFileSystem() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); _listFolders = new FileSystemFolderList(lwDataAccess.EnumerateFileSystemFolders(AssetID), lwDataAccess.EnumerateFileSystemFiles(AssetID)); return(_listFolders.Count); }
/// <summary> /// Load all of the Child Assets for this asset /// </summary> /// <returns>Count of items added to the list</returns> public int PopulateChildAssets() { AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); _childAssets = new AssetList(lwDataAccess.EnumerateChildAssets(AssetID), false); return(_childAssets.Count); }
/// <summary> /// Return a table containing all of the Actions that have been defined /// </summary> /// <returns></returns> public DataTable EnumerateActions() { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } DataTable actionTable = new DataTable(TableNames.ACTIONS); if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT ACTIONS.[_ACTIONID] " + ", ACTIONS.[_TYPE] " + ", ACTIONS.[_APPLICATIONID] " + ", ACTIONS.[_ASSETS] " + ", ACTIONS.[_STATUS] " + ", ACTIONS.[_NOTES] " + ", APPLICATIONS.[_NAME] " + "FROM dbo.ACTIONS " + "LEFT JOIN dbo.APPLICATIONS ON (ACTIONS._APPLICATIONID = dbo.APPLICATIONS.[_APPLICATIONID]) " + "ORDER BY _ACTIONID"; using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { new SqlCeDataAdapter(command).Fill(actionTable); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); actionTable = lAuditWizardDataAccess.EnumerateActions(); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(actionTable); }
/// <summary> /// Return a table of the intances of the specified application /// </summary> /// <param name="applicationID"></param> /// <returns></returns> public DataTable GetApplicationInstances(int applicationID) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } DataTable applicationsTable = new DataTable(TableNames.APPLICATION_INSTANCES); if (compactDatabaseType) { try { using (SqlCeCommand command = new SqlCeCommand("SELECT APPLICATION_INSTANCES._INSTANCEID ,APPLICATION_INSTANCES._APPLICATIONID ,APPLICATION_INSTANCES._ASSETID ,APPLICATION_INSTANCES._PRODUCTID ,APPLICATION_INSTANCES._CDKEY " + ",APPLICATIONS._NAME ,APPLICATIONS._VERSION ,APPLICATIONS._PUBLISHER ,APPLICATIONS._GUID ,APPLICATIONS._IGNORED ,APPLICATIONS._ALIASED_TOID ,APPLICATIONS._USER_DEFINED " + ",ASSETS._NAME AS ASSETNAME " + ",ASSET_TYPES._ICON AS ASSETICON " + ",LOCATIONS._FULLNAME AS FULLLOCATIONNAME " + ",LOCATIONS._NAME AS LOCATIONNAME " + ",DOMAINS._NAME AS DOMAINNAME " + "FROM APPLICATION_INSTANCES " + "LEFT JOIN APPLICATIONS ON (APPLICATION_INSTANCES._APPLICATIONID = APPLICATIONS._APPLICATIONID) " + "LEFT JOIN ASSETS ON (APPLICATION_INSTANCES._ASSETID = ASSETS._ASSETID) " + "LEFT JOIN ASSET_TYPES ON (ASSETS._ASSETTYPEID = ASSET_TYPES._ASSETTYPEID) " + "LEFT JOIN LOCATIONS ON (ASSETS._LOCATIONID = LOCATIONS._LOCATIONID) " + "LEFT JOIN DOMAINS ON (ASSETS._DOMAINID = DOMAINS._DOMAINID) " + "WHERE APPLICATION_INSTANCES._APPLICATIONID = @applicationID " + "AND ASSETS._STOCK_STATUS <> 3", DatabaseConnection.OpenCeConnection())) { command.Parameters.AddWithValue("@applicationID", applicationID); new SqlCeDataAdapter(command).Fill(applicationsTable); } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); applicationsTable = lAuditWizardDataAccess.GetApplicationInstances(applicationID); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(applicationsTable); }
/// <summary> /// Delete this Operation from the database /// </summary> /// <returns></returns> public int Delete() { // First remove the reference to the Operation from the database AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); lwDataAccess.OperationDelete(this); return(0); }
/// <summary> /// return whether or not the specified named group is already a child of this group /// </summary> /// <param name="childname"></param> /// <returns></returns> public AssetGroup IsChildGroup(string childname) { // First get a list of our current children AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); AssetGroupList listChildren = new AssetGroupList(lwDataAccess.GetGroups(this), _groupType); return(listChildren.FindGroup(childname)); }
public int Add() { // Add from the database AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess(); _alertID = lwDataAccess.AlertAdd(this); return(_alertID); }
/// <summary> /// This function is the base function for returning notes for a specific item or the specified scope /// and database ID. It is called from the public specific functions /// </summary> /// <param name="aScope"></param> /// <param name="aParentID"></param> /// <returns></returns> public DataTable EnumerateNotes(SCOPE aScope, int aParentID) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } DataTable table = new DataTable(TableNames.NOTES); if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT NOTES.* " + "FROM NOTES " + "WHERE _SCOPE = @nScope AND _PARENTID = @nParentID " + "ORDER BY _DATE DESC"; SqlCeParameter[] spParams = new SqlCeParameter[2]; spParams[0] = new SqlCeParameter("@nScope", (int)aScope); spParams[1] = new SqlCeParameter("@nParentID", aParentID); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); new SqlCeDataAdapter(command).Fill(table); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); table = lAuditWizardDataAccess.EnumerateNotes(aScope, aParentID); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(table); }
public int GetAssetTypeIDByName(string aAssetTypeName) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } int lAssetTypeId = -1; if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT _ASSETTYPEID " + "FROM ASSET_TYPES " + "WHERE _NAME = @assetTypeName"; using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddWithValue("@assetTypeName", aAssetTypeName); object result = command.ExecuteScalar(); if ((result != null) && (result.GetType() != typeof(DBNull))) { lAssetTypeId = Convert.ToInt32(result); } } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lAssetTypeId = lAuditWizardDataAccess.GetAssetTypeIDByName(aAssetTypeName); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(lAssetTypeId); }
/// <summary> /// Update the specified action /// </summary> /// <param name="theAsset"></param> /// <returns></returns> public int ActionUpdate(Action aAction) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "UPDATE ACTIONS SET _STATUS = @nStatus " + ", _ASSETS = @cAssets " + ", _NOTES = @cNotes " + "WHERE _ACTIONID = @nActionID"; SqlCeParameter[] spParams = new SqlCeParameter[4]; spParams[0] = new SqlCeParameter("@nActionID", aAction.ActionID); spParams[1] = new SqlCeParameter("@nStatus", (int)aAction.Status); spParams[2] = new SqlCeParameter("@cAssets", aAction.AssociatedAssets); spParams[3] = new SqlCeParameter("@cNotes", aAction.Notes); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); command.ExecuteNonQuery(); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(0); }
/// <summary> /// Return a table of any suppoprt contracts for which alerts should be generated /// </summary> /// <param name="applicationID"></param> /// <returns></returns> public DataTable EnumerateSupportContractAlerts() { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } DataTable alertsTable = new DataTable(TableNames.SUPPORT_STATISTICS); if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT LICENSES._SUPPORT_EXPIRES, LICENSES._SUPPORT_ALERTDAYS, LICENSES._SUPPORT_ALERTBYEMAIL, LICENSES._SUPPORT_ALERTRECIPIENTS " + ",APPLICATIONS._NAME " + "FROM LICENSES " + "LEFT JOIN APPLICATIONS ON (LICENSES._APPLICATIONID = APPLICATIONS._APPLICATIONID) " + "WHERE _SUPPORTED = 1 " + "AND _SUPPORT_ALERTDAYS <> -1 " + "AND ((_SUPPORT_EXPIRES - _SUPPORT_ALERTDAYS) <= GETDATE())"; using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { new SqlCeDataAdapter(command).Fill(alertsTable); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); alertsTable = lAuditWizardDataAccess.EnumerateSupportContractAlerts(); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(alertsTable); }
/// <summary> /// Update the definintion for a PickItem /// </summary> /// <param name="category"></param> /// <returns></returns> public int PickItemUpdate(PickItem aPickItem) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "UPDATE PICKLISTS SET " + "_NAME = @cName " + "WHERE " + "_PICKLISTID = @nPicklistID"; SqlCeParameter[] spParams = new SqlCeParameter[2]; spParams[0] = new SqlCeParameter("@nPicklistID", aPickItem.PickItemID); spParams[1] = new SqlCeParameter("@cName", aPickItem.Name); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); command.ExecuteNonQuery(); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lAuditWizardDataAccess.PickItemUpdate(aPickItem); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(0); }
/// <summary> /// Return a table containing all of the license which have been declared for the /// specified application /// </summary> /// <param name="applicationID"></param> /// <returns></returns> public DataTable GetApplicationLicenses(int applicationID) { //if (isDebugEnabled) logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); DataTable licensesTable = new DataTable(TableNames.LICENSES); if (compactDatabaseType) { try { //using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) //{ string commandText = "SELECT LICENSES._LICENSEID, LICENSES._LICENSETYPEID ,LICENSES._COUNT " + ",LICENSES._APPLICATIONID ,LICENSES._SUPPORTED, LICENSES._SUPPORT_EXPIRES ,LICENSES._SUPPORT_ALERTDAYS " + ",LICENSES._SUPPORT_ALERTBYEMAIL ,LICENSES._SUPPORT_ALERTRECIPIENTS " + ",LICENSES._SUPPLIERID " + ",LICENSE_TYPES._NAME AS LICENSE_TYPES_NAME ,LICENSE_TYPES._COUNTED " + ",APPLICATIONS._NAME AS APPLICATION_NAME " + ",SUPPLIERS._NAME AS SUPPLIER_NAME " + "FROM LICENSES " + "LEFT JOIN LICENSE_TYPES ON (LICENSES._LICENSETYPEID = LICENSE_TYPES._LICENSETYPEID) " + "LEFT JOIN APPLICATIONS ON (LICENSES._APPLICATIONID = APPLICATIONS._APPLICATIONID) " + "LEFT JOIN SUPPLIERS ON (LICENSES._SUPPLIERID = SUPPLIERS._SUPPLIERID) " + "WHERE LICENSES._APPLICATIONID = @applicationID"; using (SqlCeCommand command = new SqlCeCommand(commandText, DatabaseConnection.OpenCeConnection())) { command.Parameters.AddWithValue("@applicationID", applicationID); new SqlCeDataAdapter(command).Fill(licensesTable); } //} } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); licensesTable = lAuditWizardDataAccess.GetApplicationLicenses(applicationID); } //if (isDebugEnabled) logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); return(licensesTable); }
/// <summary> /// Dismiss the specified Alert - this does not actually delete the alert - just marks it as dismissed /// </summary> /// <param name="licenseID"></param> /// <returns></returns> public int AlertSetStatus(Alert aAlert) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } if (compactDatabaseType) { if (aAlert.AlertID != 0) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "UPDATE ALERTS SET _STATUS = @nStatus WHERE _ALERTID = @nAlertID"; SqlCeParameter[] spParams = new SqlCeParameter[2]; spParams[0] = new SqlCeParameter("@nAlertID", aAlert.AlertID); spParams[0] = new SqlCeParameter("@nStatus", (int)aAlert.Status); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); command.ExecuteNonQuery(); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lAuditWizardDataAccess.AlertSetStatus(aAlert); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(0); }
/// <summary> /// Return the database index of the specified Supplier Record /// </summary> /// <param name="name"></param> /// <returns></returns> public int SupplierFind(string aName) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } int lItemId = 0; if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT _SUPPLIERID FROM SUPPLIERS WHERE _name = @cName"; using (SqlCeCommand commandReturnValue = new SqlCeCommand(commandText, conn)) { commandReturnValue.Parameters.AddWithValue("@cName", aName); object result = commandReturnValue.ExecuteScalar(); if ((result != null) && (result.GetType() != typeof(DBNull))) { lItemId = Convert.ToInt32(result); } } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lItemId = lAuditWizardDataAccess.SupplierFind(aName); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(lItemId); }
/// <summary> /// Get the database index of the last operation in the database /// </summary> /// <returns></returns> public int OperationGetLastIndex() { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } int lReturnID = 0; if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "SELECT max(_OPERATIONID) FROM OPERATIONS"; using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { object result = command.ExecuteScalar(); if ((result != null) && (result.GetType() != typeof(DBNull))) { lReturnID = (int)result; } } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lReturnID = lAuditWizardDataAccess.OperationGetLastIndex(); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out with id : " + lReturnID); } return(lReturnID); }
/// <summary> /// Update an application instance record /// </summary> /// <param name="applicationInstance"></param> /// <returns></returns> public int ApplicationInstanceUpdate(ApplicationInstance applicationInstance) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "UPDATE APPLICATION_INSTANCES SET " + "_PRODUCTID = @cProductID " + ",_CDKEY = @cCDKey " + "WHERE _INSTANCEID = @nInstanceID"; using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddWithValue("@cProductID", applicationInstance.Serial.ProductId); command.Parameters.AddWithValue("@cCDKey", applicationInstance.Serial.CdKey); command.Parameters.AddWithValue("nInstanceID", applicationInstance.InstanceID); command.ExecuteNonQuery(); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lAuditWizardDataAccess.ApplicationInstanceUpdate(applicationInstance); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(0); }
/// <summary> /// Delete the specified PickList from the database /// Note that it is the responsibility of the caller to ensure that the referential integrity of the /// database is retained - i.e. do not delete PickLists that are still being referenced /// </summary> /// <param name="licenseID"></param> /// <returns></returns> public int PickListDelete(int aIndex) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } if (compactDatabaseType) { // The delete code will perform a sanity check to ensure that we do not // delete user defined categories/fields which are still referenced so we simply delete it now try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "DELETE FROM PICKLISTS WHERE _PICKLISTID = @nPicklistID"; SqlCeParameter[] spParams = new SqlCeParameter[1]; spParams[0] = new SqlCeParameter("@nPicklistID", aIndex); using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddRange(spParams); command.ExecuteNonQuery(); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lAuditWizardDataAccess.PickListDelete(aIndex); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out"); } return(0); }