private void featureType_ProcessCompleted(object sender, ResultEventArgs<Dictionary<string, List<WFSFeatureDescription>>> e)
 {
     foreach (var item in e.Result)
     {
         if (item.Key == "http://www.supermap.com/World")
         {
             GetWFSFeature getWFSFeature = new GetWFSFeature(url)
             {
                 MaxFeatures = 5,
                 FeatureNS = item.Key
             };
             WFSFeatureDescription typeCountries = new WFSFeatureDescription
             {
                 TypeName = item.Value[0].TypeName,
                 SpatialProperty = item.Value[0].SpatialProperty,
             };
             typeCountries.Properties.Add("COUNTRY");
             typeCountries.Properties.Add("CAPITAL");
             getWFSFeature.FeatureDescriptions.Add(typeCountries);
             getWFSFeature.ProcessAsync();
             getWFSFeature.ProcessCompleted += new EventHandler<ResultEventArgs<GetWFSFeatureResult>>(getWFSFeature_ProcessCompleted);
             getWFSFeature.Failed += new EventHandler<FailedEventArgs>(ServiceError_Failed);
         }
     }
 }
예제 #2
0
 protected virtual void OnResults(ResultEventArgs e1)
 {
     EventHandler<ResultEventArgs> handler = Results;
     if (handler != null)
     {
         handler(this, e1);
     }
 }
예제 #3
0
 void rt_FindMoviesCompleted(object sender, ResultEventArgs<MovieSearchResult> e) {
     if (e.Result.Total != 0)
         loadingText = WAITING;
     else
         loadingText = NORESULTS;
     resultListBox.ItemsSource = e.Result;
     resultListBox.SelectionChanged += resultListBox_SelectionChanged;
 }
 void rt_FindMoviesCompleted(object sender, ResultEventArgs<MovieSearchResult> e) {
     var m = e.Result.First();
     m.LoadFullCastCompleted += new EventHandler<EventArgs>(m_LoadFullCastCompleted);
     m.LoadReviewsCompleted += new EventHandler<EventArgs>(m_LoadReviewsCompleted);
     m.LoadUnabridgedCompleted += new EventHandler<EventArgs>(m_LoadUnabridgedCompleted);
     m.LoadUnabridgedAsync(); 
     m.LoadFullCastAsync();
     m.LoadTopCriticReviewsAsync();
     m.LoadDvdReviewsAsync();
 }
 private void getWFSFeature_ProcessCompleted(object sender, ResultEventArgs<GetWFSFeatureResult> e)
 {
     foreach (var key in e.Result.FeaturePair)
     {
         featuresLayer.AddFeatureSet(key.Value);
         foreach (Feature feature in key.Value)
         {
             feature.ToolTip = new TextBlock { Text = "Country: " + feature.Attributes["COUNTRY"] + "\n" + "Capital: " + feature.Attributes["CAPITAL"] };
         }
     }
 }
 private void getCapabilities_ProcessCompleted(object sender, ResultEventArgs<List<WFSFeatureType>> e)
 {
     if (e.Result != null && e.Result.Count > 9)
     {
         GetWFSDescribeFeatureType featureType = new GetWFSDescribeFeatureType(url);
         featureType.TypeNames.Add("World:Countries");
         featureType.ProcessAsync();
         featureType.ProcessCompleted += new EventHandler<ResultEventArgs<Dictionary<string, List<WFSFeatureDescription>>>>(featureType_ProcessCompleted);
         featureType.Failed += new EventHandler<FailedEventArgs>(ServiceError_Failed);
     }
 }
예제 #7
0
 /// <summary>
 /// Event fired when the user details have arrived
 /// </summary>
 /// <param name="sender">the event sender</param>
 /// <param name="e">the event params</param>
 private void GetUserDetailsCompletedOnThread(object sender, ResultEventArgs<Users> e)
 {
     if (e.ResultStatus.Success)
     {
         User user = e.ResultValue.Results[0];
         outputTextBlock.Text = string.Format("User {0} is {1}", user.UserId, user.UserName);
     }
     else
     {
         outputTextBlock.Text = string.Format("Error {0}: {1}", e.ResultStatus.ErrorMessage, e.ResultStatus.Exception);
     }
 }
예제 #8
0
 private void OnDialogResult(object sender, ResultEventArgs e)
 {
     if (e.DialogResult == DialogResultType.OK)
     {
         var selectedCustomer = e.Data as CustomerVM;
         if (selectedCustomer != null)
         {
             this.txtCustomerID.Text    = selectedCustomer.CustomerID;
             this.txtCustomerSysNo.Text = selectedCustomer.SysNo.ToString();
             OnCustomerSelected(selectedCustomer);
             this.txtCustomerID.Focus();
         }
     }
     else if (e.DialogResult == DialogResultType.Cancel)
     {
         this.txtCustomerID.Text = string.Empty;
     }
 }
        //public void LoadPreset(string controllerName)
        //{
        //	string name = controllerName.Replace(" ", "_");
        //	mainForm.LoadPreset(name, ControllerComboBox.SelectedIndex);
        //}

        //public void LoadSetting(Guid padSettingChecksum)
        //{
        //	var ws = new WebServiceClient();
        //	ws.Url = MainForm.Current.OptionsPanel.InternetDatabaseUrlComboBox.Text;
        //	ws.LoadSettingCompleted += ws_LoadSettingCompleted;
        //	ws.LoadSettingAsync(new Guid[] { padSettingChecksum });
        //}

        //void ws_LoadSettingCompleted(object sender, ResultEventArgs e)
        //{
        //	var result = (SearchResult)e.Result;
        //	if (result.PadSettings.Length == 0)
        //	{
        //		mainForm.UpdateHelpHeader(string.Format("{0: yyyy-MM-dd HH:mm:ss}: Setting was not found.", DateTime.Now), MessageBoxIcon.Information);
        //	}
        //	else
        //	{
        //		var di = _devices[ControllerComboBox.SelectedIndex];
        //		var padSectionName = SettingManager.Current.GetInstanceSection(di.InstanceGuid);
        //		SettingManager.Current.SetPadSetting(padSectionName, di);
        //		SettingManager.Current.SetPadSetting(padSectionName, result.PadSettings[0]);
        //		MainForm.Current.SuspendEvents();
        //		SettingManager.Current.ReadPadSettings(SettingManager.IniFileName, padSectionName, ControllerComboBox.SelectedIndex);
        //		MainForm.Current.ResumeEvents();
        //		var name = ((KeyValuePair)ControllerComboBox.SelectedItem).Key;
        //		mainForm.UpdateHelpHeader(string.Format("{0: yyyy-MM-dd HH:mm:ss}: Settings loaded into '{1}' successfully.", DateTime.Now, name), MessageBoxIcon.Information);
        //		// Save setting and notify if value changed.
        //		SettingManager.Current.SaveSettings();
        //		MainForm.Current.NotifySettingsChange();
        //		mainForm.UpdateTimer.Start();
        //	}
        //}

        void ws_SearchSettingsCompleted(object sender, ResultEventArgs e)
        {
            var ws = (WebServiceClient)sender;

            ws.SearchSettingsCompleted -= ws_SearchSettingsCompleted;
            // Make sure method is executed on the same thread as this control.
            BeginInvoke((MethodInvoker) delegate()
            {
                MainForm.Current.AddTask(TaskName.SearchSettings);
                //refreshed = true;
                if (e.Error != null || e.Result == null)
                {
                    AppHelper.UpdateList(new List <Setting>(), SettingsManager.Settings.Items);
                    AppHelper.UpdateList(new List <Summary>(), SettingsManager.Summaries.Items);
                    //UpdateActionButtons();
                    if ((bool)e.UserState)
                    {
                        MainForm.Current.SetHeaderBody(
                            MessageBoxIcon.Information,
                            "{0: yyyy-MM-dd HH:mm:ss}: No data received.",
                            DateTime.Now
                            );
                    }
                }
                else
                {
                    var result = (SearchResult)e.Result;
                    // Reorder summaries.
                    result.Summaries = result.Summaries.OrderBy(x => x.ProductName).ThenBy(x => x.FileName).ThenBy(x => x.FileProductName).ThenByDescending(x => x.Users).ToArray();
                    AppHelper.UpdateList(result.Settings, SettingsManager.Settings.Items);
                    AppHelper.UpdateList(result.Summaries, SettingsManager.Summaries.Items);
                    //	UpdateActionButtons();
                    if ((bool)e.UserState)
                    {
                        MainForm.Current.SetHeaderBody(
                            MessageBoxIcon.Information,
                            "{0: yyyy-MM-dd HH:mm:ss}: {1} Your Settings and {2} General Settings received.",
                            DateTime.Now, result.Settings.Length, result.Summaries.Length
                            );
                    }
                }
                MainForm.Current.RemoveTask(TaskName.SearchSettings);
            });
        }
예제 #10
0
        void ws_SearchSettingsCompleted(object sender, ResultEventArgs e)
        {
            // Make sure method is executed on the same thread as this control.
            if (InvokeRequired)
            {
                var method = new EventHandler <ResultEventArgs>(ws_SearchSettingsCompleted);
                BeginInvoke(method, new object[] { sender, e });
                return;
            }
            // Detach event handler so resource could be released.
            var ws = (WebServiceClient)sender;

            ws.SearchSettingsCompleted -= ws_SearchSettingsCompleted;
            if (e.Error != null)
            {
                var error = e.Error.Message;
                if (e.Error.InnerException != null)
                {
                    error += "\r\n" + e.Error.InnerException.Message;
                }
                _ParentForm.SetHeaderError(error);
            }
            else if (e.Result == null)
            {
                _ParentForm.SetHeaderInfo("No user settings received.");
            }
            else
            {
                var result = (SearchResult)e.Result;
                // Reorder Settings.
                result.Settings = result.Settings.OrderBy(x => x.ProductName).ThenBy(x => x.FileName).ThenBy(x => x.FileProductName).ToArray();
                SettingsManager.Current.UpsertSettings(result.Settings);
                // Insert pad settings which are used by settings.
                SettingsManager.Current.UpsertPadSettings(result.PadSettings);
                // Remove unused pad settings.
                SettingsManager.Current.CleanupPadSettings();
                // Display results about operation.
                var settingsCount    = (result.Settings == null) ? 0 : result.Settings.Length;
                var padSettingsCount = (result.PadSettings == null) ? 0 : result.PadSettings.Length;
                _ParentForm.SetHeaderInfo("{0} user settings and {1} PAD settings received.", settingsCount, padSettingsCount);
            }
            _ParentForm.RemoveTask(TaskName.SearchSettings);
            SettingsRefreshButton.Enabled = true;
        }
예제 #11
0
 private void OnDeleteExportJobCompleted(object sender, ResultEventArgs <IExportJob> e)
 {
     RefreshExportJobs();
     if (e.HasError)
     {
         DebugLogger.Instance.LogMsg("An error occurred when deleting the export job: {0}", e.ErrorMessage);
     }
     else
     {
         if (e.Result != null)
         {
             DebugLogger.Instance.LogMsg("The export job with the ID {0} was deleted.", e.Result.Id);
         }
         else
         {
             DebugLogger.Instance.LogMsg("The export job deleted and didn't report an error but the details of the deleted job were null.", e.Result.Id);
         }
     }
 }
예제 #12
0
 private void OnCreateExportJobCompleted(object sender, ResultEventArgs <IExportJob> e)
 {
     RefreshExportJobs();
     if (e.HasError)
     {
         DebugLogger.Instance.LogMsg("There was an error creating the export job: {0}", e.ErrorMessage);
     }
     else
     {
         if (e.Result != null && e.Result.CreatedBy != null && !string.IsNullOrEmpty(e.Result.CreatedBy.DisplayName))
         {
             DebugLogger.Instance.LogMsg("Export job was successfully created by {0} with the details, Job ID: {1}, MapType: {2}, ExportType: {3}", e.Result.CreatedBy.DisplayName, e.Result.Id, e.Result.MapType, e.Result.Type);
         }
         else
         {
             DebugLogger.Instance.LogMsg("No error was reported when creating the export job but the returned details of the created were invalid.");
         }
     }
 }
예제 #13
0
        void ResultEventHandler(object sender, ResultEventArgs args)
        {
            var result = args.Result;
            int index  = 0;

            lock (ImageResults) {
                foreach (var image in ImageResults)
                {
                    if (image.Path == result.Path)
                    {
                        index = ImageResults.IndexOf(image);
                        break;
                    }
                }
                Dispatcher.UIThread.InvokeAsync(() => {
                    lock (ImageResults) {
                        ImageResults[index] = new MNISTModelResultDb(result);
                        ImageClasses[result.Class].Add(new MNISTModelResultDb(result));
                        ClassesInfo[result.Class] = ClassInfoProcess(result.Class,
                                                                     ImageClasses[result.Class].Count);
                        processed++;
                        ProdProgressInfo();
                    }
                });
                Task.Run(() =>
                {
                    lock (dbContext)
                    {
                        Bitmap resImage = new Bitmap(result.Path);
                        Blob resBlob    = new Blob {
                            Bytes = ImageToByteArray(resImage)
                        };
                        dbContext.ClassifiedImages.Add(new ClassifiedImage {
                            Path          = result.Path,
                            Class         = result.Class, Confidence = result.Confidence,
                            RetrieveCount = 0, Image = resBlob
                        });
                        dbContext.Blobs.Add(resBlob);
                        dbContext.SaveChanges();
                    }
                });
            }
        }
예제 #14
0
        void ws_SearchSummariesCompleted(object sender, ResultEventArgs e)
        {
            // Make sure method is executed on the same thread as this control.
            if (InvokeRequired)
            {
                var method = new EventHandler <ResultEventArgs>(ws_SearchSummariesCompleted);
                BeginInvoke(method, new object[] { sender, e });
                return;
            }
            // Detach event handler so resource could be released.
            var ws = (WebServiceClient)sender;

            ws.SearchSettingsCompleted -= ws_SearchSummariesCompleted;
            if (e.Error != null)
            {
                var error = e.Error.Message;
                if (e.Error.InnerException != null)
                {
                    error += "\r\n" + e.Error.InnerException.Message;
                }
                _ParentForm.SetHeaderError(error);
            }
            else if (e.Result == null)
            {
                _ParentForm.SetHeaderInfo("No default settings received.");
            }
            else
            {
                var result = (SearchResult)e.Result;
                // Reorder summaries.
                result.Summaries = result.Summaries.OrderBy(x => x.ProductName).ThenBy(x => x.FileName).ThenBy(x => x.FileProductName).ThenByDescending(x => x.Users).ToArray();
                AppHelper.UpdateList(result.Summaries, SettingsManager.Summaries.Items);
                // PadSettings can't be null if summaries supplied.
                SettingsManager.Current.UpsertPadSettings(result.PadSettings);
                SettingsManager.Current.CleanupPadSettings();
                var summariesCount   = (result.Summaries == null) ? 0 : result.Summaries.Length;
                var padSettingsCount = (result.PadSettings == null) ? 0 : result.PadSettings.Length;
                _ParentForm.SetHeaderInfo("{0} default settings and {0} PAD settings received.", summariesCount, padSettingsCount);
            }
            _ParentForm.RemoveTask(TaskName.SearchSummaries);
            SummariesRefreshButton.Enabled = true;
        }
예제 #15
0
 private void OnProductSelected(object sender, ResultEventArgs e)
 {
     if (e.DialogResult == DialogResultType.OK)
     {
         var selectedProductList = (List <ProductVM>)e.Data;
         foreach (var productItem in selectedProductList)
         {
             if (!_model.ProductSettingValue.Any(x => x.SysNo == productItem.SysNo))
             {
                 SimpleObject productObject = new SimpleObject()
                 {
                     SysNo = productItem.SysNo,
                     ID    = productItem.ProductID,
                     Name  = productItem.ProductName
                 };
                 _model.ProductSettingValue.Add(productObject);
             }
         }
     }
 }
예제 #16
0
        void ws_DeleteSettingCompleted(object sender, ResultEventArgs e)
        {
            if (e.Error != null)
            {
                mainForm.UpdateHelpHeader(e.Error.Message, MessageBoxIcon.Error);
                throw e.Error;
            }
            var result = (string)e.Result;

            if (!string.IsNullOrEmpty(result))
            {
                mainForm.UpdateHelpHeader(result, MessageBoxIcon.Error);
            }
            else
            {
                var name = ((KeyValuePair)ControllerComboBox.SelectedItem).Key;
                mainForm.UpdateHelpHeader(string.Format("{0: yyyy-MM-dd HH:mm:ss}: '{1}' setting deleted successfully.", DateTime.Now, name), MessageBoxIcon.Information);
            }
            RefreshGrid(false);
        }
예제 #17
0
        void ws_LoadSettingCompleted(object sender, ResultEventArgs e)
        {
            var result = (SearchResult)e.Result;

            if (result.PadSettings.Length == 0)
            {
                MainForm.Current.UpdateHelpHeader(string.Format("{0: yyyy-MM-dd HH:mm:ss}: Setting was not found.", DateTime.Now), MessageBoxIcon.Information);
            }
            else
            {
                var padSectionName = SettingManager.Current.GetInstanceSection(_di.InstanceGuid);
                SettingManager.Current.SetPadSetting(padSectionName, _di);
                SettingManager.Current.SetPadSetting(padSectionName, result.PadSettings[0]);
                MainForm.Current.SuspendEvents();
                SettingManager.Current.ReadPadSettings(SettingManager.IniFileName, padSectionName, _padIndex);
                MainForm.Current.ResumeEvents();
                MainForm.Current.UpdateHelpHeader(string.Format("{0: yyyy-MM-dd HH:mm:ss}: Settings loaded into '{1}' successfully.", DateTime.Now, (_padIndex + 1) + "." + _di.ProductName), MessageBoxIcon.Information);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
예제 #18
0
        void ws_LoadSettingCompleted(object sender, ResultEventArgs e)
        {
            var result = (SearchResult)e.Result;

            if (result.PadSettings.Length == 0)
            {
                MainForm.Current.SetHeaderBody("Setting was not found.");
            }
            else
            {
                var padSectionName = SettingsManager.Current.GetInstanceSection(_di.InstanceGuid);
                SettingsManager.Current.SetPadSetting(padSectionName, _di);
                //SettingManager.Current.SetPadSetting(padSectionName, result.PadSettings[0]);
                SettingsManager.Current.SuspendEvents();
                //SettingManager.Current.LoadPadSettings(SettingManager.IniFileName, padSectionName, _padIndex);
                SettingsManager.Current.ResumeEvents();
                MainForm.Current.SetHeaderBody("Settings loaded into '{0}.{1}' successfully.", _padIndex + 1, _di.ProductName);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
예제 #19
0
        private void OnResultUpdated(object sender, ResultEventArgs args)
        {
            if (MainController.View.Handler.InvokeRequired)
            {
                MainController.View.Handler.BeginInvoke(
                    new EventHandler <ResultEventArgs>(OnResultUpdated),
                    sender, args);
            }
            else
            {
                _view.StartTime          = args.Result.StartTime.ToLongTimeString();
                _view.ElapsedTime        = args.Result.ElapsedTime.ToString();
                _view.EndTime            = args.Result.StartTime.Add(args.Result.ElapsedTime).ToLongTimeString();
                _view.MinPerformance     = args.Result.PerformanceMeasurement.MinValue.ToString("0.##");
                _view.AveragePerformance = args.Result.PerformanceMeasurement.AverageValue.ToString("0.##");
                _view.MaxPerformance     = args.Result.PerformanceMeasurement.MaxValue.ToString("0.##");
                _view.MinCpuLoad         = args.Result.CpuLoadMeasurement.MinValue.ToString("0.##");
                _view.AverageCpuLoad     = args.Result.CpuLoadMeasurement.AverageValue.ToString("0.##");
                _view.MaxCpuLoad         = args.Result.CpuLoadMeasurement.MaxValue.ToString("0.##");
                _view.MinMemoryUsage     = args.Result.MemoryUsageMeasurement.MinValue.ToString("0.##");
                _view.AverageMemoryUsage = args.Result.MemoryUsageMeasurement.AverageValue.ToString("0.##");
                _view.MaxMemoryUsage     = args.Result.MemoryUsageMeasurement.MaxValue.ToString("0.##");

                string          resultName = args.Result.Benchmarks.Count != 1 ? "All" : args.Result.Benchmarks[0].FullName;
                ExecutionResult result;
                if (_results.TryGetValue(resultName, out result))
                {
                    result.Update(args.Result);
                }
                else
                {
                    result = new ExecutionResult(args.Result);
                    _results.Add(resultName, result);
                }
                _view.ExecutionResults = new List <ExecutionResult>(_results.Values);

                _view.AddCurrentPerformancePoint(_model.Configuration.MeasurementType == MeasurementType.Peak
                    ? args.Result.PerformanceMeasurement.CurrentValue
                    : args.Result.CpuLoadMeasurement.CurrentValue);
            }
        }
예제 #20
0
        //------------------------------------------------------------------------------------------------------------------
        //  名称:检测方法四
        //  功能:跳线检测
        //
        //------------------------------------------------------------------------------------------------------------------



        /// <summary>
        ///  名称:检测方法四
        ///  功能:跳线检测
        /// </summary>
        /// <param name="e"></param>
        private void InspectMethod_TwoSnTwoLab(InspectEventArgs e)
        {
            try
            {
                Get_SN_List(e);

                ResultEventArgs _Result = new ResultEventArgs();                                                                                                                           //定义结果返回类
                _Result.ErrorList = "";                                                                                                                                                    //异常列表 归零
                _GLL_SerialNumber = _M_SerialNumber.GetModel(e.SN);                                                                                                                        //获取条码 实体

                if (_GLL_SerialNumber == null || _GLL_SerialNumber.OrderID != _GLL_WorkOrder.OrderID || _GLL_SerialNumber.Type != Maticsoft.Model.E_SerialNumber_Type.ClientSN.ToString()) //判断是否属于此工单
                {
                    _Result.ErrorList += "此条码:" + e.SN + "  不属于此工单:" + _GLL_WorkOrder.OrderID + "";
                }
                else if (_GLL_SerialNumber.State != Maticsoft.Model.E_Barcode_State.Not_Pack.ToString()) //判断是否已经包装
                {
                    _Result.ErrorList += "此条码:" + _GLL_SerialNumber.SN + "  已包装或已打印!包装批号:" + _GLL_SerialNumber.BatchNO + "";
                }
                else
                {
                    if (_GLL_WorkOrder.InspectType == Maticsoft.Model.E_InspectType.检测3D与Exfo)
                    {
                        Inspect_TwoSnToLab_Inspect_3D(e, _Result); Inspect_TwoSnToLab_Inspect_Exfo(e, _Result);
                    }
                    else if (_GLL_WorkOrder.InspectType == Maticsoft.Model.E_InspectType.检测Exfo)
                    {
                        _Result.Result_3D = true; Inspect_TwoSnToLab_Inspect_Exfo(e, _Result);
                    }
                    else if (_GLL_WorkOrder.InspectType == Maticsoft.Model.E_InspectType.检测3D)
                    {
                        _Result.Result_Exfo = true; Inspect_TwoSnToLab_Inspect_3D(e, _Result);
                    }
                }
                e.InspectResult = _Result;
                if (IsUpdate)  //检测是否启用更新
                {
                    Up_SerialNumber(e);
                }
            }
            catch (Exception ex) { My_MessageBox.My_MessageBox_Message(ex.Message); }
        }
예제 #21
0
        /// <summary>
        /// 两码两签 检测Exfo
        /// </summary>
        private void Inspect_TwoSnToLab_Inspect_Exfo(InspectEventArgs e, ResultEventArgs _Result)
        {
            //------------------------------------------------检测-Exfo
            string temWhere_Exfo = _M_User_Exfo.GetSql_Where(_GLL_WorkOrder, _GLL_Standard_PigtailList);

            Maticsoft.DAL.My_GetTestData.GetDataEventArgs GetData_Exfo_e = new Maticsoft.DAL.My_GetTestData.GetDataEventArgs(temWhere_Exfo, e.ClientSN);
            _Result.Data_Exfo = _GLL_TestData.Start_GetData_Exfo(GetData_Exfo_e);
            ArrayList Inspect_Exfo = isEqual(_GLL_Standard_PigtailList, GetData_Exfo_e.PigtailList);

            if (Inspect_Exfo.Count > 0)
            {
                _Result.Fill_Exfo   = ArrayListToString(Inspect_Exfo);
                _Result.Result_Exfo = false;
            }
            else
            {
                //更新数据
                Maticsoft.DAL.My_GetTestData.UpDataEventArgs UpData_Exfo_e =
                    new Maticsoft.DAL.My_GetTestData.UpDataEventArgs(GetData_Exfo_e.TestData, _GLL_WorkOrder, _GLL_PackBatch.BatchNo, e.SN);
                _GLL_TestData.Start_UpData_Exfo(UpData_Exfo_e);
                _Result.Result_Exfo = true;

                if (_Result.Result_3D)  //如果3D为良品
                {
                    //如果需要打印标签
                    if (My_Print.IsPrint)
                    {
                        foreach (string temSN in _GLL_Standard_PigtailList)
                        {
                            //添加打印数据
                            DataSet temds = _M_Pack_Exfo.GetList("ClientSN='" + temSN + "' AND (Wave = '1550nm')");
                            My_Print.Add_PrintData(temds);
                        }
                    }
                }
            }

            //设置配组 为未完成 因为不需要进行配组
            _Result.Combination = false;
        }
예제 #22
0
        void wsPresets_SearchSettingsCompleted(object sender, ResultEventArgs e)
        {
            var ws = (WebServiceClient)sender;

            ws.SearchSettingsCompleted -= wsPresets_SearchSettingsCompleted;
            // Make sure method is executed on the same thread as this control.
            BeginInvoke((MethodInvoker) delegate()
            {
                AddTask(TaskName.SearchPresets);
                if (e.Error != null || e.Result == null)
                {
                    var showResult = (bool)e.UserState;
                    if (showResult)
                    {
                        SetHeaderBody(
                            MessageBoxIcon.Information,
                            "{0: yyyy-MM-dd HH:mm:ss}: No Presets received.",
                            DateTime.Now
                            );
                    }
                }
                else
                {
                    var result = (SearchResult)e.Result;
                    AppHelper.UpdateList(result.Presets, SettingsManager.Presets.Items);
                    AppHelper.UpdateList(result.PadSettings, SettingsManager.PadSettings.Items);
                    if ((bool)e.UserState)
                    {
                        var presetsCount     = (result.Presets == null) ? 0 : result.Presets.Length;
                        var padSettingsCount = (result.PadSettings == null) ? 0 : result.PadSettings.Length;
                        SetHeaderBody(
                            MessageBoxIcon.Information,
                            "{0: yyyy-MM-dd HH:mm:ss}: {1} Presets and {2} PAD Settings received.",
                            DateTime.Now, presetsCount, padSettingsCount
                            );
                    }
                }
                RemoveTask(TaskName.SearchPresets);
            });
        }
예제 #23
0
 void ProgramsWebServiceClient_GetProgramsCompleted(object sender, ResultEventArgs e)
 {
     MainForm.Current.LoadingCircle = false;
     if (e.Error != null)
     {
         var error = e.Error.Message;
         if (e.Error.InnerException != null)
         {
             error += "\r\n" + e.Error.InnerException.Message;
         }
         MainForm.Current.UpdateHelpHeader(error, MessageBoxIcon.Error);
     }
     else if (e.Result == null)
     {
         MainForm.Current.UpdateHelpHeader("No results were returned by the web service!", MessageBoxIcon.Error);
     }
     else
     {
         var result = (List <x360ce.Engine.Data.Program>)e.Result;
         ImportAndBindPrograms(result);
     }
 }
예제 #24
0
 private void OnGetExportJobsCompleted(object sender, ResultEventArgs <ExportJobCollection> e)
 {
     if (!e.HasError)
     {
         if (e.Context is Guid && (Guid)e.Context == RootMap.Id)
         {
             if (RootMap != null)
             {
                 RootMap.ExportJobs = new ObservableCollection <IExportJob>();
                 foreach (var pair in e.Result.OrderByDescending(q => q.Value.Created))
                 {
                     RootMap.ExportJobs.Add(pair.Value);
                 }
                 RefreshFilter();
             }
         }
     }
     else
     {
         SuperMessageBoxService.ShowError("Error Occurred", "There was a failure reading the exports that exist for the selected map.");
     }
 }
예제 #25
0
        void wsPresets_SearchSettingsCompleted(object sender, ResultEventArgs e)
        {
            // Make sure method is executed on the same thread as this control.
            if (InvokeRequired)
            {
                var method = new EventHandler <ResultEventArgs>(wsPresets_SearchSettingsCompleted);
                BeginInvoke(method, new object[] { sender, e });
                return;
            }
            // Detach event handler so resource could be released.
            var ws = (WebServiceClient)sender;

            ws.SearchSettingsCompleted -= wsPresets_SearchSettingsCompleted;
            if (e.Error != null)
            {
                var error = e.Error.Message;
                if (e.Error.InnerException != null)
                {
                    error += "\r\n" + e.Error.InnerException.Message;
                }
                _ParentForm.SetHeaderError(error);
            }
            else if (e.Result == null)
            {
                _ParentForm.SetHeaderBody("No default settings received.");
            }
            else
            {
                var result = (SearchResult)e.Result;
                AppHelper.UpdateList(result.Presets, SettingsManager.Presets.Items);
                SettingsManager.Current.UpsertPadSettings(result.PadSettings);
                SettingsManager.Current.CleanupPadSettings();
                var presetsCount     = (result.Presets == null) ? 0 : result.Presets.Length;
                var padSettingsCount = (result.PadSettings == null) ? 0 : result.PadSettings.Length;
                _ParentForm.SetHeaderBody("{0} default settings and {1} PAD settings received.", presetsCount, padSettingsCount);
            }
            _ParentForm.RemoveTask(TaskName.SearchPresets);
            PresetRefreshButton.Enabled = true;
        }
예제 #26
0
        /// <summary>
        /// 名称: 检测方法四
        /// 功能: 检测TFK12芯X2 线材
        /// </summary>
        /// <param name="e"></param>
        private void InspectMothod_four(InspectEventArgs e)
        {
            try
            {
                ResultEventArgs _Result = new ResultEventArgs();                                                                                                                           //定义结果返回类
                _Result.ErrorList = "";                                                                                                                                                    //异常列表 归零
                _GLL_SerialNumber = _M_SerialNumber.GetModel(e.SN);                                                                                                                        //获取条码 实体

                if (_GLL_SerialNumber == null || _GLL_SerialNumber.OrderID != _GLL_WorkOrder.OrderID || _GLL_SerialNumber.Type != Maticsoft.Model.E_SerialNumber_Type.ClientSN.ToString()) //判断是否属于此工单
                {
                    _Result.ErrorList += "此条码:" + e.SN + "  不属于此工单:" + _GLL_WorkOrder.OrderID + "";
                }
                else if (_GLL_SerialNumber.State != Maticsoft.Model.E_Barcode_State.Not_Pack.ToString()) //判断是否已经包装
                {
                    _Result.ErrorList += "此条码:" + _GLL_SerialNumber.SN + "  已包装或已打印!包装批号:" + _GLL_SerialNumber.BatchNO + "";
                }
                else
                {
                    if (_GLL_WorkOrder.InspectType == Maticsoft.Model.E_InspectType.检测3D与Exfo)
                    {
                        Inspect_four_Inspect_3D(e, _Result); Inspect_four_Inspect_Exfo(e, _Result);
                    }
                    else if (_GLL_WorkOrder.InspectType == Maticsoft.Model.E_InspectType.检测Exfo)
                    {
                        _Result.Result_3D = true; Inspect_four_Inspect_Exfo(e, _Result);
                    }
                    else if (_GLL_WorkOrder.InspectType == Maticsoft.Model.E_InspectType.检测3D)
                    {
                        _Result.Result_Exfo = true; Inspect_four_Inspect_3D(e, _Result);
                    }

                    //设置配组 为未完成 因为不需要进行配组
                    _Result.Combination = false;
                }
                e.InspectResult = _Result;
            }
            catch (Exception ex) { My_MessageBox.My_MessageBox_Message(ex.Message); }
        }
예제 #27
0
        private static void ResultEventHandler(object sender, ResultEventArgs <bool> resultEventArgs)
        {
            if (!DBHelper.SuccessSync)
            {
                Settings.User     = "";
                Settings.Password = "";
                Application.InvokeOnMainThread(AuthScreen.ClearPassword);
                Application.InvokeOnMainThread(() => AuthScreen.EditableVisualElements(true));
                return;
            }
#if DEBUG
            DConsole.WriteLine(Parameters.Splitter);
            DConsole.WriteLine("Синхронизация удачна");
            DConsole.WriteLine($"{nameof(DBHelper.SuccessSync)} - {DBHelper.SuccessSync}");
            DConsole.WriteLine($"In Class {nameof(Authorization)} Method {nameof(StartAuthorization)}");
            DConsole.WriteLine(Parameters.Splitter);
            DConsole.WriteLine("Loading first screen...");
#endif
            FileSystem.ClearPrivate();
            FileSystem.ClearShared();
            FileSystem.SyncShared(Settings.ImageServer, Settings.User, Settings.Password);
            Application.InvokeOnMainThread(() => Navigation.ModalMove(nameof(EventListScreen)));
        }
예제 #28
0
        private void Inspect_One_Inspect_3D(InspectEventArgs e, ResultEventArgs _Result)
        {
            //检测-3D
            string temWhere_3D = _M_User_3D.GetSql_Where(_GLL_WorkOrder, _GLL_Standard_PigtailList, e.SN);

            Maticsoft.DAL.My_GetTestData.GetDataEventArgs GetData_3D_e = new Maticsoft.DAL.My_GetTestData.GetDataEventArgs(temWhere_3D, e.SN);
            _Result.Data_3D = _GLL_TestData.Start_GetData_3D(GetData_3D_e);
            ArrayList Inspect_3D = isEqual(_GLL_Standard_PigtailList, GetData_3D_e.PigtailList);

            if (Inspect_3D.Count > 0)
            {
                _Result.Fill_3D   = ArrayListToString(Inspect_3D);
                _Result.Result_3D = false;
            }
            else
            {
                //更新数据
                Maticsoft.DAL.My_GetTestData.UpDataEventArgs UpData_3D_e =
                    new Maticsoft.DAL.My_GetTestData.UpDataEventArgs(GetData_3D_e.TestData, _GLL_WorkOrder, _GLL_PackBatch.BatchNo, e.SN);
                _GLL_TestData.Start_UpData_3D(UpData_3D_e);
                _Result.Result_3D = true;
            }
        }
        protected void LogResult(int intervals, double min, double max, double average)
        {
            var handler = ResultGenerated;

            if (handler == null)
            {
                return;
            }

            var result = new Result
            {
                DeviceCounter = _deviceCounter,
                LogDate       = DateTime.Now,
                Intervals     = intervals,
                MinimumRead   = min,
                MaximumRead   = max,
                AverageRead   = average
            };

            var e = new ResultEventArgs(result);

            handler(this, e);
        }
예제 #30
0
        private void Inspect_Three_Inspect_Exfo(InspectEventArgs e, ResultEventArgs _Result)
        {
            //------------------------------------------------检测-Exfo
            string temWhere_Exfo = _M_User_Exfo.GetSql_Where(_GLL_WorkOrder, _GLL_Standard_PigtailList, e.SN);

            Maticsoft.DAL.My_GetTestData.GetDataEventArgs GetData_Exfo_e = new Maticsoft.DAL.My_GetTestData.GetDataEventArgs(temWhere_Exfo, e.ClientSN);
            _Result.Data_Exfo = _GLL_TestData.Start_GetData_Exfo(GetData_Exfo_e);
            ArrayList Inspect_Exfo = isEqual(_GLL_Standard_PigtailList, GetData_Exfo_e.PigtailList);

            if (Inspect_Exfo.Count > 0)
            {
                _Result.Fill_Exfo   = ArrayListToString(Inspect_Exfo);
                _Result.Result_Exfo = false;
            }
            else
            {
                //更新数据
                Maticsoft.DAL.My_GetTestData.UpDataEventArgs UpData_Exfo_e =
                    new Maticsoft.DAL.My_GetTestData.UpDataEventArgs(GetData_Exfo_e.TestData, _GLL_WorkOrder, _GLL_PackBatch.BatchNo, e.SN);
                _GLL_TestData.Start_UpData_Exfo(UpData_Exfo_e);
                _Result.Result_Exfo = true;
            }
        }
예제 #31
0
        void ws_SearchSettingsCompleted(object sender, ResultEventArgs e)
        {
            sr = null;
            if (e.Error != null)
            {
                InternetPictureBox.Image = Properties.Resources.delete_16x16;
                return;
            }
            InternetPictureBox.Image = Properties.Resources.check_16x16;
            InternetLabel.Text      += " Done";
            var result = (SearchResult)e.Result;

            sr = result;
            // Reorder summaries
            sr.Summaries = sr.Summaries.OrderBy(x => x.ProductName).ThenBy(x => x.FileName).ThenBy(x => x.FileProductName).ThenByDescending(x => x.Users).ToArray();
            var s = GetBestSetting(result);

            if (s != null)
            {
                configs.Add(s);
            }
            Complete();
        }
예제 #32
0
        private static void SyncHandler(object state, ResultEventArgs <bool> resultEventArgs)
        {
            if (state.Equals("Full"))
            {
                Toast.MakeToast(Translator.Translate(resultEventArgs.Result ? "sync_success" : "sync_fail"));
            }
            else
            {
#if DEBUG
                DConsole.WriteLine($"---------------{Environment.NewLine}"
                                   + Translator.Translate(resultEventArgs.Result ? "sync_success" : "sync_fail"));
                DConsole.WriteLine($"Последняя ошибка: {LastError}");
                DConsole.WriteLine($"Результат синхронизации в callback {resultEventArgs.Result}" +
                                   $"{Environment.NewLine}{nameof(SuccessSync)}: {SuccessSync}" +
                                   $"{Environment.NewLine}---------------");
#endif
            }
            if (!resultEventArgs.Result)
            {
#if DEBUG
                DConsole.WriteLine(Parameters.Splitter);
                DConsole.WriteLine($"Новые данные не пришли," +
                                   $"настройки не обновляем" +
                                   $" {nameof(resultEventArgs.Result)} = {resultEventArgs.Result}" +
                                   $"{Environment.NewLine}Last Error {_db.LastError}");
                DConsole.WriteLine(Parameters.Splitter);
#endif
                return;
            }
#if DEBUG
            DConsole.WriteLine(Parameters.Splitter);
            DConsole.WriteLine("Пришли новые настройки. Обновляем их");
            DConsole.WriteLine(Parameters.Splitter);
#endif

            Settings.Init();
        }
예제 #33
0
        public async Task ResumeFromLaunch()
        {
            _connected = true;
            if (_initialBreakArgs != null)
            {
                await CheckModules();

                _libraryLoaded.Clear();
                await HandleBreakModeEvent(_initialBreakArgs);

                _initialBreakArgs = null;
            }
            else
            {
                switch (_launchOptions.LaunchCompleteCommand)
                {
                case LaunchCompleteCommand.ExecRun:
                    await MICommandFactory.ExecRun();

                    break;

                case LaunchCompleteCommand.ExecContinue:
                    await MICommandFactory.ExecContinue();

                    break;

                case LaunchCompleteCommand.None:
                    break;

                default:
                    Debug.Fail("Not implemented enum code for LaunchCompleteCommand??");
                    throw new NotImplementedException();
                }

                FireDeviceAppLauncherResume();
            }
        }
예제 #34
0
        void ResultEventHandler(object sender, ResultEventArgs args)
        {
            var result = args.Result;
            int index  = 0;

            lock (ImageResults) {
                foreach (var image in ImageResults)
                {
                    if (image.Path == result.Path)
                    {
                        index = ImageResults.IndexOf(image);
                        break;
                    }
                }
                Dispatcher.UIThread.InvokeAsync(() => {
                    lock (ImageResults) {
                        ImageResults[index] = new MNISTModelResult(result);
                        ImageClasses[result.Class].Add(new MNISTModelResult(result));
                        ClassesInfo[result.Class] = ClassInfoProcess(result.Class,
                                                                     ImageClasses[result.Class].Count);
                    }
                });
            }
        }
예제 #35
0
        private void settingsEditor_ResultReturned(object sender, ResultEventArgs e)
        {
            settingsGrid.Visibility = Visibility.Collapsed;

            if(e.IsOk)
            {
                price.ForceDraw(true);
            }
        }
예제 #36
0
        public DebuggedProcess(bool bLaunched, LaunchOptions launchOptions, ISampleEngineCallback callback, WorkerThread worker, BreakpointManager bpman, AD7Engine engine, HostConfigurationStore configStore) : base(launchOptions)
        {
            uint processExitCode = 0;
            _pendingMessages = new StringBuilder(400);
            _worker = worker;
            _breakpointManager = bpman;
            Engine = engine;
            _libraryLoaded = new List<string>();
            _loadOrder = 0;
            MICommandFactory = MICommandFactory.GetInstance(launchOptions.DebuggerMIMode, this);
            _waitDialog = MICommandFactory.SupportsStopOnDynamicLibLoad() ? new HostWaitDialog(ResourceStrings.LoadingSymbolMessage, ResourceStrings.LoadingSymbolCaption) : null;
            Natvis = new Natvis.Natvis(this, launchOptions.ShowDisplayString);

            // we do NOT have real Win32 process IDs, so we use a guid
            AD_PROCESS_ID pid = new AD_PROCESS_ID();
            pid.ProcessIdType = (int)enum_AD_PROCESS_ID.AD_PROCESS_ID_GUID;
            pid.guidProcessId = Guid.NewGuid();
            this.Id = pid;

            SourceLineCache = new SourceLineCache(this);

            _callback = callback;
            _moduleList = new List<DebuggedModule>();
            ThreadCache = new ThreadCache(callback, this);
            Disassembly = new Disassembly(this);
            ExceptionManager = new ExceptionManager(MICommandFactory, _worker, _callback, configStore);

            VariablesToDelete = new List<string>();

            OutputStringEvent += delegate (object o, string message)
            {
                // We can get messages before we have started the process
                // but we can't send them on until it is
                if (_connected)
                {
                    _callback.OnOutputString(message);
                }
                else
                {
                    _pendingMessages.Append(message);
                }
            };

            LibraryLoadEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;
                string file = results.Results.TryFindString("host-name");
                if (!string.IsNullOrEmpty(file) && MICommandFactory.SupportsStopOnDynamicLibLoad())
                {
                    _libraryLoaded.Add(file);
                    if (_waitDialog != null)
                    {
                        _waitDialog.ShowWaitDialog(file);
                    }
                }
                else if (this.MICommandFactory.Mode == MIMode.Clrdbg)
                {
                    string id = results.Results.FindString("id");
                    ulong baseAddr = results.Results.FindAddr("base-address");
                    uint size = results.Results.FindUint("size");
                    bool symbolsLoaded = results.Results.FindInt("symbols-loaded") != 0;
                    var module = new DebuggedModule(id, file, baseAddr, size, symbolsLoaded, string.Empty, _loadOrder++);
                    lock (_moduleList)
                    {
                        _moduleList.Add(module);
                    }
                    _callback.OnModuleLoad(module);
                }
                else if (!string.IsNullOrEmpty(file))
                {
                    string addr = results.Results.TryFindString("loaded_addr");
                    if (string.IsNullOrEmpty(addr) || addr == "-")
                    {
                        return; // identifies the exe, not a real load
                    }
                    // generate module 
                    string id = results.Results.TryFindString("name");
                    bool symsLoaded = true;
                    string symPath = null;
                    if (results.Results.Contains("symbols-path"))
                    {
                        symPath = results.Results.FindString("symbols-path");
                        if (string.IsNullOrEmpty(symPath))
                        {
                            symsLoaded = false;
                        }
                    }
                    else
                    {
                        symPath = file;
                    }
                    ulong loadAddr = results.Results.FindAddr("loaded_addr");

                    uint size = results.Results.FindUint("size");
                    if (String.IsNullOrEmpty(id))
                    {
                        id = file;
                    }
                    var module = FindModule(id);
                    if (module == null)
                    {
                        module = new DebuggedModule(id, file, loadAddr, size, symsLoaded, symPath, _loadOrder++);
                        lock (_moduleList)
                        {
                            _moduleList.Add(module);
                        }
                        _callback.OnModuleLoad(module);
                    }
                }
            };

            if (_launchOptions is LocalLaunchOptions)
            {
                LocalLaunchOptions localLaunchOptions = (LocalLaunchOptions)_launchOptions;
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) &&
                    _launchOptions.DebuggerMIMode == MIMode.Gdb &&
                    String.IsNullOrEmpty(localLaunchOptions.MIDebuggerServerAddress)
                    )
                {
                    // For local linux launch, use the local linux transport which creates a new terminal and uses fifos for gdb communication.
                    // CONSIDER: add new flag and only do this if new terminal is true? Note that setting this to false on linux will cause a deadlock
                    // during debuggee launch
                    if (localLaunchOptions.ShouldStartServer())
                    {
                        this.Init(new MICore.ClientServerTransport
                            (
                                        new LocalLinuxTransport(),
                                        new ServerTransport(killOnClose: true, filterStdout: localLaunchOptions.FilterStdout, filterStderr: localLaunchOptions.FilterStderr)
                                  ), _launchOptions
                            );
                    }
                    else
                    {
                        this.Init(new MICore.LocalLinuxTransport(), _launchOptions);
                    }
                }
                else
                {
                    if (localLaunchOptions.ShouldStartServer())
                    {
                        this.Init(new MICore.ClientServerTransport
                            (
                                        new LocalTransport(),
                                        new ServerTransport(killOnClose: true, filterStdout: localLaunchOptions.FilterStdout, filterStderr: localLaunchOptions.FilterStderr)
                                  ), _launchOptions
                            );
                    }
                    else
                    {
                        this.Init(new MICore.LocalTransport(), _launchOptions);
                    }
                }
            }
            else if (_launchOptions is PipeLaunchOptions)
            {
                this.Init(new MICore.PipeTransport(), _launchOptions);
            }
            else if (_launchOptions is TcpLaunchOptions)
            {
                this.Init(new MICore.TcpTransport(), _launchOptions);
            }
            else
            {
                throw new ArgumentOutOfRangeException("LaunchInfo.options");
            }

            MIDebugCommandDispatcher.AddProcess(this);

            // When the debuggee exits, we need to exit the debugger
            ProcessExitEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;

                if (results.Results.Contains("exit-code"))
                {
                    // GDB sometimes returns exit codes, which don't fit into uint, like "030000000472".
                    // And we can't throw from here, because it crashes VS.
                    // Full exit code will still usually be reported in the Output window,
                    // but here let's return "uint.MaxValue" just to indicate that something went wrong.
                    if (!uint.TryParse(results.Results.FindString("exit-code"), out processExitCode))
                    {
                        processExitCode = uint.MaxValue;
                    }
                }

                // quit MI Debugger
                _worker.PostOperation(CmdExitAsync);
                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }
            };

            // When the debugger exits, we tell AD7 we are done
            DebuggerExitEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                // this is the last AD7 Event we can ever send
                // Also the transport is closed when this returns
                _callback.OnProcessExit(processExitCode);

                Dispose();
            };

            DebuggerAbortedEvent += delegate (object o, /*OPTIONAL*/ string debuggerExitCode)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                // The MI debugger process unexpectedly exited.
                _worker.PostOperation(() =>
                    {
                        // If the MI Debugger exits before we get a resume call, we have no way of sending program destroy. So just let start debugging fail.
                        if (!_connected)
                        {
                            return;
                        }

                        string message;
                        if (string.IsNullOrEmpty(debuggerExitCode))
                            message = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_MIDebuggerExited_UnknownCode, MICommandFactory.Name);
                        else
                            message = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_MIDebuggerExited_WithCode, MICommandFactory.Name, debuggerExitCode);

                        _callback.OnError(message);
                        _callback.OnProcessExit(uint.MaxValue);

                        Dispose();
                    });
            };

            ModuleLoadEvent += async delegate (object o, EventArgs args)
            {
                // NOTE: This is an async void method, so make sure exceptions are caught and somehow reported

                if (_libraryLoaded.Count != 0)
                {
                    string moduleNames = string.Join(", ", _libraryLoaded);

                    try
                    {
                        _libraryLoaded.Clear();
                        SourceLineCache.OnLibraryLoad();

                        await _breakpointManager.BindAsync();
                        await CheckModules();

                        _bLastModuleLoadFailed = false;
                    }
                    catch (Exception e)
                    {
                        if (this.ProcessState == MICore.ProcessState.Exited)
                        {
                            return; // ignore exceptions after the process has exited
                        }

                        string exceptionDescription = EngineUtils.GetExceptionDescription(e);
                        string message = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_ExceptionProcessingModules, moduleNames, exceptionDescription);

                        // to avoid spamming the user, if the last module failed, we send the next failure to the output windiw instead of a message box
                        if (!_bLastModuleLoadFailed)
                        {
                            _callback.OnError(message);
                            _bLastModuleLoadFailed = true;
                        }
                        else
                        {
                            _callback.OnOutputMessage(new OutputMessage(message, enum_MESSAGETYPE.MT_OUTPUTSTRING, OutputMessage.Severity.Warning));
                        }
                    }
                }
                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }
                if (MICommandFactory.SupportsStopOnDynamicLibLoad())
                {
                    CmdContinueAsync();
                }
            };

            // When we break we need to gather information
            BreakModeEvent += async delegate (object o, EventArgs args)
            {
                // NOTE: This is an async void method, so make sure exceptions are caught and somehow reported

                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;
                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }

                if (!this._connected)
                {
                    _initialBreakArgs = results;
                    return;
                }

                try
                {
                    await HandleBreakModeEvent(results);
                }
                catch (Exception e)
                {
                    if (this.ProcessState == MICore.ProcessState.Exited)
                    {
                        return; // ignore exceptions after the process has exited
                    }

                    string exceptionDescription = EngineUtils.GetExceptionDescription(e);
                    string message = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_FailedToEnterBreakState, exceptionDescription);
                    _callback.OnError(message);

                    Terminate();
                }
            };

            ErrorEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                ResultEventArgs result = (ResultEventArgs)args;
                _callback.OnError(result.Results.FindString("msg"));
            };

            ThreadCreatedEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs result = (ResultEventArgs)args;
                ThreadCache.ThreadEvent(result.Results.FindInt("id"), /*deleted */false);
            };

            ThreadExitedEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs result = (ResultEventArgs)args;
                ThreadCache.ThreadEvent(result.Results.FindInt("id"), /*deleted*/true);
            };

            MessageEvent += (object o, ResultEventArgs args) =>
            {
                OutputMessage outputMessage = DecodeOutputEvent(args.Results);
                if (outputMessage != null)
                {
                    _callback.OnOutputMessage(outputMessage);
                }
            };

            TelemetryEvent += (object o, ResultEventArgs args) =>
            {
                string eventName;
                KeyValuePair<string, object>[] properties;
                if (DecodeTelemetryEvent(args.Results, out eventName, out properties))
                {
                    HostTelemetry.SendEvent(eventName, properties);
                }
            };

            BreakChangeEvent += _breakpointManager.BreakpointModified;
        }
예제 #37
0
 public override void ProcessResults(object sender, ResultEventArgs results)
 {
     var result = GetResultOfType<LoginResult>(results);
     if (result != null)
     uc.Add(new User(result.UserName, result.IP, result.Port, result.TimeStamp));
 }
예제 #38
0
 /// <summary>
 /// Event fired when the user details have arrived
 /// </summary>
 /// <param name="sender">the event sender</param>
 /// <param name="e">the event params</param>
 private void GetUserDetailsCompleted(object sender, ResultEventArgs<Users> e)
 {
     this.Dispatcher.BeginInvoke(new EventHandler<ResultEventArgs<Users>>(this.GetUserDetailsCompletedOnThread), sender, e);
 }
예제 #39
0
 private void Form_OnProcess(object sender, ResultEventArgs e)
 {
     e.Result = this._controller.Process();
 }
예제 #40
0
        private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest breakRequest)
        {
            string reason = results.Results.TryFindString("reason");
            int tid;
            if (!results.Results.Contains("thread-id"))
            {
                Results res = await MICommandFactory.ThreadInfo();
                tid = res.FindInt("id");
            }
            else
            {
                tid = results.Results.FindInt("thread-id");
            }

            if (_childProcessHandler != null && await _childProcessHandler.Stopped(results.Results, tid))
            {
                return;
            }

            // Any existing variable objects at this point are from the last time we were in break mode, and are
            //  therefore invalid.  Dispose them so they're marked for cleanup.
            lock (this.ActiveVariables)
            {
                foreach (IVariableInformation varInfo in this.ActiveVariables)
                {
                    varInfo.Dispose();
                }
                this.ActiveVariables.Clear();
            }

            ThreadCache.MarkDirty();
            MICommandFactory.DefineCurrentThread(tid);

            DebuggedThread thread = await ThreadCache.GetThread(tid);
            if (thread == null)
            {
                if (!this.IsStopDebuggingInProgress)
                {
                    Debug.Fail("Failed to find thread on break event.");
                    throw new Exception(String.Format(CultureInfo.CurrentUICulture, ResourceStrings.MissingThreadBreakEvent, tid));
                }
                else
                {
                    // It's possible that the SIGINT was sent because GDB is trying to terminate a running debuggee and stop debugging
                    // See https://devdiv.visualstudio.com/DevDiv/VS%20Diag%20IntelliTrace/_workItems?_a=edit&id=236275&triage=true
                    // for a repro
                    return;
                }
            }

            await ThreadCache.StackFrames(thread);  // prepopulate the break thread in the thread cache
            ThreadContext cxt = await ThreadCache.GetThreadContext(thread);

            if (cxt == null)
            {
                // Something went seriously wrong. For instance, this can happen when the primary thread
                // of an app exits on linux while background threads continue to run with pthread_exit on the main thread
                // See https://devdiv.visualstudio.com/DefaultCollection/DevDiv/VS%20Diag%20IntelliTrace/_workItems?_a=edit&id=197616&triage=true
                // for a repro
                Debug.Fail("Failed to find thread on break event.");
                throw new Exception(String.Format(CultureInfo.CurrentUICulture, ResourceStrings.MissingThreadBreakEvent, tid));
            }

            ThreadCache.SendThreadEvents(this, null);   // make sure that new threads have been pushed to the UI

            //always delete breakpoints pending deletion on break mode
            //the flag tells us if we hit an existing breakpoint pending deletion that we need to continue

            await _breakpointManager.DeleteBreakpointsPendingDeletion();

            // Delete GDB variable objects that have been marked for cleanup
            List<string> variablesToDelete = null;
            lock (VariablesToDelete)
            {
                variablesToDelete = new List<string>(this.VariablesToDelete);
                VariablesToDelete.Clear();
            }

            foreach (var variable in variablesToDelete)
            {
                try
                {
                    await MICommandFactory.VarDelete(variable);
                }
                catch (MIException)
                {
                    //not much to do really, we're leaking MI debugger variables.
                    Debug.Fail("Failed to delete variable: " + variable + ". This is leaking memory in the MI Debugger.");
                }
            }

            if (String.IsNullOrWhiteSpace(reason) && !this.EntrypointHit)
            {
                breakRequest = BreakRequest.None;   // don't let stopping interfere with launch processing
                this.EntrypointHit = true;
                CmdContinueAsync();
                FireDeviceAppLauncherResume();
            }
            else if (reason == "entry-point-hit")
            {
                this.EntrypointHit = true;
                _callback.OnEntryPoint(thread);
            }
            else if (reason == "breakpoint-hit")
            {
                string bkptno = results.Results.FindString("bkptno");
                ulong addr = cxt.pc ?? 0;

                bool fContinue;
                TupleValue frame = results.Results.TryFind<TupleValue>("frame");
                AD7BoundBreakpoint[] bkpt = _breakpointManager.FindHitBreakpoints(bkptno, addr, frame, out fContinue);
                if (bkpt != null)
                {
                    if (frame != null && addr != 0)
                    {
                        string sourceFile = frame.TryFindString("fullname");
                        if (!String.IsNullOrEmpty(sourceFile))
                        {
                            await this.VerifySourceFileTimestamp(addr, sourceFile);
                        }
                    }

                    // Hitting a bp before the entrypoint overrules entrypoint processing.
                    this.EntrypointHit = true;

                    List<object> bplist = new List<object>();
                    bplist.AddRange(bkpt);
                    _callback.OnBreakpoint(thread, bplist.AsReadOnly());
                }
                else if (!this.EntrypointHit)
                {
                    this.EntrypointHit = true;

                    if (this.MICommandFactory.Mode == MIMode.Lldb)
                    {
                        // When the terminal window is closed, a SIGHUP is sent to lldb-mi and LLDB's default is to stop.
                        // We want to not stop (break) when this happens and the SIGHUP to be sent to the debuggee process.
                        // LLDB requires this command to be issued after the process has started.
                        await ConsoleCmdAsync("process handle --pass true --stop false --notify false SIGHUP", true);
                    }

                    _callback.OnEntryPoint(thread);
                }
                else if (bkptno == "<EMBEDDED>")
                {
                    _callback.OnBreakpoint(thread, new ReadOnlyCollection<object>(new AD7BoundBreakpoint[] { }));
                }
                else
                {
                    if (fContinue)
                    {
                        //we hit a bp pending deletion
                        //post the CmdContinueAsync operation so it does not happen until we have deleted all the pending deletes
                        CmdContinueAsyncConditional(breakRequest);
                    }
                    else
                    {
                        // not one of our breakpoints, so stop with a message
                        _callback.OnException(thread, "Unknown breakpoint", "", 0);
                    }
                }
            }
            else if (reason == "watchpoint-trigger")
            {
                var wpt = results.Results.Find("wpt");
                string bkptno = wpt.FindString("number");
                ulong addr = cxt.pc ?? 0;

                bool fContinue;
                AD7BoundBreakpoint bkpt = _breakpointManager.FindHitWatchpoint(bkptno, out fContinue);
                if (bkpt != null)
                {
                    List<object> bplist = new List<object>();
                    bplist.Add(bkpt);
                    _callback.OnBreakpoint(thread, bplist.AsReadOnly());
                }
                else
                {
                    if (fContinue)
                    {
                        //we hit a bp pending deletion
                        //post the CmdContinueAsync operation so it does not happen until we have deleted all the pending deletes
                        CmdContinueAsyncConditional(breakRequest);
                    }
                    else
                    {
                        // not one of our breakpoints, so stop with a message
                        _callback.OnException(thread, "Unknown watchpoint", "", 0);
                    }
                }
            }
            else if (reason == "end-stepping-range" || reason == "function-finished")
            {
                _callback.OnStepComplete(thread);
            }
            else if (reason == "signal-received")
            {
                string name = results.Results.TryFindString("signal-name");
                if ((name == "SIG32") || (name == "SIG33"))
                {
                    // we are going to ignore these (Sigma) signals for now
                    CmdContinueAsyncConditional(breakRequest);
                }
                else if (MICommandFactory.IsAsyncBreakSignal(results.Results))
                {
                    _callback.OnAsyncBreakComplete(thread);
                }
                else
                {
                    uint code = 0;
                    string sigName = results.Results.TryFindString("signal-name");
                    code = results.Results.Contains("signal") ? results.Results.FindUint("signal") : 0;
                    if (String.IsNullOrEmpty(sigName) && code != 0 && EngineUtils.SignalMap.Instance.ContainsValue(code))
                    {
                        sigName = EngineUtils.SignalMap.Instance.First((p) => p.Value == code).Key;
                    }
                    else if (!String.IsNullOrEmpty(sigName) && code == 0 && EngineUtils.SignalMap.Instance.ContainsKey(sigName))
                    {
                        code = EngineUtils.SignalMap.Instance[sigName];
                    }
                    bool stoppedAtSIGSTOP = false;
                    if (sigName == "SIGSTOP")
                    {
                        if (AD7Engine.RemoveChildProcess(_launchOptions.ProcessId))
                        {
                            stoppedAtSIGSTOP = true;
                        }
                    }
                    string message = results.Results.TryFindString("signal-meaning");
                    if (stoppedAtSIGSTOP)
                    {
                        await MICommandFactory.Signal("SIGCONT");
                    }
                    else
                    {
                        _callback.OnException(thread, sigName, message, code);
                    }
                }
            }
            else if (reason == "exception-received")
            {
                string exceptionName = results.Results.TryFindString("exception-name");
                if (string.IsNullOrEmpty(exceptionName))
                    exceptionName = "Exception";

                string description = results.Results.FindString("exception");
                Guid? exceptionCategory;
                ExceptionBreakpointState state;
                MICommandFactory.DecodeExceptionReceivedProperties(results.Results, out exceptionCategory, out state);

                _callback.OnException(thread, exceptionName, description, 0, exceptionCategory, state);
            }
            else
            {
                if (breakRequest == BreakRequest.None)
                {
                    Debug.Fail("Unknown stopping reason");
                    _callback.OnException(thread, "Unknown", "Unknown stopping event", 0);
                }
            }
            if (IsExternalBreakRequest(breakRequest))
            {
                _callback.OnStopComplete(thread);
            }
        }
예제 #41
0
        /// <summary>
        /// Listings data has been received
        /// </summary>
        /// <param name="listingsReceived">the listings</param>
        private void FrontFeaturedListingsReceivedSync(ResultEventArgs<Listings> listingsReceived)
        {
            if (!listingsReceived.ResultStatus.Success)
            {
                this.StatusText = "Failed to load listings";
                return;
            }

            this.DisplayListings(listingsReceived.ResultValue.Results);
            this.StatusText = string.Format(CultureInfo.InvariantCulture, "Loaded {0} front listings", this.listings.Count);
            CommandLocator.MainWindowCanExecuteChanged();
        }
예제 #42
0
        void CompletedGetFavoritesSync(ResultEventArgs<Listings> e)
        {
            if (!e.ResultStatus.Success)
            {
                this.ErrorMessage = e.ResultStatus.ErrorMessage;
                return;
            }

            this.listings.Clear();

            foreach (Listing listing in e.ResultValue.Results)
            {
                this.listings.Add(new ListingViewModel(listing));
            }

            this.ErrorMessage = this.listings.Count.ToString() + " listings loaded";
        }
예제 #43
0
        public DebuggedProcess(bool bLaunched, LaunchOptions launchOptions, ISampleEngineCallback callback, WorkerThread worker, BreakpointManager bpman, AD7Engine engine, string registryRoot)
        {
            uint processExitCode = 0;
            g_Process = this;
            _bStarted = false;
            _pendingMessages = new StringBuilder(400);
            _worker = worker;
            _launchOptions = launchOptions;
            _breakpointManager = bpman;
            Engine = engine;
            _libraryLoaded = new List<string>();
            _loadOrder = 0;
            MICommandFactory = MICommandFactory.GetInstance(launchOptions.DebuggerMIMode, this);
            _waitDialog = MICommandFactory.SupportsStopOnDynamicLibLoad() ? new WaitDialog(ResourceStrings.LoadingSymbolMessage, ResourceStrings.LoadingSymbolCaption) : null;
            Natvis = new Natvis.Natvis(this);

            // we do NOT have real Win32 process IDs, so we use a guid
            AD_PROCESS_ID pid = new AD_PROCESS_ID();
            pid.ProcessIdType = (int)enum_AD_PROCESS_ID.AD_PROCESS_ID_GUID;
            pid.guidProcessId = Guid.NewGuid();
            this.Id = pid;

            SourceLineCache = new SourceLineCache(this);

            _callback = callback;
            _moduleList = new List<DebuggedModule>();
            ThreadCache = new ThreadCache(callback, this);
            Disassembly = new Disassembly(this);
            ExceptionManager = new ExceptionManager(MICommandFactory, _worker, _callback, registryRoot);

            VariablesToDelete = new List<string>();

            MessageEvent += delegate (object o, string message)
            {
                // We can get messages before we have started the process
                // but we can't send them on until it is
                if (_bStarted)
                {
                    _callback.OnOutputString(message);
                }
                else
                {
                    _pendingMessages.Append(message);
                }
            };

            LibraryLoadEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;
                string file = results.Results.TryFindString("host-name");
                if (!string.IsNullOrEmpty(file) && MICommandFactory.SupportsStopOnDynamicLibLoad())
                {
                    _libraryLoaded.Add(file);
                    if (_waitDialog != null)
                    {
                        _waitDialog.ShowWaitDialog(file);
                    }
                }
                else if (this.MICommandFactory.Mode == MIMode.Clrdbg)
                {
                    string id = results.Results.FindString("id");
                    ulong baseAddr = results.Results.FindAddr("base-address");
                    uint size = results.Results.FindUint("size");
                    bool symbolsLoaded = results.Results.FindInt("symbols-loaded") != 0;
                    var module = new DebuggedModule(id, file, baseAddr, size, symbolsLoaded, string.Empty, _loadOrder++);
                    lock (_moduleList)
                    {
                        _moduleList.Add(module);
                    }
                    _callback.OnModuleLoad(module);
                }
                else if (!string.IsNullOrEmpty(file))
                {
                    string addr = results.Results.TryFindString("loaded_addr");
                    if (string.IsNullOrEmpty(addr) || addr == "-")
                    {
                        return; // identifies the exe, not a real load
                    }
                    // generate module 
                    string id = results.Results.TryFindString("name");
                    bool symsLoaded = true;
                    string symPath = null;
                    if (results.Results.Contains("symbols-path"))
                    {
                        symPath = results.Results.FindString("symbols-path");
                        if (string.IsNullOrEmpty(symPath))
                        {
                            symsLoaded = false;
                        }
                    }
                    else
                    {
                        symPath = file;
                    }
                    ulong loadAddr = results.Results.FindAddr("loaded_addr");
                    uint size = results.Results.FindUint("size");
                    if (String.IsNullOrEmpty(id))
                    {
                        id = file;
                    }
                    var module = FindModule(id);
                    if (module == null)
                    {
                        module = new DebuggedModule(id, file, loadAddr, size, symsLoaded, symPath, _loadOrder++);
                        lock (_moduleList)
                        {
                            _moduleList.Add(module);
                        }
                        _callback.OnModuleLoad(module);
                    }
                }
            };

            if (_launchOptions is LocalLaunchOptions)
            {
                this.Init(new MICore.LocalTransport(), _launchOptions);
            }
            else if (_launchOptions is PipeLaunchOptions)
            {
                this.Init(new MICore.PipeTransport(), _launchOptions);
            }
            else if (_launchOptions is TcpLaunchOptions)
            {
                this.Init(new MICore.TcpTransport(), _launchOptions);
            }
            else if (_launchOptions is SerialLaunchOptions)
            {
                string port = ((SerialLaunchOptions)_launchOptions).Port;
                this.Init(new MICore.SerialTransport(port), _launchOptions);
            }
            else
            {
                throw new ArgumentOutOfRangeException("LaunchInfo.options");
            }

            MIDebugCommandDispatcher.AddProcess(this);

            // When the debuggee exits, we need to exit the debugger
            ProcessExitEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;

                if (results.Results.Contains("exit-code"))
                {
                    processExitCode = results.Results.FindUint("exit-code");
                }

                // quit MI Debugger
                _worker.PostOperation(CmdExitAsync);
                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }
            };

            // When the debugger exits, we tell AD7 we are done
            DebuggerExitEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                // this is the last AD7 Event we can ever send
                // Also the transport is closed when this returns
                _callback.OnProcessExit(processExitCode);

                Dispose();
            };

            DebuggerAbortedEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                // The MI debugger process unexpectedly exited.
                _worker.PostOperation(() =>
                    {
                        // If the MI Debugger exits before we get a resume call, we have no way of sending program destroy. So just let start debugging fail.
                        if (!_connected)
                        {
                            return;
                        }

                        _callback.OnError(MICoreResources.Error_MIDebuggerExited);
                        _callback.OnProcessExit(uint.MaxValue);

                        Dispose();
                    });
            };

            ModuleLoadEvent += async delegate (object o, EventArgs args)
            {
                // NOTE: This is an async void method, so make sure exceptions are caught and somehow reported

                if (_libraryLoaded.Count != 0)
                {
                    string moduleNames = string.Join(", ", _libraryLoaded);

                    try
                    {
                        _libraryLoaded.Clear();
                        SourceLineCache.OnLibraryLoad();

                        await _breakpointManager.BindAsync();
                        await CheckModules();

                        _bLastModuleLoadFailed = false;
                    }
                    catch (Exception e)
                    {
                        if (this.ProcessState == MICore.ProcessState.Exited)
                        {
                            return; // ignore exceptions after the process has exited
                        }

                        string exceptionDescription = EngineUtils.GetExceptionDescription(e);
                        string message = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_ExceptionProcessingModules, moduleNames, exceptionDescription);

                        // to avoid spamming the user, if the last module failed, we send the next failure to the output windiw instead of a message box
                        if (!_bLastModuleLoadFailed)
                        {
                            _callback.OnError(message);
                            _bLastModuleLoadFailed = true;
                        }
                        else
                        {
                            _callback.OnOutputMessage(message, enum_MESSAGETYPE.MT_OUTPUTSTRING);
                        }
                    }
                }
                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }
                if (MICommandFactory.SupportsStopOnDynamicLibLoad())
                {
                    CmdContinueAsync();
                }
            };

            // When we break we need to gather information
            BreakModeEvent += async delegate (object o, EventArgs args)
            {
                // NOTE: This is an async void method, so make sure exceptions are caught and somehow reported

                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;
                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }

                if (!this._connected)
                {
                    _initialBreakArgs = results;
                    return;
                }

                try
                {
                    await HandleBreakModeEvent(results);
                }
                catch (Exception e)
                {
                    if (this.ProcessState == MICore.ProcessState.Exited)
                    {
                        return; // ignore exceptions after the process has exited
                    }

                    string exceptionDescription = EngineUtils.GetExceptionDescription(e);
                    string message = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_FailedToEnterBreakState, exceptionDescription);
                    _callback.OnError(message);

                    Terminate();
                }
            };

            RunModeEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                if (!_bStarted)
                {
                    _bStarted = true;

                    // Send any strings we got before the process came up
                    if (_pendingMessages.Length != 0)
                    {
                        try
                        {
                            _callback.OnOutputString(_pendingMessages.ToString());
                        }
                        catch
                        {
                            // If something goes wrong sending the output, lets not crash VS
                        }
                    }
                    _pendingMessages = null;
                }
            };

            ErrorEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                ResultEventArgs result = (ResultEventArgs)args;
                _callback.OnError(result.Results.FindString("msg"));
            };

            ThreadCreatedEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs result = (ResultEventArgs)args;
                ThreadCache.ThreadEvent(result.Results.FindInt("id"), /*deleted */false);
            };

            ThreadExitedEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs result = (ResultEventArgs)args;
                ThreadCache.ThreadEvent(result.Results.FindInt("id"), /*deleted*/true);
            };

            BreakChangeEvent += _breakpointManager.BreakpointModified;
        }
예제 #44
0
        public async Task ResumeFromLaunch()
        {
            _connected = true;

            // Send any strings we got before the process came up
            if (_pendingMessages != null && _pendingMessages.Length != 0)
            {
                _callback.OnOutputString(_pendingMessages.ToString());
                _pendingMessages = null;
            }

            await this.ExceptionManager.EnsureSettingsUpdated();

            if (_initialBreakArgs != null)
            {
                await CheckModules();
                _libraryLoaded.Clear();
                await HandleBreakModeEvent(_initialBreakArgs);
                _initialBreakArgs = null;
            }
            else
            {
                switch (_launchOptions.LaunchCompleteCommand)
                {
                    case LaunchCompleteCommand.ExecRun:
                        await MICommandFactory.ExecRun();
                        break;
                    case LaunchCompleteCommand.ExecContinue:
                        await MICommandFactory.ExecContinue();
                        break;
                    case LaunchCompleteCommand.None:
                        break;
                    default:
                        Debug.Fail("Not implemented enum code for LaunchCompleteCommand??");
                        throw new NotImplementedException();
                }

                FireDeviceAppLauncherResume();
            }
        }
예제 #45
0
 private void CompletedGetFavorites(object sender, ResultEventArgs<Listings> e)
 {
     this.Dispatcher.BeginInvoke(
         new ResultsReceivedHandler<Listings>(CompletedGetFavoritesSync), e);
 }
예제 #46
0
        private void OnRenameNodeMetadataCompleted(object sender, RenameNodeMetadataCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                ResultEventArgs resultEventArgs = new ResultEventArgs(e.Result);

                if (RenameNodeMetadataCompleted != null)
                {
                    RenameNodeMetadataCompleted.Invoke(this, resultEventArgs);
                }
            }
        }
예제 #47
0
        void kwsCallback(IntPtr utter_hyp)
        {
            String result = Marshal.PtrToStringAnsi(utter_hyp);
            int kwIndex = kwsDictionary[result];
            int topicInd = topicIndices[kwIndex];
            if (!topicDone[topicInd] && !kwUsed[kwIndex])
            {
                kwUsed[kwIndex] = true;
                scores[topicInd] += kwScores[kwIndex];
                double prob = (float)scores[topicInd] / totalScores[topicInd];
                if (prob > maxScore)
                {
                    maxScore = prob;
                    maxIndex = topicInd;
                }
            }

            string probs = "";
            for (int topicNumber = 0; topicNumber < nTopics; topicNumber++)
            {
                int p = 100 * scores[topicNumber] / totalScores[topicNumber];
                probs += "Topic " + topicNumber.ToString() + " probability: " + p.ToString() + "%\n";
            }

            ResultEventArgs args = new ResultEventArgs();
            args.text = result;
            args.probs = probs;
            OnResults(args);
            if (maxScore > scoreThreshold)
            {
                args.text = maxIndex.ToString() + " " + maxScore.ToString();
                topicDone[maxIndex] = true;
                OnResults(args);
                maxScore = 0;
            }
        }
예제 #48
0
        /// <summary>
        /// Search for listings by keyword.
        /// </summary>
        /// <param name="searchTerms">Specify keywords to search on, separated by spaces or semicolons. You can also use the operators AND and NOT to control keyword matching.</param>
        /// <param name="sortOn">Specify the field to sort on</param>
        /// <param name="sortOrder">Specify the direction to sort on </param>
        /// <param name="minPrice">Minimum for restricting price ranges. Values are in US dollars and may include cents.</param>
        /// <param name="maxPrice">Maximum for restricting price ranges. Values are in US dollars and may include cents.</param>
        /// <param name="searchDescription">If true, listing descriptions will count towards search matches. (This may produce less relevant results.)</param>
        /// <param name="offset">To page through large result sets</param>
        /// <param name="limit">Specify the number of results to return</param>
        /// <param name="detailLevel">control how much information to return</param>
        /// <returns>the async state of the request</returns>
        public IAsyncResult GetListingsByKeyword(IEnumerable<string> searchTerms, SortField sortOn, SortOrder sortOrder, decimal? minPrice, decimal? maxPrice, bool searchDescription, int offset, int limit, DetailLevel detailLevel)
        {
            if (!ServiceHelper.TestCallPrerequisites(this, this.GetListingsByKeywordCompleted, this.etsyContext))
            {
                return null;
            }

            // error if the given min price is more than the given max price
            if (minPrice.HasValue && maxPrice.HasValue && (minPrice.Value > maxPrice.Value))
            {
                var errorResult = new ResultEventArgs<Listings>(null, new ResultStatus("Invalid price range", null));
                ServiceHelper.TestSendEvent(this.GetListingsByKeywordCompleted, this, errorResult);
                return null;
            }

            UriBuilder uriBuilder = UriBuilder.Start(this.etsyContext, "listings/keywords/")
                .Append(searchTerms)
                .Sort(sortOn, sortOrder)
                .OptionalParam("min_price", minPrice)
                .OptionalParam("max_price", maxPrice)
                .Param("search_description", searchDescription)
                .OffsetLimit(offset, limit)
                .DetailLevel(detailLevel);

            return ServiceHelper.GenerateRequest(this, uriBuilder.Result(), this.GetListingsByKeywordCompleted);
        }
예제 #49
0
        public async Task ResumeFromLaunch()
        {
            _connected = true;

            // Send any strings we got before the process came up
            if (_pendingMessages?.Length != 0)
            {
                _callback.OnOutputString(_pendingMessages.ToString());
                _pendingMessages = null;
            }

            await this.ExceptionManager.EnsureSettingsUpdated();

            if (_initialBreakArgs != null)
            {
                await CheckModules();
                _libraryLoaded.Clear();
                await HandleBreakModeEvent(_initialBreakArgs, BreakRequest.None);
                _initialBreakArgs = null;
            }
            else if (this.IsCoreDump)
            {
                // Set initial state of debug engine to stopped with emulated results
                this.OnStateChanged("stopped", await this.GenerateStoppedRecordResults());
            }
            else
            {
                bool attach = false;
                int attachPid = _launchOptions.ProcessId;
                if (attachPid != 0)
                {
                    attach = true;
                }

                if (!attach)
                {
                    switch (_launchOptions.LaunchCompleteCommand)
                    {
                        case LaunchCompleteCommand.ExecRun:
                            await MICommandFactory.ExecRun();
                            break;
                        case LaunchCompleteCommand.ExecContinue:
                            await MICommandFactory.ExecContinue();
                            break;
                        case LaunchCompleteCommand.None:
                            break;
                        default:
                            Debug.Fail("Not implemented enum code for LaunchCompleteCommand??");
                            throw new NotImplementedException();
                    }
                }

                FireDeviceAppLauncherResume();
            }
        }
예제 #50
0
        private async Task HandleBreakModeEvent(ResultEventArgs results)
        {
            string reason = results.Results.TryFindString("reason");
            int tid;
            if (!results.Results.Contains("thread-id"))
            {
                Results res = await MICommandFactory.ThreadInfo();
                tid = res.FindInt("id");
            }
            else
            {
                tid = results.Results.FindInt("thread-id");
            }

            ThreadCache.MarkDirty();
            MICommandFactory.DefineCurrentThread(tid);

            DebuggedThread thread = await ThreadCache.GetThread(tid);
            await ThreadCache.StackFrames(thread);  // prepopulate the break thread in the thread cache
            ThreadContext cxt = await ThreadCache.GetThreadContext(thread);
            ThreadCache.SendThreadEvents(this, null);   // make sure that new threads have been pushed to the UI

            //always delete breakpoints pending deletion on break mode
            //the flag tells us if we hit an existing breakpoint pending deletion that we need to continue

            await _breakpointManager.DeleteBreakpointsPendingDeletion();

            //delete varialbes that have been GC'd
            List<string> variablesToDelete = new List<string>();
            lock (VariablesToDelete)
            {
                foreach (var variable in VariablesToDelete)
                {
                    variablesToDelete.Add(variable);
                }
                VariablesToDelete.Clear();
            }

            foreach (var variable in variablesToDelete)
            {
                try
                {
                    await MICommandFactory.VarDelete(variable);
                }
                catch (MIException)
                {
                    //not much to do really, we're leaking MI debugger variables.
                    Debug.Fail("Failed to delete variable: " + variable + ". This is leaking memory in the MI Debugger.");
                }
            }

            if (String.IsNullOrWhiteSpace(reason) && !_bEntrypointHit)
            {
                // CLRDBG TODO: Try to verify this code path
                _bEntrypointHit = true;
                CmdContinueAsync();
                FireDeviceAppLauncherResume();
            }
            else if (reason == "breakpoint-hit")
            {
                string bkptno = results.Results.FindString("bkptno");
                ulong addr = cxt.pc ?? 0;
                AD7BoundBreakpoint bkpt = null;
                bool fContinue;
                TupleValue frame = results.Results.TryFind<TupleValue>("frame");
                bkpt = _breakpointManager.FindHitBreakpoint(bkptno, addr, frame, out fContinue); // use breakpoint number to resolve breakpoint
                if (bkpt != null)
                {
                    List<object> bplist = new List<object>();
                    bplist.Add(bkpt);
                    _callback.OnBreakpoint(thread, bplist.AsReadOnly());
                }
                else if (!_bEntrypointHit)
                {
                    _bEntrypointHit = true;
                    _callback.OnEntryPoint(thread);
                }
                else
                {
                    if (fContinue)
                    {
                        //we hit a bp pending deletion
                        //post the CmdContinueAsync operation so it does not happen until we have deleted all the pending deletes
                        CmdContinueAsync();
                    }
                    else
                    {
                        // not one of our breakpoints, so stop with a message
                        _callback.OnException(thread, "Unknown breakpoint", "", 0);
                    }
                }
            }
            else if (reason == "end-stepping-range" || reason == "function-finished")
            {
                _callback.OnStepComplete(thread);
            }
            else if (reason == "signal-received")
            {
                string name = results.Results.TryFindString("signal-name");
                if ((name == "SIG32") || (name == "SIG33"))
                {
                    // we are going to ignore these (Sigma) signals for now
                    CmdContinueAsync();
                }
                else if (MICommandFactory.IsAsyncBreakSignal(results.Results))
                {
                    _callback.OnAsyncBreakComplete(thread);
                }
                else
                {
                    uint code = 0;
                    string sigName = results.Results.TryFindString("signal-name");
                    code = results.Results.Contains("signal") ? results.Results.FindUint("signal") : 0;
                    if (String.IsNullOrEmpty(sigName) && code != 0 && EngineUtils.SignalMap.Instance.ContainsValue(code))
                    {
                        sigName = EngineUtils.SignalMap.Instance.First((p) => p.Value == code).Key;
                    }
                    else if (!String.IsNullOrEmpty(sigName) && code == 0 && EngineUtils.SignalMap.Instance.ContainsKey(sigName))
                    {
                        code = EngineUtils.SignalMap.Instance[sigName];
                    }
                    _callback.OnException(thread, sigName, results.Results.TryFindString("signal-meaning"), code);
                }
            }
            else if (reason == "exception-received")
            {
                string exceptionName = results.Results.TryFindString("exception-name");
                if (string.IsNullOrEmpty(exceptionName))
                    exceptionName = "Exception";

                string description = results.Results.FindString("exception");
                Guid? exceptionCategory;
                ExceptionBreakpointState state;
                MICommandFactory.DecodeExceptionReceivedProperties(results.Results, out exceptionCategory, out state);

                _callback.OnException(thread, exceptionName, description, 0, exceptionCategory, state);
            }
            else
            {
                Debug.Fail("Unknown stopping reason");
                _callback.OnException(thread, "Unknown", "Unknown stopping event", 0);
            }
        }
예제 #51
0
        public DebuggedProcess(bool bLaunched, LaunchOptions launchOptions, ISampleEngineCallback callback, WorkerThread worker, BreakpointManager bpman, AD7Engine engine, HostConfigurationStore configStore, HostWaitLoop waitLoop = null) : base(launchOptions, engine.Logger)
        {
            uint processExitCode = 0;
            _pendingMessages = new StringBuilder(400);
            _worker = worker;
            _breakpointManager = bpman;
            Engine = engine;
            _libraryLoaded = new List<string>();
            _loadOrder = 0;
            MICommandFactory = MICommandFactory.GetInstance(launchOptions.DebuggerMIMode, this);
            _waitDialog = (MICommandFactory.SupportsStopOnDynamicLibLoad() && launchOptions.WaitDynamicLibLoad) ? new HostWaitDialog(ResourceStrings.LoadingSymbolMessage, ResourceStrings.LoadingSymbolCaption) : null;
            Natvis = new Natvis.Natvis(this, launchOptions.ShowDisplayString);

            // we do NOT have real Win32 process IDs, so we use a guid
            AD_PROCESS_ID pid = new AD_PROCESS_ID();
            pid.ProcessIdType = (int)enum_AD_PROCESS_ID.AD_PROCESS_ID_GUID;
            pid.guidProcessId = Guid.NewGuid();
            this.Id = pid;

            SourceLineCache = new SourceLineCache(this);

            _callback = callback;
            _moduleList = new List<DebuggedModule>();
            ThreadCache = new ThreadCache(callback, this);
            Disassembly = new Disassembly(this);
            ExceptionManager = new ExceptionManager(MICommandFactory, _worker, _callback, configStore);

            VariablesToDelete = new List<string>();
            this.ActiveVariables = new List<IVariableInformation>();
            _fileTimestampWarnings = new HashSet<Tuple<string, string>>();

            OutputStringEvent += delegate (object o, string message)
            {
                // We can get messages before we have started the process
                // but we can't send them on until it is
                if (_connected)
                {
                    _callback.OnOutputString(message);
                }
                else
                {
                    _pendingMessages.Append(message);
                }
            };

            LibraryLoadEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;
                string file = results.Results.TryFindString("host-name");
                if (!string.IsNullOrEmpty(file) && MICommandFactory.SupportsStopOnDynamicLibLoad())
                {
                    _libraryLoaded.Add(file);
                    if (_waitDialog != null)
                    {
                        _waitDialog.ShowWaitDialog(file);
                    }
                }
                else if (this.MICommandFactory.Mode == MIMode.Clrdbg)
                {
                    string id = results.Results.FindString("id");
                    ulong baseAddr = results.Results.FindAddr("base-address");
                    uint size = results.Results.FindUint("size");
                    bool symbolsLoaded = results.Results.FindInt("symbols-loaded") != 0;
                    var module = new DebuggedModule(id, file, baseAddr, size, symbolsLoaded, string.Empty, _loadOrder++);
                    lock (_moduleList)
                    {
                        _moduleList.Add(module);
                    }
                    _callback.OnModuleLoad(module);
                }
                else if (!string.IsNullOrEmpty(file))
                {
                    string addr = results.Results.TryFindString("loaded_addr");
                    if (string.IsNullOrEmpty(addr) || addr == "-")
                    {
                        return; // identifies the exe, not a real load
                    }
                    // generate module 
                    string id = results.Results.TryFindString("name");
                    bool symsLoaded = true;
                    string symPath = null;
                    if (results.Results.Contains("symbols-path"))
                    {
                        symPath = results.Results.FindString("symbols-path");
                        if (string.IsNullOrEmpty(symPath))
                        {
                            symsLoaded = false;
                        }
                    }
                    else
                    {
                        symPath = file;
                    }
                    ulong loadAddr = results.Results.FindAddr("loaded_addr");

                    uint size = results.Results.FindUint("size");
                    if (String.IsNullOrEmpty(id))
                    {
                        id = file;
                    }
                    var module = FindModule(id);
                    if (module == null)
                    {
                        module = new DebuggedModule(id, file, loadAddr, size, symsLoaded, symPath, _loadOrder++);
                        lock (_moduleList)
                        {
                            _moduleList.Add(module);
                        }
                        _callback.OnModuleLoad(module);
                    }
                }
            };

            if (_launchOptions is LocalLaunchOptions)
            {
                LocalLaunchOptions localLaunchOptions = (LocalLaunchOptions)_launchOptions;

                if (!localLaunchOptions.IsValidMiDebuggerPath())
                {
                    throw new Exception(MICoreResources.Error_InvalidMiDebuggerPath);
                }

                if (PlatformUtilities.IsOSX() &&
                    localLaunchOptions.DebuggerMIMode != MIMode.Clrdbg &&
                    localLaunchOptions.DebuggerMIMode != MIMode.Lldb &&
                    !UnixUtilities.IsBinarySigned(localLaunchOptions.MIDebuggerPath))
                {
                    string message = String.Format(CultureInfo.CurrentCulture, ResourceStrings.Warning_DarwinDebuggerUnsigned, localLaunchOptions.MIDebuggerPath);
                    _callback.OnOutputMessage(new OutputMessage(
                        message + Environment.NewLine,
                        enum_MESSAGETYPE.MT_MESSAGEBOX,
                        OutputMessage.Severity.Warning));
                }

                ITransport localTransport = null;
                // For local Linux and OS X launch, use the local Unix transport which creates a new terminal and
                // uses fifos for debugger (e.g., gdb) communication.
                if (this.MICommandFactory.UseExternalConsoleForLocalLaunch(localLaunchOptions) &&
                    (PlatformUtilities.IsLinux() || (PlatformUtilities.IsOSX() && localLaunchOptions.DebuggerMIMode != MIMode.Lldb)))
                {
                    localTransport = new LocalUnixTerminalTransport();

                    // Only need to clear terminal for Linux and OS X local launch
                    _needTerminalReset = (localLaunchOptions.ProcessId == 0 && _launchOptions.DebuggerMIMode == MIMode.Gdb);
                }
                else
                {
                    localTransport = new LocalTransport();
                }

                if (localLaunchOptions.ShouldStartServer())
                {
                    this.Init(
                        new MICore.ClientServerTransport(
                            localTransport,
                            new ServerTransport(killOnClose: true, filterStdout: localLaunchOptions.FilterStdout, filterStderr: localLaunchOptions.FilterStderr)
                        ),
                        _launchOptions);
                }
                else
                {
                    this.Init(localTransport, _launchOptions);
                }

                // Only need to know the debugger pid on Linux and OS X local launch to detect whether
                // the debugger is closed. If the debugger is not running anymore, the response (^exit)
                // to the -gdb-exit command is faked to allow MIEngine to shut down.
                SetDebuggerPid(localTransport.DebuggerPid);
            }
            else if (_launchOptions is PipeLaunchOptions)
            {
                this.Init(new MICore.PipeTransport(), _launchOptions);
            }
            else if (_launchOptions is TcpLaunchOptions)
            {
                this.Init(new MICore.TcpTransport(), _launchOptions);
            }
            else if (_launchOptions is UnixShellPortLaunchOptions)
            {
                this.Init(new MICore.UnixShellPortTransport(), _launchOptions, waitLoop);
            }
            else
            {
                throw new ArgumentOutOfRangeException("LaunchInfo.options");
            }

            MIDebugCommandDispatcher.AddProcess(this);

            // When the debuggee exits, we need to exit the debugger
            ProcessExitEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                ResultEventArgs results = args as MICore.Debugger.ResultEventArgs;

                if (results.Results.Contains("exit-code"))
                {
                    // GDB sometimes returns exit codes, which don't fit into uint, like "030000000472".
                    // And we can't throw from here, because it crashes VS.
                    // Full exit code will still usually be reported in the Output window,
                    // but here let's return "uint.MaxValue" just to indicate that something went wrong.
                    if (!uint.TryParse(results.Results.FindString("exit-code"), out processExitCode))
                    {
                        processExitCode = uint.MaxValue;
                    }
                }

                // quit MI Debugger
                if (!this.IsClosed)
                {
                    _worker.PostOperation(CmdExitAsync);
                }
                else
                {
                    // If we are already closed, make sure that something sends program destroy
                    _callback.OnProcessExit(processExitCode);
                }

                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }
            };

            // When the debugger exits, we tell AD7 we are done
            DebuggerExitEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                // this is the last AD7 Event we can ever send
                // Also the transport is closed when this returns
                _callback.OnProcessExit(processExitCode);

                Dispose();
            };

            DebuggerAbortedEvent += delegate (object o, DebuggerAbortedEventArgs eventArgs)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                // The MI debugger process unexpectedly exited.
                _worker.PostOperation(() =>
                    {
                        _engineTelemetry.SendDebuggerAborted(MICommandFactory, GetLastSentCommandName(), eventArgs.ExitCode);

                        // If the MI Debugger exits before we get a resume call, we have no way of sending program destroy. So just let start debugging fail.
                        if (!_connected)
                        {
                            return;
                        }

                        _callback.OnError(string.Concat(eventArgs.Message, " ", ResourceStrings.DebuggingWillAbort));
                        _callback.OnProcessExit(uint.MaxValue);

                        Dispose();
                    });
            };

            ModuleLoadEvent += async delegate (object o, EventArgs args)
            {
                // NOTE: This is an async void method, so make sure exceptions are caught and somehow reported

                if (_needTerminalReset)
                {
                    _needTerminalReset = false;

                    // This is to work around a GDB bug of warning "Failed to set controlling terminal: Operation not permitted"
                    // Reset debuggee terminal after the first module load.
                    await ResetConsole();
                }

                if (this.MICommandFactory.SupportsStopOnDynamicLibLoad() && !_launchOptions.WaitDynamicLibLoad)
                {
                    await CmdAsync("-gdb-set stop-on-solib-events 0", ResultClass.None);
                }

                await this.EnsureModulesLoaded();


                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }
                if (MICommandFactory.SupportsStopOnDynamicLibLoad())
                {
                    // Do not continue if debugging core dump
                    if (!this.IsCoreDump)
                    {
                        CmdContinueAsync();
                    }
                }
            };

            // When we break we need to gather information
            BreakModeEvent += async delegate (object o, EventArgs args)
            {
                // NOTE: This is an async void method, so make sure exceptions are caught and somehow reported

                StoppingEventArgs results = args as MICore.Debugger.StoppingEventArgs;
                if (_waitDialog != null)
                {
                    _waitDialog.EndWaitDialog();
                }

                if (!this._connected)
                {
                    _initialBreakArgs = results;
                    return;
                }

                try
                {
                    await HandleBreakModeEvent(results, results.AsyncRequest);
                }
                catch (Exception e) when (ExceptionHelper.BeforeCatch(e, Logger, reportOnlyCorrupting: true))
                {
                    if (this.IsStopDebuggingInProgress)
                    {
                        return; // ignore exceptions after the process has exited
                    }

                    string exceptionDescription = EngineUtils.GetExceptionDescription(e);
                    string message = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_FailedToEnterBreakState, exceptionDescription);
                    _callback.OnError(message);

                    Terminate();
                }
            };

            ErrorEvent += delegate (object o, EventArgs args)
            {
                // NOTE: Exceptions leaked from this method may cause VS to crash, be careful

                ResultEventArgs result = (ResultEventArgs)args;
                _callback.OnError(result.Results.FindString("msg"));
            };

            ThreadCreatedEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs result = (ResultEventArgs)args;
                ThreadCache.ThreadCreatedEvent(result.Results.FindInt("id"), result.Results.TryFindString("group-id"));
                _childProcessHandler?.ThreadCreatedEvent(result.Results);
            };

            ThreadExitedEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs result = (ResultEventArgs)args;
                ThreadCache.ThreadExitedEvent(result.Results.FindInt("id"));
            };

            ThreadGroupExitedEvent += delegate (object o, EventArgs args)
            {
                ResultEventArgs result = (ResultEventArgs)args;
                ThreadCache.ThreadGroupExitedEvent(result.Results.FindString("id"));
            };

            MessageEvent += (object o, ResultEventArgs args) =>
            {
                OutputMessage outputMessage = DecodeOutputEvent(args.Results);
                if (outputMessage != null)
                {
                    _callback.OnOutputMessage(outputMessage);
                }
            };

            TelemetryEvent += (object o, ResultEventArgs args) =>
            {
                string eventName;
                KeyValuePair<string, object>[] properties;
                if (_engineTelemetry.DecodeTelemetryEvent(args.Results, out eventName, out properties))
                {
                    HostTelemetry.SendEvent(eventName, properties);
                }
            };

            BreakChangeEvent += _breakpointManager.BreakpointModified;
        }
예제 #52
0
        public async Task ResumeFromLaunch()
        {
            _connected = true;
            await this.ExceptionManager.EnsureSettingsUpdated();

            if (_initialBreakArgs != null)
            {
                await CheckModules();
                _libraryLoaded.Clear();
                await HandleBreakModeEvent(_initialBreakArgs);
                _initialBreakArgs = null;
            }
            else
            {
                switch (_launchOptions.LaunchCompleteCommand)
                {
                    case LaunchCompleteCommand.ExecRun:
                        await MICommandFactory.ExecRun();
                        break;
                    case LaunchCompleteCommand.ExecContinue:
                        await MICommandFactory.ExecContinue();
                        break;
                    case LaunchCompleteCommand.None:
                        break;
                    default:
                        Debug.Fail("Not implemented enum code for LaunchCompleteCommand??");
                        throw new NotImplementedException();
                }

                FireDeviceAppLauncherResume();
            }
        }
예제 #53
0
 private void ExportJobCreated(object sender, ResultEventArgs<IExportJob> e)
 {
     //todo: complete this
 }
예제 #54
0
 public override void ProcessResults(object sender, ResultEventArgs results)
 {
     var result = GetResultOfType<ChatResult>(results);
     if (result != null) { }
 }
예제 #55
0
 /// <summary>
 /// Callback for when Listings data has been received
 /// </summary>
 /// <param name="sender">event sender</param>
 /// <param name="e">event params</param>
 private void FrontFeaturedListingsReceived(object sender, ResultEventArgs<Listings> e)
 {
     // put it onto the Ui thread
     this.dispatcher.Invoke(
         DispatcherPriority.Normal,
         new ResultsReceivedHandler<Listings>(this.FrontFeaturedListingsReceivedSync),
         e);
 }
 private void OnProcessComplated(ResultEventArgs<Dictionary<string, List<WFSFeatureDescription>>> result)
 {
     if (ProcessCompleted != null)
     {
         ProcessCompleted(this, result);
     }
 }
예제 #57
0
        private void Form_OnLoadData(object sender, ResultEventArgs e)
        {
            this._form = new MainForm();

            if (this._importers.Count > 1)
            {
                var ttl = "Data Source";
                var msg = "Select the source from which to copy data.";
                var frm = new SelectForm(ttl, msg, this._importers.Keys.Select(x => x.ToString()));

                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                ControllerType type;
                if (Enum.TryParse(frm.SelectedItems[0], out type))
                {
                    this._selectedImporter = this._importers[type];
                }
            }

            if (this._selectedImporter == null)
            {
                return;
            }

            try
            {
                switch (this._selectedImporter.Type)
                {
                case ControllerType.EXCEL:
                    this._selectedImporter.MultiplePages += this.OnMultipleExcelPages;
                    OpenFileDialog dialog = new OpenFileDialog {
                        Filter = "Excel Files|*.xls;*.xlsx;*.xlsm"
                    };
                    if (dialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    this._source = dialog.FileName;
                    break;

                //case ControllerType.JSON:
                //    break;
                //case ControllerType.SQL:
                //    break;
                default:
                    throw new ArgumentOutOfRangeException();
                }

                //e.Result = this._controller.ImportData(this._selectedImporter, this._source);
            }
            finally
            {
                switch (this._selectedImporter.Type)
                {
                case ControllerType.EXCEL:
                    this._selectedImporter.MultiplePages -= this.OnMultipleExcelPages;
                    break;

                //case ControllerType.JSON:
                //    break;
                //case ControllerType.SQL:
                //    break;
                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
예제 #58
0
        private void sourceStreamDataAvailable(object sender, WaveInEventArgs e)
        {
            string path = outputPath + "wavsam" + nFiles + ".wav";
            writer = new WaveFileWriter(path, waveFormat);
            writer.Write(e.Buffer, 0, e.Buffer.Length);
            writer.Flush();
            writer.Close();
            nFiles++;

            Process process = new Process();
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.FileName = "praatcon.exe";
            String male;
            if (isMale) male = "yes"; else male = "no";
            process.StartInfo.Arguments = "extract_measures.praat " + path + " " + male;
               // process.StartInfo.RedirectStandardOutput = true;

            process.Start();

            process.WaitForExit();

            ResultEventArgs args = new ResultEventArgs();
              //      args.text = output;
            OnResults(args);
               // args.nWords = err.Length;
        }
 private static void BackendClient_ResultReceived(object sender, ResultEventArgs e)
 {
     _preCheckErrorMessage = e.Message;
     _logger.WriteDebug($"Received result: {e.Message}");
     _logger.WriteTrace($"Received result: {e.Message}");
 }
예제 #60
0
        /// <summary>
        /// Test the wiggle room value
        /// </summary>
        /// <param name="wiggle">the wiggle room</param>
        /// <param name="completedEvent">the event to fire on error</param>
        /// <returns>true if the value is in range</returns>
        private bool TestWiggle(int wiggle, EventHandler<ResultEventArgs<Listings>> completedEvent)
        {
            if ((wiggle < 0) || (wiggle > MaxWiggle))
            {
                ResultEventArgs<Listings> errorResult = new ResultEventArgs<Listings>(
                    null,
                    new ResultStatus("Wiggle must be in the range 0 to 15", null));
                ServiceHelper.TestSendEvent(completedEvent, this, errorResult);
                return false;
            }

            return true;
        }