예제 #1
0
        private void btnGet_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(this.txtNcode.Text))
            {
                MessageBox.Show(String.Format(Resources.Msg_FieldInput, "ncode"),
                                Resources.Msg_Information,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            var ncode = this.txtNcode.Text.Trim();

            this.Html = HtmlMng.getNovel(ncode);

            if (String.IsNullOrWhiteSpace(Html))
            {
                MessageBox.Show(String.Format(Resources.Msg_NcodeNotFound, ncode),
                                Resources.Msg_Information,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            this.txtTitle.Text      = HtmlMng.getNovelTitle(Html);
            this.txtWritername.Text = HtmlMng.getNovelWriterName(Html);
            this.txtSummary.Text    = HtmlMng.getNovelSummary(Html);
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var ncode = this.txtNcode.Text.Trim();

            if (String.IsNullOrWhiteSpace(Html))
            {
                MessageBox.Show(String.Format(Resources.Msg_NcodeNotFound, ncode),
                                Resources.Msg_Information,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (DbMng.IsNcodeExists(ncode))
            {
                MessageBox.Show(String.Format(Resources.Msg_AlreadyBeenRegistered, ncode),
                                Resources.Msg_Information,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            using (var cnn = DbMng.getConnection())
            {
                cnn.Open();
                cnn.ChangePassword("");
                using (var trans = cnn.BeginTransaction())
                {
                    using (var context = DbMng.getContext(cnn))
                    {
                        var novellist = new Novellist();
                        novellist.Ncode      = ncode;
                        novellist.Title      = this.txtTitle.Text;
                        novellist.Writername = this.txtWritername.Text;
                        novellist.Html       = this.Html;
                        var novelid   = DbMng.addNovelList(novellist, context);
                        var subtitles = HtmlMng.getNovelSubtitleList(this.Html);
                        foreach (var a in subtitles)
                        {
                            var subtitle = HtmlMng.getNovelSubtitle(ncode, a.InnerHtml);
                            subtitle.Novelid = novelid;
                            DbMng.addSubtitle(subtitle, context);
                        }
                        DbMng.addNewNovelSetting(novelid, context);
                    }
                    trans.Commit();
                }
                cnn.Close();
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #3
0
        private void frmNdlUpdate_Load(object sender, System.EventArgs e)
        {
            var lsubtitles = DbMng.getSubTitleByNovelId(this.Ncode);
            var osubtitles = new List <Subtitle>();
            var html       = HtmlMng.getNovel(this.Ncode);
            var subtitles  = HtmlMng.getNovelSubtitleList(html);

            foreach (var a in subtitles)
            {
                var subtitle = HtmlMng.getNovelSubtitle(this.Ncode, a.InnerHtml);
                osubtitles.Add(subtitle);
            }

            foreach (var lsubtitle in lsubtitles)
            {
                var upddate = osubtitles.Find(x => x.Url == lsubtitle.Url);

                var updflg = true;
                if (lsubtitle.Upddate.Equals(upddate.Upddate))
                {
                    updflg = false;
                }

                this.dgvSubtitles.Rows.Add(updflg,
                                           lsubtitle.Id,
                                           lsubtitle.Capter,
                                           lsubtitle.Title,
                                           lsubtitle.Upddate,
                                           upddate.Upddate);
            }

            foreach (var osubtitle in osubtitles)
            {
                var notlocal = lsubtitles.Find(x => x.Url.Contains(osubtitle.Url));
                if (notlocal != null)
                {
                    continue;
                }

                this.dgvSubtitles.Rows.Add(true,
                                           0,
                                           osubtitle.Capter,
                                           osubtitle.Title,
                                           "",
                                           osubtitle.Upddate);
            }
        }