public void Insert(string QryDesc,string QryText,int? ByEmployeeID,int? ByContactID,string LogIp,DateTime? LogQryDate,string QrySourceDeprecated,string QrySource,byte[] LogQryTs)
	    {
		    DbQueryLog item = new DbQueryLog();
		    
            item.QryDesc = QryDesc;
            
            item.QryText = QryText;
            
            item.ByEmployeeID = ByEmployeeID;
            
            item.ByContactID = ByContactID;
            
            item.LogIp = LogIp;
            
            item.LogQryDate = LogQryDate;
            
            item.QrySourceDeprecated = QrySourceDeprecated;
            
            item.QrySource = QrySource;
            
            item.LogQryTs = LogQryTs;
            
	    
		    item.Save(UserName);
	    }
Esempio n. 2
0
        internal int ExecuteNonQuery(string SqlQuery, TimeBoundAccessRequest tbar)
        {
            try
            {
                PegasusSystem system = PegasusSystem.QueryWithStoredProc("GetSystemById", tbar.SystemCode).FirstOrDefault();

                if (system == null)
                {
                    throw new Exception($"UNABLE TO EXECUTE QUERY ON {tbar.SystemCode} AT THIS TIME");
                }

                ThirdPartyDB thirdPartyDB = new ThirdPartyDB(system.ConnectionString);
                int          rowsAffected = thirdPartyDB.ExecuteNonQuery(SqlQuery);

                DbQueryLog dbQueryLog = new DbQueryLog();
                dbQueryLog.CreatedOn            = DateTime.Now;
                dbQueryLog.CreatedBy            = tbar.UserId;
                dbQueryLog.ModifiedBy           = tbar.UserId;
                dbQueryLog.ModifiedOn           = DateTime.Now;
                dbQueryLog.NumberOfRowsAffected = "Rows Affected = " + rowsAffected;
                dbQueryLog.QuerySql             = SqlQuery;
                dbQueryLog.RecordDate           = DateTime.Now;
                dbQueryLog.UserId = tbar.UserId;

                //save db query async
                Task.Factory.StartNew(() =>
                {
                    dbQueryLog.SaveLog();
                });

                return(rowsAffected);
            }
            catch (Exception ex)
            {
                Task.Factory.StartNew(() =>
                {
                    DatabaseHandler dh = new DatabaseHandler();
                    dh.LogError(nameof(SendOneTimePIN), $"{SqlQuery}, Error:{ex.Message}");
                });
                throw ex;
            }
        }
    //end set visible data 

    //saves query, IP address, etc to database
    protected void append_to_query_log(string _query, string _name)
    {
        try
        {
            if (!string.IsNullOrEmpty(_query))
            {

                DbQueryLog _newlog = new DbQueryLog();

                _newlog.QryText = _query;
                _newlog.QryDesc = _name.Replace("___report", ""); ;
                _newlog.LogIp = userRequestingIP();
                _newlog.LogQryDate = DateTime.Now;
                _newlog.ByContactID = 0;
                _newlog.ByEmployeeID = 0;
                _newlog.QrySource = "container"; //"CNTR";//_name.Contains("___report") ? "OTR" : "OTV"; ///order tracking REPORT (goes to combobox) or order tracking view

                if (Session["user"] != null)
                {
                    UserClass _thisuser = (UserClass)Session["user"];

                    if (_thisuser.CompanyId == -1)
                    { //employee
                        _newlog.ByContactID = 0;
                        _newlog.ByEmployeeID = _thisuser.UserId;
                    }
                    else
                    {
                        _newlog.ByContactID = _thisuser.UserId;
                        _newlog.ByEmployeeID = 0;
                    }
                }
                _newlog.Save();

                this.dxhfMethod.Set("status", 1);
            }
        }
        catch (Exception ex)
        {
            //Response.Write(ex.Message.ToString());
            this.lblmsgboxdiv.Text += "<div class='alert'>Error description" + ": " + ex.Message.ToString() + "</div>";
        }
    }
    //saves query, IP address, etc to database
    protected void append_to_query_log(string _query, string _name)
    {
        try
        {
            if (!string.IsNullOrEmpty(_query))
            {

                DbQueryLog _newlog = new DbQueryLog();

                _newlog.QryText = _query;
                _newlog.QryDesc = _name;
                _newlog.LogIp = userRequestingIP();
                _newlog.LogQryDate = DateTime.Now;
                _newlog.ByContactID = 0;
                _newlog.ByEmployeeID = 0;
                _newlog.QrySource = "OCE"; //order cargo edit

                if (Session["user"] != null)
                {
                    UserClass _thisuser = (UserClass)Session["user"];

                    if (_thisuser.CompanyId == -1)
                    { //employee
                        _newlog.ByContactID = 0;
                        _newlog.ByEmployeeID = _thisuser.UserId;
                    }
                    else
                    {
                        _newlog.ByContactID = _thisuser.UserId;
                        _newlog.ByEmployeeID = 0;
                    }
                }
                _newlog.Save();

                this.dxhfMethod.Set("status", 1);
            }
        }
        catch (Exception ex)
        {
            //Response.Write(ex.Message.ToString());
            this.lblmsgboxdiv.Text += "<div class='alert'>Error description" + ": " + ex.Message.ToString() + "</div>";
        }
    }