多数据集视图中,每个数据集保留一个DataViewInfo
Ejemplo n.º 1
0
        public CtlGfsView(DataViewInfo dataViewInfo)
        {
            InitializeComponent();
            InitTool();
            MDataViewInfo = dataViewInfo;
            DataShower.Add(lstData);
            if (!GuiConfig.IsUseDefaultLanguage)
            {
                DeleteFileToolStripMenuItem.Text = GuiConfig.GetText(TextType.MainMenuOperationFileSystemDelFile);
                DeleteFileStripButton.Text = DeleteFileToolStripMenuItem.Text;

                UploadFileToolStripMenuItem.Text = GuiConfig.GetText(TextType.MainMenuOperationFileSystemUploadFile);
                UploadFileStripButton.Text = UploadFileToolStripMenuItem.Text;

                UploadFolderToolStripMenuItem.Text =
                    GuiConfig.GetText(TextType.MainMenuOperationFileSystemUploadFolder);
                UpLoadFolderStripButton.Text = UploadFolderToolStripMenuItem.Text;

                DownloadFileToolStripMenuItem.Text = GuiConfig.GetText(TextType.MainMenuOperationFileSystemDownload);
                DownloadFileStripButton.Text = DownloadFileToolStripMenuItem.Text;

                OpenFileToolStripMenuItem.Text = GuiConfig.GetText(TextType.MainMenuOperationFileSystemOpenFile);
                OpenFileStripButton.Text = OpenFileToolStripMenuItem.Text;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     展示数据
 /// </summary>
 /// <param name="dataList"></param>
 /// <param name="controls"></param>
 /// <param name="currentDataViewInfo"></param>
 public static void FillDataToControl(List<BsonDocument> dataList, List<Control> controls,
     DataViewInfo currentDataViewInfo)
 {
     var collectionPath = currentDataViewInfo.StrDbTag.Split(":".ToCharArray())[1];
     var cp = collectionPath.Split("/".ToCharArray());
     foreach (var control in controls)
     {
         if (control.GetType() == typeof (ListView))
         {
             if (
                 !(dataList.Count == 0 &&
                   currentDataViewInfo.StrDbTag.Split(":".ToCharArray())[0] == ConstMgr.CollectionTag))
             {
                 //只有在纯数据集的时候才退出,不然的话,至少需要将字段结构在ListView中显示出来。
                 FillDataToListView(cp[(int) EnumMgr.PathLevel.Collection], (ListView) control, dataList);
             }
         }
         if (control.GetType() == typeof (TextBox))
         {
             FillJsonDataToTextBox((TextBox) control, dataList, currentDataViewInfo.SkipCnt);
         }
         if (control.GetType() == typeof (CtlTreeViewColumns))
         {
             UiHelper.FillDataToTreeView(cp[(int) EnumMgr.PathLevel.Collection], (CtlTreeViewColumns) control,
                 dataList,
                 currentDataViewInfo.SkipCnt);
         }
     }
 }
Ejemplo n.º 3
0
 public CtlUserView(DataViewInfo dataViewInfo)
 {
     InitializeComponent();
     InitToolAndMenu();
     MDataViewInfo = dataViewInfo;
     DataShower.Add(lstData);
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     ExportToFile
 /// </summary>
 /// <param name="currentDataViewInfo"></param>
 /// <param name="excelFileName"></param>
 /// <param name="exportType"></param>
 /// <param name="mongoCol"></param>
 public static void ExportToFile(DataViewInfo currentDataViewInfo,
     string excelFileName,
     EnumMgr.ExportType exportType,
     MongoCollection mongoCol)
 {
     MongoCursor<BsonDocument> cursor;
     //Query condition:
     if (currentDataViewInfo != null && currentDataViewInfo.IsUseFilter)
     {
         cursor = mongoCol.FindAs<BsonDocument>(
             QueryHelper.GetQuery(currentDataViewInfo.MDataFilter.QueryConditionList))
             .SetFields(QueryHelper.GetOutputFields(currentDataViewInfo.MDataFilter.QueryFieldList))
             .SetSortOrder(QueryHelper.GetSort(currentDataViewInfo.MDataFilter.QueryFieldList));
     }
     else
     {
         cursor = mongoCol.FindAllAs<BsonDocument>();
     }
     var dataList = cursor.ToList();
     switch (exportType)
     {
         case EnumMgr.ExportType.Excel:
             //ExportToExcel(dataList, ExcelFileName);
             GC.Collect();
             break;
         case EnumMgr.ExportType.Text:
             ExportToJson(dataList, excelFileName, MongoHelper.JsonWriterSettings);
             break;
         case EnumMgr.ExportType.Xml:
             break;
     }
     MongoHelper.OnActionDone(new ActionDoneEventArgs(" Completed "));
 }
Ejemplo n.º 5
0
 public CtlDocumentView(DataViewInfo dataViewInfo)
 {
     InitializeComponent();
     InitToolAndMenu();
     if (dataViewInfo == null) return;
     MDataViewInfo = dataViewInfo;
     DataShower.Add(lstData);
     DataShower.Add(txtData);
     DataShower.Add(trvData);
 }
Ejemplo n.º 6
0
 /// <summary>
 ///     设置DataFilter
 /// </summary>
 public void SetCurrDataFilter(DataViewInfo currentDataViewInfo)
 {
     //过滤条件
     for (var i = 0; i < _conditionCount; i++)
     {
         var ctl = (CtlQueryCondition) Controls.Find("Condition" + (i + 1), true)[0];
         if (ctl.IsSeted)
         {
             currentDataViewInfo.MDataFilter.QueryConditionList.Add(ctl.ConditionItem);
         }
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        ///     获得展示数据
        /// </summary>
        /// <param name="currentDataViewInfo"></param>
        /// <param name="mServer"></param>
        public static List <BsonDocument> GetDataList(ref DataViewInfo currentDataViewInfo, MongoServer mServer)
        {
            var             collectionPath = currentDataViewInfo.StrDbTag.Split(":".ToCharArray())[1];
            var             cp             = collectionPath.Split("/".ToCharArray());
            MongoCollection mongoCol       =
                mServer.GetDatabase(cp[(int)EnumMgr.PathLevel.Database])
                .GetCollection(cp[(int)EnumMgr.PathLevel.Collection]);


            MongoCursor <BsonDocument> cursor;

            //Query condition:
            if (currentDataViewInfo.IsUseFilter)
            {
                cursor = mongoCol.FindAs <BsonDocument>(
                    QueryHelper.GetQuery(currentDataViewInfo.MDataFilter.QueryConditionList))
                         .SetSkip(currentDataViewInfo.SkipCnt)
                         .SetFields(QueryHelper.GetOutputFields(currentDataViewInfo.MDataFilter.QueryFieldList))
                         .SetSortOrder(QueryHelper.GetSort(currentDataViewInfo.MDataFilter.QueryFieldList))
                         .SetLimit(currentDataViewInfo.LimitCnt);
            }
            else
            {
                cursor = mongoCol.FindAllAs <BsonDocument>()
                         .SetSkip(currentDataViewInfo.SkipCnt)
                         .SetLimit(currentDataViewInfo.LimitCnt);
            }
            currentDataViewInfo.Query = cursor.Query != null
                ? cursor.Query.ToJson(MongoHelper.JsonWriterSettings)
                : string.Empty;

            currentDataViewInfo.Explain = cursor.Explain().ToJson(MongoHelper.JsonWriterSettings);
            var dataList = cursor.ToList();

            if (currentDataViewInfo.SkipCnt == 0)
            {
                if (currentDataViewInfo.IsUseFilter)
                {
                    //感谢cnblogs.com 网友Shadower
                    currentDataViewInfo.CurrentCollectionTotalCnt =
                        (int)mongoCol.Count(QueryHelper.GetQuery(currentDataViewInfo.MDataFilter.QueryConditionList));
                }
                else
                {
                    currentDataViewInfo.CurrentCollectionTotalCnt = (int)mongoCol.Count();
                }
            }
            SetPageEnable(ref currentDataViewInfo);
            return(dataList);
        }
Ejemplo n.º 8
0
 /// <summary>
 ///     ExportToFile
 /// </summary>
 /// <param name="currentDataViewInfo"></param>
 /// <param name="excelFileName"></param>
 /// <param name="exportType"></param>
 /// <param name="mongoCol"></param>
 public static void ExportToFile(DataViewInfo currentDataViewInfo,
     string excelFileName,
     EnumMgr.ExportType exportType,
     MongoCollection mongoCol)
 {
     MongoCursor<BsonDocument> cursor;
     cursor = mongoCol.FindAllAs<BsonDocument>();
     var dataList = cursor.ToList();
     switch (exportType)
     {
         case EnumMgr.ExportType.Text:
             ExportToJson(dataList, excelFileName, MongoHelper.JsonWriterSettings);
             break;
         case EnumMgr.ExportType.Excel:
         case EnumMgr.ExportType.Xml:
             break;
     }
     MongoHelper.OnActionDone(new ActionDoneEventArgs(" Completed "));
 }
Ejemplo n.º 9
0
        /// <summary>
        ///     获得展示数据
        /// </summary>
        /// <param name="currentDataViewInfo"></param>
        /// <param name="mServer"></param>
        public static List<BsonDocument> GetDataList(ref DataViewInfo currentDataViewInfo, MongoServer mServer)
        {
            var PathArray = currentDataViewInfo.strCollectionPath.Split(":".ToCharArray())[1].Split("/".ToCharArray());
            MongoCollection mongoCol = mServer.GetDatabase(PathArray[(int)EnumMgr.PathLevel.Database]).GetCollection(PathArray[(int)EnumMgr.PathLevel.CollectionAndView]);
            //由于Tab页的关系,这里当前数据集并非DataViewInfo的数据集,所以不能写成下面这个样子
            //var mongoCol = RuntimeMongoDbContext.GetCurrentCollection();
            MongoCursor<BsonDocument> cursor;
            cursor = mongoCol.FindAllAs<BsonDocument>()
                .SetSkip(currentDataViewInfo.SkipCnt)
                .SetLimit(currentDataViewInfo.LimitCnt);
            currentDataViewInfo.Query = cursor.Query != null
                ? cursor.Query.ToJson(MongoHelper.JsonWriterSettings)
                : string.Empty;

            if (!currentDataViewInfo.IsView)
            {
                currentDataViewInfo.Explain = cursor.Explain().ToJson(MongoHelper.JsonWriterSettings);
            }

            var dataList = cursor.ToList();

            //https://jira.mongodb.org/browse/SERVER-26802
            //在非正常Shutdown的时候,这个统计结果可能出现错误
            //这个时候需要执行验证数据集命令
            if (currentDataViewInfo.SkipCnt == 0)
            {
                currentDataViewInfo.CurrentCollectionTotalCnt = (int)mongoCol.Count();
            }
            SetPageEnable(ref currentDataViewInfo);
            return dataList;
        }
Ejemplo n.º 10
0
 public FrmExport(DataViewInfo info)
 {
     InitializeComponent();
     _viewinfo = info;
 }
Ejemplo n.º 11
0
 /// <summary>
 ///     设置导航状态
 /// </summary>
 /// <param name="mDataViewInfo">Data View Information(Structure,Must By Ref)</param>
 public static void SetPageEnable(ref DataViewInfo mDataViewInfo)
 {
     mDataViewInfo.HasPrePage  = mDataViewInfo.SkipCnt != 0;
     mDataViewInfo.HasNextPage = mDataViewInfo.SkipCnt + mDataViewInfo.LimitCnt <
                                 mDataViewInfo.CurrentCollectionTotalCnt;
 }
Ejemplo n.º 12
0
        /// <summary>
        ///     Create a DataView Tab
        /// </summary>
        private void ViewDataRecord()
        {
            //由于Collection 和 Document 都可以触发这个事件,所以,先把Tag以前的标题头去掉
            //Collectiong:XXXX 和 Document:XXXX 都统一成 XXXX
            var dataKey = RuntimeMongoDbContext.SelectTagData;
            if (MultiTabManger.IsExist(dataKey))
            {
                MultiTabManger.SelectTab(dataKey);
                return;
            }

            var mDataViewInfo = new DataViewInfo
            {
                strCollectionPath = RuntimeMongoDbContext.SelectObjectTag,
                IsReadOnly = RuntimeMongoDbContext.CurrentMongoConnectionconfig.IsReadOnly,
            };

            CtlDataView dataViewctl;
            switch (RuntimeMongoDbContext.SelectTagType)
            {
                case ConstMgr.GridFileSystemTag:
                    dataViewctl = new CtlGfsView(mDataViewInfo);
                    dataViewctl.AllowDrop = true;
                    break;
                case ConstMgr.UserListTag:
                    dataViewctl = new CtlUserView(mDataViewInfo);
                    break;
                case ConstMgr.ViewTag:
                    mDataViewInfo.IsView = true;
                    dataViewctl = new CtlDocumentView(mDataViewInfo);
                    break;
                default:
                    dataViewctl = new CtlDocumentView(mDataViewInfo);
                    break;
            }

            dataViewctl.mDataViewInfo = mDataViewInfo;
            dataViewctl.SelectObjectTag = RuntimeMongoDbContext.SelectObjectTag;
            dataViewctl.ParentMenu = CollectionToolStripMenuItem;
            var TabTitle = UiHelper.GetShowName(RuntimeMongoDbContext.GetCurrentDataBaseName(),RuntimeMongoDbContext.GetCurrentCollectionName());
            MultiTabManger.AddView(dataViewctl, TabTitle, RuntimeMongoDbContext.SelectTagType);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     Create a DataView Tab
        /// </summary>
        private void ViewDataRecord()
        {
            //由于Collection 和 Document 都可以触发这个事件,所以,先把Tag以前的标题头去掉
            //Collectiong:XXXX 和 Document:XXXX 都统一成 XXXX
            var dataKey = RuntimeMongoDbContext.SelectTagData;
            if (MultiTabManger.IsExist(dataKey))
            {
                MultiTabManger.SelectTab(dataKey);
                return;
            }

            var mDataViewInfo = new DataViewInfo
            {
                StrDbTag = RuntimeMongoDbContext.SelectObjectTag,
                IsUseFilter = false,
                IsReadOnly = RuntimeMongoDbContext.CurrentMongoConnectionconfig.IsReadOnly,
                MDataFilter = new DataFilter()
            };

            CtlDataView dataViewctl;
            switch (RuntimeMongoDbContext.SelectTagType)
            {
                case ConstMgr.GridFileSystemTag:
                    dataViewctl = new CtlGfsView(mDataViewInfo);
                    break;
                case ConstMgr.UserListTag:
                    dataViewctl = new CtlUserView(mDataViewInfo);
                    break;
                default:
                    dataViewctl = new CtlDocumentView(mDataViewInfo);
                    break;
            }

            dataViewctl.MDataViewInfo = mDataViewInfo;
            dataViewctl.SelectObjectTag = RuntimeMongoDbContext.SelectObjectTag;
            dataViewctl.ParentMenu = CollectionToolStripMenuItem;
            MultiTabManger.AddView(dataViewctl, RuntimeMongoDbContext.GetCurrentCollectionName());
        }
Ejemplo n.º 14
0
 /// <summary>
 ///     初始化
 /// </summary>
 /// <param name="mDataViewInfo">Filter也是DataViewInfo的一个属性,所以这里加上参数</param>
 public FrmQuery(DataViewInfo mDataViewInfo)
 {
     InitializeComponent();
     _currentDataViewInfo = mDataViewInfo;
     RuntimeMongoDbContext.SelectObjectTag = mDataViewInfo.StrDbTag;
 }
Ejemplo n.º 15
0
 /// <summary>
 ///     换页操作
 /// </summary>
 /// <param name="pageChangeMode"></param>
 /// <param name="mDataViewInfo"></param>
 /// <param name="dataShower"></param>
 public static void PageChanged(PageChangeOpr pageChangeMode, ref DataViewInfo mDataViewInfo,
     List<Control> dataShower)
 {
     switch (pageChangeMode)
     {
         case PageChangeOpr.FirstPage:
             mDataViewInfo.SkipCnt = 0;
             break;
         case PageChangeOpr.LastPage:
             if (mDataViewInfo.CurrentCollectionTotalCnt%mDataViewInfo.LimitCnt == 0)
             {
                 //没有余数的时候,600 % 100 == 0  => Skip = 600-100 = 500
                 mDataViewInfo.SkipCnt = mDataViewInfo.CurrentCollectionTotalCnt - mDataViewInfo.LimitCnt;
             }
             else
             {
                 // 630 % 100 == 30  => Skip = 630-30 = 600  
                 mDataViewInfo.SkipCnt = mDataViewInfo.CurrentCollectionTotalCnt -
                                         mDataViewInfo.CurrentCollectionTotalCnt%mDataViewInfo.LimitCnt;
             }
             break;
         case PageChangeOpr.NextPage:
             mDataViewInfo.SkipCnt += mDataViewInfo.LimitCnt;
             if (mDataViewInfo.SkipCnt >= mDataViewInfo.CurrentCollectionTotalCnt)
             {
                 mDataViewInfo.SkipCnt = mDataViewInfo.CurrentCollectionTotalCnt - 1;
             }
             break;
         case PageChangeOpr.PrePage:
             mDataViewInfo.SkipCnt -= mDataViewInfo.LimitCnt;
             if (mDataViewInfo.SkipCnt < 0)
             {
                 mDataViewInfo.SkipCnt = 0;
             }
             break;
         default:
             break;
     }
     var datalist = DataViewInfo.GetDataList(ref mDataViewInfo, RuntimeMongoDbContext.GetCurrentServer());
     FillDataToControl(datalist, dataShower, mDataViewInfo);
 }
Ejemplo n.º 16
0
 /// <summary>
 ///     设置导航状态
 /// </summary>
 /// <param name="mDataViewInfo">Data View Information(Structure,Must By Ref)</param>
 public static void SetPageEnable(ref DataViewInfo mDataViewInfo)
 {
     mDataViewInfo.HasPrePage = mDataViewInfo.SkipCnt != 0;
     mDataViewInfo.HasNextPage = mDataViewInfo.SkipCnt + mDataViewInfo.LimitCnt <
                                 mDataViewInfo.CurrentCollectionTotalCnt;
 }
Ejemplo n.º 17
0
 /// <summary>
 ///     初始化
 /// </summary>
 /// <param name="dataViewInfo"></param>
 public CtlDataView(DataViewInfo dataViewInfo)
 {
     InitializeComponent();
     MDataViewInfo = dataViewInfo;
 }
Ejemplo n.º 18
0
        /// <summary>
        ///     获得展示数据
        /// </summary>
        /// <param name="currentDataViewInfo"></param>
        /// <param name="mServer"></param>
        public static List<BsonDocument> GetDataList(ref DataViewInfo currentDataViewInfo, MongoServer mServer)
        {
            var collectionPath = currentDataViewInfo.StrDbTag.Split(":".ToCharArray())[1];
            var cp = collectionPath.Split("/".ToCharArray());
            MongoCollection mongoCol =
                mServer.GetDatabase(cp[(int) EnumMgr.PathLevel.Database])
                    .GetCollection(cp[(int) EnumMgr.PathLevel.Collection]);

            MongoCursor<BsonDocument> cursor;
            //Query condition:
            if (currentDataViewInfo.IsUseFilter)
            {
                cursor = mongoCol.FindAs<BsonDocument>(
                    QueryHelper.GetQuery(currentDataViewInfo.MDataFilter.QueryConditionList))
                    .SetSkip(currentDataViewInfo.SkipCnt)
                    .SetFields(QueryHelper.GetOutputFields(currentDataViewInfo.MDataFilter.QueryFieldList))
                    .SetSortOrder(QueryHelper.GetSort(currentDataViewInfo.MDataFilter.QueryFieldList))
                    .SetLimit(currentDataViewInfo.LimitCnt);
            }
            else
            {
                cursor = mongoCol.FindAllAs<BsonDocument>()
                    .SetSkip(currentDataViewInfo.SkipCnt)
                    .SetLimit(currentDataViewInfo.LimitCnt);
            }
            currentDataViewInfo.Query = cursor.Query != null
                ? cursor.Query.ToJson(MongoHelper.JsonWriterSettings)
                : string.Empty;
            currentDataViewInfo.Explain = cursor.Explain().ToJson(MongoHelper.JsonWriterSettings);
            var dataList = cursor.ToList();
            if (currentDataViewInfo.SkipCnt == 0)
            {
                if (currentDataViewInfo.IsUseFilter)
                {
                    //感谢cnblogs.com 网友Shadower
                    currentDataViewInfo.CurrentCollectionTotalCnt =
                        (int) mongoCol.Count(QueryHelper.GetQuery(currentDataViewInfo.MDataFilter.QueryConditionList));
                }
                else
                {
                    currentDataViewInfo.CurrentCollectionTotalCnt = (int) mongoCol.Count();
                }
            }
            SetPageEnable(ref currentDataViewInfo);
            return dataList;
        }