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);
        }
Пример #2
0
    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);
    }
Пример #3
0
 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);
 }
Пример #4
0
 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();
 }
Пример #5
0
    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);
    }
Пример #6
0
    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();
    }
Пример #7
0
 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."));
 }
Пример #8
0
        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);
        }
Пример #9
0
 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);
 }
Пример #10
0
        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();
        }
Пример #11
0
    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);
    }
Пример #12
0
 public static byte[] GetLargeBuffer(DataFill dataFill) => GetBuffer(LargeBufferSize, dataFill);
Пример #13
0
 public static byte[] GetSmallBuffer(DataFill dataFill) => GetBuffer(SmallBufferSize, dataFill);
Пример #14
0
 public static MemoryStream GetStream(int length, DataFill dataFill) => new MemoryStream(GetBuffer(length, dataFill));
Пример #15
0
 public static MemoryStream GetLargeStream(DataFill dataFill) => GetStream(LargeBufferSize, dataFill);
Пример #16
0
 public static MemoryStream GetSmallStream(DataFill dataFill) => GetStream(SmallBufferSize, dataFill);
Пример #17
0
 public DataRepository(DataFill fill)
 {
     this.context = new DataContext();
     fill.Fill(this);
 }
Пример #18
0
    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);//调用分页方法;
    }
Пример #19
0
 public static MemoryStream GetLargeStream(DataFill dataFill) => new MemoryStream(GetBuffer(LargeBufferSize, dataFill));
Пример #20
0
 public static MemoryStream GetSmallStream(DataFill dataFill) => new MemoryStream(GetBuffer(SmallBufferSize, dataFill));
Пример #21
0
 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."));
 }
Пример #22
0
        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
        }
Пример #23
0
 public Shop(DataFill fill)
 {
     data = new DataRepository(fill);
 }