/// <summary> /// Serializes this instance. /// </summary> public virtual void Serialize() { if (!_isStarted) { return; } TimeSpan elapsed = EndTime.Subtract(StartTime); Logger.Info("......................................."); Logger.Info(string.Format("{0,-18} : {1}", "Task Name", Name)); if (!ShowOnlyElapsedTime) { Logger.Info(string.Format("{0,-18} : {1}", "Start Time", StartTime.ToLongTimeString())); Logger.Info(string.Format("{0,-18} : {1}", "End Time", EndTime.ToLongTimeString())); } Logger.Info(string.Format("{0,-18} : {1} ms", "Elapsed Time", elapsed.TotalMilliseconds)); Fields.ForEach(item => { if (null != item) { Logger.Info(string.Format("{0,-18} : {1}", item.Name, item.Value)); } } ); SerializeMessages(); if (SyncLogger.EnableReportLog) { // Serialize the logs for Test Reports string reportLog = string.Format("{0,-40} | {1,-12} | {2,-12} | {3,-12}", Name, StartTime.ToLongTimeString(), EndTime.ToLongTimeString(), elapsed.TotalMilliseconds); ReportLog.Dump(reportLog); } SubTasks.ForEach(item => item.Serialize()); }
/// <summary> /// Serializes this instance. /// </summary> public virtual void Serialize() { TimeSpan elapsed = EndTime.Subtract(StartTime); // log only if available if (!string.IsNullOrEmpty(ClientProfile.SessionId)) { Logger.Info(string.Format("{0,-18} : {1}", "Id", ClientProfile.SessionId)); } if (!string.IsNullOrEmpty(ClientProfile.UserId.ToString())) { Logger.Info(string.Format("{0,-18} : {1}", "UserId", ClientProfile.UserId)); } if (!string.IsNullOrEmpty(ClientProfile.UserName)) { Logger.Info(string.Format("{0,-18} : {1}", "UserName", ClientProfile.UserName)); } if (!string.IsNullOrEmpty(ClientProfile.ClientApplication)) { Logger.Info(string.Format("{0,-18} : {1}", "ClientApplication", ClientProfile.ClientApplication)); } if (!string.IsNullOrEmpty(ClientProfile.ClientMachineName)) { Logger.Info(string.Format("{0,-18} : {1}", "ClientMachineName", ClientProfile.ClientMachineName)); } if (!LogTask.ShowOnlyElapsedTime) { Logger.Info(string.Format("{0,-18} : {1}", "Start Time", StartTime.ToLongTimeString())); Logger.Info(string.Format("{0,-18} : {1}", "End Time", EndTime.ToLongTimeString())); } Logger.Info(string.Format("{0,-18} : {1} ms", "Elapsed Time", elapsed.TotalMilliseconds)); Fields.ForEach(item => { if (null != item) { Logger.Info(string.Format("{0,-18} : {1}", item.Name, item.Value)); } } ); if (EnableReportLog) { // Serialize the logs for Test Reports LogField nameField = Fields.Find(item => String.Compare(item.Name, "UserName", StringComparison.OrdinalIgnoreCase) == 0); string userName = (null != nameField) ? nameField.Value : ClientProfile.SessionId; string reportLog = string.Format("{0,-40} | {1,-12} | {2,-12} | {3,-12}", userName, StartTime.ToLongTimeString(), EndTime.ToLongTimeString(), elapsed.TotalMilliseconds); ReportLog.Dump(" "); ReportLog.Dump(" "); ReportLog.Dump(reportLog); } if (EnableDumpStatistics) { CollectStatistics(); } SerializeTasks(); }