示例#1
0
        public Blog Transform(Blog blog)
        {
            _logger.LogInformation("Removing numbers from category urls...");
            foreach (var blogCategory in blog.Categories)
            {
                _logger.LogInformation($"Processing {blogCategory.Url}...");

                var newUrl = LinkUtils.MakeFriendly(blogCategory.Url);
                blogCategory.Url = newUrl;

                _logger.LogInformation($"Processed: {newUrl}");
            }

            foreach (var blogPost in blog.Posts)
            {
                _logger.LogInformation($"Processing {blogPost.Url}...");

                var newUrl = LinkUtils.MakeFriendly(blogPost.Category);
                blogPost.Category = newUrl;

                _logger.LogInformation($"Processed: {newUrl}");
            }

            _logger.LogInformation("Numbers have been removed from category urls.");
            return(blog);
        }
        private void GoToChatWebPageButton_Click(object sender,
                                                 RoutedEventArgs e)
        {
            const string link = "https://chat.apianon.ru/";

            LinkUtils.OpenLink(link);
        }
示例#3
0
        public async Task <IActionResult> CreateQuiz([FromForm] QuizInfoForCreationDto inputQuizInfo)
        {
            if (inputQuizInfo == null)
            {
                return(BadRequest(Constants.QuizDataEmpty));
            }

            var quizInfoEntity = mapper.Map <QuizInfo>(inputQuizInfo);

            if (inputQuizInfo.PreviewImage != null)
            {
                if (!FileUtils.IsPreviewValid(inputQuizInfo.PreviewImage))
                {
                    return(BadRequest(Constants.InvalidImage));
                }

                quizInfoEntity.PreviewPath = await FileUtils.SaveAsync(DirType.Previews, inputQuizInfo.PreviewImage);
            }

            string queryParam = RandomGenerator.GenerateHexKey();

            quizInfoEntity.TemporaryLink = queryParam;

            quizInfoEntity.CreatedAt = DateTime.Now;

            if (quizInfoEntity.OwnerId == null)
            {
                return(BadRequest(Constants.OwnerNull));
            }

            /*Will be changed in the future accroding to User Identity */
            quizInfoEntity.Owner = manager.Repository <User>().FindBy(u => u.Id == quizInfoEntity.OwnerId).SingleOrDefault();

            string mongoId = RandomGenerator.GenerateHexKey();

            quizInfoEntity.QuizId = mongoId;

            await manager.Repository <QuizInfo>().Create(quizInfoEntity);

            manager.Save();

            mongoId = mongo.Create(mongoId);

            if (string.IsNullOrEmpty(mongoId))
            {
                return(BadRequest(Constants.MongoDbCreationFailure(nameof(Entities.Models.Mongo.Quiz))));
            }

            var result = mapper.Map <QuizInfoForOwnerDto>(quizInfoEntity);

            var request = HttpContext.Request;

            result.TemporaryLink = LinkUtils.GenerateTemporaryLink(request.IsHttps, request.Host.Value, request.Path, queryParam);

            // It will be changed according to the User Identity
            result.HasAccessToEdit = true;

            return(CreatedAtRoute("QuizInfoById", new { id = result.Id }, result));
        }
 public static string GetDataLink(string datafile)
 {
     if (datafile.ToUpper().StartsWith("GSM"))
     {
         return(LinkUtils.GetGeoLink(datafile));
     }
     return(LinkUtils.GetGoogleLink(datafile));
 }
示例#5
0
 private Uri GetOwaBaseLink(ExchangePrincipal targetPrincipal, bool supportsIntegratedAuth)
 {
     return(LinkUtils.GetOwaBaseLink(delegate()
     {
         string item = Strings.OWAServiceUrlFailure(this.TargetMailboxUser.PrimarySmtpAddress.ToString(), "Topology service cannot find the OWA service.");
         if (!this.SearchObject.Errors.Contains(item))
         {
             this.SearchObject.Errors.Add(item);
         }
     }, targetPrincipal, supportsIntegratedAuth));
 }
示例#6
0
        public string GenerateOWAPreviewResultsLink()
        {
            ExchangePrincipal targetPrincipal = ExchangePrincipal.FromADUser(this.DiscoverySystemMailboxUser.OrganizationId.ToADSessionSettings(), this.DiscoverySystemMailboxUser);
            Uri owaBaseLink = this.GetOwaBaseLink(targetPrincipal, false);

            if (owaBaseLink != null)
            {
                return(LinkUtils.UpdateOwaLinkToSearchId(owaBaseLink, this.SearchName).ToString());
            }
            return(null);
        }
示例#7
0
        public string GenerateOWASearchResultsLink()
        {
            ExchangePrincipal targetPrincipal = ExchangePrincipal.FromADUser(this.TargetMailboxUser.OrganizationId.ToADSessionSettings(), this.TargetMailboxUser);
            Uri owaBaseLink = this.GetOwaBaseLink(targetPrincipal, false);

            if (owaBaseLink != null)
            {
                return(LinkUtils.UpdateOwaLinkWithMailbox(owaBaseLink, this.TargetMailboxUser.PrimarySmtpAddress).ToString());
            }
            return(null);
        }
        public static string GetDatasetLink(string dataset)
        {
            if (dataset.ToUpper().StartsWith("GSE"))
            {
                return(LinkUtils.GetGeoLink(dataset));
            }

            if (dataset.ToUpper().StartsWith("E-"))
            {
                return(LinkUtils.GetEbiArrayLink(dataset));
            }

            return(LinkUtils.GetGoogleLink(dataset));
        }
示例#9
0
        public Blog Transform(Blog blogDto)
        {
            _logger.LogInformation("Transforming links...");
            foreach (var blogDtoLink in blogDto.Links)
            {
                var linkedCategory = blogDto.Categories.FirstOrDefault(_ => _.Url == blogDtoLink.Url);
                if (linkedCategory != null)
                {
                    blogDtoLink.Url = CategoryPrefix + LinkUtils.MakeFriendly(blogDtoLink.Url);
                    continue;
                }

                if (string.IsNullOrEmpty(blogDtoLink.Url))
                {
                    blogDtoLink.Url = "/";
                    continue;
                }
            }

            _logger.LogInformation("Links transformed.");

            return(blogDto);
        }
        public override void Process(IList <SearchSource> item)
        {
            Recorder.Trace(4L, TraceType.InfoTrace, "CompleteSourceLookup.Process Item:", item);
            Guid guid = new Guid("aca47e7e-5bb8-43ed-976a-f3158f6d4df7");
            List <PreviewItem>       list  = new List <PreviewItem>();
            List <MailboxStatistics> list2 = new List <MailboxStatistics>();
            SearchMailboxesInputs    searchMailboxesInputs = base.Context.TaskContext as SearchMailboxesInputs;
            Uri     baseUri = new Uri("http://local/");
            StoreId value   = new VersionedId(new byte[]
            {
                3,
                1,
                2,
                3,
                3,
                1,
                2,
                3,
                byte.MaxValue
            });
            UniqueItemHash itemHash   = new UniqueItemHash(string.Empty, string.Empty, null, false);
            PagingInfo     pagingInfo = ((SearchMailboxesInputs)base.Executor.Context.Input).PagingInfo;
            ReferenceItem  sortValue  = new ReferenceItem(pagingInfo.SortBy, ExDateTime.Now, 0L);
            Dictionary <PropertyDefinition, object> properties = new Dictionary <PropertyDefinition, object>
            {
                {
                    ItemSchema.Id,
                    value
                }
            };

            foreach (SearchSource searchSource in item)
            {
                if (searchSource.MailboxInfo != null && (searchSource.MailboxInfo.MailboxGuid != Guid.Empty || searchSource.MailboxInfo.IsRemoteMailbox))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    if (searchSource.MailboxInfo != null && searchSource.MailboxInfo.MailboxGuid != Guid.Empty)
                    {
                        Dictionary <string, string> dictionary2 = dictionary;
                        string key = "Name";
                        string value2;
                        if ((value2 = searchSource.OriginalReferenceId) == null)
                        {
                            value2 = (searchSource.MailboxInfo.DisplayName ?? string.Empty);
                        }
                        dictionary2[key]   = value2;
                        dictionary["Smtp"] = (searchSource.MailboxInfo.PrimarySmtpAddress.ToString() ?? string.Empty);
                        dictionary["DN"]   = (searchSource.MailboxInfo.LegacyExchangeDN ?? string.Empty);
                    }
                    if (searchMailboxesInputs != null)
                    {
                        dictionary["Lang"]   = (searchMailboxesInputs.Language ?? string.Empty);
                        dictionary["Config"] = (searchMailboxesInputs.SearchConfigurationId ?? string.Empty);
                    }
                    Uri owaLink = LinkUtils.AppendQueryString(baseUri, dictionary);
                    Recorder.Trace(4L, TraceType.InfoTrace, new object[]
                    {
                        "CompleteSourceLookup.Process Found:",
                        searchSource.ReferenceId,
                        "MailboxInfo:",
                        searchSource.MailboxInfo
                    });
                    list.Add(new PreviewItem(properties, (searchSource.MailboxInfo.MailboxGuid != Guid.Empty) ? searchSource.MailboxInfo.MailboxGuid : guid, owaLink, sortValue, itemHash)
                    {
                        MailboxInfo = searchSource.MailboxInfo
                    });
                    list2.Add(new MailboxStatistics(searchSource.MailboxInfo, 0UL, new ByteQuantifiedSize(0UL)));
                }
            }
            SortedResultPage resultPage   = new SortedResultPage(list.ToArray(), pagingInfo);
            ISearchResult    searchResult = new ResultAggregator(resultPage, null, 0UL, new ByteQuantifiedSize(0UL), null, null, list2);

            base.Executor.EnqueueNext(new SearchMailboxesResults(item)
            {
                SearchResult = searchResult
            });
        }
        private void ProcessGlobalSearch(SearchDocumentsRequest nextDocumentsRequest)
        {
            if (nextDocumentsRequest.GlobalResults != null)
            {
                if (nextDocumentsRequest.GlobalResults.Count > 0)
                {
                    BeginOnUIThread(() =>
                    {
                        if (nextDocumentsRequest.IsCanceled)
                        {
                            return;
                        }

                        foreach (var result in nextDocumentsRequest.GlobalResults)
                        {
                            Items.Add((TLMessage)result);
                        }
                        NotifyOfPropertyChange(() => IsEmptyList);
                        Status = Items.Count > 0 ? string.Empty : AppResources.NoResults;
                    });
                }
            }
            else
            {
                IsWorking = true;
                MTProtoService.SearchAsync(nextDocumentsRequest.InputPeer, new TLString(nextDocumentsRequest.Text), new TLInputMessagesFilterUrl(), new TLInt(0), new TLInt(0), new TLInt(0), new TLInt(0), new TLInt(100),
                                           result =>
                {
                    LinkUtils.ProcessLinks(result.Messages, _mediaWebPagesCache);

                    nextDocumentsRequest.GlobalResults = new List <TLMessageBase>(result.Messages.Count);

                    foreach (var message in result.Messages)
                    {
                        if (nextDocumentsRequest.ResultsIndex == null ||
                            !nextDocumentsRequest.ResultsIndex.ContainsKey(message.Index))
                        {
                            nextDocumentsRequest.GlobalResults.Add(message);
                        }
                    }


                    BeginOnUIThread(() =>
                    {
                        IsWorking = false;
                        if (nextDocumentsRequest.IsCanceled)
                        {
                            return;
                        }

                        if (nextDocumentsRequest.GlobalResults.Count > 0)
                        {
                            foreach (var message in nextDocumentsRequest.GlobalResults)
                            {
                                Items.Add((TLMessage)message);
                            }
                            NotifyOfPropertyChange(() => IsEmptyList);
                        }

                        Status = Items.Count > 0 ? string.Empty : AppResources.NoResults;
                    });
                },
                                           error => BeginOnUIThread(() =>
                {
                    IsWorking = false;

                    if (TLRPCError.CodeEquals(error, ErrorCode.BAD_REQUEST) &&
                        TLRPCError.TypeEquals(error, ErrorType.QUERY_TOO_SHORT))
                    {
                        nextDocumentsRequest.GlobalResults = new List <TLMessageBase>();
                    }
                    else if (TLRPCError.CodeEquals(error, ErrorCode.FLOOD))
                    {
                        nextDocumentsRequest.GlobalResults = new List <TLMessageBase>();
                        BeginOnUIThread(() => MessageBox.Show(AppResources.FloodWaitString + Environment.NewLine + "(" + error.Message + ")", AppResources.Error, MessageBoxButton.OK));
                    }

                    Execute.ShowDebugMessage("messages.search error " + error);
                }));
            }
        }