Exemplo n.º 1
0
 private void RefreshPage(ProgressMessage obj)
 {
     Progress = obj.Percent;
     Message  = obj.Message;
     RaisePropertyChanged(nameof(Progress));
     RaisePropertyChanged(nameof(Message));
 }
Exemplo n.º 2
0
        protected override void ReceiveCancelMessage(CancelMessage message)
        {
            if (!TaskCanceled) // prevent multiple log entries
            {
                if (message.CancelCompleteTask)
                {
                    HandleCancelation(message);
                }

                Status             = TaskStatus.Canceled;
                CancelationMessage = message.CancelationMessage;
                End = DateTime.Now;

                LogToUi(message.LogLevel,
                        string.Format("{0} {1}", Status.ToString(), message.CancelationMessage)
                        );


                var progressMsg = new ProgressMessage(
                    Id,
                    1d,
                    string.Format("'{0}' '{1}'! {2}", Title, Status.ToString(), message.CancelationMessage));

                eventAggregator.PublishOnUIThread(progressMsg);
            }
        }
        public async Task UpdateAsync(string domainName, string recordName, string newValue)
        {
            if (string.IsNullOrEmpty(newValue))
            {
                using (var progress = new ProgressMessage("detecting your external IP address..."))
                {
                    newValue = await GetMyPublicIp();

                    progress.Message += " " + newValue + ".";
                }
            }

            GoDaddyDnsRecord record;

            using (var progress = new ProgressMessage("fetching details..."))
            {
                record = (await _goDaddyClient.GetDomainRecordDetailsAsync(domainName, "A", recordName)).FirstOrDefault();

                PoshWriteLine($"IP: {{{record.Data}}}, TTL: {{{record.Ttl}}}", ConsoleColor.Green, ConsoleColor.Magenta);
            }

            using (var progress = new ProgressMessage($"updating IP address to {newValue}..."))
            {
                record.Data = newValue;

                await _goDaddyClient.SetDomainRecordDetailsAsync(domainName, "A", recordName, new[] { record });
            }
        }
Exemplo n.º 4
0
        public async Task DownloadRecordTarget(HashSet <string> recordsIds, CancellationToken cancellationToken)
        {
            await Task.Factory.StartNew(() =>
            {
                var z = 0;
                using (var autoSave = Context.I.DbContainerAutoSave)
                {
                    var dbContainer = autoSave.DBContainer;

                    var records = dbContainer.AudioBookSet.GetRecordsByKeys(recordsIds).ToArray();

                    foreach (var record in records)
                    {
                        ProgressMessage.Report(z, records.Length);
                        DownloadRecordTarget(null, record, dbContainer, cancellationToken);
                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }
                        dbContainer.SaveChanges();
                        z++;
                    }
                }
            }, cancellationToken);
        }
Exemplo n.º 5
0
 protected void ProgressHandler(ProgressMessage progressMessage)
 {
     WriteProgress(new ProgressRecord(progressMessage.ActivityId, progressMessage.Activity, progressMessage.Description)
     {
         PercentComplete = progressMessage.PercentComplete, RecordType = progressMessage.MessageType.CastToString().CastToEnum <ProgressRecordType>()
     });
 }
Exemplo n.º 6
0
        public async Task RunTimer(CancellationToken token)
        {
            NotificationCompat.Builder builder = GetNotificationBuilder();
            notificationManager = (NotificationManager)GetSystemService(NotificationService);

            await Task.Run(() =>
            {
                timer = Observable.Interval(TimeSpan.FromSeconds(1))
                        .Subscribe(s =>
                {
                    var progress = new ProgressMessage {
                        Message = new DateTime(TimeSpan.FromSeconds(s).Ticks).ToString("mm:ss")
                    };

                    notificationManager.Notify(NotificationIdServiceInProgress, GetNotificationBuilder(progress.Message).Build());

                    MessagingCenter.Send(progress, nameof(ProgressMessage));
                });

                cancellationTokenSource.Token.Register(() =>
                {
                    timer.Dispose();
                    notificationManager.Cancel(NotificationIdServiceInProgress);
                });
            }, token);
        }
Exemplo n.º 7
0
        public void OnTestEvent(string report)
        {
            var progressMessage = new ProgressMessage(report);
            var bytes           = new BinarySerializationProtocol().Encode(progressMessage);

            _clientSocket.Send(bytes);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 私聊消息处理事件
        /// </summary>
        private static void FriendMessageHandler(string fn)
        {
            Task task = new Task(() =>
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                ReceiveMessage PrivateMessage = JsonConvert.DeserializeObject <ReceiveMessage>(fn);
                string message = ProgressMessage.Start(PrivateMessage);
                var b          = Encoding.UTF8.GetBytes(message);
                message        = GB18030.GetString(Encoding.Convert(Encoding.UTF8, GB18030, b));
                int msgID      = PrivateMessage.CurrentPacket.Data.MsgSeq;

                ReceiveMessage.Data data = PrivateMessage.CurrentPacket.Data;
                if (PrivateMessage.CurrentPacket.Data.FromUin == Save.curentQQ && !Save.ReceiveSelfMsg)
                {
                    Dll.AddMsgToSave(new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin));
                    return;
                }
                int logid = LogHelper.WriteLog(LogLevel.InfoReceive, "OPQBot框架", "[↓]收到好友消息", $"QQ:{data.FromUin} {message}", "处理中...");
                var c     = new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin);
                Dll.AddMsgToSave(c);
                int pluginid = pluginManagment.CallFunction(FunctionEnums.Functions.PrivateMsg, 11, msgID, data.FromUin, Marshal.StringToHGlobalAnsi(message), 0);
                stopwatch.Stop();
                string updatemsg = $"√ {stopwatch.ElapsedMilliseconds / (double)1000:f2} s";
                if (pluginid > 0)
                {
                    updatemsg += $"(由 {pluginManagment.Plugins[pluginid - 1].appinfo.Name} 结束消息处理)";
                }
                LogHelper.UpdateLogStatus(logid, updatemsg);
            }); task.Start();
        }
Exemplo n.º 9
0
 // Callback that fires when a progress update is made.
 private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     // We get progress from GenTest, and from the IAssembler/IGenerator classes.  This
     // is necessary to make cancellation work right, and allows us to show the
     // asm/gen progress messages if we want to.
     if (e.UserState is ProgressMessage)
     {
         ProgressMessage msg = e.UserState as ProgressMessage;
         if (msg.HasColor)
         {
             progressRichTextBox.AppendText(msg.Text, msg.Color);
         }
         else
         {
             // plain foreground text color
             progressRichTextBox.AppendText(msg.Text, mDefaultColor);
         }
         progressRichTextBox.ScrollToEnd();
     }
     else
     {
         // Most progress updates have an e.ProgressPercentage value and a blank string.
         if (!string.IsNullOrEmpty((string)e.UserState))
         {
             Debug.WriteLine("Sub-progress: " + e.UserState);
         }
     }
 }
Exemplo n.º 10
0
        private Boolean IsCancellingImport(ProviderPortalEntities _db)
        {
            // Check if we have stopped the import
            ProgressMessage pm = _db.ProgressMessages.FirstOrDefault(x => x.MessageArea == MessageArea);

            return(pm == null || pm.MessageText == cancelImportMessage);
        }
        /// <summary>
        /// 传输文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="blockSize"></param>
        public void RunFileTransfer(string path, int blockSize = 8192)
        {
            //prepare
            PrepareReadFile(path);
            var fileBlockInfo = ClacFileBlockInfo(path, blockSize);
            var request       = GenerateTransferRequest(fileBlockInfo);

#if DEBUG
            Console.WriteLine("Preparing send file");
#endif
            //check progress handler
            ProgressMessage progress = _progressHandler?.ProgressMessageDic.ContainsKey(path) == true ? _progressHandler?.ProgressMessageDic[path] : new ProgressMessage();

            //send
            OnSendFile(path, progress, fileBlockInfo, request);

            //远程检查MD5
            request.IsSendingOver = true;
            var checkResponsed = _sendAdapter.UpdateFileData(request);

            //判断是否需要重发文件 check if need resend
            var result = ReSendFile(path, fileBlockInfo, request, checkResponsed);

            if (progress != null)
            {
                progress.StateMsg = result ? "校验成功!" : "校验失败!";
                _progressHandler?.OnSendEnd(fileBlockInfo.FileName, result);
#if DEBUG
                Console.WriteLine($"{progress.StateMsg}");
#endif
            }

            //finish send
            FinishReadFile(path);
        }
Exemplo n.º 12
0
 public void Handle(ProgressMessage message)
 {
     if (message.Progress >= 1d && message.TaskId == recentLoadTask)
     {
         CanReLoad = true;
     }
 }
Exemplo n.º 13
0
 private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (e.UserState is ProgressMessage)
     {
         ProgressMessage msg = e.UserState as ProgressMessage;
         if (msg.HasColor)
         {
             progressRichTextBox.AppendText(msg.Text, msg.Color);
         }
         else
         {
             // plain foreground text color
             progressRichTextBox.AppendText(msg.Text);
         }
         progressRichTextBox.SelectionStart = progressRichTextBox.Text.Length;
         progressRichTextBox.ScrollToCaret();
     }
     else
     {
         if (!string.IsNullOrEmpty((string)e.UserState))
         {
             Debug.WriteLine("Weird progress: " + e.UserState);
         }
     }
 }
        public async Task MonitorEventsAsync_EmptyContainersList_CanBeCancelled()
        {
            var progress = new ProgressMessage()
            {
                _onMessageCalled = (m) => { }
            };

            var cts = new CancellationTokenSource();

            cts.CancelAfter(1000);

            var task = _client.System.MonitorEventsAsync(new ContainerEventsParameters(), progress, cts.Token);

            var taskIsCancelled = false;

            try
            {
                await task;
            }
            catch
            {
                // Exception is not always thrown when cancelling token
                taskIsCancelled = true;
            }

            // On local develop machine task is completed.
            // On CI/CD Pipeline exception is thrown, not always
            Assert.True(task.IsCompleted || taskIsCancelled);
        }
Exemplo n.º 15
0
    void onProgress(NetworkMessage message)
    {
        ProgressMessage pMessage = message.ReadMessage <ProgressMessage>();

        _progress += pMessage.progress;
        GetComponent <Slider>().value = _progress / (float)maxProgress;

        if (_progress == maxProgress)
        {
            new WinMessage().sendToServer();
            FindObjectOfType <TestInstructionReciever>().disable();
            foreach (MoveDownUp d in FindObjectsOfType <MoveDownUp>())
            {
                d.moveUp();
            }
            _progress = startProgress;
        }

        if (_progress == 0)
        {
            new LossMessage().sendToServer();
            FindObjectOfType <TestInstructionReciever>().disable();
            foreach (MoveDownUp d in FindObjectsOfType <MoveDownUp>())
            {
                d.moveUp();
            }
        }
    }
Exemplo n.º 16
0
        protected void SendProgress()
        {
            if (!TaskCanceled)
            {
                if (PercentCompleted > 0d && Status == TaskStatus.Started)
                {
                    Status = TaskStatus.InProgress;
                }

                if (PercentCompleted >= 1d && Status != TaskStatus.Failed && Status != TaskStatus.Canceled &&
                    Status != TaskStatus.Completed)
                {
                    Status = TaskStatus.Completed;
                }

                if (PercentCompleted != 1d && Start == null)
                {
                    Start = DateTime.Now;
                    LogToUi(LogLevel.Information,
                            string.Format("Started '{1}' (TaskID: '{0}')", Id, Title)
                            );
                }

                if (PercentCompleted >= 1d && End == null)
                {
                    End = DateTime.Now;
                    LogToUi(Core.Models.Enums.LogLevel.Information,
                            string.Format("{0} {1}", Status.ToString(), StatusReport)
                            );

                    // as task list ist deleted after restart, no need to delete tasks here
                }

                ProgressMessage progressMsg;

                if (PercentCompleted < 1d)
                {
                    if (Status == TaskStatus.InProgress || (Status == TaskStatus.Started && PercentCompleted == 0))
                    {
                        progressMsg = new ProgressMessage(Id, PercentCompleted, string.Format("'{0}' in progress ({1:F0}%), please wait ...", Title, PercentCompleted * 100, Status.ToString()));
                    }
                    else
                    {
                        progressMsg = new ProgressMessage(Id, PercentCompleted, string.Format("Attention! '{0}' '{2}' ({1:F0}%), please wait ...", Title, PercentCompleted * 100, Status.ToString()));
                        LogToUi(LogLevel.Warning, progressMsg.Title);
                    }
                }
                else
                {
                    progressMsg = new ProgressMessage(Id, PercentCompleted, string.Format("'{0}' '{2}'! Elapsed time: {1}", Title, ElapsedTime, Status.ToString()));
                    if (isSubTaskActor && ParentTaskActor != null)
                    {
                        ParentTaskActor.Tell(progressMsg);
                    }
                }

                eventAggregator.PublishOnUIThread(progressMsg);
            }
        }
Exemplo n.º 17
0
 private void ViewInProfileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listViewMessages.SelectedIndices.Count > 0)
     {
         ProgressMessage pm = this.progressMessages[listViewMessages.SelectedIndices[0]];
         ShowProfileDialog(pm.Service, pm.Operation);
     }
 }
Exemplo n.º 18
0
        public void SendProgress(object data)
        {
            var progressMessage = new ProgressMessage {
                Data = data
            };

            MessagingCenter.Send(progressMessage, nameof(ProgressMessage));
        }
        private void OnSendFile(string path, FileStream fs, ProgressMessage progress, FileBlockInfo fileBlockInfo, FileTransferRequest request)
        {
            fs.Position = 0;
            long positionOffset = 0;
            int  sendBlockSize  = request.EachBlockSize;

            if (progress != null)
            {
                progress.Title    = fileBlockInfo.FileName;
                progress.MaxValue = fileBlockInfo.BlockCount;
                progress.StateMsg = "Prepare OK";
                try
                {
                    _progressHandler?.OnSendStart(fileBlockInfo.FileName, progress);
#if DEBUG
                    Console.WriteLine(progress.StateMsg);
#endif
                }
                catch
                {
                    // ignored
                }
            }
            //普通循环读取和发送文件
            while (fs.Position < fs.Length)
            {
                request.BlockData  = null;
                request.SeekOffset = positionOffset;

                var buffer = ReadFileBytes(path, fs.Position, sendBlockSize);
                request.BlockData = buffer;

                var responsed = _sendAdapter.UpdateFileData(request);
                _responsedHandler?.HandleResponsed(responsed);//等待外部对回应进行处理
                positionOffset = responsed.RemoteStreamPosition;

                OfflineReSendCheck(responsed, request, fileBlockInfo, fs.Position, ref positionOffset, ref sendBlockSize); //文件离线重传检查
                fs.Position = positionOffset;                                                                              //进度对齐

                if (progress != null)
                {
                    progress.ProgressValue = request.BlockIndex;
                    try
                    {
                        _progressHandler?.OnSending(fileBlockInfo.FileName);
#if DEBUG
                        Console.Write($"{progress.ProgressValue}/{progress.MaxValue}");
                        Console.SetCursorPosition(0, Console.CursorTop);
                        ClearCurrentConsoleLine();
#endif
                    }
                    catch
                    {
                        // ignored
                    }
                }
            }
        }
Exemplo n.º 20
0
 public virtual void Progress(ProgressMessage message)
 {
     if (message != null)
     {
         string format = $"{Name} task propress update Message: {message.Message}, Percent : {message.Percent}";
         Console.WriteLine(format);
         Store(format);
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// 群消息处理事件
        /// </summary>
        private static void GroupMessageHandler(string fn)
        {
            Task task = new Task(() =>
            {
                string msg          = fn;
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                ReceiveMessage groupMessage = JsonConvert.DeserializeObject <ReceiveMessage>(msg);
                ReceiveMessage.Data data    = groupMessage.CurrentPacket.Data;
                //群文件事件
                if (groupMessage.CurrentPacket.Data.MsgType == "GroupFileMsg")
                {
                    JObject fileupload        = JObject.Parse(data.Content);
                    MemoryStream stream       = new MemoryStream();
                    BinaryWriter binaryWriter = new BinaryWriter(stream);
                    BinaryWriterExpand.Write_Ex(binaryWriter, fileupload["FileID"].ToString());
                    BinaryWriterExpand.Write_Ex(binaryWriter, fileupload["FileName"].ToString());
                    BinaryWriterExpand.Write_Ex(binaryWriter, Convert.ToInt64(fileupload["FileSize"].ToString()));
                    BinaryWriterExpand.Write_Ex(binaryWriter, 0);
                    pluginManagment.CallFunction(FunctionEnums.Functions.Upload, 1, GetTimeStamp(), data.FromGroupId,
                                                 data.FromUserId, Convert.ToBase64String(stream.ToArray()));
                    stopwatch.Stop();
                    LogHelper.WriteLog(LogLevel.InfoReceive, "OPQBot框架", "文件上传", $"来源群:{data.FromGroupId}({data.FromGroupName}) 来源QQ:{data.FromUserId}({data.FromNickName}) " +
                                       $"文件名:{fileupload["FileName"]} 大小:{Convert.ToDouble(fileupload["FileSize"]) / 1000}KB FileID:{fileupload["FileID"]}", $"√ {stopwatch.ElapsedMilliseconds / (double)1000:f2} s");
                    return;
                }
                string message = ProgressMessage.Start(groupMessage);
                var b          = Encoding.UTF8.GetBytes(message);
                message        = GB18030.GetString(Encoding.Convert(Encoding.UTF8, GB18030, b));

                //表示自己发送出去的消息, 写入消息列表
                int msgID = groupMessage.CurrentPacket.Data.MsgSeq;
                if (groupMessage.CurrentPacket.Data.FromUserId == Save.curentQQ && !Save.ReceiveSelfMsg)
                {
                    Dll.AddMsgToSave(new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin));
                    return;
                }
                int logid = LogHelper.WriteLog(LogLevel.InfoReceive, "OPQBot框架", "[↓]收到消息", $"群:{data.FromGroupId}({data.FromGroupName}) QQ:{data.FromUserId}({data.FromNickName}) {message}", "处理中...");
                var c     = new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin);
                Dll.AddMsgToSave(c);//保存消息到消息列表
                byte[] messageBytes = GB18030.GetBytes(message + "\0");
                var messageIntptr   = Marshal.AllocHGlobal(messageBytes.Length);
                Marshal.Copy(messageBytes, 0, messageIntptr, messageBytes.Length);
                //调用插件功能
                int pluginid = pluginManagment.CallFunction(FunctionEnums.Functions.GroupMsg, 2, msgID, data.FromGroupId, data.FromUserId,
                                                            "", messageIntptr, 0);
                Marshal.FreeHGlobal(messageIntptr);
                GC.Collect();
                stopwatch.Stop();
                string updatemsg = $"√ {stopwatch.ElapsedMilliseconds / (double)1000:f2} s";
                if (pluginid > 0)
                {
                    updatemsg += $"(由 {pluginManagment.Plugins[pluginid - 1].appinfo.Name} 结束消息处理)";
                }
                LogHelper.UpdateLogStatus(logid, updatemsg);
            }); task.Start();
        }
Exemplo n.º 22
0
        //--------------------------------------------------------------------------------------------------

        public void OnProcessingStarted(Entity referenceEntity, string description)
        {
            _ProcessingEntitiesStack.Push(referenceEntity);

            if (_ProcessingEntitiesStack.Count == 1)
            {
                ProgressMessage?.Invoke(this, new ProgressMessageEventArgs(ProgressMessageEventReason.ProcessingStarted, description));
            }
        }
Exemplo n.º 23
0
        private void DeleteProgressMessage()
        {
            ProgressMessage pm = db.ProgressMessages.Find(MessageArea);

            if (pm != null)
            {
                db.Entry(pm).State = EntityState.Deleted;
                db.SaveChanges();
            }
        }
Exemplo n.º 24
0
        public void StartTest()
        {
            string json   = "{\r\n  \"CurrentPacket\": {\r\n    \"WebConnId\": \"\",\r\n    \"Data\": {\r\n      \"FromGroupId\": 891787846,\r\n      \"FromGroupName\": \"水银控♂制台\",\r\n      \"FromUserId\": 863450594,\r\n      \"FromNickName\": \"(*´◐∀◐`*)智障\",\r\n      \"Content\": \"{\\\"Content\\\":\\\"[[分享]寄世界于东方~Otomad World]请使用最新版本手机QQ查看{\\\\\\\"app\\\\\\\":\\\\\\\"com.tencent.structmsg\\\\\\\",\\\\\\\"desc\\\\\\\":\\\\\\\"音乐\\\\\\\",\\\\\\\"view\\\\\\\":\\\\\\\"music\\\\\\\",\\\\\\\"ver\\\\\\\":\\\\\\\"0.0.0.1\\\\\\\",\\\\\\\"prompt\\\\\\\":\\\\\\\"[分享]寄世界于东方~Otomad World\\\\\\\",\\\\\\\"meta\\\\\\\":{\\\\\\\"music\\\\\\\":{\\\\\\\"action\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"android_pkg_name\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"app_type\\\\\\\":1,\\\\\\\"appid\\\\\\\":100495085,\\\\\\\"desc\\\\\\\":\\\\\\\"玛丽的对头\\\\\\\\/Snowf_Ake\\\\\\\",\\\\\\\"jumpUrl\\\\\\\":\\\\\\\"https:\\\\\\\\/\\\\\\\\/y.music.163.com\\\\\\\\/m\\\\\\\\/song\\\\\\\\/1421345210\\\\\\\\/?userid=1487080427\\\\\\\",\\\\\\\"musicUrl\\\\\\\":\\\\\\\"http:\\\\\\\\/\\\\\\\\/music.163.com\\\\\\\\/song\\\\\\\\/media\\\\\\\\/outer\\\\\\\\/url?id=1421345210\\\\u0026userid=1487080427\\\\\\\",\\\\\\\"preview\\\\\\\":\\\\\\\"http:\\\\\\\\/\\\\\\\\/p3.music.126.net\\\\\\\\/m5jfcQrNF3KIBUGS0z3Yag==\\\\\\\\/109951164682072553.jpg\\\\\\\",\\\\\\\"sourceMsgId\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"source_icon\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"source_url\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"tag\\\\\\\":\\\\\\\"网易云音乐\\\\\\\",\\\\\\\"title\\\\\\\":\\\\\\\"寄世界于东方~Otomad World\\\\\\\"}},\\\\\\\"config\\\\\\\":{\\\\\\\"autosize\\\\\\\":true,\\\\\\\"ctime\\\\\\\":1624234735,\\\\\\\"forward\\\\\\\":true,\\\\\\\"token\\\\\\\":\\\\\\\"67f82d769d8ffd790fe7378466fc3915\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"normal\\\\\\\"}}\\\"}\",\r\n      \"MsgType\": \"JsonMsg\",\r\n      \"MsgTime\": 1624235276,\r\n      \"MsgSeq\": 23533,\r\n      \"MsgRandom\": 1413885862,\r\n      \"RedBaginfo\": null\r\n    }\r\n  },\r\n  \"CurrentQQ\": 3020887057\r\n}";
            string xml    = "{\r\n  \"CurrentPacket\": {\r\n    \"WebConnId\": \"\",\r\n    \"Data\": {\r\n      \"FromGroupId\": 891787846,\r\n      \"FromGroupName\": \"水银控♂制台\",\r\n      \"FromUserId\": 863450594,\r\n      \"FromNickName\": \"(*´◐∀◐`*)智障\",\r\n      \"Content\": \"{\\\"Content\\\":\\\"\\\\u003c?xml version='1.0' encoding='UTF-8' standalone='yes' ?\\\\u003e\\\\u003cmsg serviceID=\\\\\\\"35\\\\\\\" templateID=\\\\\\\"1\\\\\\\" action=\\\\\\\"viewMultiMsg\\\\\\\" brief=\\\\\\\"[聊天记录]\\\\\\\" m_resid=\\\\\\\"u4+3DkbZM5n+XAwOUlDdiQI94jzboPgkAFp2CTFDr/VJDeCb4n9KwZRbof37CpvY\\\\\\\" m_fileName=\\\\\\\"6976041871604282006\\\\\\\" tSum=\\\\\\\"2\\\\\\\" sourceMsgId=\\\\\\\"0\\\\\\\" url=\\\\\\\"\\\\\\\" flag=\\\\\\\"3\\\\\\\" adverSign=\\\\\\\"0\\\\\\\" multiMsgFlag=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003citem layout=\\\\\\\"1\\\\\\\" advertiser_id=\\\\\\\"0\\\\\\\" aid=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003ctitle size=\\\\\\\"34\\\\\\\" maxLines=\\\\\\\"2\\\\\\\" lineSpace=\\\\\\\"12\\\\\\\"\\\\u003e群聊的聊天记录\\\\u003c/title\\\\u003e\\\\u003ctitle size=\\\\\\\"26\\\\\\\" color=\\\\\\\"#777777\\\\\\\" maxLines=\\\\\\\"4\\\\\\\" lineSpace=\\\\\\\"12\\\\\\\"\\\\u003epoweroff:  老民科了\\\\u003c/title\\\\u003e\\\\u003ctitle size=\\\\\\\"26\\\\\\\" color=\\\\\\\"#777777\\\\\\\" maxLines=\\\\\\\"4\\\\\\\" lineSpace=\\\\\\\"12\\\\\\\"\\\\u003e18车卓汤伟诚:  其实和我们不是同一个系的,是石油的,没什么了解🤔\\\\u003c/title\\\\u003e\\\\u003chr hidden=\\\\\\\"false\\\\\\\" style=\\\\\\\"0\\\\\\\" /\\\\u003e\\\\u003csummary size=\\\\\\\"26\\\\\\\" color=\\\\\\\"#777777\\\\\\\"\\\\u003e查看2条转发消息\\\\u003c/summary\\\\u003e\\\\u003c/item\\\\u003e\\\\u003csource name=\\\\\\\"聊天记录\\\\\\\" icon=\\\\\\\"\\\\\\\" action=\\\\\\\"\\\\\\\" appid=\\\\\\\"-1\\\\\\\" /\\\\u003e\\\\u003c/msg\\\\u003e\\\"}\",\r\n      \"MsgType\": \"XmlMsg\",\r\n      \"MsgTime\": 1624236319,\r\n      \"MsgSeq\": 23534,\r\n      \"MsgRandom\": 417139587,\r\n      \"RedBaginfo\": null\r\n    }\r\n  },\r\n  \"CurrentQQ\": 3020887057\r\n}";
            string qquser = "******"CurrentPacket\": {\r\n    \"WebConnId\": \"\",\r\n    \"Data\": {\r\n      \"FromGroupId\": 891787846,\r\n      \"FromGroupName\": \"水银控♂制台\",\r\n      \"FromUserId\": 863450594,\r\n      \"FromNickName\": \"(*´◐∀◐`*)智障\",\r\n      \"Content\": \"{\\\"Content\\\":\\\"\\\\u003c?xml version='1.0' encoding='UTF-8' standalone='yes' ?\\\\u003e\\\\u003cmsg serviceID=\\\\\\\"14\\\\\\\" templateID=\\\\\\\"1\\\\\\\" action=\\\\\\\"plugin\\\\\\\" actionData=\\\\\\\"AppCmd://OpenContactInfo/?uin=2185367837\\\\\\\" a_actionData=\\\\\\\"mqqapi://card/show_pslcard?src_type=internal\\\\u0026amp;source=sharecard\\\\u0026amp;version=1\\\\u0026amp;uin=2185367837\\\\\\\" i_actionData=\\\\\\\"mqqapi://card/show_pslcard?src_type=internal\\\\u0026amp;source=sharecard\\\\u0026amp;version=1\\\\u0026amp;uin=2185367837\\\\\\\" brief=\\\\\\\"推荐了水银之翼\\\\\\\" sourceMsgId=\\\\\\\"0\\\\\\\" url=\\\\\\\"\\\\\\\" flag=\\\\\\\"1\\\\\\\" adverSign=\\\\\\\"0\\\\\\\" multiMsgFlag=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003citem layout=\\\\\\\"0\\\\\\\" mode=\\\\\\\"1\\\\\\\" advertiser_id=\\\\\\\"0\\\\\\\" aid=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003csummary\\\\u003e推荐联系人\\\\u003c/summary\\\\u003e\\\\u003chr hidden=\\\\\\\"false\\\\\\\" style=\\\\\\\"0\\\\\\\" /\\\\u003e\\\\u003c/item\\\\u003e\\\\u003citem layout=\\\\\\\"2\\\\\\\" mode=\\\\\\\"1\\\\\\\" advertiser_id=\\\\\\\"0\\\\\\\" aid=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003cpicture cover=\\\\\\\"mqqapi://card/show_pslcard?src_type=internal\\\\u0026amp;source=sharecard\\\\u0026amp;version=1\\\\u0026amp;uin=2185367837\\\\\\\" w=\\\\\\\"0\\\\\\\" h=\\\\\\\"0\\\\\\\" /\\\\u003e\\\\u003ctitle\\\\u003e水银之翼\\\\u003c/title\\\\u003e\\\\u003csummary\\\\u003e帐号:2185367837\\\\u003c/summary\\\\u003e\\\\u003c/item\\\\u003e\\\\u003csource name=\\\\\\\"\\\\\\\" icon=\\\\\\\"\\\\\\\" action=\\\\\\\"\\\\\\\" appid=\\\\\\\"-1\\\\\\\" /\\\\u003e\\\\u003c/msg\\\\u003e你的QQ暂不支持查看推荐好友,请期待后续版本。\\\"}\",\r\n      \"MsgType\": \"XmlMsg\",\r\n      \"MsgTime\": 1624236319,\r\n      \"MsgSeq\": 23534,\r\n      \"MsgRandom\": 417139587,\r\n      \"RedBaginfo\": null\r\n    }\r\n  },\r\n  \"CurrentQQ\": 3020887057\r\n}";
            string group  = "{\r\n  \"CurrentPacket\": {\r\n    \"WebConnId\": \"\",\r\n    \"Data\": {\r\n      \"FromGroupId\": 891787846,\r\n      \"FromGroupName\": \"水银控♂制台\",\r\n      \"FromUserId\": 863450594,\r\n      \"FromNickName\": \"(*´◐∀◐`*)智障\",\r\n      \"Content\": \"{\\\"Content\\\":\\\"\\\\u003c?xml version='1.0' encoding='UTF-8' standalone='yes' ?\\\\u003e\\\\u003cmsg serviceID=\\\\\\\"15\\\\\\\" templateID=\\\\\\\"1\\\\\\\" action=\\\\\\\"web\\\\\\\" actionData=\\\\\\\"group:891787846\\\\\\\" a_actionData=\\\\\\\"group:891787846\\\\\\\" i_actionData=\\\\\\\"group:891787846\\\\\\\" brief=\\\\\\\"推荐群聊:水银控♂制台\\\\\\\" sourceMsgId=\\\\\\\"0\\\\\\\" url=\\\\\\\"https://jq.qq.com/?_wv=1027\\\\u0026amp;k=ivsIdSoV\\\\\\\" flag=\\\\\\\"0\\\\\\\" adverSign=\\\\\\\"0\\\\\\\" multiMsgFlag=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003citem layout=\\\\\\\"0\\\\\\\" mode=\\\\\\\"1\\\\\\\" advertiser_id=\\\\\\\"0\\\\\\\" aid=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003csummary\\\\u003e推荐群聊\\\\u003c/summary\\\\u003e\\\\u003chr hidden=\\\\\\\"false\\\\\\\" style=\\\\\\\"0\\\\\\\" /\\\\u003e\\\\u003c/item\\\\u003e\\\\u003citem layout=\\\\\\\"2\\\\\\\" mode=\\\\\\\"1\\\\\\\" advertiser_id=\\\\\\\"0\\\\\\\" aid=\\\\\\\"0\\\\\\\"\\\\u003e\\\\u003cpicture cover=\\\\\\\"http://p.qlogo.cn/gh/891787846/891787846/100\\\\\\\" w=\\\\\\\"0\\\\\\\" h=\\\\\\\"0\\\\\\\" needRoundView=\\\\\\\"0\\\\\\\" /\\\\u003e\\\\u003ctitle\\\\u003e水银控♂制台\\\\u003c/title\\\\u003e\\\\u003csummary\\\\u003e水银之翼天下第 一!\\\\u003c/summary\\\\u003e\\\\u003c/item\\\\u003e\\\\u003csource name=\\\\\\\"\\\\\\\" icon=\\\\\\\"\\\\\\\" action=\\\\\\\"\\\\\\\" appid=\\\\\\\"-1\\\\\\\" /\\\\u003e\\\\u003c/msg\\\\u003ehttps://jq.qq.com/?_wv=1027\\\\u0026k=ivsIdSoV\\\"}\",\r\n      \"MsgType\": \"XmlMsg\",\r\n      \"MsgTime\": 1624236319,\r\n      \"MsgSeq\": 23534,\r\n      \"MsgRandom\": 417139587,\r\n      \"RedBaginfo\": null\r\n    }\r\n  },\r\n  \"CurrentQQ\": 3020887057\r\n}";
            var    b      = ProgressMessage.Start(JsonConvert.DeserializeObject <ReceiveMessage>(json));

            Debug.WriteLine(b);
        }
Exemplo n.º 25
0
        private void UpdateProgressMessage()
        {
            // Calculate base progress based on state
            float       baseProgress  = 0;
            float       stateProgress = 0;
            string      message       = "Serializing translations...";
            ImportState state         = currentStatus.Value;

            if (state == ImportState.ReadFile)
            {
                // Get the CSV status
                CsvReader.ReadStatus.State csvState = csvReadStatus.CurrentState;
                if (csvState == CsvReader.ReadStatus.State.ReadingFileIntoRows)
                {
                    // Report that we're reading the file.
                    // Progress is not calculated here because we do not
                    // check how long the CSV file is.
                    message = "Parsing CSV file into text...";
                }
                else
                {
                    // Report the text is being split into cells
                    message = "Splitting text into cells...";

                    // Calculate the progress
                    baseProgress  = (int)csvState;
                    stateProgress = csvReadStatus.ProgressPercent;
                }
            }
            else
            {
                // Check the state
                if (state == ImportState.ConvertToTranslations)
                {
                    // Report cells are being converted
                    message = "Converting cells into translations...";
                }

                // Calculate the progress
                baseProgress  = ((int)state) + 1;
                stateProgress = progressReport.ProgressPercent;
            }

            // Calculate progress
            baseProgress  /= TotalStates;
            stateProgress /= TotalStates;
            baseProgress  += stateProgress;
            Progress       = baseProgress;

            // Update message
            ProgressMessage.Clear();
            ProgressMessage.Append(baseProgress.ToString("00%"));
            ProgressMessage.Append(": ");
            ProgressMessage.Append(message);
        }
 protected void ShowMessage(ProgressMessage Msg)
 {
     //--- Update the message controls
     try
     { UpdateMessageControls(Msg); }
     catch (Exception Exc)
     {
         ShowException(Exc);
         return;
     }
 }
Exemplo n.º 27
0
        public ActionResult CancelImport()
        {
            ProgressMessage pm = db.ProgressMessages.Find(MessageArea);

            if (pm != null && !pm.IsComplete)
            {
                AddOrReplaceProgressMessage(cancelImportMessage);
            }

            return(RedirectToAction("Index"));
        }
        public async Task MonitorEventsAsync_Succeeds()
        {
            const string repository = "hello-world";
            var          newTag     = $"MonitorTests-{Guid.NewGuid().ToString().Substring(1, 10)}";

            var progressJSONMessage = new ProgressJSONMessage
            {
                _onJSONMessageCalled = (m) =>
                {
                    // Status could be 'Pulling from...'
                    Console.WriteLine($"{System.Reflection.MethodInfo.GetCurrentMethod().Module}->{System.Reflection.MethodInfo.GetCurrentMethod().Name}: _onJSONMessageCalled - {m.ID} - {m.Status} {m.From} - {m.Stream}");
                    Assert.NotNull(m);
                }
            };

            var wasProgressCalled = false;
            var progressMessage   = new ProgressMessage
            {
                _onMessageCalled = (m) =>
                {
                    Console.WriteLine($"{System.Reflection.MethodInfo.GetCurrentMethod().Module}->{System.Reflection.MethodInfo.GetCurrentMethod().Name}: _onMessageCalled - {m.Action} - {m.Status} {m.From} - {m.Type}");
                    wasProgressCalled = true;
                    Assert.NotNull(m);
                }
            };

            using var cts = new CancellationTokenSource();

            await _client.Images.CreateImageAsync(new ImagesCreateParameters { FromImage = "hello-world" }, null, progressJSONMessage);

            var task = Task.Run(() => _client.System.MonitorEventsAsync(new ContainerEventsParameters(), progressMessage, cts.Token));

            await _client.Images.TagImageAsync(repository, new ImageTagParameters { RepositoryName = repository, Tag = newTag });

            cts.Cancel();

            bool taskIsCancelled = false;

            try
            {
                await task;
            }
            catch (OperationCanceledException)
            {
                taskIsCancelled = true;
            }

            // On local develop machine task is completed.
            // On CI/CD Pipeline exception is thrown, not always
            Assert.True(task.IsCompleted || taskIsCancelled);
            Assert.True(wasProgressCalled);

            await _client.Images.DeleteImageAsync($"{repository}:{newTag}", new ImageDeleteParameters());
        }
Exemplo n.º 29
0
        private void JSInterface_Progress(object sender, ProgressMessage e)
        {
            TotalSteps  = e.Total;
            CurrentStep = e.Step;
            LastMessage = e.Message;

            if (!e.Message.StartsWith("~"))
            {
                Messages.Add(e.Message);
            }
        }
Exemplo n.º 30
0
        //--------------------------------------------------------------------------------------------------

        public void OnProcessingStopped()
        {
            if (_ProcessingEntitiesStack.Count > 0)
            {
                _ProcessingEntitiesStack.Pop();
            }

            if (_ProcessingEntitiesStack.Count == 0)
            {
                ProgressMessage?.Invoke(this, new ProgressMessageEventArgs(ProgressMessageEventReason.ProcessingStopped, null));
            }
        }
Exemplo n.º 31
0
        private void SetProgressbarContent(ProgressMessage message)
        {
            switch (message)
            {
                case ProgressMessage.AddingWidgets:
                    _progressBarWindow.Description.Content = "Finding more widgets ...";
                    break;

                case ProgressMessage.RemovingWidgets:
                    _progressBarWindow.Description.Content = "Removing widgets ...";
                    break;

                case ProgressMessage.UpdatingLayers:
                    _progressBarWindow.Description.Content = "Configuring Layers ...";
                    break;

                case ProgressMessage.UpdatingDepCode:
                    _progressBarWindow.Description.Content = "Configuring Interpretation Code";
                    break;
            }

        }
Exemplo n.º 32
0
      void SetProgress(ProgressMessage message)
      {
        if (message.Token.IsCancellationRequested)
        {
          _label.Text = "処理はキャンセルされました。";
          return;
        }

        _label.Text = message.Message;
        if (message is AfterMessage)
        {
          _bar.PerformStep();
        }
      }