Пример #1
0
        /// <summary>
        /// Adds audit information to the data source using the new wrapper functionality. If the update fails
        /// an exception will be passed back to the calling routine
        /// </summary>
        /// <param name="passedUniqueID">The unique ID of the record</param>
        /// <param name="passedAction">The action taken on that record</param>
        /// <param name="connectionString">The string for connecting to the data source</param>
        public void AddToAudit(string passedUniqueID, string passedAction, string connectionString)
        {
            New_Wrapper.DataHandler MyHandler = new New_Wrapper.DataHandler();

            DateTime dateT;
            string   dateOf;

            dateT  = DateTime.Parse(DateTime.Now.ToShortDateString());
            dateOf = dateT.ToString("yyyyMMdd");

            DateTime timeT;
            string   timeOf;

            timeT  = DateTime.Parse(DateTime.Now.ToShortTimeString());
            timeOf = timeT.ToString("HH:mm:ss");
            try
            {
                string tempId = Guid.NewGuid().ToString();
                MyHandler.InsertData(connectionString, "INSERT INTO tblAudit (AuditID, AuditDate, AuditTime, PID, RequestID, AuditAction) VALUES ('" + tempId + "', '" + dateOf + "', '" + timeOf + "', '" + Environment.UserName.ToString() + "', '" + passedUniqueID + "', '" + passedAction + "')");
            }
            catch (Exception ex)
            {
                throw new Exception("DMBT-GT01a - unable to store the audit information - " + ex.Message);
            }
        }