Ejemplo n.º 1
0
        /// <summary>
        /// Converts Freeform entity message to Moitor entity message
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public MonMsg_G2H CreateEntity(FFMsg_G2H request)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "CreateEntity"))
            {
                MonMsg_G2H result = null;
                try
                {
                    result = _monMsgParserG2H.CreateEntity(null, request) as MonMsg_G2H;
                    if (result == null)
                    {
                        Log.Info("Unable to create the monitor message");
                        return(null);
                    }

                    Stack <IFreeformEntity> st = new Stack <IFreeformEntity>();
                    request.CopyTo(st);

                    // push all the grandchildren into stack and process again
                    while (st.Count != 0)
                    {
                        IFreeformEntity child = st.Pop() as IFreeformEntity;
                        if (child.IsLeafNode)
                        {
                            continue;
                        }

                        MonitorEntity_MsgTgt target = this.CreateTargetEntity(child as IFreeformEntity_MsgTgt);
                        if (target != null)
                        {
                            result.AddTarget(target);
                        }

                        if (target is MonTgt_G2H_Status_CardBase)
                        {
                            result.CardNumber = (target as MonTgt_G2H_Status_CardBase).CardNumber;
                        }

                        child.CopyTo(st);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }