public ControllerTests() { var options = new DbContextOptionsBuilder <Context>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; _context = new Context(options); _roleManager = new RoleManager <AppRole>( new RoleStore <AppRole, Context, int>(_context), new List <RoleValidator <AppRole> > { new RoleValidator <AppRole>() }, null, null, new Mock <ILogger <RoleManager <AppRole> > >().Object ); _userManager = new UserManager <AppUser>( new UserStore <AppUser, AppRole, Context, int>(_context), null, new PasswordHasher <AppUser>(), new List <UserValidator <AppUser> > { new UserValidator <AppUser>() }, null, null, null, null, new Mock <ILogger <UserManager <AppUser> > >().Object ); DataFill.LoadData(_context); DataFill.LoadOglasi(_context); DataFill.AddUsers(_userManager, _context, _roleManager); }
protected void Page_Load(object sender, EventArgs e) { string sqlcom = "select goodsid,images,goodsname,goodsprice from [Goods] where goodssort='书籍' order by goodsid desc "; DataFill data = new DataFill(); data.DataPage(sqlcom, MarketDetailDl, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request); }
public void load() { DataAccess data = new DataAccess(); data.Connection(); int id = Convert.ToInt32(Request.QueryString["id"].ToString()); string sqlcom = "select mescontent, Username, mestime from [message] where goodsid=" + id; DataFill ds = new DataFill(); ds.DataPage(sqlcom, DataList1, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request); }
protected void Page_Load(object sender, EventArgs e) { if (Session["Username"] == null) { Response.Redirect("Login.aspx"); } string sqlcom = "select goodsid,images,goodsname,goodsprice,connectpeople,phone ,datetime from [Goods] where Username='******' order by goodsid desc "; DataFill data = new DataFill(); data.DataPage(sqlcom, MarketDetailDl, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request); userName.Text = Session["Username"].ToString(); }
public int EachPage; //每页总条数 protected void Page_Load(object sender, EventArgs e) { if (Session["Username"] == null) { Response.Redirect("Login.aspx"); } string sqlcom = "select goodsid,images,goodsname,goodsprice,connectpeople,phone ,datetime from [Goods] where Username='******' order by goodsid desc "; DataFill data = new DataFill(); data.DataPage(sqlcom, MarketDetailDl, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request); userName.Text = Session["Username"].ToString(); }
public IActionResult FillDatabase() { if (DataFill.IsEmptyDB(context)) { if (DataFill.LoadData(context) && DataFill.LoadOglasi(context)) { return(Content("Baza uspjesno popunjena.")); } else { return(Content("Nemoguce popuniti tabele. Potrebno je obrisati čitavu bazu i ponovo uraditi migracije i update da bi mogli ponovo generisati podatke.")); } } return(Content("Baza je vec puna. Potrebno je obrisati citavu bazu pa ponovo generisati podatke.")); }
public static byte[] GetBuffer(int length, DataFill dataFill) { var buffer = new byte[length]; if (dataFill == DataFill.Random) { Random.NextBytes(buffer); } else { for (int i = 0; i < buffer.Length; i++) { buffer[i] = (byte)(i % 256); } } return(buffer); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] == null) Response.Redirect("Default.aspx"); int id = Convert.ToInt32(Request.QueryString["id"].ToString()); DataAccess data = new DataAccess(); data.Connection(); string sqlcom = "SELECT goodsname,goodsprice,phone,images,details FROM [Goods] where goodsid=" + id; SqlCommand cmd = data.excute(sqlcom); DataSet ds = data.Fill(cmd); gName.Text = ds.Tables[0].Rows[0][0].ToString(); money.Text = ds.Tables[0].Rows[0][1].ToString(); tel.Text = ds.Tables[0].Rows[0][2].ToString(); Image1.ImageUrl = ds.Tables[0].Rows[0][3].ToString(); Mes.Text = ds.Tables[0].Rows[0][4].ToString(); string sqlcom1 = "select mescontent, Username, mestime from [message] where goodsid=" + id; DataFill ds1 = new DataFill(); ds1.DataPage(sqlcom1, DataList1, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request); }
public static void Main(string[] args) { //CreateHostBuilder(args).Build().Run(); var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <Context>(); var userMgr = services.GetRequiredService <UserManager <AppUser> >(); var roleMgr = services.GetRequiredService <RoleManager <AppRole> >(); var signInMgr = services.GetRequiredService <SignInManager <AppUser> >(); context.Database.Migrate(); var controller = new AccountController(context, userMgr, signInMgr, roleMgr); var task = Task.Run(() => controller.CreateRolesOnce()); task.Wait(); Console.WriteLine("Users added"); if (!context.Proizvod.Any()) { if (DataFill.LoadData(context) && DataFill.LoadOglasi(context)) { Console.WriteLine("Data added"); } } } catch (Exception e) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(e, "Desila se greska prilikom ubacivanja podataka u bazu."); } } host.Run(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] == null) { Response.Redirect("Default.aspx"); } int id = Convert.ToInt32(Request.QueryString["id"].ToString()); DataAccess data = new DataAccess(); data.Connection(); string sqlcom = "SELECT goodsname,goodsprice,phone,images,details FROM [Goods] where goodsid=" + id; SqlCommand cmd = data.excute(sqlcom); DataSet ds = data.Fill(cmd); gName.Text = ds.Tables[0].Rows[0][0].ToString(); money.Text = ds.Tables[0].Rows[0][1].ToString(); tel.Text = ds.Tables[0].Rows[0][2].ToString(); Image1.ImageUrl = ds.Tables[0].Rows[0][3].ToString(); Mes.Text = ds.Tables[0].Rows[0][4].ToString(); string sqlcom1 = "select mescontent, Username, mestime from [message] where goodsid=" + id; DataFill ds1 = new DataFill(); ds1.DataPage(sqlcom1, DataList1, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request); }
public static byte[] GetLargeBuffer(DataFill dataFill) => GetBuffer(LargeBufferSize, dataFill);
public static byte[] GetSmallBuffer(DataFill dataFill) => GetBuffer(SmallBufferSize, dataFill);
public static MemoryStream GetStream(int length, DataFill dataFill) => new MemoryStream(GetBuffer(length, dataFill));
public static MemoryStream GetLargeStream(DataFill dataFill) => GetStream(LargeBufferSize, dataFill);
public static MemoryStream GetSmallStream(DataFill dataFill) => GetStream(SmallBufferSize, dataFill);
public DataRepository(DataFill fill) { this.context = new DataContext(); fill.Fill(this); }
public int Tnum; //总条数; #endregion Fields #region Methods protected void Page_Load(object sender, EventArgs e) { string sqlcom = "select goodsid,images,goodsname,goodsprice from [Goods] where goodssort='生活用品' order by goodsid desc "; DataFill data = new DataFill();//创建分页填充类对象; data.DataPage(sqlcom, MarketDetailDl, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request);//调用分页方法; }
public static MemoryStream GetLargeStream(DataFill dataFill) => new MemoryStream(GetBuffer(LargeBufferSize, dataFill));
public static MemoryStream GetSmallStream(DataFill dataFill) => new MemoryStream(GetBuffer(SmallBufferSize, dataFill));
public IActionResult EmptyDatabase() { DataFill.EmptyDatabase(context); return(Content("Podaci su obrisani. Ako želite ponovo generisati podatke, morate obrisati bazu i ponovo uraditi migracije i update.")); }
private static void FinishLoad() { if (FiveDaysSteps == null || FiveDaysCalories == null || FiveDaysDistance == null || FiveDaysActiveTime == null) { return; } FiveDaysSteps = FiveDaysSteps.RemoveLastElements(1).ToArray(); FiveDaysCalories = FiveDaysCalories.RemoveLastElements(1).ToArray(); FiveDaysDistance = FiveDaysDistance.RemoveLastElements(1).Select(x => x / 1000).ToArray(); FiveDaysActiveTime = FiveDaysActiveTime.RemoveLastElements(1).ToArray(); #region If statistics less than 5 days Func <int, IEnumerable <int> > range = i => Enumerable.Range(0, 5 - i); if (FiveDaysSteps.Length < 5) { FiveDaysSteps = range(FiveDaysSteps.Length).Select(x => 0D).Concat(FiveDaysSteps).ToArray(); } if (FiveDaysCalories.Length < 5) { FiveDaysCalories = range(FiveDaysCalories.Length).Select(x => 0D).Concat(FiveDaysCalories).ToArray(); } if (FiveDaysDistance.Length < 5) { FiveDaysDistance = range(FiveDaysDistance.Length).Select(x => 0D).Concat(FiveDaysDistance).ToArray(); } if (FiveDaysActiveTime.Length < 5) { FiveDaysActiveTime = range(FiveDaysActiveTime.Length) .Select(x => TimeSpan.FromMilliseconds(0)) .Concat(FiveDaysActiveTime) .ToArray(); } #endregion TodaySteps = Convert.ToInt32(Math.Round(FiveDaysSteps.Last())); TodayCalories = Convert.ToInt32(Math.Round(FiveDaysCalories.Last())); TodayDistance = Math.Round(FiveDaysDistance.Last(), 2); TodayActiveTime = FiveDaysActiveTime.Last(); _statisticsInLoad = false; StatisticsInit = true; DataFill?.Invoke(); Analytics.TrackEvent("Trying to retrieve data from HealthKit/Google Fit API.", new Dictionary <string, string> { { "Page", "Login" }, { "Category", "Request" }, { "API", FitnessTracker?.ApiName }, { "Result", true.ToString() }, { "Error_message", "" } }); #endregion }
public Shop(DataFill fill) { data = new DataRepository(fill); }