Esempio n. 1
0
        private async Task PerformExportXmlToFileAsync(Guid idSiteMap, Func <Task <IOrganizationServiceExtented> > getService, string fieldName, string fieldTitle)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.ExportingXmlFieldToFileFormat1, fieldTitle);

            var service = await getService();

            if (service != null)
            {
                var repository = new SiteMapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, ColumnSetInstances.AllColumns);

                string xmlContent = sitemap.GetAttributeValue <string>(fieldName);

                string filePath = await CreateFileAsync(service.ConnectionData, sitemap.SiteMapName, sitemap.SiteMapNameUnique, sitemap.Id, fieldTitle, xmlContent);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);
            }

            ToggleControls(true, Properties.OutputStrings.ExportingXmlFieldToFileCompletedFormat1, fieldName);
        }
Esempio n. 2
0
        private async Task PerformExportDescriptionToFileAsync(Guid idSiteMap, Func <Task <IOrganizationServiceExtented> > getService)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.CreatingEntityDescription);

            var service = await getService();

            if (service != null)
            {
                var repository = new SiteMapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, ColumnSetInstances.AllColumns);

                var description = await EntityDescriptionHandler.GetEntityDescriptionAsync(sitemap, service.ConnectionData);

                string filePath = await CreateDescriptionFileAsync(service.ConnectionData, sitemap.SiteMapName, sitemap.Id, EntityFileNameFormatter.Headers.EntityDescription, description);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);
            }

            ToggleControls(true, Properties.OutputStrings.CreatingEntityDescriptionCompleted);
        }
        private async Task <bool> ValidateDocumentSiteMapXml(ConnectionData connectionData, XDocument doc)
        {
            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ValidatingXmlForFieldFormat1, SiteMap.Schema.Attributes.sitemapxml);

            ContentComparerHelper.ClearRoot(doc);

            bool validateResult = await SiteMapRepository.ValidateXmlDocumentAsync(connectionData, _iWriteToOutput, doc);

            if (!validateResult)
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ValidatingXmlForFieldFailedFormat1, SiteMap.Schema.Attributes.sitemapxml);
                _iWriteToOutput.ActivateOutputWindow(connectionData);

                var dialogResult = MessageBoxResult.Cancel;

                var thread = new Thread(() =>
                {
                    dialogResult = MessageBox.Show(Properties.MessageBoxStrings.ContinueOperation, Properties.MessageBoxStrings.QuestionTitle, MessageBoxButton.OKCancel, MessageBoxImage.Question);
                });
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();

                thread.Join();

                if (dialogResult != MessageBoxResult.OK)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 4
0
 public void SetUp()
 {
     siteMapRepository = siteMapRepository ?? new SiteMapRepository(
         new Shared.Mocks.MockMongoRepositority <SiteMapping>(),
         new Shared.Mocks.MockMongoRepositority <SiteExpression>(),
         new Shared.Mocks.MockMongoRepositority <UnknownSite>(),
         new Shared.Mocks.MockMongoRepositority <SiteMapVersion>());
 }
Esempio n. 5
0
        public ActionResult History()
        {
            IEnumerable <MapSite> mapSite           = new List <MapSite>();
            SiteMapRepository     siteMapRepository = new SiteMapRepository();

            mapSite = siteMapRepository.Get();
            return(View(mapSite));
        }
Esempio n. 6
0
        private async Task PerformShowingDifferenceDescriptionAsync(LinkedEntities <SiteMap> linked, bool showAllways)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.ShowingDifferenceEntityDescription);

            try
            {
                var service1 = await GetService1();

                var service2 = await GetService2();

                if (service1 != null && service2 != null)
                {
                    var repository1 = new SiteMapRepository(service1);
                    var repository2 = new SiteMapRepository(service2);

                    var sitemap1 = await repository1.GetByIdAsync(linked.Entity1.Id, ColumnSetInstances.AllColumns);

                    var sitemap2 = await repository2.GetByIdAsync(linked.Entity2.Id, ColumnSetInstances.AllColumns);

                    var desc1 = await EntityDescriptionHandler.GetEntityDescriptionAsync(sitemap1);

                    var desc2 = await EntityDescriptionHandler.GetEntityDescriptionAsync(sitemap2);

                    if (showAllways || desc1 != desc2)
                    {
                        string filePath1 = await CreateDescriptionFileAsync(service1.ConnectionData, sitemap1.SiteMapName, sitemap1.Id, EntityFileNameFormatter.Headers.EntityDescription, desc1);

                        string filePath2 = await CreateDescriptionFileAsync(service2.ConnectionData, sitemap2.SiteMapName, sitemap2.Id, EntityFileNameFormatter.Headers.EntityDescription, desc2);

                        if (File.Exists(filePath1) && File.Exists(filePath2))
                        {
                            await this._iWriteToOutput.ProcessStartProgramComparerAsync(service1.ConnectionData, filePath1, filePath2, Path.GetFileName(filePath1), Path.GetFileName(filePath2), service2.ConnectionData);
                        }
                        else
                        {
                            this._iWriteToOutput.PerformAction(service1.ConnectionData, filePath1);

                            this._iWriteToOutput.PerformAction(service2.ConnectionData, filePath2);
                        }
                    }
                }

                ToggleControls(true, Properties.OutputStrings.ShowingDifferenceEntityDescriptionCompleted);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(null, ex);

                ToggleControls(true, Properties.OutputStrings.ShowingDifferenceEntityDescriptionFailed);
            }
        }
Esempio n. 7
0
        private async Task PerformShowingDifferenceSingleXmlAsync(LinkedEntities <SiteMap> linked, bool showAllways, string fieldName, string fieldTitle)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.ShowingDifferenceXmlForFieldFormat1, fieldName);

            try
            {
                var service1 = await GetService1();

                var service2 = await GetService2();

                if (service1 != null && service2 != null)
                {
                    var repository1 = new SiteMapRepository(service1);
                    var repository2 = new SiteMapRepository(service2);

                    var sitemap1 = await repository1.GetByIdAsync(linked.Entity1.Id, ColumnSetInstances.AllColumns);

                    var sitemap2 = await repository2.GetByIdAsync(linked.Entity2.Id, ColumnSetInstances.AllColumns);

                    string xml1 = sitemap1.GetAttributeValue <string>(fieldName);
                    string xml2 = sitemap2.GetAttributeValue <string>(fieldName);

                    if (showAllways || !ContentComparerHelper.CompareXML(xml1, xml2).IsEqual)
                    {
                        string filePath1 = await CreateFileAsync(service1.ConnectionData, sitemap1.SiteMapName, sitemap1.SiteMapNameUnique, sitemap1.Id, fieldTitle, xml1);

                        string filePath2 = await CreateFileAsync(service2.ConnectionData, sitemap2.SiteMapName, sitemap2.SiteMapNameUnique, sitemap2.Id, fieldTitle, xml2);

                        if (File.Exists(filePath1) && File.Exists(filePath2))
                        {
                            await this._iWriteToOutput.ProcessStartProgramComparerAsync(service1.ConnectionData, filePath1, filePath2, Path.GetFileName(filePath1), Path.GetFileName(filePath2), service2.ConnectionData);
                        }
                        else
                        {
                            this._iWriteToOutput.PerformAction(service1.ConnectionData, filePath1);

                            this._iWriteToOutput.PerformAction(service2.ConnectionData, filePath2);
                        }
                    }
                }

                ToggleControls(true, Properties.OutputStrings.ShowingDifferenceXmlForFieldCompletedFormat1, fieldName);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(null, ex);

                ToggleControls(true, Properties.OutputStrings.ShowingDifferenceXmlForFieldFailedFormat1, fieldName);
            }
        }
Esempio n. 8
0
        private void FillSolutionComponentFromSchemaName(ICollection <SolutionComponent> result, string sitemapName, int?behavior)
        {
            var repository = new SiteMapRepository(_service);

            var entity = repository.FindByExactName(sitemapName, ColumnSetInstances.None);

            if (entity != null)
            {
                FillSolutionComponentInternal(result, entity.Id, behavior);
            }
        }
        private async Task <Tuple <bool, SiteMap> > GetSiteMapByAttribute(IOrganizationServiceExtented service, CommonConfiguration commonConfig, string siteMapNameUnique)
        {
            var repositorySiteMap = new SiteMapRepository(service);

            var siteMap = await repositorySiteMap.FindByExactNameAsync(siteMapNameUnique ?? string.Empty, ColumnSetInstances.AllColumns);

            if (siteMap == null)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionSiteMapWasNotFoundFormat2, service.ConnectionData.Name, SiteMap.Schema.EntityLogicalName, siteMapNameUnique);
                this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData);

                WindowHelper.OpenExportSiteMapExplorer(_iWriteToOutput, service, commonConfig, siteMapNameUnique);
            }

            return(Tuple.Create(siteMap != null, siteMap));
        }
        private async Task ShowExistingSiteMaps()
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ConnectionData connectionData = GetSelectedConnection();

            ToggleControls(connectionData, false, Properties.OutputStrings.LoadingSiteMaps);

            this.Dispatcher.Invoke(() =>
            {
                this._itemsSource.Clear();
            });

            IEnumerable <SiteMap> list = Enumerable.Empty <SiteMap>();

            try
            {
                var service = await GetService();

                if (service != null)
                {
                    var repository = new SiteMapRepository(service);

                    list = await repository.GetListAsync(new ColumnSet(SiteMap.EntityPrimaryIdAttribute, SiteMap.Schema.Attributes.sitemapname, SiteMap.Schema.Attributes.sitemapnameunique));
                }
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(connectionData, ex);
            }

            string textName = string.Empty;

            txtBFilter.Dispatcher.Invoke(() =>
            {
                textName = txtBFilter.Text.Trim().ToLower();
            });

            list = FilterList(list, textName);

            LoadSiteMaps(list);

            ToggleControls(connectionData, true, Properties.OutputStrings.LoadingSiteMapsCompletedFormat1, list.Count());
        }
        private async Task PerformExportEntityDescription(string folder, Guid idSiteMap, string name, string nameUnique)
        {
            var service = await GetService();

            if (service == null)
            {
                return;
            }

            ToggleControls(service.ConnectionData, false, Properties.OutputStrings.CreatingEntityDescription);

            try
            {
                string fileName = EntityFileNameFormatter.GetSiteMapFileName(service.ConnectionData.Name, name, idSiteMap, EntityFileNameFormatter.Headers.EntityDescription, FileExtension.txt);
                string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName));

                var repository = new SiteMapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, ColumnSetInstances.AllColumns);

                await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, sitemap, service.ConnectionData);

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedEntityDescriptionFormat3
                                                   , service.ConnectionData.Name
                                                   , sitemap.LogicalName
                                                   , filePath);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingEntityDescriptionCompleted);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingEntityDescriptionFailed);
            }
        }
        private async Task PerformExportXmlToFile(string folder, Guid idSiteMap, string name, string nameUnique, string fieldName, string fieldTitle)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            var service = await GetService();

            if (service == null)
            {
                return;
            }

            ToggleControls(service.ConnectionData, false, Properties.OutputStrings.ExportingXmlFieldToFileFormat1, fieldTitle);

            try
            {
                var repository = new SiteMapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, new ColumnSet(fieldName));

                string xmlContent = sitemap.GetAttributeValue <string>(fieldName);

                string filePath = await CreateFileAsync(folder, name, nameUnique, idSiteMap, fieldTitle, xmlContent);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.ExportingXmlFieldToFileCompletedFormat1, fieldName);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.ExportingXmlFieldToFileFailedFormat1, fieldName);
            }
        }
Esempio n. 13
0
        public JsonResult SiteJson(string urladdress)
        {
            SiteMapUrl           siteMapUrl        = new SiteMapUrl();
            SiteMapRepository    siteMapRepository = new SiteMapRepository();
            string               massage;
            IEnumerable <string> listSite    = new List <string>();
            SiteMapDoc           siteMapDoc  = new SiteMapDoc();
            TestSiteMap          testSiteMap = new TestSiteMap();
            MapSite              mapSite     = new MapSite();

            try
            {
                listSite         = siteMapDoc.ParseSitemapFile(urladdress); // список страниц
                mapSite.NameSite = urladdress;
                testSiteMap.TestSites(listSite, mapSite);                   //Для наглядности работоспособности сайта используеться первые 20 линков
                siteMapRepository.Create(mapSite);
                return(Json(mapSite.SiteMapUrls.OrderBy(m => m.TimeOut), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                massage = ex.Message;
                return(Json(massage, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 14
0
        const int SessionThreshold = 300;  // sessions elapse after 5 minutes

        public static List <WebSession> ProcessRecords(SiteMapRepository siteMapRepository, List <WebSession> dbSessions, CollectorRecord collectorRecord)
        {
            // working sessions list
            var sessions = new List <WebSession>();

            // set of WebSession references that have been modified or added
            var resultSessions = new List <WebSession>();
            var recordList     = collectorRecord.RecordList.OrderBy(r => r.Timestamp).ToList();

            // terminate all sessions that aren't "in progress"
            var firstRecord = recordList.First();
            var timestamp   = Convert.ToDateTime(firstRecord.Timestamp);

            if (dbSessions != null && dbSessions.Count() > 0)
            {
                foreach (var s in dbSessions)
                {
                    var sessionStart = Convert.ToDateTime(s.Start);
                    if (s.InProgress == true && timestamp > sessionStart + TimeSpan.FromSeconds(SessionThreshold))
                    {
                        // session is no longer in progress - mark it for update
                        s.InProgress = false;
                        resultSessions.Add(s);
                    }
                    else
                    {
                        // add it to the working session list
                        sessions.Add(s);
                    }
                }
            }

            foreach (var record in recordList)
            {
                // get the sitemap for this site and skip if the site is suppressed
                var siteMap = siteMapRepository.GetSiteMapping(record.WebsiteName);
                if (siteMap == null)
                {
                    continue;
                }

                // find an in-progress session
                var session = sessions.LastOrDefault(s =>
                                                     s.Device.DeviceId == collectorRecord.DeviceId &&
                                                     s.Site == siteMap.Site &&
                                                     s.InProgress == true);
                if (session == null)
                {
                    var newSession = new WebSession()
                    {
                        UserId   = collectorRecord.UserId,
                        DeviceId = collectorRecord.DeviceId,
                        Device   = new Device()
                        {
                            DeviceId = collectorRecord.DeviceId, Hostname = collectorRecord.DeviceName, UserId = collectorRecord.UserId
                        },
                        Site       = siteMap.Site,
                        Category   = siteMap.Category,
                        Start      = record.Timestamp,
                        Duration   = record.Duration,
                        InProgress = true
                    };
                    sessions.Add(newSession);
                    resultSessions.Add(newSession);
                }
                else
                {
                    var recordTimestamp = Convert.ToDateTime(record.Timestamp);
                    var sessionStart    = Convert.ToDateTime(session.Start);
                    var sessionCurrent  = sessionStart + TimeSpan.FromSeconds(session.Duration);

                    // is this a new session?
                    if (recordTimestamp > sessionCurrent + TimeSpan.FromSeconds(SessionThreshold))
                    {
                        // terminate the current session and add it to the result session list
                        session.InProgress = false;
                        if (!resultSessions.Contains(session))
                        {
                            resultSessions.Add(session);
                        }

                        // create a new session
                        var newSession = new WebSession()
                        {
                            UserId   = collectorRecord.UserId,
                            DeviceId = collectorRecord.DeviceId,
                            Device   = new Device()
                            {
                                DeviceId = collectorRecord.DeviceId, Hostname = collectorRecord.DeviceName, UserId = collectorRecord.UserId
                            },
                            Site       = siteMap.Site,
                            Category   = siteMap.Category,
                            Start      = record.Timestamp,
                            Duration   = record.Duration,
                            InProgress = true
                        };
                        sessions.Add(newSession);
                        resultSessions.Add(newSession);
                    }
                    else
                    {
                        // extend the session
                        int duration = 0;
                        if (recordTimestamp < sessionStart)
                        {
                            // handle the case where the current record somehow predates the existing session
                            session.Start = record.Timestamp;
                            sessionStart  = recordTimestamp;
                            duration      = session.Duration > record.Duration ? session.Duration : record.Duration;
                        }
                        else
                        {
                            // normal processing - just calculate the delta between the new record timestamp and the session start, and add the duration
                            // also ensure that the resulting duration isn't smaller than the existing session duration
                            var delta = (int)(recordTimestamp - sessionStart).TotalSeconds + record.Duration;
                            duration = delta > session.Duration ? delta : session.Duration;
                        }
                        session.Duration = duration;

                        // add it to the result session list if not there already
                        if (!resultSessions.Contains(session))
                        {
                            resultSessions.Add(session);
                        }
                    }
                }
            }

            return(resultSessions);
        }
        private async Task PerformUpdateEntityField(string folder, Guid idSiteMap, string name, string nameUnique, string fieldName, string fieldTitle)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            var service = await GetService();

            if (service == null)
            {
                return;
            }

            ToggleControls(service.ConnectionData, false, Properties.OutputStrings.InConnectionUpdatingFieldFormat2, service.ConnectionData.Name, fieldName);

            try
            {
                var repository = new SiteMapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, new ColumnSet(fieldName));

                string xmlContent = sitemap.GetAttributeValue <string>(fieldName);

                await CreateFileAsync(folder, name, nameUnique, idSiteMap, fieldTitle + " BackUp", xmlContent);

                var newText = string.Empty;

                {
                    bool?dialogResult = false;

                    this.Dispatcher.Invoke(() =>
                    {
                        var form = new WindowTextField("Enter " + fieldTitle, fieldTitle, xmlContent);

                        dialogResult = form.ShowDialog();

                        newText = form.FieldText;
                    });

                    if (dialogResult.GetValueOrDefault() == false)
                    {
                        ToggleControls(service.ConnectionData, true, Properties.OutputStrings.InConnectionUpdatingFieldCanceledFormat2, service.ConnectionData.Name, fieldName);
                        return;
                    }
                }

                newText = ContentComparerHelper.RemoveInTextAllCustomXmlAttributesAndNamespaces(newText);

                UpdateStatus(service.ConnectionData, Properties.OutputStrings.ValidatingXmlForFieldFormat1, fieldName);

                if (!ContentComparerHelper.TryParseXmlDocument(newText, out var doc))
                {
                    ToggleControls(service.ConnectionData, true, Properties.OutputStrings.TextIsNotValidXml);

                    _iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
                    return;
                }

                bool validateResult = await SiteMapRepository.ValidateXmlDocumentAsync(service.ConnectionData, _iWriteToOutput, doc);

                if (!validateResult)
                {
                    var dialogResult = MessageBoxResult.Cancel;

                    this.Dispatcher.Invoke(() =>
                    {
                        dialogResult = MessageBox.Show(Properties.MessageBoxStrings.ContinueOperation, Properties.MessageBoxStrings.QuestionTitle, MessageBoxButton.OKCancel, MessageBoxImage.Question);
                    });

                    if (dialogResult != MessageBoxResult.OK)
                    {
                        ToggleControls(service.ConnectionData, true, Properties.OutputStrings.ValidatingXmlForFieldFailedFormat1, fieldName);
                        _iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
                        return;
                    }
                }

                newText = doc.ToString(SaveOptions.DisableFormatting);

                var updateEntity = new SiteMap
                {
                    Id = idSiteMap
                };
                updateEntity.Attributes[fieldName] = newText;

                await service.UpdateAsync(updateEntity);

                UpdateStatus(service.ConnectionData, Properties.OutputStrings.InConnectionPublishingSiteMapFormat3, service.ConnectionData.Name, name, idSiteMap.ToString());

                {
                    var repositoryPublish = new PublishActionsRepository(service);

                    await repositoryPublish.PublishSiteMapsAsync(new[] { idSiteMap });
                }

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.InConnectionUpdatingFieldCompletedFormat2, service.ConnectionData.Name, fieldName);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);

                ToggleControls(service.ConnectionData, true, Properties.OutputStrings.InConnectionUpdatingFieldFailedFormat2, service.ConnectionData.Name, fieldName);
            }
        }
Esempio n. 16
0
        private async Task ShowExistingSiteMaps()
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.OutputStrings.LoadingSiteMaps);

            this.Dispatcher.Invoke(() =>
            {
                this._itemsSource.Clear();
            });

            IEnumerable <LinkedEntities <SiteMap> > list = Enumerable.Empty <LinkedEntities <SiteMap> >();

            try
            {
                var service1 = await GetService1();

                var service2 = await GetService2();

                if (service1 != null && service2 != null)
                {
                    var columnSet = new ColumnSet(SiteMap.EntityPrimaryIdAttribute, SiteMap.Schema.Attributes.sitemapname, SiteMap.Schema.Attributes.sitemapnameunique);

                    List <LinkedEntities <SiteMap> > temp = new List <LinkedEntities <SiteMap> >();

                    if (service1.ConnectionData.ConnectionId != service2.ConnectionData.ConnectionId)
                    {
                        var repository1 = new SiteMapRepository(service1);
                        var repository2 = new SiteMapRepository(service2);

                        var task1 = repository1.GetListAsync(columnSet);
                        var task2 = repository2.GetListAsync(columnSet);

                        var list1 = await task1;
                        var list2 = await task2;

                        foreach (var sitemap1 in list1)
                        {
                            var sitemap2 = list2.FirstOrDefault(c => string.Equals(c.SiteMapNameUnique ?? string.Empty, sitemap1.SiteMapNameUnique ?? string.Empty));

                            if (sitemap2 == null)
                            {
                                continue;
                            }

                            temp.Add(new LinkedEntities <SiteMap>(sitemap1, sitemap2));
                        }
                    }
                    else
                    {
                        var repository1 = new SiteMapRepository(service1);

                        var task1 = repository1.GetListAsync(columnSet);

                        var list1 = await task1;

                        foreach (var sitemap1 in list1)
                        {
                            temp.Add(new LinkedEntities <SiteMap>(sitemap1, null));
                        }
                    }

                    list = temp;
                }
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(null, ex);
            }

            var textName = string.Empty;

            txtBFilter.Dispatcher.Invoke(() =>
            {
                textName = txtBFilter.Text.Trim().ToLower();
            });

            list = FilterList(list, textName);

            LoadEntities(list);
        }
Esempio n. 17
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(_configuration);
            services.AddSingleton(_hostingEnvironment);

            services.AddApplicationInsightsTelemetry(_configuration);

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDatabaseDeveloperPageExceptionFilter();
            services.AddDbContext <RepoContext>();

            services.AddControllersWithViews()
            .AddRazorRuntimeCompilation()
            .AddXmlSerializerFormatters();

            services.AddLogging();

            services.AddScoped <IRepoRepository, RepoRepository>();
            services.AddScoped <IArticleRepository, ArticleRepository>();

            var blogRepo = new BlogRepository(_configuration["BlogUrl"]);

            services.AddSingleton <IBlogRepository>(blogRepo);
            services.AddSingleton <IRedirectRepository>(new RedirectRepository(new System.Collections.Generic.List <IRedirectRepository> {
                blogRepo
            }));

            var activityRepo = new ActivityRepository(_configuration["ActivityUrl"], _configuration["ActivityCode"]);

            services.AddSingleton <IActivityRepository>(activityRepo);

            var siteMapRepo = new SiteMapRepository(_hostingEnvironment);

            siteMapRepo.AddRepository(blogRepo);
            services.AddSingleton <ISiteMapRepository>(siteMapRepo);

            services.AddTransient <RepoContextSeedData>();

            var sendGridConfiguration = new SendGridConfiguration
            {
                ApiKey = _configuration["SendGridApiKey"],
                From   = _configuration["SendGridFromEmailAddress"]
            };

            services.AddSingleton(sendGridConfiguration);
            services.AddTransient <IEmail, SendGridEmail>();

            services.AddSingleton(new HttpClient());
            services.AddSingleton <IPodcastRespository, PodcastRespository>();

            var reCaptchaConfiguration = new ReCaptchaConfiguration
            {
                SecretKey = _configuration["ReCaptchaSecretKey"]
            };

            services.AddSingleton(reCaptchaConfiguration);
            services.AddTransient <ITokenVerification, ReCaptchaTokenVerification>();
        }