Example #1
0
        private void ImportEmployees(IFileDataImporter fileImporter, IContentRepository contentRepo, EmployeeContainerLookup lookup)
        {
            string[] allEmployees = fileImporter.RetrieveAllData(_employeeDataFile);

            foreach (string employeeRow in allEmployees)
            {
                string[] fields = fileImporter.SplitByDelimiter(employeeRow, TabDelimiter);
                if (!string.IsNullOrWhiteSpace(fields[2]))
                {
                    string firstLetter = fields[2].Substring(0, 1).ToUpper();
                    string pageName    = string.Format("{0}, {1}", fields[2], fields[1]);

                    int pageReference = lookup.GetIndex(firstLetter);

                    ContentReference startingFolder = new ContentReference(pageReference);

                    EmployeePage page = lookup.GetExistingPage <EmployeePage>(startingFolder, pageName);

                    if (page != null)
                    {
                        page = page.CreateWritableClone() as EmployeePage;
                    }
                    else
                    {
                        page = contentRepo.GetDefault <EmployeePage>(startingFolder);
                    }

                    MapFields(fields, page);
                    page.Name = pageName;


                    contentRepo.Save(page, EPiServer.DataAccess.SaveAction.Publish);
                }
                //For long running jobs periodically check if stop is signaled and if so stop execution
                if (_stopSignaled)
                {
                    break;
                }
            }
        }
Example #2
0
        private void ImportExpertise(IFileDataImporter fileImporter, IContentRepository contentRepo, EmployeeContainerLookup lookup)
        {
            string[]         allExpertise  = fileImporter.RetrieveAllData(_expertiseDataFile);
            ContentReference expertiseRoot = lookup.EmployeeSpecialityRootPage;

            foreach (string expertise in allExpertise)
            {
                EmployeeExpertise expertisePage = lookup.GetExistingPage <EmployeeExpertise>(expertiseRoot, expertise);
                if (expertisePage == null)
                {
                    expertisePage      = contentRepo.GetDefault <EmployeeExpertise>(expertiseRoot);
                    expertisePage.Name = expertise;

                    contentRepo.Save(expertisePage, EPiServer.DataAccess.SaveAction.Publish);

                    //For long running jobs periodically check if stop is signaled and if so stop execution
                    if (_stopSignaled)
                    {
                        break;
                    }
                }
            }
        }
Example #3
0
        private void ImportLocations(IFileDataImporter fileImporter, IContentRepository contentRepo, EmployeeContainerLookup lookup)
        {
            string[]         allLocations = fileImporter.RetrieveAllData(_locationDataFile);
            ContentReference locationRoot = lookup.EmployeeLocationRootPage;

            foreach (string location in allLocations)
            {
                EmployeeLocationPage locationPage = lookup.GetExistingPage <EmployeeLocationPage>(locationRoot, location);
                if (locationPage == null)
                {
                    locationPage      = contentRepo.GetDefault <EmployeeLocationPage>(locationRoot);
                    locationPage.Name = location;

                    contentRepo.Save(locationPage, EPiServer.DataAccess.SaveAction.Publish);

                    //For long running jobs periodically check if stop is signaled and if so stop execution
                    if (_stopSignaled)
                    {
                        break;
                    }
                }
            }
        }