public IActionResult GetUserListByDeptId(int pageIndex, int rowCount, string deptId) { /*判断是否合法*/ if (ModelState.IsValid) { try { if (string.IsNullOrEmpty(deptId)) { deptId = User.Identities.First(u => u.IsAuthenticated).FindFirst("UsrDeptId").Value; } IList <HelpCenter.Model.DbModel.DbDeptUserModel> usrList = Usr.GetListByDeptId(pageIndex, rowCount, out int _totalCount, out int _pageCount, deptId); return(null == usrList ? Ok(new { result = false, tips = ResponseMessageTips.MSG_USR_INFO_NO_FOUND }) : Ok(new { result = true, tips = ResponseMessageTips.MSG_PROCESS_SUCCESS, data = new { totalCount = _totalCount, pageCount = _pageCount, info = usrList } })); } catch (Exception e) { return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_EXCEPTION + e.Message.ToString() })); } } return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_DATA_FORMAT_ERROR })); }
public HttpResponseMessage Put(int ID, Usr user) { try { using (MultimediaEntities3 en = new MultimediaEntities3()) { var Myuser = en.Usrs.FirstOrDefault(a => a.ID == ID); if (Myuser == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Record Not Found")); } else { Myuser.Name = user.Name; Myuser.Password = user.Password; Myuser.Photo = user.Photo; Myuser.Imagepath = user.Imagepath; Myuser.Age = user.Age; Myuser.E_mail = user.E_mail; en.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, Myuser)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } }
private async Task AddUserToRole(Usr user, RoleData roleData) { if (await _roleManager.RoleExistsAsync(roleData.Name)) { await _userManager.AddToRoleAsync(user, roleData.Name); } }
public string CreatePaginatedLinks(int paginatedPageNumber, string userid) { string functionString = "getData2('DownloadUserPictures.asmx/GetUserPictures', '#changePhototFromGallery',this,'" + userid + "')"; string numberOfPicturesPaginationLinks = Usr.BuildHtmlPagination(Usr.maxPhotosPerUploadNewProfilePicture, paginatedPageNumber, functionString); return(numberOfPicturesPaginationLinks); }
public string GetUserPictures(string userid, string paginatedPageNumbers) { int paginatedPageNumber = Int32.Parse(paginatedPageNumbers); int numberOfPictures = Usr.CountAllUserPictures(userid); if (numberOfPictures != 0) { List <string> photos = Usr.GetAllUserPicturesPaginated(userid, paginatedPageNumber); string imgsrc = "<a class=\"popupBoxClose\" onclick=\"unloadPopupBox(changePhototFromGallery)\" >X</a>"; foreach (string photo in photos) { imgsrc += "<img class='notSelected' src=\'" + photo + "\' onclick = \"SelectPicture(this)\" />"; } imgsrc += "<br /><a onclick=\"ajaxChangeProfilePic('" + userid + "')\" class='buttonclass'>Zmień zdjęcie</a>"; string paginatedLinks = ""; if (numberOfPictures > Usr.maxPhotosPerUploadNewProfilePicture) { paginatedLinks = CreatePaginatedLinks(paginatedPageNumber, userid); } //in javascript function which recieve response, check if value after '|' is not equal to 0, //if not, then pagination links should be replaced return(imgsrc + "|" + paginatedLinks); } return("Nie dodałeś żadnych zdjęć do galerii"); }
public MCustomersForm(string gradeEnum) { InitializeComponent(); dtgvCustomers.AutoGenerateColumns = false; Usr usr = MainForm.usr; grade = gradeEnum; page = new PageVO(); page.PageNo = 1; if (null == manager) { manager = InterfaceProxyGenerator.CreateInterfaceProxy <ICustomerManager>(usr); } BindingSource stBs = new BindingSource(); Dictionary <string, string> custMap = new Dictionary <string, string>(); custMap.Add("", "全部"); custMap.Add(ST.VALID, ST.CUST_MAP[ST.VALID]); custMap.Add(ST.INVALID, ST.CUST_MAP[ST.INVALID]); stBs.DataSource = custMap; cboxSt.DisplayMember = "Value"; cboxSt.ValueMember = "Key"; cboxSt.DataSource = stBs; if (GRADE.SUPPLIER == grade) { this.lblCName.Text = "供应商名称:"; } else if (GRADE.RESELLER == grade) { this.lblCName.Text = "分销商名称:"; } }
private void cboxUsr_SelectedIndexChanged(object sender, EventArgs e) { BindData(); Usr usr = cboxUsr.SelectedItem as Usr; txtUName.Text = usr.UName; }
private void btnLogin_Click(object sender, EventArgs e) { try { Usr usr = new Usr(); usr.UId__PK = txtLogId.Text; usr.Pwd = txtPwd.Text; if (StringUtil.isEmpty(usr.UId__PK) || StringUtil.isEmpty(usr.Pwd)) { MessageBox.Show("请输入登录名 / 密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } manager = InterfaceProxyGenerator.CreateInterfaceProxy <IUsrManager>(null); string respTxt = string.Empty; loginUsr = manager.Login(usr); if (null != loginUsr) { this.DialogResult = DialogResult.OK; } } catch (Exception e1) { string msg = e1.Message; MessageBox.Show(msg, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void enviarCorreoNewUsr(Usr user) { string qry = "SELECT REPLACE(Salt,'-','') SaltNoDash,* FROM [Usr] WHERE UserName = @UserName"; SqlCommand myCmd = new SqlCommand(qry); myCmd.Parameters.AddWithValue("@UserName", user.UserName); myCmd.CommandType = CommandType.Text; Sql myClsSql = new Sql(_conf); DataTable dt = myClsSql.cmdToDataTable(myCmd); string UserName = dt.Rows[0]["UserName"].ToString(); string FirstName = dt.Rows[0]["FirstName"].ToString(); string SaltNoDash = dt.Rows[0]["SaltNoDash"].ToString(); string Email = dt.Rows[0]["Email"].ToString(); string body = string.Empty; StreamReader reader = new StreamReader(_env.ContentRootPath + "/resources/eMailNewUser.html"); body = reader.ReadToEnd(); body = body.Replace("[[FirstName]]", FirstName); body = body.Replace("[[UserName]]", UserName); body = body.Replace("[[param1]]", SaltNoDash); body = body.Replace("[[param1]]", SaltNoDash); body = body.Replace("[[Company]]", "[[Company]]"); body = body.Replace("[[myUrl]]", "http://localhost:4200/user/validateEmail/"); enviarCorreoHTML(Email, "Verify you new Novamex account", body); }
private void btnAdd2List_Click(object sender, EventArgs e) { Goods goods = autxtNSupplyGoods.SelectedObj as Goods; if (null == goods) { if (!StringUtil.isEmpty(autxtNSupplyGoods.Term)) { DialogResult rslt = MessageBox.Show("无此商品!是否新增?", "操作结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (rslt == DialogResult.OK) { Usr usr = MainForm.usr; GoodsForm gForm = new GoodsForm(null, goodsManager, InterfaceProxyGenerator.CreateInterfaceProxy <ISubCatgManager>(usr)); gForm.ShowDialog(); } } return; } foreach (DataGridViewRow row in dtgvStockin.Rows) { long gId = StringUtil.Obj2Long(row.Cells[colGID.Name].Value); if (gId == goods.GID__PK) { MainForm.Warn("此商品已添加,请重新选择!"); autxtNSupplyGoods.clear(); return; } } int index = dtgvStockin.Rows.Add(); InitRow(index, goods); autxtNSupplyGoods.clear(); }
protected void Page_Load(object sender, EventArgs e) { Usr usr = (Usr)WebSession.LoginUsr; Usr usr1 = Master._usr.GetAll().FirstOrDefault(m => m.UsrId == usr.UsrId); BindDataListview(usr1.UsrId); }
public UsrForm(Usr usr, IUsrManager manager) { InitializeComponent(); this.manager = manager; if (null == usr) { Text = "注册用户"; rbtnValid.Enabled = false; rbnInvalid.Enabled = false; } else { Text = "修改用户"; txtUID.Enabled = false; uptFlag = true; rbtnValid.Enabled = true; rbnInvalid.Enabled = true; txtUID.Text = usr.UId__PK; txtUName.Text = usr.UName; txtQQ.Text = usr.QQ; txtTel.Text = usr.Tel; txtRmk.Text = usr.Remark; } }
internal Usr GetUserByLogin(string login) { using (SqlCommand selectUser = new SqlCommand()) { string prmName = "nickName"; selectUser.Connection = connection; selectUser.CommandType = CommandType.Text; selectUser.CommandText = "select id, psw, first_name, second_name, last_name, mail, extended_verification, use_mail_to_reports " + " from usr " + " where nick_name = @" + prmName + " "; selectUser.Parameters.Add(prmName, SqlDbType.VarChar, 50); selectUser.Parameters[prmName].Value = login; using (SqlDataReader reader = selectUser.ExecuteReader()) { if (reader.Read()) { usr = new Usr(); usr.id = reader.GetInt32(0); usr.nickName = login; usr.psw = reader.GetString(1); usr.firstName = reader.GetString(2); usr.secondName = reader.GetString(3); usr.lastName = reader.GetString(4); usr.mail = reader.GetString(5); usr.extendedVerification = string.Equals(reader.GetString(6), "Y", StringComparison.CurrentCultureIgnoreCase); usr.useMailToReports = string.Equals(reader.GetString(7), "Y", StringComparison.CurrentCultureIgnoreCase); } } return(usr); } }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = manager.Client; manager.CreateCommands("", commServ => { #region butthurt commServ.CreateCommand("butthurt") .Description("Sends specified user a butthurt report.") .Parameter("user", ParameterType.Unparsed) .Do(async(e) => { await e.Channel.SendMessage($"http://i.imgur.com/jhiVEpv.png"); await e.Channel.SendMessage($"{e.GetArg("user")} Please fill out this butthurt report."); }); #endregion #region info commServ.CreateCommand("info") .Description("Provides the sender with the servers info.") .Do(async(e) => { await e.Channel.SendMessage(Svr.getServerInfo(e)); }); #endregion #region uinfo commServ.CreateCommand("uinfo") .Description("Provides the sender with either their info or if specified another users info.") .Parameter("user", ParameterType.Unparsed) .Do(async(e) => { /*if (e.Args[0] == string.Empty) * { * } * else * { * await e.Channel.SendMessage(Usr.getUserInfo(Usr.getUser(e), e, false)); * }*/ if (e.Args[0] != string.Empty) { await e.Channel.SendMessage(Usr.getUserInfo(Usr.getUser(e), e, false)); } }); #endregion #region bot commServ.CreateCommand("bot") .Description("Sends the bot info to the user.") .Do(async(e) => { await e.User.PrivateChannel.SendMessage($@"**Xeno is created and maintained by ImPhantom** **Xeno is still in *ALPHA*, So expect issues.** **GitHub:** https://github.com/ImPhantom/Xeno **Downloads:** http://bot.xenorp.com/"); }); #endregion }); }
//sprawdzenie czy użytkownik o danej nazwie i mailu istnieje //jeśli tak - resetowanie hasła i wysłanie maila z nowym hasłem (automatycznie wygenerowany guid) protected void Sent_Click(object sender, EventArgs e) { string username = Username.Text; string email = mail.Text; bool validated = Usr.CheckUserByEmailAndName(username, email); if (!validated) { wrong.Visible = true; } else { string newpass = Guid.NewGuid().ToString(); try { if (Usr.SaveNewPassToDb(newpass, username)) { SendEmail(email, newpass); } } catch (Exception err) { HttpContext.Current.Trace.Write(err.Message); } } }
//metoda do zaznaczenia elementów z bazy danych usera w liscie rozwijanej (sport) protected void SelectCheckBox() { List <string> sporty = new List <string>(); string userid = Session["userid"].ToString(); sporty = Usr.GetSporty(userid); if (sporty.Count > 0) { CheckBoxList checkedListBox1 = (CheckBoxList)pnlCustomers.FindControl("cblCustomerList"); foreach (ListItem li in checkedListBox1.Items) { if (sporty.Contains(li.Text)) { li.Selected = true; } } } if (sporty.Count == 1) { divDDL.InnerText = "1 element"; } else if (sporty.Count < 5) { divDDL.InnerText = sporty.Count + " elementy"; } else { divDDL.InnerText = sporty.Count + " elementów"; } }
public async Task <IActionResult> PutUsr([FromRoute] int id, [FromBody] Usr usr) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != usr.IdUser) { return(BadRequest()); } _context.Entry(usr).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsrExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected void lbtnLuu_Click(object sender, EventArgs e) { Mstr mstr = (Mstr)AdminSession.LoginAdmin; Usr mstrUsr = Master.usr_BUS.GetAll().FirstOrDefault(m => m.UsrId == mstr.MstrId); Usr rs1 = (from c in Master.usr_BUS.GetAll() where c.UsrId == mstrUsr.UsrId select c).FirstOrDefault(); if (fupava.HasFile) { rs1.Avatar = fupava.FileName; } rs1.UsrName = txtUsrName.Text; rs1.Address = txtAddress.Text; rs1.Phone = txtPhone.Text; rs1.Email = txtEmail.Text; rs1.DateEdit = DateTime.Now; rs1.DateAdd = mstrUsr.DateAdd; rs1.Active = mstrUsr.Active; rs1.Login = mstrUsr.Login; rs1.Password = mstrUsr.Password; Master.usr_BUS.Update(rs1); Response.Redirect(Request.RawUrl); ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Cập nhật thành công')", true); }
public Tsk Get(string tskName) { Usr usr = _session.Get <Usr>(_userSession.UserId); var act = usr.Rol.SelectMany(x => x.Cat).SelectMany(y => y.Tsk).Where(z => z.Name == tskName).FirstOrDefault(); if (act != null) { return(act); } var rbc = usr.Rol.SelectMany(x => x.Cat).SelectMany(y => y.Tsk).Where(z => z.Name == tskName).FirstOrDefault(); if (rbc != null) { return(rbc); } var flwAct = usr.Rol.SelectMany(x => x.Cat).SelectMany(c => c.Flw).SelectMany(y => y.Tsk).Where(z => z.Name == tskName).FirstOrDefault(); if (flwAct != null) { return(flwAct); } var flwRbc = usr.Rol.SelectMany(x => x.Cat).SelectMany(c => c.Flw).SelectMany(y => y.Tsk).Where(z => z.Name == tskName).FirstOrDefault(); if (flwRbc != null) { return(flwRbc); } return(null); }
protected void lblThaydoi_Click(object sender, EventArgs e) { Usr usr = (Usr)WebSession.LoginUsr; Usr usr1 = Master._usr.GetAll().FirstOrDefault(m => m.UsrId == usr.UsrId); fupava.Visible = true; lbtnLuu.Visible = true; lbtnHuy.Visible = true; lblThaydoi.Visible = false; txtUsrName.Visible = true; txtPhone.Visible = true; txtAddress.Visible = true; txtEmail.Visible = true; txtUsrName.Text = usr1.UsrName; txtPhone.Text = usr1.Phone; txtEmail.Text = usr1.Email; txtAddress.Text = usr1.Address; lblUsrName.Visible = false; lblPhone.Visible = false; lblEmail.Visible = false; lblAddress.Visible = false; }
//POST : /api/User/Register public JsonResult addUser(Usr user) { try { string qry = "spUsrRegister"; SqlCommand myCmd = new SqlCommand(qry); myCmd.Parameters.AddWithValue("@pUserName", user.UserName); myCmd.Parameters.AddWithValue("@pPassword", user.Password); myCmd.Parameters.AddWithValue("@pFirstName", user.FirstName); myCmd.Parameters.AddWithValue("@pLastName", user.LastName); myCmd.Parameters.AddWithValue("@pEmail", user.Email); myCmd.CommandType = CommandType.StoredProcedure; Sql myClsSql = new Sql(_conf); DataTable dt = myClsSql.cmdToDataTable(myCmd); Msg myMsg = new Msg(); myMsg.ResponseMessage = dt.Rows[0]["responseMessage"].ToString(); myMsg.ResponseStatus = dt.Rows[0]["responseStatus"].ToString(); enviarCorreoNewUsr(user); return(new JsonResult(new { myResponseMessage = myMsg.ResponseMessage, myResponseStatus = myMsg.ResponseStatus })); } catch (Exception ex) { return(new JsonResult(new { myResponseMessage = ex.Message, myResponseStatus = "0" })); } }
public virtual IPrincipal GetPrincipal(Usr user, long tntId) { // TODO: Make any projects available var identity = new GenericIdentity(user.ULogin, Constants.SchemeTypes.Basic); List <Rol> rols = null; if (tntId != -1) { rols = user.Rol.Where(x => x.Tnt.Id == tntId).ToList(); } else { identity.AddClaim(new Claim(ClaimTypes.Role, Constants.RoleNames.Member)); } if (rols != null && rols.Count > 0) { rols.ForEach(x => identity.AddClaim(new Claim(ClaimTypes.Role, x.Name))); } if (identity.Claims != null) { identity.AddClaim(new Claim(ClaimTypes.SerialNumber, user.Id.ToString())); return(new ClaimsPrincipal(identity)); } else { return(null); } }
public void adduser(userinfo eh) { var uid = db.Usrs.Max(v => v.ID) + 1; Usr ei = new Usr(); Secur sr = new Secur(); UserRole ur = new UserRole(); ei.UserID = uid; ei.EmpID = eh.EmpID; var emp = db.EmpInfoes.Where(x => x.ID == eh.EmpID).FirstOrDefault(); emp.Usr = eh.UserName.Trim(); ei.UserName = eh.UserName.Trim(); ei.UserKey = sr.Encrypt(eh.UserKey.Trim()); ei.EntryKey = "000"; ei.Role = eh.Role; ei.Email = eh.Email; ei.Telephone = eh.Telephone; ei.IsActive = eh.IsActive; ei.ValidFrom = eh.ValidFrom; ei.CreatedBy = eh.Createby; ei.CreatedDate = DateTime.Today; ei.CreatedTime = DateTime.Now.TimeOfDay; ur.UserID = uid; ur.RoleID = eh.Role; ur.IsActive = eh.IsActive; ur.ValidFrom = DateTime.Today; ur.CreatedBy = eh.Createby; ur.CreatedDate = DateTime.Today; ur.CreatedTime = DateTime.Now.TimeOfDay; db.Usrs.Add(ei); db.SaveChanges(); db.UserRoles.Add(ur); db.SaveChanges(); }
protected void btnSignUp_Click(object sender, EventArgs e) { if (!IsValidRegister()) { return; } var usr = new Usr() { UsrId = MyLibrary.Usr_BUS.GetLastestId() + 1, UsrName = username.Value, Login = login.Value, Password = EncryptHelper.Encrypt(password.Value), DateAdd = DateTime.Now }; if (MyLibrary.Usr_BUS.IsExist(usr)) { lbStatus.InnerText = "Đã tồn tại"; return; } MyLibrary.Usr_BUS.Insert(usr); MyLibrary.Cus_BUS.Insert(new Cus() { CusId = usr.UsrId }); MyLibrary.Usr_BUS.CreateActCode(usr); Response.Redirect(Request.RawUrl); }
public async Task <ActionResult> Register(RegisterAdmin reg) { reg.Email.Trim(); AbzContext db = new AbzContext(); Usr user = new Usr(); user.Email = reg.Email; string Password = GenerateRandomPassword(6); user.Password = Password; user.UserId = Guid.NewGuid().ToString(); db.Users.Add(user); db.SaveChanges(); UserInCust uc = new UserInCust(); uc.CustID = reg.CustId; uc.UserId = user.UserId; uc.LastDat = DateTime.Now; uc.Email = reg.Email; //uc.Pwd = Password; db.UserInCusts.Add(uc); db.SaveChanges(); await EmailSend.EMailRegAsync(reg.Email, Password); return(RedirectToAction("Index", "Home")); }
public Scr Get(string scrName) { Usr usr = _session.Get <Usr>(_userSession.UserId); var act = usr.Rol.SelectMany(x => x.Cat).SelectMany(y => y.Tsk).Where(z => z.Action != null && z.Action.Name == scrName).Select(o => o.Action).FirstOrDefault(); if (act != null) { return(act); } var rbc = usr.Rol.SelectMany(x => x.Cat).SelectMany(y => y.Tsk).Where(z => z.Rback != null && z.Rback.Name == scrName).Select(o => o.Rback).FirstOrDefault(); if (rbc != null) { return(rbc); } var flwAct = usr.Rol.SelectMany(x => x.Cat).SelectMany(c => c.Flw).SelectMany(y => y.Tsk).Where(z => z.Action != null && z.Action.Name == scrName).Select(o => o.Action).FirstOrDefault(); if (flwAct != null) { return(flwAct); } var flwRbc = usr.Rol.SelectMany(x => x.Cat).SelectMany(c => c.Flw).SelectMany(y => y.Tsk).Where(z => z.Rback != null && z.Rback.Name == scrName).Select(o => o.Action).FirstOrDefault(); if (flwRbc != null) { return(flwRbc); } return(null); }
protected void Page_Load(object sender, EventArgs e) { var lpg = ((IObjCache)System.Web.HttpContext.Current.Cache.Get("Lpg")); var LoginP = ""; if (lpg == null) { LoginP = Usr.LoginPage(); } else { LoginP = lpg.Pages.Count() > 0 ? Usr.RUrl(lpg.Pages.First()) : Usr.LoginPage(); } StringBuilder sb = new StringBuilder(); sb.Append("<script language='javascript'>"); sb.Append("var x=alert('Acceso Denegado - Su Usuario no cuenta con los permisos Requeridos.');"); sb.Append("var r = confirm('Aceptar: Login - Cancelar: Pagina Anterior');"); sb.Append("if (r == true){window.location = '" + LoginP + "';}else{window.history.back(-1);}"); sb.Append("</script>"); if (!ClientScript.IsStartupScriptRegistered("JSScript")) { ClientScript.RegisterStartupScript(base.GetType(), "JSScript", sb.ToString()); } }
private bool checkUser() { bool retVal = true; using (var db = new CroceRossaEntities()) { Usr usr = db.Usr.FirstOrDefault(x => x.UsrNam.Equals(UserTextBox.Text.ToString())); if (usr == null) { retVal = false; } else { if (KriptoEntity.DecryptString(usr.UsrPsw) != PasswordBox.Password.ToString()) { retVal = false; } else { GlobalInfo.LoggedUser = usr.toUserEntity(); } } } return(retVal); }
protected void Page_Load(object sender, EventArgs e) { string userid = Session["userid"].ToString(); if (!IsPostBack) { try { FillWojewodztwo(); FillPlec(); FillDataUrodzin(); BuildCheckBox(); CheckWygladDropDownList(); FillWzrost(); FillWaga(); FillBMI(); BindOpis(); CreateImgControls(Usr.GetAllUserPictures(userid)); zlyImg.Text = ""; } catch (Exception ex) { HttpContext.Current.Trace.Write(ex.Message); } } }
//采购需求部门确认提交计划 待初审 public void SubmitPlan(IEnumerable <int> ids, int userID) { if (ids == null) { throw new ArgumentNullException(); } var dbcontext = ServiceProvider.GetDbcontext <IPurocumentDbcontext>(); ///之前改审核状态改漏了 值是对的 避免使用魔幻数值 if(dbcontext.PurchasingPlan.Count(c=>ids.Contains(c.ID) && c.Status!=1)>0) if (dbcontext.PurchasingPlan.Count(c => ids.Contains(c.ID) && c.Status != (int)EnumPurchasingPlanState.PlanDraft) > 0) { throw new Exception("采购计划状态不正确"); } var plans = dbcontext.PurchasingPlan.Where(w => ids.Contains(w.ID)).ToList(); int intDeparmentID = 0; string strCode = string.Empty; string strDateTime = string.Empty; //string result = isPass ? "通过" : $"未通过:Desc"; string title = string.Empty; string content = string.Empty; string toUsrID = string.Empty; foreach (var item in plans) { item.Status = item.Status + 1; item.UpdateUserID = userID; item.UpdateTime = DateTime.Now; strCode += item.Code + ' '; //为了通知 intDeparmentID = item.DepartmentID; //为了通知 strDateTime = item.UpdateTime.ToString(strMessageTimeFormat); } dbcontext.UpdateRange(plans); dbcontext.SaveChanges(); var toUsrs = dbcontext.Usr.Where(w => w.RoleID == (int)EnumRole.测试 || w.RoleID == (int)EnumRole.采购员 ).ToList(); Usr usr = dbcontext.Usr.SingleOrDefault(s => s.ID == userID); Department department = dbcontext.Department.SingleOrDefault(s => s.ID == intDeparmentID); var toUsrIDs = toUsrs.Select(s => s.WechatID); toUsrID = string.Empty; var toUserWechatIDs = toUsrs.Select(s => s.WechatID); toUsrID = string.Join("|", toUsrs.Select(s => s.WechatID).ToArray()); title = "待初审采购计划"; content = $"编号:{strCode} 部门:{department?.Name}"; MessageService.Post( toUsrID, title, strDateTime, content ); }
public void WhereColumnInStringArrayDoesntCauseFormattingExceptions() { string emailWithOpenBrace = "OpenBrace{@hotmail.com"; Usr u1 = new Usr {Email = emailWithOpenBrace}; u1.Update(); string emailWithCloseBrace = "CloseBrace}@hotmail.com"; Usr u2 = new Usr {Email = emailWithCloseBrace}; u2.Update(); UsrSet us = new UsrSet(new Query(new Q(Usr.Columns.Email, new[] {emailWithOpenBrace, emailWithCloseBrace})){OrderBy = new OrderBy(Usr.Columns.K)}); Assert.AreEqual(u1.K, us[0].K); Assert.AreEqual(u2.K, us[1].K); }
static void Main(string[] args) { Usr user = new Usr(); user.Longitude = ConvertToRadians(Double.Parse(Console.ReadLine().Replace(',', '.'))); user.Latitude = ConvertToRadians(Double.Parse(Console.ReadLine().Replace(',', '.'))); int Nb_defibrilator = int.Parse(Console.ReadLine()); List<DefPositionFromUsr> defibrilators = new List<DefPositionFromUsr>(); for (int i = 0; i < Nb_defibrilator; i++) { Defibrillator def = new Defibrillator(Console.ReadLine()); defibrilators.Add(new DefPositionFromUsr(def, user)); } defibrilators.Sort(); // Write an action using Console.WriteLine() // To debug: Console.Error.WriteLine("Debug messages..."); Console.WriteLine(defibrilators.First().Def.Name); }
public void UsrFavoursParentMusicType_BannerTargetsChild_BannerIsServed() { Usr u = new Usr(); u.Name = Guid.NewGuid().ToString(); u.Update(); MusicType parentMusicType = new MusicType() { ParentK = 1 }; parentMusicType.Update(); MusicType childMusicType = new MusicType() { ParentK = parentMusicType.K }; childMusicType.Update(); UsrMusicTypeFavourite umtf = new UsrMusicTypeFavourite() { MusicTypeK = parentMusicType.K, UsrK = u.K }; umtf.Update(); Banner b = new Banner() { IsMusicTargetted = true }; b.Update(); b.SaveMusicTargetting(new List<int>() { childMusicType.K }); MusicTypesFavouredByIdentityRule rule = new MusicTypesFavouredByIdentityRule(new UsrIdentity(u)); RequestRules rr = new RequestRules(); rr.MusicTypes = rule; ReadOnlyCollection<BannerDataHolder> results = rr.GetBannersSatsfyingQueryConditionsInTimeslot(Timeslots.GetCurrentTimeslot()); Assert.IsTrue(ContainsBanner(b.K, results)); }
public UsrIdentity(Usr u) : base() { this.Usr = u; this.Guid = u.Guid; }
private double GetDistanceFromUser(Defibrillator def, Usr user) { double x = (def.Longitude - user.Longitude) * Math.Cos((user.Latitude + def.Latitude) / 2); double y = def.Latitude - user.Latitude; return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)) * 6371; }
public DefPositionFromUsr(Defibrillator d, Usr user) { this.Def = d; this.Distance = GetDistanceFromUser(d, user); }
public void UsrFavoursOneMusicType_BannerTargetsAnother_BannerIsNotServed() { Usr u = new Usr(); u.Name = Guid.NewGuid().ToString(); u.Update(); MusicType musicTypeA = new MusicType() { ParentK = 1 }; musicTypeA.Update(); MusicType musicTypeB = new MusicType() { ParentK = 1 }; musicTypeB.Update(); UsrMusicTypeFavourite umtf = new UsrMusicTypeFavourite() { MusicTypeK = musicTypeA.K, UsrK = u.K }; umtf.Update(); Banner b = new Banner() { IsMusicTargetted = true }; b.Update(); BannerMusicType bmt = new BannerMusicType() { BannerK = b.K, MusicTypeK = musicTypeB.K }; bmt.Update(); MusicTypesFavouredByIdentityRule rule = new MusicTypesFavouredByIdentityRule(new UsrIdentity(u)); RequestRules rr = new RequestRules() { MusicTypes = rule }; ReadOnlyCollection<BannerDataHolder> results = rr.GetBannersSatsfyingQueryConditionsInTimeslot(Timeslots.GetCurrentTimeslot()); Assert.IsFalse(ContainsBanner(b.K, results)); }