コード例 #1
0
ファイル: SysManageController.cs プロジェクト: imbkj/xeasyapp
        public JsonResult SaveDictInfo(int?id, DictInfo di)
        {
            JsonReturnMessages msg = new JsonReturnMessages();

            try
            {
                if (id.HasValue && id.Value > 0)
                {
                    di.IsNew  = false;
                    di.DictID = id.Value;
                }
                else
                {
                    di.IsNew = true;
                }
                di.IsSystem = false;

                sysManageService.SaveDictInfo(di);
                msg.IsSuccess = true;
                msg.Msg       = "操作成功";
            }
            catch (BizException ex)
            {
                msg.IsSuccess = false;
                msg.Msg       = ex.Message;
            }
            catch (Exception ex)
            {
                msg.IsSuccess = false;
                msg.Msg       = "操作失败:" + ex.Message;
            }
            return(Json(msg));
        }
コード例 #2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        DictInfo info = new DictInfo();

        info.Code     = this.TXT_CODE.Text.Trim();
        info.Name     = this.TXT_NAME.Text.Trim();
        info.TypeCode = this.DDL_TYPE.SelectedValue;
        info.Remark   = this.TXT_REMARK.Text.Trim();
        info.IsEnable = this.CHB_ISENABLE.Checked ? "Y" : "N";
        if (this.TXT_SORT.Text.Trim() != "")
        {
            info.Sort = int.Parse(this.TXT_SORT.Text.Trim());
        }
        else
        {
            info.Sort = 0;
        }
        if (_Dict.ModifyDict(info))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增字典保存成功!');</script>");
            Response.Redirect("Default.aspx");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增字典保存失败!');</script>");
        }
    }
コード例 #3
0
        private List <DictInfo> GetLogType()
        {
            List <DictInfo> list  = new List <DictInfo>();
            DictInfo        dict1 = new DictInfo();

            dict1.DictCode = "";
            dict1.DictName = "全部";

            DictInfo dict2 = new DictInfo();

            dict2.DictCode = "0";
            dict2.DictName = "调试";
            DictInfo dict3 = new DictInfo();

            dict3.DictCode = "1";
            dict3.DictName = "跟踪";

            DictInfo dict4 = new DictInfo();

            dict4.DictCode = "2";
            dict4.DictName = "错误";

            list.Add(dict1);
            list.Add(dict2);
            list.Add(dict3);
            list.Add(dict4);
            return(list);
        }
コード例 #4
0
        private async Task <DictInfo> GenerateBaseInfoFromInfoFile(string path)
        {
            if (false == File.Exists(path))
            {
                return(null);
            }
            var result = new DictInfo();
            var type   = typeof(DictInfo);
            var props  = type.GetProperties();
            var lines  = File.ReadAllLines(path).Where(t => false == string.IsNullOrWhiteSpace(t));

            foreach (var line in lines)
            {
                var kv = line.Split('=');
                if (kv.Length != 2)
                {
                    continue;
                }
                var prop = props.FirstOrDefault(t => t.Name.ToLower() == kv[0]);
                if (prop == null)
                {
                    continue;
                }
                prop.SetValue(result, kv[1]);
            }
            return(await Task.FromResult(result));
        }
コード例 #5
0
ファイル: SysManageController.cs プロジェクト: imbkj/xeasyapp
        public ActionResult EditDictInfo(int?id, int?ParentID, string ParentName)
        {
            DictInfo di;

            if (id.HasValue)
            {
                di = sysManageService.GetDictInfo(id.Value);
                if (di == null)
                {
                    throw new ArgumentException("参数错误,不存在对应的数据字典", "DictID");
                }
                else //处理
                {
                }
            }
            else
            {
                di = new DictInfo();
                if (ParentID.HasValue)
                {
                    di.ParentID   = ParentID.Value;
                    di.ParentName = ParentName;
                }
                else
                {
                    di.ParentID   = 0;
                    di.ParentName = "数据字典";
                }
            }
            return(View(di));
        }
コード例 #6
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            tableName2SQLite = textBoxTableName.Text;
            briefIntro       = textBoxBriefIntroduction.Text;

            string errMsg = "";

            if (tableName2SQLite.Length < 2)
            {
                errMsg = "词典名字至少需要2个字符!";
            }
            else if (GetDictsInfo(FormMain.sqliteInstance).Contains(tableName2SQLite))
            {
                //tableName已经存在
                errMsg = "您指定的词典名字已经存在,请重新指定名字。";
            }
            else if (string.IsNullOrEmpty(fileName))
            {
                errMsg = "您还没有指定词典文件,请指定。";
            }
            else if (briefIntro.Length < 10)
            {
                errMsg = "词典简介10个字符,请完善简介信息。";
            }

            DataTable wordsTable = ExcelNpoiUtility.ExcelToDataTableNpoi(fileName);

            if (wordsTable == null)
            {
                errMsg = "读取EXCEL文件失败,请关闭文件后再次尝试。";
            }
            if (errMsg.Length > 0)
            {
                MessageBox.Show(errMsg, "词典错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxTableName.Focus();
                return;
            }

            string sql2CreateTable = DictHelper.FormatCreateWordInfoSql(tableName2SQLite);

            FormMain.sqliteInstance.WriteTable2Db(wordsTable, tableName2SQLite, sql2CreateTable);

            DictInfo di = new DictInfo
            {
                DictName   = tableName2SQLite,
                WordCount  = wordsTable.Rows.Count,
                BriefIntro = briefIntro,
                IsChecked  = 1 //新加入的默认为勾选
            };
            List <DictInfo> diList = new List <DictInfo>
            {
                di
            };

            SetupDictsInfo(diList, DictOps.AddDict, FormMain.sqliteInstance);
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #7
0
        private static bool Swap(List <DictInfo> diList, DictInfo di1, DictInfo di2)
        {
            int pos1 = diList.IndexOf(di1);
            int pos2 = diList.IndexOf(di2);

            diList[pos1] = di2;
            diList[pos2] = di1;
            return(true);
        }
コード例 #8
0
ファイル: DictSearcher.cs プロジェクト: hsxian/AnyDict
 public async Task <bool> SetDict(byte[] dict, DictInfo info)
 {
     if (dict?.Any() == false || info?.IdxMap == null)
     {
         return(false);
     }
     this._info = info;
     this._dict = dict;
     return(await Task.FromResult(true));
 }
コード例 #9
0
ファイル: Default.aspx.cs プロジェクト: xibeilang524/JXNG
    /// <summary>
    ///
    /// </summary>
    private void BindGridView()
    {
        DictInfo info = new DictInfo();

        info.Code                 = this.TXT_CODE.Text.Trim();
        info.Name                 = this.TXT_NAME.Text.Trim();
        info.TypeCode             = this.DDL_TYPE.SelectedValue;
        info.IsEnable             = this.CHB_ISENABLE.Checked ? "Y" : "N";
        this.GridView1.DataSource = _Dict.GetDictInfoByCondition(info);
        this.GridView1.DataBind();
    }
コード例 #10
0
        public async Task <DictInfo> GetDictInfo(string dir, string name)
        {
            DictInfo result = await GenerateBaseInfoFromInfoFile(Path.Combine(dir, name) + ".ifo");

            if (result == null)
            {
                return(null);
            }
            result.IdxMap = await GetWordIdxMap(Path.Combine(dir, name) + ".idx");

            return(result);
        }
コード例 #11
0
ファイル: DeptManage.aspx.cs プロジェクト: xibeilang524/JXNG
    /// <summary>
    ///
    /// </summary>
    private void BindDDL()
    {
        Dict     _Dict = new Dict();
        DictInfo _info = new DictInfo();

        _info.TypeCode = "BMLX";
        this.DDL_DEPTTYPE.DataSource     = _Dict.GetDictInfoByCondition(_info);
        this.DDL_DEPTTYPE.DataTextField  = "Name";
        this.DDL_DEPTTYPE.DataValueField = "Code";
        this.DDL_DEPTTYPE.DataBind();
        this.DDL_DEPTTYPE.Items.Insert(0, new ListItem("---请选择---", ""));
    }
コード例 #12
0
ファイル: FrmDictionary.cs プロジェクト: yyan/winform
        /// <summary>
        /// 读取xml数据
        /// </summary>
        private void ReadXMLData()
        {
            #region 加载数据字典大项
            XmlNodeList xmlNodeLst = xmldicthelper.Read("datatype/dataitem");
            dictTypeInfoList = new List <DictInfo>();
            foreach (XmlNode xn1 in xmlNodeLst)
            {
                DictInfo dictInfo = new DictInfo();
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;

                // 得到DataTypeInfo节点的所有子节点
                XmlNodeList xnl0 = xe.ChildNodes;
                dictInfo.ID     = Convert.ToInt32(xnl0.Item(0).InnerText);
                dictInfo.PID    = Convert.ToInt32(xnl0.Item(1).InnerText);
                dictInfo.Name   = xnl0.Item(2).InnerText;
                dictInfo.Remark = xnl0.Item(3).InnerText;

                dictTypeInfoList.Add(dictInfo);
            }
            #endregion

            #region 读取项目数据
            XmlNodeList xmlprejectNodeLst = xmlprojectthelper.Read("datatype");

            if (xmlprejectNodeLst.Count == 0)
            {
                return;
            }

            XmlNode xn1project = xmlprejectNodeLst[0];
            projectInfo = new ProjectInfo();

            // 将节点转换为元素,便于得到节点的属性值
            XmlElement xeproject = (XmlElement)xn1project;
            // 得到Type和ISBN两个属性的属性值
            projectInfo.GUID = xeproject.GetAttribute("guid").ToString();
            // 得到DataTypeInfo节点的所有子节点
            XmlNodeList xnl0project = xeproject.ChildNodes;
            projectInfo.Name          = xnl0project.Item(0).InnerText;
            projectInfo.Version       = xnl0project.Item(1).InnerText;
            projectInfo.Contract      = xnl0project.Item(2).InnerText;
            projectInfo.Remark        = xnl0project.Item(3).InnerText;
            projectInfo.DbType        = xnl0project.Item(4).InnerText;
            projectInfo.DicttypeTable = xnl0project.Item(5).InnerText;
            projectInfo.DictdataTable = xnl0project.Item(6).InnerText;
            projectInfo.ErrTable      = xnl0project.Item(7).InnerText;
            projectInfo.LastTime      = xnl0project.Item(8).InnerText;
            projectInfo.OutputPath    = xnl0project.Item(9).InnerText;

            #endregion
        }
コード例 #13
0
    /// <summary>
    ///
    /// </summary>
    private void GetDictInfo(string Code, string Type)
    {
        DictInfo info = _Dict.GetDictInfo(Code, Type);

        if (info != null)
        {
            this.TXT_CODE.Text          = info.Code;
            this.TXT_NAME.Text          = info.Name;
            this.TXT_SORT.Text          = info.Sort.ToString();
            this.TXT_REMARK.Text        = info.Remark;
            this.DDL_TYPE.SelectedValue = info.TypeCode;
            this.CHB_ISENABLE.Checked   = info.IsEnable == "Y" ? true : false;
        }
    }
コード例 #14
0
        private static DictInfo GetAdjecentDictInfo(List <DictInfo> diList, DictInfo me, Direction direction)
        {
            DictInfo di;
            int      index = diList.IndexOf(me);

            if (direction == Direction.ToHigher)
            {
                di = diList[index - 1];
            }
            else
            {
                di = diList[index + 1];
            }
            return(di);
        }
コード例 #15
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            tableName2SQLite = textBoxTableName.Text;
            briefIntro       = textBoxBriefIntroduction.Text;

            string errMsg = "";

            if (tableName2SQLite.Length < 2)
            {
                errMsg = "词典名字至少需要2个字符!";
            }
            else if (GetDictsInfo(FormMain.sqliteInstance).Contains(tableName2SQLite))
            {
                //tableName已经存在
                errMsg = "您指定的词典名字已经存在,请重新指定名字。";
            }
            else if (string.IsNullOrEmpty(fileName))
            {
                errMsg = "您还没有指定词典文件,请指定。";
            }
            else if (briefIntro.Length < 10)
            {
                errMsg = "词典简介10个字符,请完善简介信息。";
            }

            if (errMsg.Length > 0)
            {
                MessageBox.Show(errMsg, "词典错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxTableName.Focus();
                return;
            }

            DataTable dataTable = ExcelNpoiUtility.ExcelToDataTableNpoi(fileName);

            FormMain.sqliteInstance.WriteTable2Db(dataTable, tableName2SQLite);
            DictInfo di = new DictInfo();

            di.DictName   = tableName2SQLite;
            di.WordCount  = dataTable.Rows.Count;
            di.BriefIntro = briefIntro;
            di.IsChecked  = 1; //新加入的默认为勾选
            List <DictInfo> diList = new List <DictInfo>();

            diList.Add(di);
            SetupDictsInfo(diList, DictOps.AddDict, FormMain.sqliteInstance);
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #16
0
        private List <DictInfo> GetPrivilegeTypeDictList()
        {
            List <DictInfo> list  = new List <DictInfo>();
            DictInfo        dict1 = new DictInfo();

            dict1.DictCode = "1";
            dict1.DictName = "普通权限";

            DictInfo dict2 = new DictInfo();

            dict2.DictCode = "2";
            dict2.DictName = "菜单权限";
            list.Add(dict1);
            list.Add(dict2);
            return(list);
        }
コード例 #17
0
        /// <summary>
        /// 读取数据库中 _Dicts_Info 的信息
        /// </summary>
        /// <returns></returns>
        public static List <DictInfo> GetDictsInfo(SqliteSingleton sqliteInstance)
        {
            try
            {
                if (dictinfoList != null)
                {
                    return(dictinfoList);
                }

                dictinfoList = new List <DictInfo>();

                using SQLiteConnection con = sqliteInstance.GetConnection();
                string           sql    = $"SELECT * FROM [{_Dicts_Info_Table}]";
                var              sqlcmd = new SQLiteCommand(sql, con);//sql语句
                SQLiteDataReader reader = sqlcmd.ExecuteReader();
                DataTable        dt     = new DataTable();
                if (reader != null)
                {
                    dt.Load(reader, LoadOption.PreserveChanges, null);
                }

                int rowCount    = dt.Rows.Count;    //行数
                int columnCount = dt.Columns.Count; //列数
                if (columnCount != DictInfoItemCount)
                {
                    ErrorLog.Insert("GetDictsInfo 得到的列数与结构体不匹配");
                }
                for (int i = 0; i < rowCount; i++)
                {
                    DictInfo di = new DictInfo();
                    di.DictName   = dt.Rows[i][0].ToString();
                    di.WordCount  = int.Parse(dt.Rows[i][1].ToString());
                    di.BriefIntro = dt.Rows[i][2].ToString();
                    di.Priority   = int.Parse(dt.Rows[i][3].ToString());
                    di.IsChecked  = int.Parse(dt.Rows[i][4].ToString());
                    dictinfoList.Add(di);
                }

                return(dictinfoList);
            }
            catch (Exception ex)
            {
                ErrorLog.Insert("GetTableNames获取数据库表名字列表出现异常!" + ex);
                return(null);
            }
        }
コード例 #18
0
        /// <summary>
        /// 每当搜索项中的词典的勾选状态发生改变,则写入到数据库中。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listViewSearchManage_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            string dictName = e.Item.Text;

            List <DictInfo> checkChangedList = DictsInfoList.Where(i => i.DictName == dictName).ToList();
            DictInfo        checkChangedDict = checkChangedList[0];
            int             index            = DictsInfoList.IndexOf(checkChangedDict);
            bool            checkStateInArr  = CheckedStateArr[index] == 1 ? true : false;

            if (e.Item.Checked == checkStateInArr)//没有变化,是又进入了TabControl或进行了TabPage切换
            {
                return;
            }

            DictOps dictOp = e.Item.Checked ? DictOps.DictChecked : DictOps.DictUnchecked;

            SetupDictsInfo(checkChangedList, dictOp, FormMain.sqliteInstance);
        }
コード例 #19
0
        private void LoadDicts2ListView(ListView listView)
        {
            listView.Items.Clear();
            DictsInfoList   = GetDictsInfo(FormMain.sqliteInstance);
            CheckedStateArr = new int[DictsInfoList.Count];

            for (int i = 0; i < DictsInfoList.Count; i++)
            {
                DictInfo     di   = DictsInfoList[i];
                ListViewItem item = new ListViewItem(new string[] { di.DictName, di.WordCount.ToString(), di.BriefIntro })
                {
                    Checked = di.IsChecked == 1
                };//VS推荐的简化对象初始化

                listView.Items.Add(item);
                CheckedStateArr[i] = di.IsChecked;
            }
            listView.Refresh();
        }
コード例 #20
0
ファイル: PageBase.cs プロジェクト: xibeilang524/JXNG
    protected void BindDDL(DropDownList ddl, string typeCode)
    {
        DictInfo dictInfo = new DictInfo()
        {
            TypeCode = typeCode
        };
        Dict            dict = new Dict();
        List <DictInfo> list = dict.GetDictInfoByCondition(dictInfo);

        if (list.Count > 0)
        {
            ddl.DataSource     = list;
            ddl.DataTextField  = "Name";
            ddl.DataValueField = "Code";
            ddl.DataBind();
        }

        ddl.Items.Insert(0, new ListItem("---请选择---", string.Empty));
    }
コード例 #21
0
        private List <DictInfo> GetOrgTypeDictList()
        {
            List <DictInfo> list  = new List <DictInfo>();
            DictInfo        dict1 = new DictInfo();

            dict1.DictCode = "0";
            dict1.DictName = "单位";

            DictInfo dict2 = new DictInfo();

            dict2.DictCode = "1";
            dict2.DictName = "部门";
            DictInfo dict3 = new DictInfo();

            dict3.DictCode = "2";
            dict3.DictName = "组";
            list.Add(dict1);
            list.Add(dict2);
            list.Add(dict3);
            return(list);
        }
コード例 #22
0
ファイル: FrmStdField.cs プロジェクト: yyan/winform
        /// <summary>
        /// 加载数据字典
        /// </summary>
        private void LoadDicData()
        {
            #region 加载数据字典大项
            XmlHelper   xmldicthelper = new XmlHelper(@"XML\dict.xml");
            XmlNodeList xmlNodeLst    = xmldicthelper.Read("datatype/dataitem");
            dictTypeInfoList = new List <DictInfo>();
            foreach (XmlNode xn1 in xmlNodeLst)
            {
                DictInfo dictInfo = new DictInfo();
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;

                // 得到DataTypeInfo节点的所有子节点
                XmlNodeList xnl0 = xe.ChildNodes;
                dictInfo.ID   = Convert.ToInt32(xnl0.Item(0).InnerText);
                dictInfo.PID  = Convert.ToInt32(xnl0.Item(1).InnerText);
                dictInfo.Name = xnl0.Item(2).InnerText;

                StringBuilder sb = new StringBuilder();

                XmlNodeList xmlNodeLst2 = xmldicthelper.Read(string.Format("datatype/dataitem/item[id=\"{0}\"]/subdic", dictInfo.ID));

                List <DictDetailInfo> dictDetailInfoList = new List <DictDetailInfo>();
                foreach (XmlNode xn12 in xmlNodeLst2)
                {
                    // 将节点转换为元素,便于得到节点的属性值
                    XmlElement xe2 = (XmlElement)xn12;

                    // 得到DataTypeInfo节点的所有子节点
                    XmlNodeList xnl02 = xe2.ChildNodes;
                    sb.Append(string.Format("{0}-{1},\r\n", xnl02.Item(0).InnerText, xnl02.Item(1).InnerText));
                }

                dictInfo.Remark = sb.ToString();

                dictTypeInfoList.Add(dictInfo);
            }
            #endregion
        }
コード例 #23
0
        public static void FindInDictionary(Activity mActivity, DictInfo currentDictionary, string s)
        {
            switch (currentDictionary.internalDict)
            {
            case 0:
                Intent intent = new Intent(currentDictionary.action);
                if (currentDictionary.className != null || Build.VERSION.SdkInt == BuildVersionCodes.Cupcake)
                {
                    intent.SetComponent(new ComponentName(currentDictionary.packageName, currentDictionary.className));
                }
                else
                {
                    intent.SetPackage(currentDictionary.packageName);
                }
                intent.AddFlags(Build.VERSION.SdkInt >= BuildVersionCodes.EclairMr1 ? ActivityFlags.ClearTask : ActivityFlags.NewTask);
                if (s != null)
                {
                    intent.PutExtra(currentDictionary.dataKey, s);
                    intent.PutExtra(Intent.ExtraText, s);
                    intent.SetType("text/plain");
                }
                try
                {
                    mActivity.StartActivity(intent);
                }
                catch (ActivityNotFoundException e)
                {
                    System.Console.WriteLine("Dictionaries FindInDictionary ERROR => " + e.Message);

                    throw new DictionaryException("Dictionary \"" + currentDictionary.name + "\" is not installed");
                }
                break;

            case 1:
                string SEARCH_ACTION    = currentDictionary.action;
                string EXTRA_QUERY      = "EXTRA_QUERY";
                string EXTRA_FULLSCREEN = "EXTRA_FULLSCREEN";

                Intent intent1 = new Intent(SEARCH_ACTION);
                if (s != null)
                {
                    intent1.PutExtra(EXTRA_QUERY, s);     //Search Query
                }
                intent1.PutExtra(EXTRA_FULLSCREEN, true);
                try
                {
                    mActivity.StartActivity(intent1);
                }
                catch (ActivityNotFoundException)
                {
                    throw new DictionaryException("Dictionary \"" + currentDictionary.name + "\" is not installed");
                }
                break;

            case 2:
                // Dictan support
                Intent intent2 = new Intent("android.intent.action.VIEW");
                // Add custom category to run the Dictan external dispatcher
                intent2.AddCategory("info.softex.dictan.EXTERNAL_DISPATCHER");

                // Don't include the dispatcher in activity
                // because it doesn't have any content view.
                intent2.SetFlags(ActivityFlags.NoHistory);

                intent2.PutExtra(DICTAN_ARTICLE_WORD, s);

                try
                {
                    mActivity.StartActivityForResult(intent2, DICTAN_ARTICLE_REQUEST_CODE);
                }
                catch (ActivityNotFoundException)
                {
                    throw new DictionaryException("Dictionary \"" + currentDictionary.name + "\" is not installed");
                }
                break;

            case 3:
                Intent intent3 = new Intent("aard2.lookup");
                intent3.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                intent3.PutExtra(SearchManager.Query, s);
                try
                {
                    mActivity.StartActivity(intent3);
                }
                catch (ActivityNotFoundException)
                {
                    throw new DictionaryException("Dictionary \"" + currentDictionary.name + "\" is not installed");
                }
                break;
            }
        }
コード例 #24
0
        /// <summary>
        /// 根据配置导出SQL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGenerateSQL_Click(object sender, EventArgs e)
        {
            if (projectInfo != null)
            {
                if (string.IsNullOrEmpty(projectInfo.OutputPath))
                {
                    MessageDxUtil.ShowError("请在项目菜单中配置导出脚本路径");
                    return;
                }

                if (!DirectoryUtil.IsExistDirectory(projectInfo.OutputPath))
                {
                    MessageDxUtil.ShowError(string.Format("配置的路径{0}在系统中不存在,请在项目菜单中配置导出脚本路径", projectInfo.OutputPath));
                    return;
                }

                // 操控进度条
                //var progressBar = (this.MdiParent as MainForm).progressBar;
                //progressBar.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;

                if (FileUtil.IsExistFile(projectInfo.OutputPath + "\\Dict.sql"))
                {
                    FileUtil.DeleteFile(projectInfo.OutputPath + "\\Dict.sql");
                }

                FileUtil.CreateFile(projectInfo.OutputPath + "\\Dict.sql");

                #region 处理每个Table脚本
                XmlHelper           xmldicthelper      = new XmlHelper(@"XML\dict.xml");
                XmlNodeList         xmlNodeLst2        = xmldicthelper.Read("datatype/dataitem");
                List <DictInfo>     dictTypeInfoList2  = new List <DictInfo>();
                List <DictDataInfo> dictDetailInfoList = new List <DictDataInfo>();
                foreach (XmlNode xn1 in xmlNodeLst2)
                {
                    DictInfo dictInfo = new DictInfo();
                    // 将节点转换为元素,便于得到节点的属性值
                    XmlElement xe = (XmlElement)xn1;

                    // 得到DataTypeInfo节点的所有子节点
                    XmlNodeList xnl0 = xe.ChildNodes;
                    dictInfo.Id     = Convert.ToInt32(xnl0.Item(0).InnerText);
                    dictInfo.Pid    = Convert.ToInt32(xnl0.Item(1).InnerText);
                    dictInfo.Name   = xnl0.Item(2).InnerText;
                    dictInfo.Remark = xnl0.Item(3).InnerText;

                    if (!string.IsNullOrEmpty(xnl0.Item(4).InnerXml))
                    {
                        System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //新建对象
                        doc.LoadXml("<tmp>" + xnl0.Item(4).InnerXml + "</tmp>");   //符合xml格式的字符串
                        var nodes = doc.DocumentElement.ChildNodes;
                        foreach (var node in nodes)
                        {
                            DictDataInfo dicdetailInfo = new DictDataInfo();
                            var          dNode         = ((XmlElement)node).ChildNodes;
                            dicdetailInfo.DicttypeValue = dNode.Item(0).InnerText.ToInt32();
                            dicdetailInfo.Name          = dNode.Item(1).InnerText;
                            dicdetailInfo.Seq           = dNode.Item(2).InnerText;
                            dicdetailInfo.Remark        = dNode.Item(3).InnerText;
                            dicdetailInfo.DicttypeId    = dictInfo.Id;

                            dictDetailInfoList.Add(dicdetailInfo);
                        }
                    }

                    dictTypeInfoList2.Add(dictInfo);
                }

                // T_Basic_DictType
                // T_Basic_DictData
                FileUtil.AppendText(projectInfo.OutputPath + "\\Dict.sql", JCodes.Framework.Common.Proj.SqlOperate.initDictTypeInfo(projectInfo.DbType, tableGroup["DictType"] + "DictType", "数据字典类型", dictTypeInfoList2), Encoding.Default);

                //progressBar.EditValue = 50;

                FileUtil.AppendText(projectInfo.OutputPath + "\\Dict.sql", JCodes.Framework.Common.Proj.SqlOperate.initDictDataInfo(projectInfo.DbType, tableGroup["DictData"] + "DictData", "数据字典明细", dictDetailInfoList), Encoding.Default);

                //progressBar.EditValue = 100;
                #endregion

                MessageDxUtil.ShowTips("生成脚本成功");
                //progressBar.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            }
        }
コード例 #25
0
        /// <summary>
        /// 设置_Dicts_Info的信息,每当有词典的导入、卸载、向上、向下时,都要设置
        /// </summary>
        /// <param name="tableNames"></param>
        /// <param name="dictOop"></param>
        public static int SetupDictsInfo(List <DictInfo> toOpDictInfos, DictOps dictOp, SqliteSingleton sqliteInstance)
        {
            if (toOpDictInfos.Count == 0)
            {
                return(0);
            }
            int resultCount = 1;

            switch (dictOp)
            {
            case DictOps.AddDict:
                DictInfo toAddDictInfo = toOpDictInfos[0];
                toAddDictInfo.Priority = dictinfoList.Count + 1;    //其他信息已经设置
                dictinfoList.Add(toAddDictInfo);
                break;

            case DictOps.RemoveDicts:
                foreach (DictInfo di in toOpDictInfos)     //其实只允许选中一个
                {
                    dictinfoList.Remove(di);
                }
                for (int i = 0; i < dictinfoList.Count; i++)
                {
                    DictInfo di = dictinfoList[i];
                    di.Priority = i + 1;
                }
                resultCount = toOpDictInfos.Count;
                break;

            case DictOps.DictToHigher:    //TODO:暂时只向上移动一个

                DictInfo toHigherDictInfo = toOpDictInfos[0];
                toHigherDictInfo.Priority -= 1;
                DictInfo adjecent2Higher = GetAdjecentDictInfo(dictinfoList, toHigherDictInfo, Direction.ToHigher);
                adjecent2Higher.Priority += 1;
                Swap(dictinfoList, toHigherDictInfo, adjecent2Higher);
                break;

            case DictOps.DictToLower:    //TODO:暂时只向下移动一个
                DictInfo toLowerrDictInfo = toOpDictInfos[0];
                DictInfo adjecent2Lower   = GetAdjecentDictInfo(dictinfoList, toLowerrDictInfo, Direction.ToLower);
                toLowerrDictInfo.Priority += 1;
                adjecent2Lower.Priority   -= 1;
                Swap(dictinfoList, toLowerrDictInfo, adjecent2Lower);
                break;

            case DictOps.DictChecked:
                DictInfo checkedDictInfo = toOpDictInfos[0];
                checkedDictInfo.IsChecked = 1;
                break;

            case DictOps.DictUnchecked:
                DictInfo uncheckedDictInfo = toOpDictInfos[0];
                uncheckedDictInfo.IsChecked = 0;
                break;
            }

            DataTable dt = ConvertDictInfoList(dictinfoList);

            sqliteInstance.WriteTable2Db(dt, _Dicts_Info_Table, Sql2CreatelDictsInfo);
            return(resultCount);
        }
コード例 #26
0
        /// <summary>
        /// 读取xml数据
        /// </summary>
        private void ReadXMLData()
        {
            #region 加载数据字典大项
            XmlNodeList xmlNodeLst = xmldicthelper.Read("datatype/dataitem");
            dictTypeInfoList = new List <DictInfo>();
            foreach (XmlNode xn1 in xmlNodeLst)
            {
                DictInfo dictInfo = new DictInfo();
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;

                // 得到DataTypeInfo节点的所有子节点
                XmlNodeList xnl0 = xe.ChildNodes;
                dictInfo.Id     = xnl0.Item(0).InnerText.ToInt32();
                dictInfo.Pid    = xnl0.Item(1).InnerText.ToInt32();
                dictInfo.Name   = xnl0.Item(2).InnerText;
                dictInfo.Remark = xnl0.Item(3).InnerText;

                dictTypeInfoList.Add(dictInfo);
            }
            #endregion

            #region 读取项目数据
            XmlNodeList xmlprejectNodeLst = xmlprojectthelper.Read("datatype");

            if (xmlprejectNodeLst.Count == 0)
            {
                return;
            }

            XmlNode xn1project = xmlprejectNodeLst[0];
            projectInfo = new ProjectInfo();

            // 将节点转换为元素,便于得到节点的属性值
            XmlElement xeproject = (XmlElement)xn1project;
            // 得到Type和ISBN两个属性的属性值
            projectInfo.Gid = xeproject.GetAttribute("gid").ToString();
            // 得到DataTypeInfo节点的所有子节点
            XmlNodeList xnl0project = xeproject.ChildNodes;
            projectInfo.Name           = xnl0project.Item(0).InnerText;
            projectInfo.Version        = xnl0project.Item(1).InnerText;
            projectInfo.Contacts       = xnl0project.Item(2).InnerText;
            projectInfo.Remark         = xnl0project.Item(3).InnerText;
            projectInfo.DbType         = xnl0project.Item(4).InnerText;
            projectInfo.DicttypeTable  = xnl0project.Item(5).InnerText;
            projectInfo.DictdataTable  = xnl0project.Item(6).InnerText;
            projectInfo.ErrTable       = xnl0project.Item(7).InnerText;
            projectInfo.LastUpdateTime = Convert.ToDateTime(xnl0project.Item(8).InnerText);
            projectInfo.OutputPath     = xnl0project.Item(9).InnerText;

            #endregion

            #region 读取Table.xml 配置信息
            XmlHelper   xmltableshelper = new XmlHelper(@"XML\tables.xml");
            XmlNodeList xmlNodeLst2     = xmltableshelper.Read("datatype/tabletype");
            guidGroup.Clear();
            tableGroup.Clear();
            foreach (XmlNode xn1 in xmlNodeLst2)
            {
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;

                // 获取字符串中的英文字母 [a-zA-Z]+
                string GroupEnglishName = CRegex.GetText(xe.GetAttribute("name").ToString(), "[a-zA-Z]+", 0);

                guidGroup.Add(xe.GetAttribute("gid").ToString(), string.Format("{0}{1}_", Const.TablePre, GroupEnglishName));
            }

            XmlNodeList xmlNodeLst3 = xmltableshelper.Read("datatype/dataitem");
            foreach (XmlNode xn1 in xmlNodeLst3)
            {
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;
                // 得到Type和ISBN两个属性的属性值

                // 得到ConstantInfo节点的所有子节点
                XmlNodeList xnl0 = xe.ChildNodes;

                tableGroup.Add(xnl0.Item(0).InnerText, guidGroup[xnl0.Item(3).InnerText]);
            }
            #endregion
        }
コード例 #27
0
ファイル: FrmGeneralSql.cs プロジェクト: 15831944/winform-1
        //第二步:定义执行线程主体事件
        //线程主体方法
        public void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            List <object> args = e.Argument as List <object>;

            #region 根据项目属性获取数据类型
            XmlHelper   xmlprojectthelper = new XmlHelper(@"XML\project.xml");
            XmlNodeList xmlprejectNodeLst = xmlprojectthelper.Read("datatype");

            if (xmlprejectNodeLst.Count == 0)
            {
                return;
            }

            XmlNode xn1project = xmlprejectNodeLst[0];

            // 将节点转换为元素,便于得到节点的属性值
            XmlElement xeproject = (XmlElement)xn1project;

            // 得到DataTypeInfo节点的所有子节点
            XmlNodeList xnl0project = xeproject.ChildNodes;

            string dbType   = xnl0project.Item(4).InnerText;
            string filePath = xnl0project.Item(9).InnerText;
            #endregion

            switch (args[0].ToString())
            {
            case "GenerTableSql":
                string[] filenames = args[1] as string[];
                Dictionary <string, string> constrainttypelst = new Dictionary <string, string>();
                constrainttypelst.Add("0", "主键");
                constrainttypelst.Add("1", "索引");
                constrainttypelst.Add("2", "唯一索引");

                //在线程中更新UI(通过ReportProgress方法)
                //...执行线程任务

                #region 先读取datatype.xml 在读取defaulttype.xml 然后Linq 查询保存到数据字典dic中
                XmlHelper           xmldatatypehelper  = new XmlHelper(@"XML\datatype.xml");
                XmlNodeList         xmldatatypeNodeLst = xmldatatypehelper.Read("datatype");
                List <DataTypeInfo> dataTypeInfoList   = new List <DataTypeInfo>();
                foreach (XmlNode xn1 in xmldatatypeNodeLst)
                {
                    DataTypeInfo dataTypeInfo = new DataTypeInfo();
                    // 将节点转换为元素,便于得到节点的属性值
                    XmlElement xe = (XmlElement)xn1;
                    // 得到Type和ISBN两个属性的属性值
                    dataTypeInfo.Gid = xe.GetAttribute("gid").ToString();

                    // 得到DataTypeInfo节点的所有子节点
                    XmlNodeList xnl0 = xe.ChildNodes;
                    dataTypeInfo.Name      = xnl0.Item(0).InnerText;
                    dataTypeInfo.StdType   = xnl0.Item(2).InnerText;
                    dataTypeInfo.Length    = xnl0.Item(3).InnerText;
                    dataTypeInfo.Precision = xnl0.Item(4).InnerText;

                    dataTypeInfoList.Add(dataTypeInfo);
                }

                XmlHelper   defaulttypexmlHelper  = new XmlHelper(@"XML\defaulttype.xml");
                XmlNodeList defaulttypexmlNodeLst = defaulttypexmlHelper.Read("datatype");
                Dictionary <string, string> dict  = new Dictionary <string, string>();
                foreach (var dataTypeInfo in dataTypeInfoList)
                {
                    foreach (XmlNode xn1 in defaulttypexmlNodeLst)
                    {
                        // 将节点转换为元素,便于得到节点的属性值
                        XmlElement xe = (XmlElement)xn1;
                        // 得到DataTypeInfo节点的所有子节点
                        XmlNodeList xnl0  = xe.ChildNodes;
                        string      value = string.Empty;
                        if (dbType == "Oracle")
                        {
                            value = xnl0.Item(2).InnerText;
                        }
                        else if (dbType == "Mysql")
                        {
                            value = xnl0.Item(3).InnerText;
                        }
                        else if (dbType == "DB2")
                        {
                            value = xnl0.Item(4).InnerText;
                        }
                        else if (dbType == "SqlServer")
                        {
                            value = xnl0.Item(5).InnerText;
                        }
                        else if (dbType == "Sqlite")
                        {
                            value = xnl0.Item(6).InnerText;
                        }
                        else if (dbType == "Access")
                        {
                            value = xnl0.Item(7).InnerText;
                        }

                        // 找到匹配记录
                        if (dataTypeInfo.StdType == xnl0.Item(0).InnerText)
                        {
                            if (value.Contains("$L"))
                            {
                                if (String.Empty == dataTypeInfo.Length)
                                {
                                    value = value.Replace("$L", "0");
                                }
                                else
                                {
                                    value = value.Replace("$L", dataTypeInfo.Length);
                                }
                            }
                            if (value.Contains("$P"))
                            {
                                if (String.Empty == dataTypeInfo.Precision)
                                {
                                    value = value.Replace("$P", "0");
                                }
                                else
                                {
                                    value = value.Replace("$P", dataTypeInfo.Precision);
                                }
                            }
                            dict.Add(dataTypeInfo.Name, value);
                        }
                    }
                }

                XmlHelper   stdfieldxmlHelper  = new XmlHelper(@"XML\stdfield.xml");
                XmlNodeList stdfieldxmlNodeLst = stdfieldxmlHelper.Read("datatype/dataitem");

                List <StdFieldComboBox> stdFieldInfoList = new List <StdFieldComboBox>();
                foreach (XmlNode xn1 in stdfieldxmlNodeLst)
                {
                    // 将节点转换为元素,便于得到节点的属性值
                    XmlElement xe = (XmlElement)xn1;
                    // 得到DataTypeInfo节点的所有子节点
                    XmlNodeList      xnl0     = xe.ChildNodes;
                    StdFieldComboBox listItem = new StdFieldComboBox();
                    listItem.Name        = xnl0.Item(0).InnerText;
                    listItem.ChineseName = xnl0.Item(1).InnerText;
                    listItem.DataType    = xnl0.Item(2).InnerText;
                    listItem.DictNo      = xnl0.Item(3).InnerText.ToInt32();
                    if (dictTypeInfoList != null)
                    {
                        var dictType = dictTypeInfoList.Find(new Predicate <DictInfo>(dictinfo => dictinfo.Id == xnl0.Item(3).InnerText.ToInt32()));
                        if (dictType != null)
                        {
                            listItem.DictNameLst = dictType.Remark;
                        }
                    }

                    stdFieldInfoList.Add(listItem);
                }
                #endregion

                if (FileUtil.IsExistFile(filePath + "\\TableInit.sql"))
                {
                    FileUtil.DeleteFile(filePath + "\\TableInit.sql");
                }

                FileUtil.CreateFile(filePath + "\\TableInit.sql");

                #region 处理每个Table脚本
                for (Int32 ii = 0; ii < filenames.Length; ii++)
                {
                    // 20190925 没有做好的不生成
                    if (filenames[ii].Contains("_TODO"))
                    {
                        Console.WriteLine(string.Format("{0} [{1})]无需处理.\r\n", LogLevel.LOG_LEVEL_INFO, filenames[ii]));
                        backgroundWorker1.ReportProgress((Int32)(progressBar.Position + 1) / progressBar.Properties.Maximum, string.Format("{0} [{1})]无需处理.\r\n", LogLevel.LOG_LEVEL_INFO, filenames[ii]));
                        continue;
                    }

                    XmlHelper xmltablesinfohelper = new XmlHelper(filenames[ii]);

                    XmlNodeList xmlbasicsLst = xmltablesinfohelper.Read(string.Format("datatype/basicinfo"));
                    XmlNodeList xmlbasicsOne = ((XmlElement)xmlbasicsLst[0]).ChildNodes;
                    string      functionStr  = xmlbasicsOne.Item(0).InnerText;
                    string      englishName  = xmlbasicsOne.Item(1).InnerText;
                    string      chineseName  = xmlbasicsOne.Item(2).InnerText;
                    Boolean     checkHis     = Convert.ToInt32(xmlbasicsOne.Item(3).InnerText) == 0 ? false : true;

                    XmlNodeList            xmlfieldsLst  = xmltablesinfohelper.Read(string.Format("datatype/fieldsinfo"));
                    List <TableFieldsInfo> FieldsInfoLst = new List <TableFieldsInfo>();
                    foreach (XmlNode xn1 in xmlfieldsLst)
                    {
                        TableFieldsInfo tablefieldInfo = new TableFieldsInfo();

                        // 将节点转换为元素,便于得到节点的属性值
                        XmlElement xe = (XmlElement)xn1;

                        tablefieldInfo.Gid = xe.GetAttribute("gid").ToString();

                        // 得到DataTypeInfo节点的所有子节点
                        XmlNodeList xnl0 = xe.ChildNodes;

                        for (Int32 i = 0; i < stdFieldInfoList.Count; i++)
                        {
                            if (string.Equals(stdFieldInfoList[i].Name, xnl0.Item(0).InnerText))
                            {
                                tablefieldInfo.FieldName   = stdFieldInfoList[i].Name;
                                tablefieldInfo.ChineseName = stdFieldInfoList[i].ChineseName;
                                tablefieldInfo.DataType    = stdFieldInfoList[i].DataType;
                                tablefieldInfo.FieldInfo   = stdFieldInfoList[i].DictNameLst;
                                break;
                            }
                        }

                        tablefieldInfo.IsNull  = (short)(xnl0.Item(1).InnerText == "0" ? 0 : 1);
                        tablefieldInfo.Remark  = xnl0.Item(2).InnerText;
                        tablefieldInfo.lstInfo = new Dictionary <string, DevExpress.XtraEditors.DXErrorProvider.ErrorInfo>();
                        FieldsInfoLst.Add(tablefieldInfo);
                    }

                    // 如果没有字段则写日志继续
                    if (FieldsInfoLst.Count == 0)
                    {
                        backgroundWorker1.ReportProgress((Int32)(progressBar.Position + 1) / progressBar.Properties.Maximum, string.Format("{0} 表[{1}({2})]不存在字段,请检查,处理完成.\r\n", LogLevel.LOG_LEVEL_ERR, chineseName, englishName));
                        continue;
                    }

                    XmlNodeList xmlindexLst = xmltablesinfohelper.Read(string.Format("datatype/indexsinfo"));

                    List <TableIndexsInfo> IndexsInfoLst = new List <TableIndexsInfo>();

                    foreach (XmlNode xn1 in xmlindexLst)
                    {
                        TableIndexsInfo tableindexsInfo = new TableIndexsInfo();

                        // 将节点转换为元素,便于得到节点的属性值
                        XmlElement xe = (XmlElement)xn1;
                        tableindexsInfo.Gid = xe.GetAttribute("gid").ToString();

                        // 得到DataTypeInfo节点的所有子节点
                        XmlNodeList xnl0 = xe.ChildNodes;
                        tableindexsInfo.IndexName      = xnl0.Item(0).InnerText;
                        tableindexsInfo.IndexFieldLst  = xnl0.Item(1).InnerText;
                        tableindexsInfo.ConstraintType = string.IsNullOrEmpty(xnl0.Item(2).InnerText) ? (short)-1 : Convert.ToInt16(xnl0.Item(2).InnerText);
                        tableindexsInfo.lstInfo        = new Dictionary <string, DevExpress.XtraEditors.DXErrorProvider.ErrorInfo>();
                        IndexsInfoLst.Add(tableindexsInfo);
                    }

                    FileUtil.AppendText(filePath + "\\TableInit.sql", JCodes.Framework.Common.Proj.SqlOperate.initTableInfo(dbType, tableGroup[englishName] + englishName, string.Format("{0}({1})", chineseName, functionStr), checkHis, FieldsInfoLst, IndexsInfoLst, dict), Encoding.UTF8);

                    Console.WriteLine(string.Format("{0} [{1}({2})]处理完成.\r\n", LogLevel.LOG_LEVEL_INFO, chineseName, englishName));
                    backgroundWorker1.ReportProgress((Int32)(progressBar.Position + 1) / progressBar.Properties.Maximum, string.Format("{0} [{1}({2})]处理完成.\r\n", LogLevel.LOG_LEVEL_INFO, chineseName, englishName));
                }
                #endregion
                break;

            case "TableDataSql":
                string[] filenames2 = args[1] as string[];

                //在线程中更新UI(通过ReportProgress方法)
                if (FileUtil.IsExistFile(filePath + "\\TableDataSql.sql"))
                {
                    FileUtil.DeleteFile(filePath + "\\TableDataSql.sql");
                }

                FileUtil.CreateFile(filePath + "\\TableDataSql.sql");

                #region 处理每个Table脚本
                for (Int32 ii = 0; ii < filenames2.Length; ii++)
                {
                    DataTable dt = new DataTable();
                    // 先读取表结构信息
                    XmlHelper xmltablefieldhelper = new XmlHelper(filenames2[ii].Replace("basicdata", "table"));

                    XmlNodeList xmlfieldsbasicLst = xmltablefieldhelper.Read(string.Format("datatype/basicinfo"));

                    XmlNodeList xnl0basic   = ((XmlElement)xmlfieldsbasicLst[0]).ChildNodes;
                    string      englishName = xnl0basic.Item(1).InnerText;
                    string      chineseName = xnl0basic.Item(2).InnerText;

                    XmlNodeList xmlfieldsLst = xmltablefieldhelper.Read(string.Format("datatype/fieldsinfo"));

                    foreach (XmlNode xn1 in xmlfieldsLst)
                    {
                        // 将节点转换为元素,便于得到节点的属性值
                        XmlElement xe = (XmlElement)xn1;
                        // 得到DataTypeInfo节点的所有子节点
                        XmlNodeList xnl0 = xe.ChildNodes;

                        dt.Columns.Add(xnl0.Item(0).InnerText);
                    }

                    // 读取数据信息
                    XmlHelper   xmltabledatahelper = new XmlHelper(filenames2[ii]);
                    XmlNodeList xmlNodeLst         = xmltabledatahelper.Read("datatype/dataitem");

                    foreach (XmlNode xn1 in xmlNodeLst)
                    {
                        DataRow dr = dt.NewRow();
                        // 将节点转换为元素,便于得到节点的属性值
                        XmlElement xe = (XmlElement)xn1;

                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            if (xe.Attributes[dt.Columns[i].ColumnName.ToLower()] != null)
                            {
                                dr[dt.Columns[i].ColumnName] = xe.GetAttribute(dt.Columns[i].ColumnName.ToLower()).ToString();
                            }
                            else
                            {
                                xe.SetAttribute(dt.Columns[i].ColumnName.ToLower(), string.Empty);
                            }
                        }
                        xmltabledatahelper.Save(false);
                        dt.Rows.Add(dr);

                        // 根据属性去反查是否存在不存在则删除
                        List <String> tmp = new List <string>();
                        foreach (XmlAttribute a in xe.Attributes)
                        {
                            if (dt.Columns[a.Name] == null && !string.Equals(a.Name, "gid"))
                            {
                                tmp.Add(a.Name);
                            }
                        }
                        foreach (var s in tmp)
                        {
                            xe.RemoveAttribute(s);
                        }
                        xmltabledatahelper.Save(false);
                    }

                    FileUtil.AppendText(filePath + "\\TableDataSql.sql", JCodes.Framework.Common.Proj.SqlOperate.initTableDataInfo(dbType, tableGroup[englishName] + englishName, chineseName, dt), Encoding.Default);

                    backgroundWorker1.ReportProgress((Int32)(progressBar.Position + 1) / progressBar.Properties.Maximum, string.Format("{0} [{1}({2})]处理完成.\r\n", LogLevel.LOG_LEVEL_INFO, chineseName, englishName));
                }
                #endregion
                break;

            case "DictionarySql":
                //在线程中更新UI(通过ReportProgress方法)
                if (FileUtil.IsExistFile(filePath + "\\Dict.sql"))
                {
                    FileUtil.DeleteFile(filePath + "\\Dict.sql");
                }

                FileUtil.CreateFile(filePath + "\\Dict.sql");

                #region 处理每个Table脚本
                XmlHelper           xmldicthelper      = new XmlHelper(@"XML\dict.xml");
                XmlNodeList         xmlNodeLst2        = xmldicthelper.Read("datatype/dataitem");
                List <DictInfo>     dictTypeInfoList2  = new List <DictInfo>();
                List <DictDataInfo> dictDetailInfoList = new List <DictDataInfo>();
                foreach (XmlNode xn1 in xmlNodeLst2)
                {
                    DictInfo dictInfo = new DictInfo();
                    // 将节点转换为元素,便于得到节点的属性值
                    XmlElement xe = (XmlElement)xn1;

                    // 得到DataTypeInfo节点的所有子节点
                    XmlNodeList xnl0 = xe.ChildNodes;
                    dictInfo.Id     = Convert.ToInt32(xnl0.Item(0).InnerText);
                    dictInfo.Pid    = Convert.ToInt32(xnl0.Item(1).InnerText);
                    dictInfo.Name   = xnl0.Item(2).InnerText;
                    dictInfo.Remark = xnl0.Item(3).InnerText;

                    if (!string.IsNullOrEmpty(xnl0.Item(4).InnerXml))
                    {
                        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();  //新建对象
                        doc.LoadXml("<tmp>" + xnl0.Item(4).InnerXml + "</tmp>");    //符合xml格式的字符串
                        var nodes = doc.DocumentElement.ChildNodes;
                        foreach (var node in nodes)
                        {
                            DictDataInfo dicdetailInfo = new DictDataInfo();
                            var          dNode         = ((XmlElement)node).ChildNodes;
                            dicdetailInfo.DicttypeValue = dNode.Item(0).InnerText.ToInt32();
                            dicdetailInfo.Name          = dNode.Item(1).InnerText;
                            dicdetailInfo.Seq           = dNode.Item(2).InnerText;
                            dicdetailInfo.Remark        = dNode.Item(3).InnerText;
                            dicdetailInfo.DicttypeId    = dictInfo.Id;

                            dictDetailInfoList.Add(dicdetailInfo);
                        }
                    }

                    dictTypeInfoList2.Add(dictInfo);
                }

                // T_Basic_DictType
                // T_Basic_DictData
                FileUtil.AppendText(filePath + "\\Dict.sql", JCodes.Framework.Common.Proj.SqlOperate.initDictTypeInfo(dbType, tableGroup["DictType"] + "DictType", "数据字典类型", dictTypeInfoList2), Encoding.Default);

                backgroundWorker1.ReportProgress((Int32)(progressBar.Position + 1) / progressBar.Properties.Maximum, string.Format("{0} [{1}({2})]处理完成.\r\n", LogLevel.LOG_LEVEL_INFO, "数据字典类型", "DictType"));

                FileUtil.AppendText(filePath + "\\Dict.sql", JCodes.Framework.Common.Proj.SqlOperate.initDictDataInfo(dbType, tableGroup["DictData"] + "DictData", "数据字典明细", dictDetailInfoList), Encoding.Default);

                backgroundWorker1.ReportProgress((Int32)(progressBar.Position + 1) / progressBar.Properties.Maximum, string.Format("{0} [{1}({2})]处理完成.\r\n", LogLevel.LOG_LEVEL_INFO, "数据字典明细", "DictData"));

                #endregion

                break;

            case "MenuSql":
                //在线程中更新UI(通过ReportProgress方法)
                if (FileUtil.IsExistFile(filePath + "\\Menu.sql"))
                {
                    FileUtil.DeleteFile(filePath + "\\Menu.sql");
                }

                FileUtil.CreateFile(filePath + "\\Menu.sql");

                #region 处理每个Table脚本
                XmlHelper       xmlmenuhelper = new XmlHelper(@"XML\menu.xml");
                XmlNodeList     xmlNodeLst3   = xmlmenuhelper.Read("datatype/dataitem");
                List <MenuInfo> menuInfolst   = new List <MenuInfo>();
                foreach (XmlNode xn1 in xmlNodeLst3)
                {
                    MenuInfo menuinfo = new MenuInfo();
                    // 将节点转换为元素,便于得到节点的属性值
                    XmlElement xe = (XmlElement)xn1;

                    // 得到DataTypeInfo节点的所有子节点
                    XmlNodeList xnl0 = xe.ChildNodes;
                    menuinfo.Gid            = xnl0.Item(0).InnerText;
                    menuinfo.Pgid           = xnl0.Item(1).InnerText;
                    menuinfo.Name           = xnl0.Item(2).InnerText;
                    menuinfo.Icon           = xnl0.Item(3).InnerText;
                    menuinfo.Seq            = xnl0.Item(4).InnerText;
                    menuinfo.AuthGid        = xnl0.Item(5).InnerText;
                    menuinfo.IsVisable      = Convert.ToInt16(xnl0.Item(6).InnerText);
                    menuinfo.WinformClass   = xnl0.Item(7).InnerText;
                    menuinfo.Url            = xnl0.Item(8).InnerText;
                    menuinfo.WebIcon        = xnl0.Item(9).InnerText;
                    menuinfo.SystemtypeId   = xnl0.Item(10).InnerText;
                    menuinfo.CreatorId      = Convert.ToInt32(xnl0.Item(11).InnerText);
                    menuinfo.CreatorTime    = Convert.ToDateTime(xnl0.Item(12).InnerText);
                    menuinfo.EditorId       = Convert.ToInt32(xnl0.Item(13).InnerText);
                    menuinfo.LastUpdateTime = Convert.ToDateTime(xnl0.Item(14).InnerText);
                    menuinfo.IsDelete       = Convert.ToInt16(xnl0.Item(15).InnerText);
                    menuInfolst.Add(menuinfo);
                }

                FileUtil.AppendText(filePath + "\\Menu.sql", JCodes.Framework.Common.Proj.SqlOperate.initMenuInfo(dbType, tableGroup["Menu"] + "Menu", "系统菜单", menuInfolst), Encoding.Default);

                backgroundWorker1.ReportProgress((Int32)(progressBar.Position + 1) / progressBar.Properties.Maximum, string.Format("{0} [{1}({2})]处理完成.\r\n", LogLevel.LOG_LEVEL_INFO, "系统菜单", "Menu"));
                #endregion
                break;

            case "FunctionSql":
                //在线程中更新UI(通过ReportProgress方法)
                if (FileUtil.IsExistFile(filePath + "\\Function.sql"))
                {
                    FileUtil.DeleteFile(filePath + "\\Function.sql");
                }

                FileUtil.CreateFile(filePath + "\\Function.sql");

                #region 处理每个Table脚本
                XmlHelper   xmlfunctionhelper = new XmlHelper(@"XML\function.xml");
                XmlNodeList xmlNodeLst4       = xmlfunctionhelper.Read("datatype/dataitem");
                List <JCodes.Framework.Entity.FunctionInfo> functionInfolst = new List <JCodes.Framework.Entity.FunctionInfo>();
                foreach (XmlNode xn1 in xmlNodeLst4)
                {
                    JCodes.Framework.Entity.FunctionInfo functioninfo = new JCodes.Framework.Entity.FunctionInfo();
                    // 将节点转换为元素,便于得到节点的属性值
                    XmlElement xe = (XmlElement)xn1;

                    // 得到DataTypeInfo节点的所有子节点
                    XmlNodeList xnl0 = xe.ChildNodes;
                    functioninfo.Gid          = xnl0.Item(0).InnerText;
                    functioninfo.Pgid         = xnl0.Item(1).InnerText;
                    functioninfo.Name         = xnl0.Item(2).InnerText;
                    functioninfo.DllPath      = xnl0.Item(3).InnerText;
                    functioninfo.SystemtypeId = xnl0.Item(4).InnerText;
                    functioninfo.Seq          = xnl0.Item(5).InnerText;
                    functionInfolst.Add(functioninfo);
                }

                FileUtil.AppendText(filePath + "\\Function.sql", JCodes.Framework.Common.Proj.SqlOperate.initFunctionInfo(dbType, tableGroup["Function"] + "Function", "系统功能", functionInfolst), Encoding.Default);

                #endregion
                break;
            }
            //...执行线程其他任务

            backgroundWorker1.ReportProgress(100, string.Format("{0} 已全部生成完毕.\r\n", LogLevel.LOG_LEVEL_INFO));
        }
コード例 #28
0
 /// <summary>
 /// 保存数据字典信息
 /// </summary>
 /// <param name="di">The di.</param>
 public void SaveDictInfo(DictInfo di)
 {
     dictRepository.Save(di);
 }