public List<Log> GetPage(string predicate, int page, int page_size, string order, string asc, string runclass, string username, out int total) { using ( MongoDBUtility db = new MongoDBUtility() ) { var quer = db.GetIMongoCollection<Log>().Linq(); if (runclass!=null&&runclass.Length>0) { quer = quer.Where(p => p.RunClassName == runclass); } if ( username != null && username.Length > 0 ) { quer = quer.Where(p => p.UserName == username); } quer = quer.OrderSort(order, asc).ThenOrderSort(order, asc); total = quer.Count(); return quer.Skip(( page - 1 ) * page_size).Take(page_size).ToList(); } }
public List <Log> GetPage(string predicate, int page, int page_size, string order, string asc, string runclass, string username, out int total) { using (MongoDBUtility db = new MongoDBUtility()) { var quer = db.GetIMongoCollection <Log>().Linq(); if (runclass != null && runclass.Length > 0) { quer = quer.Where(p => p.RunClassName == runclass); } if (username != null && username.Length > 0) { quer = quer.Where(p => p.UserName == username); } quer = quer.OrderSort(order, asc).ThenOrderSort(order, asc); total = quer.Count(); return(quer.Skip((page - 1) * page_size).Take(page_size).ToList()); } }
/// <summary> /// /// </summary> public BoundaryTest() { _skill = new Skill { SkillName = ".Net core 3.1", SkillCategory = SkillCategory.DotNet, SkillLevel = SkillLevel.Intermediate, SkillType = SkillType.Programming, SkillTotalExperiance = 1 }; _user = new User { FirstName = "Dnyati", LastName = "Dube", Email = "*****@*****.**", Mobile = 9685744263, }; MongoDBUtility = new MongoDBUtility(); context = MongoDBUtility.MongoDBContext; _userRepository = new UserRepository(context); _skillRepository = new SkillRepository(context); _userService = new UserService(_userRepository); _skillService = new SkillService(_skillRepository); config = new ConfigurationBuilder().AddJsonFile("appsettings.test.json").Build(); }
public BusinessLogicTest() { MongoDBUtility mongoDBUtility = new MongoDBUtility(); context = mongoDBUtility.MongoDBContext; _userRepository = new UserRepository(context); _skillRepository = new SkillRepository(context); _userService = new UserService(_userRepository); _skillService = new SkillService(_skillRepository); _skill = new Skill { SkillName = ".Net core 3.1", SkillCategory = SkillCategory.DotNet, SkillLevel = SkillLevel.Intermediate, SkillType = SkillType.Programming, SkillTotalExperiance = 1 }; _user = new User { FirstName = "anvi", LastName = "patil", Email = "*****@*****.**", Mobile = 1236548978, MapSkills = 2 }; config = new ConfigurationBuilder().AddJsonFile("appsettings.test.json").Build(); }
public BoundaryTest() { _bill = new BillDetails { Title = "Electricity Bill", Catagory = BillCategory.Office, Amount = 1000, DateOfEntry = DateTime.Now, DueDate = DateTime.Now.AddDays(30), PaymentMode = BillPaymentMode.Bank_Transfer, Status = BillStatus.Unpaid }; _user = new User { UserName = "******", Password = "******", ConfirmPassword = "******", Email = "*****@*****.**", UserType = UserType.Visitor }; _userLogin = new UserLogin { UserName = "******", Password = "******", }; MongoDBUtility mongoDBUtility = new MongoDBUtility(); context = mongoDBUtility.MongoDBContext; _userRepository = new UserRepository(context); _billRepository = new BillRepository(context); _userService = new UserService(_userRepository); _billService = new BillService(_billRepository); config = new ConfigurationBuilder().AddJsonFile("appsettings.test.json").Build(); }
public ExceptionTest() { taskGroup = new TaskGroup { GroupName = "Academic Task", Active = "Yes", Color = "red" }; taskItem = new TaskItem { Name = "Training", Priority = TaskPriority.High, TaskStatus = TaskStatus.Yet_To_Start, TaskStartDate = DateTime.Now, TaskEndDate = DateTime.Now.AddDays(5), TaskGroup = "Academic Task", TaskColorCode = "purple" }; MongoDBUtility mongoDBUtility = new MongoDBUtility(); context = mongoDBUtility.MongoDBContext; _taskRepository = new TaskRepository(context); _taskService = new TaskService(_taskRepository); config = new ConfigurationBuilder().AddJsonFile("appsettings.test.json").Build(); }
private void btnAnalyze_Click(object sender, EventArgs e) { //Declarations MongoDBUtility objMongoDBUtility = new MongoDBUtility(); DataTable dtNetworkData; String strFilter = txtAnalyze.Text.Trim(); Int32 intMatches = 0; pbAnalyze.Value = 0; //Get the network data if (strFilter != String.Empty) { pbAnalyze.Value = 70; //Get the matching network data dtNetworkData = objMongoDBUtility.GetData("NetworkData", "NetworkData", strFilter, out intMatches); //Bind the data to the grid view gvViewer.DataSource = dtNetworkData; lblCount.Text = intMatches.ToString() + " matches"; pbAnalyze.Value = 100; } }
public bool Delete() { using (MongoDBUtility db = new MongoDBUtility()) { db.GetIMongoCollection <Log>().Remove(p => p.GuID != null); return(db.GetIMongoCollection <Log>().Count() == 0); } }
//public Expression<Func<T, D>> GenerateOrder<T, D>(string order) //{ // ParameterExpression orderex = Expression.Parameter(typeof(T), "orderex"); // Expression<Func<T, D>> field = // Expression.Lambda<Func<T, D>>( // Expression.Property( // orderex, // order // ), // new ParameterExpression[] { orderex } // ); // return field; //} public object GetClassList() { using (MongoDBUtility db = new MongoDBUtility()) { var quer = db.GetIMongoCollection <Log>().Linq().Select(p => p.RunClassName).ToList(); return(quer.GroupBy(p => p).Select(p => { return new { name = p.Key.Split('.').Last(), value = p.Key }; }).ToList()); } }
public object GetUserNamelist() { using (MongoDBUtility db = new MongoDBUtility()) { var quer = db.GetIMongoCollection <Log>().Linq().Select(p => p.UserName).ToList(); return(quer.GroupBy(p => p).Select(p => { return new { name = p.Key, value = p.Key }; }).ToList()); } }
//public Expression<Func<T, D>> GenerateOrder<T, D>(string order) //{ // ParameterExpression orderex = Expression.Parameter(typeof(T), "orderex"); // Expression<Func<T, D>> field = // Expression.Lambda<Func<T, D>>( // Expression.Property( // orderex, // order // ), // new ParameterExpression[] { orderex } // ); // return field; //} public object GetClassList() { using ( MongoDBUtility db = new MongoDBUtility() ) { var quer = db.GetIMongoCollection<Log>().Linq().Select(p => p.RunClassName).ToList(); return quer.GroupBy(p => p).Select(p => { return new { name = p.Key.Split('.').Last(), value = p.Key }; }).ToList(); } }
public bool Delete() { using ( MongoDBUtility db = new MongoDBUtility() ) { db.GetIMongoCollection<Log>().Remove(p => p.GuID != null); return db.GetIMongoCollection<Log>().Count() == 0; } }
public ExceptionalTest() { _bill = new BillDetails { Title = "Electricity Bill", Catagory = BillCategory.Office, Amount = 0, DateOfEntry = null, DueDate = null, PaymentMode = BillPaymentMode.Bank_Transfer, Status = BillStatus.Unpaid }; config = new ConfigurationBuilder().AddJsonFile("appsettings.test.json").Build(); MongoDBUtility mongoDBUtility = new MongoDBUtility(); context = mongoDBUtility.MongoDBContext; _userRepository = new UserRepository(context); _billRepository = new BillRepository(context); _userService = new UserService(_userRepository); _billService = new BillService(_billRepository); }
protected DataTable GetData(ExportData xExportData) { DataTable spData = new DataTable(); if (xExportData.SourceDatabase == "EF-MONGO") { if (xExportData.SQLQuery == "GET_ENQUIRY_DATA") { MongoDBUtility mongDB = new MongoDBUtility(); int i = mongDB.GetEnquiries(); _log.Info($"Records added {xExportData.SQLQuery} : {i}"); } } else { efDataExtporter.Helpers.MSSqlDbUtility sqlu = new Helpers.MSSqlDbUtility(xExportData.SourceDatabase); if (xExportData.SQLQuery.Trim().Contains(" ")) { string[] param = xExportData.SQLQuery.Split(' '); xExportData.SQLQuery = param[0]; List <SqlParameter> sqlParam = new List <SqlParameter>() { new SqlParameter("Days", SqlDbType.Int) { Value = param[1] }, }; spData = sqlu.executeStoredProc(xExportData.SQLQuery, sqlParam); } else { spData = sqlu.executeStoredProc(xExportData.SQLQuery, null); } } return(spData); }
public DatabaseConnectionTest() { MongoDBUtility = new MongoDBUtility(); config = new ConfigurationBuilder().AddJsonFile("appsettings.test.json").Build(); }
public override InvokeContext Action(InvokeContext context) { context = base.Action(context); if (context.MethodName == "Add" || context.MethodName == "Edit" || context.MethodName == "Remove" || context.MethodName == "TrueRemove" || context.MethodName == "SetUseConfigrByKey" || context.MethodName == "AddUserTo" || context.MethodName == "setRoleButtons" || context.MethodName == "setButtons") { var Session = HttpContext.Current.Session; T_UserInfo userinfo = new RUserInfo().GetUserInfoBySession(); Document Dmodel = new Document(); Log logmodel = new Log(); OperationType optype = new OperationType(); List <string> liststr = userinfo.T_Rolels.Select(p => p.RoleName).ToList(); string Rolelist = string.Join("|", liststr); var quer = context.Parameters.FirstOrDefault(); switch (context.MethodName) { case "Add": case "Edit": optype = OperationType.Insert; if (context.MethodName == "Edit") { optype = OperationType.Update; } if (quer != null) { foreach (var item in quer.GetType().GetProperties()) { var value = item.GetValue(quer, null); string strval = value != null?value.ToString() : ""; Dmodel.Add(item.Name, strval); } } logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null?userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "Remove": optype = OperationType.Delete; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null?userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "TrueRemove": optype = OperationType.TrueDelete; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null?userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "SetUseConfigrByKey": optype = OperationType.UseConfigrByKey; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); Dmodel.Add("ConfigJson", context.Parameters[1] != null ? context.Parameters[1].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null?userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "AddUserTo": optype = OperationType.UserRolesUpdate; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); try { int[] roleids = (int[])context.Parameters[1]; Dmodel.Add("roleids", roleids.Length > 1 ? string.Join(",", roleids) : roleids[0].ToString()); } catch (Exception) { Dmodel.Add("roleids", "日志存储异常"); } logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null?userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "setRoleButtons": optype = OperationType.RoleNavButtons; // Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); Dmodel.Add("Data", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null?userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "setButtons": optype = OperationType.NavButtons; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); try { int[] roleids = (int[])context.Parameters[1]; Dmodel.Add("btns", roleids.Length > 1 ? string.Join(",", roleids) : roleids[0].ToString()); } catch (Exception) { Dmodel.Add("btns", "日志存储异常"); } logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null?userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; } using (MongoDBUtility db = new MongoDBUtility()) { db.GetIMongoCollection <Log>().Insert(logmodel); } } return(context); }
public async Task ExceptionTestFor_NewTaskGroup_FailWithException() { var result = string.Empty; try { MongoDBUtility mongoDBUtility = new MongoDBUtility(new TaskGroup()); //_mockContext = mongoDBUtility.MockContext; //_mockCollectionGroup = mongoDBUtility.MockCollectionGroup; //_mockOptions = mongoDBUtility.MockOptions; //context = mongoDBUtility.MongoDBContext; //_mockCollectionGroup.Setup(op => op.InsertOneAsync(taskGroup, null, //default(CancellationToken))).Returns(Task.CompletedTask); //_mockContext.Setup(c => c.GetCollection<TaskGroup>(typeof(TaskGroup).Name)).Returns(_mockCollectionGroup.Object); //var taskService = new TaskService(context); taskGroup = null; //Action result = await _taskService.NewTaskGroup(taskGroup); if (result == "New Group Added") { testResult = "ExceptionTestFor_NewTaskGroup_FailWithException=" + "False"; // Write test case result in text file fileUtility.WriteTestCaseResuItInText(testResult); // Write test case result in xml file if (config["env"] == "development") { cases newcase = new cases { TestCaseType = "Exception", Name = "ExceptionTestFor_NewTaskGroup_FailWithException", expectedOutput = "False", weight = 2, mandatory = "False", desc = "na" }; await new FileUtility().WriteTestCaseResuItInXML(newcase); } } else { // Assert Assert.Null(result); } } catch (Exception exception) { var error = exception; testResult = "ExceptionTestFor_NewTaskGroup_FailWithException=" + "True"; // Write test case result in text file fileUtility.WriteTestCaseResuItInText(testResult); // Write test case result in xml file if (config["env"] == "development") { cases newcase = new cases { TestCaseType = "Exception", Name = "ExceptionTestFor_NewTaskGroup_FailWithException", expectedOutput = "True", weight = 2, mandatory = "True", desc = "na" }; await new FileUtility().WriteTestCaseResuItInXML(newcase); } } }
public override InvokeContext Action(InvokeContext context) { context = base.Action(context); if ( context.MethodName == "Add" || context.MethodName == "Edit" || context.MethodName == "Remove" || context.MethodName == "TrueRemove" || context.MethodName == "SetUseConfigrByKey" || context.MethodName == "AddUserTo" || context.MethodName == "setRoleButtons" || context.MethodName == "setButtons" ) { var Session = HttpContext.Current.Session; T_UserInfo userinfo = new RUserInfo().GetUserInfoBySession(); Document Dmodel = new Document(); Log logmodel = new Log(); OperationType optype = new OperationType(); List<string> liststr = userinfo.T_Rolels.Select(p => p.RoleName).ToList(); string Rolelist = string.Join("|", liststr); var quer = context.Parameters.FirstOrDefault(); switch ( context.MethodName ) { case "Add": case "Edit": optype = OperationType.Insert; if ( context.MethodName == "Edit" ) { optype = OperationType.Update; } if ( quer != null ) { foreach ( var item in quer.GetType().GetProperties() ) { var value = item.GetValue(quer, null); string strval = value != null ? value.ToString() : ""; Dmodel.Add(item.Name, strval); } } logmodel = new Log() { Model = Dmodel, MethodName=context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null ? userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "Remove": optype = OperationType.Delete; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null ? userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "TrueRemove": optype = OperationType.TrueDelete; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null ? userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "SetUseConfigrByKey": optype = OperationType.UseConfigrByKey; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); Dmodel.Add("ConfigJson", context.Parameters[1] != null ? context.Parameters[1].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null ? userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "AddUserTo": optype = OperationType.UserRolesUpdate; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); try { int[] roleids = (int[]) context.Parameters[1]; Dmodel.Add("roleids", roleids.Length > 1 ? string.Join(",", roleids) : roleids[0].ToString()); } catch ( Exception ) { Dmodel.Add("roleids", "日志存储异常"); } logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null ? userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "setRoleButtons": optype = OperationType.RoleNavButtons; // Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); Dmodel.Add("Data", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null ? userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; case "setButtons": optype = OperationType.NavButtons; Dmodel.Add("ID", context.Parameters[0] != null ? context.Parameters[0].ToString() : ""); try { int[] roleids = (int[]) context.Parameters[1]; Dmodel.Add("btns", roleids.Length > 1 ? string.Join(",", roleids) : roleids[0].ToString()); } catch ( Exception ) { Dmodel.Add("btns", "日志存储异常"); } logmodel = new Log() { Model = Dmodel, MethodName = context.MethodName, RunClassName = context.ClassFullName.ToString(), OperationTime = DateTime.Now, OperationType = optype, UserID = userinfo.T_User.ID, SaveChangesint = context.Result.ToString(), UserName = userinfo.T_User.TrueName != null ? userinfo.T_User.TrueName.Trim() : userinfo.T_User.UserName.Trim(), PurviewName = Rolelist }; break; } using ( MongoDBUtility db = new MongoDBUtility() ) { db.GetIMongoCollection<Log>().Insert(logmodel); } } return context; }
public object GetUserNamelist() { using ( MongoDBUtility db = new MongoDBUtility() ) { var quer = db.GetIMongoCollection<Log>().Linq().Select(p => p.UserName).ToList(); return quer.GroupBy(p => p).Select(p => { return new { name = p.Key, value = p.Key }; }).ToList(); } }