Exemplo n.º 1
0
 static bool IsCanCache(MDataTable dt)
 {
     if (dt == null || dt.Rows.Count > 100000)
     {
         return(false);// 大于10万条的不缓存。
     }
     foreach (MCellStruct item in dt.Columns)
     {
         if (DataType.GetGroup(item.SqlType) == 999)//只存档基础类型
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 2
0
            public static void ReadAndRemoveKey()
            {
                MAction    action    = ActionInstance;//
                string     cacheTime = DBTool.Keyword("CacheTime", action.DataBaseType);
                MDataTable dt        = action.Select(cacheTime + ">" + keyTime + " order by " + cacheTime + " asc");

                if (dt.Rows.Count > 0)
                {
                    foreach (MDataRow row in dt.Rows)
                    {
                        RemoveCache(row.Get <string>(0));                 //移除。
                    }
                    keyTime = dt.Rows[dt.Rows.Count - 1].Get <string>(1); //将时间重置为为最后一次最大的时间。
                }
            }
Exemplo n.º 3
0
 private void btnSetOrdinal_Click(object sender, EventArgs e)
 {
     //把第二位的列移前
     mdc.SetOrdinal(mdc[1].ColumnName, 0);
     if (mdc.Table != null && mdc.Table.Rows.Count > 1)
     {
         new MDataTable().Bind(dgvData);
         MDataTable dt = mdc.Table.Clone();
         dt.Bind(dgvData);
     }
     else
     {
         mdc.ToTable().Bind(dgvData);
     }
 }
Exemplo n.º 4
0
        private static MDataTable get_fenlei_mdt()
        {
            var mdt = new MDataTable();

            if (HttpContext.Current.Cache[tc_fenlei] == null)
            {
                mdt = new Model.TcFenlei().Select("order by Paixu");
                HttpContext.Current.Cache.Insert(tc_fenlei, mdt, null, DateTime.Now.AddDays(c_day), TimeSpan.Zero);
                return(mdt);
            }
            else
            {
                mdt = HttpContext.Current.Cache[tc_fenlei] as MDataTable;
            }
            return(mdt);
        }
Exemplo n.º 5
0
 private static void BindList(Win.ListControl listControl, MDataTable source)
 {
     try
     {
         if (source.Columns.Count > 0)
         {
             listControl.DataSource    = new MDataView(ref source);
             listControl.ValueMember   = source.Columns[0].ColumnName;
             listControl.DisplayMember = source.Columns[source.Columns.Count > 1 ? 1 : 0].ColumnName;
         }
     }
     catch (Exception err)
     {
         Log.WriteLogToTxt(err);
     }
 }
Exemplo n.º 6
0
 private void AddSuperAdminPromission(string menuid, string actionids)
 {
     if (!string.IsNullOrEmpty(actionids))
     {
         MDataTable dt = new MDataTable(U_AriesEnum.Sys_RoleAction.ToString());
         dt.Columns.Add("RoleID");
         dt.Columns.Add("MenuID");
         dt.Columns.Add("ActionID");
         foreach (string actionid in actionids.Split(','))
         {
             dt.NewRow(true).Set(0, UserAuth.SuperAdminRoleID)
             .Set(1, menuid).Set(2, actionid);
         }
         dt.AcceptChanges(AcceptOp.Insert, CrossDb.GetConn(U_AriesEnum.Sys_RoleAction.ToString()));
     }
 }
Exemplo n.º 7
0
        public void insert()
        {
            String     con = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.31)(PORT = 1521)))(CONNECT_DATA =(SID = fluxtms1)(SERVICE_NAME=fluxtms)));User ID=TMS_ZC;password=TMS_ZC";
            MDataTable dt  = null;

            using (MAction action = new MAction("TMP_CODE1", con))
            {
                action.BeginTransation();
                action.Set("FCODE1", 1);
                action.Set("FCODE2", 1);
                action.Set("FCODE3", 1);
                action.Insert(InsertOp.None);
                action.EndTransation();
            }
            Console.WriteLine("123");
        }
Exemplo n.º 8
0
 private void AddSuperAdminPromission(string menuID, string actionIDs)
 {
     if (!string.IsNullOrEmpty(actionIDs))
     {
         MDataTable dt = new MDataTable(TableNames.Sys_RoleAction.ToString());
         dt.Columns.Add("RoleID");
         dt.Columns.Add("MenuID");
         dt.Columns.Add("ActionID");
         foreach (string actionID in actionIDs.Split(','))
         {
             dt.NewRow(true).Set(0, UserAuth.SuperAdminRoleID)
             .Set(1, menuID).Set(2, actionID);
         }
         dt.AcceptChanges(AcceptOp.Insert);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// 获取表的列头数据(输出EasyUI的列头格式)
        /// </summary>
        public void GetHeader()
        {
            MDataTable dt = GridConfig.GetList(ObjName, GridConfig.SelectType.All);

            if (dt == null || dt.Rows.Count == 0)
            {
                dt = GridConfig.Create(ObjCode, dt.GetSchema(false));
            }
            else
            {
                //dt = GridConfig.Check(ObjCode, dt);
            }
            //顺带处理视图语句与菜单名称的绑定
            KeyValueConfig.SetTableDescription(ObjName, p.MenuName);
            jsonResult = dt.ToJson(false, false, true);
        }
Exemplo n.º 10
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            MDataTable delDt = dt.GetSchema(false);

            for (int i = 0; i < dgView.Rows.Count; i++)
            {
                if (Convert.ToString(dgView.Rows[i].Cells[0].Value) == "True")
                {
                    dgView.Rows.RemoveAt(i);
                    delDt.NewRow(true).LoadFrom(dt.Rows[i]);
                }
            }
            dgView.Refresh();
            delDt.AcceptChanges(AcceptOp.Delete);
            delDt.AcceptChanges(AcceptOp.Insert | AcceptOp.Truncate);
        }
Exemplo n.º 11
0
        override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            MDataTable dt = objectProvider.GetObject() as MDataTable;

            if (dt != null)
            {
                try
                {
                    FormCreate.BindTable(windowService, dt, null);
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }
Exemplo n.º 12
0
 protected override MDataTable Select(GridConfig.SelectType st)
 {
     switch (ObjName)
     {
     case "V_Test":    //处理Demo中文本数据库
         MDataTable dt = null;
         using (MAction action = new MAction("Demo_TestA"))
         {
             dt = action.Select();
         }
         dt.JoinOnName = "id";
         MDataTable joinDt = dt.Join("Demo_TestB", "id");
         return(joinDt.Select(PageIndex, PageSize, GetWhere() + GetOrderBy("id"), GridConfig.GetSelectColumns(ObjName, st)));
     }
     return(base.Select(st));
 }
Exemplo n.º 13
0
        void ResetMainState()
        {
            MDataTable table = null;

            using (ProjectConfig config = new ProjectConfig())
            {
                table = config.Select();//更新其它的状态。
            }
            if (table.Rows.Count > 0)
            {
                foreach (MDataRow row in table.Rows)
                {
                    row.Set("IsMain", false);
                }
                table.AcceptChanges(AcceptOp.Update);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 去除列的重复信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dt"></param>
        /// <param name="mainIndexes">主索引(如果主索引不同,则不去重)</param>
        /// <param name="indexes">要去重的索引(可以是整数、列名)</param>
        /// <returns></returns>
        public static void ClearRepeateInfo <T>(this MDataTable dt, T[] mainIndexes, params T[] indexes)
        {
            if (indexes.Length < 1)
            {
                indexes     = mainIndexes;
                mainIndexes = null;
            }

            //先初始化前一行要去重的值为null
            var preValues     = new object[indexes.Length];
            var mainIsRepeat  = mainIndexes == null;
            var preMainValues = mainIndexes == null ? null : new object[mainIndexes.Length];

            //去除重复信息
            foreach (var row in dt.Rows)
            {
                //判断主索引对应的值是否相同
                if (mainIndexes != null)
                {
                    mainIsRepeat = true;
                    var preMainIndex = 0;
                    foreach (var mainIndex in mainIndexes)
                    {
                        if (mainIsRepeat && !Equals(preMainValues[preMainIndex], row[mainIndex].Value))
                        {
                            mainIsRepeat = false;
                        }
                        preMainValues[preMainIndex] = row[mainIndex].Value;
                        preMainIndex++;
                    }
                }

                //去重
                var preIndex = 0;
                foreach (var index in indexes)
                {
                    var isRepeat = mainIsRepeat && Equals(preValues[preIndex], row[index].Value);
                    preValues[preIndex] = row[index].Value;
                    if (isRepeat)
                    {
                        row[index].Value = null;
                    }
                    preIndex++;
                }
            }
        }
Exemplo n.º 15
0
 public void Fill(MDataTable table)
 {
     if (table == null)
     {
         ErrorMsg = "查询对象为Null";
         return;
     }
     Count = table.Rows.Count;
     for (int i = 0; i < table.Rows.Count; i++)
     {
         for (int j = 0; j < table.Columns.Count; j++)
         {
             addItem(table.Columns[j].ColumnName, Convert.ToString(table.Rows[i][j].Value));
         }
         addItemOk();
     }
 }
Exemplo n.º 16
0
 private void GatherChildrenID(MDataTable dt, string parentID, StringBuilder sb, string parentName = "ParentID")
 {
     if (!string.IsNullOrEmpty(parentID))
     {
         List <MDataRow> rows = dt.FindAll(parentName + "='" + parentID + "'");
         if (rows != null)
         {
             string id = string.Empty;
             foreach (MDataRow row in rows)
             {
                 id = row.Get <string>(0);
                 sb.Append("'" + id + "',");
                 GatherChildrenID(dt, id, sb, parentName);
             }
         }
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// 保存目录列表
        /// </summary>
        /// <param name="menulist"></param>
        /// <returns></returns>
        public bool SaveNovelContents(List <NovelContent> menulist)
        {
            int maxid = GetNovelContentMaxId();

            foreach (var menu in menulist)
            {
                if (menu.Id > 0)
                {
                    continue;
                }
                menu.Id = maxid++;
            }
            var dt = MDataTable.CreateFrom(menulist);

            dt.TableName = menulist[0].TableName;
            return(dt.AcceptChanges(AcceptOp.Auto));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 接收Post过来的Json权限
        /// </summary>
        /// <returns></returns>
        private MDataTable GetTable(string roleID)
        {
            MDataTable rowAction = new MDataTable(TableNames.Sys_RoleAction.ToString());

            rowAction.Columns.Add("RoleID", SqlDbType.NVarChar);
            rowAction.Columns.Add("MenuID", SqlDbType.NVarChar);
            rowAction.Columns.Add("ActionID", SqlDbType.NVarChar);
            MDataTable dt;

            if (Query <string>("all") == "1")
            {
                if (UserAuth.IsSuperAdmin)
                {
                    dt = SysMenu.MenuTable;
                }
                else
                {
                    dt = SysMenu.GetUserMenu(true);
                }
            }
            else
            {
                dt = MDataTable.CreateFrom(Query <string>("data"));
            }
            if (dt != null && dt.Rows.Count > 0)
            {
                string menuID = string.Empty;
                foreach (MDataRow row in dt.Rows)
                {
                    menuID = row.Get <string>("MenuID");
                    if (!string.IsNullOrEmpty(menuID))
                    {
                        string[] ActionIDs = row.Get <string>("ActionIDs", "").Split(',');
                        foreach (string actionID in ActionIDs)
                        {
                            if (!string.IsNullOrEmpty(actionID))
                            {
                                rowAction.NewRow(true).Set(0, roleID).Set(1, menuID).Set(2, actionID);
                            }
                        }
                    }
                }
            }
            return(rowAction);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 数据结构行刷新
        /// </summary>
        /// <param name="objName"></param>
        /// <param name="objCode"></param>
        /// <param name="dt">原有数据</param>
        /// <returns></returns>
        public static bool Flesh(string objName, string objCode, MDataTable dt, out string msg)
        {
            bool result = false;

            msg = LangConst.NoNewColumn;
            MDataTable newDt = dt.GetSchema(false);
            //移除表结构缓存
            string tableKey = CacheManage.GetKey(CacheKeyType.Schema, objName);
            string codeKey  = CacheManage.GetKey(CacheKeyType.Schema, objCode);

            CacheManage.LocalInstance.Remove(tableKey);
            CacheManage.LocalInstance.Remove(codeKey);
            if (!string.IsNullOrEmpty(AppConfig.DB.SchemaMapPath))
            {
                IOHelper.Delete(AppConfig.RunPath + AppConfig.DB.SchemaMapPath + tableKey + ".ts");
                IOHelper.Delete(AppConfig.RunPath + AppConfig.DB.SchemaMapPath + codeKey + ".ts");
            }
            FillTable(objName, objCode, newDt);//重新获取。

            MDataTable addTable = dt.GetSchema(false);

            // bool needUpdate = false;
            foreach (MDataRow row in newDt.Rows)
            {
                MDataRow mr = dt.FindRow(string.Format("Field='{0}'", row.Get <string>("Field")));
                if (mr == null)//找不到,则添加行
                {
                    row.Set(Config_Grid.OrderNum, 255);
                    row.Set(Config_Grid.Hidden, true);
                    row.Set(Config_Grid.GridID, Guid.NewGuid());
                    addTable.Rows.Add(row);
                }
            }

            if (addTable.Rows.Count > 0)
            {
                result = addTable.AcceptChanges(AcceptOp.InsertWithID);
                if (!result)
                {
                    msg = Convert.ToString((Exception)addTable.DynamicData);
                }
            }

            return(result);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="dy"></param>
        /// <returns></returns>
        public bool Del(dynamic dy)
        {
            bool result = false;

            try
            {
                string v_table = Convert.ToString(dy.table);

                //获取主键
                string guid       = string.Empty;
                string table_guid = @"select   column_name   from   user_cons_columns   
                                      where   constraint_name   =   (select   constraint_name   from   user_constraints   
                                      where   table_name   =   '" + v_table.ToUpper() + "'  and   constraint_type   ='P')";
                using (MAction action_guid = new MAction(table_guid))
                {
                    MDataTable mdt_guid = action_guid.Select();
                    if (mdt_guid != null && mdt_guid.Rows.Count > 0)
                    {
                        guid = mdt_guid.Rows[0][0].ToString();
                    }
                }
                string ids = Convert.ToString(dy.guids);
                ids = ids.Replace(",", "','");
                using (MAction action = new MAction(v_table))
                {
                    action.BeginTransation();
                    result = action.Delete("" + guid + " in ('" + ids + "')");
                    if (result)
                    {
                        action.EndTransation();
                    }
                    else
                    {
                        action.RollBack();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteLogToTxt(ex.Message, LogType.Error);
                result = false;
                throw new Exception(ex.Message);
            }
            return(result);
        }
Exemplo n.º 21
0
 static bool IsCanSetCache(MDataTable dt)
 {
     if (dt == null || dt.Rows.Count > 1000)
     {
         return(false);// 大于1000条的不缓存,1000这个数字,性能调节上相对合适。
     }
     if (_AutoCache.CacheType != CacheType.LocalCache)
     {
         foreach (MCellStruct item in dt.Columns)
         {
             if (DataType.GetGroup(item.SqlType) == DataGroupType.Object)//只存档基础类型
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 22
0
        private static string GetInnerJson(List <MDataRow> groupList)
        {
            MDataTable group = groupList;

            if (AppConfig.DB.DefaultDalType == DalType.Txt)
            {
                group.Rows.Sort("OrderNo ASC");//文本需要再次排序(因为不支持查询的时候多重排序)
            }
            JsonHelper json = new JsonHelper(false, false);

            foreach (MDataRow row in group.Rows)
            {
                json.Add("text", row.Get <string>("ConfigName"));
                json.Add("value", row.Get <string>("ConfigValue"));
                json.AddBr();
            }
            return(json.ToString(true));
        }
Exemplo n.º 23
0
 /// <summary>
 /// 设置数据表列名
 /// </summary>
 /// <param name="dataTable"></param>
 /// <param name="shtColName"></param>
 /// <param name="colNames"></param>
 /// <param name="colCount"></param>
 private static void SetDataTableColName(MDataTable dataTable,
                                         IRow shtColName, string[] colNames, int colCount)
 {
     if (colNames == null || colNames.Length < 1 || colNames.Length < colCount)
     {
         for (int i = 0; i < colCount; i++)
         {
             dataTable.Columns[i].ColumnName = shtColName.GetCell(i).StringCellValue;
         }
     }
     else
     {
         for (int i = 0; i < colCount; i++)
         {
             dataTable.Columns[i].ColumnName = colNames[i];
         }
     }
 }
Exemplo n.º 24
0
        public override void GetData(object target, System.IO.Stream outgoingData)
        {
            MDataTable dt = null;

            if (target is MDataTable)
            {
                dt = target as MDataTable;
            }
            else if (target is NameObjectCollectionBase)
            {
                dt = MDataTable.CreateFrom(target as NameObjectCollectionBase);
            }
            else if (target is IEnumerable)
            {
                dt = MDataTable.CreateFrom(target as IEnumerable);
            }
            base.GetData(Format(dt), outgoingData);
        }
Exemplo n.º 25
0
        private static void CreateSheet(IWorkbook workbook, MDataTable dataTable, string sheetName = null)
        {
            var newShtName = sheetName ?? dataTable.TableName;

            DateFormat = workbook.GetDateFormat();
            int shtCount = (dataTable.Rows.Count + 49999) / 50000;

            for (int i = 0; i < shtCount; i++)
            {
                ISheet sht = workbook.CreateSheet(newShtName + "_" + (i + 1));

                //写数据表头
                WriteSheetTitle(dataTable, sht);

                //写数据
                WriteToSheet(sht, dataTable, i * 50000, i * 50000 + 49999);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 获取某对应项对应的数据库脚本。
        /// </summary>
        /// <param name="objName">对象名称</param>
        /// <returns></returns>
        internal static string GetGridConfigScript(string objName)
        {
            StringBuilder sb = new StringBuilder();
            MDataTable    dt = GridConfig.GetList(objName, GridConfig.SelectType.All);

            if (dt != null)
            {
                dt.Columns.RemoveAt(0);//移除主键
                sb.Append("Delete from Config_Grid where ObjName='" + objName + "'\r\nGo\r\n");
                //创建SQL脚本。
                foreach (var row in dt.Rows)
                {
                    row.TableName = "Config_Grid";
                    sb.AppendLine(GetSQLScript(row, "ObjName", "Field"));
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 27
0
        private void btnTransation_Click(object sender, EventArgs e)
        {
            //for (int i = 0; i < 100; i++)
            //{


            MDataTable dt   = null;
            string     guid = Guid.NewGuid().ToString();

            using (MAction action = new MAction("Users"))
            {
                bool result = false;
                action.SetTransLevel(IsolationLevel.ReadCommitted); //可设置的事务级别,一般可以不用设置
                action.BeginTransation();                           //设置开启事务标识
                action.Set("Name", guid.Substring(1, 5));
                action.Set("Password", "123456");
                int id = 0;
                if (action.Insert())    //第一个执行时,事务才被加载
                {
                    id = action.Get <int>(0);
                    action.ResetTable("Article");
                    action.Set("UserID", id);
                    action.Set("Title", guid.Substring(3, 5));
                    action.Set("Content", guid.Substring(5, 5));
                    action.Set("PubTime", DateTime.Now);
                    result = action.Insert(InsertOp.None);
                }
                else
                {
                    action.RollBack();    //手工回滚
                }
                action.EndTransation();   //提交事务
                if (result)
                {
                    LoadData("UserID=" + id);
                }
                OutSql(action.DebugInfo);
            }
            if (dt != null)
            {
                dt.Bind(dgvView);
            }
            //}
        }
Exemplo n.º 28
0
        /// <summary>
        /// 合并行列
        /// </summary>
        /// <param name="dtPbGrid"></param>
        /// <param name="dic"></param>
        /// <param name="export"></param>
        /// <param name="maxMerge"></param>
        public static void MergedRowAndCol(MDataTable dtPbGrid, Dictionary <MDataRow, int> dic, IWorkbook export, int maxMerge)
        {
            string     title = string.Empty;
            ICellStyle style = GetStyle(export, HSSFColor.LightOrange.Index);
            ISheet     sheet = export.GetSheet("Sheet1");
            ICell      cell;
            IRow       row;
            int        cellIndex = 0;
            int        colspan = 0, merge = 0;
            int        dex = 0;

            for (int i = 0; i < dtPbGrid.Rows.Count; i++)
            {
                title     = dtPbGrid.Rows[i]["Title"].Value.ToString();
                colspan   = Convert.ToInt32(dtPbGrid.Rows[i]["Colspan"].Value);
                merge     = Convert.ToInt32(dtPbGrid.Rows[i]["MergeIndexed"].Value);
                cellIndex = i;
                if (dic.ContainsKey(dtPbGrid.Rows[i]))
                {
                    dex = dic[dtPbGrid.Rows[i]];//取索引
                }
                if (!i.Equals(dex))
                {
                    cellIndex = dex;
                }
                int rf = 0, rl = 0, cf = 0, cl = 0;
                row        = sheet.GetRow(merge - 1);
                row.Height = 300;
                if (colspan > 1)//跨列
                {
                    rf = merge - 1; rl = merge - 1; cf = cellIndex; cl = cellIndex + colspan - 1;
                }
                else//跨行
                {
                    rf = merge - 1; rl = maxMerge - 1; cf = cellIndex; cl = cellIndex;
                }
                cell = row.GetCell(cellIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK);
                //cell.CellStyle = style;
                cell.SetCellValue(title);
                sheet.SetColumnWidth(cellIndex, 4000);
                sheet.AddMergedRegion(new CellRangeAddress(rf, rl, cf, cl));
            }
        }
Exemplo n.º 29
0
        public bool Del(dynamic dy)
        {
            bool result = false;

            try
            {
                string v_table = Convert.ToString(dy.table);

                //获取主键
                string guid       = string.Empty;
                string table_guid = string.Format(@" SELECT c.COLUMN_NAME  FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS t,INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS c where t.TABLE_NAME = c.TABLE_NAME
                                    and t.TABLE_NAME='{0}'  /*AND t.TABLE_SCHEMA = 'demodata'*/  AND t.CONSTRAINT_TYPE = 'PRIMARY KEY'", v_table.ToLower());
                using (MAction action_guid = new MAction(table_guid))
                {
                    MDataTable mdt_guid = action_guid.Select();
                    if (mdt_guid != null && mdt_guid.Rows.Count > 0)
                    {
                        guid = mdt_guid.Rows[0][0].ToString();
                    }
                }
                string ids = Convert.ToString(dy.guids);
                //ids = ids.Replace(",", "','");
                using (MAction action = new MAction(v_table))
                {
                    action.BeginTransation();
                    result = action.Delete("" + guid + " in (" + ids + ")");
                    if (result)
                    {
                        action.EndTransation();
                    }
                    else
                    {
                        action.RollBack();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteLogToTxt(ex.Message, LogType.Error);
                result = false;
            }
            return(result);
        }
Exemplo n.º 30
0
        //public void GetUserInfo()
        //{
        //    jsonResult = UserAuth.User.ToJson();
        //}
        /// <summary>
        /// 用户首页呈现的菜单数据
        /// </summary>
        public void GetUserMenu()
        {
            MDataTable dt = p.UserMenu;

            if (IsUseUISite)//格式化菜单数据。
            {
                string ui = AppConfig.GetApp("UI").Trim('/');
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    MDataRow row = dt.Rows[i];
                    string   url = row.Get <string>(Sys_Menu.MenuUrl).TrimStart('/');
                    if (url != "#" && !url.ToLower().StartsWith(ui.ToLower() + "/"))
                    {
                        row.Set(Sys_Menu.MenuUrl, "/" + ui + "/" + url);
                    }
                }
            }
            jsonResult = dt.ToJson(false, false, true);
        }
Exemplo n.º 31
0
        /// <summary>
        /// 把MDataTable中的数据写入Excel表中
        /// </summary>
        /// <param name="sht">要写入数据的Sheet</param>
        /// <param name="dataTable">MDataTable</param>
        /// <param name="startRowIndex"></param>
        /// <param name="endRowIndex"></param>
        /// <param name="startColIndex"></param>
        private static void WriteToSheet(ISheet sht, MDataTable dataTable,
                                         int startRowIndex = 0, int endRowIndex = 50000, int startColIndex = 0)
        {
            endRowIndex = endRowIndex > dataTable.Rows.Count ? dataTable.Rows.Count : endRowIndex;
            int rowIndex = 1;

            for (int i = startRowIndex; i < endRowIndex; i++)
            {
                //创建行
                IRow xlsRow = sht.CreateRow(rowIndex++);

                //创建单元格
                int colIndex = 0;
                foreach (MDataCell cell in dataTable.Rows[i])
                {
                    CreateCell(xlsRow, colIndex++, cell.Value);
                }
            }
        }
Exemplo n.º 32
0
Arquivo: Rss.cs Projeto: Angliy/Common
 public void LoadData(MDataTable table)
 {
     _MTable = table;
 }
Exemplo n.º 33
0
 private void InitClass()
 {
     this.DataSetName = "OlapMemSet";
     this.Prefix = "";
     this.Namespace = "http://tempuri.org/OlapMemSet.xsd";
     this.Locale = new System.Globalization.CultureInfo("en-US");
     this.CaseSensitive = false;
     this.EnforceConstraints = true;
     this.tableM = new MDataTable();
     this.Tables.Add(this.tableM);
 }
Exemplo n.º 34
0
 internal MRow(DataRowBuilder rb)
     : base(rb)
 {
     this.tableM = ((MDataTable)(this.Table));
 }
 internal MRow(global::System.Data.DataRowBuilder rb) : 
         base(rb) {
     this.tableM = ((MDataTable)(this.Table));
 }
 private void InitClass() {
     this.DataSetName = "OlapMemSet";
     this.Prefix = "";
     this.Namespace = "http://tempuri.org/OlapMemSet.xsd";
     this.EnforceConstraints = true;
     this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema;
     this.tableM = new MDataTable();
     base.Tables.Add(this.tableM);
 }
 internal void InitVars(bool initTable) {
     this.tableM = ((MDataTable)(base.Tables["M"]));
     if ((initTable == true)) {
         if ((this.tableM != null)) {
             this.tableM.InitVars();
         }
     }
 }
Exemplo n.º 38
0
        public MDataTable Load(string json)
        {
            MDataTable table = new MDataTable("loadFromJson");
            if (!string.IsNullOrEmpty(json) && json.Length > 30 && json.StartsWith("{") && json.IndexOf(',') > -1 && json.EndsWith("}"))
            {
                try
                {
                    int start=json.IndexOf(":[{") + 2;
                    string data = json.Substring(start, json.LastIndexOf("]}") - start);
                    data = data.Replace("\\}", "#100#").Replace("\\,", "#101#").Replace("\\:,", "#102#");
                    bool isOK=false;
                    if (!string.IsNullOrEmpty(data))
                    {
                        string[] items = data.Replace("{",string.Empty).Split('}');//分隔每一行
                        string item = string.Empty, key = string.Empty, value = string.Empty;
                        for (int i = 0; i < items.Length; i++)//循环每一行数据
                        {
                            item = items[i].Replace("#100#", "\\}").Trim(',');
                            if (string.IsNullOrEmpty(item))
                            {
                                continue;
                            }
                            string[] keyValues = item.Split(',');

                            string keyValue = string.Empty;
                            if (i == 0)
                            {
                                for (int j = 0; j < keyValues.Length; j++)
                                {
                                    keyValue = keyValues[j].Replace("#101#", "\\,");
                                    key = keyValue.Split(':')[0].Trim('\'', '\"');
                                    table.Columns.Add(key, SqlDbType.NVarChar);
                                }
                                isOK=true;

                            }
                            if (isOK)
                            {
                                MDataRow row = table.NewRow();
                                for (int k = 0; k < keyValues.Length; k++)
                                {
                                    keyValue = keyValues[k].Replace("#101#", "\\,");
                                    if (keyValue.IndexOf(':') > -1)
                                    {
                                        value = keyValue.Substring(keyValue.IndexOf(':')+1).Replace("#102#", "\\:").Trim('\'', '\"');
                                        row[k].Value = value;
                                    }
                                }
                                table.Rows.Add(row);
                            }

                        }
                    }
                }
                catch
                {
                    return table;
                }
            }
            return table;
        }
Exemplo n.º 39
0
 internal void InitVars()
 {
     this.tableM = ((MDataTable)(this.Tables["M"]));
     if ((this.tableM != null)) {
         this.tableM.InitVars();
     }
 }
Exemplo n.º 40
0
 public void LoadData(MDataTable table)
 {
     _Table = table;
     if (_Table.Rows.Count > 0)
     {
         _Row = _Table.Rows[0];
     }
 }