Beispiel #1
0
        public ActionResult AjaxDropDownRegions(string stateElementId, string countryCode)
        {
            var regions = new HtmlServices().DropDownModelStates(new AddressModel {
                CountryCode = countryCode
            });

            regions.AjaxElementId = stateElementId;
            return(PartialView(regions));
        }
        public ServiceResponse GetStatesByCountry(string countryCode)
        {
            var states = new HtmlServices().DropDownModelStates(new AddressModel {
                CountryCode = countryCode
            });

            response.Model = states;
            return(response);
        }
        public SubmittalPackageController()
        {
            projectService   = new ProjectServices();
            quoteService     = new QuoteServices();
            htmlService      = new HtmlServices();
            submittalService = new SubmittalPackageServices();

            //this.log = Log;
        }
Beispiel #4
0
        public void ContentService()
        {
            var provider = new TestContentService();

            WebServiceLocator.RegisterService(provider, VirtualPathUtility.GetDirectory(testContentPath));
            var result = HtmlServices.LoadContent(testContentPath);

            Assert.AreEqual(result.Content, testContent, "测试内容提供程序失败");

            Assert.AreEqual(result.Provider, provider, "内容结果中的提供程序错误");
            Assert.AreEqual(result.VirtualPath, testContentPath, "内容结果中的虚拟路径错误");
        }
        private string GenerateHtml(ISmartContent content, bool editor, string blogId)
        {
            MapSettings settings = new MapSettings(content.Properties);

            settings.PublishTargetId = blogId;

            Uri imageUri = content.Files.GetUri(settings.ImageFileId);

            if (imageUri == null)
            {
                //try to regenerate the image using the default size for blog
                Size mapSize = _pluginOptions.GetDefaultMapSize(blogId);
                UpdateMapImage(content, settings, mapSize);
                settings.Size = mapSize;

                imageUri = content.Files.GetUri(settings.ImageFileId);
            }

            string imgAltText = Res.Get(StringId.MapImageAltText);

            if (settings.Caption != String.Empty)
            {
                imgAltText = settings.Caption;
            }

            string imageHtml = settings.Caption;

            if (imageUri != null)
            {
                Size   mapSize   = settings.Size;
                string sizeAttrs = mapSize != Size.Empty
                                                        ? String.Format(CultureInfo.InvariantCulture, " width=\"{0}\" height=\"{1}\"", mapSize.Width, mapSize.Height) : "";
                imageHtml = String.Format(CultureInfo.InvariantCulture, "<img src=\"{0}\"{1} alt=\"{2}\">", HtmlServices.HtmlEncode(imageUri.ToString()), sizeAttrs, HtmlServices.HtmlEncode(imgAltText));
            }
            else
            {
                if (imageHtml.Equals(String.Empty))
                {
                    imageHtml = Res.Get(StringId.ViewMap);
                }
            }

            string clickToViewAttr = editor ? "" : String.Format(CultureInfo.InvariantCulture, " alt=\"{0}\" title=\"{0}\"", clickToViewText);
            string mapHtml         = String.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\" id=\"{2}\"{3}>{1}</a>",
                                                   HtmlServices.HtmlEncode(settings.LiveMapUrl), imageHtml, settings.MapId, clickToViewAttr);

            if (imageUri != null && settings.Caption != String.Empty)
            {
                //append the caption HTML
                mapHtml += String.Format(CultureInfo.InvariantCulture, _pluginOptions.CaptionHtmlFormat, HtmlServices.HtmlEncode(settings.Caption), settings.MapId);
            }
            return(mapHtml);
        }
 internal static string CreateInnerAnchor(string imageUri, string mapAddress)
 {
     string anchorInnerHtml;
     if (imageUri != null)
     {
         anchorInnerHtml = "<img src=\"" + HtmlServices.HtmlEncode(imageUri) + "\" />";
     }
     else
     {
         anchorInnerHtml = mapAddress;
     }
     return anchorInnerHtml;
 }
Beispiel #7
0
        static void Main(string[] args)
        {
            ProductServices.SetAvailableToFalse();

            var category_links = System.IO.File.ReadAllLines(
                @"C:\Coding\scraper\scraperLinks\scraperLinks\category_links.txt");

            Console.WriteLine("How many threads to use?");
            int threadCount     = int.Parse(Console.ReadLine());
            int threadLinkCount = category_links.Length / threadCount;

            List <List <string> > categorySplitList = new List <List <string> >();

            for (int i = 0; i < threadCount; i++)
            {
                List <string> tempThreadList = new List <string>();
                for (int j = i * threadLinkCount,
                     c = (i == threadCount) ? category_links.Length : (i + 1) * threadLinkCount;
                     j < c;
                     j++)
                {
                    tempThreadList.Add(category_links[j]);
                }

                categorySplitList.Add(tempThreadList);
            }

            Stopwatch priceChangesStopwatch = new Stopwatch();

            priceChangesStopwatch.Start();

            Thread[] threadArray = new Thread[threadCount];

            for (int i = 0; i < threadCount; i++)
            {
                var index = i;
                threadArray[i] = new Thread(() => HtmlServices.AddingProduct(categorySplitList[index]));
                threadArray[i].Start();
            }


            priceChangesStopwatch.Stop();
            Console.WriteLine("Time for the Program to finish checking prices is  " + (priceChangesStopwatch.ElapsedMilliseconds / 60000).ToString()
                              + " minutes and " + ((priceChangesStopwatch.ElapsedMilliseconds % 60000) / 1000).ToString() + " seconds");

            Console.ReadLine();
        }
        /// <summary>
        /// Create content using an Insert dialog box.
        /// </summary>
        /// <param name="dialogOwner">Owner for any dialog boxes shown.</param>
        /// <param name="content">Newly created content. If there is an existing contiguous selection within the editor when CreateContent is called,
        /// the parameter will contain the contents of the selection by default.</param>
        /// <returns><see cref="DialogResult.OK"/> if content was successfully created, <see cref="DialogResult.Cancel"/> if the user cancels the Insert dialog.</returns>
        public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
        {
            DialogResult result = DialogResult.Cancel;

            content = HtmlServices.HtmlDecode(content);

            using (CodeForm form = new CodeForm(content))
            {
                result = form.ShowDialog(dialogOwner);
                if (result == DialogResult.OK)
                {
                    content = form.Code;
                }
            }

            return(result);
        }
Beispiel #9
0
        internal static string GenerateFlickrHtml(FlickrNet.Photo selectedPhoto, string imageUrl, string cssClass, string border, string vSpace, string hSpace, string alignment, bool hyperLink, string userId)
        {
            StringBuilder imageTag  = new StringBuilder();
            string        imageHtml = string.Empty;

            imageTag.Append("<img ");                                                                     // begin tag
            imageTag.Append(string.Format("src=\"{0}\" ", HtmlServices.HtmlEncode(imageUrl)));
            imageTag.Append(string.Format("alt=\"{0}\" ", HtmlServices.HtmlEncode(selectedPhoto.Title))); // alt required for XHTML
            imageTag.Append(string.Format("border=\"{0}\" ", HtmlServices.HtmlEncode(border)));

            if (cssClass.Trim().Length > 0)
            {
                imageTag.Append(string.Format("class=\"{0}\" ", cssClass));
            }

            if (hSpace.Trim().Length > 0 && hSpace != "0")
            {
                imageTag.Append(string.Format("hspace=\"{0}\" ", hSpace));
            }

            if (vSpace.Trim().Length > 0 && vSpace != "0")
            {
                imageTag.Append(string.Format("vspace=\"{0}\" ", vSpace));
            }

            if (alignment.Trim().Length > 0 && alignment.ToLower() != "none")
            {
                imageTag.Append(string.Format("align=\"{0}\" ", alignment.ToLower()));
            }

            imageTag.Append("/>"); // end tag XHTML

            imageHtml = imageTag.ToString();

            if (hyperLink)
            {
                imageHtml = string.Format("<a href=\"{0}\" title=\"{2}\">{1}</a>", HtmlServices.HtmlEncode(selectedPhoto.WebUrl), imageHtml, HtmlServices.HtmlEncode(selectedPhoto.Title));
                // TODO: Fix this temp hack in FlicrkNet library -- photoset photos array in FlickrAPI does not include owner attribute
                // thus the serialization lacks the Userid attribute to properly input the WebUrl
                // THIS IS A TEMP HACK TO FIX PHOTOSET ONLY
                imageHtml = FixPhotosetWebUrl(imageHtml, userId);
            }

            return(imageHtml);
        }
        internal SemanticHtmlPreviewManager(IBlogPostEditingSite editingSite, TemplateHtmlDelegate templateHtmlDelegate, int width, int height)
        {
            _previewLock          = new object();
            _editingSite          = editingSite;
            _templateHtmlDelegate = templateHtmlDelegate;
            _width  = width;
            _height = height;

            string previewText = HtmlServices.HtmlEncode(Res.Get(StringId.SemanticHtmlPreviewText));

            _postBodyHtml =
                @"<h1 {style} id=" + PreviewId_H1 + @">" + previewText + @"</h1>
                 <h2 {style} id=" + PreviewId_H2 + @">" + previewText + @"</h2>
                 <h3 {style} id=" + PreviewId_H3 + @">" + previewText + @"</h3>
                 <h4 {style} id=" + PreviewId_H4 + @">" + previewText + @"</h4>
                 <h5 {style} id=" + PreviewId_H5 + @">" + previewText + @"</h5>
                 <h6 {style} id=" + PreviewId_H6 + @">" + previewText + @"</h6>
                 <p  {style} id=" + PreviewId_P + @">" + previewText + @"</p>";
        }
Beispiel #11
0
        /// <summary>
        /// Returns HTML that can be inserted into the canvas to display an emoticon.
        /// </summary>
        public string GetHtml(Emoticon emoticon)
        {
            if (!CanInsertEmoticonImage)
            {
                // If we can't insert images, just return a plain-text emoticon.
                Debug.Assert(emoticon.AutoReplaceText.Count > 0, "Emoticon is missing autoreplace text.");
                return(emoticon.AutoReplaceText[0]);
            }

            Uri inlineImageUri;

            if (!_inlineImageUriTable.TryGetValue(emoticon, out inlineImageUri))
            {
                inlineImageUri = CreateInlineImage(emoticon);
            }

            return(String.Format(CultureInfo.InvariantCulture, "<img src=\"{0}\" style=\"border-style: none;\" alt=\"{1}\" class=\"{2} {3}\" />",
                                 UrlHelper.SafeToAbsoluteUri(inlineImageUri), HtmlServices.HtmlEncode(emoticon.AltText), Emoticon.CLASS_NAME, emoticon.Id));
        }
Beispiel #12
0
        internal static string GenerateContentHtml(Smugmug.Image selectedPhoto, string imageUrl, string cssClass, string border, string vSpace, string hSpace, string alignment, bool hyperlink)
        {
            StringBuilder imageTag  = new StringBuilder();
            string        imageHtml = string.Empty;

            imageTag.Append("<img ");                                                                       // begin tag
            imageTag.Append(string.Format("src=\"{0}\" ", HtmlServices.HtmlEncode(imageUrl)));
            imageTag.Append(string.Format("alt=\"{0}\" ", HtmlServices.HtmlEncode(selectedPhoto.Caption))); // alt required for XHTML
            imageTag.Append(string.Format("border=\"{0}\" ", HtmlServices.HtmlEncode(border)));

            if (cssClass.Trim().Length > 0)
            {
                imageTag.Append(string.Format("class=\"{0}\" ", cssClass));
            }

            if (hSpace.Trim().Length > 0 && hSpace != "0")
            {
                imageTag.Append(string.Format("hspace=\"{0}\" ", hSpace));
            }

            if (vSpace.Trim().Length > 0 && vSpace != "0")
            {
                imageTag.Append(string.Format("vspace=\"{0}\" ", vSpace));
            }

            if (alignment.Trim().Length > 0 && alignment.ToLower() != "none")
            {
                imageTag.Append(string.Format("align=\"{0}\" ", alignment.ToLower()));
            }

            imageTag.Append("/>"); // end tag XHTML

            imageHtml = imageTag.ToString();

            if (hyperlink)
            {
                imageHtml = string.Format("<a href=\"{0}\" title=\"{2}\">{1}</a>", HtmlServices.HtmlEncode(selectedPhoto.AlbumUrl), imageHtml, HtmlServices.HtmlEncode(selectedPhoto.Caption));
            }

            return(imageHtml);
        }
        public override void CreateContentFromUrl(string url, ref string title, ref string newContent)
        {
            Match m = Regex.Match(url, PHOTO_REGEX_URL);

            if (!m.Success)
            {
                base.CreateContentFromUrl(url, ref title, ref newContent);
            }
            else
            {
                string photoId = m.Groups["id"].Value;

                // get photo
                FlickrNet.Flickr flickrProxy = FlickrPluginHelper.GetFlickrProxy();

                FlickrNet.PhotoInfo photo = flickrProxy.PhotosGetInfo(photoId);

                title      = photo.Title;
                newContent = string.Format("<p><a href=\"{0}\" title=\"{2}\"><img alt=\"{2}\" border=\"0\" src=\"{1}\"></a></p>", photo.WebUrl, photo.MediumUrl, HtmlServices.HtmlEncode(photo.Title));
            }
        }