コード例 #1
0
        //public bool AddDataLogs()
        //{
        //    DataTable dt = this.DataAccess.GetDataTable("select * from  DataLogsM");
        //    return true;
        //}

        public DataTable[] SearchData(Dictionary <string, List <string> > tableAndlogids)
        {
            DataTable[] results = { };
            if (tableAndlogids != null)
            {
                foreach (var item in tableAndlogids)
                {
                    if (item.Value == null || item.Value.Count == 0)
                    {
                        continue;
                    }
                    foreach (string logid in item.Value)
                    {
                        LibDbParameter[] parameters = new LibDbParameter[2];
                        parameters[0] = new LibDbParameter {
                            ParameterNm = "@tablenm", DbType = DbType.String, Value = item.Key
                        };
                        parameters[1] = new LibDbParameter {
                            ParameterNm = "@logid", DbType = DbType.String, Value = logid
                        };
                        Array.Resize(ref results, results.Length + 1);
                        results[results.Length - 1]           = this.DataAccess.ExecStoredProcedure("p_searclog", parameters);
                        results[results.Length - 1].TableName = string.Format("{0}{2}{1}", item.Key, logid, SysConstManage.Underline);
                    }
                }
            }
            return(results);
        }
コード例 #2
0
ファイル: DataAccess.cs プロジェクト: zyylonghai/BWYSDP
        private string DoGetLogSqlStr(DataRow dr, string tablenm, int action, ILibDBHelp dBHelp)
        {
            //List<string> sqllist = new List<string>();
            StringBuilder sql = new StringBuilder();

            try
            {
                string           logid      = dr[SysConstManage.Sdp_LogId].ToString();
                LibDbParameter[] parameters = new LibDbParameter[4];
                parameters[0] = new LibDbParameter {
                    ParameterNm = "@logid", DbType = DbType.String, Value = logid
                };
                parameters[1] = new LibDbParameter {
                    ParameterNm = "@tablenm", DbType = DbType.String, Value = tablenm
                };
                parameters[2] = new LibDbParameter {
                    ParameterNm = "@ID", DbType = DbType.Int64, Direction = ParameterDirection.Output, Value = 0
                };
                parameters[3] = new LibDbParameter {
                    ParameterNm = "@logtbnm", DbType = DbType.String, Size = 35, Direction = ParameterDirection.Output, Value = string.Empty
                };
                dBHelp.StoredProcedureReturnValue(action == 1 ? "p_addlogM" : "p_GetlogM", parameters);
                ColExtendedProperties colextprop = null;
                object fieldvalue    = null;
                object oldfieldvalue = null;
                if (!string.IsNullOrEmpty(parameters[3].Value.ToString()) && (Int64)parameters[2].Value != 0)
                {
                    foreach (DataColumn c in dr.Table.Columns)
                    {
                        colextprop = Newtonsoft.Json.JsonConvert.DeserializeObject <ColExtendedProperties>(c.ExtendedProperties[SysConstManage.ExtProp].ToString());
                        if (!colextprop.IsActive)
                        {
                            continue;
                        }
                        if (action == 2 && LibSysUtils.Compare(dr[c, DataRowVersion.Original], dr[c, DataRowVersion.Current], false))
                        {
                            continue;
                        }
                        if (c.DataType == typeof(byte[]))
                        {
                            fieldvalue    = dr[c] == DBNull.Value?string.Empty : Convert.ToBase64String((byte[])dr[c]);
                            oldfieldvalue = (action == 1 || dr[c, DataRowVersion.Original] == DBNull.Value)? string.Empty: Convert.ToBase64String((byte[])dr[c, DataRowVersion.Original]);
                        }
                        else
                        {
                            fieldvalue    = dr[c];
                            oldfieldvalue = action == 1 ? string.Empty : dr[c, DataRowVersion.Original];
                        }
                        sql.AppendFormat("  EXEC sp_executesql N'insert into {0}(ID,Action,UserId,IP,DT,FieldNm,FieldValue,OldFieldValue) values(@ID,@Action,@UserId,@IP,@DT,@FieldNm,@FieldValue,@OldFieldValue) '", parameters[3].Value.ToString());
                        sql.Append(" ,N'@ID bigint,@Action char(1),@UserId nvarchar(30),@IP nvarchar(15),@DT datetime,@FieldNm nvarchar(30),@FieldValue ntext,@OldFieldValue ntext',");
                        sql.AppendFormat("  @ID={0},@Action='{1}',@UserId='{2}',@IP='{3}',@DT='{4}',@FieldNm='{5}',@FieldValue='{6}',@OldFieldValue='{7}' ",
                                         (Int64)parameters[2].Value, action, this._clientInfo.UserId, this._clientInfo.IP, DateTime.Now, c.ColumnName, fieldvalue, oldfieldvalue);
                        //sqllist.Add(sql.ToString());
                    }
                }
                //dBHelp.ExecuteNonQuery(sql.ToString());
            }
            catch (Exception ex) {
            }
            return(sql.ToString());
        }