Exemple #1
0
        public bool saveUpdatedPageFilesItemData(PageFilesItemData updatedFileItem)
        {
            if (updatedFileItem.Id < 0)
            {
                return(false);
            }

            string sql = "update pagefileitem set ";

            sql += "Filename = '" + dbEncode(updatedFileItem.Filename) + "', ";
            sql += "Title = '" + dbEncode(updatedFileItem.Title) + "', ";
            sql += "Author = '" + dbEncode(updatedFileItem.Author) + "', ";
            sql += "Abstract = '" + dbEncode(updatedFileItem.Abstract) + "', ";
            sql += "FileSize = " + updatedFileItem.FileSize.ToString() + ", ";
            sql += "LastModified = " + dbEncode(updatedFileItem.lastModified) + ", ";
            sql += "CreatorUsername = '******' ";

            sql += " where PageFileItemId = " + updatedFileItem.Id.ToString() + "; ";

            int NumModified = this.RunUpdateQuery(sql);

            if (NumModified >= 0)
            {
                return(true);
            }
            return(false);
        } //  saveUpdatedPageFilesItemData
Exemple #2
0
        } // ItemDataFromDataRow

        /// <summary>
        /// deletes the pageFileItemToDelete. Note: the calling pageFileItemToDelete.Filename is modified with this function.
        /// </summary>
        /// <param name="pageFileItemToDelete"></param>
        /// <param name="page"></param>
        /// <param name="identifier"></param>
        /// <returns>TRUE if successful, false if not</returns>
        public bool deletePageFilesItemData(PageFilesItemData pageFileItemToDelete, CmsPage page, int identifier, CmsLanguage language)
        {
            if (pageFileItemToDelete.Id >= 0)
            {
                string renamedFilename = "Deleted." + DateTime.Now.ToString("yyyyMMdd.HH.mm.ss.") + pageFileItemToDelete.Filename;

                string currentFilenameOnDisk = pageFileItemToDelete.getFilenameOnDisk(page, identifier, language);
                pageFileItemToDelete.Filename = renamedFilename;
                string renamedFilenameOnDisk = pageFileItemToDelete.getFilenameOnDisk(page, identifier, language);

                if (System.IO.File.Exists(currentFilenameOnDisk))
                {
                    try
                    {
                        System.IO.File.Move(currentFilenameOnDisk, renamedFilenameOnDisk);
                    }
                    catch (Exception e)
                    {
                        Console.Write(e.Message);
                        return(false);
                    }
                }

                string sql = "update pagefileitem set Deleted = NOW(), Filename = '" + dbEncode(renamedFilename) + "' where PageFileItemId = " + pageFileItemToDelete.Id.ToString();

                int numAffected = this.RunUpdateQuery(sql);
                if (numAffected > 0)
                {
                    return(page.setLastUpdatedDateTimeToNow());
                }
            } // if

            return(false);
        }
Exemple #3
0
        }         // getPageFilesItemDatas

        public bool saveNewPageFilesItemData(PageFilesItemData newItem, CmsPage page, int indentifier, CmsLanguage pageLanguage)
        {
            string sql = "insert into pagefileitem (PageId, Identifier, langShortCode, Filename, Title, Author, Abstract, FileSize, LastModified, CreatorUsername) VALUES (";

            sql += "" + page.ID.ToString() + ", ";
            sql += "" + indentifier.ToString() + ", ";
            sql += "'" + dbEncode(pageLanguage.shortCode) + "', ";
            sql += "'" + dbEncode(newItem.Filename) + "', ";
            sql += "'" + dbEncode(newItem.Title) + "', ";
            sql += "'" + dbEncode(newItem.Author) + "', ";
            sql += "'" + dbEncode(newItem.Abstract) + "', ";
            sql += "" + newItem.FileSize.ToString() + ", ";
            sql += "" + dbEncode(newItem.lastModified) + ", ";
            sql += "'" + dbEncode(newItem.CreatorUsername) + "' ";
            sql += ")";

            int newId = this.RunInsertQuery(sql);

            if (newId >= 0)
            {
                newItem.Id = newId;
                return(true);
            }
            return(false);
        }
            public static FileAggItem FromPageFilesItemData(PageFilesItemData sourceDetails, CmsUrlFormat pageLinkUrlFormat, CmsUrlFormat fileLinkUrlFormat)
            {
                CmsPage detailsPage = CmsContext.getPageById(sourceDetails.DetailsPageId);
                Dictionary <string, string> pageUrlParams = new Dictionary <string, string>();

                pageUrlParams.Add(PageFiles.CurrentFileIdFormName, sourceDetails.Id.ToString());
                string   PageDisplayURL  = detailsPage.getUrl(pageUrlParams, sourceDetails.Lang, pageLinkUrlFormat);
                string   FileDownloadURL = sourceDetails.getDownloadUrl(fileLinkUrlFormat);
                string   Title           = sourceDetails.Title;
                string   Description     = sourceDetails.Abstract;
                string   CategoryName    = detailsPage.getTitle(sourceDetails.Lang); // use the page title as the category
                DateTime lastModified    = sourceDetails.lastModified;

                return(new FileAggItem(PageDisplayURL, FileDownloadURL, Title, Description, CategoryName, lastModified));
            }
Exemple #5
0
        } // saveUpdatedPageFilesData

        private PageFilesItemData getItemDataFromDataRow(DataRow dr)
        {
            PageFilesItemData item = new PageFilesItemData();

            item.Id              = Convert.ToInt32(dr["PageFileItemId"]);
            item.Filename        = dr["Filename"].ToString();
            item.Title           = dr["Title"].ToString();
            item.Author          = dr["Author"].ToString();
            item.Abstract        = dr["Abstract"].ToString();
            item.FileSize        = Convert.ToInt64(dr["FileSize"]);
            item.lastModified    = Convert.ToDateTime(dr["LastModified"]);
            item.CreatorUsername = dr["CreatorUsername"].ToString();

            item.DetailsPageId = Convert.ToInt32(dr["PageId"]);
            item.Identifier    = Convert.ToInt32(dr["Identifier"]);
            string langCode = dr["langShortCode"].ToString();

            item.Lang = CmsLanguage.GetFromHaystack(langCode, CmsConfig.Languages);

            return(item);
        } // ItemDataFromDataRow