/// <summary> /// Create new user /// </summary> public bool Save(OUser input) { // Check if login exists bool loginExists = context.Users.AsNoTracking().FirstOrDefault(u => u.uLogin == input.login) != null; if (loginExists) { throw new Exception("User already exists"); } // Get encrypted password string hashedPassword = hashPassword(input.password); // Create new user User userModel = new User(); userModel.uName = input.name; userModel.uLastName = input.lastName; userModel.uLogin = input.login; userModel.uPassword = hashedPassword; context.Users.Add(userModel); context.SaveChanges(); return(true); }
private void Updater_Elapsed(object sender, ElapsedEventArgs e) { foreach (Data.osuUser OUser in osuInfo.osuUsers) { try { if (_client.GetServer(155403174142803969).GetUser(OUser.discordID).Status.Value.Equals(UserStatus.Online.Value)) { dynamic dict = Data.osuUser.userStats(OUser.ident.ToString(), OUser.mainMode); if (OUser.pp < double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture)) { string query = Information.readURL($"https://osu.ppy.sh/api/get_user_recent?u={OUser.ident}&{OUser.mainMode}&limit=1&k={apiKey}"); query = query.Remove(0, 1); query = query.Remove(query.Length - 1, 1); var jss = new JavaScriptSerializer(); var dict2 = jss.Deserialize <dynamic>(query); string beatmap_ID = dict2["beatmap_id"]; query = Information.readURL($@"https://osu.ppy.sh/api/get_scores?b={beatmap_ID}&{OUser.mainMode}&u={OUser.username}&limit=1&k={apiKey}"); query = query.Remove(0, 1); query = query.Remove(query.Length - 1, 1); var dict3 = jss.Deserialize <dynamic>(query); _client.GetServer(155403174142803969).GetChannel(219423083537235968).SendMessage($"Recieved pp change of `+{Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture) - OUser.pp, 2)}` by **{OUser.username}** ({Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture), 2)}pp)\n\nOn https://osu.ppy.sh/b/{dict2["beatmap_id"]}&{OUser.mainMode}\nScore: {string.Format("{0:n0}", int.Parse(dict2["score"]))} ({calcAcc(dict3, OUser.mainMode)}% , {dict2["maxcombo"]}x)\n{dict2["rank"]}, `{dict3["pp"]}pp`"); OUser.updateStats(dict); } } } catch { } } }
/// <summary> /// Check login /// </summary> public OUser checkLogin(string username, string password) { OUser login = null; HashingOptions hashingOptions = new HashingOptions(); hashingOptions.Iterations = 1000; IOptions <HashingOptions> options = Options.Create(hashingOptions); PasswordHasher hasher = new PasswordHasher(options); User user = context.Users.AsNoTracking() .FirstOrDefault(u => u.uLogin == username); if (user == null) { throw new Exception("User not found"); } var check = hasher.Check(user.uPassword, password); if (!check.Verified) { throw new Exception("Incorrect password"); } else { UserManager userManager = new UserManager(context); login = userManager.convert(user); } return(login); }
/// <summary> /// Đăng nhập /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnLogin_Click(object sender, EventArgs e) { BUser ctlUser = new BUser(); if (txtUsername.Text.Trim() != "" && txtPassword.Text.Trim() != "") { IList <OUser> lst = ctlUser.Get(txtUsername.Text.Trim(), Common.ECommon.GetMd5String(txtPassword.Text.Trim())); if (lst != null && lst.Count > 0) { UInfo = lst[0]; string strReturn = ""; if (Request.QueryString["returnURL"] == null) { strReturn = "/"; } else { strReturn = Server.UrlDecode(Request.QueryString["returnURL"]); } Response.Redirect(strReturn); } else { RegisterClientScriptBlock("Notification", "<script language='javascript'>alert('Thông tin đăng nhập không hợp lệ');</script>"); } } else { RegisterClientScriptBlock("Notification", "<script language='javascript'>alert('Thông tin đăng nhập không hợp lệ');</script>"); } }
/// <summary> /// Load danh sahcs nguoi xu ly /// </summary> /// <param name="str"></param> public string BindUserProcess(object str) { string strU = ""; BUser ctl = new BUser(); foreach (string i in str.ToString().Split(',')) { try { OUser obj = ctl.Get(int.Parse(i))[0]; if (obj != null) { if (strU == "") { strU = strU + obj.FullName; } else { strU = strU + ", " + obj.FullName; } } } catch (Exception ex) { } } return(strU); }
protected void btnReset_Click(object sender, EventArgs e) { string UserName = Global.UserInfo.UserName; BUser Bobj = new BUser(); OUser obj = new OUser(); obj = Bobj.Get(UserName).First(); if (Common.ECommon.GetMd5String(txtPass.Text) != obj.Password) { lblThongBao.Text = "MẬT KHẨU CŨ KHÔNG ĐÚNG!"; } else { if (txtPassRepeat.Text != txtPassNew.Text) { lblThongBao.Text = "MẬT KHẨU NHẮC LẠI KHÔNG KHỚP!"; } else { if (Bobj.Update(UserName, Common.ECommon.GetMd5String(txtPassNew.Text))) { lblThongBao.Text = "ĐỔI MẬT KHẨU THÀNH CÔNG!"; } } } }
public bool Add(OUser obj) { SqlParameter[] sqlPara = new SqlParameter[12]; sqlPara[0] = new SqlParameter("@UserName", SqlDbType.VarChar); sqlPara[0].Value = obj.UserName; sqlPara[1] = new SqlParameter("@Password", SqlDbType.VarChar); sqlPara[1].Value = obj.Password; sqlPara[2] = new SqlParameter("@FullName", SqlDbType.NVarChar); sqlPara[2].Value = obj.FullName; sqlPara[3] = new SqlParameter("@Email", SqlDbType.VarChar); sqlPara[3].Value = obj.Email; sqlPara[4] = new SqlParameter("@PhoneNumber", SqlDbType.VarChar); sqlPara[4].Value = obj.PhoneNumber; sqlPara[5] = new SqlParameter("@Tel", SqlDbType.VarChar); sqlPara[5].Value = obj.Tel; sqlPara[6] = new SqlParameter("@Gender", SqlDbType.VarChar); sqlPara[6].Value = obj.Gender; sqlPara[7] = new SqlParameter("@BirthDay", SqlDbType.DateTime); sqlPara[7].Value = obj.BirthDay; sqlPara[8] = new SqlParameter("@Address", SqlDbType.NVarChar); sqlPara[8].Value = obj.Address; sqlPara[9] = new SqlParameter("@Position", SqlDbType.NVarChar); sqlPara[9].Value = obj.Position; sqlPara[10] = new SqlParameter("@Status", SqlDbType.VarChar); sqlPara[10].Value = obj.Status; sqlPara[11] = new SqlParameter("@IDDepartment", SqlDbType.Int); sqlPara[11].Value = obj.IDDepartment; //sqlPara[12] = new SqlParameter("@IDGroup", SqlDbType.Int); //sqlPara[12].Value = obj.IDGroup; return(RunProcudure("sp_tblUser_add", sqlPara)); }
/// <summary> /// Khởi tạo dữ liệu /// </summary> private void InitData() { BUser ctl = new BUser(); OUser obj = new OUser(); try { //-- kiểm tra và lấy về thí sinh cần sửa if (!string.IsNullOrEmpty(Username)) { obj = ctl.Get(Username)[0]; } else { return; } txtUsername.Text = obj.UserName; lblUsername.Text = obj.UserName; tr_mk.Visible = false; tr_cmk.Visible = false; lblUsername.Visible = true; txtUsername.Visible = false; txtFullName.Text = obj.FullName; txtEmail.Text = obj.Email; txtPhoneNumber.Text = obj.PhoneNumber; txtTel.Text = obj.Tel; try { ddlGender.Items.FindByValue(obj.Gender).Selected = true; } catch (Exception ex) { } txtBirthDay.Text = obj.BirthDay.ToString("dd/MM/yyyy"); txtAddress.Text = obj.Address; txtPossition.Text = obj.Position; try { ddlStatus.Items.FindByValue(obj.Status).Selected = true; } catch (Exception ex) { } try { ddlDepartment.Items.FindByValue(obj.IDDepartment.ToString()).Selected = true; } catch (Exception ex) { } try { ddlGroup.Items.FindByValue(obj.IDGroup.ToString()).Selected = true; } catch (Exception ex) { } } catch (Exception ex) { } }
/// <summary> /// Transform from Model to Object /// </summary> public OUser convert(User model) { OUser user = new OUser(); user.id = model.uId; user.name = model.uName; user.lastName = model.uLastName; user.login = model.uLastName; return(user); }
protected bool ValidateForm() { bool bResult = true; lblUserNameRequired.Visible = false; lblEmailRequired.Visible = false; if (txtEmail.Text.Trim().Length < 1) { lblEmailRequired.Visible = true; bResult = false; } if (txtUserLogin.Text.Trim().Length < 1) { lblUserNameRequired.Visible = true; bResult = false; } if (bResult) { user = OUser.GetUserByLoginName(txtUserLogin.Text.Trim()); if (user == null) { lblResetError.Text = Resources.Errors.User_UserNameNotExist; bResult = false; } else //if user exists { if (user.UserBase.Email.Trim().Length < 1 || user.UserBase.Email.Equals(txtEmail.Text.Trim()) == false) { lblResetError.Text = Resources.Errors.User_EmailWrong; bResult = false; } else if (user.IsBanned == 1) { lblResetError.Text = Resources.Errors.User_AccountBanned; bResult = false; } else if (!user.IsPasswordOldEnoughToChange()) { int intDayToWait = Convert.ToInt32(OApplicationSetting.Current.PasswordMinimumAge) - user.GetPasswordAge(); lblResetError.Text = String.Format(Resources.Errors.User_PasswordCannotChange, intDayToWait.ToString()); bResult = false; } } } return bResult; }
/// <summary> /// Cập nhật thông tin User /// </summary> private void UpdateUser() { if (!IsUsernameValid()) { return; } BUser ctl = new BUser(); OUser obj; try { if (!string.IsNullOrEmpty(Username)) { obj = ctl.Get(Username)[0]; } else { obj = new OUser(); } }catch (Exception ex) { obj = new OUser(); } //-- gán thông tin cho đổi tượng người dùng obj.BirthDay = DateTime.ParseExact(txtBirthDay.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); obj.Email = txtEmail.Text.ToString(); obj.FullName = txtFullName.Text.Trim(); obj.Gender = ddlGender.SelectedValue; obj.IDDepartment = int.Parse(ddlDepartment.SelectedValue); obj.IDGroup = int.Parse(ddlGroup.SelectedValue); obj.PhoneNumber = txtPhoneNumber.Text.Trim(); obj.Tel = txtTel.Text.Trim(); obj.Address = txtAddress.Text.Trim(); obj.Position = txtPossition.Text.Trim(); obj.Status = ddlStatus.SelectedValue; //-- Cập nhật User if (obj.UserID > 0) { ctl.Update(obj.UserName, obj.FullName, obj.Email, obj.PhoneNumber, obj.Tel, obj.Gender, obj.BirthDay, obj.Address, obj.Position, "1", obj.IDDepartment); //RegisterClientScriptBlock("notifycation", "<script language='javascript'>alert('Cập nhật thành công.');</script>"); Response.Redirect("Default.aspx"); } //--Thêm mới User else { obj.UserName = txtUsername.Text.Trim(); obj.Password = Common.ECommon.GetMd5String(txtPassword.Text.Trim()); ctl.Add(obj); Response.Redirect("Default.aspx"); } }
private ResultObject FillParameters() { try { USER_USER UserObj = new USER_USER(); if (!String.IsNullOrEmpty(slcSinif.Value)) { UserObj.SINIF = Convert.ToInt16(slcSinif.Value); } if (!String.IsNullOrEmpty(slcMahalle.Value)) { UserObj.BOLGE_ID = Convert.ToInt64(slcMahalle.Value); } if (!String.IsNullOrEmpty(hiddenOgrId.Value)) { UserObj.OGR_GUID = Convert.ToInt64(hiddenOgrId.Value); lstOgrBilgi = (List <OGR_BILGI>)ViewState["lstOgrBilgi"]; UserObj.HOCA_GUID = lstOgrBilgi.Where(x => x.GUID == UserObj.OGR_GUID).ToList()[0].HOCA_GUID; } if (!String.IsNullOrEmpty(hiddenHocaId.Value)) { UserObj.HOCA_GUID = Convert.ToInt64(hiddenHocaId.Value); } UserObj.EMAIL = txtEmail.Value; UserObj.INSERT_USER = KsfSI.UserGuid; UserObj.IS_ADMIN = slcAdmin.Value == "1" ? short.Parse("1") : short.Parse("0"); UserObj.NAME = txtAd.Value; UserObj.PASSWORD = KasifBusiness.Utilities.KasifHelper.GetSha512HashedData(txtPassword.Value); UserObj.SURNAME = txtSoyad.Value; OUser oUser = new OUser(UserObj); ResultObject result = oUser.OUserOperation(); if (result.isOk) { USER_ROLE_OWNERSHIP uRo = new USER_ROLE_OWNERSHIP(); uRo.USER_GUID = UserObj.GUID; uRo.ROLE_GUID = Convert.ToInt64(slcRole.Value); DbOperations.Insert(uRo); } return(result); } catch (Exception ex) { ResultObject result = new ResultObject(); result.errorMsg = ex.Message; result.errPrefix = "Beklenmeyen Hata. "; result.isOk = false; return(result); } }
public Boolean GetOAuth(String strAccount, out OUser Entity) { Boolean isSucessful = false; IEnumerable<OUser> LstEntity = new List<OUser>(); try { isSucessful = true; Search.TryAuthenticate(eDomainName, eUserName, ePassWord, out LstEntity, strAccount); Entity = LstEntity.Where(o => o.sAMAccountName.ToUpper() == strAccount.ToUpper()).ToList()[0]; } catch (Exception ex) { Entity = null; } return isSucessful; }
/// <summary> /// Load danh sahcs nguoi xu ly /// </summary> /// <param name="str"></param> private void BindUserProcess(string str) { BUser ctl = new BUser(); foreach (string i in str.Split(',')) { try { OUser obj = ctl.Get(int.Parse(i))[0]; if (obj != null) { lsbUserProcess.Items.Add(new ListItem(obj.FullName, obj.UserID.ToString())); } } catch (Exception ex) { } } }
public Boolean OAuth(String strAccount, String strPassport, out OUser Entity) { Entity = null; #region OAuth //非常重要的配置 如果要配置请保证其正确性!建议不要配置 默认读取域名 strCookieDomain = System.Configuration.ConfigurationManager.AppSettings["OAuthURL"]; //是否使用域验证 OAuthByLDAP = System.Configuration.ConfigurationManager.AppSettings["OAuthByLDAP"] == "true"; //验证通过后跳转页面 SSO 登录中心导向页面 OAuthDefaultURL = System.Configuration.ConfigurationManager.AppSettings["OAuthSucessfulURL"]; if (OAuthByLDAP) { OAuthLDAP = System.Configuration.ConfigurationManager.AppSettings["OAuthLDAP"]; //isValidUser = ADHelper.TryAuthenticate(OAuthLDAP, strAccount, strPassport); //IdentityImpersonation Login = new IdentityImpersonation(strAccount, strPassport, OAuthLDAP); //Login.BeginImpersonate(); DomainName = System.Configuration.ConfigurationManager.AppSettings["DomainName"]; IEnumerable<OUser> LstEntity = new List<OUser>(); isValidUser = Search.TryAuthenticate(DomainName, strAccount, strPassport, out LstEntity, strAccount); if (isValidUser && LstEntity != null) { Entity = LstEntity.Where(o => o.sAMAccountName.ToUpper() == strAccount.ToUpper()).ToList()[0]; } } else { isValidUser = strAccount == System.Configuration.ConfigurationManager.AppSettings["Acount"] && strPassport == System.Configuration.ConfigurationManager.AppSettings["PassWord"]; } #endregion return isValidUser; }
protected void KhoiTao() { string UserName = Global.UserInfo.UserName; BUser BobjUser = new BUser(); OUser objUser = new OUser(); objUser = BobjUser.Get(UserName).First(); lblUserName.Text = UserName; txtFullName.Text = objUser.FullName; txtDate.Text = objUser.BirthDay.ToString("dd/MM/yyyy"); txtEmail.Text = objUser.Email; txtPhone.Text = objUser.PhoneNumber; txtTel.Text = objUser.Tel; txtAddress.Text = objUser.Address; //Load Giới tính BindGender(); }
/// <summary> /// Cập nhật mật khẩu mới /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbtChangedPassword_Click(object sender, EventArgs e) { if (Global.UserInfo.Password != txtCurrentPassword.Text.Trim()) { lblErrorChangedPass.Text = "Mật khẩu hiện tại không hợp lệ!."; } else { if (txtNewPassword.Text.Trim() != txtConfirmNewPassword.Text.Trim()) { lblErrorChangedPass.Text = "Mật khẩu mới hoặc xác nhận mật khẩu mới không hợp lệ!."; } lblErrorChangedPass.Text = ""; Global.UserInfo.Password = txtConfirmNewPassword.Text.Trim(); OUser obj = Global.UserInfo; (new BUser()).Update(obj.UserName, obj.Password); RegisterClientScriptBlock("Notification", "<script language='javascript'>alert('Thay đổi mật khẩu thành công');</script>"); } }
protected void cmdDownAttachs_Click(object sender, EventArgs e) { try { string usn = ""; ODocument obj; BDocument ctl = new BDocument(); if (DocumentId != "") { try { obj = ctl.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentSend.ToString("D")))[0]; if (obj != null) { BUser ctlU = new BUser(); OUser objU = ctlU.Get(obj.IDUserCreate)[0]; if (objU != null) { usn = objU.UserName; } } } catch (Exception ex) { } } else { } HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName("DocumentFiles/" + usn + "/" + lblAttach.Text)); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.WriteFile("DocumentFiles/" + usn + "/" + lblAttach.Text); HttpContext.Current.Response.End(); } catch (Exception ex) { throw ex; } }
public Boolean GetEmailOAuth(String strAccount, out OUser Entity) { //String eDomainName = "sznsdc01.skyworth.com"; //String eUserName = "******"; //String ePassWord = "******"; Boolean isSucessful = false; IEnumerable<OUser> LstEntity = new List<OUser>(); try { isSucessful = true; Search.TryAuthenticate(eDomainName, eUserName, ePassWord, out LstEntity, strAccount); Entity = LstEntity.Where(o => o.sAMAccountName.ToUpper() == strAccount.ToUpper()).ToList()[0]; } catch (Exception ex) { Entity = null; } return isSucessful; }
/// <summary> /// Edit existing user /// </summary> public OUser Edit(OUser input) { // Get user User userModel = context.Users.FirstOrDefault(u => u.uId == input.id); if (userModel == null) { throw new Exception("User not found"); } // Edit data userModel.uName = input.name; userModel.uLastName = input.lastName; if (input.password != null) { userModel.uPassword = hashPassword(input.password); } context.Users.Update(userModel); context.SaveChanges(); return(convert(userModel)); }
public List <OUser> GetUserProcess(int WorkID) { IList <OWork> lstWork = this.GetWork(WorkID); string strAttachID = lstWork[0].IDUserProcess; String[] arrUser = strAttachID.Split(','); List <OUser> lstUser = new List <OUser>(); BUser objBUser = new BUser(); if (arrUser.Count() > 1) { for (int i = 1; i < arrUser.Count() - 1; i++) { IList <OUser> lstUserCurent = objBUser.Get(arrUser[i]); if (lstUserCurent.Count > 0) { OUser objUser = lstUserCurent[0]; lstUser.Add(objUser); } } } return(lstUser); }
protected void Infomation_Load() { int WorkID = int.Parse(Request.QueryString["WorkID"].ToString()); BWork Bobj = new BWork(); OWork obj = new OWork(); obj = Bobj.GetWork(WorkID).First(); BUser BobjUser = new BUser(); OUser objUser = BobjUser.Get(int.Parse(obj.IDUserCreate.ToString())).First(); lblName.Text = obj.Name; lblNgayTao.Text = obj.CreateDate.ToString("dd/MM/yyyy"); lblNgayBatDau.Text = obj.StartProcess.ToString("dd/MM/yyyy"); lblNgayKetThuc.Text = obj.EndProcess.ToString("dd/MM/yyyy"); lblYeuCau.Text = obj.Description; lblUserCreate.Text = objUser.FullName; //Lấy file Attachs string list = obj.Attachs.ToString(); string[] item; item = list.Split(','); rptFiles.DataSource = Bobj.GetAttachs(WorkID); rptFiles.DataBind(); if (obj.Attachs == "" || obj.Attachs == ",") { lblThongBao.Text = "Không có file đính kèm!"; } //Load ListUserProcess rptListUser.DataSource = Bobj.GetUserProcess(WorkID); rptListUser.DataBind(); hdfUserJoin.Value = Bobj.GetWork(WorkID).First().IDUserProcess; }
/// <summary> /// Resets the user's password. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnResetPassword_Click(object sender, EventArgs e) { if (ValidateForm()) { user = OUser.GetUserByLoginName(txtUserLogin.Text.Trim()); user.ResetPassword(); lblResetError.Text = Resources.Errors.User_PasswordReset; } }
public void SendEmail(OUser user) { user.SendMessage("Reading_Reminder", user.UserBase.Email, user.UserBase.Cellphone); }
//-------------------------------------------------------------------- /// <summary> /// If user is active directory try to authenticate user from active directory. /// </summary> /// <param name="OUser"></param> //-------------------------------------------------------------------- protected bool IsActiveDirectory(OUser user) { DirectoryEntry entry = null; if (user.ActiveDirectoryDomain != null && user.ActiveDirectoryDomain != string.Empty) { entry = new DirectoryEntry(OApplicationSetting.Current.ActiveDirectoryPath, user.ActiveDirectoryDomain + "\\" + login.UserName, login.Password); } else { entry = new DirectoryEntry(OApplicationSetting.Current.ActiveDirectoryPath, OApplicationSetting.Current.ActiveDirectoryDomain + "\\" + login.UserName, login.Password); } Object obj = entry.NativeObject; DirectorySearcher search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + login.UserName + ")"; search.PropertiesToLoad.Add("cn"); SearchResult result = search.FindOne(); if (null == result) return false; return true; }
public void SendEmail(OEquipmentReminder re, OUser user) { re.SendMessage("Equipment_Reminder", user.UserBase.Email, user.UserBase.Cellphone); }
/// <summary> /// Validates the user access to the specific report and location. /// </summary> /// <param name="user"></param> /// <param name="report"></param> /// <param name="LocationID"></param> /// <returns></returns> private static bool validateUserAccessRight(OUser user, OReport report, Guid locationID) { bool locationAccess = false, reportAccess = false; DataList<OPosition> positions = user.Positions; List<Guid> roles = new List<Guid>(); foreach (OPosition position in positions) { if (position.LocationAccess.Find(locationID) != null) { locationAccess = true; break; } roles.Add(position.RoleID.Value); } foreach (Guid roleID in roles) { if (report.Roles.Find(roleID) != null) { reportAccess = true; break; } } return locationAccess && reportAccess; }
private void Updater_Elapsed(object sender, ElapsedEventArgs e) { if (osuInfo == null && owInfo == null) { updater.Interval = 60000; osuInfo = new Data.Osu_Data(); owInfo = new Data.Overwatch_Data(); return; } foreach (Data.osuUser OUser in osuInfo.osuUsers) { try { if (OUser.channels[0].GetUser(OUser.discordID).Status.Value.Equals(UserStatus.Online.Value) || OUser.channels[0].Id.Equals(226499471683485697)) { dynamic dict = Data.osuUser.userStats(OUser.ident.ToString(), OUser.mainMode); if (OUser.pp + 1 <= double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture)) { string query = Information.readURL($"https://osu.ppy.sh/api/get_user_recent?u={OUser.ident}&{OUser.mainMode}&limit=1&k={apiKey}"); query = query.Remove(0, 1); query = query.Remove(query.Length - 1, 1); var jss = new JavaScriptSerializer(); var dict2 = jss.Deserialize <dynamic>(query); string beatmap_ID = dict2["beatmap_id"]; query = Information.readURL($@"https://osu.ppy.sh/api/get_scores?b={beatmap_ID}&{OUser.mainMode}&u={OUser.username}&limit=1&k={apiKey}"); query = query.Remove(0, 1); query = query.Remove(query.Length - 1, 1); var dict3 = jss.Deserialize <dynamic>(query); string output = $"Recieved pp change of `+{Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture) - OUser.pp, 2)}` by **{OUser.username}** ({Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture), 2)}pp)\n\nOn https://osu.ppy.sh/b/{dict2["beatmap_id"]}&{OUser.mainMode}\nScore: {string.Format("{0:n0}", int.Parse(dict2["score"]))} ({calcAcc(dict3, OUser.mainMode)}% , {dict2["maxcombo"]}x)\n{dict2["rank"]}, `{dict3["pp"]}pp`"; foreach (Channel ch in OUser.channels) { ch.SendMessage(output); } OUser.updateStats(dict); } else if (OUser.pp < double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture)) { OUser.updateStats(dict); } } } catch { } } //foreach (Data.OW_User user in owInfo.OW_Users) //{ // if (!user.channels[0].GetUser(user.discordID).Status.Value.Equals(UserStatus.Offline.Value) // && user.channels[0].GetUser(user.discordID).CurrentGame.Value.Equals("Overwatch")) // { // string tracker = user.trackChange(); // if (!tracker.Equals("")) // foreach (Channel ch in user.channels) // ch.SendMessage(tracker); // } //} }
protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e) { if (e.Container.Mode == SchedulerFormMode.Insert) { Status = "Insert"; } if (e.Container.Mode == SchedulerFormMode.AdvancedInsert) { Status = "AdvancedInsert"; RadDateTimePicker startInput = (RadDateTimePicker)e.Container.FindControl("StartInput"); //startInput.SelectedDate = DateTime.Parse(hdf.Value); RadDateTimePicker endInput = (RadDateTimePicker)e.Container.FindControl("EndInput"); //endInput.SelectedDate = DateTime.Parse(hdf.Value); //-- Kiểm tra quyền tạo việc BUser ctl = new BUser(); Panel panelUser = (Panel)e.Container.FindControl("panelUser"); if (ctl.HasPermission(Global.UserInfo.UserID, PermissionCode.CalendarCreate.ToString()) || Global.IsAdmin()) { panelUser.Visible = true; } else { panelUser.Visible = false; } } if (e.Container.Mode == SchedulerFormMode.AdvancedEdit) { HiddenField hdfID = ((HiddenField)e.Container.FindControl("hdfID")); hdfID.Value = e.Appointment.ID.ToString(); TextBox subjectBox = (TextBox)e.Container.FindControl("SubjectTextBox"); subjectBox.Text = e.Appointment.Subject; RadDateTimePicker startInput = (RadDateTimePicker)e.Container.FindControl("StartInput"); //startInput. = RadScheduler1.EditFormDateFormat + " " + RadScheduler1.EditFormTimeFormat; startInput.SelectedDate = RadScheduler1.DisplayToUtc(e.Appointment.Start); RadDateTimePicker endInput = (RadDateTimePicker)e.Container.FindControl("EndInput"); //endInput.DateFormat = RadScheduler1.EditFormDateFormat + " " + RadScheduler1.EditFormTimeFormat; endInput.SelectedDate = RadScheduler1.DisplayToUtc(e.Appointment.End); TextBox txtDescription = (TextBox)e.Container.FindControl("txtDescription"); txtDescription.Text = e.Appointment.Description; TextBox txtAddress = (TextBox)e.Container.FindControl("txtAddress"); BCalendar BCaledarobj = new BCalendar(); OCalendar objCalendar = new OCalendar(); objCalendar = BCaledarobj.Get(int.Parse(e.Appointment.ID.ToString())).First(); //Lấy danh sách người tham gia BUser BobjUser = new BUser(); OUser objUser = new OUser(); string[] listUser; Panel panelUser = (Panel)e.Container.FindControl("panelUser"); string html = ""; html += "<table width='100%'>"; int count = 0; string UserJoin = objCalendar.UserJoin; listUser = UserJoin.Split(','); for (int i = 1; i < listUser.Count() - 1; i++) { OUser _OUser = new OUser(); _OUser = BobjUser.Get(listUser[i]).First(); if (count % 4 == 0) { html += "<tr>"; } html += "<td width='25%'>"; html += "<input id='ckxUser' class='cbxUser' name='ckxUser' type='checkbox' value='" + _OUser.UserName + "' title='" + _OUser.FullName + "'" + "checked='checked'" + " />"; html += " "; html += "" + _OUser.FullName + ""; html += "</td>"; count++; if (count % 4 == 0) { html += "</tr>"; } } if (count % 4 != 0) { html += "</tr>"; } html += "</table>"; Literal LiteralUser = (Literal)e.Container.FindControl("LiteralUser"); LiteralUser.Text = html; HiddenField hdfUserJoin = (HiddenField)e.Container.FindControl("hdfUserJoin"); hdfUserJoin.Value = UserJoin; //Lấy địa chỉ họp txtAddress.Text = objCalendar.Address; //-- Kiểm tra quyền tạo việc BUser ctl = new BUser(); if (ctl.HasPermission(Global.UserInfo.UserID, PermissionCode.CalendarCreate.ToString()) || Global.IsAdmin()) { panelUser.Visible = true; } else { panelUser.Visible = false; } } }
public void SendEmail(OContractReminder re, OUser user) { re.SendMessage("Contract_Reminder", user.UserBase.Email, user.UserBase.Cellphone); }