コード例 #1
0
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
 public void Test_GetUrlList()
 {
     UrlService service = new UrlService();
     Dto<Url> results = service.GetUrlList();
     Assert.IsNotNull(results);
     Assert.IsNotNull(results.Entities);
     Assert.IsTrue(results.TotalRows > 0);
 }
コード例 #2
0
ファイル: ApiService.cs プロジェクト: ApiNetworks/iAFWeb
        public object ExpandUrl(UrlRequest request)
        {
            if (!request.ShortId.IsShortCode())
                throw new ArgumentNullException(request.ShortId);

            UrlService service = new UrlService();
            var dbResponse = service.ExpandUrl(request.ShortId);
            return Mapper.MapResponse(dbResponse);
        }
コード例 #3
0
        public static void ResolveUrl(Url url)
        {
            Task.Factory.StartNew((u) =>
                {
                    try
                    {
                        UrlService urlService = new UrlService();
                        if (url != null)
                        {
                            urlService.ResolveResponseUrl(url);
                        }
                    }
                    catch
                    {

                    }
                },
                url);
        }
コード例 #4
0
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        public void Test_Get_Items_By_ShortId()
        {
            UrlService service = new UrlService();

            Stopwatch stopwatch = new Stopwatch();

            // Begin timing
            stopwatch.Start();

            Parallel.For(0, 1000, i =>
            {
                Url url = service.ExpandUrl(i.ToString());
            });

            // Stop timing
            stopwatch.Stop();

            // Write result
            string response = stopwatch.Elapsed.TotalMilliseconds.ToString();

            Assert.Inconclusive(response);
        }
コード例 #5
0
ファイル: ApiService.cs プロジェクト: ApiNetworks/iAFWeb
        public object ShortenUrl(UrlRequest request)
        {
            if (String.IsNullOrEmpty(request.Url))
                throw new ArgumentNullException(request.Url);

            Uri uri;
            if (Uri.TryCreate(request.Url, UriKind.Absolute, out uri) == false)
                throw new ArgumentNullException(request.Url);

            if (uri.AbsoluteUri.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) == false
                && uri.AbsoluteUri.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase) == false
                && uri.AbsoluteUri.StartsWith("ftp", StringComparison.InvariantCultureIgnoreCase) == false)
                throw new ArgumentException(request.Url);

            Url entity = new Url();
            entity.Href = uri.AbsoluteUri;
            iAFWebHost.Entities.Url dbEntity = Mapper.MapResponse(entity);

            UrlService service = new UrlService();
            iAFWebHost.Entities.Url dbResponse = service.ShortenUrl(dbEntity);
            entity = Mapper.MapResponse(dbResponse);

            return entity;
        }
コード例 #6
0
ファイル: PostsController.cs プロジェクト: sirems/SpringBlog
 public ActionResult New(NewPostViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Post post = new Post
         {
             CategoryId       = vm.CategoryId,
             Title            = vm.Title,
             Content          = vm.Content,
             AuthorId         = User.Identity.GetUserId(),
             Slug             = UrlService.URLFriendly(vm.Slug),
             CreateTime       = DateTime.Now,
             ModificationTime = DateTime.Now,
             PhotoPath        = this.SaveImage(vm.FeaturedImage)
         };
         db.Posts.Add(post);
         db.SaveChanges();
         TempData["SuccessMessage"] = "The post has been created successfully!";
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId =
         new SelectList(db.Categories.OrderBy(x => x.CategoryName).ToList(), "Id", "CategoryName");
     return(View());
 }
コード例 #7
0
        private async Task PopulateUrlRecordsFor <T>(IEnumerable <T> entities)
            where T : BaseEntity, ISlugSupported, new()
        {
            using (var scope = UrlService.CreateBatchScope())
            {
                foreach (var entity in entities)
                {
                    var ur = _data.CreateUrlRecordFor(entity);
                    if (ur != null)
                    {
                        scope.ApplySlugs(new ValidateSlugResult
                        {
                            Source      = entity,
                            Found       = ur,
                            Slug        = ur.Slug,
                            LanguageId  = 0,
                            FoundIsSelf = true,
                        });
                    }
                }

                await scope.CommitAsync();
            }
        }
コード例 #8
0
        public ActionResult Index(string username, AccountDetailsView detailsView)
        {
            IDictionary <string, string> crumbs = GetBreadCrumbs("details", UrlService.UserUrl("account"));

            if (ModelState.IsValid)
            {
                detailsView.Password = _cryptographyService.Encrypt(detailsView.Password);
                Domain.Model.User savedUser = detailsView.GetUser();
                savedUser.Settings = Owner.Settings;
                savedUser.Id       = Owner.Id;
                _userRepository.Save(savedUser);

                detailsView.UIMessage           = "Account details saved.";
                detailsView.Password            = _cryptographyService.Decrypt(savedUser.Password);
                detailsView                     = SetAuthorizationAndUrlService(detailsView);
                detailsView.Authorization.Owner = savedUser;
            }
            else
            {
                ValidationHelper.ValidationHackRemoveNameAndBlankKey(ModelState);
            }

            return(View(detailsView, crumbs));
        }
コード例 #9
0
        public OrderViewModelBuilder(
            RequestModelAccessor requestModelAccessor,
            FieldDefinitionService fieldDefinitionService,
            PageService pageServcie,
            UrlService urlService,
            ProductModelBuilder productModelBuilder,
            VariantService variantService,
            UnitOfMeasurementService unitOfMeasurementService,
            OrganizationService organizationService,
            PersonStorage personStorage,
            OrderOverviewService orderOverviewService,
            ChannelService channelService,
            CurrencyService currencyService,
            ShippingProviderService shippingProviderService,
            StateTransitionsService stateTransitionsService,
            CountryService countryService,
            OrderHelperService orderHelperService)
        {
            _requestModelAccessor   = requestModelAccessor;
            _fieldDefinitionService = fieldDefinitionService;
            _pageServcie            = pageServcie;
            _urlService             = urlService;

            _productModelBuilder      = productModelBuilder;
            _variantService           = variantService;
            _unitOfMeasurementService = unitOfMeasurementService;
            _organizationService      = organizationService;
            _personStorage            = personStorage;
            _orderOverviewService     = orderOverviewService;
            _channelService           = channelService;
            _currencyService          = currencyService;
            _countryService           = countryService;
            _orderHelperService       = orderHelperService;
            _shippingProviderService  = shippingProviderService;
            _stateTransitionsService  = stateTransitionsService;
        }
コード例 #10
0
ファイル: ModulePage.aspx.cs プロジェクト: gkovalev/nastia
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request["ModuleId"]))
        {
            Response.Redirect("");
        }

        var module = AttachedModules.GetModules(AttachedModules.EModuleType.ClientPage).FirstOrDefault(
            item => ((IClientPageModule)Activator.CreateInstance(item, null)).ModuleStringId == Request["ModuleId"]);

        if (module != null)
        {
            var moduleObject = (IClientPageModule)Activator.CreateInstance(module, null);

            var userControl =
                (this).LoadControl(
                    UrlService.GetAbsoluteLink(string.Format("/Modules/{0}/{1}", moduleObject.ModuleStringId,
                                                             moduleObject.ClientPageControlFileName)));

            if (userControl != null)
            {
                pnlContent.Controls.Add(userControl);
            }

            SetMeta(new MetaInfo
            {
                Title           = moduleObject.PageTitle,
                MetaDescription = moduleObject.MetaDescription,
                MetaKeywords    = moduleObject.MetaKeyWords
            }, "");
        }
        else
        {
            Response.Redirect(UrlService.GetAdminAbsoluteLink(""));
        }
    }
コード例 #11
0
 public NavigationViewModelBuilder(RequestModelAccessor requestModelAccessor,
                                   CategoryService categoryService,
                                   PageService pageService,
                                   UrlService urlService,
                                   PageByFieldTemplateCache <MegaMenuPageFieldTemplateCache> pageByFieldType,
                                   AuthorizationService authorizationService,
                                   FilterService filterService,
                                   ContentProcessorService contentProcessorService,
                                   FilterAggregator filterAggregator,
                                   RouteRequestInfoAccessor routeRequestInfoAccessor)
 {
     _requestModelAccessor     = requestModelAccessor;
     _categoryService          = categoryService;
     _pageService              = pageService;
     _urlService               = urlService;
     _pageByFieldType          = pageByFieldType;
     _authorizationService     = authorizationService;
     _filterService            = filterService;
     _contentProcessorService  = contentProcessorService;
     _filterAggregator         = filterAggregator;
     _routeRequestInfoAccessor = routeRequestInfoAccessor;
     _channelSystemId          = _requestModelAccessor.RequestModel.ChannelModel.SystemId;
     _websiteSystemId          = _requestModelAccessor.RequestModel.WebsiteModel.SystemId;
 }
コード例 #12
0
        protected override void Seed(BlogFall.Models.ApplicationDbContext context)
        {
            var autoGenerateSlugs    = false;
            var autoGeneretaSlugsAll = false;

            ////tüm kullanýcýlarý aktif yapar
            //foreach (var item in context.Users)
            //{
            //    item.IsEnabled = true;
            //}
            //return;

            #region Admin Rolünü ve Kullanýcýsýný Oluþtur
            if (!context.Roles.Any(r => r.Name == "Admin"))
            {
                var store   = new RoleStore <IdentityRole>(context);
                var manager = new RoleManager <IdentityRole>(store);
                var role    = new IdentityRole {
                    Name = "Admin"
                };

                manager.Create(role);
            }

            if (!context.Users.Any(u => u.UserName == "*****@*****.**"))
            {
                var store   = new UserStore <ApplicationUser>(context);
                var manager = new UserManager <ApplicationUser>(store);
                var user    = new ApplicationUser
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                manager.Create(user, "Atahan1.");
                manager.AddToRole(user.Id, "Admin");

                //Oluþturulan bu kullanýcýya ait yazýlar ekleyelim:
                #region Kategoriler ve Yazýlar
                if (!context.Categories.Any())
                {
                    Category cat1 = new Category
                    {
                        CategoryName = "Gezi Yazýlarý"
                    };

                    cat1.Posts = new List <Post>();

                    cat1.Posts.Add(new Post
                    {
                        Title        = "Gezi Yazýsý 1",
                        AuthorId     = user.Id,
                        Content      = @"<p>Tincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel.</p>
<p>Placerat suscipit, orci nisl iaculis eros, a tincidunt nisi odio eget lorem nulla condimentum tempor mattis ut vitae feugiat augue cras ut metus a risus iaculis scelerisque eu ac ante.</p>
<p>Fusce non varius purus aenean nec magna felis fusce vestibulum velit mollis odio sollicitudin lacinia aliquam posuere, sapien elementum lobortis tincidunt, turpis dui ornare nisl, sollicitudin interdum turpis nunc eget.</p>",
                        CreationTime = DateTime.Now
                    });

                    cat1.Posts.Add(new Post
                    {
                        Title        = "Gezi Yazýsý 2",
                        AuthorId     = user.Id,
                        Content      = @"<p>Tincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel.</p>
<p>Placerat suscipit, orci nisl iaculis eros, a tincidunt nisi odio eget lorem nulla condimentum tempor mattis ut vitae feugiat augue cras ut metus a risus iaculis scelerisque eu ac ante.</p>
<p>Fusce non varius purus aenean nec magna felis fusce vestibulum velit mollis odio sollicitudin lacinia aliquam posuere, sapien elementum lobortis tincidunt, turpis dui ornare nisl, sollicitudin interdum turpis nunc eget.</p>",
                        CreationTime = DateTime.Now
                    });

                    Category cat2 = new Category
                    {
                        CategoryName = "Ýþ Yazýlarý"
                    };

                    cat2.Posts = new List <Post>();

                    cat2.Posts.Add(new Post
                    {
                        Title        = "Ýþ Yazýsý 1",
                        AuthorId     = user.Id,
                        Content      = @"<p>Tincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel.</p>
<p>Placerat suscipit, orci nisl iaculis eros, a tincidunt nisi odio eget lorem nulla condimentum tempor mattis ut vitae feugiat augue cras ut metus a risus iaculis scelerisque eu ac ante.</p>
<p>Fusce non varius purus aenean nec magna felis fusce vestibulum velit mollis odio sollicitudin lacinia aliquam posuere, sapien elementum lobortis tincidunt, turpis dui ornare nisl, sollicitudin interdum turpis nunc eget.</p>",
                        CreationTime = DateTime.Now
                    });

                    cat2.Posts.Add(new Post
                    {
                        Title        = "Ýþ Yazýsý 2",
                        AuthorId     = user.Id,
                        Content      = @"<p>Tincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel.</p>
<p>Placerat suscipit, orci nisl iaculis eros, a tincidunt nisi odio eget lorem nulla condimentum tempor mattis ut vitae feugiat augue cras ut metus a risus iaculis scelerisque eu ac ante.</p>
<p>Fusce non varius purus aenean nec magna felis fusce vestibulum velit mollis odio sollicitudin lacinia aliquam posuere, sapien elementum lobortis tincidunt, turpis dui ornare nisl, sollicitudin interdum turpis nunc eget.</p>",
                        CreationTime = DateTime.Now
                    });

                    context.Categories.Add(cat1);
                    context.Categories.Add(cat2);
                }
                #endregion
            }
            #endregion

            #region Admin kullanýcýsýna 77 yeni yazý ekle
            if (!context.Categories.Any(x => x.CategoryName == "Diðer"))
            {
                ApplicationUser admin = context.Users.Where(x => x.UserName == "*****@*****.**").FirstOrDefault();

                if (admin != null)
                {
                    if (!context.Categories.Any(x => x.CategoryName == "Diðer"))
                    {
                        Category diger = new Category
                        {
                            CategoryName = "Diðer",
                            Posts        = new HashSet <Post>()
                        };

                        for (int i = 1; i <= 77; i++)
                        {
                            diger.Posts.Add(new Post
                            {
                                Title        = "Diðer Yazý " + i,
                                AuthorId     = admin.Id,
                                Content      = @"<p>Tincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel.</p>
<p>Placerat suscipit, orci nisl iaculis eros, a tincidunt nisi odio eget lorem nulla condimentum tempor mattis ut vitae feugiat augue cras ut metus a risus iaculis scelerisque eu ac ante.</p>",
                                CreationTime = DateTime.Now.AddMinutes(i)
                            });
                        }

                        context.Categories.Add(diger);
                    }
                }
            }
            #endregion

            #region Mevcut kategori ve yazýlarýn slug'larýný oluþtur
            if (autoGenerateSlugs)
            {
                foreach (var item in context.Categories)
                {
                    if (autoGeneretaSlugsAll || string.IsNullOrEmpty(item.Slug))
                    {
                        item.Slug = UrlService.URLFriendly(item.CategoryName);
                    }
                }

                foreach (var item in context.Posts)
                {
                    if (autoGeneretaSlugsAll || string.IsNullOrEmpty(item.Slug))
                    {
                        item.Slug = UrlService.URLFriendly(item.Title);
                    }
                }
            }
            #endregion
        }
コード例 #13
0
 public SampleRequestClient(UrlService urlService, BookChapterClientService client)
 {
     _urlService = urlService;
     _client     = client;
 }
コード例 #14
0
    protected bool ValidateInput()
    {
        string synonym = txtSynonym.Text;

        if (string.IsNullOrEmpty(synonym))
        {
            MsgErr(Resource.Admin_StaticPage_URLIsRequired);
            return(false);
        }
        var r = new Regex("^[a-zA-Z0-9_-]*$");

        if (!r.IsMatch(synonym))
        {
            MsgErr(Resource.Admin_m_Category_SynonymInfo);
            return(false);
        }
        if (StaticPageId == 0 ? !UrlService.IsAvalibleUrl(ParamType.StaticPage, synonym) : !UrlService.IsAvalibleUrl(StaticPageId, ParamType.StaticPage, synonym))
        {
            MsgErr(Resource.Admin_SynonymExist);
            return(false);
        }

        if (string.IsNullOrEmpty(txtPageName.Text))
        {
            MsgErr(Resource.Client_AuxView_EnterTitle);
            return(false);
        }

        if (string.IsNullOrEmpty(fckPageText.Text))
        {
            MsgErr(Resource.Client_AuxView_EnterText);
            return(false);
        }

        int ti;

        if (!Int32.TryParse(txtSortOrder.Text, out ti))
        {
            txtSortOrder.Text = "0";
        }
        return(true);
    }
コード例 #15
0
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        public void Test_Get_Item_By_LongId()
        {
            UrlService service = new UrlService();

            Stopwatch stopwatch = new Stopwatch();

            // Begin timing
            stopwatch.Start();

            Url url = service.ExpandUrl(((ulong)45).EncodeBase58());

            // Stop timing
            stopwatch.Stop();

            // Write result
            string response = stopwatch.Elapsed.TotalMilliseconds.ToString();

            Assert.Inconclusive(response);
        }
コード例 #16
0
ファイル: JobWord.cs プロジェクト: git-thinh/ben
        void test_run_v1(string word)
        {
            word = "forget";
            string url = string.Empty;

            //UrlService.GetAsync("https://dictionary.cambridge.org/dictionary/english/forget", (stream) =>
            //{
            //    oWordDefine wo = new oWordDefine(text);
            //    object rs = null;
            //    string s = string.Empty;
            //    using (var reader = new StreamReader(stream, Encoding.UTF8))
            //        s = reader.ReadToEnd();
            //    if (s.Length > 0)
            //        s = HttpUtility.HtmlDecode(s);
            //    if (s.Length > 0)
            //    {
            //        if (s.Contains(@"<span class=""ipa"">"))
            //            wo.PronunceUK = s.Split(new string[] { @"<span class=""ipa"">" }, StringSplitOptions.None)[1].Split('<')[0].Trim();

            //    }
            //    else return new UrlAnanyticResult() { Message = "Can not read" };
            //    return new UrlAnanyticResult() { Ok = true, Html = s, Result = wo };
            //}, (result) =>
            //{
            //    if (result.Result != null)
            //    {

            //    }
            //});

            url = string.Format("https://www.oxfordlearnersdictionaries.com/definition/english/{0}?q={0}", word);
            //url = "https://en.oxforddictionaries.com/definition/forget";
            UrlService.GetAsync(url, (stream) =>
            {
                oWordDefine wo = new oWordDefine(word);
                object rs      = null;
                string s       = string.Empty;
                using (var reader = new StreamReader(stream, Encoding.UTF8))
                    s = reader.ReadToEnd();
                if (s.Length > 0)
                {
                    s = HttpUtility.HtmlDecode(s);
                }
                if (s.Length > 0)
                {
                    #region

                    const char heading_char   = '#'; // ■ ≡ ¶ ■
                    const string heading_text = "\r\n# ";

                    string htm = s, pro = string.Empty, type = string.Empty, mean_en = word.ToUpper();

                    HtmlNode nodes = f_word_speak_getPronunciationFromOxford_Nodes(htm);
                    pro            = nodes.QuerySelectorAll("span[class=\"phon\"]").Select(x => x.InnerText).Where(x => !string.IsNullOrEmpty(x)).Take(1).SingleOrDefault();
                    type           = nodes.QuerySelectorAll("span[class=\"pos\"]").Select(x => x.InnerText).Where(x => !string.IsNullOrEmpty(x)).Take(1).SingleOrDefault();
                    string[] pro_s = nodes.QuerySelectorAll("span[class=\"vp-g\"]").Select(x => x.InnerText).Where(x => !string.IsNullOrEmpty(x))
                                     .Select(x => x.Replace(" BrE BrE", " = UK: ").Replace("; NAmE NAmE", "US: ").Replace("//", "/")).ToArray();
                    string[] word_links = pro_s.Select(x => x.Split('=')[0].Trim()).ToArray();
                    if (pro == null)
                    {
                        pro = string.Empty;
                    }

                    if (type != null && type.Length > 0)
                    {
                        mean_en += " (" + type + ")";
                    }

                    if (!string.IsNullOrEmpty(pro))
                    {
                        if (pro.StartsWith("BrE"))
                        {
                            pro = pro.Substring(3).Trim();
                        }
                        pro = pro.Replace("//", "/");
                    }

                    List <string> ls_Verb_Group = new List <string>();
                    var wgs = nodes.QuerySelectorAll("span[class=\"vp\"]").Select(x => x.InnerText_NewLine).Where(x => !string.IsNullOrEmpty(x)).ToArray();
                    foreach (string wi in wgs)
                    {
                        string[] a = wi.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                        ls_Verb_Group.Add(a[a.Length - 1]);
                    }
                    if (ls_Verb_Group.Count > 0)
                    {
                        mean_en += heading_text + "REF: " + string.Join("; ", ls_Verb_Group.ToArray());
                    }


                    if (word_links.Length > 0)
                    {
                        mean_en += "\r\n" + string.Join(Environment.NewLine, word_links).Replace("-ing", "V-ing").Trim();
                    }

                    string[] mp3 = nodes.QuerySelectorAll("div[data-src-mp3]")
                                   .Select(x => x.GetAttributeValue("data-src-mp3", string.Empty))
                                   .Where(x => !string.IsNullOrEmpty(x))
                                   .Distinct()
                                   .ToArray();
                    if (mp3.Length > 0)
                    {
                        mean_en += "\r\n{\r\n" + string.Join(Environment.NewLine, mp3) + "\r\n}\r\n";
                    }

                    string[] uns     = nodes.QuerySelectorAll("span[class=\"un\"]").Select(x => x.InnerText_NewLine).Where(x => !string.IsNullOrEmpty(x)).ToArray();
                    string[] idoms   = nodes.QuerySelectorAll("span[class=\"idm-g\"]").Select(x => x.InnerText_NewLine).Where(x => !string.IsNullOrEmpty(x)).ToArray();
                    string[] defines = nodes.QuerySelectorAll("li[class=\"sn-g\"]").Select(x => x.InnerText_NewLine).Where(x => !string.IsNullOrEmpty(x)).ToArray();

                    if (defines.Length > 0)
                    {
                        mean_en += heading_text + "DEFINE:\r\n" +
                                   string.Join(Environment.NewLine,
                                               string.Join(Environment.NewLine, defines)
                                               .Split(new char[] { '\r', '\n' })
                                               .Select(x => x.Replace(".", ".\r\n").Trim())
                                               .Where(x => x.Length > 0)
                                               .ToArray())
                                   .Replace("\r\n[", ". ")
                                   .Replace("]", ":")

                                   .Replace("1\r\n", "\r\n- ")
                                   .Replace("2\r\n", "\r\n- ")
                                   .Replace("3\r\n", "\r\n- ")
                                   .Replace("4\r\n", "\r\n- ")
                                   .Replace("5\r\n", "\r\n- ")
                                   .Replace("6\r\n", "\r\n- ")
                                   .Replace("7\r\n", "\r\n- ")
                                   .Replace("8\r\n", "\r\n- ")
                                   .Replace("9\r\n", "\r\n- ")

                                   .Replace("1.", "\r\n+ ")
                                   .Replace("2.", "\r\n+ ")
                                   .Replace("3.", "\r\n+ ")
                                   .Replace("4.", "\r\n+ ")
                                   .Replace("5.", "\r\n+ ")
                                   .Replace("6.", "\r\n+ ")
                                   .Replace("7.", "\r\n+ ")
                                   .Replace("8.", "\r\n+ ")
                                   .Replace("9.", "\r\n+ ");
                    }

                    if (uns.Length > 0)
                    {
                        mean_en += heading_text + "NOTE:\r\n" + string.Join(Environment.NewLine, string.Join(Environment.NewLine, uns).Split(new char[] { '\r', '\n' }).Select(x => x.Replace(".", ".\r\n").Trim()).Where(x => x.Length > 0).ToArray());
                    }

                    if (idoms.Length > 0)
                    {
                        mean_en += heading_text + "IDOM:\r\n" + string.Join(Environment.NewLine, string.Join(Environment.NewLine, idoms).Split(new char[] { '\r', '\n' }).Select(x => x.Replace(".", ".\r\n").Trim()).Where(x => x.Length > 0).ToArray());
                    }

                    mean_en = Regex.Replace(mean_en, "[ ]{2,}", " ").Replace("\r\n’", "’");

                    mean_en = string.Join(Environment.NewLine,
                                          mean_en.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)
                                          .Select(x => x.Trim())
                                          .Select(x => x.Length > 0 ?
                                                  (
                                                      (x[0] == '+' || x[0] == '-') ?
                                                      (x[0].ToString() + " " + x[2].ToString().ToUpper() + x.Substring(3))
                                        : (x[0].ToString().ToUpper() + x.Substring(1))
                                                  ) : x)
                                          .ToArray());

                    string[] sens = nodes.QuerySelectorAll("span[class=\"x\"]")
                                    .Where(x => !string.IsNullOrEmpty(x.InnerText))
                                    .Select(x => x.InnerText.Trim())
                                    .Where(x => x.Length > 0)
                                    .Select(x => "- " + x)
                                    .ToArray();
                    if (sens.Length > 0)
                    {
                        string sen_text = string.Join(Environment.NewLine, sens);
                        mean_en        += heading_text + "EXAMPLE:\r\n" + sen_text;
                    }

                    mean_en = mean_en.Replace("See full entry", string.Empty).Replace(Environment.NewLine, "|")
                              .Replace("’ ", @""" ").Replace(".’", @".""").Replace("’|", @"""|")
                              .Replace(" ‘", @" """)
                              .Replace("’", @"'");

                    mean_en = Regex.Replace(mean_en, @"[^\x20-\x7E]", string.Empty);

                    mean_en = mean_en.Replace("|", Environment.NewLine);
                    //mean_en = Regex.Replace(mean_en, @"[^0-9a-zA-Z;,|{}():/'#+-._\r\n]+!\?", " ");
                    mean_en = Regex.Replace(mean_en, "[ ]{2,}", " ");

                    #endregion
                }
                else
                {
                    return new UrlAnanyticResult()
                    {
                        Message = "Can not read"
                    }
                };
                return(new UrlAnanyticResult()
                {
                    Ok = true, Html = s, Result = wo
                });
            }, (result) =>
            {
                if (result.Result != null)
                {
                }
            });


            ;
        }
コード例 #17
0
        private void CreateBrands()
        {
            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText = "SELECT [BrandName], [BrandID], [UrlPath] FROM [Catalog].[Brand] Where enabled=1 ORDER BY BrandName";
                db.cnOpen();
                using (var read = db.cmd.ExecuteReader())
                {
                    bool tempHaveItem = read.HasRows;

                    if (tempHaveItem)
                    {
                        _sw.WriteLine("<b>" + Resource.Client_Sitemap_Brands + " </b> <ul>");
                    }

                    while (read.Read())
                    {
                        _sw.WriteLine(string.Format("<li><a href='{0}'>{1}</a></li>", _prefUrl + UrlService.GetLink(ParamType.Brand, Convert.ToString(read["UrlPath"]), Convert.ToInt32(read["BrandID"])), read["BrandName"]));
                    }

                    if (tempHaveItem)
                    {
                        _sw.WriteLine("</ul>");
                    }
                }
            }
        }
コード例 #18
0
 public LinkUrlResolver(RouteRequestLookupInfoAccessor routeRequestLookupInfoAccessor,
                        UrlService urlService)
 {
     _routeRequestLookupInfoAccessor = routeRequestLookupInfoAccessor;
     _urlService = urlService;
 }
コード例 #19
0
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        public void Test_Multiple_Upsert()
        {
            UrlService service = new UrlService();

            // Create new stopwatch
            Stopwatch stopwatch = new Stopwatch();

            //// Begin timing
            stopwatch.Start();

            Parallel.For(0, 1000, i =>
            {
                Url u = service.ShortenUrl(GenereateEntity());
            });

            // Stop timing
            stopwatch.Stop();

            // Write result
            var res = stopwatch.Elapsed.TotalMilliseconds;
        }
コード例 #20
0
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        public void Test_Single_Upsert()
        {
            UrlService service = new UrlService();

            Url input = GenereateEntity();
            Url output = service.ShortenUrl(input);

            Assert.AreEqual(input.ShortId, String.Empty);
            Assert.IsNotNull(output.ShortId);
        }
コード例 #21
0
ファイル: DetailsSocial.aspx.cs プロジェクト: gkovalev/nastia
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ProductId == 0)
        {
            Error404();
            return;
        }

        //if not have category
        if (ProductService.GetCountOfCategoriesByProductId(ProductId) == 0)
        {
            Error404();
            return;
        }


        // --- Check product exist ------------------------
        CurrentProduct = ProductService.GetProduct(ProductId);
        if (CurrentProduct == null || CurrentProduct.Enabled == false || CurrentProduct.HirecalEnabled == false)//CategoryService.IsEnabledParentCategories(_product.CategoryID) == false)
        {
            Error404();
            return;
        }

        if (CurrentProduct.Amount == 0 || CurrentProduct.Price == 0)
        {
            divAmount.Visible = false;
        }

        rating.ProductId  = CurrentProduct.ID;
        rating.Rating     = CurrentProduct.Ratio;
        rating.ShowRating = SettingsCatalog.EnableProductRating;
        rating.ReadOnly   = RatingService.DoesUserVote(ProductId, CustomerSession.CustomerId);


        pnlSize.Visible = !string.IsNullOrEmpty(CurrentProduct.Size) && (CurrentProduct.Size != "0|0|0");
        //lblSize.Text = !string.IsNullOrEmpty(_product.Size) ? _product.Size.Replace("|", "x") : string.Empty;
        pnlWeight.Visible = CurrentProduct.Weight != 0;
        //lblWeight.Text = _product.Weight.ToString();
        pnlBrand.Visible = CurrentProduct.Brand != null;

        productPropertiesView.ProductId = ProductId;
        productPhotoView.Product        = CurrentProduct;
        ProductVideoView.ProductID      = ProductId;
        relatedProducts.ProductIds.Add(ProductId);
        alternativeProducts.ProductIds.Add(ProductId);
        breadCrumbs.Items = CategoryService.GetParentCategories(CurrentProduct.CategoryID).Reverse().Select(cat => new BreadCrumbs()
        {
            Name = cat.Name,
            Url  = "social/catalogsocial.aspx?categoryid=" + cat.CategoryId
        }).ToList();
        breadCrumbs.Items.Insert(0, new BreadCrumbs()
        {
            Name = Resource.Client_MasterPage_MainPage,
            Url  = UrlService.GetAbsoluteLink("social/catalogsocial.aspx")
        });

        breadCrumbs.Items.Add(new BreadCrumbs {
            Name = CurrentProduct.Name, Url = null
        });

        RecentlyViewService.SetRecentlyView(CustomerSession.CustomerId, ProductId);

        if ((!IsPostBack) && (IsEditItem))
        {
            if (!IsCorrectItemType)
            {
                Redirect(UrlService.GetLink(ParamType.Product, CurrentProduct.UrlPath, ProductId));
                return;
            }

            switch (ItemType)
            {
            case ShoppingCartType.ShoppingCart:
                //txtAmount.Text = ShoppingCartService.CurrentShoppingCart[ItemIndex].Amount.ToString();
                break;

            case ShoppingCartType.Wishlist:
                //txtAmount.Text = "1";
                break;
            }
        }

        SetMeta(CurrentProduct.Meta, CurrentProduct.Name);

        productReviews.EntityType = EntityType.Product;
        productReviews.EntityId   = ProductId;
        //Master.CurrencyChanged += (OnCurrencyChanged);
        int reviewsCount = ReviewService.GetReviewsCount(ProductId, EntityType.Product);

        if (reviewsCount > 0)
        {
            lReviewsCount.Text = string.Format("({0})", reviewsCount);
        }
        GetOffer();
    }
コード例 #22
0
ファイル: AdvantShopPage.cs プロジェクト: gkovalev/nastia
 protected string GetAbsoluteLink(string link)
 {
     return(UrlService.GetAbsoluteLink(link));
 }
コード例 #23
0
        private void CreateNews()
        {
            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText = "SELECT [NewsID], [Title], [AddingDate],[UrlPath] FROM [Settings].[News] ORDER BY AddingDate DESC";
                db.cnOpen();
                using (var read = db.cmd.ExecuteReader())
                {
                    bool tempHaveItem = read.HasRows;

                    if (tempHaveItem)
                    {
                        _sw.WriteLine("<b>" + Resource.Client_Sitemap_News + " </b> <ul>");
                    }

                    while (read.Read())
                    {
                        _sw.WriteLine(string.Format("<li><a href='{0}'>{1}</a></li>", _prefUrl + UrlService.GetLink(ParamType.News, Convert.ToString(read["UrlPath"]), Convert.ToInt32(read["NewsID"])), read["AddingDate"] + " :: " + read["Title"]));
                    }

                    if (tempHaveItem)
                    {
                        _sw.WriteLine("</ul>");
                    }
                }
            }
        }
コード例 #24
0
        public void MoveToNextStep(ProfileWizardStep step)
        {
            switch (step)
            {
            case ProfileWizardStep.UnknownProfileDisclaimer:
                MoveFromStepUnknownProfileDisclaimer();
                break;

            case ProfileWizardStep.InternalCredentials:
                MoveFromStepInternalCredentials();
                break;

            case ProfileWizardStep.OrganizationSelector:
                MoveFromStepOrganizationSelector();
                break;

            case ProfileWizardStep.ProfileTypeSelector:
                MoveFromStepProfileTypeSelector();
                break;

            case ProfileWizardStep.ProfileUserData:
                List <ProfilerError> errors = UrlService.VerifyProfileInfo(View.ProfileInfo);
                if (errors.Count > 0)
                {
                    View.LoadProfileInfoError(errors);
                }
                else
                {
                    View.UnloadProfileInfoError();
                    if (!View.AvailableSteps.Contains(ProfileWizardStep.Privacy))
                    {
                        UpdateStepsToSkip(ProfileWizardStep.Privacy, true);
                        View.GotoStep(ProfileWizardStep.Summary);
                    }
                    else
                    {
                        if (!View.IsInitialized(ProfileWizardStep.Privacy))
                        {
                            View.InitializeStep(ProfileWizardStep.Privacy);
                        }
                        View.GotoStep(ProfileWizardStep.Privacy);
                    }
                }
                break;

            case ProfileWizardStep.Privacy:
                Boolean UseInternalCredentials = (View.SelectedProvider == AuthenticationProviderType.Internal);
                if (View.AcceptedMandatoryPolicy && UseInternalCredentials && View.IdProfile > 0)
                {
                    Person person = CurrentManager.GetPerson(View.IdProfile);
                    UrlAuthenticationProvider provider = GetProvider();
                    View.LogonUser(person, View.idProvider, provider.RemoteLoginUrl, false, CurrentManager.GetUserDefaultIdOrganization(View.IdProfile));
                }
                else if (View.AcceptedMandatoryPolicy && !UseInternalCredentials)
                {
                    View.GotoStep(ProfileWizardStep.Summary);
                }
                break;

            case ProfileWizardStep.Summary:
                break;
            }
        }
コード例 #25
0
        private void ProcessProductRow(ExportFeedProduts row, StreamWriter memoryBuffer)
        {
            memoryBuffer.Write("\"");
            //MPN
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Manufacturer name
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //UPC
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product Name
            memoryBuffer.Write(row.Name);
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product Description
            string desc = _description == "full" ? row.Description : row.BriefDescription;

            memoryBuffer.Write(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product Price
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            memoryBuffer.Write(CatalogService.CalculatePrice(row.Price, row.Discount).ToString(nfi));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Product URL
            memoryBuffer.Write(ShopUrl.TrimEnd('/') + "/" + UrlService.GetLink(ParamType.Product, row.UrlPath, row.ProductId));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");
            memoryBuffer.Write("\"");
            //Image URL
            if (!string.IsNullOrEmpty(row.Photos))
            {
                var temp = row.Photos.Split(',');
                var item = temp.FirstOrDefault();
                if (!string.IsNullOrEmpty(item))
                {
                    memoryBuffer.Write(GetImageProductPath(item));
                }
            }

            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Shopping.com Categorization
            var      categorizationBuffer = new StringBuilder();
            Category category             = CategoryService.GetCategory(row.ParentCategory);

            categorizationBuffer.Insert(0, category.Name);
            while (category.ParentCategoryId != 0)
            {
                category = CategoryService.GetCategory(category.ParentCategoryId);
                categorizationBuffer.Insert(0, category.Name + " >> ");
            }
            memoryBuffer.Write(categorizationBuffer.ToString());
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Stock Availability
            //memoryBuffer.Write(SQLDataHelper.GetBoolean(row["Enabled"]));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Stock Description
            memoryBuffer.Write("shopping");
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Ground Shipping
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Weight
            //memoryBuffer.Write(SQLDataHelper.GetDecimal(row["Weight"]));
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Zip Code
            memoryBuffer.Write("\"");

            memoryBuffer.Write(",");

            memoryBuffer.Write("\"");
            //Condition
            memoryBuffer.Write("New");
            memoryBuffer.Write("\"");

            memoryBuffer.Write("\n");
        }
コード例 #26
0
 public string ConvertToSlug(string title)
 {
     return(UrlService.URLFriendly(title));
 }
コード例 #27
0
 public ParallelUrlCollector(IParallelUrlCollectingService parallelUrlCollectingService, UrlService urlService)
 {
     this.parallelUrlCollectingService = parallelUrlCollectingService;
     this.urlService = urlService;
 }
コード例 #28
0
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
 public void Test_GetUrlCount()
 {
     UrlService service = new UrlService();
     int result = service.GetUrlCount();
 }
コード例 #29
0
 protected string GetProductLink(ProductItem item)
 {
     return(UrlService.GetLinkDB(ParamType.Product, item.ProductId));
 }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _paging = new SqlPaging
            {
                TableName =
                    "[Catalog].[Product] LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] inner join Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID] LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[OfferID] = [Catalog].[Offer].[OfferID] AND [Catalog].[ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId"
            };
            _paging.AddFieldsRange(
                new List <Field>
            {
                new Field {
                    Name = "[Product].[ProductID]", IsDistinct = true
                },
                //new Field {Name = "PhotoName AS Photo"},
                new Field {
                    Name = "(CASE WHEN Offer.ColorID is not null THEN (Select Count(PhotoName) From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) ELSE (Select Count(PhotoName) From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) END)  AS CountPhoto"
                },
                new Field {
                    Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END)  AS Photo"
                },
                new Field {
                    Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END)  AS PhotoDesc"
                },

                new Field {
                    Name = "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors"
                },
                //new Field {Name = "[Photo].[Description] AS PhotoDesc"},
                new Field {
                    Name = "[ProductCategories].[CategoryID]", NotInQuery = true
                },
                new Field {
                    Name = "BriefDescription"
                },
                new Field {
                    Name = "Product.ArtNo"
                },
                new Field {
                    Name = "Name"
                },
                new Field {
                    Name = "(CASE WHEN Price=0 THEN 0 ELSE 1 END) as TempSort", Sorting = SortDirection.Descending
                },
                new Field {
                    Name = "Recomended"
                },
                new Field {
                    Name = "Bestseller"
                },
                new Field {
                    Name = "New"
                },
                new Field {
                    Name = "OnSale"
                },
                new Field {
                    Name = "Discount"
                },
                new Field {
                    Name = "Offer.Main", NotInQuery = true
                },
                new Field {
                    Name = "Offer.OfferID"
                },
                new Field {
                    Name = "Offer.Amount"
                },
                new Field {
                    Name = "(CASE WHEN Offer.Amount=0 OR Offer.Amount < IsNull(MinAmount,0) THEN 0 ELSE 1 END) as TempAmountSort", Sorting = SortDirection.Descending
                },
                new Field {
                    Name = "MinAmount"
                },
                new Field {
                    Name = "MaxAmount"
                },
                new Field {
                    Name = "Enabled"
                },
                new Field {
                    Name = "AllowPreOrder"
                },
                new Field {
                    Name = "Ratio"
                },
                new Field {
                    Name = "RatioID"
                },
                new Field {
                    Name = "DateModified"
                },
                new Field {
                    Name = "ShoppingCartItemId"
                },
                new Field {
                    Name = "UrlPath"
                },
                new Field {
                    Name = "[ProductCategories].[SortOrder]"
                },
                new Field {
                    Name = "[ShoppingCart].[CustomerID]", NotInQuery = true
                },
                new Field {
                    Name = "BrandID", NotInQuery = true
                },
                new Field {
                    Name = "Offer.ProductID as Size_ProductID", NotInQuery = true
                },
                new Field {
                    Name = "Offer.ProductID as Color_ProductID", NotInQuery = true
                },
                new Field {
                    Name = "Offer.ProductID as Price_ProductID", NotInQuery = true
                },
                new Field {
                    Name = "Offer.ColorID"
                },
                new Field {
                    Name = "CategoryEnabled", NotInQuery = true
                },
            });

            if (SettingsCatalog.ComplexFilter)
            {
                _paging.AddFieldsRange(new List <Field>
                {
                    new Field {
                        Name = "(select max (price) - min (price) from catalog.offer where offer.productid=product.productid) as MultiPrices"
                    },
                    new Field {
                        Name = "(select min (price) from catalog.offer where offer.productid=product.productid) as Price"
                    },
                });
            }
            else
            {
                _paging.AddFieldsRange(new List <Field>
                {
                    new Field {
                        Name = "0 as MultiPrices"
                    },
                    new Field {
                        Name = "Price"
                    },
                });
            }

            _paging.AddParam(new SqlParam {
                ParameterName = "@CustomerId", Value = CustomerContext.CustomerId.ToString()
            });
            _paging.AddParam(new SqlParam {
                ParameterName = "@Type", Value = PhotoType.Product.ToString()
            });

            if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId))
            {
                _categoryId = 0;

                var sbMainPage = StaticBlockService.GetPagePartByKeyWithCache("MainPageSocial");
                if (sbMainPage != null && sbMainPage.Enabled)
                {
                    MainPageText = sbMainPage.Content;
                }
            }

            if (!string.IsNullOrEmpty(MainPageText))
            {
                SetMeta(null, string.Empty);
                return;
            }

            category = CategoryService.GetCategory(_categoryId);
            if (category == null || category.Enabled == false || category.ParentsEnabled == false)
            {
                Error404();
                return;
            }

            ProductsCount = category.GetProductCount();

            categoryView.CategoryID = _categoryId;
            categoryView.Visible    = true;
            pnlSort.Visible         = ProductsCount > 0;
            productView.Visible     = ProductsCount > 0;

            lblCategoryName.Text = _categoryId != 0 ? category.Name : Resource.Client_MasterPage_Catalog;
            //lblCategoryDescription.Text = category.Description;

            //imgCategoryImage.ImageUrl = string.IsNullOrEmpty(category.Picture) ? "" : string.Format("{0}", ImageFolders.GetImageCategoryPath(false, category.Picture));

            breadCrumbs.Items =
                CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs
            {
                Name = parent.Name,
                Url  = "social/catalogsocial.aspx?categoryid=" + parent.CategoryId
            }).Reverse().ToList();
            breadCrumbs.Items.Insert(0, new BreadCrumbs
            {
                Name = Resource.Client_MasterPage_MainPage,
                Url  = UrlService.GetAbsoluteLink("social/catalogsocial.aspx")
            });

            SetMeta(category.Meta, category.Name);

            if (category.DisplayChildProducts)
            {
                var cfilter = new InChildCategoriesFieldFilter
                {
                    CategoryId = _categoryId.ToString(),
                    ParamName  = "@CategoryID"
                };
                _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter;
            }
            else
            {
                var cfilter = new EqualFieldFilter {
                    Value = _categoryId.ToString(), ParamName = "@catalog"
                };
                _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter;
            }

            _paging.Fields["Enabled"].Filter = new EqualFieldFilter {
                Value = "1", ParamName = "@enabled"
            };;
            _paging.Fields["CategoryEnabled"].Filter = new EqualFieldFilter {
                Value = "1", ParamName = "@CategoryEnabled"
            };

            var logicalFilter = new LogicalFilter {
                ParamName = "@Main", HideInCustomData = true
            };

            logicalFilter.AddFilter(new EqualFieldFilter {
                Value = "1", ParamName = "@Main1", HideInCustomData = true
            });
            logicalFilter.AddLogicalOperation("OR");
            logicalFilter.AddFilter(new NullFieldFilter {
                Null = true, ParamName = "@Main2", HideInCustomData = true
            });
            _paging.Fields["Offer.Main"].Filter = logicalFilter;

            BuildSorting();
        }
コード例 #31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            form.Action = Request.RawUrl;

            lsocialCss.Text = string.Format("<link type=\"text/css\" rel=\"stylesheet\" href=\"templates/social/css/{0}.css\" />", UrlService.IsSocialUrl(Request.Url.ToString()).ToString());

            searchBlock.Visible = (SettingsDesign.SearchBlockLocation == SettingsDesign.eSearchBlockLocation.TopMenu && SettingsDesign.MainPageMode == SettingsDesign.eMainPageMode.Default);

            SettingsDesign.eMainPageMode currentMode = !Demo.IsDemoEnabled ||
                                                       !CommonHelper.GetCookieString("structure").IsNotEmpty()
                                                           ? SettingsDesign.MainPageMode
                                                           : (SettingsDesign.eMainPageMode)
                                                       Enum.Parse(typeof(SettingsDesign.eMainPageMode),
                                                                  CommonHelper.GetCookieString("structure"));

            if (currentMode == SettingsDesign.eMainPageMode.Default)
            {
                menuTop.Visible         = true;
                searchBig.Visible       = false;
                menuCatalog.Visible     = true;
                menuTopMainPage.Visible = false;

                liViewCss.Text = "<link rel=\"stylesheet\" href=\"css/views/default.css\" >";
            }
            else if (currentMode == SettingsDesign.eMainPageMode.TwoColumns)
            {
                menuTop.Visible         = false;
                searchBig.Visible       = (SettingsDesign.SearchBlockLocation == SettingsDesign.eSearchBlockLocation.TopMenu);
                menuCatalog.Visible     = false;
                searchBlock.Visible     = false;
                menuTopMainPage.Visible = true;

                liViewCss.Text = "<link rel=\"stylesheet\" href=\"css/views/twocolumns.css\" >";
            }
            else if (currentMode == SettingsDesign.eMainPageMode.ThreeColumns)
            {
                menuTop.Visible         = false;
                searchBig.Visible       = (SettingsDesign.SearchBlockLocation == SettingsDesign.eSearchBlockLocation.TopMenu);
                menuCatalog.Visible     = false;
                menuTopMainPage.Visible = true;

                liViewCss.Text = "<link rel=\"stylesheet\" href=\"css/views/threecolumns.css\" >";
            }
        }
コード例 #32
0
        public JsonResult ConverToSlug(string title)
        {
            var data = UrlService.URLFriendly(title);

            return(Json(data));
        }
コード例 #33
0
        public JsonResult ConverToSlug(string title)
        {
            var data = UrlService.URLFriendly(title);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #34
0
 public UrlGenerator(UrlService urlService)
 {
     this.urlService = urlService;
 }
コード例 #35
0
        public WebsiteType(WebsiteService websiteService,
                           RouteInfoService routeInfoService,
                           CategoryService categoryService,
                           UrlService urlService,
                           PageService pageService)
        {
            Name = "Website";
            Field(p => p.LogoUrl);
            Field(p => p.SystemId, type: typeof(IdGraphType));

            Field <FooterType>(nameof(WebsiteModel.Footer), "The website footer",
                               arguments: new QueryArguments(
                                   new QueryArgument <GlobalInputType> {
                Name = "global"
            }
                                   ),
                               resolve: context =>
            {
                var website = websiteService.Get(context.Source.SystemId);
                var footer  = website.Fields.GetValue <IList <MultiFieldItem> >(AcceleratorWebsiteFieldNameConstants.Footer);
                if (footer != null)
                {
                    var globalModel       = context.GetArgument <GlobalModel>("global");
                    var culture           = CultureInfo.GetCultureInfo(globalModel.CurrentUICulture);
                    var startPageSystemId = pageService.GetChildPages(Guid.Empty, globalModel.WebsiteSystemId).FirstOrDefault()?.SystemId;
                    routeInfoService.Setup(globalModel, startPageSystemId);
                    return(new FooterModel()
                    {
                        SectionList = footer.Select(c => new SectionModel()
                        {
                            SectionTitle = c.Fields.GetValue <string>(AcceleratorWebsiteFieldNameConstants.FooterHeader, culture) ?? string.Empty,
                            SectionLinkList = c.Fields.GetValue <IList <PointerItem> >(AcceleratorWebsiteFieldNameConstants.FooterLinkList)
                                              .OfType <PointerPageItem>().ToList()
                                              .Select(x => x.MapTo <Web.Models.LinkModel>()).Where(c => c != null).Select(l => new Models.LinkModel()
                            {
                                Href = l.Href,
                                Text = l.Text
                            }).ToList() ?? new List <Models.LinkModel>(),
                            SectionText = c.Fields.GetValue <string>(AcceleratorWebsiteFieldNameConstants.FooterText, culture) ?? string.Empty
                        }).ToList()
                    });
                }
                return(null);
            });

            Field <HeaderType>(nameof(WebsiteModel.Header), "The website header",
                               arguments: new QueryArguments(
                                   new QueryArgument <GlobalInputType> {
                Name = "global"
            }
                                   ),
                               resolve: context =>
            {
                var globalModel = context.GetArgument <GlobalModel>("global");
                var items       = categoryService.GetChildCategories(Guid.Empty, globalModel.AssortmentSystemId);
                var culture     = CultureInfo.GetCultureInfo(globalModel.CurrentCulture);
                return(new HeaderModel()
                {
                    SectionList = items.Select(c => new SectionModel()
                    {
                        SectionText = c.GetEntityName(culture),
                        SectionTitle = c.GetEntityName(culture),
                        Href = urlService.GetUrl(c, new CategoryUrlArgs(globalModel.ChannelSystemId)),
                        SectionLinkList = categoryService.GetChildCategories(c.SystemId).Select(subCategory => new LinkModel()
                        {
                            Href = urlService.GetUrl(subCategory, new CategoryUrlArgs(globalModel.ChannelSystemId)),
                            Text = subCategory.GetEntityName(culture)
                        }).ToList()
                    }).ToList()
                });
            });
        }
コード例 #36
0
 public RedirectUrl(UrlService urlService)
 {
     this.urlService = urlService;
 }
コード例 #37
0
        /// <summary>
        /// Renders the cover media.
        /// </summary>
        /// <returns></returns>
        public string RenderCoverMedia()
        {
            string html = string.Empty;

            if (CoverMedia != null)
            {
                MediaFile websize = CoverMedia.GetImageByPhotoType(PhotoType.Websize);
                html = string.Format("<label class=\"instructions\" style=\"margin-bottom:20px;\" >cover image</label><img  class=\"covermedia topten\"  src=\"{0}\" alt=\"{1}\" />", UrlService.CreateImageUrl(websize.FilePath), CoverMedia.Title);
            }

            return(html);
        }
コード例 #38
0
 public SampleRequest(UrlService urlService, BookChapterClientService bookChapterClientService)
 {
     _urlService = urlService ?? throw new ArgumentNullException(nameof(urlService));
     _bookChapterClientService = bookChapterClientService ?? throw new ArgumentNullException(nameof(bookChapterClientService));
 }
コード例 #39
0
ファイル: PostsController.cs プロジェクト: Saroglu/BlogFall
 public ActionResult GenerateSlug(string title)
 {
     return(Json(UrlService.URLFriendly(title)));
 }
コード例 #40
0
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        public void Test_List_Upsert()
        {
            UrlService service = new UrlService();

            // Create new stopwatch
            Stopwatch stopwatch = new Stopwatch();

            //// Begin timing
            stopwatch.Start();

            List<Url> list = new List<Url>();
            for (int i = 0; i < 1000; i++)
            {
                list.Add(GenereateUniqueEntity());
            }

            List<Url> response = service.Upsert(list);

            // Stop timing
            stopwatch.Stop();

            // Write result
            var res = stopwatch.Elapsed.TotalMilliseconds;
        }