示例#1
0
        /// <summary>
        /// 缓存数据库
        /// </summary>
        /// <param name="pgs"></param>
        /// <param name="FileName"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public Boolean CacheTable(PgsBar pgs, string FileName, out string msg)
        {
            try
            {
                List <TableCompareModel> tblist  = new List <TableCompareModel>();
                TableCompareModel        tbmodel = new TableCompareModel();
                DataTable dt     = new DataTable();
                string    retmsg = "缓存失败";

                dt = idefdal.GetDBList(new List <WhereModel>());
                pgs.PgsScoroll(10, "源数据读取完成");
                if (dt != null)
                {
                    pgs.SetPgsMax(dt.Rows.Count + 20);
                    foreach (DataRow dr in dt.Rows)//表
                    {
                        string tbname = dr["SelName"].ToString();
                        tbmodel = new TableCompareModel();
                        tbmodel = idefdal.CreateTableModel(tbname);
                        tblist.Add(tbmodel);
                        //Thread.Sleep(500);
                        pgs.PgsScoroll(1, tbname + "缓存完成");
                    }
                }
                pgs.PgsScoroll(0, "生成缓存文件。。。");
                if (CreateXmlFile(tblist, CommonConfig.basecachepath + FileName, out retmsg))
                {
                    pgs.PgsScoroll(10, "数据缓存完成");
                }
                else
                {
                    pgs.PgsScoroll(10, "生成缓存文件失败");
                }

                msg = "数据缓存完成";
                return(true);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                pgs.PgsScoroll(0, ex.Message);
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 表中字段比对
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public TableCompareModel CompareColumn(TableCompareModel model)
        {
            model.Isequal = "11";
            TableCompareModel sourcemodel = isourcedal.CreateTableModel(model.Tablename);
            TableCompareModel targetmodel = itargetdal.CreateTableModel(model.Tablename);

            TableCompareModel outmodel;
            TableCompareModel inmodel;

            ColumnModel column = new ColumnModel();
            bool        flag   = false;

            for (int i = 0; i < 2; i++)
            {
                #region 列互换比较
                if (i == 0)
                {
                    outmodel = sourcemodel;
                    inmodel  = targetmodel;
                }
                else
                {
                    outmodel = targetmodel;
                    inmodel  = sourcemodel;
                }
                #endregion

                foreach (ColumnModel outcol in outmodel.Column)
                {
                    string colname = outcol.Columnname;
                    flag = false;
                    foreach (ColumnModel incol in inmodel.Column)
                    {
                        #region 列存在
                        if (colname == incol.Columnname)
                        {
                            if (i == 0)
                            {
                                string propertyequal = CompareSingleColumn(incol.Source, outcol.Source);
                                if (propertyequal != "111")//字段类型、是否为空、默认值不匹配
                                {
                                    column                 = new ColumnModel();
                                    column.Columnname      = colname;
                                    column.Isequal         = "11";
                                    column.Ispropertyequal = propertyequal;

                                    column.Source.CloneIt(outcol.Source);
                                    column.Target.CloneIt(incol.Source);

                                    model.Column.Add(column);
                                }
                            }
                            flag = true;
                            break;
                        }
                        #endregion
                    }

                    #region 列不存在
                    //列不存在,并且允许比对时
                    if (!flag && scc.ColumnAdd)
                    {
                        column                 = new ColumnModel();
                        column.Columnname      = colname;
                        column.Isequal         = i == 0 ? "10" : "01";
                        column.Ispropertyequal = "000";
                        if (i == 0)
                        {
                            column.Source.CloneIt(outcol.Source);
                            column.Target.Clear();
                        }
                        else
                        {
                            column.Source.Clear();
                            column.Target.CloneIt(outcol.Source);
                        }
                        model.Column.Add(column);
                    }
                    #endregion
                }
            }
            return(model);
        }