public ActionResult CreateCpContent2(int?id)
        {
            List <SelectListItem> cpList = new List <SelectListItem>();

            foreach (Chapter cp in _Util.Facade.ChapterFacade.GetAllChapterName().Where(x => x.Type == "Act"))
            {
                SelectListItem option = new SelectListItem();
                option.Text  = cp.Name;
                option.Value = cp.ChapterNo.ToString();

                cpList.Add(option);
            }
            List <SelectListItem> titleList = new List <SelectListItem>();

            foreach (ChapterContent cp in _Util.Facade.ChapterContentFacade.GetContentCountAct().ToList())
            {
                SelectListItem option = new SelectListItem();
                option.Text  = cp.Title;
                option.Value = cp.Id.ToString();

                titleList.Add(option);
            }

            // sending the list to view through ViewBag
            ViewBag.contents = cpList;
            ViewBag.titles   = titleList;
            ChapterContent content = new ChapterContent();

            if (id.HasValue && id > 0)
            {
                //Get data using id
                content = _Util.Facade.ChapterContentFacade.GetChapterById(id.Value);
            }
            return(View(content));
        }
        public JsonResult SaveContent(LocalizeResource resourceTitle, LocalizeResource resourceContent, ChapterContent Content)
        {
            bool result = false;

            try
            {
                if (Content.Id > 0)
                {
                    ChapterContent          cp = _Util.Facade.ChapterContentFacade.GetAllChapterName().Where(x => x.Id == Content.Id).FirstOrDefault();
                    List <LocalizeResource> lr = _Util.Facade.ResourceFacade.GetAllResourceName().Where(x => x.ResourceName == cp.CpContent).ToList();
                    LocalizeResource        l1 = lr.Where(x => x.LanguageId == 2).FirstOrDefault();
                    l1.ResourceValue = resourceContent.ResourceValue;
                    _Util.Facade.ResourceFacade.UpdateResource(l1);
                    LocalizeResource l2 = lr.Where(x => x.LanguageId == 1).FirstOrDefault();
                    l2.ResourceValue = resourceContent.ResourceName;
                    _Util.Facade.ResourceFacade.UpdateResource(l2);
                    Content.CpContent = cp.CpContent;
                    Content.ChapterId = cp.ChapterId;
                    _Util.Facade.ChapterContentFacade.UpdateChapter(Content);
                }
                else
                {
                    resourceTitle.CompanyId  = Guid.NewGuid();
                    resourceTitle.LanguageId = 2;
                    LocalizeResource rr = new LocalizeResource();
                    rr.CompanyId     = Guid.NewGuid();
                    rr.ResourceName  = Guid.NewGuid().ToString();
                    rr.ResourceValue = resourceTitle.ResourceName;
                    rr.LanguageId    = 1;
                    _Util.Facade.ResourceFacade.InsertLocalizeResource(resourceTitle);
                    _Util.Facade.ResourceFacade.InsertLocalizeResource(rr);
                    resourceTitle.ResourceName = rr.ResourceName;
                    _Util.Facade.ResourceFacade.UpdateResource(resourceTitle);
                    resourceContent.CompanyId  = Guid.NewGuid();
                    resourceContent.LanguageId = 2;
                    LocalizeResource rr1 = new LocalizeResource();
                    rr1.CompanyId     = Guid.NewGuid();
                    rr1.ResourceName  = Guid.NewGuid().ToString();
                    rr1.ResourceValue = resourceContent.ResourceName;
                    rr1.LanguageId    = 1;
                    _Util.Facade.ResourceFacade.InsertLocalizeResource(resourceContent);
                    _Util.Facade.ResourceFacade.InsertLocalizeResource(rr1);
                    resourceContent.ResourceName = rr1.ResourceName;
                    _Util.Facade.ResourceFacade.UpdateResource(resourceContent);
                    LocalizeResource lr = _Util.Facade.ResourceFacade.GetAllResourceName().Where(x => x.ResourceValue == Content.CpContent).FirstOrDefault();
                    Content.CpContent = lr.ResourceName;
                    _Util.Facade.ChapterContentFacade.InsertChapter(Content);
                }
                if (HttpRuntime.Cache != null && HttpRuntime.Cache["LanguagePack"] != null)
                {
                    HttpRuntime.Cache.Remove("LanguagePack");
                }
                result = true;
            }
            catch (Exception ex)
            {
            }
            // return RedirectToAction("Dashboard");
            return(Json(result));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// populates a ChapterContent with its child entities
 /// </summary>
 /// <param name="chapterContent"></param>
 /// <param name="fillChilds"></param>
 private void FillChapterContentWithChilds(ChapterContent chapterContentObject, bool fillChilds)
 {
     // populate child data for a chapterContentObject
     if (chapterContentObject != null)
     {
     }
 }
        public ActionResult ShowContentbyTitle(string title)
        {
            ChapterContent coo = new ChapterContent();

            foreach (ChapterContent cp in _Util.Facade.ChapterContentFacade.GetAllChapterName())
            {
                if (cp.Title == title)
                {
                    coo = cp;
                }
            }
            return(View(coo));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 保存章节
        /// </summary>
        /// <param name="c"></param>
        private void SaveChapter(ChapterContent c, string Content)
        {
            DataEntities ent = new DataEntities();

            Book b = (from l in ent.Book where l.ID == CurBook.ID select l).First();


            BookChapter bc = new BookChapter();

            bc.BookID         = CurBook.ID;
            bc.BookTitle      = CurBook.Title;
            bc.ChapterIndex   = 0;
            bc.ClassID        = CurBook.ClassID;
            bc.ClassName      = CurBook.ClassName;
            bc.ClickCount     = 0;
            bc.Enable         = true;
            bc.IsFree         = true;
            bc.IsImageChapter = false;
            bc.IsTemp         = false;
            bc.IsVipChapter   = false;
            bc.TextLength     = c.content.Length;
            bc.Title          = c.title;
            bc.UpdateTime     = DateTime.UtcNow.AddHours(8);
            bc.ValumeID       = 0;
            bc.ValumeName     = "";

            w(string.Format("保存章节:{0}  {1} ", bc.Title, bc.BookTitle));

            ent.AddToBookChapter(bc);
            ent.SaveChanges();

            b.LastChapterID    = bc.ID;
            b.LastChapterTitle = bc.Title;
            b.UpdateTime       = DateTime.UtcNow.AddHours(8);
            b.VipUpdateTime    = DateTime.UtcNow.AddHours(8);
            ent.SaveChanges();

            w("Saving content..");

            NameValueCollection nv = new NameValueCollection();

            nv.Add("chapterid", bc.ID.ToS());
            nv.Add("chaptertitle", bc.Title);
            nv.Add("content", Content);
            nv.Add("isimagechapter", "False");
            nv.Add("istemp", "False");

            Url.Post(nv, ApiUrl + "?a=chapteredit");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Update base of ChapterContent Object.
        /// Data manipulation processing for: new, deleted, updated ChapterContent
        /// </summary>
        /// <param name="chapterContentObject"></param>
        /// <returns></returns>
        public bool UpdateBase(ChapterContent chapterContentObject)
        {
            // use of switch for different types of DML
            switch (chapterContentObject.RowState)
            {
            // insert new rows
            case BaseBusinessEntity.RowStateEnum.NewRow:
                return(Insert(chapterContentObject));

            // delete rows
            case BaseBusinessEntity.RowStateEnum.DeletedRow:
                return(Delete(chapterContentObject.Id));
            }
            // update rows
            using (ChapterContentDataAccess data = new ChapterContentDataAccess(ClientContext))
            {
                return(data.Update(chapterContentObject) > 0);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Insert new chapterContent.
 /// data manipulation for insertion of ChapterContent
 /// </summary>
 /// <param name="chapterContentObject"></param>
 /// <returns></returns>
 private bool Insert(ChapterContent chapterContentObject)
 {
     // new chapterContent
     using (ChapterContentDataAccess data = new ChapterContentDataAccess(ClientContext))
     {
         // insert to chapterContentObject
         Int32 _Id = data.Insert(chapterContentObject);
         // if successful, process
         if (_Id > 0)
         {
             chapterContentObject.Id = _Id;
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 8
0
        private async Task M0004_Books_TypeL()
        {
            string LRoot = "shared/transfers/LVolumes/";

            if (!Shared.Storage.DirExist(LRoot))
            {
                return;
            }

            string[] Ids = Shared.Storage.ListDirs(LRoot);

            int         l       = Ids.Length;
            List <Book> Entries = new List <Book>();
            await Ids.ExecEach(async ( Id, i ) =>
            {
                MesgR(stx.Text("MightTakeAWhile") + string.Format("{1}/{2} ( {0} )", Id, i + 1, l));

                Book Entry = null;
                if (int.TryParse(Id, out int k) && X.Exists)
                {
                    BookItem Item = X.Instance <BookItem>(XProto.BookItemEx, Id);
                    Entry         = Item.Entry;
                    Entry.Type    = Entry.Type | BookType.L;
                }
                else
                {
                    BookItem Item = new LocalTextDocument(Id);
                    Entry         = Item.Entry;
                }

                await Shared.BooksDb.LoadCollectionAsync(Entry, x => x.Volumes, x => x.Index);
                Entry.Volumes.Clear();

                string BRoot   = LRoot + Id + "/";
                string MetaLoc = BRoot + "METADATA.xml";

                XRegistry XMeta = new XRegistry("<Meta />", MetaLoc);

                XParameter[] VolDefs = XMeta.Parameters("vid");

                VolDefs.ExecEach((VolDef, vi) =>
                {
                    Volume Vol = new Volume()
                    {
                        Book     = Entry,
                        Title    = VolDef.GetValue("name"),
                        Chapters = new List <Chapter>(),
                        Index    = vi
                    };

                    Vol.Meta[AppKeys.GLOBAL_VID] = VolDef.Id;
                    XRegistry ChReg     = new XRegistry("<ch />", BRoot + VolDef.Id + ".vol");
                    XParameter[] ChDefs = ChReg.Parameters("cid");

                    ChDefs.ExecEach((ChDef, ei) =>
                    {
                        Chapter Ch = new Chapter()
                        {
                            Book   = Entry,
                            Volume = Vol,
                            Title  = ChDef.GetValue("name"),
                            Index  = ei
                        };

                        Ch.Meta[AppKeys.GLOBAL_CID] = ChDef.Id;

                        string ChLocation = BRoot + VolDef.Id + "/" + ChDef.Id + ".txt";
                        if (Shared.Storage.FileExists(ChLocation))
                        {
                            ChapterContent ChCont = new ChapterContent()
                            {
                                Chapter = Ch,
                            };
                            ChCont.Data.BytesValue = Shared.Storage.GetBytes(ChLocation);
                            Shared.BooksDb.ChapterContents.Add(ChCont);
                        }

                        Vol.Chapters.Add(Ch);
                    });

                    Entry.Volumes.Add(Vol);
                });

                Entries.Add(Entry);
            });

            MesgR(stx.Text("SavingRecords"));
            Shared.BooksDb.SaveBooks(Entries.ToArray());

            Purge(LRoot);
        }
Ejemplo n.º 9
0
 public bool UpdateChapter(ChapterContent chapter)
 {
     return(_ChapterDataAccess.Update(chapter) > 0);
 }
Ejemplo n.º 10
0
 public bool InsertChapter(ChapterContent chapter)
 {
     return(_ChapterDataAccess.Insert(chapter) > 0);
 }