private void RollBackOp() { if ((!string.IsNullOrEmpty(this.RollBackMark)) && this.RollBackMark != "-1") { DBLog dbl = new DBLog(); DataTable DT = dbl.GetBakUps(this.RollBackMark); string sitename = string.Empty; if (DT != null && DT.Rows.Count > 0) { sitename = DT.Rows[0]["RBSiteName"].ToString(); } TaskInfo SiteObj = new TaskInfo(); if (Convert.ToInt32(DT.Rows[0]["IsUsed"]) == 0) { string msg = ""; TaskWorker SyncAction = new TaskWorker(SiteObj, dbl); if (SyncAction.RollBackSite()) { new DBLog().UpdateBakUsedMark(this.RollBackMark); Response.Write("<script>alert('回滚成功');</script>"); } else { Response.Write("<script>alert('回滚失败!\\r\\n\\r\\n" + msg + "');</script>"); } } else { this.Data_Bind(); Response.End(); } } }
private void manageSourceFiles(FileInfo srcFolder) { //Move/copy all files in subfolder <srcFolder> that meet the file pattern try { //Enumerate source folder files string[] srcFiles = Directory.GetFiles(srcFolder.FullName, this.mSrcFilePattern); for (int i = 0; i < srcFiles.Length; i++) { //Move source file; rename for uniqueness FileInfo file = new FileInfo(srcFiles[i]); string destFile = ""; try { if (file.Name.Substring(0, 1) != "_" && file.Length > 0) { //Move file and rename source string srcFilename = file.Name; destFile = getDestinationFilename(); file.MoveTo(destFile); FileInfo _file = new FileInfo(destFile); DBLog.LogFileMove(srcFilename, _file.Name); SvcLog.LogMessage("MOVED FILE\t" + srcFiles[i] + "\t" + destFile); } } catch (Exception ex) { SvcLog.LogMessage("MOVE FILE ERROR\t" + srcFiles[i] + "\t" + destFile + "\t" + ex.Message); } } } catch (Exception ex) { SvcLog.LogMessage("UNEXPECTED ERROR\tDDUFileSvc::manageSourceFiles(); " + ex.Message); } }
/// <summary> /// 合併兩筆以上的可堆疊道具紀錄 /// 出現Bug的時候才會執行 /// </summary> /// <param name="uid"></param> /// <param name="equipmentList"></param> /// <returns></returns> private static async ETTask _MergeEquipment(long uid, params Equipment[] equipmentList) { var first = equipmentList[0]; var set = new HashSet <long>(equipmentList.Length); for (int i = 1; i < equipmentList.Length; i++) { var equipmentInfo = equipmentList[i]; if (first.configId == equipmentInfo.configId) { first.count += equipmentInfo.count; set.Add(equipmentInfo.Id); } } await dbProxy.Save(first); await dbProxy.DeleteJson <Equipment>(entity => set.Contains(entity.Id)); CharacterConfig characterConfig = (CharacterConfig)configComponent.Get(typeof(CharacterConfig), first.configId); DBLog dBLog = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId()); dBLog.uid = uid; dBLog.logType = (int)DBLog.LogType.MergeEquipment; dBLog.document = new BsonDocument { { "mergedId", new BsonArray(equipmentList.Select(e => e.Id)) }, // 紀錄參與合併的道具紀錄Ids { "configType", characterConfig.Type }, { "configId", first.configId }, { "mergeCount", first.count }, // 合併後的數量 }; dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); await dbProxy.Save(dBLog); }
public List <DBLog> getLogList() { List <DBLog> list = new List <DBLog>(); String sql = String.Format("select * from UserLog"); try { using (DbDataReader reader = conn.execReader(sql)) { while (reader.Read()) { DBLog log = new DBLog(); log.Id = Convert.ToInt32(reader[0]); log.LogDate = reader[1].ToString(); log.LogCate = reader[2].ToString(); log.OperateCode = reader[3].ToString(); log.Message = reader[4].ToString(); list.Add(log); } } } catch (DbException) { //输出日志 } return(list); }
public void Execute() { //Execute this service try { //Perform file operations in source folder SvcLog.LogMessage("CHECKING FOR FILES ON " + this.mFtpClient.Server + "/" + this.mFtpClient.RemotePath + "..."); this.mFtpClient.Login(); string[] srcFiles = this.mFtpClient.GetFileList(this.mFilePattern); for (int i = 0; i < srcFiles.Length; i++) { //Rename for uniqueness string srcFile = srcFiles[i]; string destFile = ""; try { if (srcFile.Trim().Length > 0 && srcFile.Substring(0, 1) != "_") { //Move file and rename source destFile = getDestinationFilename(); this.mFtpClient.RenameFile(srcFile, destFile, true); DBLog.LogFileMove(srcFile, destFile); SvcLog.LogMessage("RENAMED FILE\t" + srcFile + "\t" + destFile); } } catch (Exception ex) { SvcLog.LogMessage("MOVE FILE ERROR\t" + srcFiles[i] + "\t" + destFile + "\t" + ex.Message); } } this.mFtpClient.Close(); } catch (Exception ex) { SvcLog.LogMessage("UNEXPECTED ERROR\t" + ex.Message); } }
protected void Application_End(object sender, EventArgs e) { m_log.Info(string.Format("订单扫描记录-订单扫描应用程序退出-ApplicationEnd")); Handle.Info("订单扫描记录", "JinRi.Notify.OrderScanService.OrderScanHandler", "订单扫描应用程序退出", "ApplicationEnd"); DBLog.FlushLogMessage(); System.Threading.Thread.Sleep(1000); }
public static void Fatal(string ikey, string logtype, string module, string orderNo, string content, string keyword) { if (LogLevelEnum.Fatal >= LogSetting.LogLevel) { DBLog.Process(RequestProfile.Username, ikey, RequestProfile.ClientIP, module, orderNo, logtype, content, string.IsNullOrWhiteSpace(keyword) ? "Fatal" : keyword); } }
public int ExecNotifyMessageDataMove(int day) { string notifySql = @"CREATE TEMPORARY TABLE temp_notifymessage (SELECT * FROM notifymessage WHERE DATEDIFF(CURRENT_TIME(),createtime) >=@Day LIMIT 30000) ; INSERT INTO notifymessage_backup(messageid ,appid,messagepriority,clientip,createtime,sourcefrom,messagekey,messagetype,notifydata) SELECT messageid ,appid,messagepriority,clientip,createtime,sourcefrom,messagekey,messagetype,notifydata FROM temp_notifymessage ; DELETE a FROM notifymessage a,temp_notifymessage b WHERE a.mid=b.mid ; DROP TABLE temp_notifymessage;"; DynamicParameters param = new DynamicParameters(); param.Add("Day", day); int row = 0; using (IDbConnection conn = ConnectionFactory.JinRiNotify_CMD) { try { conn.Open(); IDbTransaction tran = conn.BeginTransaction(); row = conn.Execute(notifySql, param); if (row > 0) { tran.Commit(); } } catch (Exception ex) { DBLog.Process("", "", ClientHelper.GetClientIP(), "", "", "数据迁移", string.Format("数据迁移异常【{0}】", ex.ToString()), "数据"); } return(row); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="_TaskObj">任务对象</param> /// <param name="_dbLogObj">日志对象</param> public TaskWorker(TaskInfo _TaskObj, DBLog _dbLogObj) { this.SiteObj = _TaskObj; this.block = _dbLogObj.BlockStr; this.dbLog = _dbLogObj; this.ftpcmd = new FtpAtomOperation(_dbLogObj); }
public static void Warning(string ikey, string logtype, string module, string orderNo, string content, string keyword) { if (LogLevelEnum.Warning >= LogSetting.LogLevel) { DBLog.Handle(RequestProfile.Username, ikey, RequestProfile.ClientIP, module, orderNo, logtype, content, string.IsNullOrWhiteSpace(keyword) ? "Warning" : keyword); } }
public void ReaderExecuting(IDbCommand command, DbCommandInterceptionContext <IDataReader> interceptionContext) { interceptionContext.DataBag.Add("startTime", DateTime.Now); Debug.WriteLine(AppendDbCommandInfo(command)); Console.WriteLine(command.CommandText); DBLog.Info(command.CommandText); }
public static int Insert(string connectionString, DBLog log) { using (IDbConnection cnn = new SQLiteConnection(connectionString)) { var sqlStatement = @" INSERT INTO [LogData] (BossID ,EvtcPath ,JsonPath ,HtmlPath ,Link ,SizeKb ,TimeStamp ,DurationMs ,Flags ,RemainingHealth) VALUES (@BossID ,@EvtcPath ,@JsonPath ,@HtmlPath ,@Link ,@SizeKb ,@TimeStamp ,@DurationMs ,@Flags ,@RemainingHealth); SELECT CAST(last_insert_rowid() as int);"; var newID = cnn.ExecuteScalar(sqlStatement, log); return((int)(long)newID); } }
private void Data_Bind() { DataTable DT = new DBLog().GetBakDateList(); this.BakDateLab += "<select id='BakDateList' name='BakDateList' onchange=\"javascript:SelBakDate()\"><option value='-1'>---请选择备份时间---</option>"; if (DT != null && DT.Rows.Count > 0) { DateTime[] TimeArray = null; List <int> TimeList = new List <int>(); foreach (DataRow dr in DT.Rows) { if (!string.IsNullOrEmpty(dr[0].ToString())) { TimeList.Add(Convert.ToInt32(dr[0].ToString())); } } TimeList.Sort(); foreach (int TimeS in TimeList) { string BakDate = TimeS.ToString().Insert(4, "年").Insert(7, "月") + "日"; if (SelBakDate == BakDate) { this.BakDateLab += "<option value='" + BakDate + "' selected='selected'>" + BakDate + "</option>"; } else { this.BakDateLab += "<option value='" + BakDate + "'>" + BakDate + "</option>"; } } } this.BakDateLab += "</select>"; if (!string.IsNullOrEmpty(this.SelBakDate)) { DataTable MarkDt = new DBLog().GetBakRollMark(Convert.ToDateTime(this.SelBakDate).ToString("yyyyMMdd")); this.BakMarkLab += "<table width='100%' border='1' cellspacing='0' cellpadding='0'>"; this.BakMarkLab += "<tr><td width='20%'>站点</td><td width='20%'>备份号</td><td width='20%'>时间</td><td>是否已用</td><td width='20%'>操作</td></tr>"; if (MarkDt != null && MarkDt.Rows.Count > 0) { foreach (DataRow dr in MarkDt.Rows) { this.BakMarkLab += "<tr onmouseover=\"this.style.background='#ccc'\" onmouseout=\"this.style.background='#fff'\">"; this.BakMarkLab += "<td style='white-space:normal; word-break:break-all;word-wrap:break-word'>" + dr[1].ToString() + "</td>"; this.BakMarkLab += "<td style='white-space:normal; word-break:break-all;word-wrap:break-word'>" + dr[0].ToString() + "</td>"; this.BakMarkLab += "<td style='white-space:normal; word-break:break-all;word-wrap:break-word'>" + dr[0].ToString().Substring(dr[0].ToString().IndexOf('/') + 1).Replace('_', ':') + "</td>"; if (Convert.ToInt32(dr[2].ToString()) == 1) { this.BakMarkLab += "<td>已回滚</td><td>已回滚 | <a href='#' onclick=\"javascript:ViewRBOp('" + dr[0].ToString() + "')\">察看回滚日志</a></td></tr>"; } else { this.BakMarkLab += "<td>未回滚</td><td><a href='#' onclick=\"javascript:RollBack('" + dr[0].ToString() + "')\">未回滚</a> | <a href='#' onclick=\"javascript:ViewRBOp('" + dr[0].ToString() + "')\">察看回滚日志</a></td></tr>"; } } } this.BakMarkLab += "</table>"; } }
public ApiModelDataContext() : base("ConnectionName") { Configuration.LazyLoadingEnabled = true; Configuration.ProxyCreationEnabled = true; Database.SetInitializer <ApiModelDataContext>(new Initializer <ApiModelDataContext>()); Database.Log = message => DBLog.WriteLine(message); }
public static void Delete(string connectionString, DBLog log) { using (IDbConnection cnn = new SQLiteConnection(connectionString)) { var sqlStatement = "DELETE FROM LogData WHERE ID = @ID"; cnn.Execute(sqlStatement, log); } }
private void Data_Bind() { if (this.BlockList.Items.Count > 1) { DataTable DT = new DBLog().GetTraces(BlockList.SelectedItem.Value, SiteList.SelectedItem.Value); TGridView.DataSource = DT; TGridView.DataBind(); } }
protected void lkcancel_Click(object sender, EventArgs e) { //记录回归日志 Common.LogUtility.DBLog Userlog = new DBLog(); Userlog.UserOperLog("取消上传操作", "站点:" + SiteName + ",批次:" + block, OpUser.UserId); Common.LogUtility.UploadTrace.TaskCancel(block); Response.Redirect(Request.Url.ToString()); }
public static async ETTask SaveLog(this DBProxyComponent self, long uid, DBLog.LogType logType, BsonDocument record) { DBLog dBLog = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId()); dBLog.uid = uid; dBLog.logType = (int)logType; dBLog.document = record; dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); await self.SaveLog(dBLog); }
private void InitList() { List <string> Years = new DBLog().GetBlockYears(); YearList.Items.Clear(); YearList.Items.Add(new ListItem("---请选择---", "-1")); foreach (var YearStr in Years) { YearList.Items.Add(new ListItem(YearStr, YearStr)); } }
internal void ErrorClickerWorker() { do { Thread.Sleep(DefaultSleepTime); bool InGame = false; try { using (ZetaDia.Memory.AcquireFrame()) { InGame = ZetaDia.IsInGame; } } catch (Exception) { DBLog.Debug("[ErrorClicker] Safely Handled IsInGame Exception!"); } if (InGame) { try { using (ZetaDia.Memory.AcquireFrame()) { if (ErrorDialog.IsVisible) { if (ErrorDialog.ErrorCode == -1) { HadDisconnectError = true; } DBLog.Debug("[ErrorClicker] Closing error " + ErrorDialog.ErrorCode.ToString()); ErrorDialog.Click(); } //else if(BotMain.ExecutionStateAvailable) //{ UIElement OkButton; if (UIElement.IsValidElement(0xB4433DA3F648A992) && (OkButton = UIElement.FromHash(0xB4433DA3F648A992)) != null) { if (OkButton.IsValid && OkButton.IsVisible && OkButton.IsEnabled) { DBLog.Info("[ErrorClicker] Closing unhandled error"); OkButton.Click(); } } //} } } catch (Exception) { } } } while (true); }
public virtual void Save_Ok() { var log = new DBLog() { Id = "", LogTime = DateTime.Now, SQL = "UnitTest", UserName = "******" }; Assert.True(log.Save(log)); }
public void WriteDateTimeAndReturnsContainsDataTime() { //Arrange var log = new DBLog(); var dataTime = DateTime.Now.ToString(); //Act log.Write(dataTime); //Assert Assert.IsTrue(log.Read().Contains(dataTime)); }
protected void DayList_SelectedIndexChanged(object sender, EventArgs e) { if (this.YearList.SelectedItem.Value != "-1" && this.MonthList.SelectedItem.Value != "-1" && this.DayList.SelectedItem.Value != "-1") { DataTable DT = new DBLog().GetMarkBlocks(this.YearList.SelectedItem.Value.Trim(), this.MonthList.SelectedItem.Value.Trim(), this.DayList.SelectedItem.Value.Trim(), SiteList.SelectedItem.Value); this.BlockList.Items.Clear(); this.BlockList.Items.Add(new ListItem("---请选择---", "-1")); foreach (DataRow dr in DT.Rows) { this.BlockList.Items.Add(new ListItem(dr["BlockCode"].ToString(), dr["BlockCode"].ToString())); } } }
public void Start() { try { log.Info("服务正在启动……"); DBLog.ConsumeForEach(); log.Info("服务启动完成!"); } catch (Exception ex) { log.Error("服务启动异常,原因:" + ex.ToString()); } }
/// <summary> /// Gets a log item /// </summary> /// <param name="LogID">Log item identifier</param> /// <returns>Log item</returns> public static Log GetLogByID(int LogID) { if (LogID == 0) { return(null); } DBLog dbItem = DBProviderManager <DBLogProvider> .Provider.GetLogByID(LogID); Log log = DBMapping(dbItem); return(log); }
protected void YearList_SelectedIndexChanged(object sender, EventArgs e) { if (YearList.SelectedItem.Value != "-1") { DataTable DT = new DBLog().GetBlockMonthList(YearList.SelectedItem.Value, SiteList.SelectedItem.Value); this.MonthList.Items.Clear(); this.MonthList.Items.Add(new ListItem("---请选择---", "-1")); foreach (DataRow dr in DT.Rows) { this.MonthList.Items.Add(new ListItem(dr["MonthVal"].ToString(), dr["MonthVal"].ToString())); } } }
public static async ETTask SaveLog(this DBProxyComponent self, long uid, DBLog.LogType logType, ComponentWithId record) { Session session = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress); DBLog dBLog = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId()); dBLog.uid = uid; dBLog.logType = (int)logType; BsonDocument doc = null; BsonDocument.TryParse(record.ToJson(), out doc); dBLog.document = doc; dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); await self.SaveLog(dBLog); }
public void Task_Ok() { var log = new DBLog() { Id = "", LogTime = DateTime.Now, SQL = "UnitTest", UserName = "******" }; LogHelper.AddDBLog(log); var task = new LogHelper.DbLogTask(); task.Execute(CancellationToken.None); }
protected void BtnClearLog_Click(object sender, EventArgs e) { DBLog log = new DBLog(); LogInfo info = new LogInfo(); info.UserName = PEContext.Current.Admin.AdminName; info.UserIP = PEContext.Current.UserHostAddress; info.ScriptName = base.Request.RawUrl; info.Timestamp = DateTime.Now; info.Message = "清空日志"; info.Title = info.Message; log.Add(info); log.Delete(DateTime.Today.AddDays(-2.0)); AdminPage.WriteSuccessMsg("成功清空了日志。注意:两天内的日志会被系统保留。", "LogManager.aspx"); }
public void Add(Models.LogModel e) { string name = "tbl_" + MD5Encoding(e.App); CreateTabel(name); using (DBContext.ChangeTable <DBLog>(name)) { DBLog log = new DBLog(); log.App = e.App; log.Content = e.Content; log.CreateTime = e.CreateTime; log.Host = e.Host; log.Type = e.Type; log.Save(DB); } }
public List<DBLog> GetLogs(DateTime start, DateTime end, Connector connector) { var connection = connector.Connection; if (connection.State != ConnectionState.Open) connection.Open(); var command = new SqlCommand(String.Format( "select {0}, {1}, {2}, {3} from {4} where {3} between @start and @end", PartIdColumn, LocaleIdColumn, KeyColumn, DateColumn, _table ), connection); command.Parameters.Add(new SqlParameter("start", SqlDbType.Date) { Value = start }); command.Parameters.Add(new SqlParameter("end", SqlDbType.Date) { Value = end }); using(var result = command.ExecuteReader()) { if (!result.HasRows) return new List<DBLog>(0); var logs = new List<DBLog>(result.RecordsAffected); while (result.Read()) { var value = new DBLog(result.GetInt64(0), result.GetInt32(1), result.GetString(2), result.GetDateTime(3)); logs.Add(value); } return logs; } }