Beispiel #1
0
 public void LogMessageBroadcast(string message, ServiceMessageType messageType)
 {
     foreach (var service in _services)
     {
         service.LogMessage(message, messageType);
     }
 }
        private IServiceMessage ParseMessage(Hashtable messageTable)
        {
            ServiceMessageType type    = messageTable.GetValue <byte>((int)SPC.Type, ServiceMessageType.Info.toByte()).toEnum <ServiceMessageType>();
            string             message = messageTable.GetValue <string>((int)SPC.Message, string.Empty);

            return(new ServiceMessage(type, message));
        }
Beispiel #3
0
 // parse segment number
 public ValidateSegmentRoutine(ServiceMessageType msgType, byte[] options)
     : base()
 {
     if (msgType == ServiceMessageType.Request)
     {
         SegmentID = options[1];
     }
 }
Beispiel #4
0
 public ServiceMessage(int id, string message, ServiceMessageType type, bool isSystem)
 {
     this.Id = id;
     this.Message = message;
     this.Type = type;
     this.ReferenceNumber = Guid.NewGuid();
     this.IsSystem = isSystem;
 }
 internal void LogMessageCore(string message, ServiceMessageType messageType)
 {
     if (!string.IsNullOrWhiteSpace(_instrumentationKey))
     {
         _telemetryClient.InstrumentationKey = _instrumentationKey;
         _telemetryClient.TrackTrace(message, GetSeverityLevel(messageType));
     }
     EventLog.WriteEntry(message, GetEventLogEntryType(messageType));
 }
Beispiel #6
0
        internal static bool IsValid(this ServiceMessageType value)
        {
            switch (value)
            {
            case ServiceMessageType.None:
            case ServiceMessageType.Information:
            case ServiceMessageType.Warning:
            case ServiceMessageType.Error:
                return(true);

            default:
                return(false);
            }
        }
Beispiel #7
0
 MsgsFile(string filename, bool isrequest, List <string> lines, string extraindent)
 {
     if (resolver == null)
     {
         resolver = new Dictionary <string, List <string> >();
     }
     serviceMessageType = isrequest ? ServiceMessageType.Request : ServiceMessageType.Response;
     filename           = filename.Replace(".srv", ".msg");
     if (!filename.Contains(".msg"))
     {
         throw new Exception("" + filename + " IS NOT A VALID SRV FILE!");
     }
     string[] sp = filename.Replace(Program.inputdir, "").Replace(".msg", "").Split('\\');
     classname  = sp[sp.Length - 1];
     Namespace += "." + filename.Replace(Program.inputdir, "").Replace(".msg", "");
     Namespace  = Namespace.Replace("\\", ".").Replace("..", ".");
     string[] sp2 = Namespace.Split('.');
     Namespace = "";
     for (int i = 0; i < sp2.Length - 2; i++)
     {
         Namespace += sp2[i] + ".";
     }
     Namespace += sp2[sp2.Length - 2];
     //THIS IS BAD!
     classname  = classname.Replace("/", ".");
     Name       = Namespace.Replace("Messages", "").TrimStart('.') + "." + classname;
     Name       = Name.TrimStart('.');
     classname  = Name.Split('.').Length > 1 ? Name.Split('.')[1] : Name;
     classname += (isrequest ? "Request" : "Response");
     Namespace  = Namespace.Trim('.');
     def        = new List <string>();
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i].Trim().Length == 0)
         {
             continue;
         }
         def.Add(lines[i]);
         if (Name.ToLower() == "string")
         {
             lines[i].Replace("String", "string");
         }
         SingleType test = KnownStuff.WhatItIs(this, lines[i], extraindent);
         if (test != null)
         {
             Stuff.Add(test);
         }
     }
 }
        internal static SeverityLevel GetSeverityLevel(ServiceMessageType messageType)
        {
            switch (messageType)
            {
            case ServiceMessageType.None:
            case ServiceMessageType.Information:
                return(SeverityLevel.Information);

            case ServiceMessageType.Warning:
                return(SeverityLevel.Warning);

            case ServiceMessageType.Error:
                return(SeverityLevel.Error);

            default:
                throw new ArgumentOutOfRangeException(nameof(messageType));
            }
        }
        internal static EventLogEntryType GetEventLogEntryType(ServiceMessageType messageType)
        {
            switch (messageType)
            {
            case ServiceMessageType.None:
            case ServiceMessageType.Information:
                return(EventLogEntryType.Information);

            case ServiceMessageType.Warning:
                return(EventLogEntryType.Warning);

            case ServiceMessageType.Error:
                return(EventLogEntryType.Error);

            default:
                throw new ArgumentOutOfRangeException(nameof(messageType));
            }
        }
Beispiel #10
0
        public virtual void LogMessage(Service service, string message, ServiceMessageType messageType)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (!messageType.IsValid())
            {
                throw new ArgumentOutOfRangeException(nameof(messageType));
            }

            service.LogMessageCore(message, messageType);
        }
        /// <summary>
        /// Logs a message to the event log associated with the service.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="messageType">The message type to log.</param>
        /// <remarks>
        /// In user-interactive mode, <see cref="ServiceMessageType.Information"/>
        /// message types are written to the console standard output stream, while
        /// <see cref="ServiceMessageType.Warning"/> and
        /// <see cref="ServiceMessageType.Error"/> message types are written to the
        /// console standard error stream.
        /// </remarks>
        public virtual void LogMessage(string message, ServiceMessageType messageType)
        {
            if (_manager != null)
            {
                _manager.LogMessage(this, message, messageType);
            }
            else
            {
                if (message == null)
                {
                    throw new ArgumentNullException(nameof(message));
                }

                if (!messageType.IsValid())
                {
                    throw new ArgumentOutOfRangeException(nameof(messageType));
                }

                LogMessageCore(message, messageType);
            }
        }
Beispiel #12
0
 public void ReceiveServiceMessage(ServiceMessageType messageType, string message)
 {
     if (nebulaObject)
     {
         var eventInstance = new ItemGeneric {
             ItemId          = nebulaObject.Id,
             ItemType        = nebulaObject.Type,
             CustomEventCode = (byte)CustomEventCode.ServiceMessage,
             EventData       = new Hashtable {
                 { (int)SPC.Type, (byte)messageType },
                 { (int)SPC.Message, message }
             }
         };
         var            eventData      = new EventData((byte)EventCode.ItemGeneric, eventInstance);
         SendParameters sendParameters = new SendParameters {
             Unreliable = false,
             ChannelId  = Settings.ItemEventChannel
         };
         ReceiveEvent(eventData, sendParameters);
     }
 }
Beispiel #13
0
        //specifically for SRV halves
        public MsgFile(MsgFileLocation filename, bool isRequest, List <string> lines, string extraIndent)
        {
            this.msgFileLocation = filename;
            this.extraindent     = extraIndent;
            this.lines           = lines;

            if (resolver == null)
            {
                resolver = new Dictionary <string, Dictionary <string, List <ResolvedMsg> > >();
            }

            serviceMessageType = isRequest ? ServiceMessageType.Request : ServiceMessageType.Response;
            // Parse The file name to get the classname
            classname = filename.basename;
            // Parse for the Namespace
            Namespace += "." + filename.package;
            Name       = filename.package + "." + classname;
            classname += (isRequest ? "Request" : "Response");
            Namespace  = Namespace.Trim('.');
            Package    = filename.package;
            if (!resolver.Keys.Contains(Package))
            {
                resolver.Add(Package, new Dictionary <string, List <ResolvedMsg> >());
            }
            if (!resolver[Package].ContainsKey(classname))
            {
                resolver[Package].Add(classname, new List <ResolvedMsg> {
                    new ResolvedMsg {
                        OtherType = Namespace + "." + classname, Definer = this
                    }
                });
            }
            else
            {
                resolver[Package][classname].Add(new ResolvedMsg {
                    OtherType = Namespace + "." + classname, Definer = this
                });
            }
        }
Beispiel #14
0
            public static RoutineInformation Parse(ServiceMessageType msgType, SIMOS18_RoutineIdentifier routineIdentifier, byte[] options)
            {
                RoutineInformation ret = null;

                switch (routineIdentifier)
                {
                case SIMOS18_RoutineIdentifier.SIMOS18_1_ERASE_SEGMENT:
                    ret = new EraseSegmentRoutine(msgType, options);
                    break;

                case SIMOS18_RoutineIdentifier.SIMOS18_1_VALIDATE_SEGMENT:
                    ret = new ValidateSegmentRoutine(msgType, options);
                    break;

                case SIMOS18_RoutineIdentifier.SIMOS18_1_START_FLASH:
                    ret = new StartFlashRoutine();
                    break;

                default:
                    break;
                }

                return(ret);
            }
        public ServiceUniqueNameInfo(string serviceAssemblyName, string serviceMessageName, ServiceMessageType messageType)
        {
            if (string.IsNullOrWhiteSpace(serviceAssemblyName))
            {
                throw new WindServiceBusException("serviceAssemblyName empty!", new ArgumentNullException("serviceAssemblyName"));
            }
            this.ServiceAssemblyName = serviceAssemblyName;

            if (string.IsNullOrWhiteSpace(serviceMessageName))
            {
                throw new WindServiceBusException("serviceMessageName empty!", new ArgumentNullException("serviceMessageName"));
            }
            this.ServiceMessageName = serviceMessageName;

            this.MessageType = messageType;
        }
Beispiel #16
0
 public ServiceMessage(ServiceMessageType type, string message)
 {
     this.Type    = type;
     this.Message = message;
     this.time    = DateTime.UtcNow;
 }
Beispiel #17
0
     MsgsFile(MsgFileLocation filename, bool isrequest, List<string> lines, string extraindent)
 {
     msgfilelocation = filename;
     if (resolver == null)
         resolver = new Dictionary<string, Dictionary<string, List<ResolvedMsg>>>();
     serviceMessageType = isrequest ? ServiceMessageType.Request : ServiceMessageType.Response;
     //Parse The file name to get the classname;
     classname = filename.basename;
     //Parse for the Namespace
     Namespace += "." + filename.package;
     Name = filename.package + "." + classname;
     classname += (isrequest ? "Request" : "Response");
     Namespace = Namespace.Trim('.');
     Package = filename.package;
     if (!resolver.Keys.Contains(Package))
         resolver.Add(Package, new Dictionary<string, List<ResolvedMsg>>());
     if (!resolver[Package].ContainsKey(classname))
         resolver[Package].Add(classname, new List<ResolvedMsg> { new ResolvedMsg { OtherType = Namespace + "." + classname, Definer = this } });
     else
         resolver[Package][classname].Add(new ResolvedMsg { OtherType = Namespace + "." + classname, Definer = this });
     def = new List<string>();
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i].Trim().Length == 0)
         {
             continue;
         }
         def.Add(lines[i]);
         SingleType test = KnownStuff.WhatItIs(this, lines[i], extraindent);
         if (test != null)
             Stuff.Add(test);
     }
 }
Beispiel #18
0
 public ServiceMessage(string message, ServiceMessageType type)
 {
     this.Message = message;
     this.Type = type;
     this.ReferenceNumber = Guid.NewGuid();
 }
Beispiel #19
0
     MsgsFile(string filename, bool isrequest, List<string> lines, string extraindent)
 {
     if (resolver == null) resolver = new Dictionary<string, List<string>>();
     serviceMessageType = isrequest ? ServiceMessageType.Request : ServiceMessageType.Response;
     filename = filename.Replace(".srv", ".msg");
     if (!filename.Contains(".msg"))
         throw new Exception("" + filename + " IS NOT A VALID SRV FILE!");
     string[] sp = filename.Replace(Program.inputdir, "").Replace(".msg", "").Split('\\');
     classname = sp[sp.Length - 1];
     Namespace += "." + filename.Replace(Program.inputdir, "").Replace(".msg", "");
     Namespace = Namespace.Replace("\\", ".").Replace("..", ".");
     string[] sp2 = Namespace.Split('.');
     Namespace = "";
     for (int i = 0; i < sp2.Length - 2; i++)
         Namespace += sp2[i] + ".";
     Namespace += sp2[sp2.Length - 2];
     //THIS IS BAD!
     classname = classname.Replace("/", ".");
     Name = Namespace.Replace("Messages", "").TrimStart('.') + "." + classname;
     Name = Name.TrimStart('.');
     classname = Name.Split('.').Length > 1 ? Name.Split('.')[1] : Name;
     classname += (isrequest ? "Request" : "Response");
     Namespace = Namespace.Trim('.');
     def = new List<string>();
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i].Trim().Length == 0)
         {
             continue;
         }
         def.Add(lines[i]);
         if (Name.ToLower() == "string")
             lines[i].Replace("String", "string");
         SingleType test = KnownStuff.WhatItIs(this, lines[i], extraindent);
         if (test != null)
             Stuff.Add(test);
     }
 }