private async static Task UpdateReportedProperties(ModuleClient ioTHubModuleClient, OperationStatus status)
        {
            var reportedProperties = new TwinCollection();

            reportedProperties[Constants.RabbitMQConfigPropertyName] = status.ToString();
            await ioTHubModuleClient.UpdateReportedPropertiesAsync(reportedProperties);
        }
Exemplo n.º 2
0
 private static void Throw(OperationStatus status)
 {
     throw GetException();
     InvalidOperationException GetException()
     {
         return(new InvalidOperationException(status.ToString()));
     }
 }
        public static void TrackStatus(this TelemetryClient client, string eventName, string correlationId, string description, OperationStatus status, IDictionary <string, double> metrics = null)
        {
            var properties = GetCommonProperties("Status Log", correlationId);

            properties["Description"] = description;
            properties["Status"]      = status.ToString();
            client.TrackEvent(eventName, properties, metrics);
        }
        public static void LogProgress(this ILogger logger, OperationStatus phase, string message, string correlationId)
        {
            var status = phase.ToString();

            logger.LogInformation(
                "Phase: {status}, Message: {message}, CorrelationId: {correlationId}",
                status,
                message,
                correlationId);
        }
        public static void LogFailedOperation(this ILogger logger, OperationStatus phase, string messsage, IEnumerable <KeyValuePair <string, string> > errors, string correlationId)
        {
            var description = $"{messsage}, Errors: {string.Join(",", errors.Select(err => $"[{err.Key}]: {err.Value}"))}";
            var status      = phase.ToString();

            logger.LogError(
                "Phase: {status},  Description: {description}, CorrelationId: {correlationId}",
                status,
                description,
                correlationId);
        }
Exemplo n.º 6
0
        private static string Map2(OperationStatus operationStatus)
        {
            switch (operationStatus)
            {
            case OperationStatus.OK: return("OK");

            case OperationStatus.KO: return("KO");

            case OperationStatus.EX: return("EX");

            default: throw new NotSupportedException(operationStatus.ToString());
            }
        }
Exemplo n.º 7
0
 public static string GetMessage(OperationStatus status)
 {
     if (_operationStatus.ContainsKey(status))
     {
         var statusKey = _operationStatus[status];
         if (_defaultLocaleResources.ContainsKey(statusKey))
         {
             return(_defaultLocaleResources[_operationStatus[status]]);
         }
         return(statusKey);
     }
     return(status.ToString());
 }
        private static async Task InsertLog(DateTime startedOn, OperationStatus status, ILogger log)
        {
            var finishedOn  = DateTime.Now;
            var elapsedTime = finishedOn - startedOn;
            // see https://stackoverflow.com/a/23163325/12805412
            var command = $"INSERT INTO bi.Logs VALUES (@id, @startedOn, @finishedOn, @elapsedTime, @status)";
            IDictionary <string, object> args = new Dictionary <string, object>();

            args.Add("@id", Guid.NewGuid());
            args.Add("@startedOn", startedOn);
            args.Add("@finishedOn", finishedOn);
            args.Add("@elapsedTime", elapsedTime.TotalSeconds);
            args.Add("@status", status.ToString());
            await Database.ExecuteNonQuery(command, args);
        }
            public static dynamic GetTSObject(OperationStatus dynEnum)
            {
                var tsType = TSActivator.CreateInstance("Tekla.Structures.Model.BentPlateGeometrySolver.OperationStatus").GetType();

                switch (dynEnum)
                {
                case OperationStatus.Success:
                    return(System.Enum.Parse(tsType, "Success"));

                case OperationStatus.Failure:
                    return(System.Enum.Parse(tsType, "Failure"));

                case OperationStatus.FacePerpendicularToIntersectionLine:
                    return(System.Enum.Parse(tsType, "FacePerpendicularToIntersectionLine"));

                case OperationStatus.PlateIntersectsWithIntersectionLine:
                    return(System.Enum.Parse(tsType, "PlateIntersectsWithIntersectionLine"));

                case OperationStatus.ExtensionIntersectsWithPlate:
                    return(System.Enum.Parse(tsType, "ExtensionIntersectsWithPlate"));

                case OperationStatus.FacesTooNearEachOther:
                    return(System.Enum.Parse(tsType, "FacesTooNearEachOther"));

                case OperationStatus.FacesAtAnObtuseAngle:
                    return(System.Enum.Parse(tsType, "FacesAtAnObtuseAngle"));

                case OperationStatus.UndefinedCurveDirection:
                    return(System.Enum.Parse(tsType, "UndefinedCurveDirection"));

                case OperationStatus.UnsupportedChamfer:
                    return(System.Enum.Parse(tsType, "UnsupportedChamfer"));

                case OperationStatus.InvalidRadius:
                    return(System.Enum.Parse(tsType, "InvalidRadius"));

                case OperationStatus.InvalidFacePoints:
                    return(System.Enum.Parse(tsType, "InvalidFacePoints"));

                default:
                    throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented");
                }
            }
Exemplo n.º 10
0
 void LogOperation(string operation, string key, Stopwatch timer, OperationStatus status, string details)
 {
     this.logger.Information(
         "{Operation} {Key}: {ElapsedMs}ms: {Status}: {Details}",
         operation, key.ToString(), timer.ElapsedMilliseconds, status.ToString(), details);
 }
Exemplo n.º 11
0
 void LogOperation(
     string operation,
     ObjectKey key,
     string contentType,
     long?objectSize,
     long?storageSize,
     Stopwatch timer,
     OperationStatus status,
     string details
     )
 {
     this.logger.Information(
         "{Operation} {Key} ({ContentType} {ObjectBytes}bytes/{StorageBytes}compressed): {ElapsedMs}ms: {Status}: {Details}",
         operation, key.ToString(), contentType, objectSize, storageSize, timer.ElapsedMilliseconds, status.ToString(), details);
 }
Exemplo n.º 12
0
 private void AddErrors(OperationStatus result)
 {
     ModelState.AddModelError("", result.ToString());
 }
Exemplo n.º 13
0
 internal static void Throw(OperationStatus status)
 {
     throw new InvalidOperationException(status.ToString());
 }
Exemplo n.º 14
0
 public OperationResult(OperationStatus status, string message, T data)
 {
     this.Data    = data;
     this.Status  = status.ToString();
     this.Message = message;
 }
Exemplo n.º 15
0
 private static string Map(OperationStatus operationStatus)
 {
     return(operationStatus.ToString().Substring(0, 2).ToUpper());
 }
Exemplo n.º 16
0
 public static string GetMessage(OperationStatus status)
 {
     if (_operationStatus.ContainsKey(status))
     {
         var statusKey = _operationStatus[status];
         if (_defaultLocaleResources.ContainsKey(statusKey))
         {
             return _defaultLocaleResources[_operationStatus[status]];
         }
         return statusKey;
     }
     return status.ToString();
 }
Exemplo n.º 17
0
 private static string OperationStatusToString(OperationStatus status)
 {
     return(status != OperationStatus.Unknown ? status.ToString().ToLowerInvariant() : "?");
 }