示例#1
0
        public bool DeleteContent(string newsId)
        {
            try
            {
                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                News         news         = new News(siteSettings.SiteId, Convert.ToInt32(newsId));

                if (news != null && news.NewsID != -1)
                {
                    NewsHelper.DeleteFolder(siteSettings.SiteId, news.NewsID);

                    ContentMedia.DeleteByContent(news.NewsGuid);

                    var listAtributes = ContentAttribute.GetByContentAsc(news.NewsGuid);
                    foreach (ContentAttribute item in listAtributes)
                    {
                        ContentLanguage.DeleteByContent(item.Guid);
                    }
                    ContentAttribute.DeleteByContent(news.NewsGuid);
                    ContentLanguage.DeleteByContent(news.NewsGuid);

                    news.Delete();
                    FriendlyUrl.DeleteByPageGuid(news.NewsGuid);

                    FileAttachment.DeleteByItem(news.NewsGuid);
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }
示例#2
0
        private void SaveAttributeContentLanguage(Guid contentGuid)
        {
            if (contentGuid == Guid.Empty || !IsAttributeLanguageTab())
            {
                return;
            }

            int languageID = -1;

            if (tabOptionLanguage.SelectedIndex > 0)
            {
                languageID = Convert.ToInt32(tabOptionLanguage.SelectedTab.Value);
            }

            if (languageID == -1)
            {
                return;
            }

            var content = new ContentLanguage(contentGuid, languageID);

            if (txtOptionName.Text.Length > 0)
            {
                content.LanguageId  = languageID;
                content.ContentGuid = contentGuid;
                content.SiteGuid    = siteSettings.SiteGuid;
                content.Title       = txtOptionName.Text.Trim();
                content.Save();
            }
        }
示例#3
0
        protected void tabLanguage_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
        {
            txtName.Text              = string.Empty;
            txtDisplayName.Text       = string.Empty;
            txtInvalidMessage.Text    = string.Empty;
            btnDeleteLanguage.Visible = false;

            if (field != null && field.CustomFieldId > 0)
            {
                if (e.Tab.Index == 0)
                {
                    txtName.Text           = field.Name;
                    txtDisplayName.Text    = field.DisplayName;
                    txtInvalidMessage.Text = field.InvalidMessage;
                }
                else
                {
                    ContentLanguage content = new ContentLanguage(field.Guid, Convert.ToInt32(e.Tab.Value));
                    if (content != null && content.Guid != Guid.Empty)
                    {
                        txtName.Text           = content.Title;
                        txtDisplayName.Text    = content.MetaTitle;
                        txtInvalidMessage.Text = content.ExtraText1;

                        btnDeleteLanguage.Visible = true;
                    }
                }
            }

            upButton.Update();
        }
示例#4
0
        protected void tabLanguage_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
        {
            txtName.Text              = string.Empty;
            edDescription.Text        = string.Empty;
            btnDeleteLanguage.Visible = false;

            if (method != null && method.PaymentMethodId > 0)
            {
                if (e.Tab.Index == 0)
                {
                    txtName.Text       = method.Name;
                    edDescription.Text = method.Description;
                }
                else
                {
                    ContentLanguage content = new ContentLanguage(method.Guid, Convert.ToInt32(e.Tab.Value));
                    if (content != null && content.Guid != Guid.Empty)
                    {
                        txtName.Text       = content.Title;
                        edDescription.Text = content.MetaTitle;

                        btnDeleteLanguage.Visible = true;
                    }
                }
            }

            upButton.Update();
        }
示例#5
0
        private void SaveContentLanguage(Guid contentGuid)
        {
            if (contentGuid == Guid.Empty || !IsLanguageTab())
            {
                return;
            }

            int languageID = -1;

            if (tabLanguage.SelectedIndex > 0)
            {
                languageID = Convert.ToInt32(tabLanguage.SelectedTab.Value);
            }

            if (languageID == -1)
            {
                return;
            }

            var content = new ContentLanguage(contentGuid, languageID);

            if (txtName.Text.Length > 0)
            {
                content.LanguageId  = languageID;
                content.ContentGuid = contentGuid;
                content.SiteGuid    = siteSettings.SiteGuid;
                content.Title       = txtName.Text.Trim();
                content.MetaTitle   = txtDisplayName.Text.Trim();
                content.ExtraText1  = txtInvalidMessage.Text.Trim();

                content.Save();
            }
        }
示例#6
0
        void btnDeleteOption_Click(object sender, EventArgs e)
        {
            try
            {
                if (field != null && lbOptions.SelectedValue.Length > 0)
                {
                    CustomFieldOption option = null;

                    if (lbOptions.SelectedValue.Length > 0)
                    {
                        option = new CustomFieldOption(Convert.ToInt32(lbOptions.SelectedValue));
                    }

                    if (option != null && option.CustomFieldOptionId > 0)
                    {
                        ContentLanguage.DeleteByContent(option.Guid);
                        ProductProperty.DeleteByCustomFieldOption(option.CustomFieldOptionId);
                        CustomFieldOption.Delete(option.CustomFieldOptionId);

                        LogActivity.Write("Delete custom field option", lbOptions.SelectedItem.Text);

                        selOption = lbOptions.Items[lbOptions.SelectedIndex - 1].Value;
                    }

                    BindOptions();
                    PopulateOptionControls();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
示例#7
0
 public void Handle(ContentLanguageUpdated e)
 {
     using (var db = new CoreDbContext())
     {
         var temp = db.ContentLanguages.FirstOrDefault(i => i.Id == e.Id &&
                                                       i.LanguageId == e.LanguageId && i.ColumnName.Equals(e.ColumnName, StringComparison.OrdinalIgnoreCase));
         if (temp == null)
         {
             temp             = new ContentLanguage();
             temp.Id          = e.Id;
             temp.LanguageId  = e.LanguageId;
             temp.ColumnName  = e.ColumnName;
             temp.ColumnValue = e.ColumnValue;
             temp.TableName   = e.TableName;
             temp.CreatedDate = DateTime.Now;
             db.ContentLanguages.Add(temp);
         }
         else
         {
             temp.Id          = e.Id;
             temp.LanguageId  = e.LanguageId;
             temp.ColumnName  = e.ColumnName;
             temp.ColumnValue = e.ColumnValue;
             temp.TableName   = e.TableName;
             temp.CreatedDate = DateTime.Now;
         }
         db.SaveChanges();
     }
 }
示例#8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                bool isDeleted = false;

                foreach (GridDataItem data in grid.SelectedItems)
                {
                    int tagId = Convert.ToInt32(data.GetDataKeyValue("TagId"));
                    Tag tag   = new Tag(tagId);

                    if (tag != null && tag.TagId > -1)
                    {
                        ContentLanguage.DeleteByContent(tag.Guid);
                        TagItem.DeleteByTag(tag.TagId);
                        Tag.Delete(tagId);

                        LogActivity.Write("Delete product tag", tag.TagText);

                        isDeleted = true;
                    }
                }

                if (isDeleted)
                {
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                    WebUtils.SetupRedirect(this, Request.RawUrl);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
 /// <summary>
 /// Get a hash code for the BlobHttpHeaders.
 /// </summary>
 /// <returns>Hash code for the BlobHttpHeaders.</returns>
 public override int GetHashCode()
 => CacheControl.GetHashCode()
 ^ ContentDisposition.GetHashCode()
 ^ ContentEncoding.GetHashCode()
 ^ ContentLanguage.GetHashCode()
 ^ ContentHash.GetHashCode()
 ^ ContentType.GetHashCode()
 ;
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var currentUrl = HttpContext.Current.Request.Url.ToString();
        var uri        = new Uri(currentUrl);
        var host       = uri.Host.Split('.');

        LiveChatLink = string.Format(Common.GetAppSetting <string>("WebHandler"), host[1], HttpUtility.UrlEncode(currentUrl));
        if (ContentLanguage.Equals("zh-my"))
        {
            LiveChatLink = string.Format("{0}{1}", LiveChatLink, "&ul=en-us");
        }
        Response.Redirect(LiveChatLink, false);
    }
示例#11
0
        private void PopulateOptionData(Telerik.Web.UI.RadTab tab)
        {
            txtOptionName.Text = string.Empty;
            btnDeleteOptionLanguage.Visible = false;
            if (divOptionType.Visible)
            {
                ddlOptionType.ClearSelection();
                colorPicker.SelectedColor = ColorTranslator.FromHtml(string.Empty);
            }

            if (lbOptions.SelectedValue.Length > 0)
            {
                CustomFieldOption option = new CustomFieldOption(Convert.ToInt32(lbOptions.SelectedValue));

                if (option == null || option.Guid == Guid.Empty)
                {
                    return;
                }

                if (divOptionType.Visible)
                {
                    ListItem li = ddlOptionType.Items.FindByValue(option.OptionType.ToString());
                    if (li != null)
                    {
                        ddlOptionType.ClearSelection();
                        li.Selected = true;
                    }

                    if (option.OptionColor.Length == 7 && option.OptionColor.StartsWith("#"))
                    {
                        colorPicker.SelectedColor = ColorTranslator.FromHtml(option.OptionColor);
                    }
                }

                if (IsAttributeLanguageTab())
                {
                    ContentLanguage content = new ContentLanguage(option.Guid, Convert.ToInt32(tab.Value));
                    if (content != null && content.Guid != Guid.Empty)
                    {
                        txtOptionName.Text = content.Title;
                        btnDeleteOptionLanguage.Visible = true;
                    }
                }
                else
                {
                    txtOptionName.Text = option.Name;
                }
            }
        }
示例#12
0
        protected void rptLanguages_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var txtName       = (TextBox)e.Item.FindControl("txtName");
                var hdfLanguageId = (HiddenField)e.Item.FindControl("hdfLanguageId");
                int languageId    = Convert.ToInt32(hdfLanguageId.Value);
                var content       = ContentLanguage.GetOneFromList(listContents, languageId);

                if (content != null)
                {
                    txtName.Text = content.Title;
                }
            }
        }
示例#13
0
        public bool DeleteContent(string paymentMethodId)
        {
            try
            {
                PaymentMethod method = new PaymentMethod(Convert.ToInt32(paymentMethodId));
                if (method != null && method.PaymentMethodId > 0)
                {
                    ContentLanguage.DeleteByContent(method.Guid);
                    PaymentMethod.Delete(method.PaymentMethodId);
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }
 public override int GetHashCode() =>
 BlobName.GetHashCode() ^
 CacheControl.GetHashCode() ^
 BlobContainerName.GetHashCode() ^
 ContentDisposition.GetHashCode() ^
 ContentEncoding.GetHashCode() ^
 ContentLanguage.GetHashCode() ^
 ContentType.GetHashCode() ^
 ExpiryTime.GetHashCode() ^
 Identifier.GetHashCode() ^
 IPRange.GetHashCode() ^
 Permissions.GetHashCode() ^
 Protocol.GetHashCode() ^
 StartTime.GetHashCode() ^
 Version.GetHashCode();
示例#15
0
        public bool DeleteContent(string shippingMethodId)
        {
            try
            {
                ShippingMethod method = new ShippingMethod(Convert.ToInt32(shippingMethodId));
                if (method != null && method.ShippingMethodId > 0)
                {
                    ContentLanguage.DeleteByContent(method.Guid);
                    ShippingTableRate.DeleteByMethod(method.ShippingMethodId);
                    ShippingMethod.Delete(method.ShippingMethodId);
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }
示例#16
0
        private void BindGrid()
        {
            btnAddNew.Visible = true;

            List <Tag> tags = Tag.GetPage(siteSettings.SiteGuid, News.FeatureGuid, keyword, -1, pageNumber, pageSize);

            string pageUrl = SiteRoot + "/News/TagBulkEdit.aspx";

            if (keyword != null)
            {
                pageUrl += "?keyword=" + keyword + "&pagenumber={0}";
            }
            else
            {
                pageUrl += "?pagenumber={0}";
            }

            pgr.PageURLFormat = pageUrl;
            pgr.ShowFirstLast = true;
            pgr.CurrentIndex  = pageNumber;
            pgr.PageSize      = pageSize;
            pgr.ItemCount     = Tag.GetCount(siteSettings.SiteGuid, News.FeatureGuid, null, -1);

            if (WebConfigSettings.AllowMultiLanguage)
            {
                string listGuidString = string.Empty;
                string sepa           = string.Empty;
                foreach (Tag item in tags)
                {
                    listGuidString += sepa + item.Guid.ToString();
                    sepa            = ";";
                }

                listAllContents = ContentLanguage.GetByListContent(listGuidString);
                listLanguages   = LanguageHelper.GetPublishedLanguages(true);
            }

            if (tags.Count > 0)
            {
                rpt.DataSource = tags;
                rpt.DataBind();
            }
        }
示例#17
0
        protected void btnDeleteOptionLanguage_Click(object sender, EventArgs e)
        {
            if (!IsAttributeLanguageTab())
            {
                return;
            }

            if (tabOptionLanguage.SelectedIndex > 0 && lbOptions.SelectedValue.Length == 36)
            {
                int languageId = Convert.ToInt32(tabOptionLanguage.SelectedTab.Value);

                if (languageId > 0)
                {
                    ContentLanguage.Delete(new Guid(lbOptions.SelectedValue), languageId);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");

                    PopulateOptionControls();
                }
            }
        }
示例#18
0
        protected void btnDeleteLanguage_Click(object sender, EventArgs e)
        {
            if (!IsLanguageTab())
            {
                return;
            }

            if (tabLanguage.SelectedIndex > 0)
            {
                int languageId = Convert.ToInt32(tabLanguage.SelectedTab.Value);

                if (languageId > 0 && field != null && field.Guid != Guid.Empty)
                {
                    ContentLanguage.Delete(field.Guid, languageId);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");

                    WebUtils.SetupRedirect(this, Request.RawUrl);
                }
            }
        }
示例#19
0
        private void DeleteTag(int tagId)
        {
            try
            {
                Tag tag = new Tag(tagId);

                if (tag != null && tag.TagId > -1)
                {
                    ContentLanguage.DeleteByContent(tag.Guid);
                    TagItem.DeleteByTag(tag.TagId);
                    Tag.Delete(tagId);

                    LogActivity.Write("Delete news tag", tag.TagText);
                    //message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
示例#20
0
        private void SaveContentLanguage(Repeater rptLanguages, Guid contentGuid)
        {
            if (!WebConfigSettings.AllowMultiLanguage)
            {
                return;
            }

            if (contentGuid == Guid.Empty)
            {
                return;
            }

            foreach (RepeaterItem item in rptLanguages.Items)
            {
                if ((item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem))
                {
                    var txtName       = (TextBox)item.FindControl("txtName");
                    var hdfLanguageId = (HiddenField)item.FindControl("hdfLanguageId");
                    int languageId    = Convert.ToInt32(hdfLanguageId.Value);
                    var strName       = txtName.Text.Trim();

                    var content = new ContentLanguage(contentGuid, languageId);

                    if (strName.Length > 0)
                    {
                        content.LanguageId  = languageId;
                        content.ContentGuid = contentGuid;
                        content.SiteGuid    = siteSettings.SiteGuid;
                        content.Title       = strName;
                        content.Save();
                    }
                    else if (content != null && content.Guid != Guid.Empty)
                    {
                        ContentLanguage.Delete(contentGuid, languageId);
                    }
                }
            }
        }
示例#21
0
        public bool DeleteContent(string productId)
        {
            try
            {
                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                Product      product      = new Product(siteSettings.SiteId, Convert.ToInt32(productId));

                if (product != null && product.ProductId != -1)
                {
                    ProductHelper.DeleteFolder(siteSettings.SiteId, product.ProductId);

                    ContentMedia.DeleteByContent(product.ProductGuid);
                    ShoppingCartItem.DeleteByProduct(product.ProductId);

                    var listAtributes = ContentAttribute.GetByContentAsc(product.ProductGuid);
                    foreach (ContentAttribute item in listAtributes)
                    {
                        ContentLanguage.DeleteByContent(item.Guid);
                    }
                    ContentAttribute.DeleteByContent(product.ProductGuid);
                    ContentLanguage.DeleteByContent(product.ProductGuid);

                    ProductProperty.DeleteByProduct(product.ProductId);
                    FriendlyUrl.DeleteByPageGuid(product.ProductGuid);

                    ProductComment.DeleteByProduct(product.ProductId);
                    TagItem.DeleteByItem(product.ProductGuid);

                    FileAttachment.DeleteByItem(product.ProductGuid);
                    RelatedItem.DeleteByItem(product.ProductGuid);

                    product.Delete();
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }
示例#22
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (field != null && field.CustomFieldId > -1)
                {
                    ContentLanguage.DeleteByContent(field.Guid);
                    ProductProperty.DeleteByCustomField(field.CustomFieldId);
                    CustomFieldOption.DeleteCustomField(field.CustomFieldId);
                    CustomField.Delete(field.CustomFieldId);

                    LogActivity.Write("Delete custom field", field.Name);

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                }

                WebUtils.SetupRedirect(this, SiteRoot + "/Product/AdminCP/CustomFields.aspx");
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
示例#23
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int iRecordDeleted = 0;
                foreach (Telerik.Web.UI.GridDataItem data in grid.SelectedItems)
                {
                    int customFieldId = Convert.ToInt32(data.GetDataKeyValue("CustomFieldId"));

                    CustomField field = new CustomField(customFieldId);
                    if (field != null && field.CustomFieldId != -1)
                    {
                        ContentLanguage.DeleteByContent(field.Guid);
                        ProductProperty.DeleteByCustomField(field.CustomFieldId);
                        CustomFieldOption.DeleteCustomField(field.CustomFieldId);
                        CustomField.Delete(field.CustomFieldId);

                        LogActivity.Write("Delete custom field", field.Name);

                        iRecordDeleted += 1;
                    }
                }

                if (iRecordDeleted > 0)
                {
                    //LogActivity.Write("Delete " + iRecordDeleted.ToString() + " item(s)", "Custom field");
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");

                    grid.Rebind();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
示例#24
0
        public override void RebuildIndex(
            ZoneSettings zoneSettings,
            string indexPath)
        {
            if (WebConfigSettings.DisableSearchIndex)
            {
                return;
            }

            if (zoneSettings == null)
            {
                log.Error("zoneSettings object passed to NewsIndexBuilderProvider.RebuildIndex was null");
                return;
            }

            //don't index pending/unpublished zones
            if (!zoneSettings.IsPublished)
            {
                return;
            }

            log.Info("NewsIndexBuilderProvider indexing zone - " + zoneSettings.Name);

            //try
            //{
            Guid             newsFeatureGuid = CanhCam.Business.News.FeatureGuid;
            ModuleDefinition newsFeature     = new ModuleDefinition(newsFeatureGuid);

            List <CanhCam.Business.News> lstNews = CanhCam.Business.News.GetByZone(zoneSettings.SiteId, zoneSettings.ZoneId);

            // Language
            string listGuid     = zoneSettings.ZoneGuid.ToString();
            string listNewsGuid = string.Empty;

            foreach (CanhCam.Business.News news in lstNews)
            {
                if (!listGuid.Contains(news.NewsGuid.ToString()))
                {
                    listGuid     += ";" + news.NewsGuid.ToString();
                    listNewsGuid += ";" + news.NewsGuid.ToString();
                }
            }

            List <ContentLanguage> listContent   = ContentLanguage.GetByListContent(listGuid);
            List <Language>        listLanguages = LanguageHelper.GetPublishedLanguages();
            string defaultCulture = WebConfigSettings.DefaultLanguageCultureForContent;
            // End Language

            List <ContentAttribute> listAttribute = new List <ContentAttribute>();

            foreach (Language lang in listLanguages)
            {
                if (lang.LanguageCode.ToLower() != defaultCulture.ToLower())
                {
                    listAttribute = ContentAttribute.GetByListContent(listNewsGuid, lang.LanguageID);
                }
                else
                {
                    listAttribute = ContentAttribute.GetByListContent(listNewsGuid);
                }

                foreach (CanhCam.Business.News news in lstNews)
                {
                    CanhCam.SearchIndex.IndexItem indexItem = new CanhCam.SearchIndex.IndexItem();
                    indexItem.SiteId              = zoneSettings.SiteId;
                    indexItem.ZoneId              = zoneSettings.ZoneId;
                    indexItem.ZoneName            = zoneSettings.Name;
                    indexItem.ViewRoles           = zoneSettings.ViewRoles;
                    indexItem.ZoneViewRoles       = zoneSettings.ViewRoles;
                    indexItem.FeatureId           = newsFeatureGuid.ToString();
                    indexItem.FeatureName         = newsFeature.FeatureName;
                    indexItem.FeatureResourceFile = newsFeature.ResourceFile;

                    indexItem.ItemGuid = news.NewsGuid;
                    indexItem.Title    = news.Title;

                    string url = news.Url;
                    if (url.Length > 0)
                    {
                        if (url.StartsWith("http"))
                        {
                            indexItem.ViewPage = url;
                        }
                        else
                        {
                            indexItem.ViewPage = url.Replace("~/", string.Empty);
                        }
                    }
                    else
                    {
                        indexItem.ViewPage = "News/NewsDetail.aspx?zoneid="
                                             + indexItem.ZoneId.ToInvariantString()
                                             + "&NewsID=" + news.NewsID.ToString();
                    }

                    indexItem.PageMetaDescription = news.MetaDescription;
                    indexItem.PageMetaKeywords    = news.MetaKeywords;

                    indexItem.CreatedUtc = news.StartDate;
                    indexItem.LastModUtc = news.LastModUtc;

                    //if (indexItem.ViewPage.Length > 0)
                    //{
                    indexItem.UseQueryStringParams = false;
                    //}
                    //else
                    //{
                    //    indexItem.ViewPage = "News/NewsDetail.aspx";
                    //}
                    indexItem.Content         = SecurityHelper.RemoveMarkup(news.FullContent);
                    indexItem.ContentAbstract = SecurityHelper.RemoveMarkup(news.BriefContent);

                    indexItem.IsPublished      = news.IsPublished;
                    indexItem.PublishBeginDate = news.StartDate;
                    indexItem.PublishEndDate   = news.EndDate;

                    // Language
                    indexItem.LanguageCode = defaultCulture;
                    if (lang.LanguageCode.ToLower() != defaultCulture.ToLower())
                    {
                        indexItem.ZoneName     = string.Empty;
                        indexItem.LanguageCode = lang.LanguageCode;
                        indexItem.RemoveOnly   = true;

                        foreach (ContentLanguage ct in listContent)
                        {
                            if (lang.LanguageID == ct.LanguageId)
                            {
                                if (ct.ContentGuid == zoneSettings.ZoneGuid)
                                {
                                    indexItem.ZoneName = ct.Title;
                                }
                                else if (ct.ContentGuid == news.NewsGuid)
                                {
                                    indexItem.PageMetaDescription = ct.MetaDescription;
                                    indexItem.PageMetaKeywords    = ct.MetaKeywords;
                                    indexItem.Title           = ct.Title;
                                    indexItem.Content         = SecurityHelper.RemoveMarkup(ct.FullContent);
                                    indexItem.ContentAbstract = SecurityHelper.RemoveMarkup(ct.BriefContent);

                                    indexItem.ViewPage   = ct.Url.Replace("~/", string.Empty);
                                    indexItem.RemoveOnly = false;
                                }
                            }
                        }
                    }
                    // End Language

                    foreach (ContentAttribute attribute in listAttribute)
                    {
                        if (attribute.ContentGuid == news.NewsGuid)
                        {
                            indexItem.Content += " " + attribute.Title + " " + SecurityHelper.RemoveMarkup(attribute.ContentText);
                        }
                    }

                    CanhCam.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath);

                    if (debugLog)
                    {
                        log.Debug("Indexed " + indexItem.Title);
                    }
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    log.Error(ex);
            //}
        }
        public void BuildRequestMessage_ContentLanguageHeader_Equal(ContentLanguage contentLanguage)
        {
            var options = new ProfileOptions("Hello World") {ContentLanguage = contentLanguage};
            var requestBuilder = new ProfileRequestBuilder();
            var message = requestBuilder.BuildRequestMessage(ServiceUrl, options, false);

            Assert.Equal($"{contentLanguage}".ToLower(), message.Content.Headers.ContentLanguage.FirstOrDefault());
        }
示例#26
0
        private static void IndexItem(CanhCam.Business.News news)
        {
            if (WebConfigSettings.DisableSearchIndex)
            {
                return;
            }

            if (news == null)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("news object passed to NewsIndexBuilderProvider.IndexItem was null");
                }
                return;
            }

            Guid             newsFeatureGuid = CanhCam.Business.News.FeatureGuid;
            ModuleDefinition newsFeature     = new ModuleDefinition(newsFeatureGuid);

            List <ContentAttribute> listAttribute = new List <ContentAttribute>();
            // Language
            List <Language> listLanguages  = LanguageHelper.GetPublishedLanguages();
            string          defaultCulture = WebConfigSettings.DefaultLanguageCultureForContent;
            // End Language

            ZoneSettings zoneSettings = new ZoneSettings(news.SiteId, news.ZoneID);

            //don't index pending/unpublished pages
            if (!zoneSettings.IsPublished)
            {
                return;
            }

            foreach (Language lang in listLanguages)
            {
                CanhCam.SearchIndex.IndexItem indexItem = new CanhCam.SearchIndex.IndexItem();
                if (news.SearchIndexPath.Length > 0)
                {
                    indexItem.IndexPath = news.SearchIndexPath;
                }
                indexItem.SiteId        = news.SiteId;
                indexItem.ZoneId        = zoneSettings.ZoneId;
                indexItem.ZoneName      = zoneSettings.Name;
                indexItem.ViewRoles     = zoneSettings.ViewRoles;
                indexItem.ZoneViewRoles = zoneSettings.ViewRoles;

                indexItem.PageMetaDescription = news.MetaDescription;
                indexItem.PageMetaKeywords    = news.MetaKeywords;
                indexItem.ItemGuid            = news.NewsGuid;
                indexItem.Title               = news.Title;
                indexItem.Content             = news.FullContent;
                indexItem.ContentAbstract     = news.BriefContent;
                indexItem.FeatureId           = newsFeatureGuid.ToString();
                indexItem.FeatureName         = newsFeature.FeatureName;
                indexItem.FeatureResourceFile = newsFeature.ResourceFile;

                //indexItem.OtherContent = stringBuilder.ToString();
                indexItem.IsPublished      = news.IsPublished;
                indexItem.PublishBeginDate = news.StartDate;
                indexItem.PublishEndDate   = news.EndDate;

                indexItem.CreatedUtc = news.StartDate;
                indexItem.LastModUtc = news.LastModUtc;

                if (news.Url.Length > 0)
                {
                    if (news.Url.StartsWith("http"))
                    {
                        indexItem.ViewPage = news.Url;
                    }
                    else
                    {
                        indexItem.ViewPage = news.Url.Replace("~/", string.Empty);
                    }
                }
                else
                {
                    indexItem.ViewPage = "News/NewsDetail.aspx?zoneid="
                                         + indexItem.ZoneId.ToInvariantString()
                                         + "&NewsID=" + news.NewsID.ToInvariantString()
                    ;
                }

                indexItem.UseQueryStringParams = false;

                // Language
                string listGuid = zoneSettings.ZoneGuid.ToString()
                                  + ";" + news.NewsGuid.ToString();
                List <ContentLanguage> listContent = ContentLanguage.GetByListContent(listGuid);
                indexItem.LanguageCode = defaultCulture;
                if (lang.LanguageCode.ToLower() != defaultCulture.ToLower())
                {
                    indexItem.LanguageCode = lang.LanguageCode;
                    indexItem.RemoveOnly   = true;

                    foreach (ContentLanguage ct in listContent)
                    {
                        if (lang.LanguageID == ct.LanguageId)
                        {
                            if (ct.ContentGuid == zoneSettings.PageGuid)
                            {
                                indexItem.ZoneName = ct.Title;
                            }
                            else if (ct.ContentGuid == news.NewsGuid)
                            {
                                indexItem.PageMetaDescription = ct.MetaDescription;
                                indexItem.PageMetaKeywords    = ct.MetaKeywords;
                                indexItem.Title           = ct.Title;
                                indexItem.Content         = SecurityHelper.RemoveMarkup(ct.FullContent);
                                indexItem.ContentAbstract = SecurityHelper.RemoveMarkup(ct.BriefContent);

                                indexItem.ViewPage   = ct.Url.Replace("~/", string.Empty);
                                indexItem.RemoveOnly = false;
                            }
                        }
                    }

                    listAttribute = ContentAttribute.GetByContentAsc(news.NewsGuid, lang.LanguageID);
                }
                else
                {
                    listAttribute = ContentAttribute.GetByContentAsc(news.NewsGuid);
                }
                // End Language

                foreach (ContentAttribute attribute in listAttribute)
                {
                    indexItem.Content += " " + attribute.Title + " " + SecurityHelper.RemoveMarkup(attribute.ContentText);
                }

                if (news.IsDeleted)
                {
                    indexItem.RemoveOnly = true;
                }

                CanhCam.SearchIndex.IndexHelper.RebuildIndex(indexItem);
            }

            if (debugLog)
            {
                log.Debug("Indexed " + news.Title);
            }
        }