コード例 #1
0
        /// <summary>
        /// This method is responsible for getting customer dto records with first and last names set from the attribute mappings.
        /// </summary>
        private IList <CustomerDto> GetFullCustomerDtos(IQueryable <IGrouping <int, CustomerAttributeMappingDto> > customerAttributesMappings,
                                                        int page = Configurations.DEFAULT_PAGE_VALUE, int limit = Configurations.DEFAULT_LIMIT, string order = Configurations.DEFAULT_ORDER)
        {
            var customerDtos = new List <CustomerDto>();

            customerAttributesMappings = customerAttributesMappings.OrderBy(x => x.Key);

            IList <IGrouping <int, CustomerAttributeMappingDto> > customerAttributeGroupsList = new ApiList <IGrouping <int, CustomerAttributeMappingDto> >(customerAttributesMappings, page - 1, limit);

            // Get the default language id for the current store.
            var defaultLanguageId = GetDefaultStoreLangaugeId();

            foreach (var group in customerAttributeGroupsList)
            {
                IList <CustomerAttributeMappingDto> mappingsForMerge = group.Select(x => x).ToList();

                var customerDto = Merge(mappingsForMerge, defaultLanguageId);

                customerDtos.Add(customerDto);
            }

            // Needed so we can apply the order parameter
            return(customerDtos.AsQueryable().OrderBy(order).ToList());
        }
コード例 #2
0
        /// <summary>
        /// Retrieve viewModels from actions.
        /// </summary>
        /// <param name="layoutActions">A list of layout actions.</param>
        /// <param name="apis">A list of api.</param>
        /// <returns>A list of ViewModels id.</returns>
        public static List <string> GetActionsViewModelsId(
            this ActionList layoutActions,
            ApiList apis)
        {
            var viewModels = new List <string>();

            if (!layoutActions.IsValid() ||
                !apis.IsValid())
            {
                return(viewModels);
            }

            foreach (var action in layoutActions)
            {
                if (action.IsValid())
                {
                    viewModels = viewModels
                                 .Union(action.GetActionViewModelsId(apis))
                                 .ToList();
                }
            }

            return(viewModels);
        }
コード例 #3
0
        public void GetAnswers()
        {
            ApiList <QuestionAnswer> answers = RunTest(QuestionAnswer.GetAllQuestionAnswers(Api, Settings.TestProject, Settings.TestQuestion));

            Assert.IsTrue(answers.All(Api).Any(a => a.id == Settings.TestAnswer));
        }
コード例 #4
0
        public void GetAllQuestions()
        {
            ApiList <Question> list = RunTest(Question.GetAllQuestions(Api, Settings.TestProject, Settings.TestQuestionnaire));

            Assert.IsTrue(list.All(Api).Any(q => q.id == Settings.TestQuestion));
        }
コード例 #5
0
        /// <summary>
        /// Generating an angular module containing the configuration
        /// required to get the page integrated in the Ionic 2 navigation.
        /// Ionic 2 recommends a module for each page. One page = one layout.
        /// </summary>
        /// <param name="concernId">A concern Id.</param>
        /// <param name="layout">A layout.</param>
        /// <param name="languages">A list of languages. (can be null)</param>
        /// <param name="api">A lit of apis.</param>
        public void TransformLayoutModule(string concernId, LayoutInfo layout, LanguageList languages, ApiList api)
        {
            if (concernId != null && layout != null && layout.Id != null && api != null)
            {
                LayoutModuleTemplate layoutModuleTemplate = new LayoutModuleTemplate(concernId, layout, languages, api);

                string layoutModuleDirectoryPath = Path.Combine(layoutModuleTemplate.OutputPath, TextConverter.CamelCase(concernId), TextConverter.CamelCase(layout.Id));
                string layoutModuleFilename      = TextConverter.CamelCase(concernId) + "-" + TextConverter.CamelCase(layout.Id) + ".module.ts";

                string fileToWritePath = Path.Combine(_context.BasePath, layoutModuleDirectoryPath, layoutModuleFilename);
                string textToWrite     = layoutModuleTemplate.TransformText();

                _writingService.WriteFile(fileToWritePath, textToWrite);
            }
        }
コード例 #6
0
 public void UpdateList([FromBody] ApiList model)
 {
     _listService.UpdateList(Mapper.ToBllList(model));
 }
コード例 #7
0
        public void GetAllToDoLists()
        {
            ApiList <ToDoList> lists = RunTest(ToDoList.GetAllToDoLists(Api, Settings.TestProject, Settings.TestToDoSet));

            Assert.IsTrue(lists.All(Api).Any(l => l.id == Settings.TestToDoList));
        }
コード例 #8
0
 public void GetSubVaults()
 {
     Vault           v = Vault.GetVault(Api, Settings.TestProject, Settings.TestVault).Result;
     ApiList <Vault> s = RunTest(v.GetVaults(Api));
     //Assert.IsTrue(s.All(Api).Any(m => m.id == Settings.TestMessage));
 }
コード例 #9
0
 public void GetTrashedProjects()
 {
     ApiList <Project> projects = RunTest(Project.GetAllProjects(Api, Status.trashed));
 }
コード例 #10
0
 public ComponentSpecTemplate(string smartAppId, ConcernInfo concern, LayoutInfo layout, LanguageList languages, ApiList api)
 {
     _smartAppId = smartAppId;
     if (concern != null && concern.Id != null)
     {
         _concernId = concern.Id;
     }
     _layout     = layout;
     _languages  = languages;
     _api        = api;
     _viewModels = new List <string>();
     getViewModels(layout, api);
     _apiDomainServices = getApiDomainServices(api, layout);
 }
コード例 #11
0
        public ApiList <SPListItem> List(SPList list,
                                         [Documentation(Name = "ViewFields", Type = typeof(List <string>)),
                                          Documentation(Name = "ViewQuery", Type = typeof(string))]
                                         IDictionary options)
        {
            if (list == null)
            {
                return(new ApiList <SPListItem>());
            }

            var cacheId   = string.Concat(SharePointListItemCacheId, string.Format("{0}_{1}", list.SPWebUrl, list.Id));
            var cacheList = (ApiList <SPListItem>)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (cacheList == null)
            {
                using (var clientContext = new SPContext(list.SPWebUrl, credentials.Get(list.SPWebUrl)))
                {
                    var sharepointList = clientContext.ToList(list.Id);
                    ListItemCollection listItemCollection;
                    if (options != null && options["ViewQuery"] != null)
                    {
                        var camlQuery = new CamlQuery
                        {
                            ViewXml = String.Format("<View><Query>{0}</Query></View>", options["ViewQuery"])
                        };
                        listItemCollection = sharepointList.GetItems(camlQuery);
                    }
                    else
                    {
                        listItemCollection = sharepointList.GetItems(CamlQuery.CreateAllItemsQuery());
                    }
                    IEnumerable <ListItem> items;
                    if (options != null && options["ViewFields"] != null)
                    {
                        var viewFields = (List <string>)options["ViewFields"];
                        items = clientContext.LoadQuery(listItemCollection.Include(CreateListItemLoadExpressions(viewFields)));
                    }
                    else
                    {
                        items = clientContext.LoadQuery(listItemCollection.Include(SPItemService.InstanceQuery));
                    }
                    var userItemCollection = clientContext.Web.SiteUserInfoList.GetItems(CamlQuery.CreateAllItemsQuery());
                    IEnumerable <SP.ListItem> userItems = clientContext.LoadQuery(
                        userItemCollection.Include(new Expression <Func <ListItem, object> >[] { item => item.Id, item => item["Picture"] }));

                    var fieldsQuery = clientContext.LoadQuery(sharepointList.Fields.Where(field => !field.Hidden && field.Group != "_Hidden"));
                    clientContext.ExecuteQuery();
                    var apiList = new ApiList <SPListItem>();
                    var fields  = fieldsQuery.ToList();

                    foreach (var item in items)
                    {
                        apiList.Add(new SPListItem(item, fields));
                    }

                    cacheService.Put(cacheId, apiList, CacheScope.Context | CacheScope.Process, new[] { GetTag(list.Id) }, CacheTimeOut);
                    return(apiList);
                }
            }

            return(cacheList);
        }
コード例 #12
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="api"></param>
 internal void Remove(ApiItem api)
 {
     ApiList.Remove(api);
     GlobalConfig.Remove(api);
 }
コード例 #13
0
 public void Assert(ApiList <Driver> actual)
 {
     actual.ShouldNotBeEmpty();
 }
コード例 #14
0
        private static void runTest(TestCase testCase)
        {
            var queryParam = new ApiList();

            foreach (var param in testCase.QueryParams)
            {
                queryParam.Add(param);
            }
            string queryString = queryParam.ToQueryString();

            LoggerManager.Logger.LogInformation($"Test Case {testCase.Name} started. Query string: {queryString}");
            Console.WriteLine($"Test Case {testCase.Name} started.");

            // base URL
            string baseUrl;
            //static string apiPath = "test/l2-eg/v1"; //according to "EDH_BIDWH_HPB_UAT_REST_Scenarios_Conditions_v1.0.xlsx", tab "WebService"
            //v1/entities
            //v1/entity/{uen}
            //v1/entity/{uen}/appointments
            string fullPath;

            switch (testCase.TestMethod)
            {
            case TestMethod.Entities:
                fullPath = $"{apiPath}/entities";
                break;

            case TestMethod.UENs:
                fullPath = $"{apiPath}/entity/{testCase.UEN}";
                break;

            case TestMethod.Appointments:
            default:
                fullPath = $"{apiPath}/entity/{testCase.UEN}/appointments";
                break;
            }

            if (string.IsNullOrEmpty(queryString))
            {
                baseUrl = $"https://{signingGateway}/{fullPath}";
            }
            else
            {
                baseUrl = $"https://{signingGateway}/{fullPath}?{queryString}";
            }

            // authorization header
            var authorizationHeader = ApiAuthorization.Token(realm, authPrefix, HttpMethod.GET, new Uri(baseUrl), appId, null, null, privateKey);

            //target base URL
            string targetBaseUrl;

            if (string.IsNullOrEmpty(queryString))
            {
                targetBaseUrl = $"https://{targetGatewayName}/{fullPath}";
            }
            else
            {
                targetBaseUrl = $"https://{targetGatewayName}/{fullPath}?{queryString}";
            }

            var result = ApiAuthorization.HttpRequest(new Uri(targetBaseUrl), authorizationHeader);

            LoggerManager.Logger.LogInformation($"Test Case {testCase.Name} ended with result: {result}");
            Console.WriteLine($"Test Case {testCase.Name} ended with result: {result}");
        }
コード例 #15
0
        public void GetAllProjects()
        {
            ApiList <Project> projects = RunTest(Project.GetAllProjects(Api));

            Assert.IsTrue(projects.All(Api).Any(p => p.id == Settings.TestProject));
        }
コード例 #16
0
 public LayoutComponentTemplate(ConcernInfo concern, LayoutInfo layout, LanguageList languages, ApiList api)
 {
     if (concern != null && concern.Id != null)
     {
         _concernId = concern.Id;
     }
     _layout     = layout;
     _languages  = languages;
     _api        = api;
     _viewModels = new List <string>();
     getViewModels(layout, api);
     _apiDomainServices = getApiDomainServices(api, layout);
     _menu = getMenu(concern);
 }
コード例 #17
0
 public void GetArchivedProjects()
 {
     ApiList <Project> projects = RunTest(Project.GetAllProjects(Api, Status.archived));
 }
コード例 #18
0
        private ApiList <ProfileField> UpdatedProfileFields(Dictionary <string, string> usersSamlTokenProfileData, ApiList <ProfileField> currentProfileFields)
        {
            //get a list of user profile fields with the matching prefix
            var samlProfileFields    = GetSamlProfileFields();
            var updatedProfileFields = new ApiList <ProfileField>();

            bool hasChanges = false;

            foreach (var userProfileField in samlProfileFields)
            {
                try
                {
                    bool userHasField = false;
                    //this checks the current users profile fields against saml (ie remove or update)
                    foreach (var profileField in currentProfileFields.Where(i => i.Label == userProfileField.Name))
                    {
                        //check to see if its in the saml token based on userProfileField name
                        if (!usersSamlTokenProfileData.ContainsKey(userProfileField.Name) && !string.IsNullOrWhiteSpace(profileField.Value))
                        {
                            updatedProfileFields.Add(new ProfileField()
                            {
                                Label = userProfileField.Name, Value = ""
                            });
                            hasChanges = true;
                        }

                        if (usersSamlTokenProfileData.ContainsKey(userProfileField.Name) && profileField.Value != usersSamlTokenProfileData[userProfileField.Name])
                        {
                            updatedProfileFields.Add(new ProfileField()
                            {
                                Label = userProfileField.Name, Value = usersSamlTokenProfileData[userProfileField.Name]
                            });
                            hasChanges = true;
                        }

                        userHasField = true;
                    }

                    //this checks the saml data against the user (ie adding missing entries)
                    if (!userHasField && usersSamlTokenProfileData.ContainsKey(userProfileField.Name))
                    {
                        updatedProfileFields.Add(new ProfileField()
                        {
                            Label = userProfileField.Name, Value = usersSamlTokenProfileData[userProfileField.Name]
                        });
                        hasChanges = true;
                    }
                }
                catch (Exception ex)
                {
                    _eventLogApi.Write("ProfileAttributeManager Error UpdatedProfileFields: " + ex.Message + " : " + ex.StackTrace, new EventLogEntryWriteOptions()
                    {
                        Category = "SAML", EventId = 1, EventType = "Error"
                    });
                }
            }

            if (hasChanges)
            {
                return(updatedProfileFields);
            }
            else
            {
                return(null);
            }
        }
コード例 #19
0
        public void GetAllCampfires()
        {
            ApiList <Campfire> campfires = RunTest(Campfire.GetAllCampfires(Api));

            Assert.IsTrue(campfires.All(Api).Any(c => c.id == Settings.TestCampfire));
        }
コード例 #20
0
 public LayoutModuleTemplate(string concernId, LayoutInfo layout, LanguageList languages, ApiList api)
 {
     _concernId         = concernId;
     _layout            = layout;
     _languages         = languages;
     _api               = api;
     _apiDomainServices = getApiDomainServices(api, layout.Actions);
 }
コード例 #21
0
        public void GetScheduleEntries()
        {
            ApiList <ScheduleEntry> entries = RunTest(ScheduleEntry.GetScheduleEntries(Api, Settings.TestProject, Settings.TestSchedule));

            Assert.IsTrue(entries.All(Api).Any(e => e.id == Settings.TestEvent));
        }
コード例 #22
0
        public ViewTemplate(string smartAppTitle, ConcernInfo concern, LayoutInfo layout, LanguageList languages, ApiList api, string apiSuffix, string viewModelSuffix)
        {
            _smartAppTitle   = smartAppTitle;
            _concern         = concern;
            _layout          = layout;
            _languages       = languages;
            _api             = api;
            _viewModelSuffix = TextConverter.PascalCase(viewModelSuffix);
            _apiSuffix       = TextConverter.PascalCase(apiSuffix);

            _viewModels = new List <string>();

            getViewModels(layout, api);

            _apiDomainServices = getApiDomainServices(api, layout);

            _menu = getMenu(_concern);
        }
コード例 #23
0
        public void GetAllToDoListGroups()
        {
            ApiList <ToDoListGroup> groups = RunTest(ToDoListGroup.GetAllToDoListGroups(Api, Settings.TestProject, Settings.TestToDoList));

            Assert.IsTrue(groups.All(Api).Any(g => g.id == Settings.TestToDoListGroup));
        }
コード例 #24
0
 public void AddList([FromBody] ApiList model)
 {
     _listService.AddList(Mapper.ToBllList(model));
 }