示例#1
0
        private void WriteHTMLForDataForItem(VideoSectionItem item, StringBuilder sb, ContentFile file)
        {
            if (item.ChildrenItems != null && item.ChildrenItems.Count > 0)
            {
                sb.Append("<div class=\"expandCollapseDivWrapper\">");
                sb.AppendFormat("<div wrapperId={0} class=\"expandCollapseDiv\">+</div>", item.Number);
                sb.AppendFormat("<div onclick=\"runVideo('{0}','{1}')\" class=\"chapterDivWithExpandCollapse\">", AppUtil.GetXmlUrlForItem(item,file.FileName),item.Number);
                sb.Append(AppUtil.FilterChapterName(item.Chapter));
                sb.Append("</div>");
                sb.AppendFormat("<div style=\"float:right;\">{0}</div>", GetMinuteSecond(item.Duration));
                sb.Append("<div class=\"clearBoth\"></div>");
                sb.Append("</div>");

                sb.AppendFormat("<div childrenId={0} class=\"chapterDivWithoutExpandCollapse\">", item.Number);
                foreach (VideoSectionItem childItem in item.ChildrenItems)
                {
                    WriteHTMLForDataForItem(childItem, sb, file);
                }
                sb.Append("</div>");

            }
            else
            {
                sb.AppendFormat("<div onclick=\"runVideo('{0}','{1}')\" class=\"singleItem\">", AppUtil.GetXmlUrlForItem(item, file.FileName),item.Number);

                sb.Append(AppUtil.FilterChapterName(item.Chapter));
                sb.AppendFormat("<div style=\"float:right;\">{0}</div>", GetMinuteSecond(item.Duration));
                sb.Append("</div>");

            }
        }
示例#2
0
        //public string GetResponseForItems(List<VideoSectionItem> items, ChapterDefinitionFile file)
        public string GetResponseForItems(List<VideoSectionItem> items, ContentFile file)
        {
            HttpContext.Current.Response.Clear();
            StringBuilder sb = new StringBuilder();

            foreach (VideoSectionItem item in items)
            {
                WriteHTMLForDataForItem(item, sb, file);
            }

            return sb.ToString();
        }
        /// <summary>
        /// Saves a FileContent object to the Database.
        /// </summary>
        /// <param name="file"></param>
        public void Save(ContentFile file)
        {
            if (file.FileID == 0)
            {
                file.UploadedOn = DateTime.Now;
                file.Modified = DateTime.Now;
                _Data.ContentFiles.InsertOnSubmit(file);
            }
            else
                file.Modified = DateTime.Now;

            _Data.SubmitChanges();
        }
        /// <summary>
        /// Delets a File Content from Database
        /// </summary>
        /// <param name="file"></param>
        public void Delete(ContentFile file)
        {
            var filesToDelete =
                from f in _Data.ContentFiles
                where f.FileName == file.FileName
                select f;

            if (filesToDelete != null && filesToDelete.Count() > 0)
            {
                _Data.ContentFiles.DeleteAllOnSubmit(filesToDelete);
                _Data.SubmitChanges();
                file = null;
            }
        }
示例#5
0
    protected void uploadBtn_Click(object o, EventArgs e)
    {
        // try save the file to the web server
        if (filename.PostedFile != null)
        {
            string sPath = AppUtil.GetUploadFolderForExel();
            if (!Directory.Exists(sPath))
            {
                Directory.CreateDirectory(sPath);
            }
            //build file info for display
            string sFileInfo =
                "<br>FileName: " +
                filename.PostedFile.FileName;

            try
            {
                string formattedFileName = Path.GetFileName(filename.PostedFile.FileName).Replace(" ","_");
                filename.PostedFile.SaveAs(System.IO.Path.Combine(sPath, formattedFileName));

                //ChapterDefinitionFile file = ChapterFileManager.Instance.GetByFileName(formattedFileName);
                //if (file == null)
                //{
                //    file = new ChapterDefinitionFile();
                //    file.FileName = formattedFileName;
                //}

                //ChapterFileManager.Instance.Save(file);

                ///Save File Info
                ContentFileManager fileManager = new ContentFileManager();
                ContentFile file = fileManager.GetByFileName(formattedFileName);
                if (file == null)
                {
                    file = new ContentFile();
                    file.FileName = formattedFileName;
                    file.UploadedBy = string.IsNullOrEmpty(this.Page.User.Identity.Name)?"Admin":this.Page.User.Identity.Name;
                    file.UploadedOn = DateTime.Now;
                    file.Modified = DateTime.Now;
                    file.FileCategoryID = 1;///Video File
                    fileManager.Save(file);
                }

                string filePath = Path.Combine(AppUtil.GetUploadFolderForExel(), file.FileName);
                string xmlDir = AppUtil.GetUploadFolderForXml();

                List<VideoSectionItem> videoSectionItems = ExelHelper.Instance.GetDataFromExcel(filePath);
                int levelCount = ExelHelper.Instance.GetLevelCount(videoSectionItems);
                List<VideoSectionItem> items = DataParser.Instance.GetHirararchialVideoSectionItems(videoSectionItems, xmlDir, levelCount, file.FileName);

                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FileName);
                DeleteExistingFiles(fileNameWithoutExtension);
                XmlHelper.Instance.WriteXmlsForItems(fileNameWithoutExtension, fileNameWithoutExtension, items, 0);

                status.InnerText = "File uploaded successfully.";

                ((App.Util.PageBase)this.Page).SignalFileUploaded();

            }
            catch (Exception exc)
            {
                status.InnerText = "Failed to upload file.";
                throw exc;
            }
        }
    }
示例#6
0
		private void detach_ContentFiles(ContentFile entity)
		{
			this.SendPropertyChanging();
			entity.FileCategory = null;
		}
示例#7
0
 partial void DeleteContentFile(ContentFile instance);
示例#8
0
 partial void UpdateContentFile(ContentFile instance);
示例#9
0
 partial void InsertContentFile(ContentFile instance);