예제 #1
0
        public async Task Add_TestServerExtension_When_Not_Exists_Test()
        {
            string testExtensionId = $"{nameof(TestServerExtension)}";

            using IApiClient adapter = new ApiClient(ApiEnvironment.Partner, _restApiKey);

            List <PackageModel> packages = await adapter.PackageService.GetAllPackages();

            PackageModel testPackage = packages.FirstOrDefault(p => p.FileName == TestPackageFilename);

            Assert.IsNotNull(testPackage);

            ExtensionModel testExtension = await adapter.ExtensionService.GetExtension(testExtensionId);

            if (testExtension == null)
            {
                Console.WriteLine($@"No extension {testExtensionId} exists, creating new ...");

                testExtension = await adapter.ExtensionService.AddExtension(new ExtensionCreationModel
                {
                    ExtensionId   = testExtensionId,
                    AssemblyName  = TestExtensionAssemblyName,
                    AssemblyType  = $"{typeof(TestServerExtension).FullName}",
                    ExtensionType = $"ServerExtension",
                    PackageId     = testPackage.Id,
                });
            }

            Assert.IsNotNull(testExtension);

            Console.WriteLine($@"Extension {testExtension.ExtensionId} created.");
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of ExtensionViewModel.
        /// </summary>
        public ExtensionViewModel()
        {
            _extensionModel = (App.Current as App).ExtensionModel;
            _extensionModel.ExtensionLoaded +=
                (sender, e) =>
            {
                CurrentExtension = e.Extension;
            };
            SetCurrentPageLinkCommand           = new SignalCommand();
            SetCurrentPageLinkCommand.Executed += (sender, e) =>
            {
                if ((e.Parameter != null) && (e.Parameter is PageLink))
                {
                    CurrentPageLink = e.Parameter as PageLink;
                }
            };

            SetCurrentExtensionCommand           = new SignalCommand();
            SetCurrentExtensionCommand.Executed += (sender, e) =>
            {
                if ((e.Parameter != null) && (e.Parameter is ExtensionLink))
                {
                    var link = e.Parameter as ExtensionLink;
                    CheckExtension(link);
                    if (link.Extension != null)     // may be null because of async loading (in this case, see _extensionModel.ExtensionLoaded event)
                    {
                        CurrentExtension = link.Extension;
                    }
                }
            };
        }
예제 #3
0
    public void SelectReport (TReportData reportData)
    {
      if (reportData.NotNull ()) {
        Distorted = reportData.Distorted;

        DistortedVisibility = Distorted ? Visibility.Visible : Visibility.Collapsed;
        IsEnabledApply = Distorted ? false : string.IsNullOrEmpty (Name.Trim ()).IsFalse ();

        ExtensionModel.SelectReport (reportData);
      }
    }
예제 #4
0
        //
        // GET: /Subscribe/

        public ActionResult Index(String id)
        {
            List <Extension> pt = null;

            ExtensionModel ptm = new ExtensionModel();

            pt = ptm.getSubscribeInfo(id);


            return(View(pt));
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of MainViewModel.
 /// </summary>
 public MainViewModel()
 {
     _model = new ExtensionModel();
     SetCurrentPageInfoCommand           = new SignalCommand();
     SetCurrentPageInfoCommand.Executed += (sender, e) =>
     {
         if ((e.Parameter != null) && (e.Parameter is PageInfo))
         {
             CurrentPageInfo = e.Parameter as PageInfo;
         }
     };
 }
예제 #6
0
    public void RequestModel (TEntityAction action)
    {
      if (action.NotNull ()) {
        ComponentModel.RequestModel (action);
        ExtensionModel.RequestModel (action);

        action.Id = Id;
        action.ModelAction.ComponentInfoModel.Id = Id;

        action.ModelAction.ComponentStatusModel.Id = Id;
        action.ModelAction.ComponentStatusModel.Busy = IsBusy;
      }
    }
예제 #7
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Host.Settings.EnableFrameRateCounter = true;
            // Host.Settings.EnableRedrawRegions = true;
            // Host.Settings.MaxFrameRate = 60;

            // Host.Settings.EnableCacheVisualization = true;

            var cultureinfo = IsolatedStorageHelper.LoadCultureSetting();

            if (cultureinfo != Thread.CurrentThread.CurrentCulture)
            {
                Thread.CurrentThread.CurrentCulture   = cultureinfo;
                Thread.CurrentThread.CurrentUICulture = cultureinfo;
            }

            //ParametersHelper.LoadInitParametersFrom(e.InitParams);
            //string uiCulture = ParametersHelper.ReadParameterValue("uiculture");
            //if (!String.IsNullOrEmpty(uiCulture)
            //    && !uiCulture.Equals(Thread.CurrentThread.CurrentUICulture.Name))
            //{
            //    var cultureinfo = new CultureInfo(uiCulture);
            //    Thread.CurrentThread.CurrentCulture = cultureinfo;
            //    Thread.CurrentThread.CurrentUICulture = cultureinfo;
            //}

            ExtensionModel = new ExtensionModel();
            ExtensionModel.ExtensionLinksLoaded +=
                (sender1, e1) =>
            {
                this.RootVisual = new View.MainPage();
            };
            ExtensionModel.LoadExtensionLinks(15); // timeout 15 s
            this.InstallStateChanged +=
                (sender1, e1) =>
            {
                switch (this.InstallState)
                {
                case System.Windows.InstallState.Installing:
                    ExtensionModel.InstallExtensionFiles();
                    break;

                case System.Windows.InstallState.NotInstalled:
                    ExtensionModel.UninstallExtensionFiles();
                    break;
                }
            };
        }
예제 #8
0
    public void SelectModel (TEntityAction action)
    {
      if (action.NotNull ()) {
        // DO NOT CHANGE THIS ORDER
        ExtensionModel.SelectModel (action);
        ComponentModel.SelectModel (action);

        IsBusy = action.ModelAction.ComponentStatusModel.Busy;

        BusyVisibility = IsBusy ? Visibility.Visible : Visibility.Collapsed;
        IsComponentModelEnabled = IsBusy.IsFalse ();

        Id = action.Id;

        IsEnabledApply = string.IsNullOrEmpty (Name.Trim ()).IsFalse ();
        IsEnabledCancel = Id.NotEmpty ();
      }
    }
예제 #9
0
        public async Task Apply_Default_Settings_And_Reload_For_TestServerExtension_Test()
        {
            string testExtensionId = $"{nameof(TestServerExtension)}";

            using IApiClient adapter = new ApiClient(TestApiEnvironment, _restApiKey);

            ExtensionModel testExtension = await adapter.ExtensionService.GetExtension(testExtensionId);

            Assert.IsNotNull(testExtension);

            List <ExtensionSettingModel> defaultSettings = await adapter.ExtensionService.ApplyDefaultExtensionSettings(testExtensionId);

            Assert.IsNotNull(defaultSettings);

            bool reloadResult = await adapter.ExtensionService.ReloadExtensionSettings(testExtensionId);

            Assert.IsTrue(reloadResult);
        }
예제 #10
0
        public FileContentResult Images(string id)
        {
            ExtensionModel odb = new ExtensionModel();

            if (!string.IsNullOrEmpty(id))
            {
                List <ExtensionImg> list = odb.getExtensionImg(id);
                if (list != null && list.Count > 0)
                {
                    ExtensionImg info = list.First();
                    if (info != null)
                    {
                        if (info.Photo != null)
                        {
                            return(File(info.Photo, "jpg", "image_" + id + ".jpg"));
                        }
                    }
                }
            }
            return(File(new Byte[] { }, "jpg", "image_" + id + ".jpg"));
        }
예제 #11
0
    public void Cleanup ()
    {
      m_ValidateModel = true;

      ComponentModel.Cleanup ();
      ExtensionModel.Cleanup ();

      IsEnabledApply = false;
      IsEnabledCancel = false;
      IsComponentModelEnabled = true;
      IsExtensionModelEnabled = true;

      Distorted = false;

      BusyVisibility = Visibility.Collapsed;
      DistortedVisibility = Visibility.Collapsed;

      Id = Guid.Empty;

      ClearPanels ();
      Initialize ();
    }
        public async Task UpsertUserAttributes(ExtensionModel extension)
        {
            try
            {
                _logger.LogInfo("UserAttributeService-UpsertUserAttributes: [Started] creation of user attribute in Azure AD B2C");

                if (extension == null)
                {
                    _logger.LogError("UserAttributeService-UpsertUserAttributes: Input cannot be null");
                    return;
                }


                #region Validation

                if (extension.TargetObjects == null)
                {
                    _logger.LogError("UserAttributeService-UpsertUserAttributes: Target Object for creation of custom attribute cannot be empty");
                    return;
                }

                if (string.IsNullOrEmpty(extension.Name) &&
                    string.IsNullOrEmpty(extension.DataType) &&
                    !extension.TargetObjects.Any())
                {
                    _logger.LogError("UserAttributeService-UpsertUserAttributes: Input [Name | Data Type | Target Obejct] for creation of custom attribute cannot be empty");
                    return;
                }
                #endregion

                var client = GraphClientUtility.GetGraphServiceClient();

                if (client == null)
                {
                    _logger.LogError("UserAttributeService-UpsertUserAttributes: Unable create graph proxy to access Azure AD B2C");
                    return;
                }


                var taskSchemaName = await CheckIfExtensionExist(GraphClientUtility.ExtensionName);

                var schemaName = string.Empty;

                if (taskSchemaName != null)
                {
                    schemaName = "";
                }

                if (string.IsNullOrEmpty(schemaName))
                {
                    //var schemaExtension = new SchemaExtension
                    //{
                    //    Id = GraphClientUtility.ExtensionName,
                    //    Description = extension.Description,
                    //    TargetTypes = extension.TargetObjects,
                    //    Properties = new List<ExtensionSchemaProperty>()
                    //    {
                    //        new ExtensionSchemaProperty
                    //        {
                    //            Name= extension.Name,
                    //            Type = extension.DataType
                    //        }
                    //    }
                    //};

                    var schemaExtension = new SchemaExtension
                    {
                        Id          = "prasadtest3vikas",
                        Description = "Prasad Learn training courses extensions",
                        Status      = "InDevelopment",
                        TargetTypes = new List <String>()
                        {
                            "User"
                        },
                        Properties = new List <ExtensionSchemaProperty>()
                        {
                            new ExtensionSchemaProperty
                            {
                                Name = "courseId",
                                Type = "Integer"
                            },
                            new ExtensionSchemaProperty
                            {
                                Name = "courseName",
                                Type = "String"
                            },
                            new ExtensionSchemaProperty
                            {
                                Name = "courseType",
                                Type = "String"
                            }
                        }
                    };

                    try
                    {
                        var response = await client.SchemaExtensions
                                       .Request()
                                       .AddAsync(schemaExtension);

                        var result = response;
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                    }
                }
                else
                {
                    var schemaExtension = new SchemaExtension
                    {
                        TargetTypes = extension.TargetObjects,
                        Properties  = new List <ExtensionSchemaProperty>()
                        {
                            new ExtensionSchemaProperty
                            {
                                Name = extension.Name,
                                Type = extension.DataType
                            }
                        }
                    };
                    await client.SchemaExtensions[schemaName].Request().UpdateAsync(schemaExtension);
                }


                _logger.LogInfo("UserAttributeService-UpsertUserAttributes: [Completed] creation of user attribute in Azure AD B2C");
            }
            catch (Exception ex)
            {
                _logger.LogError("UserAttributeService-UpsertUserAttributes: Exception occured....");
                _logger.LogError(ex);
                throw ex;
            }
        }
예제 #13
0
        public async Task <string> Post([FromBody] ExtensionModel extension)
        {
            try
            {
                _logger.LogInfo("ExtensionController-Post: [Started] creation of user attribute in Azure AD B2C");

                if (extension == null)
                {
                    _logger.LogError("ExtensionController-Post: Input cannot be null");
                    return(string.Empty);
                }


                #region Validation

                if (extension.TargetObjects == null)
                {
                    _logger.LogError("ExtensionController-Post: Target Object for creation of custom attribute cannot be empty");
                    return(string.Empty);
                }

                if (string.IsNullOrEmpty(extension.Name) &&
                    string.IsNullOrEmpty(extension.DataType) &&
                    !extension.TargetObjects.Any())
                {
                    _logger.LogError("ExtensionController-Post: Input [Name | Data Type | Target Obejct] for creation of custom attribute cannot be empty");
                    return(string.Empty);
                }
                #endregion

                var client = GraphClientUtility.GetGraphServiceClient();

                if (client == null)
                {
                    _logger.LogError("ExtensionController-Post: Unable create graph proxy to access Azure AD B2C");
                    return(string.Empty);
                }

                var taskSchemaName = CheckIfExtensionExist(CareStreamConst.Schema_Extension_Id);
                var schemaName     = string.Empty;

                if (taskSchemaName != null)
                {
                    schemaName = taskSchemaName.Result;
                }

                if (string.IsNullOrEmpty(schemaName))
                {
                    var schemaExtension = new SchemaExtension
                    {
                        Id          = CareStreamConst.Schema_Extension_Id,
                        Description = extension.Description,
                        TargetTypes = extension.TargetObjects,
                        Properties  = new List <ExtensionSchemaProperty>()
                        {
                            new ExtensionSchemaProperty
                            {
                                Name = extension.Name,
                                Type = extension.DataType
                            }
                        }
                    };
                    await client.SchemaExtensions.Request().AddAsync(schemaExtension);
                }
                else
                {
                    var schemaExtension = new SchemaExtension
                    {
                        TargetTypes = extension.TargetObjects,
                        Properties  = new List <ExtensionSchemaProperty>()
                        {
                            new ExtensionSchemaProperty
                            {
                                Name = extension.Name,
                                Type = extension.DataType
                            }
                        }
                    };
                    await client.SchemaExtensions[schemaName].Request().UpdateAsync(schemaExtension);
                }


                _logger.LogInfo("ExtensionController-Post: [Completed] creation of user attribute in Azure AD B2C");

                return("");
            }
            catch (Exception ex)
            {
                _logger.LogError("ExtensionController-Post: Exception occured....");
                _logger.LogError(ex);
                throw ex;
            }
        }
예제 #14
0
        /// <summary>
        /// Reqursively goes through all namespaces in the assembly and discovers unique types, extensions and namespaces.
        /// </summary>
        private void ProcessNamespace(AssemblyMetadata assembly, INamespaceSymbol namespaceSymbol)
        {
            var assemblyName = Path.GetFileName(assembly.FullPath);

            if (string.IsNullOrEmpty(assemblyName) || namespaceSymbol == null)
            {
                return;
            }

            var fullNamespaceName = (namespaceSymbol.ContainingNamespace == null || string.IsNullOrEmpty(namespaceSymbol.ContainingNamespace.Name))
                    ? namespaceSymbol.Name
                    : namespaceSymbol.ContainingNamespace + "." + namespaceSymbol.Name;

            foreach (var typeName in namespaceSymbol.GetTypeMembers())
            {
                try
                {
                    // keep only public types
                    if (typeName.DeclaredAccessibility != Accessibility.Public)
                    {
                        continue;
                    }

                    var typeFullName = string.IsNullOrEmpty(fullNamespaceName)
                                        ? typeName.Name
                                        : typeName.ContainingNamespace + "." + typeName.Name;

                    // if we meet this type first time - remember it
                    if (!_types.ContainsKey(typeFullName))
                    {
                        var newType = new TypeModel
                        {
                            Name           = typeName.Name,
                            FullName       = typeFullName,
                            AssemblyName   = assemblyName,
                            PackageName    = _package.Id,
                            PackageVersion = _package.Version
                        };
                        newType.TargetFrameworks.AddRange(assembly.TargetFrameworks);

                        _types.Add(typeFullName, newType);

                        // if namespace contains at least one type and we meet this namespace first time - remember it
                        if (!string.IsNullOrEmpty(fullNamespaceName) && !_namespaces.ContainsKey(fullNamespaceName))
                        {
                            var newNamespace = new NamespaceModel
                            {
                                Name           = fullNamespaceName,
                                AssemblyName   = assemblyName,
                                PackageName    = _package.Id,
                                PackageVersion = _package.Version
                            };
                            newNamespace.TargetFrameworks.AddRange(assembly.TargetFrameworks);

                            _namespaces.Add(fullNamespaceName, newNamespace);
                        }
                        else
                        {
                            var namespaceModel = _namespaces[fullNamespaceName];
                            namespaceModel.MergeTargetFrameworks(assembly.TargetFrameworks);
                        }
                    }
                    else
                    {
                        var typeModel = _types[typeFullName];
                        typeModel.MergeTargetFrameworks(assembly.TargetFrameworks);

                        if (!string.IsNullOrEmpty(fullNamespaceName))
                        {
                            var namespaceModel = _namespaces[fullNamespaceName];
                            namespaceModel.MergeTargetFrameworks(assembly.TargetFrameworks);
                        }
                    }

                    // if type is static, then it might contain extension methdos
                    if (typeName.IsStatic)
                    {
                        foreach (var member in typeName.GetMembers())
                        {
                            // proceed only if static type's member is a method and it is public
                            var method = member as IMethodSymbol;
                            if (method == null || method.DeclaredAccessibility != Accessibility.Public)
                            {
                                continue;
                            }

                            if (method.IsExtensionMethod)
                            {
                                var thisParameter           = method.Parameters[0];
                                var extensionMethodTypeName = thisParameter.Type.ContainingNamespace + "." + thisParameter.Type.Name;
                                var extensionFullName       = extensionMethodTypeName + "." + method.Name;

                                // if we meet this extension first time - remember it
                                if (!_extensions.ContainsKey(extensionFullName))
                                {
                                    var newExtension = new ExtensionModel
                                    {
                                        Name           = method.Name,
                                        FullName       = extensionFullName,
                                        AssemblyName   = assemblyName,
                                        PackageName    = _package.Id,
                                        PackageVersion = _package.Version,
                                        Namespace      = fullNamespaceName
                                    };
                                    newExtension.TargetFrameworks.AddRange(assembly.TargetFrameworks);

                                    _extensions.Add(extensionFullName, newExtension);
                                }
                                else
                                {
                                    var extensionModel = _extensions[extensionFullName];
                                    extensionModel.MergeTargetFrameworks(assembly.TargetFrameworks);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.Write(e.ToString());
                }
            }

            // recurse to chilren namespaces
            foreach (var childNamespace in namespaceSymbol.GetNamespaceMembers())
            {
                if (childNamespace.NamespaceKind == NamespaceKind.Module)
                {
                    ProcessNamespace(assembly, childNamespace);
                }
            }
        }
예제 #15
0
        // GET: api/<ExtensionController>
        //[HttpGet("extensions/")]
        public async Task <IActionResult> GetExtensions()
        {
            List <ExtensionModel> retVal = new List <ExtensionModel>();

            try
            {
                var authenticationResult = GraphClientUtility.GetAuthentication();

                if (authenticationResult == null)
                {
                    _logger.LogError("ExtensionController-GetExtensions: Unable to get the Access token and Authentication Result");
                    return(NotFound());
                }
                _logger.LogInfo("ExtensionController-GetExtensions: [Started] to fetch user attribute in Azure AD B2C");

                var accessToken             = authenticationResult.Result.AccessToken;
                var b2cExtensionAppObjectId = GraphClientUtility.b2cExtensionAppObjectId;
                var tenantId           = GraphClientUtility.TenantId;
                var aadGraphVersion    = GraphClientUtility.AADGraphVersion;
                var aadGraphResourceId = GraphClientUtility.AADGraphResourceId;

                CustomExtension customExtensions = null;

                if (!string.IsNullOrEmpty(b2cExtensionAppObjectId) &&
                    !string.IsNullOrEmpty(tenantId) &&
                    !string.IsNullOrEmpty(aadGraphVersion) &&
                    !string.IsNullOrEmpty(aadGraphResourceId))
                {
                    string url = $"{aadGraphResourceId}{tenantId}" +
                                 $"{CareStreamConst.ForwardSlash}{CareStreamConst.Applications}{CareStreamConst.ForwardSlash}" +
                                 $"{b2cExtensionAppObjectId}{CareStreamConst.ForwardSlash}{CareStreamConst.ExtensionProperties}" +
                                 $"{CareStreamConst.Question}{aadGraphVersion}";

                    HttpClient         http    = new HttpClient();
                    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);
                    request.Headers.Authorization = new AuthenticationHeaderValue(CareStreamConst.Bearer, accessToken);
                    HttpResponseMessage response = await http.SendAsync(request);

                    if (response.IsSuccessStatusCode)
                    {
                        var data = await response.Content.ReadAsStringAsync();

                        customExtensions = JsonConvert.DeserializeObject <CustomExtension>(data);
                    }
                }

                if (customExtensions != null)
                {
                    if (customExtensions.value != null)
                    {
                        _logger.LogInfo($"ExtensionController-GetExtensions:got {customExtensions.value.Count} user attribute from Azure AD B2C");
                    }

                    var b2cExtensionAppClientId = GraphClientUtility.b2cExtensionAppClientId;
                    b2cExtensionAppClientId = b2cExtensionAppClientId.Replace(CareStreamConst.Dash, "");
                    var toReplace = $"{CareStreamConst.Extension}{CareStreamConst.Underscore}{b2cExtensionAppClientId}{CareStreamConst.Underscore}";

                    foreach (var value in customExtensions.value)
                    {
                        try
                        {
                            var extensionModel = new ExtensionModel
                            {
                                ObjectId      = value.objectId,
                                DataType      = value.dataType,
                                TargetObjects = value.targetObjects,
                                AttributeType = CareStreamConst.Custom,
                                Description   = string.Empty,
                                Name          = value.name,
                                IsBuildIn     = false
                            };

                            if (!string.IsNullOrEmpty(extensionModel.Name))
                            {
                                extensionModel.Name = extensionModel.Name.Replace(toReplace, "");
                            }

                            retVal.Add(extensionModel);
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError($"ExtensionController-GetExtensions: fail to add extension [name:{value.name}] to collection ");
                            _logger.LogError(ex);
                        }
                    }
                }
                if (retVal.Any())
                {
                    retVal = retVal.OrderBy(x => x.Name).ToList();
                }

                _logger.LogInfo("ExtensionController-GetExtensions: [Completed] getting user attribute in Azure AD B2C");
            }
            catch (ServiceException ex)
            {
                _logger.LogError("ExtensionController-GetExtensions: Exception occured....");
                _logger.LogError(ex);
            }

            return(Ok(retVal));
        }
예제 #16
0
        public async Task <IActionResult> GetSchemaExtensions()
        {
            List <ExtensionModel> retVal = new List <ExtensionModel>();

            try
            {
                var client = GraphClientUtility.GetGraphServiceClient();

                if (client == null)
                {
                    _logger.LogError("ExtensionController-GetExtensions: Unable to create proxy for the Azure AD B2C graph client");
                    return(NotFound());
                }
                _logger.LogInfo("ExtensionController-GetExtensions: [Started] to fetch user attribute in Azure AD B2C");


                var schemaExtensions = await client.SchemaExtensions.Request().GetAsync();

                var deleteAppList = new List <string>
                {
                    "extcivhhslh_sbtest1",
                    "ext8t93kbpf_testSchemaRodney",
                    "extcivhhslh_sbtest1",
                    "ext8t93kbpf_testSchemaRodney",
                    "exti6wv1vlh_testingext",
                    "ext46vln54c_ntest",
                    "extaca0mlr5_ntest3",
                    "ext1xx3fz1l_ntest3",
                    "extmpe64h5d_ntest3",
                    "xylosbsocial_teamsTestArchiving",
                    "extc5bnq6uk_TestExtension",
                    "extmoxsowno_graphlearnTest1",
                    "extve5g6vcc_askjagroupextensionstest",
                    "extdtcu1cfg_nlegtest",
                    "extl44kejst_nlegtest222",
                    "exts8sy6qub_ExtensionTest",
                    "extq04xs9zk_test",
                    "diginoid_test",
                    "dommailtest_VDSExtensions",
                    "extbbb36prt_testSchemaExtension",
                    "extnr3ono6a_MitaTest",
                    "ext4d06qxmp_fducatest",
                    "regis_testDataSync",
                    "est1933a_test3",
                    "est1933a_test4",
                    "extxba991fd_myphoenixtestlab",
                    "fede_test",
                    "extyk7nj53r_TestExtensionName",
                    "extsgnu4ipx_TestExtensionName3",
                    "ext39c4063f_TestProject",
                    "ext8dswvbrw_sbtest1",
                    "extm3ewp8cn_puttitest",
                    "extxw26d35r_puttitest2",
                    "extoegtdaxg_NextTestExtension",
                    "nethabilis_TestMetadata1",
                    "exta4v28cm3_ActaTestSch",
                    "ext4s9ja9u0_deskutest0",
                    "extl8a9vgqv_TestYeahBoi",
                    "extkx0h0c9g_TestYeahBoi",
                    "gmpoc_UserDealerSchemaTest",
                    "extqxucmyye_ScripsTestExtentions",
                    "extp0sohkm9_test",
                    "extcjwhq847_testExtension",
                    "ext1qq0lzat_collabtest",
                    "extrpzqgpj6_test1",
                    "diginoid_test2",
                    "ext54vl35zq_TestUpdate",
                    "dommailtest_B2BGuestUserExtensions",
                    "ext3ju9rfik_MLschemaTest"
                };

                while (schemaExtensions.NextPageRequest != null)
                {
                    foreach (SchemaExtension extension in schemaExtensions.CurrentPage)
                    {
                        //if (extension.Id.Contains("prasad"))
                        if (extension.Id.Contains(CareStreamConst.Schema_Extension_Id))
                        {
                            try
                            {
                                foreach (var item in extension.Properties)
                                {
                                    try
                                    {
                                        var extensionModel = new ExtensionModel
                                        {
                                            ObjectId      = extension.Id,
                                            Description   = extension.Description,
                                            AttributeType = CareStreamConst.Custom,
                                            IsBuildIn     = false,
                                            Name          = item.Name,
                                            DataType      = item.Type
                                        };

                                        if (extension.TargetTypes != null)
                                        {
                                            extensionModel.TargetObjects = extension.TargetTypes.ToList();
                                        }
                                        retVal.Add(extensionModel);
                                    }
                                    catch (Exception ex)
                                    {
                                        _logger.LogError($"ExtensionController-GetExtensions: fail to add extension [name:{item.Name}] to collection ");
                                        _logger.LogError(ex);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                _logger.LogError($"ExtensionController-GetExtensions: fail to add extension [name:{extension.Id}] to collection ");
                                _logger.LogError(ex);
                            }
                        }
                    }
                    schemaExtensions = await schemaExtensions.NextPageRequest.GetAsync();
                }

                if (retVal.Any())
                {
                    retVal = retVal.OrderBy(x => x.Name).ToList();
                }

                _logger.LogInfo("ExtensionController-GetExtensions: [Completed] getting user attribute in Azure AD B2C");
            }
            catch (ServiceException ex)
            {
                _logger.LogError("ExtensionController-GetExtensions: Exception occured....");
                _logger.LogError(ex);
            }

            return(Ok(retVal));
        }
예제 #17
0
 TModelProperty (Server.Models.Infrastructure.TCategory modelCategory)
   : this ()
 {
   ExtensionModel.SelectModelCategory (modelCategory);
   ExtensionModel.ValidateModel ();
 }
        public async Task <string> Post([FromBody] ExtensionModel extension)
        {
            try
            {
                //Check Null condition and add logging
                _logger.LogInfo("ExtensionController-Post: [Started] creation of user attribute in Azure AD B2C");

                if (extension == null)
                {
                    _logger.LogError("ExtensionController-Post: Input cannot be null");
                    return(string.Empty);
                }

                var json = JsonConvert.SerializeObject(extension);

                var authenticationResult = GraphClientUtility.GetAuthentication();

                if (authenticationResult == null)
                {
                    _logger.LogError("ExtensionController-Post: Unable to get the Access token and Authentication Result");
                    return(string.Empty);
                }
                var accessToken = authenticationResult.Result.AccessToken;

                var tenantId = GraphClientUtility.TenantId;
                var api      = $"{CareStreamConst.ForwardSlash}{CareStreamConst.Applications}{CareStreamConst.ForwardSlash}{GraphClientUtility.b2cExtensionAppClientId}{CareStreamConst.ForwardSlash}{CareStreamConst.ExtensionProperties}";

                HttpClient httpClient = new HttpClient();
                string     url        = GraphClientUtility.AADGraphResourceId + tenantId + api + "?" + GraphClientUtility.AADGraphVersion;

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
                request.Headers.Authorization = new AuthenticationHeaderValue(CareStreamConst.Bearer, accessToken);
                request.Content = new StringContent(json, Encoding.UTF8, $"{CareStreamConst.Application}{CareStreamConst.ForwardSlash}{CareStreamConst.Json}");
                HttpResponseMessage response = await httpClient.SendAsync(request);


                if (!response.IsSuccessStatusCode)
                {
                    string error = await response.Content.ReadAsStringAsync();

                    object formatted = JsonConvert.DeserializeObject(error);

                    var errorMessage = "Error Calling the Graph API: \n" + JsonConvert.SerializeObject(formatted, Formatting.Indented);

                    _logger.LogError($"ExtensionController-Post: {errorMessage}");
                    return(errorMessage);
                }


                _logger.LogInfo("ExtensionController-Post: [Completed] creation of user attribute in Azure AD B2C");


                return(await response.Content.ReadAsStringAsync());
            }
            catch (Exception ex)
            {
                _logger.LogError("ExtensionController-Post: Exception occured....");
                _logger.LogError(ex);
                throw ex;
            }
        }
 public CreateUserAttributesModel()
 {
     extensionModel = new ExtensionModel();
 }
예제 #20
0
 public void Initialize ()
 {
   ExtensionModel.Initialize ();
 }
예제 #21
0
 public void SelectionLock (bool lockCurrent)
 {
   ExtensionModel.SelectionLock (lockCurrent);
 }
예제 #22
0
 public void ImageCleanup ()
 {
   ExtensionModel.ImageCleanup ();
 }
예제 #23
0
        public async Task <IActionResult> Upsert(ExtensionModel model)
        {
            await _userAttributeService.UpsertUserAttributes(model);

            return(RedirectToAction("List"));
        }