/// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            SVsServiceProvider serviceProvider = null;

            try
            {
                DTE dte = CoreUtility.ServiceProvider.GetService(typeof(DTE)) as DTE;

                if (dte == null)
                {
                    throw new NotSupportedException("Error with extension");
                }

                string username = SingleComment.userNameRegistry();

                if (username == null)
                {
                    username = "******";
                }

                string top     = String.Format("/// CS - By {0}, {1}, {2}\n", DateTime.Now, username, System.IO.Path.GetFileNameWithoutExtension(dte.Solution.FullName));
                string bottom  = String.Format("CE - By {0}, {1}, {2}", DateTime.Now, username, System.IO.Path.GetFileNameWithoutExtension(dte.Solution.FullName));
                string comment = top + bottom;

                (dte.ActiveDocument.Selection as EnvDTE.TextSelection).Text = comment;
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                // TODO: Do your magic for your add-in
                DirectoryInfo dirInfo = Directory.GetParent(this.Configuration.SSRSReportingLocation);

                string logPath = Path.Combine(dirInfo.FullName, "LogFiles");

                if (Directory.Exists(logPath))
                {
                    DirectoryInfo dirInfoLogs = new DirectoryInfo(logPath);

                    var latestFile = dirInfoLogs.GetFiles()
                                     .OrderByDescending(f => f.LastWriteTime)
                                     .Where(f => f.Name.StartsWith("ReportServerService__"))
                                     .First();
                    if (latestFile != null)
                    {
                        Process.Start(latestFile.FullName);
                    }
                }
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #3
0
        static void AddinManagerAddinUnloaded(object sender, AddinEventArgs args)
        {
            Addin addin = AddinFromID(args.AddinId);

            OnStateChanged(addin, false);
            Log <PluginManager> .Info("Unloaded \"{0}\".", addin.Name);
        }
예제 #4
0
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                DadJoke           joke  = DadJoke.construct(Request.dadJoke());
                MotivationalQuote quote = MotivationalQuote.construct(Request.motivationalQuote());

                string message = string.Empty;

                if (joke.Id != null)
                {
                    //message += string.Format("Dad joke:\n{0}", joke.Joke);
                    message += joke.Joke;
                }

                //if (quote.Id != 0)
                //{
                //    message += "\n\n";
                //    message += string.Format("Motivational quote:\n{0}{1}", HttpUtility.HtmlDecode(quote.Content), quote.Title.ToUpper());
                //}

                CoreUtility.DisplayInfo(message);
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
 /// <summary>
 /// Called when user clicks on the add-in menu
 /// </summary>
 /// <param name="e">The context of the VS tools and metadata</param>
 public override void OnClick(AddinEventArgs e)
 {
     this.ReferencesAdded = new List <string>();
     try
     {
         bool referenceAdded;
         do
         {
             // Check fior errors and then add the module reference
             referenceAdded = this.CheckErrorsAndAddReference();
             // now compile the project and this will give the next set of missing reference
             this.BuildSolution();
         } while (referenceAdded); // Keep doing this until errors found are similar
     }
     catch (Exception ex)
     {
         CoreUtility.HandleExceptionWithErrorMessage(ex);
     }
     if (ReferencesAdded.Count > 0)
     {
         this.ReferencesAdded.Add("Rebuild the project to check further errors");
         // show the list of references added
         System.Windows.Forms.MessageBox.Show(
             string.Join(Environment.NewLine, this.ReferencesAdded),
             "Module references added");
     }
 }
예제 #6
0
 void OnAddinLoaded(object sender, AddinEventArgs args)
 {
     if (args.AddinId == "Banshee.NotificationArea" || args.AddinId == "Banshee.AppIndicator")
     {
         Log.Debug("SoundMenu conflicts with " + args.AddinId + ", disabling SoundMenu");
         AddinManager.Registry.GetAddin("Banshee.SoundMenu").Enabled = false;
     }
 }
예제 #7
0
 void OnAddinLoaded(object sender, AddinEventArgs args)
 {
     if (args.AddinId == "Banshee.NotificationArea")
     {
         Log.Debug("ApplicationIndicator conflicts with NotificationArea, disabling ApplicationIndicator");
         AddinManager.Registry.GetAddin("Banshee.AppIndicator").Enabled = false;
     }
 }
예제 #8
0
        static void OnLoad(object s, AddinEventArgs args)
        {
            Counters.AddinsLoaded.Inc(1, "Add-in loaded: " + args.AddinId, new Dictionary <string, object> {
                { "AddinId", args.AddinId },
                { "LoadTrace", Environment.StackTrace },
            });
#if DEBUG
            LoggingService.LogDebug("Add-in loaded: {0}: {1}", args.AddinId, Environment.StackTrace);
#endif
        }
예제 #9
0
 /// <summary>
 /// Called when user clicks on the add-in menu
 /// </summary>
 /// <param name="e">The context of the VS tools and metadata</param>
 public override void OnClick(AddinEventArgs e)
 {
     try
     {
         // TODO: Do your magic for your add-in
     }
     catch (Exception ex)
     {
         CoreUtility.HandleExceptionWithErrorMessage(ex);
     }
 }
예제 #10
0
 /// <summary>
 ///     Called when user clicks on the add-in menu
 /// </summary>
 /// <param name="e">The context of the VS tools and metadata</param>
 public override void OnClick(AddinEventArgs e)
 {
     try
     {
         var paramsWin = new Parameters();
         paramsWin.ShowDialog();
     }
     catch (Exception ex)
     {
         CoreUtility.HandleExceptionWithErrorMessage(ex);
     }
 }
예제 #11
0
 /// <summary>
 /// Called when user clicks on the add-in menu
 /// </summary>
 /// <param name="e">The context of the VS tools and metadata</param>
 public override void OnClick(AddinEventArgs e)
 {
     try
     {
         // TODO: Do your magic for your add-in
         // Currently this addin works only for one element at time.
         // Next feature would be generate all labels to all project elements at once.
     }
     catch (Exception ex)
     {
         CoreUtility.HandleExceptionWithErrorMessage(ex);
     }
 }
예제 #12
0
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                // Find project to work with
                VSProjectNode project = LocalUtils.GetActiveProject();
                // An alternative way is calling ProjectHelper.GetProjectDetails(), but it's not consistent
                // with how projectService.AddElementToActiveProject() determines the active project.
                // ProjectHelper return the startup project, which doens't have to be the active project.

                if (project == null)
                {
                    throw new InvalidOperationException("No project selected.");
                }

                // Create a new class
                AxClass axClass = new AxClass()
                {
                    Name = "MyNewClass",
                    IsAbstract = true // Set a property for demonstration
                };

                // Find metamodel service needed below

                // Find current model
                //ModelInfo model = metaModelService.GetModel(ProjectHelper.GetProjectDetails().Model);
                ModelInfo model = project.GetProjectsModelInfo();

                // Prepare information needed for saving
                ModelSaveInfo saveInfo = new ModelSaveInfo
                {
                    Id = model.Id,
                    Layer = model.Layer
                };

                // Create class in the right model
                var metaModelProviders = ServiceLocator.GetService(typeof(IMetaModelProviders)) as IMetaModelProviders;
                var metaModelService = metaModelProviders.CurrentMetaModelService;
                metaModelService.CreateClass(axClass, saveInfo);

                // Add the class to the active project
                var projectService = ServiceLocator.GetService(typeof(IDynamicsProjectService)) as IDynamicsProjectService;
                projectService.AddElementToActiveProject(axClass);

            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #13
0
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                // Find project to work with
                VSProjectNode project = LocalUtils.GetActiveProject();
                // An alternative way is calling ProjectHelper.GetProjectDetails(), but it's not consistent
                // with how projectService.AddElementToActiveProject() determines the active project.
                // ProjectHelper return the startup project, which doens't have to be the active project.

                if (project == null)
                {
                    throw new InvalidOperationException("No project selected.");
                }

                // Create a new class
                AxClass axClass = new AxClass()
                {
                    Name       = "MyNewClass",
                    IsAbstract = true // Set a property for demonstration
                };

                // Find metamodel service needed below


                // Find current model
                //ModelInfo model = metaModelService.GetModel(ProjectHelper.GetProjectDetails().Model);
                ModelInfo model = project.GetProjectsModelInfo();

                // Prepare information needed for saving
                ModelSaveInfo saveInfo = new ModelSaveInfo
                {
                    Id    = model.Id,
                    Layer = model.Layer
                };

                // Create class in the right model
                var metaModelProviders = ServiceLocator.GetService(typeof(IMetaModelProviders)) as IMetaModelProviders;
                var metaModelService   = metaModelProviders.CurrentMetaModelService;
                metaModelService.CreateClass(axClass, saveInfo);

                // Add the class to the active project
                var projectService = ServiceLocator.GetService(typeof(IDynamicsProjectService)) as IDynamicsProjectService;
                projectService.AddElementToActiveProject(axClass);
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #14
0
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                TableBuilderDialog dialog = new TableBuilderDialog();
                TableBuilderParms  parms  = new TableBuilderParms();

                dialog.SetParameters(parms);
                dialog.Show();
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #15
0
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                EnumCreatorDialog dialog = new EnumCreatorDialog();
                EnumCreatorParms  parms  = new EnumCreatorParms();

                dialog.SetParameters(parms);
                DialogResult formRes = dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            if (this.IsProjectSelected())
            {
                var templateFolderPath = CreateFromTemplateMainMenuAddIn.GetTemplatePath();
                if (String.IsNullOrEmpty(templateFolderPath))
                {
                    return;
                }

                //var tempalteFolders = this.GetTemplateFolders(templateFolderPath);
                CreateFromTemplateForm createFromTemplateForm = new CreateFromTemplateForm();
                createFromTemplateForm.ShowDialog();
            }
        }
예제 #17
0
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                SnippetsParms  snippetsParms  = new SnippetsParms();
                RunBaseBuilder runBaseBuilder = new RunBaseBuilder();

                runBaseBuilder.InitDialogParms(snippetsParms);

                SnippetsDialog dialog = new SnippetsDialog();
                dialog.SetParameters(snippetsParms);
                dialog.Show();
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            try
            {
                // Read the model Settings
                var modelSettings = FetchSettings.FindOrCreateSettings();

                // Send the model settings to the UI
                ModelSettingsUI modelSettingsUI = new ModelSettingsUI();
                var             dialogResult    = modelSettingsUI.ShowDialog();
                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                }
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #19
0
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            LabelCreatorForm labelCreatorForm = null;

            try
            {
                //// Read the model Settings
                //var modelSettings = FetchSettings.FindOrCreateSettings();

                //// Send the model settings to the UI
                //ModelSettingsUI modelSettingsUI = new ModelSettingsUI();
                //var dialogResult = modelSettingsUI.ShowDialog();
                //if (dialogResult == System.Windows.Forms.DialogResult.OK)
                //{

                //}
                labelCreatorForm = new LabelCreatorForm();
                labelCreatorForm.Show();
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #20
0
 static void OnUnload(object s, AddinEventArgs args)
 {
     Counters.AddinsLoaded.Dec("Add-in unloaded: " + args.AddinId);
 }
예제 #21
0
 static void OnLoad(object s, AddinEventArgs args)
 {
     Counters.AddinsLoaded.Inc("Add-in loaded: " + args.AddinId, new Dictionary <string, string> {
         { "AddinId", args.AddinId }
     });
 }
예제 #22
0
 private static void OnLoad(object s, AddinEventArgs args)
 {
     LogConfig.Logger.Info((object)("Add-in loaded: " + args.AddinId));
 }
예제 #23
0
 void OnUnload(object s, AddinEventArgs args)
 {
     Console.WriteLine("Add-in unloaded: " + args.AddinId);
 }
예제 #24
0
        static void OnAssembliesLoaded(object s, AddinEventArgs args)
        {
#if DEBUG
            LoggingService.LogDebug("Add-in assemblies loaded: {0}: {1}", args.AddinId, Environment.StackTrace);
#endif
        }
예제 #25
0
 private static void OnUnload(object s, AddinEventArgs args)
 {
 }
예제 #26
0
 private void on_addinloaded_(object sender, AddinEventArgs args)
 {
     log.Info("[PLUGINS]: Plugin Loaded: " + args.AddinId);
 }
예제 #27
0
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            FormMain formMain  = new FormMain(this.MetaModelService.GetModelNames().ToList <string>());
            string   modelName = string.Empty;

            if (formMain.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            modelName = formMain.getModelName();

            if (modelName == string.Empty)
            {
                throw new Exception("Model name cannot be empty.");
            }

            try
            {
                Metadata.MetaModel.AxDataEntityViewExtension dataEntityExtension;

                List <string> entities = this.MetadataProvider.DataEntityViewExtensions.ListObjectsForModel(modelName).ToList <string>().Where <string>(x => x.Contains("DimensionCombinationEntity") || x.Contains("DimensionSetEntity")).ToList <string>();

                string updatedDataEntities = string.Empty;
                string names = string.Empty;

                foreach (var extensionName in entities)
                {
                    bool updated = false;

                    dataEntityExtension = this.MetadataProvider.DataEntityViewExtensions.Read(extensionName);

                    foreach (var field in dataEntityExtension.Fields)
                    {
                        string relatedDataEntity;
                        string nameL = field.Name.ToLower().Replace(" ", "");

                        // List based on https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/financial/add-dimensions-excel-templates
                        #region Related entity names
                        switch (nameL)
                        {
                        case "agreement":
                        case "agreements":
                            relatedDataEntity = "DimAttributeAgreementHeaderExt_RUEntity";
                            break;

                        case "bankaccount":
                        case "bankaccounts":
                            relatedDataEntity = "DimAttributeBankAccountTableEntity";
                            break;

                        case "businessunit":
                        case "businessunits":
                            relatedDataEntity = "DimAttributeOMBusinessUnitEntity";
                            break;

                        case "campaign":
                        case "campaigns":
                            relatedDataEntity = "DimAttributeSmmCampaignTableEntity";
                            break;

                        case "cashaccount":
                        case "cashaccounts":
                            relatedDataEntity = "DimAttributeRCashTable_RUEntity";
                            break;

                        case "costcenter":
                        case "costcenters":
                            relatedDataEntity = "DimAttributeOMCostCenterEntity";
                            break;

                        case "customergroup":
                        case "customergroups":
                            relatedDataEntity = "DimAttributeCustGroupEntity";
                            break;

                        case "customer":
                        case "customers":
                            relatedDataEntity = "DimAttributeCustTableEntity";
                            break;

                        case "deferral":
                        case "deferrals":
                            relatedDataEntity = "DimAttributeRDeferralsTable_RUEntity";
                            break;

                        case "department":
                        case "departments":
                            relatedDataEntity = "DimAttributeOMDepartmentEntity";
                            break;

                        case "expenseandincomecode":
                        case "expenseandincomecodes":
                            relatedDataEntity = "DimAttributeRTax25ProfitTable_RUEntity";
                            break;

                        case "expensepurpose":
                        case "expensepurposes":
                            relatedDataEntity = "DimAttributeTrvTravelTxtEntity";
                            break;

                        case "fiscalestablishment":
                        case "fiscalestablishments":
                            relatedDataEntity = "DimAttributeFiscalEstablishment_BREntity";
                            break;

                        case "fixedassetgroup":
                        case "fixedassetgroups":
                            relatedDataEntity = "DimAttributeAssetGroupEntity";
                            break;

                        case "fixedasset":
                        case "fixedassets":
                            relatedDataEntity = "DimAttributeAssetTableEntity";
                            break;

                        case "fund":
                        case "funds":
                            relatedDataEntity = "DimAttributeLedgerFund_PSN";
                            break;

                        case "itemgroup":
                        case "itemgroups":
                            relatedDataEntity = "DimAttributeInventItemGroupEntity";
                            break;

                        case "item":
                        case "items":
                            relatedDataEntity = "DimAttributeInventTableEntity";
                            break;

                        case "job":
                        case "jobs":
                            relatedDataEntity = "DimAttributeHcmJobEntity";
                            break;

                        case "legalentity":
                        case "legalentities":
                            relatedDataEntity = "DimAttributeCompanyInfoEntity";
                            break;

                        case "posregister":
                        case "posregisters":
                            relatedDataEntity = "DimAttributeRetailTerminalEntity";
                            break;

                        case "position":
                        case "positions":
                            relatedDataEntity = "DimAttributeHcmPositionEntity";
                            break;

                        case "projectcontract":
                        case "projectcontracts":
                            relatedDataEntity = "DimAttributeProjInvoiceTableEntity";
                            break;

                        case "projectgroup":
                        case "projectgroups":
                            relatedDataEntity = "DimAttributeProjGroupEntity";
                            break;

                        case "project":
                        case "projects":
                            relatedDataEntity = "DimAttributeProjTableEntity";
                            break;

                        case "prospect":
                        case "prospects":
                            relatedDataEntity = "DimAttributeSmmBusRelTableEntity";
                            break;

                        case "resourcegroup":
                        case "resourcegroups":
                            relatedDataEntity = "DimAttributeWrkCtrResourceGroupEntity";
                            break;

                        case "resource":
                        case "resources":
                            relatedDataEntity = "DimAttributeWrkCtrTableEntity";
                            break;

                        case "store":
                        case "stores":
                            relatedDataEntity = "DimAttributeRetailStoreEntity";
                            break;

                        case "valuestream":
                        case "valuestreams":
                            relatedDataEntity = "DimAttributeOMValueStreamEntity";
                            break;

                        case "vendorgroup":
                        case "vendorgroups":
                            relatedDataEntity = "DimAttributeVendGroupEntity";
                            break;

                        case "vendor":
                        case "vendors":
                            relatedDataEntity = "DimAttributeVendTableEntity";
                            break;

                        case "worker":
                        case "workers":
                            relatedDataEntity = "DimAttributeHcmWorkerEntity";
                            break;

                        default:
                            relatedDataEntity = "DimAttributeFinancialTagEntity";
                            break;
                        }
                        #endregion

                        var relations = dataEntityExtension.Relations;

                        if (relations.Where <Metadata.MetaModel.AxDataEntityViewRelation>(x => x.RelatedDataEntity == relatedDataEntity).Count <Metadata.MetaModel.AxDataEntityViewRelation>() == 0)
                        {
                            Metadata.MetaModel.AxDataEntityViewRelation dataEntityViewRelation = new Metadata.MetaModel.AxDataEntityViewRelation();
                            Metadata.MetaModel.AxDataEntityViewRelationConstraintField dataEntityViewRelationConstraintField = new Metadata.MetaModel.AxDataEntityViewRelationConstraintField();

                            dataEntityViewRelation.RelatedDataEntity = relatedDataEntity;
                            dataEntityViewRelation.Validate          = Metadata.Core.MetaModel.NoYes.No;
                            dataEntityViewRelation.Cardinality       = Metadata.Core.MetaModel.Cardinality.ZeroMore;
                            dataEntityViewRelation.Name = field.Name;
                            dataEntityViewRelation.RelatedDataEntityCardinality = Metadata.Core.MetaModel.RelatedTableCardinality.ZeroOne;
                            dataEntityViewRelation.RelatedDataEntityRole        = $"{Guid.NewGuid().ToString("N")}";
                            dataEntityViewRelation.Role = $"{Guid.NewGuid().ToString("N")}";

                            dataEntityViewRelationConstraintField.Name         = $"{field.Name}Constraint";
                            dataEntityViewRelationConstraintField.Field        = field.Name;
                            dataEntityViewRelationConstraintField.RelatedField = "Value";

                            dataEntityViewRelation.Constraints.Add(dataEntityViewRelationConstraintField);
                            dataEntityExtension.Relations.Add(dataEntityViewRelation);

                            updated = true;
                        }
                    }

                    if (updated)
                    {
                        Metadata.MetaModel.ModelSaveInfo modelSaveInfo = new Metadata.MetaModel.ModelSaveInfo(this.MetadataProvider.DataEntityViewExtensions.GetModelInfo(extensionName).FirstOrDefault());
                        this.MetadataProvider.DataEntityViewExtensions.Update(dataEntityExtension, modelSaveInfo);

                        updatedDataEntities += $"* {extensionName}\n";
                    }
                }

                if (entities.Count == 0)
                {
                    throw new Exception($"No entity extension has been found in {modelName} model for DimensionCombinationEntity and/or DimensionSetEntity. Did you execute \"Add financial dimensions for OData in advance?\" ");
                }

                if (updatedDataEntities != string.Empty)
                {
                    CoreUtility.DisplayInfo($"Following data entities extensions have been updated:\n{updatedDataEntities}");
                }
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #28
0
 private static void AddinManager_AddinLoaded(object sender, AddinEventArgs args)
 {
     Logger.WriteEvent("Addin loaded: {0}", args.AddinId);
 }
예제 #29
0
        /// <summary>
        /// Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinEventArgs e)
        {
            string aosServicePath = string.Empty;
            string webConfigPath  = string.Empty;

            string resource = string.Empty;
            string clientId = string.Empty;
            string tenant   = string.Empty;

            try
            {
                if (!Directory.Exists(AddinResources.AOSServicePath))
                {
                    throw new Exception($"Directory '{AddinResources.AOSServicePath}' does not exist.");
                }

                webConfigPath = $"{AddinResources.AOSServicePath}web.config";

                //webConfigPath = VirtualPathUtility.RemoveTrailingSlash(webConfigPath);

                if (!File.Exists(webConfigPath))
                {
                    throw new Exception($"File '{webConfigPath}' does not exist.");
                }

                var map = new ExeConfigurationFileMap {
                    ExeConfigFilename = webConfigPath
                };
                var configFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

                resource = configFile.AppSettings.Settings["Infrastructure.HostUrl"].Value;
                clientId = configFile.AppSettings.Settings["Aad.TrustedServiceAppIds"].Value;
                tenant   = configFile.AppSettings.Settings["Aad.AADTenantId"].Value;

                if (resource == string.Empty ||
                    clientId == string.Empty ||
                    tenant == string.Empty)
                {
                    throw new Exception($"Missing KeyValue values.");
                }

                ClientConfiguration clientConfiguration = new ClientConfiguration()
                {
                    UriString = resource,
                    UserName  = "******",
                    Password  = "******",
                    ActiveDirectoryResource        = resource.TrimEnd('/'),
                    ActiveDirectoryTenant          = $"https://login.windows.net/{tenant}/wsfed",
                    ActiveDirectoryClientAppId     = clientId,
                    ActiveDirectoryClientAppSecret = "",
                    TLSVersion = ""
                };

                var header = OAuthHelper.GetAuthenticationHeader(clientConfiguration);

                CoreUtility.DisplayInfo(header.ToString());
            }
            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }
예제 #30
0
 private void Addin_OnLoaded(object sender, AddinEventArgs args)
 {
     Console.WriteLine($"Addin_OnLoaded: {args.AddinId}");
 }