Exemple #1
0
        /// <summary>
        /// 获取AccessToken
        /// </summary>
        /// <param name="corpid"></param>
        /// <param name="corpsecret"></param>
        /// <returns></returns>
        private string GetAccessToken(string corpid, string corpsecret)
        {
            string Gurl  = string.Format("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={0}&corpsecret={1}", corpid, corpsecret);
            string html  = HttpHelper.HttpGet(Gurl, "");
            string regex = "\"access_token\":\"(?<token>.*?)\"";

            string token = CRegex.GetText(html, regex, "token");

            return(token);
        }
Exemple #2
0
        /// <summary>
        /// 获取jsapi_ticket
        /// </summary>
        /// <param name="corpid"></param>
        /// <param name="corpsecret"></param>
        /// <returns></returns>
        public string GetJsapi_ticket(string accesstoken)
        {
            string Gurl  = string.Format("https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token={0}", accesstoken);
            string html  = HttpHelper.HttpGet(Gurl, "");
            string regex = "\"ticket\":\"(?<token>.*?)\"";

            string token = CRegex.GetText(html, regex, "token");

            return(token);
        }
        /// <summary>
        /// 初始化加载图标资源
        /// </summary>
        /// <returns></returns>
        private DXImageGalleryLoader LoadData()
        {
            this.ImageCollection = new Dictionary <string, GalleryItem>();
            this.Categories      = new List <string>();
            this.Collection      = new List <string>();
            this.Size            = new List <string>();

            using (System.Resources.ResourceReader reader = GetResourceReader(DevExpress.Utils.DxImageAssemblyUtil.ImageAssembly))
            {
                System.Collections.IDictionaryEnumerator dict = reader.GetEnumerator();
                while (dict.MoveNext())
                {
                    string key = (string)dict.Key as string;
                    if (!DevExpress.Utils.DxImageAssemblyUtil.ImageProvider.IsBrowsable(key))
                    {
                        continue;
                    }
                    if (key.EndsWith(".png", StringComparison.Ordinal))
                    {
                        string reg            = @"(?<collection>\S*?)/(?<category>\S*?)/(?<name>\S*)";
                        var    collectionItem = CRegex.GetText(key, reg, "collection");
                        var    categoryItem   = CRegex.GetText(key, reg, "category");
                        string sizeReg        = @"_(?<size>\S*)\.";
                        var    sizeItem       = CRegex.GetText(key, sizeReg, "size");

                        if (!this.Collection.Contains(collectionItem))
                        {
                            this.Collection.Add(collectionItem);
                        }
                        if (!this.Categories.Contains(categoryItem))
                        {
                            this.Categories.Add(categoryItem);
                        }
                        if (!this.Size.Contains(sizeItem))
                        {
                            this.Size.Add(sizeItem);
                        }

                        Image image = GetImageFromStream((System.IO.Stream)dict.Value);
                        if (image != null)
                        {
                            var item = new DevExpress.XtraBars.Ribbon.GalleryItem(image, key, key);
                            if (!ImageCollection.ContainsKey(key))
                            {
                                ImageCollection.Add(key, item);
                            }
                        }
                    }
                }
            }
            return(this);
        }
        /// <summary>
        /// 根据条件获取集合
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, GalleryItemCollection> Search(List <string> collection, List <string> categories, List <string> size, string fileName = "")
        {
            Dictionary <string, GalleryItemCollection> dict = new Dictionary <string, GalleryItemCollection>();

            GalleryItemCollection list = new GalleryItemCollection();

            foreach (var key in ImageCollection.Keys)
            {
                //使用正则表达式获取图标文件名中的集合、类别、大小等信息
                string reg            = @"(?<collection>\S*?)/(?<category>\S*?)/(?<name>\S*)";
                var    collectionItem = CRegex.GetText(key, reg, "collection");
                var    categoryItem   = CRegex.GetText(key, reg, "category");
                string sizeReg        = @"_(?<size>\S*)\.";
                var    sizeItem       = CRegex.GetText(key, sizeReg, "size");

                //如果是查询处理,把记录放到查询结果里面
                if (!string.IsNullOrEmpty(fileName))
                {
                    if (key.Contains(fileName))
                    {
                        list.Add(ImageCollection[key]);
                    }
                    dict["查询结果"] = list;
                }
                else
                {
                    //如果是集合和列表中包含的,把它们按类别添加到字典里面
                    if (collection.Contains(collectionItem) &&
                        categories.Contains(categoryItem) &&
                        size.Contains(sizeItem))
                    {
                        if (!dict.ContainsKey(categoryItem))
                        {
                            GalleryItemCollection cateList = new GalleryItemCollection();
                            cateList.Add(ImageCollection[key]);
                            dict[categoryItem] = cateList;
                        }
                        else
                        {
                            GalleryItemCollection cateList = dict[categoryItem];
                            cateList.Add(ImageCollection[key]);
                        }
                    }
                }
            }
            return(dict);
        }
        /// <summary>
        /// 获取邮件地址和显示信息到一个字典列表中
        /// </summary>
        /// <param name="emailValues">含邮件地址和说明的字符串(多个用;分开)</param>
        /// <param name="dictList">规范的邮件地址列表</param>
        private void GetEmailList(string emailValues, ref Dictionary <string, string> dictList)
        {
            if (!string.IsNullOrEmpty(emailValues))
            {
                string emailReg = @"([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})";
                foreach (string item in emailValues.Split(new char[] { ';', ',' }))
                {
                    string email = CRegex.GetText(item, emailReg, 0);
                    if (!string.IsNullOrEmpty(email))
                    {
                        string display = item.Replace(email, "").Replace("(", "").Replace(")", "").Replace("<", "").Replace(">", "");
                        display = !string.IsNullOrEmpty(display) ? display : email;

                        if (!dictList.ContainsKey(email))
                        {
                            dictList.Add(email, display);
                        }
                    }
                }
            }
        }
Exemple #6
0
        private string getAttachValue(string attach, string value)
        {
            string regex = "(?:^|\\?|&)" + value.ToLower() + "=(?<value>[\\s\\S]+?)(?:&|$)";

            return(CRegex.GetText(attach.ToLower(), regex, "value"));
        }
Exemple #7
0
        /// <summary>
        /// 点击表信息得到的结果
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Item_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            var item = sender as NavBarItem;

            // 判断是否已经存在了如果存在了则改为选中
            for (System.Int32 i = 0; i < tabbedView.Documents.Count; i++)
            {
                // 找到 选中
                if (string.Equals(tabbedView.Documents[i].Tag, item.Hint))
                {
                    tabbedView.Controller.Activate(tabbedView.Documents[i]);
                    dockPanel6.HideSliding();
                    return;
                }
            }
            tabbedView.BeginUpdate();
            control = new UserControl();

            control.Name = item.Name;
            control.Text = item.Hint;

            List <object> args = new List <object>();

            #region 读取Table.xml 配置信息
            XmlHelper   xmltableshelper = new XmlHelper(@"XML\tables.xml");
            XmlNodeList xmlNodeLst      = xmltableshelper.Read("datatype/tabletype");
            guidGroup.Clear();
            tableGroup.Clear();
            foreach (XmlNode xn1 in xmlNodeLst)
            {
                // 将节点转换为元素,便于得到节点的属性值
                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 xmlNodeLst2 = xmltableshelper.Read("datatype/dataitem");
            foreach (XmlNode xn1 in xmlNodeLst2)
            {
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;
                // 得到Type和ISBN两个属性的属性值

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

                tableGroup.Add(xnl0.Item(0).InnerText, guidGroup[xnl0.Item(3).InnerText]);
            }
            #endregion

            #region 根据Name 去动态生成控件
            switch (control.Name)
            {
            case "GenerTableSql":
                #region 加载.table数据信息
                string[] filenames = Directory.GetFiles("./XML/", "*.table", SearchOption.TopDirectoryOnly);
                #endregion

                Panel p1 = new Panel();
                p1.Dock   = DockStyle.Top;
                p1.Height = 30;
                Panel p2 = new Panel();
                p2.Dock     = DockStyle.Right;
                p2.Width    = 10;
                progressBar = new ProgressBarControl();
                //设置一个最小值
                progressBar.Properties.Minimum = 0;
                //设置一个最大值
                progressBar.Properties.Maximum = filenames.Length;
                //设置步长,即每次增加的数
                progressBar.Properties.Step = 1;
                //设置进度条的样式
                progressBar.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
                progressBar.Dock = DockStyle.Fill;
                progressBar.Properties.ShowTitle = true;

                SimpleButton btn = new SimpleButton();
                btn.Dock   = DockStyle.Right;
                btn.Name   = "btnde";
                btn.Size   = new System.Drawing.Size(90, 25);
                btn.Text   = "执行";
                btn.Click += (sender1, e1) => {
                    progressBar.Position = 0;
                    args.Clear();
                    args.Add(control.Name);
                    args.Add(filenames);
                    this.backgroundWorker1.RunWorkerAsync(args);
                };

                p1.Controls.Add(progressBar);
                p1.Controls.Add(p2);
                p1.Controls.Add(btn);
                control.Controls.Add(p1);
                break;

            case "TableDataSql":
                #region 加载.basicdata数据信息
                string[] filenames2 = Directory.GetFiles("./XML/", "*.basicdata", SearchOption.TopDirectoryOnly);
                #endregion

                Panel p3 = new Panel();
                p3.Dock   = DockStyle.Top;
                p3.Height = 30;
                Panel p4 = new Panel();
                p4.Dock     = DockStyle.Right;
                p4.Width    = 10;
                progressBar = new ProgressBarControl();
                //设置一个最小值
                progressBar.Properties.Minimum = 0;
                //设置一个最大值
                progressBar.Properties.Maximum = filenames2.Length;
                //设置步长,即每次增加的数
                progressBar.Properties.Step = 1;
                //设置进度条的样式
                progressBar.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
                progressBar.Dock = DockStyle.Fill;
                progressBar.Properties.ShowTitle = true;

                SimpleButton btn2 = new SimpleButton();
                btn2.Dock   = DockStyle.Right;
                btn2.Name   = "btnde";
                btn2.Size   = new System.Drawing.Size(90, 25);
                btn2.Text   = "执行";
                btn2.Click += (sender1, e1) =>
                {
                    progressBar.Position = 0;
                    args.Clear();
                    args.Add(control.Name);
                    args.Add(filenames2);
                    this.backgroundWorker1.RunWorkerAsync(args);
                };

                p3.Controls.Add(progressBar);
                p3.Controls.Add(p4);
                p3.Controls.Add(btn2);
                control.Controls.Add(p3);
                break;

            case "DictionarySql":
                Panel p5 = new Panel();
                p5.Dock   = DockStyle.Top;
                p5.Height = 30;
                Panel p6 = new Panel();
                p6.Dock     = DockStyle.Right;
                p6.Width    = 10;
                progressBar = new ProgressBarControl();
                //设置一个最小值
                progressBar.Properties.Minimum = 0;
                //设置一个最大值
                progressBar.Properties.Maximum = 2;
                //设置步长,即每次增加的数
                progressBar.Properties.Step = 1;
                //设置进度条的样式
                progressBar.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
                progressBar.Dock = DockStyle.Fill;
                progressBar.Properties.ShowTitle = true;

                SimpleButton btn3 = new SimpleButton();
                btn3.Dock   = DockStyle.Right;
                btn3.Name   = "btnde";
                btn3.Size   = new System.Drawing.Size(90, 25);
                btn3.Text   = "执行";
                btn3.Click += (sender1, e1) =>
                {
                    progressBar.Position = 0;
                    args.Clear();
                    args.Add(control.Name);
                    this.backgroundWorker1.RunWorkerAsync(args);
                };

                p5.Controls.Add(progressBar);
                p5.Controls.Add(p6);
                p5.Controls.Add(btn3);
                control.Controls.Add(p5);
                break;

            case "MenuSql":
                Panel p7 = new Panel();
                p7.Dock   = DockStyle.Top;
                p7.Height = 30;
                Panel p8 = new Panel();
                p8.Dock     = DockStyle.Right;
                p8.Width    = 10;
                progressBar = new ProgressBarControl();
                //设置一个最小值
                progressBar.Properties.Minimum = 0;
                //设置一个最大值
                progressBar.Properties.Maximum = 1;
                //设置步长,即每次增加的数
                progressBar.Properties.Step = 1;
                //设置进度条的样式
                progressBar.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
                progressBar.Dock = DockStyle.Fill;
                progressBar.Properties.ShowTitle = true;

                SimpleButton btn4 = new SimpleButton();
                btn4.Dock   = DockStyle.Right;
                btn4.Name   = "btnde";
                btn4.Size   = new System.Drawing.Size(90, 25);
                btn4.Text   = "执行";
                btn4.Click += (sender1, e1) =>
                {
                    progressBar.Position = 0;
                    args.Clear();
                    args.Add(control.Name);
                    this.backgroundWorker1.RunWorkerAsync(args);
                };

                p7.Controls.Add(progressBar);
                p7.Controls.Add(p8);
                p7.Controls.Add(btn4);
                control.Controls.Add(p7);
                break;

            case "FunctionSql":
                break;
            }


            #endregion

            BaseDocument document = tabbedView.AddDocument(control);
            document.Footer = Directory.GetCurrentDirectory();
            document.Tag    = item.Hint;

            tabbedView.EndUpdate();
            tabbedView.Controller.Activate(document);

            dockPanel6.HideSliding();
        }
Exemple #8
0
        private void btnModField_Click(object sender, EventArgs e)
        {
            StdFieldInfo aftermodstdFieldInfo = new StdFieldInfo();

            aftermodstdFieldInfo.Gid         = _beforemodstdFieldInfo.Gid;
            aftermodstdFieldInfo.Name        = txtName.Text.Trim();
            aftermodstdFieldInfo.ChineseName = txtChineseName.Text.Trim();
            aftermodstdFieldInfo.DataType    = lueFieldType.EditValue.ToString();

            StringBuilder content = new StringBuilder();

            #region 检查一下字段是否存在
            foreach (StdFieldInfo dataTypeInfo in _lstDataTypeInfo)
            {
                if (string.IsNullOrEmpty(dataTypeInfo.Gid))
                {
                    continue;
                }

                // 与别的字段重名,不允许修改
                if (string.Equals(aftermodstdFieldInfo.Name, dataTypeInfo.Name) && !string.Equals(_beforemodstdFieldInfo.Name, dataTypeInfo.Name))
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_ERR, "该标准字段已存在,不允许修改", typeof(FrmModField));
                    MessageDxUtil.ShowWarning("该标准字段已存在,不允许修改");
                    return;
                }
            }
            #endregion

            #region 取project.xml 判断当前数据库
            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;
            #endregion

            #region 生成SQL文件
            if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name) || !string.Equals(_beforemodstdFieldInfo.DataType, aftermodstdFieldInfo.DataType))
            {
                // SQLServer 修改字段   exec sp_rename '表名.列名','新列名' -- 注意,单引号不可省略。
                // SQLServer 修改字段类型 alter table 表名 alter column 字段名 type not null
                // MySql 修改字段 ALTER TABLE  表名 CHANGE  旧字段名 新字段名 字段类型
                // MySql 修改字段类型 ALTER TABLE  表名 CHANGE  字段名 字段名 新字段类型
                string saveFile = FileDialogHelper.SaveText("更新字段.sql", "C:\\myares\\");
                if (!string.IsNullOrEmpty(saveFile))
                {
                    String[] sqltablefileNames = DirectoryUtil.GetFileNames(@"XML\", "*.table", true);
                    foreach (string tablefileName in sqltablefileNames)
                    {
                        LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("开始变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField));
                        XmlHelper xmltablehelper = new XmlHelper(tablefileName);
                        try
                        {
                            XmlNodeList xmlNodeLst = xmltablehelper.Read("datatype/fieldsinfo");
                            for (Int32 i = 0; i < xmlNodeLst.Count; i++)
                            {
                                // 字段变更
                                if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name) && !string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name))
                                {
                                    #region 读取Table.xml 配置信息

                                    XmlHelper   xmltableshelper            = new XmlHelper(@"XML\tables.xml");
                                    XmlNodeList xmlNodeLst22               = xmltableshelper.Read("datatype/tabletype");
                                    Dictionary <string, string> guidGroup  = new Dictionary <string, string>();
                                    Dictionary <string, string> tableGroup = new Dictionary <string, string>();
                                    guidGroup.Clear();
                                    tableGroup.Clear();
                                    foreach (XmlNode xn1 in xmlNodeLst22)
                                    {
                                        // 将节点转换为元素,便于得到节点的属性值
                                        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 xmlNodeLst2 = xmltableshelper.Read("datatype/dataitem");
                                    foreach (XmlNode xn1 in xmlNodeLst2)
                                    {
                                        // 将节点转换为元素,便于得到节点的属性值
                                        XmlElement xe = (XmlElement)xn1;
                                        // 得到Type和ISBN两个属性的属性值

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

                                        tableGroup.Add(xnl0.Item(0).InnerText, guidGroup[xnl0.Item(3).InnerText]);
                                    }
                                    #endregion

                                    string tableName = xmltablehelper.Read("datatype/basicinfo/item/name").Item(0).InnerText;
                                    content.Append(string.Format("exec sp_rename '{0}.{1}','{2}';\r\nGO\r\n\r\n", tableGroup[tableName] + tableName, _beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name));
                                }

                                if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name) && !string.Equals(_beforemodstdFieldInfo.DataType, aftermodstdFieldInfo.DataType))
                                {
                                    #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);
                                            }
                                        }
                                    }
                                    #endregion

                                    #region 读取Table.xml 配置信息

                                    XmlHelper   xmltableshelper            = new XmlHelper(@"XML\tables.xml");
                                    XmlNodeList xmlNodeLst22               = xmltableshelper.Read("datatype/tabletype");
                                    Dictionary <string, string> guidGroup  = new Dictionary <string, string>();
                                    Dictionary <string, string> tableGroup = new Dictionary <string, string>();
                                    guidGroup.Clear();
                                    tableGroup.Clear();
                                    foreach (XmlNode xn1 in xmlNodeLst22)
                                    {
                                        // 将节点转换为元素,便于得到节点的属性值
                                        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 xmlNodeLst2 = xmltableshelper.Read("datatype/dataitem");
                                    foreach (XmlNode xn1 in xmlNodeLst2)
                                    {
                                        // 将节点转换为元素,便于得到节点的属性值
                                        XmlElement xe = (XmlElement)xn1;
                                        // 得到Type和ISBN两个属性的属性值

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

                                        tableGroup.Add(xnl0.Item(0).InnerText, guidGroup[xnl0.Item(3).InnerText]);
                                    }
                                    #endregion

                                    string tableName = xmltablehelper.Read("datatype/basicinfo/item/name").Item(0).InnerText;
                                    content.Append(string.Format("alter table {0} alter column {1} {2};\r\nGO\r\n\r\n", tableGroup[tableName] + tableName, aftermodstdFieldInfo.Name, dict[aftermodstdFieldInfo.DataType]));
                                }
                            }
                            xmltablehelper.Save(false);
                        }
                        catch (Exception ex)
                        {
                            LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField));
                            MessageDxUtil.ShowError(ex.Message);
                        }
                        LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("结束变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField));
                    }

                    FileUtil.WriteText(saveFile, content.ToString(), Encoding.UTF8);

                    if (MessageDxUtil.ShowYesNoAndTips("保存成功,是否打开文件?") == System.Windows.Forms.DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start(saveFile);
                    }
                }
            }
            #endregion

            #region 修改*.table 字段
            String[] tablefileNames = DirectoryUtil.GetFileNames(@"XML\", "*.table", true);
            foreach (string tablefileName in tablefileNames)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("开始变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField));
                XmlHelper xmltablehelper = new XmlHelper(tablefileName);
                try
                {
                    #region 更新数据
                    if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name))
                    {
                        XmlNodeList xmlNodeLst = xmltablehelper.Read("datatype/fieldsinfo");
                        for (Int32 i = 0; i < xmlNodeLst.Count; i++)
                        {
                            if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name))
                            {
                                xmlNodeLst[i].ChildNodes.Item(0).InnerText = aftermodstdFieldInfo.Name;
                            }
                        }
                    }
                    xmltablehelper.Save(false);
                    #endregion
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField));
                    MessageDxUtil.ShowError(ex.Message);
                }
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("结束变更{0}文件中变更前字段为{1}", tablefileName, _beforemodstdFieldInfo.Name), typeof(FrmModField));
            }
            #endregion

            #region 修改*.entity 字段
            String[] entityfileNames = DirectoryUtil.GetFileNames(@"XML\", "*.entity", true);
            foreach (string entityfileName in entityfileNames)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("开始变更{0}文件中变更前字段为{1}", entityfileName, _beforemodstdFieldInfo.Name), typeof(FrmModField));
                XmlHelper xmlentityhelper = new XmlHelper(entityfileName);
                try
                {
                    #region 更新数据
                    if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name))
                    {
                        XmlNodeList xmlNodeLst = xmlentityhelper.Read("datatype/fieldsinfo");
                        for (Int32 i = 0; i < xmlNodeLst.Count; i++)
                        {
                            if (string.Equals(xmlNodeLst[i].ChildNodes.Item(0).InnerText, _beforemodstdFieldInfo.Name))
                            {
                                xmlNodeLst[i].ChildNodes.Item(0).InnerText = aftermodstdFieldInfo.Name;
                            }
                        }
                    }
                    xmlentityhelper.Save(false);
                    #endregion
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField));
                    MessageDxUtil.ShowError(ex.Message);
                }
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_DEBUG, string.Format("结束变更{0}文件中变更前字段为{1}", entityfileName, _beforemodstdFieldInfo.Name), typeof(FrmModField));
            }
            #endregion

            #region 修改stdfield.xml文件
            XmlHelper xmlstdfieldhelper = new XmlHelper(@"XML\stdfield.xml");
            try
            {
                #region 更新数据
                if (!string.Equals(_beforemodstdFieldInfo.Name, aftermodstdFieldInfo.Name))
                {
                    xmlstdfieldhelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/name", aftermodstdFieldInfo.Gid), aftermodstdFieldInfo.Name);
                }
                if (!string.Equals(_beforemodstdFieldInfo.ChineseName, aftermodstdFieldInfo.ChineseName))
                {
                    xmlstdfieldhelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/chineseName", aftermodstdFieldInfo.Gid), aftermodstdFieldInfo.ChineseName);
                }
                if (!string.Equals(_beforemodstdFieldInfo.DataType, aftermodstdFieldInfo.DataType))
                {
                    xmlstdfieldhelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/datatype", aftermodstdFieldInfo.Gid), aftermodstdFieldInfo.DataType);
                }
                xmlstdfieldhelper.Save(false);
                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmModField));
                MessageDxUtil.ShowError(ex.Message);
            }
            #endregion



            this.Close();
        }
Exemple #9
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
        }