Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckInputParameters();

            var ctrlMessageList = (ListActivityMessageView)LoadControl("ListActivityMessageView.ascx");

            ctrlMessageList.MessageList = GetUserActivity();
            LoadedMessageCount          = ctrlMessageList.MessageList.Count;

            CommonContainerHolder.Controls.Add(ctrlMessageList);

            _ctrlMessageCount.SelectedValue = MessageCount.ToString();

            if (ThrownExceptions.Count > 0 && _socialNetworks.Count == 1)
            {
                _ctrlErrorDescription.InnerText = GetErrorDescription(_thrownExceptions[0]);
                _ctrlErrorDescriptionContainer.Style.Add(HtmlTextWriterStyle.Display, "block");
                _ctrlMessageNumberContainer.Visible = false;
            }

            /*if (ThrownExceptions.Count > 0 && _socialNetworks.Count > 1)
             * {
             *  _ctrlErrorDescription.InnerText = GetErrorDescription(_thrownExceptions[0]);
             *  _ctrlErrorDescriptionContainer.Style.Add(HtmlTextWriterStyle.Display, "block");
             * }*/
        }
Ejemplo n.º 2
0
        public NowDateTime GetNow()
        //public DateTime GetNow()
        {
            NowDateTime ndt = new NowDateTime();

            ndt.Now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            PersianCalendar pc  = new PersianCalendar();
            DateTime        dtN = DateTime.Now;

            ndt.NowDateFa     = pc.GetYear(dtN).ToString() + "/" + pc.GetMonth(dtN).ToString().PadLeft(2, '0') + "/" + pc.GetDayOfMonth(dtN).ToString().PadLeft(2, '0');
            ndt.NowTime       = dtN.ToString("HH:mm:ss");
            ndt.NowDateTimeFa = ndt.NowDateFa + " " + ndt.NowTime;
            // ---
            MessageCount oldmsc = (MessageCount)MemoryCacher.GetValue("MessageCount");

            if ((oldmsc == null) || (oldmsc.InsDateFa != ndt.NowDateFa))
            {
                MessageCount msc = MessageUtility.GetSmsCountByDate(ndt.NowDateFa);
                ndt.MsgCount = msc;
                MemoryCacher.Add("MessageCount", msc, DateTimeOffset.Now.AddSeconds(5));
            }
            else
            {
                ndt.MsgCount = oldmsc;
            }
            // ---
            return(ndt);
        }
Ejemplo n.º 3
0
        public override int GetHashCode()
        {
            var prime  = 31;
            var result = 1;

            result = (prime * result) + ((AppId == null) ? 0 : AppId.GetHashCode());
            result = (prime * result) + ((ClusterId == null) ? 0 : ClusterId.GetHashCode());
            result = (prime * result) + ((ContentEncoding == null) ? 0 : ContentEncoding.GetHashCode());
            result = (prime * result) + (int)(ContentLength ^ (ContentLength >> INT_MASK));
            result = (prime * result) + ((ContentType == null) ? 0 : ContentType.GetHashCode());
            result = (prime * result) + ((CorrelationId == null) ? 0 : CorrelationId.GetHashCode());
            result = (prime * result) + ((DeliveryMode == null) ? 0 : DeliveryMode.GetHashCode());
            result = (prime * result) + (int)(DeliveryTag ^ (DeliveryTag >> INT_MASK));
            result = (prime * result) + ((Expiration == null) ? 0 : Expiration.GetHashCode());
            result = (prime * result) + Headers.GetHashCode();
            result = (prime * result) + ((MessageCount == null) ? 0 : MessageCount.GetHashCode());
            result = (prime * result) + ((MessageId == null) ? 0 : MessageId.GetHashCode());
            result = (prime * result) + ((Priority == null) ? 0 : Priority.GetHashCode());
            result = (prime * result) + ((ReceivedExchange == null) ? 0 : ReceivedExchange.GetHashCode());
            result = (prime * result) + ((ReceivedRoutingKey == null) ? 0 : ReceivedRoutingKey.GetHashCode());
            result = (prime * result) + ((Redelivered == null) ? 0 : Redelivered.GetHashCode());
            result = (prime * result) + ((ReplyTo == null) ? 0 : ReplyTo.GetHashCode());
            result = (prime * result) + ((Timestamp == null) ? 0 : Timestamp.GetHashCode());
            result = (prime * result) + ((Type == null) ? 0 : Type.GetHashCode());
            result = (prime * result) + ((UserId == null) ? 0 : UserId.GetHashCode());
            return(result);
        }
Ejemplo n.º 4
0
 public static MessageCount GetInstance()
 {
     if (ins == null)
     {
         ins = new MessageCount();
     }
     return(ins);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Type=1003 应用被启用<para/>
 /// 处理 酷Q 的插件启动事件回调
 /// </summary>
 /// <param name="sender">事件的触发对象</param>
 /// <param name="e">事件的附加参数</param>
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     // 当应用被启用后,将收到此事件。
     // 如果酷Q载入时应用已被启用,则在_eventStartup(Type=1001,酷Q启动)被调用后,本函数也将被调用一次。
     // 如非必要,不建议在这里加载窗口。(可以添加菜单,让用户手动打开窗口)
     ApiModel.setModel(e.CQApi, e.CQLog);
     MessageCount.GetInstance();
 }
Ejemplo n.º 6
0
        public static MessageCount GetSmsCountByDate(string InsDateFa)
        {
            MessageCount msc = new MessageCount();

            msc.InsDateFa = InsDateFa;
            try
            {
                string commandtext = string.Format(@"select MessageType, count(*) as Cnt
                                    from (select distinct s.message,
                                                        Case
                                                            WHEN userid = 'QCUser' and
                                                                instr(s.message, 'رخداد') <> 0 THEN
                                                            '1'
                                                            WHEN userid = 'QCUser' and
                                                                instr(s.message, 'رخداد') = 0 THEN
                                                            '2'
                                                            WHEN userid = 'admin' then
                                                            '3'
                                                            WHEN userid is null then
                                                            '4'
                                                        END MessageType
                                            from sp_sms s
                                            where  s.message not like  '%یک بار%' and TO_char(s.insdate, 'YYYY/MM/DD', 'nls_calendar=persian') =
                                                '{0}')a 
                                    group by MessageType
                                ", InsDateFa);

                List <MsgStatistics> lst = new List <MsgStatistics>();
                lst = DBHelper.GetDBObjectByObj2(new MsgStatistics(), null, commandtext, "stopage").Cast <MsgStatistics>().ToList();
                //---
                if ((lst != null) && (lst.Count > 0))
                {
                    if (lst.Exists(x => x.MessageType == "1"))
                    {
                        msc.QCMsgCnt = lst.Where(x => x.MessageType == "1").First().Cnt;
                    }
                    if (lst.Exists(x => x.MessageType == "2"))
                    {
                        msc.AuditMsgCnt = lst.Where(x => x.MessageType == "2").First().Cnt;
                    }
                    if (lst.Exists(x => x.MessageType == "3"))
                    {
                        msc.PTMsgCnt = lst.Where(x => x.MessageType == "3").First().Cnt;
                    }
                    if (lst.Exists(x => x.MessageType == "4"))
                    {
                        msc.SPMsgCnt = lst.Where(x => x.MessageType == "4").First().Cnt;
                    }
                }
                return(msc);
            }
            catch (Exception ex)
            {
                DBHelper.LogFile(ex);
                return(msc);
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (BanaYakinButton != null)
            {
                BanaYakinButton.Dispose();
                BanaYakinButton = null;
            }

            if (BiryersecButton != null)
            {
                BiryersecButton.Dispose();
                BiryersecButton = null;
            }

            if (HeaderView != null)
            {
                HeaderView.Dispose();
                HeaderView = null;
            }

            if (ListeHazne != null)
            {
                ListeHazne.Dispose();
                ListeHazne = null;
            }

            if (MesajlarButton != null)
            {
                MesajlarButton.Dispose();
                MesajlarButton = null;
            }

            if (MessageCount != null)
            {
                MessageCount.Dispose();
                MessageCount = null;
            }

            if (MyProfileButton != null)
            {
                MyProfileButton.Dispose();
                MyProfileButton = null;
            }

            if (PopulerButton != null)
            {
                PopulerButton.Dispose();
                PopulerButton = null;
            }

            if (TabMenuHazne != null)
            {
                TabMenuHazne.Dispose();
                TabMenuHazne = null;
            }
        }
Ejemplo n.º 8
0
 public void Print()
 {
     Console.WriteLine("{0} ({1}): {2} Connected, {3} Received, {4},  Avg latency {5} ms",
                       TestPhase,
                       Elapsed.ToString(),
                       ClientsConnected.ToString(),
                       MessageCount.ToString(),
                       BytesAsString(),
                       AvgRoundLatencyMs);
 }
        private void SetMessageCount()
        {
            int messageCountFromCookie;

            if (HttpContext.Current.Request.Cookies[MessageCountCookieName] != null && Int32.TryParse(HttpContext.Current.Request.Cookies[MessageCountCookieName].Value, out messageCountFromCookie))
            {
                MessageCount = messageCountFromCookie;
            }

            _ctrlMessageCount.SelectedValue = MessageCount.ToString();
        }
Ejemplo n.º 10
0
        public ChunkInfo(Dictionary <string, byte[]> fields, byte[] data)
        {
            StartTime = BitConverter.ToInt64(fields["start_time"], 0);
            EndTime   = BitConverter.ToInt64(fields["end_time"], 0);
            ChunkPos  = BitConverter.ToInt64(fields["chunk_pos"], 0);
            Count     = BitConverter.ToInt32(fields["count"], 0);

            for (var i = 0; i < Count; i++)
            {
                var conn  = BitConverter.ToInt32(data, (i * 8));
                var count = BitConverter.ToInt32(data, (i * 8) + 4);
                MessageCount.Add(conn, count);
            }
        }
Ejemplo n.º 11
0
        public override void WriteLine(string message)
        {
            // PREFIX
            if ((verbosity & VerbosityType.Warn) == VerbosityType.Warn && (message.StartsWith("warn:") || message.StartsWith("quirks:")))
            {
                if (message.StartsWith("quirks:"))
                {
                    writer.Write("\r\n!!!! QUIRKS MODE: !!!!\r\n");
                }
                else
                {
                    writer.Write("WARN:");
                }
            }
            else if ((verbosity & VerbosityType.Error) == VerbosityType.Error && message.StartsWith("error:"))
            {
                writer.Write("ERROR:");
            }
            else if ((verbosity & VerbosityType.Fatal) == VerbosityType.Fatal && message.StartsWith("fatal:"))
            {
                writer.Write("\r\n-- FATAL --\r\n\r\n");
            }

            // Message
            if ((verbosity & VerbosityType.Debug) == VerbosityType.Debug && message.StartsWith("debug:") ||
                (verbosity & VerbosityType.Warn) == VerbosityType.Warn && (message.StartsWith("warn:") || message.StartsWith("quirks:")) ||
                (verbosity & VerbosityType.Fatal) == VerbosityType.Fatal && message.StartsWith("fatal:") ||
                (verbosity & VerbosityType.Error) == VerbosityType.Error && message.StartsWith("error:") ||
                (verbosity & VerbosityType.Information) == VerbosityType.Information && message.StartsWith("information:"))
            {
                writer.WriteLine(message.Substring(message.IndexOf(":") + 2));
            }

            // Count the message

            string category = null;

            if (message.Contains(":"))
            {
                category = message.Substring(0, message.IndexOf(":"));
            }

            if (!MessageCount.ContainsKey(category ?? ""))
            {
                MessageCount.Add(category ?? "", 0);
            }
            MessageCount[category ?? ""]++;
        }
Ejemplo n.º 12
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (MessageCount != 0)
            {
                hash ^= MessageCount.GetHashCode();
            }
            if (BytesCount != 0L)
            {
                hash ^= BytesCount.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 13
0
    //	public void OnSubmitText ()
    //	{
    //		if (string.IsNullOrEmpty (Inputfield.text)) {
    //			SendMessageButton.interactable = false;
    //		} else {
    //			SendMessageButton.interactable = true;
    //		}
    //	}

    public void GenerateMessageInCoOp(string message, string sender)
    {
        GameObject obj = null;

        if (sender == PlayerManager.Instance.playerInfo.Username)
        {
            obj = (GameObject)Instantiate(players_message);
        }
        else
        {
            obj = (GameObject)Instantiate(other_message);
        }

        obj.transform.SetParent(message_panelForCoOp, false);
        obj.transform.localScale = Vector3.one;

        // get messages from others and apply here....
        obj.transform.FindChild("Message").GetComponent <Text> ().text = message;
        //		obj.transform.FindChild ("Image").GetComponent<Image> ().sprite = PlayerImages [UnityEngine.Random.Range (0, PlayerImages.Length)];
        obj.transform.FindChild("UserName").GetComponent <Text> ().text  = sender;
        obj.transform.FindChild("Time Text").GetComponent <Text> ().text = DateTime.Now.ToString("hh:mm tt");

        Invoke("scrollValueinCoOp", 0.1f);

        if (!ScreenAndPopupCall.Instance.ChatInCoopIsShown)
        {
            CoOpEventController.Instance.ChatBagdeCountText.gameObject.SetActive(true);
            MessageCount++;
        }
        else
        {
            MessageCount = 0;
            CoOpEventController.Instance.ChatBagdeCountText.gameObject.SetActive(false);
        }
        CoOpEventController.Instance.ChatBagdeCountText.text = MessageCount.ToString();
    }
        /// <summary>Does the test.</summary>
        /// <param name="level">The level.</param>
        /// <param name="concurrency">The concurrency.</param>
        /// <param name="transactionMode">The transaction mode.</param>
        private void DoTest(MessageCount level, Concurrency concurrency, TransactionModeUtils.TransactionMode transactionMode)
        {
            var messageCount        = (int)level;
            var concurrentConsumers = (int)concurrency;
            var transactional       = transactionMode.IsTransactional();

            var template = this.CreateTemplate(concurrentConsumers);

            var latch = new CountdownEvent(messageCount);

            for (var i = 0; i < messageCount; i++)
            {
                template.ConvertAndSend(queue.Name, i + "foo");
            }

            var container = new SimpleMessageListenerContainer(template.ConnectionFactory);
            var listener  = new LifecyclePocoListener(latch);

            container.MessageListener     = new MessageListenerAdapter(listener);
            container.AcknowledgeMode     = transactionMode.AcknowledgeMode();
            container.ChannelTransacted   = transactionMode.IsTransactional();
            container.ConcurrentConsumers = concurrentConsumers;

            if (transactionMode.Prefetch() > 0)
            {
                container.PrefetchCount = transactionMode.Prefetch();
                container.TxSize        = transactionMode.TxSize();
            }

            container.QueueNames = new[] { queue.Name };
            container.AfterPropertiesSet();
            container.Start();

            try
            {
                var waited = latch.Wait(50);
                Logger.Info("All messages received before stop: " + waited);
                if (messageCount > 1)
                {
                    Assert.False(waited, "Expected not to receive all messages before stop");
                }

                Assert.AreEqual(concurrentConsumers, container.ActiveConsumerCount);
                container.Stop();
                Thread.Sleep(500);
                Assert.AreEqual(0, container.ActiveConsumerCount);
                if (!transactional)
                {
                    var messagesReceivedAfterStop = listener.Count;
                    waited = latch.Wait(500);
                    Logger.Info("All messages received after stop: " + waited);
                    if (messageCount < 100)
                    {
                        Assert.True(waited, "Expected to receive all messages after stop");
                    }

                    Assert.AreEqual(messagesReceivedAfterStop, listener.Count, "Unexpected additional messages received after stop");

                    for (var i = 0; i < messageCount; i++)
                    {
                        template.ConvertAndSend(queue.Name, i + "bar");
                    }

                    latch = new CountdownEvent(messageCount);
                    listener.Reset(latch);
                }

                var messagesReceivedBeforeStart = listener.Count;
                container.Start();
                var timeout = Math.Min(1 + messageCount / (4 * concurrentConsumers), 30);

                Logger.Debug("Waiting for messages with timeout = " + timeout + " (s)");
                waited = latch.Wait(timeout * 1000);
                Logger.Info("All messages received after start: " + waited);
                Assert.AreEqual(concurrentConsumers, container.ActiveConsumerCount);
                if (transactional)
                {
                    Assert.True(waited, "Timed out waiting for message");
                }
                else
                {
                    var count = listener.Count;
                    Assert.True(messagesReceivedBeforeStart < count, "Expected additional messages received after start: " + messagesReceivedBeforeStart + ">=" + count);
                    Assert.Null(template.Receive(queue.Name), "Messages still available");
                }

                Assert.AreEqual(concurrentConsumers, container.ActiveConsumerCount);
            }
            finally
            {
                // Wait for broker communication to finish before trying to stop
                // container
                Thread.Sleep(500);
                container.Shutdown();
                Assert.AreEqual(0, container.ActiveConsumerCount);
            }

            Assert.Null(template.ReceiveAndConvert(queue.Name));
        }
        /// <summary>Does the test.</summary>
        /// <param name="level">The level.</param>
        /// <param name="concurrency">The concurrency.</param>
        /// <param name="transactionMode">The transaction mode.</param>
        private void DoTest(MessageCount level, Concurrency concurrency, TransactionModeUtils.TransactionMode transactionMode)
        {
            var messageCount = (int)level;
            var concurrentConsumers = (int)concurrency;
            var transactional = transactionMode.IsTransactional();

            var template = this.CreateTemplate(concurrentConsumers);

            var latch = new CountdownEvent(messageCount);
            for (var i = 0; i < messageCount; i++)
            {
                template.ConvertAndSend(queue.Name, i + "foo");
            }

            var container = new SimpleMessageListenerContainer(template.ConnectionFactory);
            var listener = new LifecyclePocoListener(latch);
            container.MessageListener = new MessageListenerAdapter(listener);
            container.AcknowledgeMode = transactionMode.AcknowledgeMode();
            container.ChannelTransacted = transactionMode.IsTransactional();
            container.ConcurrentConsumers = concurrentConsumers;

            if (transactionMode.Prefetch() > 0)
            {
                container.PrefetchCount = transactionMode.Prefetch();
                container.TxSize = transactionMode.TxSize();
            }

            container.QueueNames = new[] { queue.Name };
            container.AfterPropertiesSet();
            container.Start();

            try
            {
                var waited = latch.Wait(50);
                Logger.Info("All messages received before stop: " + waited);
                if (messageCount > 1)
                {
                    Assert.False(waited, "Expected not to receive all messages before stop");
                }

                Assert.AreEqual(concurrentConsumers, container.ActiveConsumerCount);
                container.Stop();
                Thread.Sleep(500);
                Assert.AreEqual(0, container.ActiveConsumerCount);
                if (!transactional)
                {
                    var messagesReceivedAfterStop = listener.Count;
                    waited = latch.Wait(500);
                    Logger.Info("All messages received after stop: " + waited);
                    if (messageCount < 100)
                    {
                        Assert.True(waited, "Expected to receive all messages after stop");
                    }

                    Assert.AreEqual(messagesReceivedAfterStop, listener.Count, "Unexpected additional messages received after stop");

                    for (var i = 0; i < messageCount; i++)
                    {
                        template.ConvertAndSend(queue.Name, i + "bar");
                    }

                    latch = new CountdownEvent(messageCount);
                    listener.Reset(latch);
                }

                var messagesReceivedBeforeStart = listener.Count;
                container.Start();
                var timeout = Math.Min(1 + messageCount / (4 * concurrentConsumers), 30);

                Logger.Debug("Waiting for messages with timeout = " + timeout + " (s)");
                waited = latch.Wait(timeout * 1000);
                Logger.Info("All messages received after start: " + waited);
                Assert.AreEqual(concurrentConsumers, container.ActiveConsumerCount);
                if (transactional)
                {
                    Assert.True(waited, "Timed out waiting for message");
                }
                else
                {
                    var count = listener.Count;
                    Assert.True(messagesReceivedBeforeStart < count, "Expected additional messages received after start: " + messagesReceivedBeforeStart + ">=" + count);
                    Assert.Null(template.Receive(queue.Name), "Messages still available");
                }

                Assert.AreEqual(concurrentConsumers, container.ActiveConsumerCount);
            }
            finally
            {
                // Wait for broker communication to finish before trying to stop
                // container
                Thread.Sleep(500);
                container.Shutdown();
                Assert.AreEqual(0, container.ActiveConsumerCount);
            }

            Assert.Null(template.ReceiveAndConvert(queue.Name));
        }
Ejemplo n.º 16
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj == null)
            {
                return(false);
            }

            if (GetType() != obj.GetType())
            {
                return(false);
            }

            var other = (MessageProperties)obj;

            if (AppId == null)
            {
                if (other.AppId != null)
                {
                    return(false);
                }
            }
            else if (!AppId.Equals(other.AppId))
            {
                return(false);
            }

            if (ClusterId == null)
            {
                if (other.ClusterId != null)
                {
                    return(false);
                }
            }
            else if (!ClusterId.Equals(other.ClusterId))
            {
                return(false);
            }

            if (ContentEncoding == null)
            {
                if (other.ContentEncoding != null)
                {
                    return(false);
                }
            }
            else if (!ContentEncoding.Equals(other.ContentEncoding))
            {
                return(false);
            }

            if (ContentLength != other.ContentLength)
            {
                return(false);
            }

            if (ContentType == null)
            {
                if (other.ContentType != null)
                {
                    return(false);
                }
            }
            else if (!ContentType.Equals(other.ContentType))
            {
                return(false);
            }

            if (CorrelationId == null)
            {
                if (other.CorrelationId != null)
                {
                    return(false);
                }
            }
            else if (!CorrelationId.Equals(other.CorrelationId))
            {
                return(false);
            }

            if (DeliveryMode != other.DeliveryMode)
            {
                return(false);
            }

            if (DeliveryTag != other.DeliveryTag)
            {
                return(false);
            }

            if (Expiration == null)
            {
                if (other.Expiration != null)
                {
                    return(false);
                }
            }
            else if (!Expiration.Equals(other.Expiration))
            {
                return(false);
            }

            if (!Headers.Equals(other.Headers))
            {
                return(false);
            }

            if (MessageCount == null)
            {
                if (other.MessageCount != null)
                {
                    return(false);
                }
            }
            else if (!MessageCount.Equals(other.MessageCount))
            {
                return(false);
            }

            if (MessageId == null)
            {
                if (other.MessageId != null)
                {
                    return(false);
                }
            }
            else if (!MessageId.Equals(other.MessageId))
            {
                return(false);
            }

            if (Priority == null)
            {
                if (other.Priority != null)
                {
                    return(false);
                }
            }
            else if (!Priority.Equals(other.Priority))
            {
                return(false);
            }

            if (ReceivedExchange == null)
            {
                if (other.ReceivedExchange != null)
                {
                    return(false);
                }
            }
            else if (!ReceivedExchange.Equals(other.ReceivedExchange))
            {
                return(false);
            }

            if (ReceivedRoutingKey == null)
            {
                if (other.ReceivedRoutingKey != null)
                {
                    return(false);
                }
            }
            else if (!ReceivedRoutingKey.Equals(other.ReceivedRoutingKey))
            {
                return(false);
            }

            if (Redelivered == null)
            {
                if (other.Redelivered != null)
                {
                    return(false);
                }
            }
            else if (!Redelivered.Equals(other.Redelivered))
            {
                return(false);
            }

            if (ReplyTo == null)
            {
                if (other.ReplyTo != null)
                {
                    return(false);
                }
            }
            else if (!ReplyTo.Equals(other.ReplyTo))
            {
                return(false);
            }

            if (Timestamp == null)
            {
                if (other.Timestamp != null)
                {
                    return(false);
                }
            }
            else if (!Timestamp.Equals(other.Timestamp))
            {
                return(false);
            }

            if (Type == null)
            {
                if (other.Type != null)
                {
                    return(false);
                }
            }
            else if (!Type.Equals(other.Type))
            {
                return(false);
            }

            if (UserId == null)
            {
                if (other.UserId != null)
                {
                    return(false);
                }
            }
            else if (!UserId.Equals(other.UserId))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 17
0
        void ReleaseDesignerOutlets()
        {
            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BeklenenlerButton != null)
            {
                BeklenenlerButton.Dispose();
                BeklenenlerButton = null;
            }

            if (CevrimiciButton != null)
            {
                CevrimiciButton.Dispose();
                CevrimiciButton = null;
            }

            if (ContentHazne != null)
            {
                ContentHazne.Dispose();
                ContentHazne = null;
            }

            if (HeaderHazne != null)
            {
                HeaderHazne.Dispose();
                HeaderHazne = null;
            }

            if (MekanAdiLabell != null)
            {
                MekanAdiLabell.Dispose();
                MekanAdiLabell = null;
            }

            if (MenuHazne != null)
            {
                MenuHazne.Dispose();
                MenuHazne = null;
            }

            if (MesajlarButton != null)
            {
                MesajlarButton.Dispose();
                MesajlarButton = null;
            }

            if (MessageCount != null)
            {
                MessageCount.Dispose();
                MessageCount = null;
            }

            if (TumuButton != null)
            {
                TumuButton.Dispose();
                TumuButton = null;
            }
        }
Ejemplo n.º 18
0
        private void OnTimingFrame(MessageFrame frame)
        {
            var data = Encoding.ASCII.GetString(frame.PayloadBuffer.Array, frame.PayloadBuffer.Offset,
                                                frame.PayloadBuffer.Count);

            var parts = data.Split(';');

            if (data == "completed")
            {
                var clockSyncAndNetworkDelay = TimeSpan.FromMilliseconds(_timings.Average());
                var elapsedTime = DateTime.UtcNow.Subtract(Started).Subtract(clockSyncAndNetworkDelay);
                var mbits       = (MessageCount * MessageSize * 8L / elapsedTime.TotalSeconds) / 1000000;
                Console.WriteLine(DateTime.UtcNow.ToString("HH:mm:ss.fff") + " completed.");
                Console.WriteLine("Duration:      {0} ms", elapsedTime.TotalMilliseconds);
                Console.WriteLine("Message Size:  {0} bytes", MessageSize.ToString("N0"));
                Console.WriteLine("Message Count: {0}", MessageCount.ToString("N0"));
                Console.WriteLine("Total size:    {0} bytes", (MessageSize * MessageCount).ToString("N0"));
                Console.WriteLine("Msgs/sec:      {0}", (MessageCount / elapsedTime.TotalSeconds).ToString("N0"));
                Console.WriteLine("Throughput:    {0} Mbit/s", mbits.ToString("N1"));

                if (!File.Exists("result.csv"))
                {
                    File.AppendAllText("result.csv", "sep=,\r\n");
                    File.AppendAllText("result.csv", @"""Message size (bytes)"",""Message count"",""Transfer size (bytes)"",""Msgs/Ack"",""Duration (ms)"",""Msgs/sec"",""Troughput (Mbit/s)""" + "\r\n");
                }

                File.AppendAllText(@"result.csv",
                                   string.Format("{0},{1},{2},{3},{4},{5},{6}\r\n",
                                                 MessageSize.ToString(CultureInfo.InvariantCulture),
                                                 MessageCount.ToString(CultureInfo.InvariantCulture),
                                                 (MessageSize * MessageCount).ToString(CultureInfo.InvariantCulture),
                                                 MessagesPerAck,
                                                 ((long)elapsedTime.TotalMilliseconds).ToString(CultureInfo.InvariantCulture),
                                                 ((long)(MessageCount / elapsedTime.TotalSeconds)).ToString(CultureInfo.InvariantCulture),
                                                 mbits.ToString(CultureInfo.InvariantCulture)));
                _completedEvent.Set();

                return;
            }

            var timing = int.Parse(parts[0]);

            _timings.Add(timing);
            var date       = DateTime.Parse(parts[1], CultureInfo.InvariantCulture);
            var difference = DateTime.UtcNow.Subtract(date).TotalMilliseconds;

            _timings.Add((int)difference);

            if (_timings.Count == 10)
            {
                var buffer = Encoding.ASCII.GetBytes(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.ffff") + ";end");
                _client.Send(new MessageFrame(buffer));
            }
            else if (_timings.Count == 12)
            {
                Started = DateTime.UtcNow;
                Benchmark(_client);
            }
            else
            {
                var buffer = Encoding.ASCII.GetBytes(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.ffff"));
                _client.Send(new MessageFrame(buffer));
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Type=2 群消息<para/>
 /// 处理收到的群消息
 /// </summary>
 /// <param name="sender">事件的触发对象</param>
 /// <param name="e">事件的附加参数</param>
 public void GroupMessage(object sender, CQGroupMessageEventArgs e)
 {
     ApiModel.setModel(e.CQApi, e.CQLog);
     e.Handler = MessageCount.GetInstance().processGroupMessage(e);
 }
        private void Check(PeerConnection peer, FetchInventoryDataMessage message)
        {
            MessageTypes.MsgType type = message.InventoryMessageType;

            if (type == MessageTypes.MsgType.TX)
            {
                foreach (SHA256Hash hash in message.GetHashList())
                {
                    if (peer.GetInventorySpread(new Item(hash, InventoryType.Trx)) == null)
                    {
                        throw new P2pException(P2pException.ErrorType.BAD_MESSAGE, "not spread inventory : " + hash);
                    }
                }

                int fetch_count = peer.NodeStatistics.MessageStatistics.MineralInTrxFetchInvDataElement.GetCount(10);
                int max_count   = Manager.Instance.AdvanceService.TxCount.GetCount(60);
                if (fetch_count > max_count)
                {
                    throw new P2pException(
                              P2pException.ErrorType.BAD_MESSAGE, "maxCount: " + max_count + ", fetchCount: " + fetch_count);
                }
            }
            else
            {
                bool is_advance = true;
                foreach (SHA256Hash hash in message.GetHashList())
                {
                    if (peer.GetInventorySpread(new Item(hash, InventoryType.Block)) == null)
                    {
                        is_advance = false;
                        break;
                    }
                }

                if (is_advance)
                {
                    MessageCount out_advance_block = peer.NodeStatistics.MessageStatistics.MineralOutAdvBlock;
                    out_advance_block.Add(message.GetHashList().Count);

                    int out_block_count_1min = out_advance_block.GetCount(60);
                    int produced_block_2min  = 120000 / Parameter.ChainParameters.BLOCK_PRODUCED_INTERVAL;
                    if (out_block_count_1min > produced_block_2min)
                    {
                        throw new P2pException(
                                  P2pException.ErrorType.BAD_MESSAGE,
                                  "producedBlockIn2min: " + produced_block_2min + ", outBlockCountIn1min: " + out_block_count_1min);
                    }
                }
                else
                {
                    if (!peer.IsNeedSyncUs)
                    {
                        throw new P2pException(
                                  P2pException.ErrorType.BAD_MESSAGE, "no need sync");
                    }

                    foreach (SHA256Hash hash in message.GetHashList())
                    {
                        long block_num     = new BlockId(hash).Num;
                        long min_block_num = peer.LastSyncBlockId.Num - 2 * Parameter.NodeParameters.SYNC_FETCH_BATCH_NUM;

                        if (block_num < min_block_num)
                        {
                            throw new P2pException(
                                      P2pException.ErrorType.BAD_MESSAGE, "minBlockNum: " + min_block_num + ", blockNum: " + block_num);
                        }

                        if (peer.GetSyncBlockId(hash) != null)
                        {
                            throw new P2pException(
                                      P2pException.ErrorType.BAD_MESSAGE, new BlockId(hash).GetString() + " is exist");
                        }

                        peer.AddSyncBlockId(hash, Helper.CurrentTimeMillis());
                    }
                }
            }
        }
Ejemplo n.º 21
0
        static void GetMessagesResponseCallback(IAsyncResult result)
        {
            try
            {
                HttpWebRequest httpRequest = (HttpWebRequest)result.AsyncState;
                WebResponse response = httpRequest.EndGetResponse(result);
                if (null != response)
                {
                    Stream stream = response.GetResponseStream();
                    //StreamReader sr = new StreamReader(stream);
                    //string junk = sr.ReadToEnd();
                    //string junk2 = junk;

                    var serializer = new DataContractJsonSerializer(typeof(List<Messages.Message>));
                    List<Messages.Message> messages = new List<Messages.Message>();
                    messages = (List<Messages.Message>)serializer.ReadObject(stream);
                    stream.Close();

                    App.nearby.host.messages.messages_result = new Messages.Messages_result();
                    App.nearby.host.messages.messages_result.messages = new List<Messages.Message>();
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        App.ViewModelMain.ClearNewMessageCount();
                    });

                    Dictionary<int, MessageCount> counts = new Dictionary<int, MessageCount>();
                    MessageCount messageCount;

                    foreach (var message in messages)
                    {
                        foreach (var participant in message.participants)
                        {
                            if (null != App.nearby.host.profile.user_Result)  // Profile might not be cached yet
                            {
                                if (participant.uid == App.nearby.host.profile.user_Result.uid)
                                {   // Filter all but threads where curent host is a participant
                                    App.nearby.host.messages.messages_result.messages.Add(message);
                                }
                            }

                            if (0 < message.is_new || getAllMessages) // is_new represents the number of new messages, it's not a new message boolean!
                            {   // Aggregate message counts
                                if (counts.ContainsKey(participant.uid))
                                {
                                    counts.TryGetValue(participant.uid, out messageCount);
                                }
                                else
                                {
                                    messageCount = new MessageCount();
                                }
                                messageCount.count = messageCount.count + message.is_new;
                                messageCount.name = participant.fullname;
                                counts.Remove(participant.uid);
                                counts.Add(participant.uid, messageCount);
                            }
                        }
                    }
                    foreach (var item in counts)
                    {   // This host is in a new thread with us, automatically pin and show message count in UI
                        messageCount = item.Value;
                        App.pinned.newMessage(item.Key, messageCount.name, messageCount.count);
                    }
                  App.nearby.loadMessages();
                }
                response.Close();
            }
            catch (WebException e)
            {
                System.Diagnostics.Debug.WriteLine("Exception Message " + e.Message);
                requestManager.RequestComplete(WebService.Request.getMessages);
                return;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception Message " + e.Message);
                requestManager.RequestComplete(WebService.Request.getMessages);
                return;
            }
            requestManager.RequestComplete(WebService.Request.getMessages);
        }
        void ReleaseDesignerOutlets()
        {
            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BekletmeButton != null)
            {
                BekletmeButton.Dispose();
                BekletmeButton = null;
            }

            if (CallButton != null)
            {
                CallButton.Dispose();
                CallButton = null;
            }

            if (CheckinButton != null)
            {
                CheckinButton.Dispose();
                CheckinButton = null;
            }

            if (HeaderView != null)
            {
                HeaderView.Dispose();
                HeaderView = null;
            }

            if (KonumButton != null)
            {
                KonumButton.Dispose();
                KonumButton = null;
            }

            if (Mapview != null)
            {
                Mapview.Dispose();
                Mapview = null;
            }

            if (MekandakilerButton != null)
            {
                MekandakilerButton.Dispose();
                MekandakilerButton = null;
            }

            if (mekanTitle != null)
            {
                mekanTitle.Dispose();
                mekanTitle = null;
            }

            if (MessageButton != null)
            {
                MessageButton.Dispose();
                MessageButton = null;
            }

            if (MessageCount != null)
            {
                MessageCount.Dispose();
                MessageCount = null;
            }

            if (RatingButton != null)
            {
                RatingButton.Dispose();
                RatingButton = null;
            }
        }