Example #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkArguments commandArg = e.Argument as WorkArguments;


            switch (commandArg.Command)
            {
            case "UpdateTableInfo":
                LinqSqlHelp.UpdateTableInfo();
                break;

            case "DocumentCreate":
                DbDocumentCreator creator = new DbDocumentCreator();
                creator.CreateDocument((DbDocumentInfo)commandArg.Args);
                break;

            case "DocumentRead":
                DbDocumentReader reader = new DbDocumentReader();
                reader.CreateDBScript((TableCreateInfo)commandArg.Args);
                break;

            default:
                break;
            }
        }
Example #2
0
        private bool TryParseCipai(List <M_Cipai> ciPais, string text, out string cipai, out string title)
        {
            cipai = null;
            title = null;
            if (string.IsNullOrWhiteSpace(text))
            {
                return(false);
            }
            text = text.Trim();
            Regex regex = new Regex(@"^(?<cipai>[^(]+)((?<title>[^)]+))|^(?<cipai>[^(]+)");
            Match m     = regex.Match(text);

            if (!m.Success)
            {
                return(false);
            }
            cipai = m.Groups["cipai"].Value;
            if (m.Groups["title"] != null)
            {
                title = m.Groups["title"].Value.Trim();
            }
            if (cipai.Equals("失调名"))
            {
                return(true);
            }
            var cipaiItem = LinqSqlHelp.GetCipai(ciPais, cipai);

            if (cipaiItem != null)
            {
                cipai = cipaiItem.Cipai;
                return(true);
            }
            return(false);
        }
Example #3
0
        private bool TryParseAuth(List <M_Author> auths, string text, out string auth)
        {
            auth = null;
            if (string.IsNullOrWhiteSpace(text))
            {
                return(false);
            }
            text = text.Replace(" ", "");
            if (text.Length > 7)
            {
                return(false);
            }
            if (text.Equals("无名氏"))
            {
                auth = text;
                return(true);
            }
            var authItem = LinqSqlHelp.GetAuthor(auths, text);

            if (authItem != null)
            {
                auth = authItem.Author;
                return(true);
            }
            return(false);
        }
Example #4
0
        public void ImportBookIndex(string fileName, string bookName, int bookNo)
        {
            string buffer = System.IO.File.ReadAllText(fileName, System.Text.Encoding.UTF8);
            IEnumerable <M_BookIndex> bookIndexs = ReadBookIndex(buffer, bookName, bookNo);

            LinqSqlHelp.AddBookIndex(bookIndexs);
        }
Example #5
0
 private void InitControls()
 {
     this.txtTableName.Text   = Table.TableName;
     this.txtDisplayName.Text = Table.TableDisplayName;
     this.txtComment.Text     = Table.Comment;
     this.dataGridView1.AutoGenerateColumns = false;
     this.dataGridView1.DataSource          = LinqSqlHelp.GetTableLayout(this.Table.TableName);
 }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        keyword = this.txtSearch.Text;
            SearchModes   mode    = (SearchModes)this.cmbSearchMode.SelectedValue;
            SearchOptions opts    = (this.chkTableName.Checked ? SearchOptions.TableName : SearchOptions.None) |
                                    (this.chkColumn.Checked ? SearchOptions.ColumnName : SearchOptions.None) |
                                    (this.chkComment.Checked ? SearchOptions.CommentName : SearchOptions.None);

            this.dataGridView1.AutoGenerateColumns = false;
            this.dataGridView1.DataSource          = LinqSqlHelp.Search(keyword, mode, opts);
        }
Example #7
0
 public bool AddPoem(PoemItem poem)
 {
     try
     {
         LinqSqlHelp.AddPoem2(poem.ToPoem2());
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #8
0
        private void InitControls()
        {
            //テンプレート一覧
            TemplateInfo.DocumentTemplateDataTable templates = TemplateInfo.LoadTemplate();
            this.cmbTemplate.DisplayMember = "TemplateFileName";
            this.cmbTemplate.DataSource    = templates;
            //テーブル一覧
            SearchOptions opts = SearchOptions.None;

            this.dataGridView1.AutoGenerateColumns = false;
            this.dataGridView1.DataSource          = LinqSqlHelp.Search("", SearchModes.Contain, opts);
            //選択状態
            SetDataViewState(true);
        }
Example #9
0
 private void DataView_Load(object sender, EventArgs e)
 {
     try
     {
         long   count     = LinqSqlHelp.GetTableDataCount(Table.TableName);
         string tableName = string.IsNullOrEmpty(Table.TableDisplayName) ? Table.TableName : Table.TableDisplayName;
         this.Text = tableName + "(" + count + "件)";
         InitDataView();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #10
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (this.Table.IsChanged)
            {
                LinqSqlHelp.Update(this.Table);
            }

            EntitySet <TableLayoutInfo> columns = this.dataGridView1.DataSource as EntitySet <TableLayoutInfo>;

            if (columns != null)
            {
                var changedItems = columns.Where(T => T.IsChanged).ToList();
                LinqSqlHelp.Update(changedItems);
            }
        }
Example #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            long maxId = LinqSqlHelp.GetMaxId();

            this.txtStart.Text = maxId.ToString();
        }
Example #12
0
        protected override void Regist(System.IO.MemoryStream contentStream, string[] args)
        {
            this._count++;
            string             content  = System.Text.Encoding.UTF8.GetString(contentStream.ToArray());
            CQ                 cq       = new CQ(content, HtmlParsingMode.Auto, HtmlParsingOptions.Default, DocType.HTML5);
            var                poem     = cq.Select(".poem");
            var                contents = poem.Select(".content");
            List <M_Poem2>     poems    = new List <M_Poem2>();
            List <M_PoemImage> imgs     = new List <M_PoemImage>();
            Regex              regex    = new Regex(@"(?<title>[^(]+)((?<dynasty>[^·]+)·(?<auth>[^)]+))\s(?<gelu>.*)(?=押)(押(?<yun>[^韵])韵){0,1}");

            for (int i = 0; i < contents.Length; i++)
            {
                CQ     titleSmallNode = poem.Select(".title:eq(" + i + ") > .small");
                string smallNode      = "";
                if (titleSmallNode.Length > 0)
                {
                    smallNode = titleSmallNode.Text();
                    titleSmallNode.Remove();
                }
                string titleText = poem.Select(".title:eq(" + i + ")").Text();
                Match  m         = regex.Match(titleText);
                string title     = titleText;
                string author    = "";
                string dynasty   = "";
                string yun       = "";
                if (m.Success)
                {
                    title   = m.Groups["title"].Value;
                    author  = m.Groups["auth"].Value;
                    dynasty = m.Groups["dynasty"].Value;

                    if (m.Groups["yun"] != null)
                    {
                        yun = m.Groups["yun"].Value;
                    }
                }
                string titleNote = poem.Select(".title:eq(" + i + ") ~ .titleNote").Text();
                if (!string.IsNullOrEmpty(smallNode))
                {
                    titleNote += "\n" + smallNode;
                }
                string mainBody   = poem.Select(".content:eq(" + i + ")").Text();
                string label      = poem.Select(".content:eq(" + i + ") + .footer > .label").Text();
                string footer     = poem.Select(".content:eq(" + i + ") + .footer > .comment").Text();
                string commentBar = poem.Select("div.comment").Text();
                string html       = System.Web.HttpUtility.HtmlDecode(poem.Html());
                //入力チェック
                //Title
                if (!string.IsNullOrEmpty(title) && title.Length > 250)
                {
                    if (string.IsNullOrWhiteSpace(titleNote))
                    {
                        titleNote = title;
                    }
                    title = title.Substring(0, 250);
                }
                //Dynasty
                if (!string.IsNullOrEmpty(title) && dynasty.Length > 50)
                {
                    dynasty = dynasty.Substring(0, 50);
                }
                poems.Add(new M_Poem2()
                {
                    ID        = int.Parse(args[0]),
                    SubID     = i,
                    Title     = title,
                    Yun       = yun,
                    TitleNote = titleNote,
                    MainBody  = mainBody,
                    Author    = author,
                    Dynasty   = dynasty,
                    Footer    = label + footer,
                    Comment   = commentBar,
                    Html      = html
                });
                if (this.Report != null)
                {
                    Dictionary <string, string> result = new Dictionary <string, string>();
                    result["count"]   = this._count.ToString();
                    result["message"] = string.Format("ID:{0}【{1}】{2}", args[0], title, author);;
                    result["content"] = mainBody;
                    this.Report(this.Parsentage, result);
                }
            }


            //参照イメージ
            CQ refImgs = poem.Select(".picSSIcon , .picSSOn");

            for (int i = 0; i < refImgs.Length; i++)
            {
                string title = refImgs.Get(i).Attributes["title"];
                string url   = "http://sou-yun.com" + refImgs.Get(i).Attributes["src"];
                imgs.Add(new M_PoemImage()
                {
                    ID       = int.Parse(args[0]),
                    SubID    = 0,
                    ImageId  = i + 1,
                    Title    = title,
                    ImageUrl = url
                });
            }
            LinqSqlHelp.AddPoem2(poems, imgs);
        }
Example #13
0
        private void InitDataView()
        {
            DataTable dtt = LinqSqlHelp.GetTableData(Table.TableName, 10000);

            this.dataGridView.DataSource = dtt;
        }
Example #14
0
 public List <PoemItem> QueryPoem(string key)
 {
     return(LinqSqlHelp.QueryPoem(key).Select(p => new PoemItem(p)).ToList());
 }
Example #15
0
        public void ImportCiBook(string fileName, int bookNo)
        {
            List <M_Poem> poems = ReadSongciBook(fileName, bookNo);

            LinqSqlHelp.AddPoems(poems);
        }
Example #16
0
        private List <M_Poem> ReadSongciBook(string fileName, int bookNo)
        {
            using (StreamReader reader = new StreamReader(fileName, System.Text.Encoding.UTF8))
            {
                List <M_Poem>   poems    = new List <M_Poem>();
                List <M_Author> Auths    = LinqSqlHelp.GetAllAuthor();
                List <M_Cipai>  Cipais   = LinqSqlHelp.GetAllCipai();
                M_Poem          poemItem = null;
                int             sectNo   = 0;
                int             no       = 0;
                string          title    = "";
                string          auth     = "";
                string          cipai    = "";
                StringBuilder   content  = null;
                string          text     = reader.ReadLine();

                while (text != null)
                {
                    //作成者変更
                    string tempAuth;
                    if (TryParseAuth(Auths, text, out tempAuth))
                    {
                        sectNo++;
                        if (poemItem != null)
                        {
                            poemItem.MainBody = FormatPoemText(content.ToString());
                            poemItem.Title    = title;
                            FormatCiPoemItem(poemItem);
                            poems.Add(poemItem);
                        }
                        auth     = tempAuth;
                        poemItem = null;
                        no       = 0;
                        text     = reader.ReadLine();
                        continue;
                    }

                    string tempCipai;
                    string tempTitle;
                    if (TryParseCipai(Cipais, text, out tempCipai, out tempTitle))
                    {
                        if (poemItem != null)
                        {
                            poemItem.MainBody = FormatPoemText(content.ToString());
                            FormatCiPoemItem(poemItem);
                            poems.Add(poemItem);
                        }
                        no++;
                        cipai    = tempCipai;
                        title    = tempTitle;
                        content  = new StringBuilder();
                        poemItem = new M_Poem()
                        {
                            BookNo    = bookNo,
                            SectionNo = sectNo,
                            PoemNo    = no,
                            Cipai     = cipai,
                            Title     = title,
                            Author    = auth,
                            Dynasty   = "宋",
                            PoemType  = "词"
                        };
                    }
                    else
                    {
                        if (content != null)
                        {
                            content.AppendLine(text.Trim());
                        }
                    }
                    text = reader.ReadLine();
                }
                //最後の内容
                if (poemItem != null)
                {
                    poemItem.MainBody = FormatPoemText(content.ToString());
                    poems.Add(poemItem);
                }
                return(poems);
            }
        }