Пример #1
0
        private async Task SearchAsync()
        {
            // var task = Task.Run(Search).GetAwaiter().GetResult();
            // Task.Run(() => Search("files_id", "ObjectId(\"534a811bf8b4aa4d33fdf94d\")"));
            // Task.Run(() => Search("_id", "ObjectId(\"534a811bf8b4aa4d33fdf94d\")"));
            // Task.Run(() => Search("filename", "CHORUS~1.2~EF1"));
            // Task.Run(() => Search("md5", "d41d8cd98f00b204e9800998ecf8427e"));

            // Task.Run(() => SearchAsync(cbFieldName.Text, tbTextToSearch.Text));
            EdiHelper             h      = new EdiHelper(MongoServer, MongoDatabase);
            List <GridFSFileInfo> result = await h.SearchAsync(cbFieldName.Text, cbSearchType.Text, tbTextToSearch.Text, 100);

            Helper.SetSafeDatasource(dgKeyValue, result);
        }
Пример #2
0
        private async Task InitGridAsync(string fieldName, string cbSearchType, string tbTextToSearch)
        {
            EdiHelper h = new EdiHelper(MongoServer, MongoDatabase);

            List <GridFSFileInfo> result = await h.SearchAsync(fieldName, cbSearchType, tbTextToSearch, LastItems);

            foreach (var item in result)
            {
                string filename = string.Empty;
                try
                {
                    filename = item.Metadata != null ? item.Metadata["fileName"]?.AsString : "";
                }
                catch (Exception)
                {
                    // nothing to do
                }
                PromptHelper.ShowPromptInfo($"{item.Filename} {filename } \t {item.ContentType} \t {item.Length} \t {item.UploadDateTime}");
            }
        }