protected void waitingrepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Activate": { using (VendingModelContainer dc = new VendingModelContainer()) { try { string tmpuserid = ((Label)(e.Item.FindControl("email"))).Text; Accounts tmpacc = dc.Accounts.First(x => x.UserID == tmpuserid); tmpacc.Suspended = ((CheckBox)(e.Item.FindControl("suspendedcb"))).Checked; tmpacc.Valid = ((CheckBox)(e.Item.FindControl("activecb"))).Checked; tmpacc.DeviceCountLimit = Convert.ToInt32(((TextBox)(e.Item.FindControl("devlimit"))).Text); dc.SaveChanges(); if (tmpacc.DeviceCountLimit > 0) { AccLicense tmplic = new AccLicense(tmpacc.ID); } Logger.AccountLog(Request.UserHostAddress, "Акаунт активирован", "", tmpacc.ID); Logger.SystemLog(Request.UserHostAddress, "Активация нового акаунта", tmpacc.UserID, User.Identity.Name); } catch (Exception ex) { Logger.SystemLog(Request.UserHostAddress, "Ошибка: " + ex.Message, ex.InnerException?.Message, "Server"); } } break; } case "DeleteAcc": { using (VendingModelContainer dc = new VendingModelContainer()) { try { string tmpuserid = ((Label)(e.Item.FindControl("email"))).Text; Accounts tmpacc = dc.Accounts.First(x => x.UserID == tmpuserid); dc.Accounts.Remove(tmpacc); dc.SaveChanges(); Logger.AccountLog(Request.UserHostAddress, "Акаунт удален", "", tmpacc.ID); Logger.SystemLog(Request.UserHostAddress, "Удаление акаунта", tmpacc.UserID, User.Identity.Name); } catch (Exception ex) { Logger.SystemLog(Request.UserHostAddress, "Ошибка: " + ex.Message, ex.InnerException?.Message, "Server"); } } break; } } waitingrepeater.DataBind(); }
/// <summary> /// Создает объект лицензии для ее проверки /// </summary> /// <param name="Content"></param> public AccLicense(string Content) { try { AccLicense tmpacclicense = Deserialize <List <AccLicense> >(Content)[0]; UserID = tmpacclicense.UserID; RegistrationDateTime = tmpacclicense.RegistrationDateTime; RegistrationDateTimeStr = tmpacclicense.RegistrationDateTimeStr; DeviceCountLimit = tmpacclicense.DeviceCountLimit; Signature = tmpacclicense.Signature; ServerEndPoint = tmpacclicense.ServerEndPoint; } catch { } }
protected void Button1_Click(object sender, EventArgs e) { AccLicense tmpal = new AccLicense(2); }