Beispiel #1
0
        public BaseStep()
        {
            var objectContainer = (IObjectContainer)ScenarioContext.Current.GetBindingInstance(typeof(IObjectContainer));
            var driverContainer = objectContainer.Resolve <WebDriverContainer>();

            Pages = new PageCollection(driverContainer.WebDriver);
        }
Beispiel #2
0
        public static string GetArticleTrashList(int startIndex, int maximumRows, string sortExpressions)
        {
            Guid subId = SessionHelper.GetSession(SessionKey.SubDomain) == string.Empty ? Guid.Empty : new Guid(SessionHelper.GetSession(SessionKey.SubDomain));

            if (subId == Guid.Empty)
            {
                DisplayArticleTrashList = ArticleTrashList.ToList();
            }
            else
            {
                DisplayArticleTrashList = new List <Article>();
                PSCPortal.Engine.SubDomain subDomain = new PSCPortal.Engine.SubDomain {
                    Id = subId
                };
                PageCollection listPage = subDomain.GetPagesBelongTo();
                foreach (var item in listPage)
                {
                    foreach (var article in ArticleTrashList.Where(ar => ar.PageId == item.Id))
                    {
                        DisplayArticleTrashList.Add(article);
                    }
                }
            }
            // kiem tra nhung bai viet duoc goi den da xu ly ?
            foreach (var item in ArticleSendList.Where(ar => ar.IsCheck == false))
            {
                Article article = DisplayArticleTrashList.SingleOrDefault(ar => ar.Id == item.Id);
                if (article != null)
                {
                    DisplayArticleTrashList.Remove(article);
                }
            }
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            return(js.Serialize(Libs.IEnumerableExtentionMethods.GetSegmentList(DisplayArticleTrashList, startIndex, maximumRows, sortExpressions)));
        }
Beispiel #3
0
        protected List <CmsPage> GetFilteredPageList(PageCollection pageCollection)
        {
            var hasCustomFilter = Filter != null;
            var pageList        = new List <CmsPage>();

            foreach (CmsPage page in pageCollection)
            {
                if (PageState == PublishState.Published && !page.IsAvailable)
                {
                    continue;
                }

                if (PageState == PublishState.Unpublished && page.IsAvailable)
                {
                    continue;
                }

                if (hasCustomFilter && !Filter(page))
                {
                    continue;
                }

                pageList.Add(page);
            }

            return(pageList);
        }
Beispiel #4
0
        public void AddRangeTest1()
        {
            PageCollection     target = new PageCollection();
            IEnumerable <Page> pages  = null;

            Assert.Throws <ArgumentNullException>(() => target.AddRange(pages));
        }
Beispiel #5
0
        //Thống kê truy cập bài viết
        public static List <Article> ThongKeTruyCapBaiViet(string tungay, string denngay)
        {
            PSCPortal.CMS.ArticleCollection ArticleList = ArticleCollection.GetArticleViewTimeCollectionPublish();
            List <Article> result = new List <Article>();
            Guid           subId  = SessionHelper.GetSession(SessionKey.SubDomain) == string.Empty ? Guid.Empty : new Guid(SessionHelper.GetSession(SessionKey.SubDomain));

            if (subId == Guid.Empty)
            {
                result = ArticleList.ToList();
            }
            else
            {
                result = new List <Article>();
                PSCPortal.Engine.SubDomain subDomain = new PSCPortal.Engine.SubDomain {
                    Id = subId
                };
                nameWorksheet = PSCPortal.Engine.SubDomain.GetSubById(subId.ToString()).Description;
                PageCollection listPage = subDomain.GetPagesBelongTo();
                foreach (var item in listPage)
                {
                    foreach (var article in ArticleList.Where(ar => ar.PageId == item.Id))
                    {
                        result.Add(article);
                    }
                }
            }
            if (tungay != string.Empty && denngay != string.Empty)
            {
                IFormatProvider provider  = new System.Globalization.CultureInfo("en-CA", true);
                DateTime        startDate = DateTime.Parse(tungay, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
                DateTime        endDate   = DateTime.Parse(denngay, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
                result = result.Where(ar => ar.CreatedDate >= startDate && ar.CreatedDate <= endDate).ToList <Article>();
            }
            return(result);
        }
Beispiel #6
0
        public IDictionary <long, int> ListPageForumCounts(long tenantId, IEnumerable <Page> pages, IUnitOfWork unitOfWork = null)
        {
            PageCollection pageCollection = new PageCollection();

            foreach (Page page in pages)
            {
                pageCollection.Add(page);
            }
            IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork);

            try
            {
                string sql = _sqlManager.GetSql("Sql.ListPageForumCounts.sql");
                dbm.SetSQL(sql);
                dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId);
                dbm.AddTypedParameter("@Pages", FieldType.Structured, pageCollection.Count == 0 ? null : pageCollection, "cms.PageTableType");
                dbm.ExecuteReader();
                Dictionary <long, int> countsByPageId = new Dictionary <long, int>();
                while (dbm.Read())
                {
                    long pageId      = (long)dbm.DataReaderValue("PageId");
                    int  threadCount = (int)dbm.DataReaderValue("ThreadCount");
                    int  postCount   = (int)dbm.DataReaderValue("PostCount");
                    countsByPageId.Add(pageId, threadCount + postCount);
                }
                return(countsByPageId);
            }
            finally
            {
                if (unitOfWork == null)
                {
                    dbm.Dispose();
                }
            }
        }
Beispiel #7
0
        public static void Run()
        {
            // ExStart:UpdateDimensions
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Pages();

            // Open document
            Document pdfDocument = new Document(dataDir + "UpdateDimensions.pdf");

            // Get page collection
            PageCollection pageCollection = pdfDocument.Pages;

            // Get particular page
            Page pdfPage = pageCollection[1];

            // Set the page size as A4 (11.7 x 8.3 in) and in Aspose.Pdf, 1 inch = 72 points
            // So A4 dimensions in points will be (842.4, 597.6)
            pdfPage.SetPageSize(597.6, 842.4);

            dataDir = dataDir + "UpdateDimensions_out_.pdf";
            // Save the updated document
            pdfDocument.Save(dataDir);
            // ExEnd:UpdateDimensions
            System.Console.WriteLine("\nPage dimensions updated successfully.\nFile saved at " + dataDir);
        }
Beispiel #8
0
        private static PageCollection BuildReactionList(IEnumerable <Reaction> reactions, string title, string footer = null)
        {
            var pages = new PageCollection();
            int count = 0;

            foreach (var reaction in reactions.OrderBy(x => x.Trigger).ThenBy(x => x.Id))
            {
                if (count++ % 10 == 0)
                {
                    var embed = new EmbedBuilder().WithTitle(title);

                    if (!string.IsNullOrEmpty(footer))
                    {
                        embed.WithFooter(footer);
                    }

                    pages.Add(embed);
                }

                pages.Last.Embed.AddField(x => x
                                          .WithName($"{reaction.Id}: {reaction.Trigger}".Truncate(EmbedBuilder.MaxTitleLength))
                                          .WithValue(reaction.Value.Truncate(500)));
            }

            return(pages);
        }
Beispiel #9
0
        public void AddTest1()
        {
            PageCollection target = new PageCollection();
            Page           page   = null;

            Assert.Throws <ArgumentNullException>(() => target.Add(page));
        }
Beispiel #10
0
        public static PageCollection GetPages()
        {
            if (Config.Current.sArrayValue[Enums.sArrayValue.Pages] != null)
            {
                if (Config.Current.sArrayValue[Enums.sArrayValue.Pages].Length != 0)
                {
                    try
                    {
                        PageCollection pages = null;
                        for (int i = 0; Config.Current.sArrayValue[Enums.sArrayValue.Pages].Length > i; i++)
                        {
                            if (Config.Current.sArrayValue[Enums.sArrayValue.Pages][i] == "Plugin")
                            {
                                pages = PluginManager.GetPages();
                            }
                            {
                                LAPP.Page p = Utility.GetPageFromString(Config.Current.sArrayValue[Enums.sArrayValue.Pages][i]);
                                if (p != null)
                                {
                                    pages = new PageCollection(false);
                                    pages.Add(p);
                                }
                            }
                        }
                        return(pages);
                    }
                    catch (Exception) { }
                }
            }

            return(new PageCollection(false));
        }
Beispiel #11
0
        public void Initialize()
        {
            var root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            autoweb = new PageCollection();
            autoweb.OpenBrowser(Constants.TemplateFile);
        }
Beispiel #12
0
        public void AddTest()
        {
            PageCollection target = new PageCollection();
            Page           page   = new Page();

            target.Add(page);
        }
        /// <summary>
        /// Loads the children.
        /// </summary>
        /// <param name="pageId">The page id.</param>
        private void LoadChildren(int pageId)
        {
            PageCollection pageCollection = new PageCollection().
                                            Where(Content.Page.Columns.ParentId, Comparison.Equals, pageId).
                                            OrderByAsc(Content.Page.Columns.SortOrder).
                                            Load();

            if (pageCollection.Count > 0)
            {
                dgChildren.DataSource            = pageCollection;
                dgChildren.Columns[0].HeaderText = LocalizationUtility.GetText("hdrMove");
                dgChildren.Columns[1].HeaderText = LocalizationUtility.GetText("hdrTitle");
                dgChildren.Columns[2].HeaderText = LocalizationUtility.GetText("hdrSortOrder");
                dgChildren.DataBind();
                ImageButton lbUp = dgChildren.Items[0].Cells[1].FindControl("lbUp") as ImageButton;
                if (lbUp != null)
                {
                    lbUp.Visible = false;
                }
                ImageButton lbDown = dgChildren.Items[dgChildren.Items.Count - 1].Cells[1].FindControl("lbDown") as ImageButton;
                if (lbDown != null)
                {
                    lbDown.Visible = false;
                }
            }
        }
Beispiel #14
0
 /* ----------------------------------------------------------------- */
 ///
 /// InitializeModels
 ///
 /// <summary>
 /// 各種モデルの初期化を行います。
 /// </summary>
 ///
 /// <remarks>
 /// MainForm にはモデルに関する初期化処理は最低限に留めます。
 /// </remarks>
 ///
 /* ----------------------------------------------------------------- */
 private void InitializeModels()
 {
     Pages = new PageCollection(Settings.Root);
     Pages.Tags.Everyone.Name = Properties.Resources.EveryoneTag;
     Pages.Tags.Nothing.Name  = Properties.Resources.NothingTag;
     Settings.Load();
 }
        /// <summary>
        /// This is the event handler for PrintDocument.AddPages. It provides all pages to be printed, in the form of
        /// UIElements, to an instance of PrintDocument. PrintDocument subsequently converts the UIElements
        /// into a pages that the Windows print system can deal with.
        /// </summary>
        /// <param name="sender">The print document.</param>
        /// <param name="e">Arguments containing the print task options.</param>
        protected override async void OnAddPrintPages(object sender, AddPagesEventArgs e)
        {
            var printDoc = sender as PrintDocument;

            // Loop over all of the preview pages.
            for (int i = 0; i < NumberOfPhotos; i++)
            {
                UIElement page      = null;
                bool      pageReady = false;

                lock (PrintSync)
                {
                    pageReady = PageCollection.TryGetValue(i, out page);
                }

                if (!pageReady)
                {
                    // If the page is not ready create a task that will generate its content.
                    page = await GeneratePageAsync(i + 1, CurrentPageDescription);
                }

                printDoc.AddPage(page);
            }

            // Indicate that all of the print pages have been provided.
            printDoc.AddPagesComplete();

            // Reset the current page description as soon as possible since the
            // PrintTask.Completed event might fire later (long running job).
            CurrentPageDescription = null;
        }
    public void AddChildNodes(ref SiteMapNode parentNode, PageCollection links)
    {
        //you can change this as needed
        string rewrittenDirectory = "~/view/";
        foreach (Page link in links)
        {
            if (link.ParentID.HasValue)
            {
                if (link.ParentID.Value.ToString() == parentNode.Key)
                {
                    string url = link.PageUrl;
                    var rolelist = link.Roles.Split(new char[] { ',', ';' }, 512);
                    if (!url.Contains("registered/") & !url.Contains("admin/"))
                    {
                        url = rewrittenDirectory + url;
                    }
                    // Create a SiteMapNode
                    SiteMapNode node = new SiteMapNode(this, link.PageID.ToString(), url, link.MenuTitle, link.Summary, rolelist, null, null, null);
                    AddNode(node, parentNode);
                    AddChildNodes(ref node, links);
                }
            }

        }
    }
 public PageObjects()
 {
     Pages = new PageCollection
     {
         Dashboard           = new Pages.Dashboard(),
         EditFeatures        = new Pages.EditFeatures(),
         SolutionDescription = new Pages.SolutionDescription(),
         Common                 = new Pages.Common(),
         PreviewPage            = new Pages.PreviewPage(),
         ClientApplicationTypes = new Pages.ClientApplicationTypes(),
         BrowserBasedDashboard  = new Pages.BrowserBasedDashboard(),
         BrowserBasedSections   = new BrowserBasedSections()
         {
             BrowsersSupported         = new Pages.BrowsersSupported(),
             PluginsOrExtensions       = new Pages.PluginsOrExtensions(),
             HardwareRequirements      = new Pages.HardwareRequirements(),
             ConnectivityAndResolution = new Pages.ConnectivityAndResolution(),
             MobileFirst = new Pages.MobileFirst(),
         },
         NativeMobileSections = new NativeMobileSections()
         {
             SupportedOperatingSystems      = new Pages.SupportedOperatingSystems(),
             MemoryAndStorage               = new Pages.MemoryAndStorage(),
             ThirdPartyComponentsAndDevices = new Pages.ThirdPartyComponentsAndDevices()
         },
         ContactDetails = new Pages.ContactDetails()
     };
 }
 public PageCollection FetchAll()
 {
     PageCollection coll = new PageCollection();
     Query qry = new Query(Page.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
Beispiel #19
0
        /// <summary>
        /// Create Performer View Models for each performer
        /// (order albums, calculate rate and count the number of albums)
        /// </summary>
        /// <param name="performers">Pre-selected collection of performers to work with</param>
        private async Task FillPerformerViewModelsAsync(PageCollection <PerformerDto> performers)
        {
            // why not?
            GC.Collect();
            GC.WaitForPendingFinalizers();

            CreatePageNavigationPanel(performers.TotalPages);

            Performers.Clear();
            foreach (var performer in performers.Items)
            {
                var performerViewModel = Mapper.Map <PerformerViewModel>(performer);

                // Fill performer's albumlist
                var albums = await _performerService.GetPerformerAlbumsAsync(performer.Id, AlbumPattern);

                performerViewModel.Albums = Mapper.Map <ObservableCollection <AlbumViewModel> >(albums);

                // Recalculate total rate and number of albums of performer
                performerViewModel.UpdateAlbumCollectionRate(_rateCalculator);

                // Finally, add fully created performer view model to the list
                Performers.Add(performerViewModel);

                // some animation effect )))
                await Task.Delay(50);
            }
        }
Beispiel #20
0
        public static void Upload(PageCollection pageCollection)
        {
            OutputPort onboardLed = new OutputPort(ShieldConfiguration.CurrentConfiguration.OnboardLedPin, true);

            SPI.Configuration spiConfig = new SPI.Configuration(
                ShieldConfiguration.CurrentConfiguration.SpiChipSelectPin,
                false,
                100,
                100,
                false,
                true,
                1000,
                ShieldConfiguration.CurrentConfiguration.SpiModule
                );
            var spi      = new SpotSpi(spiConfig);
            var uploader = new Uploader(spi);

            if (uploader.IsShieldInBootloaderMode())
            {
                var uploadStatusIndicator = new UploadStatusIndicator(
                    spi
                    );

                try
                {
                    //var securityRegisterData = uploader.SecurityRegisterRead();
                    //var userData = new byte[Constants.SecurityRegisterUserFieldLength];
                    //Array.Copy(securityRegisterData, 4, userData, 0, userData.Length);
                    //var userDataString = new string(System.Text.Encoding.UTF8.GetChars(userData));
                    //Debug.Print("Programming \"" + userDataString + "\"");
                    uploadStatusIndicator.Status = UploadStatusIndicator.UploadStatus.Uploading;
                    uploader.UploadBitstream(pageCollection);
                    uploadStatusIndicator.Status = UploadStatusIndicator.UploadStatus.Succeeded;
                }
                catch
                {
                    // Any exception is a failed upload

                    uploadStatusIndicator.Status = UploadStatusIndicator.UploadStatus.Failed;
                    throw;
                }
                finally
                {
                    onboardLed.Write(false);
                }
            }
            else
            {
                // Flash the onboard LED to indicate upload failure due to
                // not being in bootstrapping mode

                Thread.Sleep(500);
                onboardLed.Write(false);
                Thread.Sleep(500);
                onboardLed.Write(true);
                Thread.Sleep(500);
                onboardLed.Write(false);
            }
        }
Beispiel #21
0
        public void ToStringTest()
        {
            PageCollection target   = new PageCollection();
            string         expected = string.Empty;
            string         actual   = target.ToString();

            Assert.Equal(expected, actual);
        }
        internal PageCollection GetPagesByCriteria(Predicate <PageIndexItem> match)
        {
            var pageCollection = new PageCollection();

            _pageIndex.FindAll(match).ForEach(t => pageCollection.Add(t.PageId));

            return(pageCollection);
        }
Beispiel #23
0
        public void test1a()
        {
            var pages = new PageCollection();

            var page = pages[42];

            AssertEquals(42, page.Index);
        }
Beispiel #24
0
        public void test1b()
        {
            IReadOnlyCollection <Page> pages = new PageCollection();

            var page = pages[42];

            AssertEquals(42, page.Index);
        }
 /// <summary>
 /// Helper function that clears the page collection and also the pages attached to the "visual root".
 /// </summary>
 private void ClearPageCollection()
 {
     lock (PrintSync)
     {
         PageCollection.Clear();
         PrintCanvas.Children.Clear();
     }
 }
        /// <summary>
        /// Wizard control with designer support
        /// </summary>
        public KryptonWizard()
        {
            //Empty collection of Pages
            vPages = new PageCollection(this);

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
        }
        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();
            }
        }
Beispiel #28
0
        public void TestBrowserNavigation()
        {
            using var local = new PageCollection();
            local.OpenBrowser(Constants.TemplateFile);

            var url = Path.GetFullPath(local.Browser.Url.Replace("file:///", ""));

            Assert.IsTrue(url == Constants.TemplateFile);
        }
Beispiel #29
0
        public string SearchAndPaging(string strQuery, string index)
        {
            string result = string.Empty;

            try
            {
                List <SearchArticle>            searchArticleList = new List <SearchArticle>();
                PSCPortal.CMS.ArticleCollection ArticleList       = ArticleCollection.GetArticleCollectionPublish();
                string         nameSub       = Libs.Ultility.GetSubDomain() == string.Empty ? "HomePage" : Libs.Ultility.GetSubDomain();
                SubDomain      subDomain     = PSCPortal.Engine.SubDomain.GetSubByName(nameSub);
                PageCollection pagesBelongTo = subDomain.GetPagesBelongTo();
                string         strId         = string.Empty;
                foreach (var page in pagesBelongTo)
                {
                    foreach (var ar in ArticleList.Where(ar => ar.PageId == page.Id))
                    {
                        strId += ar.Id + " OR ";
                    }
                    if (strId.Length > 0)
                    {
                        strId = strId.Remove(strId.Length - 3, 3);
                    }
                }
                int    pageIndex = Int32.Parse(index);
                string strSearch = " ArticleDetail:(" + strQuery + ") AND ArticleId:" + "( " + strId + " )";
                Lucene.Net.Index.IndexReader        reader           = Lucene.Net.Index.IndexReader.Open(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["IndexingArticle"]));
                Lucene.Net.QueryParsers.QueryParser parser           = new Lucene.Net.QueryParsers.QueryParser("ArticleDetail", new Lucene.Net.Analysis.Standard.StandardAnalyzer());
                Lucene.Net.Search.Query             query            = parser.Parse(strSearch);
                Lucene.Net.Search.IndexSearcher     searcher         = new Lucene.Net.Search.IndexSearcher(reader);
                Lucene.Net.Search.Hits                   hits        = searcher.Search(query);
                Lucene.Net.Highlight.QueryScorer         score       = new Lucene.Net.Highlight.QueryScorer(query);
                Lucene.Net.Highlight.SimpleHTMLFormatter formater    = new Lucene.Net.Highlight.SimpleHTMLFormatter("<span class='Highlight'>", "</span>");
                Lucene.Net.Highlight.Highlighter         highlighter = new Lucene.Net.Highlight.Highlighter(formater, score);
                result += hits.Length() + "_" + "<div class='blog_news'><div class='topic_news_title1'><div class='topic_news_title'><a href='#'>Kết quả tìm thấy: " + hits.Length() + "</a></div></div>";
                result += "<div class='ct_topic_l'><div class='ct_topic_r1'>";
                for (int i = pageIndex * 20 - 20; i < pageIndex * 20 && i < hits.Length(); i++)
                {
                    string detail = hits.Doc(i).Get("ArticleDetail");
                    Lucene.Net.Analysis.TokenStream ts = (new Lucene.Net.Analysis.Standard.StandardAnalyzer()).TokenStream("ArticleDetail", new System.IO.StringReader(detail));
                    SearchArticle searchArticle        = new SearchArticle();
                    searchArticle.Id        = hits.Doc(i).Get("ArticleId");;
                    searchArticle.Title     = hits.Doc(i).Get("ArticleTitle");
                    searchArticle.Highligth = highlighter.GetBestFragment(ts, detail);
                    searchArticleList.Add(searchArticle);
                }
                reader.Close();
                JavaScriptSerializer        serializer = new JavaScriptSerializer();
                Dictionary <string, object> resultDic  = new Dictionary <string, object>();
                resultDic["Count"] = hits.Length();
                resultDic["Data"]  = searchArticleList;
                result             = serializer.Serialize(resultDic);
            }
            catch (Exception e)
            {
            }
            return(result);
        }
 /* ----------------------------------------------------------------- */
 ///
 /// TagCollectionPresenter
 ///
 /// <summary>
 /// オブジェクトを初期化します。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 public TagCollectionPresenter(ComboBox view, PageCollection pages,
                               SettingsFolder settings, EventAggregator events)
     : base(view, pages.Tags, settings, events)
 {
     View.DrawMode    = DrawMode.OwnerDrawFixed;
     View.DrawItem   += View_DrawItem;
     View.MouseWheel += View_MouseWheel;
     Model.Loaded    += Model_Loaded;
 }
Beispiel #31
0
        public async Task Views(ICommand command)
        {
            var settings = await _settings.Read<MediaSettings>(command.GuildId);
            string param = string.IsNullOrWhiteSpace(command["SongOrCategoryName"]) ? null : (string)command["SongOrCategoryName"];

            List<ComebackInfo> comebacks;
            if (string.Compare("all", param, true) == 0)
            {
                comebacks = settings.YouTubeComebacks;
            }
            else
            {
                comebacks = settings.YouTubeComebacks.Where(x => string.Compare(x.Category, param, true) == 0).ToList();
                if (comebacks.Count <= 0 && !string.IsNullOrWhiteSpace(param))
                    comebacks = settings.YouTubeComebacks.Where(x => x.Name.Search(param, true)).ToList();
            }

            if (comebacks.Count <= 0)
            {
                string rec;
                if (settings.YouTubeComebacks.Count <= 0)
                    rec = "Use the `views add` command.";
                else
                    rec = "Try " + GetOtherCategoriesRecommendation(settings, param, true, command.Prefix) + ".";

                await command.ReplyError($"No comeback info has been set for this category or song. {rec}");
                return;
            }

            // Get YT data
            var pages = new PageCollection();
            var infos = new List<Tuple<ComebackInfo, YoutubeInfo>>();
            foreach (var comeback in comebacks)
                infos.Add(Tuple.Create(comeback, await GetYoutubeInfo(comeback.VideoIds, _integrationOptions.Value.YouTubeKey)));

            // Compose embeds with info
            string recommendation = "Try also: " + GetOtherCategoriesRecommendation(settings, param, false, command.Prefix) + ".";
            foreach (var info in infos.OrderByDescending(x => x.Item2.PublishedAt))
            {
                if (pages.IsEmpty || pages.Last.Embed.Fields.Count % 5 == 0)
                {
                    pages.Add(new EmbedBuilder().WithTitle("YouTube"));

                    if (!string.IsNullOrEmpty(recommendation))
                        pages.Last.Embed.WithFooter(recommendation);
                }                
                
                TimeSpan timePublished = DateTime.Now.ToUniversalTime() - info.Item2.PublishedAt;

                pages.Last.Embed.AddField(eab => eab.WithName($":tv: {info.Item1.Name}").WithIsInline(false).WithValue(
                    $"**Views: **{info.Item2.Views.ToString("N0", GlobalDefinitions.Culture)}\n" +
                    $"**Likes: **{info.Item2.Likes.ToString("N0", GlobalDefinitions.Culture)}\n" +
                    $"**Published: **{string.Format("{0}d {1}h {2}min ago", timePublished.Days, timePublished.Hours, timePublished.Minutes)}\n\n"));
            }

            await command.Reply(pages);
        }
Beispiel #32
0
        public void AddRangeTest()
        {
            PageCollection     target = new PageCollection();
            IEnumerable <Page> pages  = new List <Page> {
                new Page(), new Page(), new Page()
            };

            target.AddRange(pages);
        }
        public HaCreatorStateManager(MultiBoard multiBoard, HaRibbon ribbon, PageCollection tabs, InputHandler input)
        {
            this.multiBoard = multiBoard;
            this.ribbon = ribbon;
            this.tabs = tabs;
            this.input = input;
            this.backupMan = new BackupManager(multiBoard, input, this, tabs);

            this.ribbon.NewClicked += ribbon_NewClicked;
            this.ribbon.OpenClicked += ribbon_OpenClicked;
            this.ribbon.SaveClicked += ribbon_SaveClicked;
            this.ribbon.RepackClicked += ribbon_RepackClicked;
            this.ribbon.AboutClicked += ribbon_AboutClicked;
            this.ribbon.HelpClicked += ribbon_HelpClicked;
            this.ribbon.SettingsClicked += ribbon_SettingsClicked;
            this.ribbon.ExitClicked += ribbon_ExitClicked;
            this.ribbon.ViewToggled += ribbon_ViewToggled;
            this.ribbon.ShowMinimapToggled += ribbon_ShowMinimapToggled;
            this.ribbon.ParallaxToggled += ribbon_ParallaxToggled;
            this.ribbon.LayerViewChanged += ribbon_LayerViewChanged;
            this.ribbon.MapSimulationClicked += ribbon_MapSimulationClicked;
            this.ribbon.RegenerateMinimapClicked += ribbon_RegenerateMinimapClicked;
            this.ribbon.SnappingToggled += ribbon_SnappingToggled;
            this.ribbon.RandomTilesToggled += ribbon_RandomTilesToggled;
            this.ribbon.InfoModeToggled += ribbon_InfoModeToggled;
            this.ribbon.HaRepackerClicked += ribbon_HaRepackerClicked;
            this.ribbon.FinalizeClicked += ribbon_FinalizeClicked;
            this.ribbon.NewPlatformClicked += ribbon_NewPlatformClicked;
            this.ribbon.UserObjsClicked += ribbon_UserObjsClicked;
            this.ribbon.ExportClicked += ribbon_ExportClicked;
            this.ribbon.RibbonKeyDown += multiBoard.DxContainer_KeyDown;

            this.tabs.CurrentPageChanged += tabs_CurrentPageChanged;
            this.tabs.PageClosing += tabs_PageClosing;
            this.tabs.PageRemoved += tabs_PageRemoved;

            this.multiBoard.OnBringToFrontClicked += multiBoard_OnBringToFrontClicked;
            this.multiBoard.OnEditBaseClicked += multiBoard_OnEditBaseClicked;
            this.multiBoard.OnEditInstanceClicked += multiBoard_OnEditInstanceClicked;
            this.multiBoard.OnLayerTSChanged += multiBoard_OnLayerTSChanged;
            this.multiBoard.OnSendToBackClicked += multiBoard_OnSendToBackClicked;
            this.multiBoard.ReturnToSelectionState += multiBoard_ReturnToSelectionState;
            this.multiBoard.SelectedItemChanged += multiBoard_SelectedItemChanged;
            this.multiBoard.MouseMoved += multiBoard_MouseMoved;
            this.multiBoard.ImageDropped += multiBoard_ImageDropped;
            this.multiBoard.ExportRequested += ribbon_ExportClicked;
            this.multiBoard.LoadRequested += ribbon_OpenClicked;
            this.multiBoard.CloseTabRequested += multiBoard_CloseTabRequested;
            this.multiBoard.SwitchTabRequested += multiBoard_SwitchTabRequested;
            this.multiBoard.BackupCheck += multiBoard_BackupCheck;
            this.multiBoard.BoardRemoved += multiBoard_BoardRemoved;
            this.multiBoard.MinimapStateChanged += multiBoard_MinimapStateChanged;

            multiBoard.Visible = false;
            ribbon.SetEnabled(false);
        }
Beispiel #34
0
        public static string Convert(PageCollection pages)
        {
            string content = string.Empty;

            foreach (Page page in pages)
            {
                if (!string.IsNullOrEmpty(content))
                {
                    content += "<hr/>";
                }
                foreach (IPageContent pageContent in page.Contents)
                {
                    if (pageContent is Paragraph)
                    {
                        content += string.Format("<p>{0}</p>", ((Paragraph)pageContent).Content);
                    }
                    else if (pageContent is Table)
                    {
                        Table table = (Table)pageContent;
                        content += "<table>";
                        for (int rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++)
                        {
                            content += "<tr>";
                            for (int columnIndex = 0; columnIndex < table.Columns.Count + 2; columnIndex++)
                            {
                                string borderStyle =
                                    columnIndex == 0 || columnIndex == table.Columns.Count + 1 ?
                                    "style=\"border: none;\"" :
                                    ""
                                ;

                                if (rowIndex == 0)
                                {
                                    content += "<th " + borderStyle + ">";
                                    content += table[rowIndex, columnIndex];
                                    content += "</th>";
                                }
                                else
                                {
                                    content += "<td " + borderStyle + ">";
                                    content += table[rowIndex, columnIndex];
                                    content += "</td>";
                                }
                            }
                            content += "</tr>";
                        }
                        content += "</table>";
                    }
                    else
                    {
                        content += pageContent.ToString().Replace("\r\n", "<br/>");
                    }
                }
            }
            return(Properties.Resources.HTML_Header + content + Properties.Resources.HTML_Footer);
        }
Beispiel #35
0
 public TabView(PageCollection parent)
 {
     parent.CurrentPageChanged += new PageCollection.CurrentPageChangedEventHandler(MyParent_CurrentPageChanged);
     parent.PageAdded += new PageCollection.PageAddedEventHandler(MyParent_PageAdded);
     parent.PageRemoved += new PageCollection.PageRemovedEventHandler(MyParent_PageRemoved);
     this.Pages = parent;
     this.Dock = DockStyle.Top;
     this.Height = 25;
     parent.Controls.Add(this);
     this.DropdownButton = new DropdownButton(this);
     this.SendToBack();
 }
Beispiel #36
0
        protected override void InitControl()
        {
            bounds = new Rectangle(0, 0, 240, 300);
            pages = new PageCollection(this);
            base.InitControl();
            header.Anchor = AnchorStyles.None;
            navigation.Anchor = AnchorStyles.None;
            Layout();
            Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            navigation.InternalEnableDoubleBuffer = false;
            controls.Add(header);
            controls.Add(navigation);


            navigation.SelectedIndexChanging += new EventHandler<ChangedEventArgs<int>>(OnSelectedIndexChanging);
            navigation.TransitionChange += new EventHandler<AnimationEventArgs>(OnTransitionChange);
            navigation.TransitionCompleted += new EventHandler<AnimationEventArgs>(OnTransitionCompleted);
            navigation.BeginTransition += new EventHandler<ChangedEventArgs<int>>(OnBeginTransition);
            header.BackButton.Click += new EventHandler(OnBackButtonClick);
        }
 public PageCollection FetchByID(object PageId)
 {
     PageCollection coll = new PageCollection().Where("PageId", PageId).Load();
     return coll;
 }
 public PageCollection FetchByQuery(Query qry)
 {
     PageCollection coll = new PageCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
        private static void AddChildrenToMenu(StringBuilder stringBuilder, CmsPage nodePage, CmsPage page, PageCollection pagePath, string itemClassName, string selectedItemClassName, string linkClassName, string listClass) {
            foreach (CmsPage child in nodePage.Children) {
                if (!child.VisibleInMenu) {
                    continue;
                }

                stringBuilder.Append("<li");
                if (child.PageId == page.PageId && !string.IsNullOrEmpty(selectedItemClassName)) {
                    AddClassName(selectedItemClassName, stringBuilder);
                }
                else {
                    AddOptionalClassName(itemClassName, stringBuilder);
                }

                stringBuilder.AppendFormat("><a href=\"{0}\"", child.PageUrl);
                AddOptionalClassName(linkClassName, stringBuilder);
                stringBuilder.AppendFormat(">{0}</a>", child.PageName);

                if (child.HasChildren && pagePath.Contains(child.PageId)) {
                    stringBuilder.Append("<ul");
                    AddOptionalClassName(listClass, stringBuilder);
                    stringBuilder.Append(">");
                    AddChildrenToMenu(stringBuilder, child, page, pagePath, itemClassName, selectedItemClassName, linkClassName, listClass);
                    stringBuilder.Append("</ul>");
                }
                stringBuilder.Append("</li>");
            }
        }
Beispiel #40
0
        internal PageCollection GetPagesByCriteria(Predicate<PageIndexItem> match) {
            var pageCollection = new PageCollection();

            _pageIndex.FindAll(match).ForEach(t => pageCollection.Add(t.PageId));

            return pageCollection;
        }
 public static byte[] CreatePdf(string key, string p, PageCollection pages)
 {
     using (var ms = new System.IO.MemoryStream())
     {
         var document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
         iTextSharp.text.pdf.PdfWriter.GetInstance(document, ms).SetFullCompression();
         document.Open();
         foreach (Page page in pages)
         {
             byte[] content = Utility.Security.AES.DecryptFile(Utility.Security.AES.GetToken(page.Id, key), System.IO.Path.Combine(p, page.Filename));
             var image = iTextSharp.text.Image.GetInstance(content);
             image.ScaleToFit(document.PageSize.Width, document.PageSize.Height);
             document.Add(image);
         }
         document.Close();
         return ms.ToArray();
     }
 }
        public bool Validate(PageCollection sourcePages, Microsoft.SharePoint.Client.ClientContext ctx)
        {
            int scount = 0;
            int tcount = 0;

            Web web = ctx.Web;
            ctx.Load(web, w => w.Url, w => w.ServerRelativeUrl);
            ctx.ExecuteQuery();

            foreach (var sourcePage in sourcePages)
            {

                string pageUrl = sourcePage.Url.ToString();
                pageUrl = pageUrl.Replace("{site}", web.ServerRelativeUrl);

                Microsoft.SharePoint.Client.File file = web.GetFileByServerRelativeUrl(pageUrl);
                ctx.Load(file, page => page.ListItemAllFields, page => page.ListItemAllFields.RoleAssignments.Include(roleAsg => roleAsg.Member,
                  roleAsg => roleAsg.RoleDefinitionBindings.Include(roleDef => roleDef.Name)));
                ctx.ExecuteQuery();

                if (file != null)
                {
                    #region Page - Fields

                    if (sourcePage.Fields.Count > 0)
                    {
                        scount = 0;
                        tcount = 0;
                        string sourceWikifield = sourcePage.Fields["WikiField"].ToString();
                        string targetwikiField = (string)file.ListItemAllFields["WikiField"];

                        if (sourceWikifield.Trim() != RemoveHTMLTags(targetwikiField).Trim())
                        {
                            return false;
                        }
                    }

                    #endregion

                    #region  Page - Webparts

                    if (!ctx.Web.IsNoScriptSite() && sourcePage.WebParts.Count > 0)
                    {
                        LimitedWebPartManager wpm = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
                        ctx.Load(wpm.WebParts, wps => wps.Include(wp => wp.WebPart.Title, wp => wp.WebPart.Properties));
                        ctx.ExecuteQuery();

                        if (wpm.WebParts.Count > 0)
                        {
                            foreach (var spwp in sourcePage.WebParts)
                            {
                                scount++;
                                foreach (WebPartDefinition wpd in wpm.WebParts)
                                {
                                    if (spwp.Title == wpd.WebPart.Title)
                                    {
                                        tcount++;

                                        //Page - Webpart Properties
                                        Microsoft.SharePoint.Client.WebParts.WebPart wp = wpd.WebPart;
                                        var isWebPropertiesMatch = CSOMWebPartPropertiesValidation(spwp.Contents, wp.Properties);
                                        if (!isWebPropertiesMatch)
                                        {
                                            return false;
                                        }
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                }
                            }
                            if (scount != tcount)
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }

                    #endregion

                    #region Page - Security

                    scount = 0;
                    tcount = 0;

                    if (sourcePage.Security != null && file.ListItemAllFields.RoleAssignments.Count > 0)
                    {
                        bool securityResult = ValidateSecurityCSOM(ctx, sourcePage.Security, file.ListItemAllFields);

                        if (!securityResult)
                        {
                            return false;
                        }
                    }
                    #endregion
                }
                else
                {
                    return false;
                }
            }

            return true;
        }
Beispiel #43
0
        public void CreateMapFromImage(WzImage mapImage, string mapName, string streetName, string categoryName, WzSubProperty strMapProp, PageCollection Tabs, MultiBoard multiBoard, EventHandler[] rightClickHandler)
        {
            if (!mapImage.Parsed) mapImage.ParseImage();
            List<string> copyPropNames = VerifyMapPropsKnown(mapImage, false);
            MapInfo info = new MapInfo(mapImage, mapName, streetName, categoryName);
            foreach (string copyPropName in copyPropNames)
            {
                info.additionalNonInfoProps.Add(mapImage[copyPropName]);
            }
            MapType type = GetMapType(mapImage);
            if (type == MapType.RegularMap)
                info.id = int.Parse(WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)));
            info.mapType = type;

            Rectangle VR = new Rectangle();
            Point center = new Point();
            Point size = new Point();
            Point minimapSize = new Point();
            Point minimapCenter = new Point();
            bool hasMinimap = false;
            bool hasVR = false;

            try
            {
                GetMapDimensions(mapImage, out VR, out center, out size, out minimapCenter, out minimapSize, out hasVR, out hasMinimap);
            }
            catch (NoVRException)
            {
                MessageBox.Show("Error - map does not contain size information and HaCreator was unable to generate it. An error has been logged.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrorLogger.Log(ErrorLevel.IncorrectStructure, "no size @map " + info.id.ToString());
                return;
            }

            lock (multiBoard)
            {
                CreateMap(mapName, WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)), CreateStandardMapMenu(rightClickHandler), size, center, 8, Tabs, multiBoard);
                Board mapBoard = multiBoard.SelectedBoard;
                mapBoard.Loading = true; // prevents TS Change callbacks
                mapBoard.MapInfo = info;
                if (hasMinimap)
                {
                    mapBoard.MiniMap = ((WzCanvasProperty)mapImage["miniMap"]["canvas"]).PngProperty.GetPNG(false);
                    System.Drawing.Point mmPos = new System.Drawing.Point(-minimapCenter.X, -minimapCenter.Y);
                    mapBoard.MinimapPosition = mmPos;
                    mapBoard.MinimapRectangle = new MinimapRectangle(mapBoard, new Rectangle(mmPos.X, mmPos.Y, minimapSize.X, minimapSize.Y));
                }
                if (hasVR)
                {
                    mapBoard.VRRectangle = new VRRectangle(mapBoard, VR);
                }
                LoadLayers(mapImage, mapBoard);
                LoadLife(mapImage, mapBoard);
                LoadFootholds(mapImage, mapBoard);
                GenerateDefaultZms(mapBoard);
                LoadRopes(mapImage, mapBoard);
                LoadChairs(mapImage, mapBoard);
                LoadPortals(mapImage, mapBoard);
                LoadReactors(mapImage, mapBoard);
                LoadToolTips(mapImage, mapBoard);
                LoadBackgrounds(mapImage, mapBoard);
                LoadMisc(mapImage, mapBoard);

                mapBoard.BoardItems.Sort();
                mapBoard.Loading = false;
            }
            if (ErrorLogger.ErrorsPresent())
            {
                ErrorLogger.SaveToFile("errors.txt");
                if (UserSettings.ShowErrorsMessage)
                {
                    MessageBox.Show("Errors were encountered during the loading process. These errors were saved to \"errors.txt\". Please send this file to the author, either via mail (" + ApplicationSettings.AuthorEmail + ") or from the site you got this software from.\n\n(In the case that this program was not updated in so long that this message is now thrown on every map load, you may cancel this message from the settings)", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                ErrorLogger.ClearErrors();
            }
        }
Beispiel #44
0
 internal void SetParent(PageCollection parent)
 {
     this.myParent = parent;
     if (ParentChanged != null)
     {
         ParentChanged();
     }
 }
Beispiel #45
0
        // TODO: Cache-candidate
        internal PageCollection GetPagePath(Guid pageId, bool includeCurrentPage = true) {
            var pathList = new PageCollection();
            var currentPageId = pageId;

            for (var i = 0; i < 10000; i++) {
                if (i > 0 || includeCurrentPage) {
                    pathList.Add(currentPageId);
                }
                currentPageId = GetPageIndexItem(currentPageId).ParentId;
                if (currentPageId == Guid.Empty) {
                    break;
                }
            }

            return pathList;
        }
Beispiel #46
0
        internal PageCollection GetPageTreeFromPage(Guid rootPageId, Guid leafPageId, PublishState pageState) {
            var pageCollection = new PageCollection();
            Predicate<PageIndexItem> match = GetPublishStatePredicate(pageState);
            var stack = new Stack();
            int currentId;
            int index = 0;

            PageCollection pagePath = GetPagePath(leafPageId);

            if (rootPageId == Guid.Empty) {
                currentId = 0;
            }
            else {
                PageIndexItem firstPage = GetPageIndexItem(rootPageId);
                if (firstPage == null) {
                    throw new ArgumentException("Page with id " + rootPageId + " not found!");
                }
                currentId = firstPage.FirstChild;
            }

            while (currentId > -1) {
                PageIndexItem item = _pageIndex[currentId];

                if (match(item)) {
                    pageCollection.Add(item.PageId);

                    if (item.NextPage > -1) {
                        stack.Push(item.NextPage);
                    }

                    if (pagePath.Contains(item.PageId)) {
                        currentId = item.FirstChild;
                    }
                    else {
                        currentId = -1;
                    }
                }
                else {
                    currentId = item.NextPage;
                }

                if ((currentId == -1) && (stack.Count > 0)) {
                    currentId = (int)stack.Pop();
                }

                if (index > _pageIndex.Count) {
                    // TODO: This should never happen, to be removed..
                    throw new Exception("Unending whileloop detected");
                }
                index++;
            }
            return pageCollection;
        }
Beispiel #47
0
        internal PageCollection GetPagesByCriteriaSorted(Predicate<PageIndexItem> match, SortOrder sortOrder, SortDirection sortDirection) {
            var pages = _pageIndex.FindAll(match);
            
            pages = SortPages(pages, sortOrder, sortDirection);

            var pageCollection = new PageCollection();
            foreach (var page in pages) {
                pageCollection.Add(page.PageId);
            }

            return pageCollection;
        }
        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 });
        }
        public ActionResult ReOrder(Guid id, string[] list)
        {
            if (list != null)
            {
                PageCollection pages = new PageCollection();
                Page p = null;

                foreach (string idPage in list)
                {
                    p = Page.Load(Guid.Parse(idPage));
                    p.Order = pages.Count;
                    p.DocumentId = id;
                    pages.Add(p);
                }

                pages.SaveAll();
            }

            return new HttpStatusCodeResult(200);
        }
Beispiel #50
0
 /// <summary>
 /// Loads the children.
 /// </summary>
 /// <param name="pageId">The page id.</param>
 private void LoadChildren(int pageId)
 {
     PageCollection pageCollection = new PageCollection().
     Where(Content.Page.Columns.ParentId, Comparison.Equals, pageId).
     OrderByAsc(Content.Page.Columns.SortOrder).
     Load();
       if(pageCollection.Count > 0) {
     dgChildren.DataSource = pageCollection;
     dgChildren.Columns[0].HeaderText = LocalizationUtility.GetText("hdrMove");
     dgChildren.Columns[1].HeaderText = LocalizationUtility.GetText("hdrTitle");
     dgChildren.Columns[2].HeaderText = LocalizationUtility.GetText("hdrSortOrder");
     dgChildren.DataBind();
     ImageButton lbUp = dgChildren.Items[0].Cells[1].FindControl("lbUp") as ImageButton;
     if(lbUp != null) {
       lbUp.Visible = false;
     }
     ImageButton lbDown = dgChildren.Items[dgChildren.Items.Count - 1].Cells[1].FindControl("lbDown") as ImageButton;
     if(lbDown != null) {
       lbDown.Visible = false;
     }
       }
 }
    public override SiteMapNode BuildSiteMap()
    {
        lock (_lock)
        {
            // Return immediately if this method has been called before
            if (_root != null)
                return _root;

            PageCollection links = new PageCollection().Load();

            //top level node
            _root = new SiteMapNode(this, "0", "~/default.aspx", "Home", "Return to main page", null, null, null, null);
            AddNode(_root, null);

            //you can change this as needed
            string rewrittenDirectory = "~/view/";

            foreach (Page link in links)
            {
                string[] rolelist = null;
                if (!String.IsNullOrEmpty(link.Roles))
                    rolelist = link.Roles.Split(new char[] { ',', ';' });

                if (link.ParentID == null)
                {
                    string url = link.PageUrl;
                    if (!url.Contains("registered/") & !url.Contains("admin/"))
                    {
                        url = rewrittenDirectory + url;
                    }

                    SiteMapNode node = new SiteMapNode(this, link.PageID.ToString(), url, link.MenuTitle, link.Summary, rolelist, null, null, null);
                    AddNode(node, _root);
                    AddChildNodes(ref node, links);

                }
            }

            ////add in the child nodes
            //foreach (CMS.Page link in links)
            //{
            //    string[] rolelist = null;
            //    if (!String.IsNullOrEmpty(link.Roles))
            //        rolelist = link.Roles.Split(new char[] { ',', ';' }, 512);
            //    if (link.ParentID != null)
            //    {
            //        string url = link.PageUrl;
            //        if (!url.Contains("registered/") & !url.Contains("admin/"))
            //        {
            //            url = rewrittenDirectory + url;
            //        }

            //        // Create a SiteMapNode
            //        SiteMapNode node = new SiteMapNode(this, link.PageID.ToString(), url, link.MenuTitle, link.Summary, rolelist, null, null, null);
            //        SiteMapNode parentNode = null;
            //        //loop the nodes to find the parent
            //        foreach (CMS.Page link2 in links)
            //        {
            //            if (link2.PageID == link.ParentID)
            //            {
            //                parentNode = new SiteMapNode(this, link2.PageID.ToString(), rewrittenDirectory + link2.PageUrl, link2.MenuTitle, link2.Summary, rolelist, null, null, null);
            //                break;
            //            }
            //        }
            //        AddNode(node, parentNode);
            //    }
            //}

            return _root;
        }
    }
Beispiel #52
0
 public static void CreateMapFromImage(WzImage mapImage, string mapName, string streetName, PageCollection Tabs, MultiBoard multiBoard, EventHandler rightClickHandler)
 {
     if (!mapImage.Parsed) mapImage.ParseImage();
     VerifyMapPropsKnown(mapImage);
     MapInfo info = new MapInfo(mapImage, mapName, streetName);
     MapType type = GetMapType(mapImage);
     if (type == MapType.RegularMap)
         info.id = int.Parse(WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)));
     info.mapType = type;
     Point center = new Point();
     Point size = new Point();
     if (mapImage["miniMap"] == null)
     {
         if (info.VR == null)
         {
             if (!GetMapVR(mapImage, ref info.VR))
             {
                 new GUI.ErrorBox("Error - map does not contain size information and HaCreator was unable to generate it. An error has been logged.");
                 //MessageBox.Show("Error - map does not contain size information and HaCreator was unable to generate it. An error has been logged.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 ErrorLogger.Log(ErrorLevel.IncorrectStructure, "no size @map " + info.id.ToString());
                 return;
             }
         }
         size = new Point(info.VR.Value.Width + 10, info.VR.Value.Height + 10); //leave 5 pixels on each side
         center = new Point(5 - info.VR.Value.Left, 5 - info.VR.Value.Top);
     }
     else
     {
         IWzImageProperty miniMap = mapImage["miniMap"];
         size = new Point(InfoTool.GetInt(miniMap["width"]), InfoTool.GetInt(miniMap["height"]));
         center = new Point(InfoTool.GetInt(miniMap["centerX"]), InfoTool.GetInt(miniMap["centerY"]));
     }
     CreateMap(mapName, WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)), CreateStandardMapMenu(rightClickHandler), size, center, 8, Tabs, multiBoard);
     Board mapBoard = multiBoard.SelectedBoard;
     mapBoard.MapInfo = info;
     if (mapImage["miniMap"] != null)
         mapBoard.MiniMap = ((WzCanvasProperty)mapImage["miniMap"]["canvas"]).PngProperty.GetPNG(false);
     LoadLayers(mapImage, mapBoard);
     LoadLife(mapImage, mapBoard);
     LoadFootholds(mapImage, mapBoard);
     LoadRopes(mapImage, mapBoard);
     LoadChairs(mapImage, mapBoard);
     LoadPortals(mapImage, mapBoard);
     LoadReactors(mapImage, mapBoard);
     LoadToolTips(mapImage, mapBoard);
     LoadBackgrounds(mapImage, mapBoard);
     mapBoard.BoardItems.Sort();
 }
Beispiel #53
0
        protected List<CmsPage> GetFilteredPageList(PageCollection pageCollection) {
            var hasCustomFilter = Filter != null;
            var pageList = new List<CmsPage>();

            foreach (CmsPage page in pageCollection) {
                if (PageState == PublishState.Published && !page.IsAvailable) {
                    continue;
                }

                if (PageState == PublishState.Unpublished && page.IsAvailable) {
                    continue;
                }

                if (hasCustomFilter && !Filter(page)) {
                    continue;
                }

                pageList.Add(page);
            }

            return pageList;
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public PanoramaPanel()
 {
     pages = new PageCollection(this);
 }