コード例 #1
0
        private void AddWebResourceToForms()
        {
            WorkAsync(new WorkAsyncInfo
            {
                Message = "Adding Application Insights Web Resources to Forms...",
                Work    = (w, e) =>
                {
                    // Get checked rows
                    var checkedRows = from DataGridViewRow r in dgvForms.Rows
                                      where Convert.ToBoolean(r.Cells[0].Value) == true
                                      select r;

                    AppInsightsConfigs config          = new AppInsightsConfigs();
                    config.disablePageviewTracking     = cboxPageView.Checked;
                    config.disablePageLoadTimeTracking = cboxPageLoad.Checked;
                    config.disableExceptionTracking    = cboxException.Checked;
                    config.disableAjaxTracking         = cboxAjax.Checked;
                    config.disableTraceTracking        = cboxTrace.Checked;
                    config.disableMetricTracking       = cboxMetrics.Checked;
                    config.disableDependencyTracking   = cboxDependency.Checked;
                    config.disableEventTracking        = cboxEvents.Checked;

                    // Add web resource to checked rows
                    foreach (var row in checkedRows)
                    {
                        var formId     = (Guid)row.Cells["FormId"].Value;
                        var formEntity = _formsCache.FirstOrDefault(f => f.Id == formId);

                        var formXml = formEntity.GetAttributeValue <string>("formxml");

                        MetadataHelper.AddJavascriptLibraryToForm(Service, formId, formXml, txtCreateWrSchemaName.Text, lblCreateSolutionPrefix.Text, config);
                    }
                },
                PostWorkCallBack = (args) =>
                {
                    if (args.Error != null)
                    {
                        MessageBox.Show(args.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        PublishChanges();
                    }
                }
            });
        }