示例#1
0
        //初始化数据库,生成各种字段
        private void initDataBase()
        {
            //IConfigurationSource source = new Castle.ActiveRecord.Framework.Config.XmlConfigurationSource("../TestCases/ActiveRecordConfig.xml");


            //// 载入程序集中所有 ActiveRecord 类。
            //ActiveRecordStarter.Initialize(source, typeof(WordRES), typeof(WordLogic));

            WordRES u = WordRES.Find(1);
            WordRES m = new WordRES();

            m.CreateAndFlush();
        }
示例#2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //所有sheet页循环
            for (int i = 1; i <= ewb.Sheets.Count; i++)
            {
                Worksheet subTableSheet = ewb.Sheets[i] as Worksheet;
                string    tempSheetName = subTableSheet.Name;
                if (tempSheetName.Contains("所有单词RES") ||
                    tempSheetName.Contains("所有单词logic") ||
                    tempSheetName.Contains("读音唯一")
                    )
                {
                    continue;
                }
                Dictionary <String, ArrayList> subTableWholeWordList = new Dictionary <string, ArrayList>();
                //检查字体
                int subTableSheetValidCount = GetValidCellRowCount(subTableSheet, subTableWholeWordList);
                for (int j = 2; j < subTableSheetValidCount; j++)
                {
                    String x;
                    try
                    {
                        x = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 4])).Font.Name;
                    }
                    catch
                    {
                        x = "Kingsoft Phonetic Plain";
                    }
                    //映射字体
                    ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 8])).Value = FontName(x);

                    try
                    {
                        //插入RES
                        WordRES wordres = new WordRES();
                        //wordres.num = j;
                        wordres.word = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 2])).Value;

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value))
                        {
                            wordres.subject = (int)(((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value);
                        }

                        wordres.phoneticSymbol = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 4])).Value;
                        wordres.wordMeaning    = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 5])).Value;
                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value))
                        {
                            wordres.unit = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value;
                        }

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 7])).Value))
                        {
                            wordres.book = (int)(((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 7])).Value) - 1;
                        }

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 8])).Value))
                        {
                            wordres.fontType = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 8])).Value;
                        }

                        wordres.CreateAndFlush();

                        //插入Logic
                        WordLogic wordlogic = new WordLogic();
                        //wordlogic.num = j - 1;
                        wordlogic.word = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 2])).Value;

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value))
                        {
                            wordlogic.subject = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value;
                        }
                        wordlogic.remCount    = 1;
                        wordlogic.lastRemTime = new DateTime(2014, 7, 8, 18, 6, 0);
                        wordlogic.nextRemTime = new DateTime(2014, 7, 8, 18, 6, 0);

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value))
                        {
                            wordlogic.unit = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value;
                        }
                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 7])).Value))
                        {
                            wordlogic.book = (int)(((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 7])).Value) - 1;
                        }

                        wordlogic.CreateAndFlush();
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc);
                    }
                }
            }
        }
示例#3
0
        //button4,将各个子sheet页的内容插入到RES和Logic表中,并填入其他所缺的内容
        private void insert_words_to_list(object sender, RoutedEventArgs e)
        {
            Regex pathrgx = new Regex(@".*\\(.*\..*)");

            if (String.IsNullOrEmpty(mappath.Text))
            {
                MessageBox.Show("检查文档不能为空!");
                return;
            }

            Match parentTableMth = pathrgx.Match(mappath.Text);

            m_Workbooks.Open(mappath.Text);
            String parentWorkbookName = parentTableMth.Groups[1].ToString();

            parentWorkBook = m_Workbooks[parentWorkbookName];
            string parentWordTableName = parentWorkBook.FullName;

            Regex versionRgx = new Regex(@"([0-9]+)_(.*)");


            //所有sheet页循环
            for (int i = 1; i <= parentWorkBook.Sheets.Count; i++)
            {
                Worksheet subTableSheet = parentWorkBook.Sheets[i] as Worksheet;
                //特殊名称的sheet页跳过
                string tempSheetName = subTableSheet.Name;
                if (tempSheetName.Contains("所有单词RES") ||
                    tempSheetName.Contains("所有单词logic") ||
                    tempSheetName.Contains("读音唯一") ||
                    tempSheetName.Contains("_未分节")
                    )
                {
                    continue;
                }

                //解析版本序号名
                Match versionMatch = versionRgx.Match(tempSheetName);
                int   bookId       = -1;
                int.TryParse(versionMatch.Groups[1].ToString(), out bookId);

                Dictionary <String, ArrayList> subTableWholeWordList = new Dictionary <string, ArrayList>();
                //检查字体
                int subTableSheetValidCount = GetValidCellRowCount(subTableSheet, subTableWholeWordList);
                for (int j = 2; j < subTableSheetValidCount; j++)
                {
                    String x;
                    try
                    {
                        x = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 4])).Font.Name;
                    }
                    catch
                    {
                        x = "Kingsoft Phonetic Plain";
                    }
                    //映射字体
                    ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 8])).Value = FontName(x);

                    try
                    {
                        //插入RES
                        WordRES wordres = new WordRES();
                        //wordres.num = j;
                        wordres.word = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 2])).Value;

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value))
                        {
                            wordres.subject = (int)(((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value);
                        }

                        wordres.phoneticSymbol = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 4])).Value;
                        wordres.wordMeaning    = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 5])).Value;
                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value))
                        {
                            wordres.unit = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value;
                        }

                        //书号
                        wordres.book = bookId - 1;

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 8])).Value))
                        {
                            wordres.fontType = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 8])).Value;
                        }

                        wordres.CreateAndFlush();

                        //插入Logic
                        WordLogic wordlogic = new WordLogic();
                        //wordlogic.num = j - 1;
                        wordlogic.word = ((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 2])).Value;

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value))
                        {
                            wordlogic.subject = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 3])).Value;
                        }
                        wordlogic.remCount    = 1;
                        wordlogic.lastRemTime = new DateTime(2014, 7, 8, 18, 6, 0);
                        wordlogic.nextRemTime = new DateTime(2014, 7, 8, 18, 6, 0);

                        if (null != (((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value))
                        {
                            wordlogic.unit = (int)((Microsoft.Office.Interop.Excel.Range)(subTableSheet.Cells[j, 6])).Value;
                        }
                        //书号
                        wordlogic.book = bookId - 1;

                        wordlogic.CreateAndFlush();
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc);
                    }
                }
            }

            parentWorkBook.Save();
            MessageBox.Show("单词对应完毕!");
        }