示例#1
0
        /// <summary>
        ///     全文检索功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //检索文法: http://docs.mongodb.org/manual/reference/command/text/#text-search-languages
            //检索关键字
            BsonDocument TextSearchOption = new BsonDocument().Add(new BsonElement("search", txtKey.Text));

            //语言
            if (cmbLanguage.SelectedIndex != 0)
            {
                TextSearchOption.Add(new BsonElement("language", cmbLanguage.Text));
            }
            //返回数限制
            TextSearchOption.Add(new BsonElement("limit", (BsonValue)NUDLimit.Value));
            try
            {
                CommandResult SearchResult = CommandHelper.ExecuteMongoColCommand("text",
                                                                                  SystemManager.GetCurrentCollection(), TextSearchOption);
                Result = SearchResult.Response;
                MongoDbHelper.FillDataToTreeView("Text Search Result", trvResult, Result);
                cmdSave.Enabled = true;
            }
            catch (Exception ex)
            {
                SystemManager.ExceptionDeal(ex);
            }
        }
        /// <summary>
        ///     插入文档
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdOK_Click(object sender, EventArgs e)
        {
            BsonDocument newBsonDocument;

            if (txtDocument.Text != string.Empty)
            {
                try
                {
                    newBsonDocument = BsonDocument.Parse(txtDocument.Text);
                    mBsonDocument   = newBsonDocument;
                    Close();
                }
                catch (Exception ex)
                {
                    SystemManager.ExceptionDeal(ex, "Error", "Format Error");
                }
            }
            else
            {
                try
                {
                    MongoDbHelper.InsertEmptyDocument(SystemManager.GetCurrentCollection(), true);
                    Close();
                }
                catch (Exception ex)
                {
                    SystemManager.ExceptionDeal(ex, "Error", "InsertEmptyDocument Error");
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRoleToDB_Click(object sender, EventArgs e)
        {
            Role r = new Role();

            r.rolename = "tester" + System.DateTime.Now.ToString("yyyyMMddHHmmss");
            r.database = "admin";
            r.roles    = new Role.GrantRole[1];
            r.roles[0] = new Role.GrantRole()
            {
                db = "admin", mRole = "read"
            };
            r.privileges    = new Role.privilege[1];
            r.privileges[0] = new Role.privilege()
            {
                actions = new Common.Security.Action.ActionType[1] {
                    Common.Security.Action.ActionType.DatabaseManagementActions_createCollection
                },
                resource = new Resource()
                {
                    CollectionName = "", DataBaseName = "admin", Type = Resource.ResourceType.DataBase
                }
            };
            var doc = Role.AddRole(SystemManager.GetCurrentServer().GetDatabase("admin"), r);

            if (doc.IsBsonDocument)
            {
                MongoDbHelper.FillDataToTreeView("myClusterwideAdmin", treeViewColumns1, doc.AsBsonDocument);
            }
        }
示例#4
0
 /// <summary>
 /// 删除学校所有学生导入结束也可以删
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public HttpResponseMessage DelSchStudent1([FromBody] DelStuOrTch m)
 {
     lock (_locker)
     {
         var exam = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);//找到这次考试
         if (exam == null)
         {
             return(ResultHelper.Failed("未找到该次考试"));
         }
         var sts  = MongoDbHelper.QueryBy <St_Info>(DbName.St_Info, w => w.sid == m.UserID && w.eid == exam._id); //找到这个学校学生
         var ppnm = MongoDbHelper.QueryOne <Pp_Nm>(DbName.Pp_Nm, w => w.sid == m.UserID && w.eid == exam._id);    //找到这个学校试卷数量
         if (ppnm != null)
         {
             MongoDbHelper.DeleteOne <Pp_Nm>(ppnm._id.ToString(), DbName.Pp_Nm);
         }
         foreach (var st in sts)
         {
             for (int i = 0; i < st.subEs.Count; i++)
             {
                 var sb = exam.sbs.Where(w => w._id == st.subEs[i].sbid).FirstOrDefault();
                 sb.stct--;
             }
             MongoDbHelper.DeleteOne <St_Info>(st._id.ToString(), DbName.St_Info);
         }
         var filter = new BsonDocument();
         filter.Add("sid", m.UserID);
         filter.Add("eid", exam._id);
         MongoDbHelper.DeleteByBson <St_Info>(filter, DbName.St_Info);
         MongoDbHelper.ReplaceOne(m.ExamID, exam, DbName.E_Info);
         return(ResultHelper.OK());
     }
 }
示例#5
0
        /// <summary>
        ///     Refresh Data
        /// </summary>
        public void RefreshGUI()
        {
            clear();
            mDataViewInfo.SkipCnt         = 0;
            SystemManager.SelectObjectTag = mDataViewInfo.strDBTag;
            List <BsonDocument> datalist = MongoDbHelper.GetDataList(ref mDataViewInfo);

            MongoDbHelper.FillDataToControl(datalist, _dataShower, mDataViewInfo);
            InitControlsEnable();
            SetDataNav();
            if (mDataViewInfo.Query != String.Empty)
            {
                txtQuery.Text = mDataViewInfo.Query;
                if (!tabDataShower.TabPages.Contains(tabQuery))
                {
                    tabDataShower.TabPages.Add(tabQuery);
                }
            }
            else
            {
                if (tabDataShower.TabPages.Contains(tabQuery))
                {
                    tabDataShower.TabPages.Remove(tabQuery);
                }
            }
            IsNeedRefresh = false;
        }
示例#6
0
        public ImageBucketRepositoryTests()
        {
            var mongoDatabase = MongoDbHelper.GetRscueCenterUnitTestDatabase();

            _imageBucketRepository = new ImageBucketRepository(mongoDatabase);
            _dataStore             = new MongoTestDataStore(mongoDatabase);
        }
        /// <summary>
        /// 删除测试
        /// </summary>
        static void DeleteTest()
        {
            var queryBuilder = new QueryBuilder <Student>();
            var query        = queryBuilder.GTE(x => x.Age, 28);

            MongoDbHelper.DeleteByCondition(DbConfigParams.ConnectionString, DbConfigParams.DbName, CollectionNames.Student, query);
        }
示例#8
0
        /// <summary>
        ///     Drop
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dropJavascriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String Result = MongoDbHelper.DelJavascript(trvsrvlst.SelectedNode.Text);

            if (String.IsNullOrEmpty(Result))
            {
                String strNodeData = SystemManager.SelectTagData;
                if (_viewTabList.ContainsKey(strNodeData))
                {
                    TabPage DataTab = _viewTabList[strNodeData];
                    foreach (ToolStripMenuItem item in JavaScriptStripMenuItem.DropDownItems)
                    {
                        if (item.Tag != DataTab.Tag)
                        {
                            continue;
                        }
                        JavaScriptStripMenuItem.DropDownItems.Remove(item);
                        break;
                    }
                    tabView.Controls.Remove(DataTab);
                    _viewTabList.Remove(strNodeData);
                }
                trvsrvlst.SelectedNode.Parent.Nodes.Remove(trvsrvlst.SelectedNode);
                DisableAllOpr();
            }
            else
            {
                MyMessageBox.ShowMessage("Delete Error", "A error is happened when delete javascript", Result, true);
            }
        }
示例#9
0
        /// <summary>
        /// Add A Custom User
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRole_Click(object sender, EventArgs e)
        {
            Role r = new Role();

            if (SystemManager.GetCurrentDataBase() != null)
            {
                r.database = SystemManager.GetCurrentDataBase().Name;
            }
            else
            {
                r.database = MongoDbHelper.DATABASE_NAME_ADMIN;
            }
            r.rolename   = txtRolename.Text;
            r.privileges = new Role.privilege[PrivilegeList.Count];
            for (int i = 0; i < PrivilegeList.Count; i++)
            {
                r.privileges[i] = PrivilegeList[i];
            }
            r.roles = new Role.GrantRole[RoleList.Count];
            for (int i = 0; i < RoleList.Count; i++)
            {
                r.roles[i] = RoleList[i];
            }
            var result = Role.AddRole(SystemManager.GetCurrentDataBase(), r);

            if (result.IsBsonDocument)
            {
                MyMessageBox.ShowMessage("Error", "Add Role Error", MongoDbHelper.ConvertToString(result));
            }
            else
            {
                MyMessageBox.ShowEasyMessage("Succeed", "Add Role OK");
            }
        }
示例#10
0
        public HttpResponseMessage Login([FromBody] UserLogin m)
        {
            var info = MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == m.Account);

            if (info != null)
            {
                if (m.Password == CommonHelper.SecurityHelper.DecryptString(info.pwd))
                {
                    Models.User su = new Models.User()
                    {
                        ID             = info._id,
                        Email          = info.em,
                        PersonName     = info.pnm,
                        QQ             = info.qq,
                        SchoolFullName = info.sfnm,
                        SchoolName     = info.snm,
                        Tel            = info.ph,
                        AreaID         = info.area,
                        Area           = info.tp == 0 ? null : Dict.Area.GetVal(info.area),
                        Type           = info.tp,
                        SchoolID       = info.tp != 1 ? null : info._id
                    };
                    return(ResultHelper.OK(su));
                }
                else
                {
                    return(ResultHelper.Failed("密码不正确"));
                }
            }
            else
            {
                return(ResultHelper.Failed("用户不存在"));
            }
        }
示例#11
0
        public async Task <IEnumerable <Account> > GetAccountsByBookIdAsync(string bookId)
        {
            var filterBuilder = Builders <Account> .Filter;
            var filter        = filterBuilder.Eq(x => x.BookId, bookId);

            return(await MongoDbHelper.GetWithFilter(collectionName, filter).ConfigureAwait(false));
        }
示例#12
0
 public HttpResponseMessage TransUser()
 {
     using (kingsundbNewEntities db = new kingsundbNewEntities())
     {
         var           sUer = db.tb_J_School.Where(w => 1 == 1).ToList();
         List <U_Info> ls   = new List <U_Info>();
         foreach (var item in sUer)
         {
             U_Info sc = new U_Info();
             sc._id  = item.SchoolID;
             sc.em   = item.Email;
             sc.ph   = item.Tel;
             sc.pnm  = item.PersonName;
             sc.pwd  = item.Pwd;
             sc.qq   = item.QQ;
             sc.sfnm = item.SchoolFullName;
             sc.snm  = item.SchoolName;
             sc.tp   = 1;
             sc.area = 1;
             ls.Add(sc);
         }
         MongoDbHelper.Insert(ls, DbName.U_Info);
     }
     return(ResultHelper.OK());
 }
示例#13
0
        public HttpResponseMessage ExportArea()
        {
            var           sts  = MongoDbHelper.QueryBy <U_Info>(DbName.U_Info, w => w.tp == 2);
            List <string> data = ExcelBLL.GetAreaColumn();
            DataTable     dt   = new DataTable();

            for (int j = 0; j < data.Count; j++)
            {
                dt.Columns.Add(data[j]);
            }
            for (int i = 0; i < sts.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = sts[i]._id;
                dr[1] = Dict.Area.GetVal(sts[i].area);
                dr[2] = sts[i].pnm;
                dr[3] = sts[i].ph;
                dr[4] = sts[i].em;
                dr[5] = sts[i].qq;
                dt.Rows.Add(dr);
            }
            string file = ExcelBLL.BuildExcel1(data.ToArray(), dt);
            string url  = RequestContext.Url.Request.RequestUri.Authority + "\\" + file;

            return(ResultHelper.OK(url));
        }
示例#14
0
        public HttpResponseMessage GetArea([FromBody] GetJKYMsg m)
        {
            var filter = new BsonDocument();

            filter.Add("tp", 2);

            int Count = MongoDbHelper.GetCount <U_Info>(DbName.U_Info, filter);

            if (Count == 0)
            {
                return(ResultHelper.OK(""));
            }
            var         schs = MongoDbHelper.GetPagedList2 <U_Info, string>(DbName.U_Info, m.Skip, m.Limit, filter, w => w._id);
            List <User> lu   = new List <Models.User>();

            for (int i = 0; i < schs.Count; i++)
            {
                Models.User su = new Models.User()
                {
                    ID         = schs[i]._id,
                    Email      = schs[i].em,
                    PersonName = schs[i].pnm,
                    QQ         = schs[i].qq,
                    SchoolName = schs[i].snm,
                    Tel        = schs[i].ph,
                    AreaID     = schs[i].area,
                    Area       = Dict.Area.GetVal(schs[i].area)
                };
                lu.Add(su);
            }
            return(ResultHelper.OK(new { Data = lu, Count = Count }));
        }
示例#15
0
        public HttpResponseMessage SendScore([FromBody] SendScore m)
        {
            var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);

            if (eInfo == null)
            {
                return(ResultHelper.Failed("未查到当前考试"));
            }
            if (m.School.ToLower() == "all")
            {
                var allsch = MongoDbHelper.QueryBy <Sch_Sc>(DbName.Sch_Sc, w => w.eid == eInfo._id);
                for (int i = 0; i < allsch.Count; i++)
                {
                    allsch[i].state = 1;
                    MongoDbHelper.ReplaceOne(allsch[i]._id.ToString(), allsch[i], DbName.Sch_Sc);
                }
                return(ResultHelper.OK());
            }
            var sch = MongoDbHelper.QueryOne <Sch_Sc>(DbName.Sch_Sc, w => w.eid == eInfo._id && w.sid == m.School);

            if (sch != null)
            {
                sch.state = 1;
                MongoDbHelper.ReplaceOne(sch._id.ToString(), sch, DbName.Sch_Sc);
                return(ResultHelper.OK());
            }
            return(ResultHelper.Failed("未找到该学校"));
        }
示例#16
0
 /// <summary>
 ///     Paste Element
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PasteElementToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (trvData.DatatreeView.SelectedNode.FullPath.EndsWith(MongoDbHelper.Array_Mark))
     {
         MongoDbHelper.PasteValue(trvData.DatatreeView.SelectedNode.FullPath);
         var NewValue = new TreeNode(MongoDbHelper.ConvertToString((BsonValue)MongoDbHelper._ClipElement));
         NewValue.Tag = MongoDbHelper._ClipElement;
         trvData.DatatreeView.SelectedNode.Nodes.Add(NewValue);
     }
     else
     {
         String PasteMessage = MongoDbHelper.PasteElement(trvData.DatatreeView.SelectedNode.FullPath);
         if (String.IsNullOrEmpty(PasteMessage))
         {
             //GetCurrentDocument()的第一个元素是ID
             MongoDbHelper.AddBsonDocToTreeNode(trvData.DatatreeView.SelectedNode,
                                                new BsonDocument().Add((BsonElement)MongoDbHelper._ClipElement));
         }
         else
         {
             MyMessageBox.ShowMessage("Exception", PasteMessage);
         }
     }
     IsNeedRefresh = true;
 }
示例#17
0
        /// <summary>
        ///     增加分片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdAddSharding_Click(object sender, EventArgs e)
        {
            var lstAddress = new List <String>();

            foreach (String item in lstHost.Items)
            {
                lstAddress.Add(item.Trim());
            }
            var           Resultlst = new List <CommandResult>();
            CommandResult Result;

            if (chkAdvance.Checked)
            {
                Result = CommandHelper.AddSharding(_prmSvr, txtReplsetName.Text, lstAddress, txtName.Text,
                                                   NumMaxSize.Value);
            }
            else
            {
                Result = CommandHelper.AddSharding(_prmSvr, txtReplsetName.Text, lstAddress, String.Empty, 0);
            }
            Resultlst.Add(Result);
            MyMessageBox.ShowMessage("Add Sharding", "Result:" + (Result.Ok ? "OK" : "Fail"),
                                     MongoDbHelper.ConvertCommandResultlstToString(Resultlst));
            lstSharding.Items.Clear();
            foreach (var lst in MongoDbHelper.GetShardInfo(_prmSvr, "_id"))
            {
                lstSharding.Items.Add(lst.Value);
            }
            lstHost.Items.Clear();
        }
示例#18
0
        public HttpResponseMessage CreateMsg([FromBody] CreateMsg m)
        {
            var users = MongoDbHelper.QueryBy <U_Info>(DbName.U_Info, w => w.tp == 1);

            Msg_J j = new Msg_J();

            j._id  = ObjectId.GenerateNewId();
            j.tt   = m.Title;
            j.pp   = m.PublishID;
            j.pt   = m.Time;
            j.ct   = m.Content;
            j.urls = m.Urls;
            MongoDbHelper.Insert(j, DbName.Msg_J);
            List <Msg_S> ls = new List <Msg_S>();

            for (int i = 0; i < users.Count; i++)
            {
                Msg_S s = new Msg_S();
                s.sid = users[i]._id;
                s.pid = j._id;
                s.ir  = 0;
                s.pt  = j.pt;
                ls.Add(s);
            }
            MongoDbHelper.Insert(ls, DbName.Msg_S);
            return(ResultHelper.OK());
        }
示例#19
0
        public HttpResponseMessage SelStudentNum([FromBody] ExamAndID m)
        {
            var      eInfo    = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);
            ObjectId objectId = new ObjectId();

            if (ObjectId.TryParse(m.ExamID, out objectId))
            {
                var data = MongoDbHelper.QueryOne <Pp_Nm>(DbName.Pp_Nm, w => w.sid == m.ID && w.eid == objectId);
                if (data == null)
                {
                    return(ResultHelper.OK(new { Data = new List <PaperNum>(), Count = 0 }));
                }
                PaperNum t = new PaperNum();
                t.IsSure = data.iss;
                for (int j = 0; j < eInfo.sbs.Count; j++)
                {
                    SubNum sub = new SubNum();
                    var    s   = data.sbnms.Where(w => w.sbid == eInfo.sbs[j]._id).FirstOrDefault();
                    sub.SubID    = s.sbid.ToString();
                    sub.SubName  = s.sbnm;
                    sub.SubCount = s.sct;
                    sub.AcCount  = s.ac;
                    t.Subs.Add(sub);
                }
                return(ResultHelper.OK(t));
            }
            return(ResultHelper.Failed("未找到该次考试"));
        }
示例#20
0
        public HttpResponseMessage GetSchMsgs([FromBody] GetSchMsg m)
        {
            var filter = new BsonDocument();

            filter.Add("sid", m.SchoolID);
            int Count = MongoDbHelper.GetCount <Msg_S>(DbName.Msg_S, filter);

            if (Count == 0)
            {
                return(ResultHelper.OK(new List <string>()));
            }
            var ms = MongoDbHelper.GetPagedList2 <Msg_S, string>(DbName.Msg_S, m.Skip, m.Limit, filter, w => w.pt);//分页查找所有消息
            List <CreateMsg> lm = new List <CreateMsg>();

            for (int i = 0; i < ms.Count; i++)
            {
                var       jm = MongoDbHelper.FindOne <Msg_J>(ms[i].pid.ToString(), DbName.Msg_J);   //父消息
                var       u  = MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == jm.pp); //发布者信息
                CreateMsg mg = new CreateMsg();
                mg.ID          = ms[i]._id.ToString();
                mg.Title       = jm.tt;
                mg.PublishName = u.pnm;
                mg.Time        = ms[i].pt;
                mg.IsRead      = ms[i].ir;
                mg.Content     = jm.ct;
                mg.Urls        = jm.urls;
                lm.Add(mg);
            }
            return(ResultHelper.OK(new { Data = lm, Count = Count }));
        }
示例#21
0
 public HttpResponseMessage DelStudent([FromBody] DelStuOrTch m)
 {
     lock (_locker)
     {
         var exam = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);//找到这次考试
         if (exam == null)
         {
             return(ResultHelper.Failed("未找到该次考试"));
         }
         St_Info st = MongoDbHelper.FindOne <St_Info>(m.UserID, DbName.St_Info);//找到这个学生
         if (st == null)
         {
             return(ResultHelper.Failed("未找到该考生信息"));
         }
         var ppnm = MongoDbHelper.QueryOne <Pp_Nm>(DbName.Pp_Nm, w => w.sid == st.sid && w.eid == exam._id);//找到这个学校试卷数量
         ppnm.ct--;
         for (int i = 0; i < st.subEs.Count; i++)
         {
             var sb = exam.sbs.Where(w => w._id == st.subEs[i].sbid).FirstOrDefault();
             var pp = ppnm.sbnms.Where(w => w.sbid == st.subEs[i].sbid).FirstOrDefault();
             sb.stct--;
             pp.sct--;
         }
         MongoDbHelper.ReplaceOne(ppnm._id.ToString(), ppnm, DbName.Pp_Nm);
         MongoDbHelper.ReplaceOne(m.ExamID, exam, DbName.E_Info);
         MongoDbHelper.DeleteOne <St_Info>(m.UserID, DbName.St_Info);
         return(ResultHelper.OK());
     }
 }
示例#22
0
        /// <summary>
        ///     刷新状态,不包含当前操作状态
        /// </summary>
        /// <param name="IsAuto">是否自动刷新</param>
        public void RefreshStatus(Boolean IsAuto)
        {
            try
            {
                if (!IsAuto)
                {
                    MongoDbHelper.FillSrvStatusToList(trvSvrStatus);
                }
                MongoDbHelper.FillDataBaseStatusToList(lstDBStatus);
                MongoDbHelper.FillCollectionStatusToList(lstCollectionStatus);
            }
            catch (Exception ex)
            {
                refreshTimer.Stop();
                ShortTimer.Stop();
                btnSwitch.Text = !SystemManager.IsUseDefaultLanguage
                    ? SystemManager.MStringResource.GetText(StringResource.TextType.Collection_Resume_AutoRefresh)
                    : "Resume Auto Refresh";
                btnSwitch.Image            = ResourceLib.Properties.Resources.Run;
                btnSwitch.Enabled          = false;
                RefreshStripButton.Enabled = false;

                SystemManager.ExceptionDeal(ex, "Refresh Status");
            }
        }
        public IActionResult EventInfoManage()
        {
            var appList = MongoDbHelper.SearchAppInfoList("");

            ViewBag.AppInfoList = appList;
            return(View());
        }
        public IActionResult PolicyInfoSave(PolicyInfoModel model, string policy_id)
        {
            if (string.IsNullOrWhiteSpace(model.app_id))
            {
                return(Content("app_id Empty"));
            }
            if (string.IsNullOrWhiteSpace(model.event_code))
            {
                return(Content("event_code Empty"));
            }
            if (string.IsNullOrWhiteSpace(model.policy_code))
            {
                return(Content("policy_code Empty"));
            }
            var list = MongoDbHelper.SearchPolicyInfoList(model.app_id, model.event_code, model.policy_code);

            if (list.Any())
            {
                MongoDbHelper.DeletePolicyInfo(model);
            }
            if (model.field.Count > 0)
            {
                model.field = model.field[0].Split(',').ToList();
            }
            var res = MongoDbHelper.InsertPolicyInfo(model);


            return(Content(res ? "OK" : "ERROR"));
        }
示例#25
0
        public async Task <ActionResult> Index()
        {
            MongoDbHelper mongo    = new MongoDbHelper();
            Random        rand     = new Random(10);
            int           rand_num = rand.Next(0, 1000);

            //List< MyApp> user = new List<MyApp>()
            // {
            //    new MyApp (){
            //        Id = Guid.NewGuid(),
            //        Name = rand_num.ToString() ,
            //        Age = 12,
            //        Time = DateTime.UtcNow
            //    }
            // };
            // var result = await mongo.Insert(user[0]);
            //var result = mongo.GetList<MyApp>(1, 10, p => p.Time > DateTime.Parse("2019-4-13 15:00:00") && p.Time < DateTime.Parse("2019-4-13 15:27:00"), p => p.Time, "asc");
            //string json_data = JsonConvert.SerializeObject(result);
            //JsonConvert.PopulateObject(json_data, user);
            //user.ForEach(item =>
            //{
            //    item.Time =item.Time.ToString();
            //});
            //var result= mongo.QueryOne<MyApp>();
            //mongo.Delete<MyApp>(result);
            return(View()); // Json(result,JsonRequestBehavior.AllowGet);
        }
        public IActionResult PolicyInfoEdit(string appid = "", string eventcode = "", string policycode = "")
        {
            if (string.IsNullOrWhiteSpace(appid))
            {
                return(Content("app_id Empty"));
            }
            if (string.IsNullOrWhiteSpace(eventcode))
            {
                return(Content("eventcode Empty"));
            }
            PolicyInfoModel model = new PolicyInfoModel();

            if (!string.IsNullOrWhiteSpace(appid) && !string.IsNullOrWhiteSpace(eventcode) && !string.IsNullOrWhiteSpace(policycode))
            {
                var list = MongoDbHelper.SearchPolicyInfoList(appid, eventcode, policycode);
                if (list.Count > 0)
                {
                    model = list.First();
                }
            }
            model.app_id     = appid;
            model.event_code = eventcode;

            return(View(model));
        }
示例#27
0
        public ProviderWorkerRepositoryTests()
        {
            var mongoDatabase = MongoDbHelper.GetRscueCenterUnitTestDatabase();

            _providerWorkerRepository = new ProviderWorkerRepository(mongoDatabase);
            _dataStore = new MongoTestDataStore(mongoDatabase);
        }
        public override int SaveChanges()
        {
            var entities     = ChangeTracker.Entries();
            var mongoDb      = MongoDbHelper.GetDatabase(DbHelper.DbHelper.MongoDBConnectionString);
            var modifiedList = ChangeTrackerHelper.GetChangModifield(entities);
            var addedList    = ChangeTrackerHelper.GetAdded(entities);
            var deletedList  = ChangeTrackerHelper.GetDeleted(entities);
            var result       = base.SaveChanges();

            if (result > 0)
            {
                if (addedList != null)
                {
                    ChangeTrackerHelper.InsertToMongoDb(addedList, EntityState.Added);
                }
                if (modifiedList != null)
                {
                    ChangeTrackerHelper.InsertToMongoDb(modifiedList, EntityState.Modified);
                }
                if (deletedList != null)
                {
                    ChangeTrackerHelper.InsertToMongoDb(deletedList, EntityState.Deleted);
                }
            }
            return(result);
        }
示例#29
0
        public async Task NothingToDeleteTest()
        {
            MongodbConfig            mongodbConfig    = MongoDbHelper.GetMongodbConfig();
            IMongoDatabase           database         = MongodbProvider.GetDatabase(mongodbConfig);
            IDeleteRepository <Test> deleteRepository = new MongodbDeleteRepository <Test>(database);

            await deleteRepository.DeleteAllByConditionsAsync(x => x.ObjectId == "non-existent-object");
        }
示例#30
0
        public async Task NullExpressionOnDeleteTest()
        {
            MongodbConfig            mongodbConfig    = MongoDbHelper.GetMongodbConfig();
            IMongoDatabase           database         = MongodbProvider.GetDatabase(mongodbConfig);
            IDeleteRepository <Test> deleteRepository = new MongodbDeleteRepository <Test>(database);

            await Assert.ThrowsAsync <ArgumentNullException>(() => deleteRepository.DeleteAllByConditionsAsync(null));
        }