public virtual string Login(LoginReq req) { long t = DateTime.Now.Ticks; LoginRes res = new LoginRes(); try { DAC dac = new DAC(Config.LoginConnectionName); res = dac.Login(req); } catch (Exception e) { Log.Write(LogAction.Svc, className, "Login", "Login", "Login", DateTime.Now.Ticks - t, "执行失败:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";" + e.Message); } return Newtonsoft.Json.JsonConvert.SerializeObject(res); }
public virtual int Regist(LoginReq req) { long t = DateTime.Now.Ticks; int res = -1; try { DAC dac = new DAC(Config.LoginConnectionName); res = dac.Regist(req); } catch (Exception e) { Log.Write(LogAction.Svc, className, "Regist", "Regist", "Regist", DateTime.Now.Ticks - t, "执行失败:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";" + e.Message); } return res; }
static RemoteLogService() { try { schema.Columns.Add("MonitorAction", typeof(string)); schema.Columns.Add("MonitorTime", typeof(DateTime)); schema.Columns.Add("Host", typeof(string)); schema.Columns.Add("IP", typeof(string)); schema.Columns.Add("MAC", typeof(string)); schema.Columns.Add("AppPath", typeof(string)); schema.Columns.Add("AppName", typeof(string)); schema.Columns.Add("ProcessName", typeof(string)); schema.Columns.Add("FirstCag", typeof(string)); schema.Columns.Add("SecondCag", typeof(string)); schema.Columns.Add("ThirdCag", typeof(string)); schema.Columns.Add("MonitorValue", typeof(double)); schema.Columns.Add("Msg", typeof(string)); mappings[0] = new SqlBulkCopyColumnMapping("MonitorAction", "MonitorAction"); mappings[1] = new SqlBulkCopyColumnMapping("MonitorTime", "MonitorTime"); mappings[2] = new SqlBulkCopyColumnMapping("Host", "Host"); mappings[3] = new SqlBulkCopyColumnMapping("IP", "IP"); mappings[4] = new SqlBulkCopyColumnMapping("MAC", "MAC"); mappings[5] = new SqlBulkCopyColumnMapping("AppPath", "AppPath"); mappings[6] = new SqlBulkCopyColumnMapping("AppName", "AppName"); mappings[7] = new SqlBulkCopyColumnMapping("ProcessName", "ProcessName"); mappings[8] = new SqlBulkCopyColumnMapping("FirstCag", "FirstCag"); mappings[9] = new SqlBulkCopyColumnMapping("SecondCag", "SecondCag"); mappings[10] = new SqlBulkCopyColumnMapping("ThirdCag", "ThirdCag"); mappings[11] = new SqlBulkCopyColumnMapping("MonitorValue", "MonitorValue"); mappings[12] = new SqlBulkCopyColumnMapping("Msg", "Msg"); if (isDb) dac = new DAC(Config.LogConnectionName); schemaCache = schema.Clone(); } catch (Exception e) { Log.Error(e); } }
public byte[] GetFile(string name) { try { DAC dac = new DAC(Config.FileConnectionName); return dac.GetFile(name); } catch (Exception e) { Log.Error("DACService.GetFile:" + e.Message); return new byte[1] { 0 }; } }
public string SaveFile(string name, byte[] img) { try { DAC dac = new DAC(Config.FileConnectionName); return dac.SaveFile(name, img); } catch (Exception e) { Log.Error("DACService.SaveFile:" + e.Message); return name; } }
public string ExecuteDataList(WrapedDatabaseParameter parms) { long t = DateTime.Now.Ticks; try { DatabaseParameter[] pars = parms.DatabaseParameters ?? new DatabaseParameter[] { }; DbParameter[] ps = ConvertParameter(pars); DAC dac = new DAC(parms.RoutingKey, parms.ConnectionString); string list = dac.ExecuteDataList(parms.CmdText, (CommandType)parms.CmdType, ps); Log.Write(LogAction.Svc, className, "ExecuteDataListWraped", parms.ConnectionString, parms.CmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + (CommandType)parms.CmdType + " " + pars.ToKeyString()); return list; } catch (Exception e) { Log.Write(LogAction.Error, className, "ExecuteDataListWraped", parms.ConnectionString, parms.CmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:" + (CommandType)parms.CmdType + " " + parms + ";" + e.ToString()); } return "[]"; }
public int ExecuteNonQuery(params WrapedDatabaseParameter[] parmss) { long t = DateTime.Now.Ticks; int n = 0; foreach (WrapedDatabaseParameter parms in parmss) { try { DatabaseParameter[] pars = parms.DatabaseParameters ?? new DatabaseParameter[] { }; DbParameter[] ps = ConvertParameter(pars); DAC dac = new DAC(parms.RoutingKey, parms.ConnectionString); n += dac.ExecuteNonQuery(parms.CmdText, (CommandType)parms.CmdType, ps); Log.Write(LogAction.Svc, className, "ExecuteNonQueryWraped", parms.ConnectionString, parms.CmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + pars.ToKeyString()); } catch (Exception e) { Log.Write(LogAction.Error, className, "ExecuteNonQueryWraped", parms.ConnectionString, parms.CmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:" + parms + ";" + e.ToString()); return -1; } } return n; }
public object ExecuteScalar(string connString, string cmdText, CommandType cmdType, params DatabaseParameter[] parameters) { long t = DateTime.Now.Ticks; try { DbParameter[] ps = ConvertParameter(parameters); DAC dac = new DAC(connString); object o = dac.ExecuteScalar(cmdText, cmdType, ps); Log.Write(LogAction.Svc, className, "ExecuteScalar", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + parameters.ToKeyString()); return o; } catch (Exception e) { Log.Write(LogAction.Error, className, "ExecuteScalar", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:cmdText:" + cmdText + ";" + parameters.ToKeyString() + ";" + e.ToString()); } return new object(); }
public bool SqlBulkInsertDataReader(string connString, string targetTable, IDataReader dr) { long t = DateTime.Now.Ticks; try { DAC dac = new DAC(connString); bool rtn = dac.SqlBulkInsertDataReader(targetTable, dr); Log.Write(LogAction.Svc, className, "SqlBulkInsertDataReader1", connString, targetTable, DateTime.Now.Ticks - t, "执行成功:"); return rtn; } catch (Exception e) { Log.Write(LogAction.Error, className, "SqlBulkInsertDataReader1", connString, targetTable, DateTime.Now.Ticks - t, "执行出错targetTable:" + targetTable + ";" + e.Message); } return false; }
public int AdapterSave(string connString, DataSet ds, string insertCmdText, string updateCmdText, string deleteCmdText, CommandType cmdType, params DatabaseParameter[] parameters) { long t = DateTime.Now.Ticks; try { DbParameter[] ps = ConvertParameter(parameters); DAC dac = new DAC(connString); int rtn = dac.AdapterSave(ds, insertCmdText, updateCmdText, deleteCmdText, cmdType, ps); Log.Write(LogAction.Svc, className, "AdapterSave", connString, updateCmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + parameters.ToKeyString()); return rtn; } catch (Exception e) { Log.Write(LogAction.Error, className, "AdapterSave", connString, updateCmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:updateCmdText:" + updateCmdText + ";" + e.ToString()); } return -1; }
public int Fill(string connString, DataSet ds, string cmdText, CommandType cmdType, params DatabaseParameter[] parameters) { long t = DateTime.Now.Ticks; try { DbParameter[] ps = ConvertParameter(parameters); DAC dac = new DAC(connString); int rtn = dac.Fill(ds, cmdText, cmdType, ps); Log.Write(LogAction.Svc, className, "Fill", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + parameters.ToKeyString()); return rtn; } catch (Exception e) { Log.Write(LogAction.Error, className, "Fill", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:cmdText:" + cmdText + ";" + parameters.ToKeyString() + ";" + e.ToString()); } return -1; }
public string ExecuteDataList(string connString, string cmdText, CommandType cmdType, params DatabaseParameter[] parameters) { long t = DateTime.Now.Ticks; try { DbParameter[] ps = ConvertParameter(parameters); DAC dac = new DAC(connString); string list = dac.ExecuteDataList(cmdText, cmdType, ps); Log.Write(LogAction.Svc, className, "ExecuteDataList", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + parameters.ToKeyString() + ";数据:" + list); return list; } catch (Exception e) { Log.Write(LogAction.Error, className, "ExecuteDataList", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:cmdText:" + cmdText + ";" + parameters.ToKeyString() + ";" + e.ToString()); } return "[]"; }
public string ExecutePagedDataList(PagedRecordParameter prp) { long t = DateTime.Now.Ticks; try { DAC dac = new DAC(prp.ConnectionString); List<DbParameter> pars = new List<DbParameter>(); pars.Add(dac.CreateParameter("TableName", prp.TableName)); pars.Add(dac.CreateParameter("Fields", prp.Fields)); pars.Add(dac.CreateParameter("OrderBy", prp.OrderBy)); pars.Add(dac.CreateParameter("PageIndex", prp.PageIndex)); pars.Add(dac.CreateParameter("PageSize", prp.PageSize)); pars.Add(dac.CreateParameter("RecordCount", prp.RecordCount)); pars.Add(dac.CreateParameter("Where", prp.Where)); string s = dac.ExecuteDataList("PagedRecordSP", CommandType.StoredProcedure, pars.ToArray()); Log.Write(LogAction.Dac, className, "ExecutePagedDataSetWraped", prp.ConnectionString, "PagedRecordSP", DateTime.Now.Ticks - t, "执行成功"); return s; } catch (Exception e) { Log.Write(LogAction.Error, className, "ExecutePagedDataSetWraped", prp.ConnectionString, "PagedRecordSP", DateTime.Now.Ticks - t, "执行出错:cmdText:PagedRecordSP;" + e.Message); } return string.Empty; }
public DataSet ExecutePagedDataSet(string connString, string dsTableName, string tableName, string fields, string orderBy, long pageIndex, long pageSize, long recordCount, string where) { long t = DateTime.Now.Ticks; try { DAC dac = new DAC(connString); List<DbParameter> pars = new List<DbParameter>(); pars.Add(dac.CreateParameter("TableName", tableName)); pars.Add(dac.CreateParameter("Fields", fields)); pars.Add(dac.CreateParameter("OrderBy", orderBy)); pars.Add(dac.CreateParameter("PageIndex", pageIndex)); pars.Add(dac.CreateParameter("PageSize", pageSize)); pars.Add(dac.CreateParameter("RecordCount", recordCount)); pars.Add(dac.CreateParameter("Where", where)); DataSet ds = dac.ExecuteDataSet(tableName, "PagedRecordSP", CommandType.StoredProcedure, pars.ToArray()); Log.Write(LogAction.Dac, className, "ExecutePagedDataSet", connString, "PagedRecordSP", DateTime.Now.Ticks - t, "执行成功"); return ds; } catch (Exception e) { Log.Write(LogAction.Error, className, "ExecutePagedDataSet", connString, "PagedRecordSP", DateTime.Now.Ticks - t, "执行出错:cmdText:PagedRecordSP;" + e.Message); } return new DataSet(); }
public virtual int Logout(string userName) { long t = DateTime.Now.Ticks; int res = -1; try { DAC dac = new DAC(Config.LoginConnectionName); res = dac.Logout(userName); } catch (Exception e) { Log.Write(LogAction.Svc, className, "Logout", "Logout", "Logout", DateTime.Now.Ticks - t, "执行失败:userName:"******";" + e.Message); } return res; }
public bool SqlBulkInsertDataTable(string connString, string targetTable, DataTable dt, SqlBulkCopyColumnMapping[] mappings) { long t = DateTime.Now.Ticks; try { DAC dac = new DAC(connString); bool rtn = dac.SqlBulkInsertDataTable(targetTable, dt, mappings); Log.Write(LogAction.Svc, className, "SqlBulkInsertDataTabl2", connString, targetTable, DateTime.Now.Ticks - t, "执行成功:"); return rtn; } catch (Exception e) { Log.Write(LogAction.Error, className, "SqlBulkInsertDataTable2", connString, targetTable, DateTime.Now.Ticks - t, "执行出错targetTable:" + targetTable + ";" + e.Message); } return false; }
public virtual int CheckLogin(string userName) { long t = DateTime.Now.Ticks; int res = -1; try { DAC dac = new DAC(Config.LoginConnectionName); res = dac.CheckLogin(userName); } catch (Exception e) { Log.Write(LogAction.Error, className, "CheckLogin", "CheckLogin", "CheckLogin", DateTime.Now.Ticks - t, "执行失败:userName:"******";" + e.Message); } Log.Write(LogAction.Info, className, "CheckLogin", "CheckLogin", "CheckLogin", DateTime.Now.Ticks - t, "检查登录:userName:"******";res:" + res); return res; }