Example #1
0
        /// <summary>
        /// Delete the Document Upload records for multiple row project data
        /// </summary>
        /// <param name="DocumentUploadBO"></param>
        /// <returns>int</returns>
        public void Delete(Int32 projectId)
        {
            // Define Constants
            const string sp = "dbo.Delete_Document_Project_Id";

            // Set Stored Procedure
            DbCommand dbCommand = _DB.GetStoredProcCommand(sp);

            try
            {
                _DB.AddInParameter(dbCommand, "Project_Id", DbType.Int32, projectId);
                _DB.ExecuteNonQuery(dbCommand);
            }
            catch (InternalException err)
            {
                // Re-Throw the Internal Exception
                throw;
            }
            catch (Exception err)
            {
                // Format the Parameters
                string parms = CommonDA.FormatParmsSQL(dbCommand);

                // Database Error
                ErrMsg = string.Format("{0} - Delete Document Upload Project Id Error - Parameters = {1} - {2}",
                                       GetType().FullName,
                                       parms,
                                       err.Message);

                // Save the Error
                CommonDA.SaveError(ErrMsg, err);
            }
        }
Example #2
0
        /// <summary>
        /// UpdateInsert the Document Upload record
        /// </summary>
        /// <param name="DocumentUploadBO"></param>
        /// <returns>int</returns>
        public void UpdateInsert(DocumentUploadBO duBO)
        {
            // Define Constants
            const string sp = "dbo.Update_Insert_Document_Upload";

            // Set Stored Procedure
            DbCommand dbCommand = _DB.GetStoredProcCommand(sp);

            try
            {
                _DB.AddInParameter(dbCommand, "Project_Id", DbType.Int32, duBO.Project_Id);
                _DB.AddInParameter(dbCommand, "Project_Name", DbType.String, duBO.Project_Name);
                _DB.AddInParameter(dbCommand, "Upload_Criteria_Id", DbType.Int32, duBO.Upload_Criteria_Id);
                _DB.AddInParameter(dbCommand, "Effective_Date", DbType.DateTime, duBO.Effective_Date);
                _DB.AddInParameter(dbCommand, "Ack_Due_Date", DbType.DateTime, duBO.Ack_Due_Date);
                _DB.AddInParameter(dbCommand, "Primary_Barcode", DbType.String, duBO.Primary_Barcode);
                _DB.AddInParameter(dbCommand, "Secondary_Barcode", DbType.String, duBO.Secondary_Barcode);
                _DB.AddInParameter(dbCommand, "Email_Notification", DbType.String, duBO.Email_Notification);
                _DB.AddInParameter(dbCommand, "Email_Reminder", DbType.String, duBO.Email_Reminder);
                _DB.AddInParameter(dbCommand, "Zip_File_Name", DbType.String, duBO.Zip_File_Name);
                _DB.AddInParameter(dbCommand, "Control_File_Name", DbType.String, duBO.Control_File_Name);
                _DB.AddInParameter(dbCommand, "PDF_File_Name", DbType.String, duBO.PDF_File_Name);
                _DB.AddInParameter(dbCommand, "Criteria_Name", DbType.String, duBO.Criteria_Name);
                _DB.AddInParameter(dbCommand, "Project_Created_By", DbType.String, duBO.Project_Created_By);
                _DB.AddInParameter(dbCommand, "Modified_By", DbType.String, duBO.Modified_By);

                _DB.AddOutParameter(dbCommand, "Id", DbType.Int32, 0);
                _DB.ExecuteNonQuery(dbCommand);

                if (duBO.Project_Id == 0)
                {
                    HttpContext.Current.Session["ProjectId"] = Convert.ToInt32(_DB.GetParameterValue(dbCommand, "@Id"));
                }
            }
            catch (InternalException err)
            {
                // Re-Throw the Internal Exception
                throw;
            }
            catch (Exception err)
            {
                // Format the Parameters
                string parms = CommonDA.FormatParmsSQL(dbCommand);

                // Database Error
                ErrMsg = string.Format("{0} - UpdateInsert Document Upload Error - Parameters = {1} - {2}",
                                       GetType().FullName,
                                       parms,
                                       err.Message);

                // Save the Error
                CommonDA.SaveError(ErrMsg, err);
            }
        }
Example #3
0
        /// <summary>
        /// Retrieves the Document Upload record for an Project Id
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns>documentUploadBO</returns>
        public DocumentUploadBO GetByProjectId(Int32 projectId)
        {
            // Define Constants
            const string sp = "dbo.Get_DocUpload_By_Project_Id";

            // Set Stored Procedure
            DbCommand dbCommand = _DB.GetStoredProcCommand(sp);

            // Define Variables
            DocumentUploadBO duBO = new DocumentUploadBO();

            try
            {
                // Set Input Parameters
                _DB.AddInParameter(dbCommand, "Project_Id", DbType.Int32, projectId);

                using (IDataReader dr = _DB.ExecuteReader(dbCommand))
                {
                    // Process all the records
                    while (dr.Read())
                    {
                        // Save the DocUpload record
                        duBO.Save(dr);
                    }
                }
            }
            catch (InternalException err)
            {
                // Re-Throw the Internal Exception
                throw;
            }
            catch (Exception err)
            {
                // Format the Parameters
                string parms = CommonDA.FormatParmsSQL(dbCommand);

                // Database Error
                ErrMsg = string.Format("{0} - Get DocUpload By Project Id Error - Parameters = {1} - {2}",
                                       GetType().FullName,
                                       parms,
                                       err.Message);

                // Save the Error
                CommonDA.SaveError(ErrMsg, err);
            }

            return(duBO);
        }
Example #4
0
        /// <summary>
        /// Inserts a record in the HRSC NET Logs Table
        /// </summary>
        /// <param name="action">Action</param>
        public void Insert(string action)
        {
            // Define Constants
            const string sp = "HRSCLogs.dbo.Insert_Activity_Log";

            // Set Stored Procedure
            DbCommand dbCommand = _DB.GetStoredProcCommand(sp);

            // Get the Application Id
            string appName = string.Empty;

            try
            {
                try
                {
                    appName = ConfigurationManager.AppSettings["Application_Name"];

                    if (String.IsNullOrEmpty(appName))
                    {
                        appName = "REIMB Web";
                    }
                }
                catch (Exception)
                {
                    appName = "REIMB Web";
                }

                // Get the User's IP Address - Returns 127.0.0.1
                //HttpRequest currentRequest = HttpContext.Current.Request;
                //string ipAddress = currentRequest.ServerVariables["HTTP_X_FORWARDED_FOR"];

                //if (ipAddress == null
                //    || ipAddress.ToLower() == "unknown")
                //{
                //    ipAddress = currentRequest.ServerVariables["REMOTE_ADDR"];
                //}

                //string ipAddress = HttpContext.Current.Request.UserHostAddress;

                // Get the User's IP Address - Actual workstation ip address when coming through VPM (MyEd)
                //string ipAddress = Dns.GetHostAddresses(strHostName).GetValue(1).ToString();
                //string ipAddress = Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

                // Get the User's IP Address
                string strHostName = Dns.GetHostName();
                //string ipAddress = Dns.GetHostAddresses(strHostName).GetValue(Dns.GetHostAddresses(strHostName).Count() - 1).ToString();
                //string ipAddress = Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
                //string ipAddress = HttpContext.Current.Session["IPAddress"].ToString();
                string ipAddress = string.Empty;

                // Using Proxy?
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
                    {
                        // Return real client IP.
                        ipAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                    }
                    // Another option for Proxies
                    else if (HttpContext.Current.Request.ServerVariables["HTTP_CLIENT_IP"] != null)
                    {
                        // Return real client IP.
                        ipAddress = HttpContext.Current.Request.ServerVariables["HTTP_CLIENT_IP"].ToString();
                    }
                    // not using proxy or can't get the Client IP
                    else
                    {
                        // While it can't get the Client IP, it will return proxy IP.
                        ipAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                    }
                }

                // Set Input Parameters
                _DB.AddInParameter(dbCommand, "AppId", DbType.String, appName);
                _DB.AddInParameter(dbCommand, "Action", DbType.String, action);
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Session["EmplId"] != null)
                    {
                        _DB.AddInParameter(dbCommand, "ActionBy", DbType.String, HttpContext.Current.Session["EmplId"].ToString().Trim());
                    }
                }
                _DB.AddInParameter(dbCommand, "IPAddress", DbType.String, ipAddress);
                _DB.AddInParameter(dbCommand, "ServerName", DbType.String, Environment.MachineName.ToString());
                _DB.AddOutParameter(dbCommand, "RowCount", DbType.Int32, 0);
                _DB.ExecuteNonQuery(dbCommand);

                int rowCount = Convert.ToInt32(_DB.GetParameterValue(dbCommand, "@RowCount"));

                if (rowCount == null ||
                    rowCount.ToString() == "0")
                {
                    // Format the Parameters
                    string parms = CommonDA.FormatParmsSQL(dbCommand);

                    // Error
                    ErrMsg = string.Format("{0} - Insert Error - Parameters = {1} - No rows were Inserted.",
                                           GetType().FullName,
                                           parms);

                    // Save the Error
                    Exception err = new Exception();
                    CommonDA.SaveError(ErrMsg, err);
                }
            }
            catch (InternalException err)
            {
                // Re-Throw the Internal Exception
                throw;
            }
            catch (Exception err)
            {
                // Format the Parameters
                string parms = CommonDA.FormatParmsSQL(dbCommand);

                // Error
                ErrMsg = string.Format("{0} - Insert Error - Parameters = {1} - {2}",
                                       GetType().FullName,
                                       parms,
                                       err.Message);

                // Save the Error
                CommonDA.SaveError(ErrMsg, err);
            }
        }