static Bulletin AddAvitoByTemplate(Guid userId, BulletinTemplate template, string brand, string model, string modifier, string price, string groupHash) { var result = default(Bulletin); BCT.Execute(d => { var group = BCT.Context.BulletinDb.Groups.FirstOrDefault(q => q.Hash == groupHash); if (group == null) { ConsoleHelper.SendMessage($"AvitoPublicateBulletin => Группа с хэшем:{groupHash} не найдена"); return; } result = new Bulletin(); result.Brand = brand; result.Model = model; result.Modifier = modifier; result.GroupId = group.Id; result.Title = template.Title; result.Description = template.Description; result.Price = price; result.Images = template.Images; result.UserId = userId; result.StateEnum = BulletinState.Created; d.SaveChanges(); }); return(result); }
protected void Page_Load(object sender, EventArgs e) { using (LabBookDBDataContext LabDB = new LabBookDBDataContext()) { try { BulletinToDelete = LabDB.Bulletin.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["id"]); if (BulletinToDelete != null) { LabDB.Bulletin.DeleteOnSubmit(BulletinToDelete); LabDB.SubmitChanges(); //Response.Write("<script type=\"text/javascript\"> alert('删除成功!');</script>"); //Response.Write("<script type=\"text/javascript\"> window.location='BulletinManage.aspx'</script>"); Response.Write("1"); //return; //Response.Redirect("BulletinManage.aspx"); } } catch (Exception ex) { //Response.Write("<script type=\"text/javascript\"> alert('"+ex.Message+"');</script>"); //Response.Write("<script type=\"text/javascript\"> window.location='BulletinManage.aspx'</script>"); Response.Write("0"); //return; //Response.Redirect("BulletinManage.aspx"); } } }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(Bulletin model) { string sql = "insert into [dbo].[T_Bulletin] values (@UserName, @TypeId, @Title, @Content,default, default, @State)"; SqlParameter[] pms = { new SqlParameter("@UserName", SqlDbType.VarChar, 16) { Value = model.UserName }, new SqlParameter("@TypeId", SqlDbType.Int) { Value = model.TypeId }, new SqlParameter("@Title", SqlDbType.NVarChar, 64) { Value = model.Title }, new SqlParameter("@Content", SqlDbType.NVarChar) { Value = model.Content }, new SqlParameter("@State", SqlDbType.NVarChar, 6) { Value = model.State } }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pms)); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(Bulletin model) { string sql = "update [dbo].[T_Bulletin] set UserName=@UserName, TypeId=@TypeId, Title=@Title, Content=@Content, ReleaseTime=default, State=@State where Id=@id"; SqlParameter[] pms = { new SqlParameter("@UserName", SqlDbType.VarChar, 16) { Value = model.UserName }, new SqlParameter("@TypeId", SqlDbType.Int) { Value = model.TypeId }, new SqlParameter("@Title", SqlDbType.NVarChar, 64) { Value = model.Title }, new SqlParameter("@Content", SqlDbType.NVarChar) { Value = model.Content }, new SqlParameter("@State", SqlDbType.NVarChar, 6) { Value = model.State }, new SqlParameter("@id", SqlDbType.Int) { Value = model.Id } }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pms)); }
internal Eleve(string name, Classe classe) { this.Name = name; this.Classe = classe; Bulletin = new Bulletin(classe); Responsabilities = new List <Responsability>(); }
///------------------------------------------------------------------------------------------------- /// <summary> Gel children recursively. </summary> /// /// <remarks> SV Milovanov, 30.01.2018. </remarks> /// /// <param name="element"> The element. </param> /// <param name="bulletin"> The bulletin. </param> ///------------------------------------------------------------------------------------------------- void GelChildrenRecursively(HtmlElement element, Bulletin bulletin) { _DCT.Execute(data => { if (!element.CanHaveChildren && element.Children.Count == 0) { return; } foreach (HtmlElement ch in element.Children) { if (ch.TagName.ToLower() == "span" && ch.GetAttribute("className").Contains("profile-item-views-count")) { if (!string.IsNullOrEmpty(bulletin.Views)) { continue; } var regex = new Regex(@"(?<count>\d+)"); var match = regex.Match(ch.InnerText); if (match.Success) { bulletin.Views = match.Groups["count"].Value; } } if (ch.TagName.ToLower() == "a" && ch.GetAttribute("name").Contains("item_")) { bulletin.Url = ch.GetAttribute("href"); bulletin.Title = ch.InnerText; } GelChildrenRecursively(ch, bulletin); } }); }
/// <summary> /// 初始化按钮 /// </summary> public void initButton(BulletinWindow _win, Bulletin _bulletin) { this.fatherWindow = _win; this.bulletin = _bulletin; fawin = _win; showUI(); }
public ActionResult Update(Bulletin bulletin) { _bulletinService.Update(bulletin); //bulletinmembers tablosundaki bulten abonelerine yeni bülten girildiğinde mail gönderiyor--gönderici mail gmail olmak zorunda. List <Company> comp = _companyService.GetAll(); MailMessage mesajım = new MailMessage(); SmtpClient istemci = new SmtpClient(); //şifre istemci.Credentials = new System.Net.NetworkCredential(comp[0].EMail, "proBT1212"); istemci.Port = 587; istemci.Host = "smtp.gmail.com"; istemci.EnableSsl = true; List <BulletinMember> bulletinMembers = _bulletinMemberService.GetAll(); foreach (var item in bulletinMembers) { mesajım.To.Add(item.EMail); mesajım.From = new MailAddress(comp[0].EMail); mesajım.Subject = bulletin.Title; mesajım.Body = bulletin.ContentText; istemci.Send(mesajım); mesajım.To.Clear(); _bulletinMemberService.Update(item); } return(RedirectToAction("List", "Bulletin")); }
public ActionResult CreateBulletin(Bulletin bulletin) { if (System.Web.HttpContext.Current.Session["username"] != null) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connStrMrtTicketing"].ConnectionString); SqlCommand cmd = new SqlCommand("spInsertBulletin", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@newsTitle", bulletin.newsTitle); cmd.Parameters.AddWithValue("@newsDescription", bulletin.newsDescription); try { conn.Open(); cmd.ExecuteNonQuery(); } catch (Exception) { return(View()); } finally { conn.Close(); } return(RedirectToAction("viewBulletin", "Admin")); } else { return(RedirectToAction("Login", "Home")); } }
public async Task <IActionResult> GetEarliestBulletin() { var bulletins = await Executor.GetQuery <GetBulletinsQuery>().Process(q => q.ExecuteAsync()); var earliestBulletin = bulletins.OrderBy(b => b.PublishDate) .FirstOrDefault(b => b.PublishDate > DateTimeOffset.Now); if (earliestBulletin == null) { var latestBulletin = bulletins.OrderBy(b => b.PublishDate) .LastOrDefault(b => b.PublishDate <= DateTimeOffset.Now); var newPublishDate = latestBulletin?.PublishDate?.AddDays(7) ?? DateTimeOffset.Now.AddDays(7); earliestBulletin = new Bulletin { PublishDate = newPublishDate, }; Executor.GetHandler <GenerateBulletinNumberHandler>() .Process <string>(h => h.Execute(earliestBulletin)); var newbulletinId = await Executor.GetCommand <CreateBulletinCommand>() .Process(c => c.ExecuteAsync(earliestBulletin)); earliestBulletin = await Executor.GetQuery <GetBulletinByIdQuery>() .Process(q => q.ExecuteAsync(newbulletinId)); } var result = Mapper.Map <BulletinDto>(earliestBulletin); return(Ok(result)); }
public async Task <Bulletin> Bulletin_Create_With_Target(Guid faction_id) { HavenSDK sdk = this.GetHavenSDK(faction_id); List <BulletinCategory> categories = await sdk.BulletinCategories.GetBulletinCategoryForFactionAsync(faction_id, 0, 1).DemoUnPack(); Guid bulletin_category_id = categories.FirstOrDefault().bulletin_category_id; List <Term> terms = await sdk.Terms.GetActiveTermByFactionAsync(faction_id, 0, 1).DemoUnPack(); Guid term_id = terms.FirstOrDefault().term_id; Bulletin bulletin = this.CreateBulletinInstance(faction_id, bulletin_category_id); bulletin.title = "This is targeted to a term"; bulletin.scope = BulletinScope.Term; bulletin.term_id = term_id; // By Group //bulletin.scope = BulletinScope.Group; //bulletin.group_id = group_id; // by Principal //bulletin.scope = BulletinScope.Principal; //bulletin.principal_id = principal_id; bulletin = await sdk.Bulletin.CreateBulletinAsync(bulletin).DemoUnPack(); return(bulletin); }
public ActionResult _ShowBul(Bulletin bulletin) { var now = DateTime.Now; var data = db.Bulletins.Where(m => m.PublishEnd > now && m.PublishStart < now).OrderByDescending(p => p.PublishStart).ToList(); return(PartialView(data)); }
public ActionResult PreviewItem(Bulletin item, ActivityLinks links) { AddEntityIdentityForContext(item.Id); var viewModel = GetPreviewViewModel(item, links); return(PartialView(PreviewItemViewPath, viewModel)); }
public void SaveBulletin_Should_SaveToDatabase() { var options = new DbContextOptionsBuilder <EveCMContext>() .UseInMemoryDatabase(databaseName: "GetBulletin_Order") .Options; Bulletin bulletin = new Bulletin() { AuthorId = "1", Content = "TestContent", CreatedDate = DateTime.Now, Id = 1234, Title = "TestTitle" }; using (var context = new EveCMContext(options)) { IBulletinRepository bulletinRepository = new BulletinRepository(context); bulletinRepository.SaveBulletin(bulletin); } using (var context = new EveCMContext(options)) { Bulletin savedBulletin = context.Bulletins.Where(x => x.Id == bulletin.Id).First(); Assert.AreEqual(bulletin.Id, savedBulletin.Id); } }
static void Main(string[] args) { // rf out: info broadcasts // rf in: requests for updates, messaging // webserver: UI for control desk Connect(); Bulletin b = new Bulletin(); b.FreeText = "here is some free text"; b.List = new[] { "this", "is", "a", "list", "of", "strings" }; b.Originator = "M0LTE-control"; b.PageNo = 123; b.Produced = DateTimeOffset.Now; b.Table = new string[][] { new[] { "a1", "b1", "c1" }, new[] { "a2", "b2", "c2" }, new[] { "a3", "b3", "c3" }, }; b.Tags = new[] { "tag1", "tag2" }; b.Title = "bulletin title"; b.Validity = TimeSpan.FromMinutes(20); try { Send(b); } finally { cli.Dispose(); } }
public IList <Bulletin> GetBulletins(int bulletinID, string title, string content, int importanceID, string importanceName, int dayCount, int createPersonID, string employeeName, string orgName, DateTime createTime, string memo, int startRowIndex, int maximumRows, string orderBy) { IList <Bulletin> bulletins = new List <Bulletin>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_BULLETIN_S"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_start_row_index", DbType.Int32, startRowIndex); db.AddInParameter(dbCommand, "p_page_size", DbType.Int32, maximumRows); db.AddInParameter(dbCommand, "p_order_by", DbType.String, GetMappingOrderBy(orderBy)); db.AddOutParameter(dbCommand, "p_count", DbType.Int32, 4); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Bulletin bulletin = CreateModelObject(dataReader); bulletins.Add(bulletin); } } _recordCount = Convert.ToInt32(db.GetParameterValue(dbCommand, "p_count")); return(bulletins); }
public IList <Bulletin> GetBulletins(string title, int importanceID, string OrgName, string EmployeeName, DateTime beginTime, DateTime endTime, bool IsAdmin, int EmployeeID) { IList <Bulletin> bulletins = new List <Bulletin>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_BULLETIN_F"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_title", DbType.String, title); db.AddInParameter(dbCommand, "p_importance_id", DbType.Int32, importanceID); db.AddInParameter(dbCommand, "p_org_name", DbType.String, OrgName); db.AddInParameter(dbCommand, "p_employee_name", DbType.String, EmployeeName); db.AddInParameter(dbCommand, "p_begin_time", DbType.Date, beginTime); db.AddInParameter(dbCommand, "p_end_time", DbType.Date, endTime); db.AddInParameter(dbCommand, "p_is_admin", DbType.Boolean, IsAdmin); db.AddInParameter(dbCommand, "p_employee_id", DbType.Int32, EmployeeID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Bulletin bulletin = CreateModelObject(dataReader); bulletins.Add(bulletin); } } return(bulletins); }
public ActionResult viewBulletin() { if (System.Web.HttpContext.Current.Session["username"] != null) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connStrMrtTicketing"].ConnectionString); String sql = "SELECT * FROM Bulletin"; SqlCommand cmd = new SqlCommand(sql, conn); var model = new List <Bulletin>(); using (conn) { conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var bulletin = new Bulletin(); bulletin.newsID = Convert.ToInt32(rdr["newsID"]); bulletin.newsTitle = Convert.ToString(rdr["newsTitle"]); bulletin.newsDescription = Convert.ToString(rdr["newsDescription"]); bulletin.newsDate = Convert.ToDateTime(rdr["newsDate"]); model.Add(bulletin); } } return(View(model)); } else { return(RedirectToAction("Login", "Home")); } }
public IList <Bulletin> GetBulletins1() { IList <Bulletin> bulletins = new List <Bulletin>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_BULLETIN_S1"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddOutParameter(dbCommand, "p_count", DbType.Int32, 4); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Bulletin bulletin = CreateModelObject(dataReader); bulletins.Add(bulletin); } } _recordCount = Convert.ToInt32(db.GetParameterValue(dbCommand, "p_count")); return(bulletins); }
public DecryptedBulletin[] decryptBulletins(Bulletin[] bulletins) { BigInteger p = new BigInteger(config.ElGamalKey["p"]); BigInteger g = new BigInteger(config.ElGamalKey["g"]); BigInteger y = new BigInteger(config.ElGamalKey["y"]); BigInteger x = new BigInteger(config.ElGamalKey["x"]); BigInteger r = new BigInteger(RandomIntegerBelow(p.ToString())); //BigInteger r = new BigInteger("4563050602903359928056136975567095439379627199326955519680189688036774281410041321175819876909720647804719670824093616183296383061532044666546235933833472251673096343116272450105539664054763234915223028670551431957859529693271468403314305086392727648853573440577217245464756227189485983502306986972904963448440312549274813331835503711865774776771198609402798831076618538230001307631055581113010460275058655927320575339606013306989068574111583648443543871675889493183316705825816481846124482880599335932066798851139920051066669702619878112698138668324247383153274909065532392098208265789989366961315859898840554496025"); DecryptedBulletin[] decryptedBulletins = new DecryptedBulletin[bulletins.Length]; for (int i = 0; i < bulletins.Length; i++) { Bulletin bulletin = bulletins[i]; BigInteger a = new BigInteger(bulletin.Data.a); BigInteger b = new BigInteger(bulletin.Data.b); BigInteger aBlind = g.ModPow(r, p).Multiply(a).Remainder(p); BigInteger ax = aBlind.ModPow(x, p); BigInteger plaintextBlind = ax.ModInverse(p).Multiply(b).Remainder(p); BigInteger plainText = y.ModPow(r, p).Multiply(plaintextBlind).Remainder(p); var str = System.Text.Encoding.Default.GetString(plainText.ToByteArray()); DecryptedBulletin decryptedBulletin = new DecryptedBulletin(); decryptedBulletin.votes = JsonConvert.DeserializeObject <List <DecryptedVote> >(str); decryptedBulletins[i] = decryptedBulletin; } return(decryptedBulletins); }
public async Task <IHttpActionResult> AddBulletin(NewBulletin newBulletin) { if (newBulletin == null) { return(Content(HttpStatusCode.NotFound, "Входные параметры должны быть заданы!")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //var user = await db.Users.FirstOrDefaultAsync(usEx => usEx.UserId == newBulletin.UserId); var bulletin = new Bulletin() { BullCreateDateTime = newBulletin.BullCreateDateTime, BullEditDateTime = newBulletin.BullEditDateTime, BullTxt = newBulletin.BullTxt, BullRate = newBulletin.BullRate, UserId = newBulletin.UserId //UserRelation = user }; db.Bulletins.Add(bulletin); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = bulletin.BullId }, bulletin)); }
/// <summary> /// Gets the bulletin by its id. /// </summary> /// <param name="id">The bulletin id.</param> /// <returns> /// a bulletin /// </returns> public Bulletin GetById(int id) { Bulletin bulletin = null; var bulletinList = new List <Bulletin>(); using (var connection = new SqlConnection(DbConnection)) { using (var command = new SqlCommand("PaBulletinGetById", connection)) { var sqlParams = new List <SqlParameter>(); var paramReturnValue = new SqlParameter("@return_value", SqlDbType.Int) { Direction = ParameterDirection.ReturnValue }; sqlParams.Add(paramReturnValue); SqlHelper.AddIntPara(id, "@BulletinId", sqlParams); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddRange(sqlParams.ToArray()); connection.Open(); LoadBulletinList(bulletinList, command); if (bulletinList.Count > 0) { bulletin = bulletinList[0]; } } } return(bulletin); // as T; }
public ActionResult Create(Bulletin model) { if (!CanEdit) { return(RedirectToNoAccessAction()); } if (ModelState.IsValid) { if (!string.IsNullOrWhiteSpace(model.ProjectField)) { // check if project is valid var project = PatService.GetProject(model.ProjectId); if (project == null) { AddErrorMessage("ProjectField", string.Format("Project Id: {0} not found. Please use a valid project", model.ProjectId)); return(View(model)); } } model.CreatedBy = User.Identity.Name.RemoveDomain(); var newID = PatService.CreateBulletin(model); if (newID > 0) { // DR01039391; The Bulletin/FAQ has been successfully submitted. TempData[CommonConstants.FlashMessageTypeInfo] = string.Format(@"The Bulletin/ FAQ has been successfully submitted: {0}", model.BulletinTitle); return(RedirectToAction("Index", "Home", new { bulletinType = model.BulletinType })); } TempData[CommonConstants.FlashMessageTypeError] = string.Format(@"The Bulletin/ FAQ submission was failed: {0}. Please try again.", model.BulletinTitle); } return(View(model)); }
public ActionResult FeedItem(Bulletin item, ActivityFeedOptionsWithGroups options) { BulletinExtendedItemViewModel extendedModel = GetItemViewModel(item, options); AddEntityIdentityForContext(item.Id); return(PartialView(ItemViewPath, extendedModel)); }
public async Task <dynamic> OnUpdateBulletinAsync([FromForm] Bulletin bulletin, [FromForm] string token) { try { var t = await tokenService.GetTokenAsync(token); if (t == null) { throw new Exception("请先登录"); } if (t.Role != UserRole.Admin) { if (t.Role == UserRole.Student) { throw new Exception("权限不足"); } var uc = await courseService.GetUserCourseAsync(t.UserID, bulletin.CourseId); if (uc == null) { throw new Exception("权限不足"); } } await courseService.UpdateBulletinAsync(bulletin); return(new { Res = true }); } catch (Exception e) { return(new { Res = false, Error = e.Message }); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,ElectionId,CityId,CandidateId")] Bulletin bulletin) { if (id != bulletin.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bulletin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BulletinExists(bulletin.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CandidateId"] = new SelectList(_context.Candidate, "Id", "PreelectionProgram", bulletin.CandidateId); ViewData["CityId"] = new SelectList(_context.City, "Id", "City1", bulletin.CityId); ViewData["ElectionId"] = new SelectList(_context.Election, "Id", "Id", bulletin.ElectionId); return(View(bulletin)); }
private void ShowBulletinById(uint id) { Bulletin bulletin = Singleton <BulletinModule> .Instance.TryGetBulletinByID(id); if ((bulletin != null) && (((ShowType)bulletin.get_type()) == this._showType)) { this._selectIdDict[this._showType] = id; base.view.transform.Find("Dialog/Content/TitleBtnList/ScrollView").GetComponent <MonoGridScroller>().RefreshCurrent(); Transform transform = base.view.transform.Find("Dialog/Content/OneNotice/ScrollView/Content"); string str = bulletin.get_banner_path(); Image component = transform.Find("Image/Pics").GetComponent <Image>(); bool flag = !string.IsNullOrEmpty(str) && UIUtil.TrySetupEventSprite(component, str); transform.Find("Image").gameObject.SetActive(flag); if (flag) { LayoutElement element = transform.Find("Image").GetComponent <LayoutElement>(); Rect rect = transform.Find("Image/Pics").GetComponent <Image>().sprite.rect; element.preferredHeight = rect.height; element.preferredWidth = rect.width; } transform.Find("Title/Text").GetComponent <Text>().text = bulletin.get_title(); if (bulletin.get_event_date_str() == string.Empty) { transform.Find("Title/Time").gameObject.SetActive(false); } else { transform.Find("Title/Time").gameObject.SetActive(true); transform.Find("Title/Time").GetComponent <Text>().text = bulletin.get_event_date_str(); } transform.Find("Body").GetComponent <MonoBulletinBody>().SetupView(UIUtil.ProcessStrWithNewLine(bulletin.get_content())); base.view.transform.Find("Dialog/Content/OneNotice/ScrollView").GetComponent <ScrollRect>().verticalNormalizedPosition = 1f; } }
private static List <Caution> CreateBulletions(string userCode) { List <Caution> list = new List <Caution>(); StringBuilder builder = new StringBuilder(); builder.Append("SELECT * FROM v_bulletin_list").AppendLine(); builder.Append("WHERE DTM_EXPRIESDATE > DATEADD(DAY, -1, GETDATE())").AppendLine(); builder.Append("\tAND AUDITSTATE = 1").AppendLine(); builder.Append("\tAND NOT EXISTS ( ").AppendLine(); builder.Append("\t\tSELECT * FROM PopupRecord ").AppendLine(); builder.Append("\t\tWHERE PopupId = CAST(I_BULLETINID AS nvarchar(50)) AND UserCode = @userCode").AppendLine(); builder.Append("\t)").AppendLine(); builder.Append("ORDER BY DTM_RELEASETIME DESC").AppendLine(); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@userCode", userCode) }; foreach (DataRow row in SqlHelper.ExecuteQuery(CommandType.Text, builder.ToString(), commandParameters).Rows) { Bulletin item = new Bulletin { Id = row["I_BULLETINID"].ToString(), Module = PopupParam.Bulletin, Title = row["V_TITLE"].ToString(), Content = StringUtility.StripTagsCharArray(row["V_CONTENT"].ToString()), HandleUrl = PopupParam.BulletinHandleUrl }; list.Add(item); } return(list); }
public void Renew(int currentCycle) { Bulletin pick = null; List <Bulletin> newList = new List <Bulletin>(); foreach (Bulletin bulletin in bulletinList) { if (pick == null && bulletin.minCycle <= currentCycle) { pick = bulletin; continue; } newList.Add(bulletin); } if (pick == null) { // No more bulletins, let's reload LoadBulletins(); return; } currentBulletin = pick; bulletinList = newList; if (GameManager.instance.soundManager != null) { GameManager.instance.soundManager.Play("BulletinPop"); } }
private void AddButton_OnClick(object sender, RoutedEventArgs e) { if (TitleTextBox.Text == string.Empty) { WarningLabel.Content = "Title is empty"; return; } if (ContentTextBox.Text == string.Empty) { WarningLabel.Content = "Content is empty"; return; } if (ImagePathTextBox.Text == string.Empty) { WarningLabel.Content = "Image path is empty"; return; } if (!_client.Connected) { return; } var bulletin = new Bulletin(ImagePathTextBox.Text, ContentTextBox.Text, TitleTextBox.Text); _client.AddBulletin(bulletin); _bulletins.Insert(0, bulletin); WarningLabel.Content = string.Empty; }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { try { BulletinToModify = LabDB.Bulletin.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["id"]); if (BulletinToModify == null) { Response.Write("<script type=\"text/javascript\"> alert('错误!该公告不存在!');</script>"); } } catch (Exception ex) { Response.Write("<script type=\"text/javascript\"> alert('错误!" + ex.Message + "');</script>"); } } if (Request.HttpMethod == "POST") { if (Request.Form["Title"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('公告标题不能为空!');</script>"); return; } if (Request.Form["Bulletiner"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('发布人不能为空!');</script>"); return; } if (Request.Form["editorValue"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('公告内容不能为空!');</script>"); return; } try { BulletinToModify.Title = Request.Form["Title"].Trim(); BulletinToModify.Bulletiner = Request.Form["Bulletiner"]; BulletinToModify.Content = Request.Form["editorValue"]; BulletinToModify.Date = DateTime.Now; LabDB.SubmitChanges(); } catch (Exception ex) { Response.Write("<script type=\"text/javascript\"> alert('" + ex.Message + "');</script>"); return; } Response.Redirect("../Bulletin.aspx?id="+BulletinToModify.Id); } }
//protected string Message = ""; protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "POST") { if (Request.Form["Title"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('公告标题不能为空!');</script>"); return; } if (Request.Form["Bulletiner"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('发布人不能为空!');</script>"); return; } if (Request.Form["editorValue"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('公告内容不能为空!');</script>"); return; } try { Bulletin bulletin = new Bulletin { Title = Request.Form["Title"].Trim(), Bulletiner = Request.Form["Bulletiner"].Trim(), Content = Request.Form["editorValue"], Date = DateTime.Now, }; using (LabBookDBDataContext LabDB = new LabBookDBDataContext()) { LabDB.Bulletin.InsertOnSubmit(bulletin); LabDB.SubmitChanges(); } Response.Redirect("../Bulletin.aspx?id="+bulletin.Id); } catch (Exception ex) { Response.Write("<script type=\"text/javascript\"> alert('" + ex.Message + "');</script>"); return; } } }
void LoadBoard() { var baseControl = new Control(); baseControl.ID = "base_board_control"; baseControl.Controls.Add(new LiteralControl("<div class=\"panel-group\" id=\"accordion\">")); int i = 0; foreach (var l in CampusClient.DeskGetActualBulletins(CurrentUser.UserAccountId).Reverse()) { var ss = l; string s = l.Subject; string t = l.Text; int id = l.BulletinId; var b1 = new ImageButton(); b1.ImageUrl = "/Images/delete.png"; b1.AlternateText = "Вид"; b1.ID = "b1_" + i; b1.Click += (source, args) => { CampusClient.DeskRemoveBulletin(id); ResetBoard(); }; var b2 = new ImageButton(); b2.ImageUrl = "/Images/edit.png"; b2.AlternateText = "Ред"; b2.ID = "b2_" + i; b2.Click += (source, args) => { CurrentBulletin = l; _baseControl.Visible = false; _editControl.Visible = true; ((TextBox)_editControl.FindControl("board_edit_subject")).Text = l.Subject; ((TextBox)_editControl.FindControl("board_edit_text")).Text = l.Text; var profDrop = ((DropDownList)_editControl.FindControl("board_prof_drop")); _allowedProfile.ForEach(a => profDrop.Items.Add(a.Name)); profDrop.SelectedValue = (l.LinkList[0].ProfileId != null) ? _allowedProfile.Find(a => a.Id == l.LinkList[0].ProfileId).Name : "Всі профайли"; /* var facultyDrop = ((DropDownList) _editControl.FindControl("board_faculty_drop")); _faculties.ForEach(a => facultyDrop.Items.Add(a.Name)); facultyDrop.SelectedValue = (l.LinkList[0].SubdivisionId != null) ? _faculties.Find(a => a.Id == l.LinkList[0].SubdivisionId).Name : "Всі факультети"; */ }; b1.Attributes["style"] = "float: left; margin-right: 5px;"; b2.Attributes["style"] = b1.Attributes["style"]; if (l.CreatorId == CurrentUser.UserAccountId) { baseControl.Controls.Add(b1); baseControl.Controls.Add(b2); } string header = "<table class=\"header-table\"><tr><td rowspan=\"2\"><div style=\"text-align: left;\">" + l.Subject + "</div></td>" + "<td><div style=\"text-align: right;\">" + l.CreationDate + "(Дата створення)</div></td></tr>" + "<tr>" + "<td><div style=\"text-align: right;\">публікатор " + l.CreatorName + "</div></td></tr></table>"; string txt = "<div class=\"panel panel-default\" style=\"margin: 10px 0px 10px 0px;\"> " + "<div class=\"panel-heading\" data-toggle=\"collapse\" data-parent=\"#accordion\" data-target=\"#collapse" + i + "\">" + "<h4 class=\"panel-title\">" + header + "</h4>" + "</div>" + "<div id=\"collapse" + i + "\" class=\"panel-collapse collapse \">" + "<div class=\"panel-body\">" + l.Text + "</div></div></div>"; baseControl.Controls.Add(new LiteralControl(txt)); i++; } baseControl.Controls.Add(new LiteralControl("</div>")); _baseControl = baseControl; ActualBulletinDiv.Controls.Add(baseControl); var editControl = new Control(); editControl.ID = "edit_board_control"; var box1 = new TextBox(); box1.ID = "board_edit_subject"; box1.Width = 780; var box2 = new TextBox(); box2.ID = "board_edit_text"; box2.Width = 780; box2.Height = 300; box2.TextMode = TextBoxMode.MultiLine; var box3 = new TextBox(); box3.ID = "dateStart_d_text"; box3.Width = 30; var box4 = new TextBox(); box4.ID = "dateStart_m_text"; box4.Width = 30; var box5 = new TextBox(); box5.ID = "dateStart_y_text"; box5.Width = 50; var box6 = new TextBox(); box6.ID = "dateEnd_d_text"; box6.Width = 30; var box7 = new TextBox(); box7.ID = "dateEnd_m_text"; box7.Width = 30; var box8 = new TextBox(); box8.ID = "dateEnd_y_text"; box8.Width = 50; var button1 = new Button(); button1.ID = "board_edit_button"; button1.Text = "Зберегти"; button1.Click += ((sender, eventArgs) => { CampusClient.DeskUpdateBulletein( CurrentUser.UserAccountId, CurrentUser.FullName, ((TextBox)_editControl.FindControl("board_edit_subject")).Text, ((TextBox)_editControl.FindControl("board_edit_text")).Text, CurrentBulletin.BulletinId, CurrentBulletin.LinkList.ConvertToString() ); ResetBoard(); }); var button2 = new Button(); button2.ID = "board_cancel_button"; button2.Text = "Відміна"; button2.Click += ((sender, eventArgs) => { _editControl.Visible = false; _baseControl.Visible = true; }); var button3 = new Button(); button3.ID = "useless_button"; button3.Text = "Вибрати"; var uselessDropDown = new DropDownList(); uselessDropDown.ID = "useless_drop_down"; var prof = new DropDownList(); prof.ID = "board_prof_drop"; //editControl.Controls.Add(prof); editControl.Controls.Add(new LiteralControl("<div class=\"form-horizontal\">" + "<div class=\"form-group\">" + "<label class=\"col-sm-2 control-label\">Профіль</label>" + "<div class=\"col-sm-8\">")); editControl.Controls.Add(prof); editControl.Controls.Add(button3); editControl.Controls.Add(new LiteralControl( "</div>" + "</div>" + "</div>")); editControl.Controls.Add(new LiteralControl("<div class=\"form-horizontal\">" + "<div class=\"form-group\">" + "<label class=\"col-sm-2 control-label\">Отримувачи:</label>" + "<div class=\"col-sm-8\">")); editControl.Controls.Add(new LiteralControl( "</div>" + "</div>" + "</div>")); editControl.Controls.Add(new LiteralControl("<div class=\"form-horizontal\">" + "<div class=\"form-group\">" + "<label class=\"col-sm-2 control-label\">Тема</label>" + "<div class=\"col-sm-8\">")); editControl.Controls.Add(box1); editControl.Controls.Add(new LiteralControl( "</div>" + "</div>" + "</div>")); editControl.Controls.Add(new LiteralControl("<div class=\"form-horizontal\">" + "<div class=\"form-group form-inline\">" + "<label class=\"col-sm-2 control-label\">Період показу</label>" + "<div class=\"col-sm-8\"> Початок: ")); editControl.Controls.Add(box3); editControl.Controls.Add(new LiteralControl(" - ")); editControl.Controls.Add(box4); editControl.Controls.Add(new LiteralControl(" - ")); editControl.Controls.Add(box5); editControl.Controls.Add(new LiteralControl("Завершення: ")); editControl.Controls.Add(box6); editControl.Controls.Add(new LiteralControl(" - ")); editControl.Controls.Add(box7); editControl.Controls.Add(new LiteralControl(" - ")); editControl.Controls.Add(box8); editControl.Controls.Add(new LiteralControl( "</div>" + "</div>" + "</div>")); editControl.Controls.Add(new LiteralControl("<div class=\"form-horizontal\">" + "<div class=\"form-group\">" + "<label class=\"col-sm-2 control-label\">Текст</label>" + "<div class=\"col-sm-8\">")); editControl.Controls.Add(box2); editControl.Controls.Add(new LiteralControl( "</div>" + "</div>" + "</div>")); editControl.Controls.Add(new LiteralControl("<br>")); editControl.Controls.Add(new LiteralControl("<div class=\"form-horizontal\">" + "<div class=\"form-group\">" + "<label class=\"col-sm-9 control-label\"></label>" + "<div class=\"col-sm-3 pull-right\">")); editControl.Controls.Add(button1); editControl.Controls.Add(button2); editControl.Controls.Add(new LiteralControl( "</div>" + "</div>" + "</div>")); editControl.Visible = false; _editControl = editControl; ActualBulletinDiv.Controls.Add(editControl); }