Ejemplo n.º 1
0
        private void LogOutput(List <PackageData> list)
        {
            if (!TestLog.DevelopmentLog)
            {
                return;                          //Su dung test log moi vao ham nay
            }
            ulong  tag         = 0;
            int    count       = 0;
            long   size        = 0;
            long   totalRecord = 0;
            string msgName     = "";

            foreach (var publishMessage in list)
            {
                if (publishMessage.Message == null)
                {
                    continue;
                }
                if (publishMessage.Message is IControler)
                {
                    if (publishMessage.Message is JournalMessage)
                    {
                        tag = (publishMessage.Message as JournalMessage).Tag;
                    }
                    continue;
                }
                ;
                if (publishMessage.Message is IMessage)
                {
                    if (publishMessage.BytesMsg != null && publishMessage.BytesMsg.Count > 0)
                    {
                        count++;
                        size += publishMessage.BytesMsg.Sum(s => s.Length);
                        var msg = publishMessage.Message as IMessage;
                        totalRecord = msg.TotalRecord;
                        msgName     = msg.GetType().Name;
                    }
                }
            }

            if (tag > 0)
            {
                ReceiveData.LogPublish(tag, count, size);
            }

            if (totalRecord > 0 && !string.IsNullOrEmpty(msgName))
            {
                LogTo.Info("Message {0} is {1} record and {2} byte", msgName, totalRecord, size);
            }
        }