当前位置: 首页>>代码示例>>C#>>正文


C# Page.Save方法代码示例

本文整理汇总了C#中Page.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Page.Save方法的具体用法?C# Page.Save怎么用?C# Page.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page.Save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractImagesFromPDF

        public static void ExtractImagesFromPDF(string password, string key, string docPath, string pagePath, PageCollection pages)
        {
            Page page = null;
            // NOTE:  This will only get the first image it finds per page.
            PdfReader pdf = new PdfReader(Utility.Security.AES.DecryptFile(key, docPath));
            //RandomAccessFileOrArray raf = new iTextSharp.text.pdf.RandomAccessFileOrArray(p);

            try
            {
                for (int pageNumber = 1; pageNumber <= pdf.NumberOfPages; pageNumber++)
                {
                    PdfDictionary pg = pdf.GetPageN(pageNumber);

                    // recursively search pages, forms and groups for images.
                    PdfObject obj = FindImageInPDFDictionary(pg);
                    if (obj != null)
                    {

                        int XrefIndex = Convert.ToInt32(((PRIndirectReference)obj).Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                        PdfObject pdfObj = pdf.GetPdfObject(XrefIndex);
                        PdfStream pdfStrem = (PdfStream)pdfObj;
                        byte[] bytes = PdfReader.GetStreamBytesRaw((PRStream)pdfStrem);
                        if ((bytes != null))
                        {
                            using (System.IO.MemoryStream memStream = new System.IO.MemoryStream(bytes))
                            {
                                memStream.Position = 0;
                                System.Drawing.Image img = System.Drawing.Image.FromStream(memStream);
                                // must save the file while stream is open.

                                page = new Page();
                                page.Order = pages.Count;
                                page.Save();
                                page.Token = Utility.Security.AES.GetToken(page.Id, password);
                                //string path = System.IO.Path.Combine(page.Filename, String.Format(@"{0}.jpg", pageNumber));
                                System.Drawing.Imaging.EncoderParameters parms = new System.Drawing.Imaging.EncoderParameters(1);
                                parms.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 0);
                                System.Drawing.Imaging.ImageCodecInfo jpegEncoder = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders().FirstOrDefault(e => e.FormatDescription == "JPEG");
                                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                                img.Save(ms, jpegEncoder, parms);
                                System.IO.File.WriteAllBytes(System.IO.Path.Combine(pagePath, page.Filename), SoftFluent.Samples.GED.Utility.Security.AES.EncryptStream(page.Token, ms.ToArray()).ToArray());
                                ms.Close();
                                pages.Add(page);
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                pdf.Close();
                //raf.Close();
            }
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:58,代码来源:PDFManager.cs

示例2: ChangeParent

        /// <summary>
        /// Resets the parent page of the supplied page
        /// </summary>
        /// <param name="pageID"></param>
        /// <param name="newParentID"></param>
        public static void ChangeParent(int pageID, int? newParentID)
        {
            //make sure that we're not resetting to a child's ID
            if (!PageHasChildren(pageID)) {
                throw new Exception("Cannot move this page to the new location as the new page is a child of this page. Move the target page to a higher level first");
            } else {
                CMS.Page p = new Page(pageID);
                p.ParentID = newParentID;
                //save it
                p.Save(System.Web.HttpContext.Current.User.Identity.Name);

            }
        }
开发者ID:hondoslack,项目名称:territorysite,代码行数:18,代码来源:ContentService.cs

示例3: ApplicationStartup

        protected static void ApplicationStartup(object sender, ActiveEventArgs e)
        {
            Language.Instance.SetDefaultValue("ButtonAdmin", "Admin");
            Language.Instance.SetDefaultValue("ButtonCMS", "CMS");
            Language.Instance.SetDefaultValue("ButtonCMSViewPages", "View Pages");
            Language.Instance.SetDefaultValue("ButtonCMSCreatePage", "Create Page");
            Language.Instance.SetDefaultValue(
                "CMSPageDeleted",
                "CMS Page was deleted. Application had to be refreshed");

            // Creating default page - if necessary...!
            if (Page.CountWhere(Criteria.Eq("URL", "home")) == 0)
            {
                Page p = new Page();
                p.Header = "Home";
                p.Body = string.Format(@"
<a href=""http://ra-brix.org"" title=""Visit the Ra-Brix website"">
<img src=""media/skins/Gold/Images/bazaar.png"" style=""float:right;margin-left:10px;margin-top:-40px;"" alt=""Visit the Ra-Brix Bazaar"" />
</a>
<p>
    Welcome to Ra-Brix. This is the default page which has been created for you.
</p>
<p>
    The first time you login a user will be created for you with the given OpenID identity
    and the first user to login will become an Administrator and Power User automatically.
</p>
<p>
    If you don't know what OpenID is then you can create an OpenID (and get a good explanation about
    it) at <a href=""http://myopenid.com"" target=""_blank"">MyOpenID.com</a>...
</p>
<p>
    Then when you have logged in, you will want to visit our Bazaar where you can find a lot
    of modules and components you can install in your portal. Some for free and others for
    a fee.
</p>
<p>
    Tutorials, more downloads, updates and videos about how to use Ra-Brix can be 
    found at <a href=""http://ra-brix.org"">the Ra-Brix website</a>.
</p>
");
                p.URL = "home";
                p.HideFromMenu = false;
                p.Save();
                ActiveEvents.Instance.RaiseActiveEvent(
                    typeof(CMSController),
                    "DefaultCMSContentCreated");
            }
        }
开发者ID:greaterwinner,项目名称:ra-brix,代码行数:48,代码来源:CMSController.cs

示例4: Save

        static bool Save(Page page, PageDetail detail)
        {
            page.Title = detail.Title;
            page.DateCreated = DateTime.ParseExact(detail.DateCreated, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
            page.IsPublished = detail.IsPublished;
            page.ShowInList = detail.ShowInList;
            page.IsDeleted = detail.IsDeleted;
            page.Content = detail.Content;
            page.Description = GetDescription(detail.Description, detail.Content);
            page.Keywords = detail.Keywords;
            page.IsFrontPage = detail.IsFrontPage;
            page.SortOrder = detail.SortOrder;

            // if changing slug, should be unique
            if (page.Slug != detail.Slug)
                page.Slug = GetUniqueSlug(detail.Slug);

            if (detail.Parent.OptionValue == "none")
            {
                page.Parent = Guid.Empty;
            }
            else
            {
                if (detail.Parent != null && detail.Parent.OptionValue != null)
                {
                    try
                    {
                        page.Parent = Guid.Parse(detail.Parent.OptionValue);
                    }
                    catch (Exception)
                    {
                        Utils.Log("Error parsing parent ID while saving page");
                    }
                }
            }

            page.Save();
            return true;
        }
开发者ID:CharlesZHENG,项目名称:BlogEngine.NET,代码行数:39,代码来源:PageRepository.cs

示例5: NewPage

        /// <summary>
        /// wp.newPage method
        /// </summary>
        /// <param name="blogId">blogID in string format</param>
        /// <param name="userName">login username</param>
        /// <param name="password">login password</param>
        /// <param name="mwaPage">The mwa page.</param>
        /// <param name="publish">if set to <c>true</c> [publish].</param>
        /// <returns>The new page.</returns>
        internal string NewPage(string blogId, string userName, string password, MWAPage mwaPage, bool publish)
        {
            if (!Security.IsAuthorizedTo(Rights.CreateNewPages))
            {
                throw new MetaWeblogException("11", "User authentication failed");
            }

            var page = new Page
                {
                    Title = mwaPage.title,
                    Content = mwaPage.description,
                    Description = string.Empty,
                    Keywords = mwaPage.mt_keywords
                };

            if (publish)
            {
                if (!page.CanPublish())
                {
                    throw new MetaWeblogException("11", "Not authorized to publish this Page.");
                }
            }

            if (mwaPage.pageDate != new DateTime())
            {
                page.DateCreated = mwaPage.pageDate;
            }

            page.ShowInList = publish;
            page.IsPublished = publish;
            if (mwaPage.pageParentID != "0")
            {
                page.Parent = new Guid(mwaPage.pageParentID);
            }

            page.Save();

            return page.Id.ToString();
        }
开发者ID:doct15,项目名称:blogengine,代码行数:48,代码来源:MetaWeblogHandler.cs

示例6: NewAjax

        public ActionResult NewAjax(string dirId, string fileName, string fileContent, string docId, bool forceDoc = false)
        {
            bool newDoc = false;
            bool multiPage = false;
            Guid idPage = new Guid();

            if (fileName.EndsWith(".pdf"))
            {
                multiPage = true;
            }

            Document document;
            PageCollection pages;
            if (string.IsNullOrWhiteSpace(docId) || (multiPage && !forceDoc))
            {
                newDoc = true;
                document = new Document();
                pages = new PageCollection();

                //document.Extension = Path.GetExtension(fileName);
                document.DirectoryId = Guid.Parse(dirId);
                document.UserId = UserId;
                document.Title = fileName;
                document.IsReady = false;
                document.IsProcessed = false;
                document.Token = null;
                document.Save();
            }
            else
            {
                document = Document.LoadById(Guid.Parse(docId));
                pages = document.Pages;
            }

            document.Token = Utility.Security.AES.GetToken(document.Id, UserPassword);

            // generate file paths
            string path = Path.Combine(Server.MapPath(Utility.Misc.Constants.docDirectory), Guid.NewGuid().ToString());
            // upload original file
            System.IO.File.WriteAllBytes(path, Utility.Security.AES.EncryptBytes(document.Token, Convert.FromBase64String(fileContent)));

            if (fileName.EndsWith(".pdf"))
            {
                string pathPDF = Server.MapPath(Utility.Misc.Constants.pageDirectory);
                Utility.Image.PDFManager.ExtractImagesFromPDF(UserPassword, document.Token, path, pathPDF, pages);
            }
            else
            {
                Page page = null;
                page = new Page();
                page.IsReady = false;
                page.IsProcessed = false;
                page.Order = pages.Count;
                page.Save();
                page.Token = Utility.Security.AES.GetToken(page.Id, UserPassword);
                idPage = page.Id;
                Utility.Image.Treatment.Convert(document.Token, Server.MapPath(Utility.Misc.Constants.pageDirectory), page, path);
                pages.Add(page);
            }

            System.IO.File.Delete(path);

            if (newDoc || pages.Count == 1)
            {
                Utility.Image.Treatment.Thumbize(Server.MapPath(Utility.Misc.Constants.pageDirectory), Server.MapPath(Utility.Misc.Constants.thumbDirectory), document, pages.First());
            }

            bool docProcessed = true;
            foreach (Page p in pages)
            {
                if (p.IsProcessed == false)
                {
                    docProcessed = false;
                }

                p.DocumentId = document.Id; // a faire plus haut...
                p.IsReady = true;
            }

            pages.SaveAll();

            document.IsProcessed = docProcessed;
            document.IsReady = true;
            document.Token = null;
            document.Save();

            return Json(new { multipage = multiPage, id = document.Id, title = document.Title, idPage = idPage });
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:88,代码来源:HomeController.cs

示例7: NewPage

        /// <summary>
        /// wp.newPage
        /// </summary>
        /// <param name="blogID">blogID in string format</param>
        /// <param name="userName">login username</param>
        /// <param name="password">login password</param>
        /// <param name="mPage"></param>
        /// <param name="publish"></param>
        /// <returns></returns>
        internal string NewPage(string blogID, string userName, string password, MWAPage mPage, bool publish)
        {
            ValidateRequest(userName, password);

            Page page = new Page();
            page.Title = mPage.title;
            page.Content = mPage.description;
            page.Description = ""; // Can not be set from WLW
            page.Keywords = mPage.mt_keywords;
            if (mPage.pageDate != new DateTime())
                page.DateCreated = mPage.pageDate;
            page.ShowInList = publish;
            page.IsPublished = publish;
            if (mPage.pageParentID != "0")
                page.Parent = new Guid(mPage.pageParentID);

            page.Save();

            return page.Id.ToString();
        }
开发者ID:rajgit31,项目名称:RajBlog,代码行数:29,代码来源:MetaWeblogHandler.cs

示例8: Save

        static bool Save(Page page, PageDetail detail)
        {
            page.Title = detail.Title;
            page.DateCreated = DateTime.ParseExact(detail.DateCreated, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
            page.IsPublished = detail.IsPublished;
            page.ShowInList = detail.ShowInList;
            page.IsDeleted = detail.IsDeleted;
            page.Slug = detail.Slug;
            page.Content = detail.Content;
            page.Description = detail.Description;
            page.Keywords = detail.Keywords;
            page.IsFrontPage = detail.IsFrontPage;

            if (detail.Parent != null)
            {
                try
                {
                    page.Parent = Guid.Parse(detail.Parent.OptionValue);
                }
                catch (Exception)
                {
                    Utils.Log("Error parsing parent ID while adding new page");
                }
            }
            page.Save();
            return true;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:27,代码来源:PageRepository.cs

示例9: Insert

        public void Insert(Guid PageGuid,int ParentId,string Title,string MenuTitle,string Keywords,string Description,int SortOrder,int TemplateId,string CreatedBy,DateTime CreatedOn,string ModifiedBy,DateTime ModifiedOn)
        {
            Page item = new Page();

            item.PageGuid = PageGuid;

            item.ParentId = ParentId;

            item.Title = Title;

            item.MenuTitle = MenuTitle;

            item.Keywords = Keywords;

            item.Description = Description;

            item.SortOrder = SortOrder;

            item.TemplateId = TemplateId;

            item.CreatedBy = CreatedBy;

            item.CreatedOn = CreatedOn;

            item.ModifiedBy = ModifiedBy;

            item.ModifiedOn = ModifiedOn;

            item.Save(UserName);
        }
开发者ID:git00n1,项目名称:dashcommerce-3,代码行数:30,代码来源:PageController.cs

示例10: CMSCreateNewPage

        protected void CMSCreateNewPage(object sender, ActiveEventArgs e)
        {
            string name = e.Params["Name"].Get<string>();
            string parentURL = e.Params["Parent"].Get<string>();

            if (parentURL == "xxx-no-parent")
            {
                Page n = new Page();
                n.Header = name;
                n.Body = "<p>Default Text - change this...</p>";
                n.Save();
            }
            else
            {
                parentURL = parentURL.Replace("xxx-value", "");
                Page p = ActiveType<Page>.SelectFirst(Criteria.Eq("URL", parentURL));
                Page n = new Page();
                n.Header = name;
                p.Children.Add(n);
                p.Save();
            }
#pragma warning disable 168
            // Making sure we're getting the language correctly...
            string tmpBugger = Language.Instance["CMSPageCreated", null, "CMS Page was created. Application had to be refreshed"];
#pragma warning restore 168
            AjaxManager.Instance.Redirect("~/?message=CMSPageCreated");
        }
开发者ID:greaterwinner,项目名称:ra-brix,代码行数:27,代码来源:CMSController.cs


注:本文中的Page.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。