Пример #1
0
        public async Task Setup()
        {
            var reader = AccountBuilder.InLibrary(LibraryId).As(Role.Reader).Build();

            _chapter  = ChapterBuilder.WithLibrary(LibraryId).WithContents().WithoutAnyAssignment().Build();
            _response = await Client.PostObject($"/libraries/{LibraryId}/books/{_chapter.BookId}/chapters/{_chapter.ChapterNumber}/assign", new { AccountId = reader.Id, Type = "write" });
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtChapterName.Text.Trim() == string.Empty)
            {
                MessageBox.Show(Constant.NOTIFICATIO_VALIDATION_ALL_FIELD_IS_REQUIRED, Constant.NOTIFICATIO_VALIDATION_ALL_FIELD_IS_REQUIRED, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            ChapterDto chapter = new ChapterDto();

            chapter.ChapterName = txtChapterName.Text.Trim();
            chapter.BookID      = Convert.ToInt64(cmbBooks.SelectedValue.ToString());
            chapter.CreatedBy   = MDIParent._UserMasterID;
            chapter.CreatedDate = DateTime.Now;
            chapter.ModifyDate  = DateTime.Now;
            chapter.ModifyedBy  = MDIParent._UserMasterID;
            chapter.Remarks     = rtxtDescription.Text.Trim();

            if (ChapterDao.Insert(chapter))
            {
                txtChapterName.Text  = string.Empty;
                rtxtDescription.Text = string.Empty;

                MessageBox.Show(Constant.NOTIFICATION_SUCCESS_DATA_SAVING, Constant.NOTIFICATION_CAPTION_SAVE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                MessageBox.Show(Constant.DBErrorMsg, Constant.NOTIFICATION_ERROR_DATA_SAVING, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        public static bool Update(ChapterDto chapter)
        {
            string        sql = " UPDATE Chapter SET ChapterName=@ChapterName,Content=@Content,Remarks=@Remarks,CreatedDate=@CreatedDate,CreatedBy=@CreatedBy,ModifyDate=@ModifyDate,ModifyedBy=@ModifyedBy,ChapterID=@ChapterID  WHERE ContentID=@ContentID";
            SqlConnection con = new SqlConnection(Properties.Settings.Default.BlindEyeDBConStr);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@ChapterName", chapter.ChapterName);
            cmd.Parameters.AddWithValue("@Remarks", chapter.Remarks);
            cmd.Parameters.AddWithValue("@ChapterId", chapter.ChapterID);
            cmd.Parameters.AddWithValue("@CreatedDate", chapter.CreatedDate);
            cmd.Parameters.AddWithValue("@CreatedBy", chapter.CreatedBy);
            cmd.Parameters.AddWithValue("@ModifyDate", chapter.ModifyDate);
            cmd.Parameters.AddWithValue("@ModifyedBy", chapter.ModifyedBy);


            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                Constant.DBErrorMsg = ex.Message;

                return(false);
            }

            finally
            {
                con.Close();
            }
        }
        public async Task Setup()
        {
            _chapter = ChapterBuilder.WithLibrary(LibraryId).Private().WithContents().Build();
            var content = ChapterBuilder.Contents.Single(x => x.ChapterId == _chapter.Id);

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_chapter.BookId}/chapters/{_chapter.Id}/contents?language={content.Language}");
        }
Пример #5
0
        public static bool Insert(ChapterDto chapter)
        {
            string sql = " INSERT INTO tblChapter (ChapterName,Remarks,CreatedDate,CreatedBy,ModifyDate,ModifyedBy,BookID) " +
                         "VALUES " +
                         " ( @ChapterName,@Remarks,@CreatedDate,@CreatedBy,@ModifyDate,@ModifyedBy,@BookID)";
            SqlConnection con = new SqlConnection(Properties.Settings.Default.BlindEyeDBConStr);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@ChapterName", chapter.ChapterName);
            cmd.Parameters.AddWithValue("@Remarks", chapter.Remarks);

            cmd.Parameters.AddWithValue("@CreatedDate", chapter.CreatedDate);
            cmd.Parameters.AddWithValue("@CreatedBy", chapter.CreatedBy);
            cmd.Parameters.AddWithValue("@ModifyDate", chapter.ModifyDate);
            cmd.Parameters.AddWithValue("@ModifyedBy", chapter.ModifyedBy);
            cmd.Parameters.AddWithValue("@BookID", chapter.BookID);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                Constant.DBErrorMsg = ex.Message;

                return(false);
            }

            finally
            {
                con.Close();
            }
        }
Пример #6
0
        public static void AddChapter(this IDbConnection connection, ChapterDto chapter)
        {
            var sql = "Insert Into Chapter (Title, BookId, ChapterNumber) OUTPUT Inserted.Id VALUES (@Title, @BookId, @ChapterNumber)";
            var id  = connection.ExecuteScalar <int>(sql, chapter);

            chapter.Id = id;
        }
Пример #7
0
        private void SearchChapter()
        {
            project = grvProject.GetRow(grvProject.FocusedRowHandle) as ProjectDto;
            List <ChapterDto> chapterList = new List <ChapterDto>();
            DataSet           ds          = webService.SearchChapter(project.ProjectCode, "");

            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ChapterDto chapter = new ChapterDto();
                    chapter.ProjectCode    = Convert.ToString(ds.Tables[0].Rows[i]["ProjectCode"]);
                    chapter.CharterCode    = Convert.ToString(ds.Tables[0].Rows[i]["CharterCode"]);
                    chapter.CharterName    = Convert.ToString(ds.Tables[0].Rows[i]["CharterName"]);
                    chapter.CharterContent = Convert.ToString(ds.Tables[0].Rows[i]["CharterContent"]);
                    chapter.OrderNo        = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderNo"]);
                    chapter.InUserID       = Convert.ToString(ds.Tables[0].Rows[i]["InUserID"]);
                    chapter.InDateTime     = Convert.ToDateTime(ds.Tables[0].Rows[i]["InDateTime"]);
                    chapter.Weight         = Convert.ToDecimal(ds.Tables[0].Rows[i]["Weight"]);
                    chapterList.Add(chapter);
                }
                grcCharter.DataSource = chapterList;
            }
            else
            {
                CommonHandler.ShowMessage(MessageType.Information, "没有数据");
            }
        }
Пример #8
0
        public async Task <ApiResponse <Chapter> > CreateChapter(ChapterDto chapterDto)
        {
            var response = new ApiResponse <Chapter>();

            try
            {
                //check chapter Exists
                var isExistChapter = await _chapterRepository.CountAsync(i => i.Name == chapterDto.Name);

                if (isExistChapter != 0)
                {
                    response.Success = false;
                    response.Errors.Add("Chapter Already Exists");
                    return(response);
                }

                var id = Guid.NewGuid();

                //create new chapter
                var chapter = Mapper.Map <Chapter>(chapterDto);
                chapter.Id          = id;
                chapter.CreatedDate = DateTime.Now;
                chapter.IsActive    = true;
                await _chapterRepository.AddAsyn(chapter);

                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Errors.Add(ex.Message);
            }
            return(response);
        }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="projectCode"></param>
        /// <param name="combox"></param>
        public static void BindChapter(string projectCode, ComboBoxEdit combox)
        {
            List <ChapterDto> chapterlist = new List <ChapterDto>();
            ChapterDto        c           = new ChapterDto();

            c.CharterCode = "";
            c.CharterName = "全部";
            chapterlist.Add(c);
            //DataSet ds = webService.SearchChapter(projectCode,"");
            DataSet ds = null;

            if (IsNetWork)
            {
                ds = webService.SearchChapter(projectCode, "");
            }
            else
            {
                localService.Url = "http://192.168.1.99/XHX.YiQiServer/service.asmx";
                ds = localService.SearchChapter(projectCode, "");
            }
            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ChapterDto chapter = new ChapterDto();
                    chapter.CharterCode = Convert.ToString(ds.Tables[0].Rows[i]["CharterCode"]);
                    chapter.CharterName = Convert.ToString(ds.Tables[0].Rows[i]["CharterName"]);
                    chapterlist.Add(chapter);
                }
            }

            // if (chapterlist)
            CommonHandler.SetComboBoxEditItems(combox, chapterlist, "CharterName", "CharterCode");
        }
Пример #10
0
        internal ChapterAssert ShouldBeSameAs(ChapterDto dto)
        {
            _chapter.Title.Should().Be(dto.Title);
            _chapter.ChapterNumber.Should().Be(dto.ChapterNumber);
            _chapter.BookId.Should().Be(dto.BookId);

            return(this);
        }
Пример #11
0
 // PUT api/values/5
 public void Put(int id, ChapterDto c)
 {
     man.RepChapter.Create(new Chapter
     {
         ChapterId  = c.ChapterId,
         ChapterUrl = c.ChapterUrl
     });
 }
        public async Task Setup()
        {
            _chapter = ChapterBuilder.WithLibrary(LibraryId).Build();

            _response = await Client.PostString($"/libraries/{LibraryId}/books/{_chapter.BookId}/chapters/{_chapter.ChapterNumber}/contents", RandomData.String, null);

            _assert = new ChapterContentAssert(_response, Library);
        }
        public async Task Setup()
        {
            _expected = ChapterBuilder.WithLibrary(LibraryId).Build(4).First();

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_expected.BookId}/chapters/{_expected.ChapterNumber}");

            _assert = ChapterAssert.FromResponse(_response, LibraryId);
        }
Пример #14
0
        private void btnCharterAddRow_Click(object sender, EventArgs e)
        {
            ChapterDto chapter = new ChapterDto();

            chapter.ProjectCode = project.ProjectCode;
            chapter.Weight      = Convert.ToDecimal(0.00);
            dataHandlerChapter.AddRow(chapter);
        }
        public async Task Setup()
        {
            _chapter  = ChapterBuilder.WithLibrary(LibraryId).Public().Build();
            _contents = RandomData.String;

            _response = await Client.PostString($"/libraries/{LibraryId}/books/{_chapter.BookId}/chapters/{_chapter.ChapterNumber}/contents?language={RandomData.Locale}", _contents, RandomData.Locale);

            _assert = new ChapterContentAssert(_response, LibraryId);
        }
Пример #16
0
        public async Task Setup()
        {
            _chapter = ChapterBuilder.WithLibrary(LibraryId).Public().WithContents().Build();
            _content = ChapterBuilder.Contents.Single(x => x.ChapterId == _chapter.Id);

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_chapter.BookId}/chapters/{_chapter.ChapterNumber}/contents?language={_content.Language}");

            _assert = new ChapterContentAssert(_response, LibraryId);
        }
Пример #17
0
        public async Task Setup()
        {
            _chapter = ChapterBuilder.WithLibrary(LibraryId).Public().WithContents().Build();
            _content = ChapterBuilder.Contents.Single(x => x.ChapterId == _chapter.Id);

            _newContents = RandomData.String;

            _response = await Client.PutString($"/libraries/{LibraryId}/books/{_chapter.BookId}/chapters/{_chapter.Id}/contents?language={_content.Language}", _newContents);
        }
Пример #18
0
        private void btnDetail_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            tabControl1.SelectedTab = tabPage2;
            ChapterDto chapter = grvCharter.GetFocusedRow() as ChapterDto;

            CommonHandler.SetComboBoxSelectedValue(cboProject, chapter.ProjectCode);
            CommonHandler.SetComboBoxSelectedValue(cboChapter, chapter.CharterCode);
            SearchLink();
        }
Пример #19
0
        private void grvCharter_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            ChapterDto chapter = grvCharter.GetRow(e.RowHandle) as ChapterDto;

            if ((e.Column == gcCharterCodeChapter && chapter.StatusType != 'I') || e.Column == gcProjectCodeChapter)
            {
                e.Appearance.BackColor = Color.Gray;
            }
        }
Пример #20
0
        private void grvCharter_ShowingEditor(object sender, CancelEventArgs e)
        {
            ChapterDto chapter = grvCharter.GetFocusedRow() as ChapterDto;

            if (grvCharter.FocusedColumn == gcCharterCodeChapter && chapter.StatusType != 'I')
            {
                e.Cancel = true;
            }
        }
Пример #21
0
        public async Task Setup()
        {
            var chapters = ChapterBuilder.WithLibrary(LibraryId).WithContents(2).Build(4);

            _expected = chapters.PickRandom();

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_expected.BookId}/chapters/{_expected.ChapterNumber}");

            _assert = ChapterAssert.FromResponse(_response, LibraryId);
        }
Пример #22
0
 private void UpdateItems(ChapterDto c)
 {
     if (currentChapterList.Contains(c))
     {
         currentChapterList.Remove(c);
     }
     else
     {
         currentChapterList.Add(c);
     }
     chapterList.Items.Refresh();
 }
Пример #23
0
        private void addChapterBtn_Click(object sender, RoutedEventArgs e)
        {
            ChapterDto c = new ChapterDto
            {
                ChapterUrl  = linkTxtBox.Text,
                DisplayName = nameTxtBox.Text
            };

            Chapter = c;
            Success = true;
            Close();
        }
Пример #24
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (filePath != string.Empty)
            {
                try
                {
                    PdfReader reder = new PdfReader(filePath);



                    for (int page = 1; page <= reder.NumberOfPages; page++)
                    {
                        ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();
                        string s = PdfTextExtractor.GetTextFromPage(reder, page, its);
                        s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));

                        ChapterDto chapter = new ChapterDto();
                        chapter.ChapterName = "Page " + page;
                        chapter.BookID      = Convert.ToInt64(cmbBook.SelectedValue.ToString());
                        chapter.CreatedBy   = MDIParent._UserMasterID;
                        chapter.CreatedDate = DateTime.Now;
                        chapter.ModifyDate  = DateTime.Now;
                        chapter.ModifyedBy  = MDIParent._UserMasterID;
                        chapter.Remarks     = rtxtDescreptio.Text.Trim();


                        ChapterDao.Insert(chapter);


                        ContentTextDto ctext = new ContentTextDto();
                        ctext.BookID      = Convert.ToInt64(cmbBook.SelectedValue.ToString());
                        ctext.ChapterID   = page;
                        ctext.Content     = s;
                        ctext.CreatedBy   = MDIParent._UserMasterID;
                        ctext.CreatedDate = DateTime.Now;
                        ctext.ModifyedBy  = MDIParent._UserMasterID;
                        ctext.ModifyDate  = DateTime.Now;
                        ctext.Remarks     = rtxtDescreptio.Text;
                        ContentTextDao.Insert(ctext);
                    }

                    MessageBox.Show(Constant.NOTIFICATION_SUCCESS_DATA_SAVING, Constant.NOTIFICATION_CAPTION_SAVE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Constant.DBErrorMsg, Constant.NOTIFICATION_ERROR_DATA_SAVING, MessageBoxButtons.OK, MessageBoxIcon.Error);


                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #25
0
        /// <summary>
        /// 创建章节
        /// </summary>
        /// <param name="chapterDto"></param>
        /// <returns></returns>
        public async Task <ChapterDto> CreateChapter(ChapterDto chapterDto)
        {
            // 判断课程是否存在
            var course = await _chapterRepository.Change <TbCourse>()
                         .FirstOrDefaultAsync(u => u.Id == chapterDto.CourseId);

            if (course == null)
            {
                throw Oops.Oh(CourseErrorCodes.c1501);
            }
            var chapter = await _chapterRepository
                          .InsertNowAsync(chapterDto.Adapt <TbChapter>());

            return(chapter.Entity.Adapt <ChapterDto>());
        }
        public static ChapterDto ToChapterDto(this Chapter chapter, int presentationId)
        {
            var c = new ChapterDto
            {
                _id            = chapter._id,
                Title          = chapter.Title,
                LastAction     = chapter.LastAction,
                Order          = chapter.Order,
                ChapterJson    = chapter.ChapterJson,
                PresentationId = presentationId.ToString(),
                SlidesCount    = chapter.Slides.Count
            };

            return(c);
        }
Пример #27
0
 public async Task <ApiResponse <Chapter> > CreateChapter(ChapterDto chapter)
 {
     try
     {
         return(await _chapterService.CreateChapter(chapter));
     }
     catch (Exception ex)
     {
         return(new ApiResponse <Chapter>()
         {
             Success = false, Errors = new List <string>()
             {
                 ex.Message
             }
         });
     }
 }
Пример #28
0
        public static List <ChapterDto> GetByBookID(long BookID)
        {
            List <ChapterDto> ChapterList = new List <ChapterDto>();
            ChapterDto        Chapter;

            string sql = "SELECT * FROM tblChapter WHERE BookID=@BookID";

            Console.WriteLine(sql);
            SqlConnection con = new SqlConnection(Properties.Settings.Default.BlindEyeDBConStr);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@BookID", BookID);
            //ChapterID,ChapterName,AuthorName,ReleseYear,Remarks,CreatedDate,CreatedBy,ModifyDate,ModifyedBy
            try
            {
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    Chapter           = new ChapterDto();
                    Chapter.ChapterID = Convert.ToInt64(rdr["ChapterID"]);

                    Chapter.ChapterName = Convert.ToString(rdr["ChapterName"]);
                    Chapter.BookID      = Convert.ToInt64(rdr["BookID"]);
                    Chapter.Remarks     = Convert.ToString(rdr["Remarks"]);
                    Chapter.CreatedDate = Convert.ToDateTime(rdr["CreatedDate"]);
                    Chapter.CreatedBy   = Convert.ToInt16(rdr["CreatedBy"]);
                    Chapter.ModifyDate  = Convert.ToDateTime(rdr["ModifyDate"]);
                    Chapter.ModifyedBy  = Convert.ToInt16(rdr["ModifyedBy"]);


                    ChapterList.Add(Chapter);
                }
                return(ChapterList);
            }
            catch (Exception ex)
            {
                Utilities.Constant.DBErrorMsg = ex.Message;
                return(ChapterList);
            }
            finally
            {
                con.Close();
            }
        }
Пример #29
0
        private void SearchChapter()
        {
            List <ChapterDto> sourcechapterList = new List <ChapterDto>();
            string            projectCode       = CommonHandler.GetComboBoxSelectedValue(cboProject).ToString();
            DataSet           ds = service.SearchChapter(projectCode, "");

            if (ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ChapterDto chapter = new ChapterDto();
                    chapter.CharterName    = Convert.ToString(ds.Tables[0].Rows[i]["CharterName"]);
                    chapter.CharterCode    = Convert.ToString(ds.Tables[0].Rows[i]["CharterCode"]);
                    chapter.CharterContent = Convert.ToString(ds.Tables[0].Rows[i]["CharterContent"]);
                    //inspection.InspectionStandardName = Convert.ToString(ds.Tables[0].Rows[i]["InspectionStandardName"]);
                    sourcechapterList.Add(chapter);
                }
                grcChapter.DataSource = sourcechapterList;
            }
        }
Пример #30
0
        private void getCustomChapterBtn_Click(object sender, RoutedEventArgs e)
        {
            List <ChapterDto> chapters = new List <ChapterDto>();
            var w = new AddChapterDialog();

            w.Owner = this;
            w.ShowDialog();
            ChapterDto c = w.Chapter;

            if (c.DisplayName == "")
            {
                try
                {
                    c.DisplayName = GetDisplayName(switchSite(c.ChapterUrl));
                }
                catch {}
            }
            if (w.Success)
            {
                c.ChapterId = currentChapterList.Count;
                currentChapterList.Add(c);
                chapterList.Items.Refresh();
            }
        }