コード例 #1
0
        /// <summary>
        /// Creates the raw freeform buffer from the given udp entity.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="udpEntity">The UDP entity.</param>
        /// <returns>Raw freeform buffer.</returns>
        public static byte[] CreateBuffer(FF_FlowDirection direction, UdpFreeformEntity udpEntity)
        {
            using (ILogMethod method = Log.LogMethod(DYN_MODULE_NAME, "CreateEntity"))
            {
                byte[] result = default(byte[]);

                try
                {
                    // get the gmu factory for the given gmu ip adddress
                    _GMU_Factory gmuFactory = GetGMUFactory(udpEntity.AddressString);
                    if (gmuFactory != null)
                    {
                        if (udpEntity.EntityData != null)
                        {
                            result            = gmuFactory[direction].CreateBuffer(udpEntity.EntityData);
                            udpEntity.RawData = result;
                        }
                        else if (udpEntity.RawData != null)
                        {
                            result = udpEntity.RawData;
                        }
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
コード例 #2
0
        public IFreeformEntity_Msg CopyTo(FF_FlowDirection direction, FFCreateEntityRequest request)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "CopyTo"))
            {
                IFreeformEntity_Msg result = null;

                try
                {
                    result            = FreeformEntityFactory.CreateEntity <IFreeformEntity_Msg>(direction, request);
                    result.IpAddress  = this.IpAddress;
                    result.DeviceType = this.DeviceType;
                    result.SessionID  = this.SessionID;
                    if (!request.SkipTransactionId)
                    {
                        result.TransactionID = this.TransactionID;
                    }
                    result.IsSecured = this.IsSecured;
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
コード例 #3
0
 public MonTgtParserMappingG2HAttribute(FF_FlowDirection direction,
                                        Type freeformTargetType,
                                        int faultSource,
                                        int faultType,
                                        params int[] parendIds)
     : this(direction, freeformTargetType, null, faultSource, faultType, parendIds)
 {
 }
コード例 #4
0
 public MonTgtParserMappingH2GAttribute(FF_FlowDirection direction,
                                        Type monitorTargetType,
                                        int faultSource,
                                        int faultType,
                                        FF_AppId_H2G_PollCodes pollCode,
                                        FF_AppId_SessionIds sessionID)
     : this(direction, null, monitorTargetType, faultSource, faultType, pollCode, sessionID)
 {
 }
コード例 #5
0
 public MonTgtParserMappingH2GAttribute(FF_FlowDirection direction,
                                        Type freeformTargetType,
                                        Type monitorTargetType,
                                        int faultSource,
                                        int faultType,
                                        FF_AppId_H2G_PollCodes pollCode,
                                        FF_AppId_SessionIds sessionID)
     : base(direction, freeformTargetType, monitorTargetType, faultSource, faultType)
 {
     this.PollCode  = pollCode;
     this.SessionID = sessionID;
 }
コード例 #6
0
 protected MonTgtParserMappingAttribute(FF_FlowDirection direction,
                                        Type freeformTargetType,
                                        Type monitorTargetType,
                                        int faultSource,
                                        int faultType)
 {
     this.FreeformTargetType = freeformTargetType;
     this.MonitorTargetType  = monitorTargetType;
     this.FaultSource        = faultSource;
     this.FaultType          = faultType;
     this.Direction          = direction;
     this.IsPrimary          = (faultSource >= -1 && faultType >= -1);
 }
コード例 #7
0
 protected MonTgtParserMappingAttribute(FF_FlowDirection direction,
                                         Type freeformTargetType,
                                         Type monitorTargetType,
                                         int faultSource,
                                         int faultType)
 {
     this.FreeformTargetType = freeformTargetType;
     this.MonitorTargetType = monitorTargetType;
     this.FaultSource = faultSource;
     this.FaultType = faultType;
     this.Direction = direction;
     this.IsPrimary = (faultSource >= -1 && faultType >= -1);
 }
コード例 #8
0
 public IFFFactory this[FF_FlowDirection direction]
 {
     get
     {
         if (_factories.ContainsKey(direction))
         {
             return(_factories[direction]);
         }
         return(null);
     }
     set
     {
         if (!_factories.ContainsKey(direction))
         {
             _factories.Add(direction, value);
         }
     }
 }
コード例 #9
0
        /// <summary>
        /// Creates the raw freeform buffer from the given entity.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        /// Raw freeform buffer.
        /// </returns>
        public static byte[] CreateBuffer(FF_FlowDirection direction, IFreeformEntity entity)
        {
            using (ILogMethod method = Log.LogMethod(DYN_MODULE_NAME, "CreateEntity"))
            {
                IPAddress ipAddress = IPAddress.None;
                if (entity is IFreeformEntity_Msg)
                {
                    ipAddress = ((IFreeformEntity_Msg)entity).IpAddress2;
                }

                return(CreateBuffer(direction,
                                    new UdpFreeformEntity()
                {
                    Address = ipAddress,
                    EntityData = entity,
                }));
            }
        }
コード例 #10
0
        public string ToStringRaw(FF_FlowDirection direction)
        {
            if (_data == null) return string.Empty;

            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "ToStringRaw");
            StringBuilder sb = new StringBuilder();

            try
            {
                sb.Append((direction == FF_FlowDirection.G2H ? " ==> " : " <== ") + this.AddressString + " : ");
                FreeformHelper.ConvertBytesToHexString(this.RawData, sb, string.Empty);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return sb.ToString();
        }
コード例 #11
0
 public MonTgtParserMappingG2HAttribute(FF_FlowDirection direction,
                                         Type freeformTargetType,
                                         Type monitorTargetType,
                                         int faultSource,
                                         int faultType,
                                         params int[] parendIds)
     : base(direction, freeformTargetType, monitorTargetType, faultSource, faultType)
 {
     if (parendIds != null)
     {
         this.ParentIds = parendIds;
         StringBuilder sb = new StringBuilder();
         foreach (var parendId in parendIds)
         {
             if (sb.Length > 0) sb.Append("_");
             sb.Append(parendId);
         }
         this.ChildKey = sb.ToString();
     }
 }
コード例 #12
0
        public string ToStringRaw(FF_FlowDirection direction)
        {
            if (_data == null)
            {
                return(string.Empty);
            }

            ModuleProc    PROC = new ModuleProc(this.DYN_MODULE_NAME, "ToStringRaw");
            StringBuilder sb   = new StringBuilder();

            try
            {
                sb.Append((direction == FF_FlowDirection.G2H ? " ==> " : " <== ") + this.AddressString + " : ");
                FreeformHelper.ConvertBytesToHexString(this.RawData, sb, string.Empty);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(sb.ToString());
        }
コード例 #13
0
 public MonTgtParserMappingG2HAttribute(FF_FlowDirection direction,
                                        Type freeformTargetType,
                                        Type monitorTargetType,
                                        int faultSource,
                                        int faultType,
                                        params int[] parendIds)
     : base(direction, freeformTargetType, monitorTargetType, faultSource, faultType)
 {
     if (parendIds != null)
     {
         this.ParentIds = parendIds;
         StringBuilder sb = new StringBuilder();
         foreach (var parendId in parendIds)
         {
             if (sb.Length > 0)
             {
                 sb.Append("_");
             }
             sb.Append(parendId);
         }
         this.ChildKey = sb.ToString();
     }
 }
コード例 #14
0
        public static T CreateEntity <T>(FF_FlowDirection direction, FFCreateEntityRequest request)
            where T : IFreeformEntity
        {
            using (ILogMethod method = Log.LogMethod(DYN_MODULE_NAME, "CreateG2HEntity"))
            {
                T result = default(T);

                try
                {
                    _GMU_Factory gmuFactory = GetGMUFactory(request.IPAddress);
                    if (gmuFactory != null)
                    {
                        result = (T)gmuFactory[direction].CreateEntity(request);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
コード例 #15
0
        public static T CreateEntity <T>(FF_FlowDirection direction, byte[] buffer, string givenAddress)
            where T : IFreeformEntity_Msg
        {
            using (ILogMethod method = Log.LogMethod(DYN_MODULE_NAME, "CreateEntity"))
            {
                IFreeformEntity result = default(IFreeformEntity);

                try
                {
                    UdpFreeformEntity udpEntity = CreateUdpEntity(direction, buffer, givenAddress);
                    if (udpEntity != null)
                    {
                        result = CreateEntity(direction, udpEntity);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return((T)result);
            }
        }
コード例 #16
0
        /// <summary>
        /// Creates the freeform entity from given buffer.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="udpEntity">The UDP entity.</param>
        /// <returns>
        /// Freeform entity.
        /// </returns>
        public static IFreeformEntity CreateEntity(FF_FlowDirection direction, UdpFreeformEntity udpEntity)
        {
            using (ILogMethod method = Log.LogMethod(DYN_MODULE_NAME, "CreateEntity"))
            {
                IFreeformEntity result = default(IFreeformEntity);

                try
                {
                    // get the gmu factory for this ip address
                    _GMU_Factory gmuFactory = GetGMUFactory(udpEntity.AddressString);
                    if (gmuFactory != null &&
                        udpEntity.RawData != null)
                    {
                        result = gmuFactory[direction].CreateEntity(udpEntity.RawData, udpEntity.AddressString);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
コード例 #17
0
 public static T CreateEntity <T>(FF_FlowDirection direction, byte[] buffer)
     where T : IFreeformEntity_Msg
 {
     return(CreateEntity <T>(direction, buffer, string.Empty));
 }
コード例 #18
0
 protected MonTgtParserMappingAttribute(FF_FlowDirection direction,
                                         Type freeformTargetType)
     : this(direction, freeformTargetType, null, -1, -1)
 {
 }
コード例 #19
0
 public MonTgtParserMappingH2GAttribute(FF_FlowDirection direction,
                                         Type freeformTargetType,
                                         Type monitorTargetType,
                                         int faultSource,
                                         int faultType,
                                         FF_AppId_H2G_PollCodes pollCode,
                                         FF_AppId_SessionIds sessionID)
     : base(direction, freeformTargetType, monitorTargetType, faultSource, faultType)
 {
     this.PollCode = pollCode;
     this.SessionID = sessionID;
 }
コード例 #20
0
 public static string CreateBufferHexString(FF_FlowDirection direction, IFreeformEntity entity)
 {
     return(CreateBuffer(direction, entity).GetConvertBytesToHexString(string.Empty));
 }
コード例 #21
0
 public MonTgtParserMappingG2HAttribute(FF_FlowDirection direction,
                                        Type freeformTargetType,
                                        params int[] parendIds)
     : this(direction, freeformTargetType, -1, -1, parendIds)
 {
 }
コード例 #22
0
 protected MonTgtParserMappingAttribute(FF_FlowDirection direction,
                                        Type freeformTargetType)
     : this(direction, freeformTargetType, null, -1, -1)
 {
 }
コード例 #23
0
        public IFreeformEntity_Msg CopyTo(FF_FlowDirection direction, FFCreateEntityRequest request)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "CopyTo"))
            {
                IFreeformEntity_Msg result = null;

                try
                {
                    result = FreeformEntityFactory.CreateEntity<IFreeformEntity_Msg>(direction, request);
                    result.IpAddress = this.IpAddress;
                    result.DeviceType = this.DeviceType;
                    result.SessionID = this.SessionID;
                    if (!request.SkipTransactionId)
                        result.TransactionID = this.TransactionID;
                    result.IsSecured = this.IsSecured;
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return result;
            }
        }
コード例 #24
0
 public FreeformEntityKeyValue(string key, FF_FlowDirection value)
 {
     _key     = key;
     _value   = value;
     _fullKey = string.Format("{0}, {1}", _key, _value);
 }
コード例 #25
0
 public ExecutionStepKeyValue(string key, FF_FlowDirection value)
 {
     _key     = key;
     _value   = value;
     _fullKey = string.Format("{0}, {1}", _key, _value);
 }
コード例 #26
0
 public MonTgtParserMappingG2HAttribute(FF_FlowDirection direction,
                                         Type freeformTargetType,
                                         params int[] parendIds)
     : this(direction, freeformTargetType, -1, -1, parendIds)
 {
 }
コード例 #27
0
 public MonTgtParserMappingG2HAttribute(FF_FlowDirection direction,
                                         Type freeformTargetType,
                                         int faultSource,
                                         int faultType,
                                         params int[] parendIds)
     : this(direction, freeformTargetType, null, faultSource, faultType, parendIds) { }
コード例 #28
0
        /// <summary>
        /// Creates the raw freeform message from the given buffer.
        /// </summary>
        /// <param name="direction">The flow direction.</param>
        /// <param name="buffer">The given buffer.</param>
        /// <param name="givenAddress">The given address.</param>
        /// <returns>
        /// Raw freeform entity.
        /// </returns>
        public static UdpFreeformEntity CreateUdpEntity(FF_FlowDirection direction, byte[] buffer, string givenAddress)
        {
            using (ILogMethod method = Log.LogMethod("FreeformEntityFactory", "CreateUdpEntity"))
            {
                UdpFreeformEntity result = default(UdpFreeformEntity);

                try
                {
                    int minLength    = _headerLengths[(int)direction];
                    int hasIPAddress = _headerLengths[(int)direction];
                    int ipOffset     = 0;
                    int ipLength     = 0;

                    // invalid message
                    if (buffer == null ||
                        buffer.Length < minLength)
                    {
                        Log.Info("Parsing buffer (Failure) : Buffer was not in expected length.");
                        return(result);
                    }
                    method.Info("Parsing buffer (Success)");

                    // ip address
                    string    ipAddress2 = givenAddress;
                    IPAddress ipAddress  = null;
                    if (givenAddress.IsEmpty())
                    {
                        ipLength   = FreeformConstants.LEN_GMU_IPADDRESS;
                        ipAddress2 = string.Format("{0:D}.{1:D}.{2:D}.{3:D}",
                                                   buffer[0], buffer[1],
                                                   buffer[2], buffer[3]);
                        ipOffset += ipLength;
                    }

                    // parse the ip address
                    if (!IPAddress.TryParse(ipAddress2, out ipAddress))
                    {
                        method.Info("Parsing ip address (Failure) : Invalid ipaddress from the buffer.");
                        return(result);
                    }
                    method.Info("Parsing ip address (Success)");

                    // get the factory
                    int          dataLength = (buffer.Length - ipLength);
                    _GMU_Factory gmuFactory = GetGMUFactory(ipAddress2);

                    // raw data
                    byte[] dataWithoutIP = new byte[dataLength];
                    Buffer.BlockCopy(buffer, ipOffset, dataWithoutIP, 0, dataWithoutIP.Length);
                    result = new UdpFreeformEntity()
                    {
                        Address     = ipAddress,
                        RawData     = dataWithoutIP,
                        ProcessDate = DateTime.Now,
                    };
                    method.Info("Received ip address : " + ipAddress + ", Data Length : " + dataWithoutIP.Length);
                }
                catch (Exception ex)
                {
                    Log.Exception(method.PROC, ex);
                }

                return(result);
            }
        }
コード例 #29
0
 public MonTgtParserMappingH2GAttribute(FF_FlowDirection direction,
                                         Type monitorTargetType,
                                         int faultSource,
                                         int faultType,
                                         FF_AppId_H2G_PollCodes pollCode,
                                         FF_AppId_SessionIds sessionID)
     : this(direction, null, monitorTargetType, faultSource, faultType, pollCode, sessionID) { }
コード例 #30
0
 public static UdpFreeformEntity CreateUdpEntity(FF_FlowDirection direction, byte[] buffer)
 {
     return(CreateUdpEntity(direction, buffer, string.Empty));
 }