public void delete_by_id(int id)
        {
            var args = new Hashtable {
                { "id", id }
            };

            DBLibs.ExecuteStoreProcedure("sp_del_tracelogs_byid", args, _cnn);
        }
Exemple #2
0
        public static int ExcuteSP(string StoreProcName, SqlParameter[] param = null)
        {
            //SqlCommand cmd = null;
            try
            {
                var args = new Hashtable();
                if (param == null)
                {
                    return(DBLibs.ExecuteStoreProcedure(StoreProcName, args, Cnn));
                }
                foreach (var p in param)
                {
                    if (p.DbType.ToString() == "DateTime")
                    {
                        var timeValue = DateTime
                                        .ParseExact(p.Value.ToString(), "dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture)
                                        .ToString("yyyy-MM-dd HH:mm:ss.fff");
                        args.Add(p.ParameterName.Replace("@", ""), timeValue);
                    }
                    else
                    {
                        args.Add(p.ParameterName.Replace("@", ""), p.Value.ToString());
                    }
                }
                return(DBLibs.ExecuteStoreProcedure(StoreProcName, args, Cnn));

                //cmd = new SqlCommand(StoreProcName);
                //cmd.Connection = con;
                //if (con.State == ConnectionState.Closed) { con.Open(); }
                //cmd.CommandType = CommandType.StoredProcedure;
                //if (param != null)
                //{
                //    for (int i = 0; i < param.Length; i++)
                //    {
                //        cmd.Parameters.Add(param[i]);
                //    }
                //}
                //return cmd.ExecuteScalar().MapInt();
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                con.Close();
            }
        }
Exemple #3
0
        /// <summary>
        /// Ghi log lai, co the dung de recovery
        /// </summary>
        /// <param name="type">Loại logs, vd: log_diem, log_access, log_ips, log_nhanxet, log_sms,..</param>
        /// <param name="modifier_guid">GUID của tài khoản thực hiện hành động</param>
        /// <param name="modifier_id">ID dạng số của tài khoản thực hiện hành động</param>
        /// <param name="newer_value">Giá trị mới</param>
        /// <param name="older_value">Giá trị trước đây</param>
        /// <param name="table_name_of_value_modified">Tên của bảng trong CSDL lưu giá trị</param>
        /// <param name="column_name_of_value_modified">Tên của cột trong CSDL lưu giá trị</param>
        /// <param name="id_of_row_modified">ID dạng số của giá trị thay đổi</param>
        /// <param name="time">Thời điểm xảy ra sự thay đổi (0: thoi diem hien tai)</param>
        public static void SetLogs(string type, string modifier_guid, string modifier_id, string newer_value, string older_value = "", string table_name_of_value_modified = "", string column_name_of_value_modified = "", string id_of_row_modified = "", int time = 0, string client_ip = "")
        {
            #region Set client_ip
            if (client_ip == "")
            {
                var context   = HttpContext.Current;
                var ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

                if (string.IsNullOrEmpty(ipAddress))
                {
                    client_ip = context.Request.ServerVariables["REMOTE_ADDR"];
                }
                else
                {
                    var addresses = ipAddress.Split(',');
                    client_ip = addresses.Length != 0 ? addresses[0] : context.Request.ServerVariables["REMOTE_ADDR"];
                }
            }
            #endregion
            try
            {
                if (time == 0)
                {
                    time = CLibs.DatetimeToTimestamp(DateTime.Now);
                }

                var args = new Hashtable
                {
                    { "type", type },
                    { "modifier_guid", modifier_guid },
                    { "modifier_id", modifier_id },
                    { "newer_value", newer_value },
                    { "older_value", older_value },
                    { "table_name", table_name_of_value_modified },
                    { "column_name", column_name_of_value_modified },
                    { "id_of_row", id_of_row_modified },
                    { "timestamp", time },
                    { "client_ip", client_ip }
                };
                DBLibs.ExecuteStoreProcedure("Proc_SetLogs", args, ConfigurationManager.ConnectionStrings["LogsConnection"].ConnectionString);
            }
            catch
            {
                // ignored
            }
        }
Exemple #4
0
 public static int ExcuteSP(string storeProcedure)
 {
     try
     {
         return(DBLibs.ExecuteStoreProcedure(storeProcedure, new Hashtable(), Cnn));
         //var result = 0;
         //SqlCommand cmd = new SqlCommand(storeProcedure, con);
         //cmd.Connection = con;
         //if (con.State == ConnectionState.Closed) { con.Open(); }
         //cmd.CommandType = CommandType.StoredProcedure;
         //cmd.CommandText = storeProcedure;
         //result = cmd.ExecuteScalar().MapInt();
         //return result;
     }
     catch { return(0); }
     finally
     {
         con.Close();
     }
 }