public questStatus Log(int userSessionId, int severity, string module, string message) { // Initialize questStatus status = null; LogId logId = null; Log log = new Log(); log.UserSessionId = userSessionId; log.Severity = severity; log.Module = module; log.Message = message; log.Created = DateTime.Now; // Create the emailRecipient using (PWTrackerLoggingEntities dbContext = new PWTrackerLoggingEntities()) { status = create(dbContext, log, out logId); if (!questStatusDef.IsSuccess(status)) { return(status); } } return(new questStatus(Severity.Success)); }
// // GET: /ADO/ /// <summary> /// Login Comtroller /// </summary> /// <param name="modal"></param> /// <returns></returns> public JsonResult SignIn(EmpSignin modal) { var res = new LogId(); var messageType = "error"; var message = "Error occured while signing in."; try { if (ModelState.IsValid) { //ADOBLLWithQuery bll = new ADOBLLWithQuery(); EPBLL bll = new EPBLL(); var isSuccess = bll.SignIn(modal); //if (isSuccess.LoginId==new LogId()) //{ res = isSuccess; messageType = "success"; message = "Signed in Successfully."; //} } else { res = new LogId(); } } catch (Exception) { //message = "Exception occurred while performing operation."; } return(Json(new { messageType = messageType, res = res, message = message }, JsonRequestBehavior.AllowGet)); }
private questStatus read(PWTrackerLoggingEntities dbContext, LogId logId, out Quest.Services.Dbio.PWTrackerLogging.Logs log) { // Initialize log = null; try { log = dbContext.Logs.Where(r => r.Id == logId.Id).SingleOrDefault(); if (log == null) { return(new questStatus(Severity.Error, String.Format("ERROR: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, String.Format("Id {0} not found", logId.Id)))); } } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); String fullErrorMessage = string.Join("; ", errorMessages); String exceptionMessage = string.Concat(ex.Message, " The DbEntityValidationException errors are: ", fullErrorMessage); return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, exceptionMessage))); } catch (System.Exception ex) { return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.InnerException != null ? ex.InnerException.Message : ex.Message))); } return(new questStatus(Severity.Success)); }
public async Task <ILspLogger> CreateLoggerAsync(string serverTypeName, string?clientName, JsonRpc jsonRpc, CancellationToken cancellationToken) { var logName = $"Roslyn.{serverTypeName}.{clientName ?? "Default"}.{Interlocked.Increment(ref s_logHubSessionId)}"; var logId = new LogId(logName, new ServiceMoniker(typeof(LanguageServerTarget).FullName)); var serviceContainer = await _asyncServiceProvider.GetServiceAsync <SVsBrokeredServiceContainer, IBrokeredServiceContainer>(_threadingContext.JoinableTaskFactory).ConfigureAwait(false); var service = serviceContainer.GetFullAccessServiceBroker(); var configuration = await TraceConfiguration.CreateTraceConfigurationInstanceAsync(service, ownsServiceBroker : true, cancellationToken).ConfigureAwait(false); // Register the default log level as information. // Loghub will take care of cleaning up older logs from past sessions / current session // if it decides the log file sizes are too large. var loggingLevel = SourceLevels.ActivityTracing | SourceLevels.Information; var logOptions = new RpcContracts.Logging.LoggerOptions(new LoggingLevelSettings(loggingLevel)); var traceSource = await configuration.RegisterLogSourceAsync(logId, logOptions, cancellationToken).ConfigureAwait(false); // Associate this trace source with the jsonrpc conduit. This ensures that we can associate logs we report // with our callers and the operations they are performing. jsonRpc.ActivityTracingStrategy = new CorrelationManagerTracingStrategy { TraceSource = traceSource }; return(new LogHubLspLogger(configuration, traceSource)); }
private static async Task <LogHubLspLogger?> CreateLoggerAsync( VSShell.IAsyncServiceProvider?asyncServiceProvider, string serverTypeName, string?clientName, JsonRpc jsonRpc, CancellationToken cancellationToken) { if (asyncServiceProvider == null) { return(null); } var logName = $"Roslyn.{serverTypeName}.{clientName ?? "Default"}.{Interlocked.Increment(ref s_logHubSessionId)}"; var logId = new LogId(logName, new ServiceMoniker(typeof(LanguageServerTarget).FullName)); var serviceContainer = await VSShell.ServiceExtensions.GetServiceAsync <SVsBrokeredServiceContainer, IBrokeredServiceContainer>(asyncServiceProvider).ConfigureAwait(false); var service = serviceContainer.GetFullAccessServiceBroker(); var configuration = await TraceConfiguration.CreateTraceConfigurationInstanceAsync(service, cancellationToken).ConfigureAwait(false); var logOptions = new RpcContracts.Logging.LoggerOptions(new LoggingLevelSettings(SourceLevels.ActivityTracing | SourceLevels.Information)); var traceSource = await configuration.RegisterLogSourceAsync(logId, logOptions, cancellationToken).ConfigureAwait(false); // Associate this trace source with the jsonrpc conduit. This ensures that we can associate logs we report // with our callers and the operations they are performing. jsonRpc.ActivityTracingStrategy = new CorrelationManagerTracingStrategy { TraceSource = traceSource }; return(new LogHubLspLogger(configuration, traceSource)); }
public override int GetHashCode() { unchecked { var hashCode = (LogId != null ? LogId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)Type; hashCode = (hashCode * 397) ^ Retry; hashCode = (hashCode * 397) ^ (Cause != null ? Cause.GetHashCode() : 0); return(hashCode); } }
private static LogConfigCommandResponse ParseData(LogConfigCommandResponse result, byte[] data) { var pos = 14; var count = (data.Length - pos) / 2; var logIds = new LogId[count]; for (var i = 0; i < count; ++i) { logIds[i] = (LogId)BitConverter.ToUInt16(data, pos); pos += 2; } result.LogIds = logIds; return(result); }
public Log GetLog(LogId logId) { var logger = loggerFactory.Create(primaryLoggerKey); Log log = null; try { log = logger.GetLogById(logId); } finally { loggerFactory.Release(logger); } return(log); }
/*---------------------------------------------------------------------------------------------------------------------------------- * CRUD *---------------------------------------------------------------------------------------------------------------------------------*/ public questStatus Read(LogId logId, out Log log) { // Initialize questStatus status = null; log = null; // Write to the log status = _dbLogMgr.Read(logId, out log); if (!questStatusDef.IsSuccess(status)) { return(status); } return(new questStatus(Severity.Success)); }
/// <summary> /// Initializes the target. /// </summary> protected override void InitializeTarget() { _cancelTokenSource = new CancellationTokenSource(); _platform = _platform ?? Platform.Instance(); string logId = LogId?.Render(LogEventInfo.CreateNullEvent()); GaxPreconditions.CheckNotNullOrEmpty(logId, nameof(LogId)); ActivateLogIdAndResource(logId); _client = _client ?? BuildLoggingServiceClient(); base.InitializeTarget(); }
public questStatus Create(DbMgrTransaction trans, Log log, out LogId logId) { // Initialize questStatus status = null; logId = null; // Data rules. log.Created = DateTime.Now; // Create the log in this transaction. status = create((PWTrackerLoggingEntities)trans.DbContext, log, out logId); if (!questStatusDef.IsSuccess(status)) { return(status); } return(new questStatus(Severity.Success)); }
public bool DisableLogs() { try { var logItemsRange = GetLogIdRanges(); var scopeId = 1; var masks = new LogId[0]; foreach (var logRange in logItemsRange) { var logScope = scopeId * 0x1000; var affectedMasks = SetLogMask(scopeId, logRange, masks); ++scopeId; } return(true); } catch { return(false); } }
/*---------------------------------------------------------------------------------------------------------------------------------- * CRUD *---------------------------------------------------------------------------------------------------------------------------------*/ public questStatus Create(Log log, out LogId logId) { // Initialize questStatus status = null; logId = null; // Data rules. log.Created = DateTime.Now; // Create the log using (PWTrackerLoggingEntities dbContext = new PWTrackerLoggingEntities()) { status = create(dbContext, log, out logId); if (!questStatusDef.IsSuccess(status)) { return(status); } } return(new questStatus(Severity.Success)); }
/// <summary> /// Initializes the target. /// </summary> protected override void InitializeTarget() { _cancelTokenSource = new CancellationTokenSource(); _platform = _platform ?? Platform.Instance(); string logId = LogId?.Render(LogEventInfo.CreateNullEvent()); GaxPreconditions.CheckNotNullOrEmpty(logId, nameof(LogId)); if (SendJsonPayload) { if (JsonConverter != null) { // Use the function provided directly. GaxPreconditions.CheckState( string.IsNullOrWhiteSpace(JsonConverterTypeName) && string.IsNullOrWhiteSpace(JsonConverterMethodName), $"{nameof(JsonConverterTypeName)} and {nameof(JsonConverterMethodName)} must not be set along with {nameof(JsonConverter)}."); _jsonConvertFunction = JsonConverter; } else if (!string.IsNullOrWhiteSpace(JsonConverterTypeName) || !string.IsNullOrWhiteSpace(JsonConverterMethodName)) { // Use the method refered to by type-name and method-name. GaxPreconditions.CheckState( !string.IsNullOrWhiteSpace(JsonConverterTypeName) && !string.IsNullOrWhiteSpace(JsonConverterMethodName), $"Either both or neither of {nameof(JsonConverterTypeName)} and {nameof(JsonConverterMethodName)} must be specified."); _jsonConvertFunction = BuildAndVerifyJsonConverter(); } else { // Use default json.net based converter. _jsonConvertFunction = BuildProtoConverter(); } } ActivateLogIdAndResource(logId); _client = _client ?? BuildLoggingServiceClient(); base.InitializeTarget(); }
private questStatus update(PWTrackerLoggingEntities dbContext, Log log) { // Initialize questStatus status = null; try { // Read the record. LogId logId = new LogId(log.Id); Quest.Services.Dbio.PWTrackerLogging.Logs _log = null; status = read(dbContext, logId, out _log); if (!questStatusDef.IsSuccess(status)) { return(status); } // Update the record. BufferMgr.TransferBuffer(log, _log); dbContext.SaveChanges(); } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); String fullErrorMessage = string.Join("; ", errorMessages); String exceptionMessage = string.Concat(ex.Message, " The DbEntityValidationException errors are: ", fullErrorMessage); return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, exceptionMessage))); } catch (System.Exception ex) { return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.InnerException != null ? ex.InnerException.Message : ex.Message))); } return(new questStatus(Severity.Success)); }
public questStatus Read(DbMgrTransaction trans, LogId logId, out Log log) { // Initialize questStatus status = null; log = null; // Perform read. using (PWTrackerLoggingEntities dbContext = new PWTrackerLoggingEntities()) { Quest.Services.Dbio.PWTrackerLogging.Logs _log = null; status = read((PWTrackerLoggingEntities)trans.DbContext, logId, out _log); if (!questStatusDef.IsSuccess(status)) { return(status); } log = new Log(); BufferMgr.TransferBuffer(_log, log); } return(new questStatus(Severity.Success)); }
/*---------------------------------------------------------------------------------------------------------------------------------- * Logs *---------------------------------------------------------------------------------------------------------------------------------*/ private questStatus create(PWTrackerLoggingEntities dbContext, Log log, out LogId logId) { // Initialize logId = null; // Perform create try { Quest.Services.Dbio.PWTrackerLogging.Logs _log = new Quest.Services.Dbio.PWTrackerLogging.Logs(); BufferMgr.TransferBuffer(log, _log); dbContext.Logs.Add(_log); dbContext.SaveChanges(); if (_log.Id == 0) { return(new questStatus(Severity.Error, "Log not created")); } logId = new LogId(_log.Id); } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); String fullErrorMessage = string.Join("; ", errorMessages); String exceptionMessage = string.Concat(ex.Message, " The DbEntityValidationException errors are: ", fullErrorMessage); return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, exceptionMessage))); } catch (System.Exception ex) { return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.InnerException != null ? ex.InnerException.Message : ex.Message))); } return(new questStatus(Severity.Success)); }
public async Task <ILspLogger> CreateLoggerAsync(string serverTypeName, string?clientName, JsonRpc jsonRpc, CancellationToken cancellationToken) { var logName = $"Roslyn.{serverTypeName}.{clientName ?? "Default"}.{Interlocked.Increment(ref s_logHubSessionId)}"; var logId = new LogId(logName, new ServiceMoniker(typeof(LanguageServerTarget).FullName)); var serviceContainer = await VSShell.ServiceExtensions.GetServiceAsync <SVsBrokeredServiceContainer, IBrokeredServiceContainer>(_asyncServiceProvider).ConfigureAwait(false); var service = serviceContainer.GetFullAccessServiceBroker(); var configuration = await TraceConfiguration.CreateTraceConfigurationInstanceAsync(service, cancellationToken).ConfigureAwait(false); // Register the default log level as warning to avoid creating log files in the hundreds of GB. // This level can be overriden by setting the environment variable 'LogLevel' to the desired source level. // See https://dev.azure.com/devdiv/DevDiv/_git/VS?path=%2Fsrc%2FPlatform%2FUtilities%2FImpl%2FLogHub%2FLocalTraceHub.cs&version=GBmain&line=142&lineEnd=143&lineStartColumn=1&lineEndColumn=1&lineStyle=plain&_a=contents // This should be switched back to SourceLevels.Information once Loghub adds support for recyclying logs while VS is open. // See https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1359778/ var loggingLevel = SourceLevels.ActivityTracing | SourceLevels.Warning; // If VS was explicitly started with /log, then record all information logs as well. // This is extremely useful for development so that F5 deployment automatically logs everything. var wasVSStartedWithLogParameter = await _wasVSStartedWithLogParameterLazy.GetValueAsync(cancellationToken).ConfigureAwait(false); if (wasVSStartedWithLogParameter) { loggingLevel |= SourceLevels.Information; } var logOptions = new RpcContracts.Logging.LoggerOptions(new LoggingLevelSettings(loggingLevel)); var traceSource = await configuration.RegisterLogSourceAsync(logId, logOptions, cancellationToken).ConfigureAwait(false); // Associate this trace source with the jsonrpc conduit. This ensures that we can associate logs we report // with our callers and the operations they are performing. jsonRpc.ActivityTracingStrategy = new CorrelationManagerTracingStrategy { TraceSource = traceSource }; return(new LogHubLspLogger(configuration, traceSource)); }
public override string ToString() { return("[" + LogId.ToString().PadLeft(3, '0') + "] " + Descr); }
public Log GetLogById(LogId logId) { return(logRepository.GetLogById(logId)); }
public Log GetLogById(LogId logId) { return(logManagerService.GetLog(logId)); }
public DC_Message SyncCountryMapping(Guid Country_Id, string CreatedBy) { try { Guid LogId; using (ConsumerEntities context = new ConsumerEntities()) { var iScheduledCount = (from dlr in context.DistributionLayerRefresh_Log where dlr.Status == "Scheduled" && dlr.Element == "Country" && dlr.Type == "Mapping" select true).Count(); if (iScheduledCount > 0) { return(new DC_Message { StatusMessage = "CountryMapping sync has already been scheduled.", StatusCode = ReadOnlyMessage.StatusCode.Information }); } else { LogId = Guid.NewGuid(); DataLayer.DistributionLayerRefresh_Log objNew = new DistributionLayerRefresh_Log(); objNew.Id = LogId; objNew.Element = "Country"; objNew.Type = "Mapping"; objNew.Create_Date = DateTime.Now; objNew.Create_User = CreatedBy;// System.Web.HttpContext.Current.User.Identity.Name; objNew.Status = "Scheduled"; context.DistributionLayerRefresh_Log.Add(objNew); context.SaveChanges(); } if (Country_Id == Guid.Empty) { using (DHSVCProxyAsync DHP = new DHSVCProxyAsync()) { string strURI = string.Format(System.Configuration.ConfigurationManager.AppSettings["Load_CountryMapping"], LogId.ToString()); DHP.GetAsync(ProxyFor.SqlToMongo, strURI); } } else { //Code goes here for Indert Update or Delete of a specific country } return(new DC_Message { StatusMessage = "CountryMapping sync has been scheduled successfully.", StatusCode = ReadOnlyMessage.StatusCode.Success }); } } catch (Exception ex) { return(new DC_Message { StatusMessage = ex.Message, StatusCode = ReadOnlyMessage.StatusCode.Failed }); } }
public Log GetLogById(LogId logId) { throw new NotImplementedException(); }
public Log GetLogById(LogId logId) { return(rep.Find(l => l.Id.Guid == logId.Guid).FirstOrDefault()); }
public DC_Message SyncActivityBySupplier(Guid log_id, Guid supplier_id, string CreatedBy) { try { Guid LogId; string SupplierName = string.Empty; using (ConsumerEntities context = new ConsumerEntities()) { var iScheduledCount = (from dlr in context.DistributionLayerRefresh_Log where (dlr.Status == "Scheduled" || dlr.Status == "Running") && dlr.Element == "Activities" && dlr.Type == "Mapping" select true).Count(); if (iScheduledCount > 0) { return(new DC_Message { StatusMessage = "Supplier Static Activity Data sync has already been scheduled.", StatusCode = ReadOnlyMessage.StatusCode.Information }); } else { LogId = Guid.NewGuid(); DataLayer.DistributionLayerRefresh_Log objNew = new DistributionLayerRefresh_Log(); objNew.Id = LogId; objNew.Element = "Activities"; objNew.Type = "Mapping"; objNew.Create_Date = DateTime.Now; objNew.Create_User = CreatedBy;// System.Web.HttpContext.Current.User.Identity.Name; objNew.Status = "Scheduled"; objNew.Supplier_Id = supplier_id; objNew.Edit_Date = DateTime.Now; objNew.Edit_User = CreatedBy; context.DistributionLayerRefresh_Log.Add(objNew); context.SaveChanges(); SupplierName = (from x in context.Supplier where x.Supplier_Id == supplier_id select x.Name).FirstOrDefault(); } if (log_id == Guid.Empty) { using (DHSVCProxyAsync DHP = new DHSVCProxyAsync()) { if (SupplierName != string.Empty) { string strURI = string.Format(System.Configuration.ConfigurationManager.AppSettings["Load_ActivityFlavourBySupplier"], LogId.ToString(), SupplierName); DHP.GetAsync(ProxyFor.SqlToMongo, strURI); } } } else { //Code goes here for Indert Update or Delete of a specific country } return(new DC_Message { StatusMessage = "Supplier Activity Data sync has been scheduled successfully.", StatusCode = ReadOnlyMessage.StatusCode.Success }); } } catch (Exception ex) { return(new DC_Message { StatusMessage = ex.Message, StatusCode = ReadOnlyMessage.StatusCode.Failed }); } }