Exemplo n.º 1
0
        /// <summary>
        /// 处理微信消息推送
        /// <para>Service URL:
        /// <a href="http://btp.iuoooo.com/Jinher.AMP.BTP.SV.WxMessageSV.svc/DealMessage">
        /// http://btp.iuoooo.com/Jinher.AMP.BTP.SV.WxMessageSV.svc/DealMessage
        /// </a></para>
        /// </summary>
        /// <param name="message">微信消息</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.WcpBusiRetDto DealMessageExt(Jinher.AMP.BTP.Deploy.CustomDTO.WcpBusiDto message)
        {
            Jinher.AMP.BTP.Deploy.CustomDTO.WcpBusiRetDto result = new WcpBusiRetDto();
            if (message == null || string.IsNullOrEmpty(message.WXContent))
            {
                return(result);
            }
            var messageDto = XmlUtil.Deserialize <WebChatMessageDTO>(message.WXContent);

            if (messageDto == null)
            {
                return(result);
            }
            WxMessageWorkerBase worker;

            switch (messageDto.Event)
            {
            //关注公众号
            case "subscribe":
                worker = new ScanSubscribeWorker(messageDto);
                break;

            //进入公众号事件推送
            case "SCAN":
                worker = new ScanWorker(messageDto);
                break;

            default:
                return(result);
            }
            worker.Do();
            return(result);
        }
 private void metroButton6_Click(object sender, EventArgs e)
 {
     try
     {
         Status.Text = "Cancelando...";
         ScanWorker.CancelAsync();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
 private void metroButton2_Click(object sender, EventArgs e)
 {
     this.ScanWorker.DoWork += (senderr, eer) => { searchingips(); };
     ScanWorker.RunWorkerAsync();
 }
        private void DoScan()
        {
            // Validation
            if (_defFiles.Count == 0)
            {
                MessageBox.Show("No def files to read", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            RouteScannerOptions scannerOptions;

            try
            {
                scannerOptions = ExportRouteScannerOptions();
            }
            catch (Exception ex)
            {
                GenericErrorAlert($"Error reading options: {ex.GetType().Name}\n{ex.Message}", "Error reading options");
                return;
            }

            if (scannerOptions.StartSystems.Count == 0 && scannerOptions.MapBounds.Count == 0 && MessageBox.Show(
                    "Specifying no route start systems and no map bounds will scan for routes across the entire map, and will take quite some time. Are you sure you want to do this?",
                    "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
            {
                return;
            }

            var progForm = new ProgressForm();

            progForm.Text = "Scanning for routes";
            progForm.Show(this);

            //var scannerOptions = new RouteScannerOptions();
            //scannerOptions.StartSystems.Add("Algorel");

            var scanner = new ScanWorker(_defFiles, scannerOptions);

            scanner.ProgressEvent += new EventHandler <ProgressEventArgs>((sender, args) =>
            {
                if (args.StatusUpdate && args.Status == ProgressEventStatus.Error)
                {
                    // Something went wrong, show an error message & close the progress form
                    progForm.CloseSafe();
                    MessageBox.Show(args.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (args.StatusUpdate && args.Status == ProgressEventStatus.Complete)
                {
                    // Done here, just close the status
                    progForm.CloseSafe();
                }
                else
                {
                    if (args.ValueUpdate)
                    {
                        progForm.SetProgress(args.Value, args.MaxValue);
                    }
                    progForm.SetMessage(args.Message);
                }
            });

            //bgWorkerScanner.RunWorkerAsync(scanner);
            //var results = scanner.Scan(_defFiles, new RouteScannerOptions()).ContinueWith((taskResult) => HandleScanResults(taskResult)); // TODO generate options

            _operationCtSource = new CancellationTokenSource();
            progForm.OnCancel += new EventHandler <EventArgs>((sender, args) => _operationCtSource?.Cancel());
            _routeScannerTask  = new Task(() =>
            {
                var result = scanner.Scan(_operationCtSource.Token);
                HandleScanResults(result);
            }, _operationCtSource.Token);
            _routeScannerTask.Start();
        }
Exemplo n.º 5
0
        public void FindVideoChunksTest()
        {
            const string filePath = @"D:\Projects\Odessa\OdessaCheckout\OdessaProductionSolution\TestProject\Test Videos\Contour_snow_speed.MOV";

            var sw = new ScanWorker
                         {InputFile = new FileInfo(filePath), FramesPerSecond = 59.94f, VideoDurationInSeconds = 200};

            var darkFrameNumbers = new List<long>
                                       {
                                           1040,
                                           1041,
                                           1042,
                                           1043,
                                           1044,
                                           1045,
                                           1046,
                                           1047,
                                           1048,
                                           1049,
                                           1050,
                                           1051,
                                           1052,
                                           1053,
                                           7778,
                                           7779,
                                           7780,
                                           7781,
                                           7782,
                                           7783,
                                           7784,
                                           7785,
                                           7786,
                                           7787
                                       };

            const int captureDurationInSeconds = 30;
            const bool ignoreEarlyHighlights = false;
            const bool useCaptureOffset = true;

            var expected = new List<VideoChunk>
                               {new VideoChunk(0, 1172, filePath), new VideoChunk(5989, 7906, filePath)};

            List<VideoChunk> actual =
                Engine_Accessor.FindVideoChunks(sw, darkFrameNumbers, captureDurationInSeconds, ignoreEarlyHighlights, useCaptureOffset);

            if (actual.Count != expected.Count)
            {
                Assert.Fail("actual.Count != expected.Count");
            }

            for (int i = 0; i < expected.Count; i++)
            {
                if (expected[i].StartFrame != actual[i].StartFrame)
                {
                    Assert.Fail("expected[" + i + "].StartFrame = " + expected[i].StartFrame + " but actual[" + i + "].StartFrame = " + actual[i].StartFrame);
                }
                if (expected[i].EndFrame != actual[i].EndFrame)
                {
                    Assert.Fail("expected[" + i + "].EndFrame = " + expected[i].EndFrame + " but actual[" + i + "].EndFrame = " + actual[i].EndFrame);
                }
            }
        }