public IHttpActionResult UpdateAttachment(int id, int attId, [FromBody] Attachement attachment) { if ((attachment == null) || (attachment.MailId != id) || (attachment.Id != attId)) { return(BadRequest()); } var attachementToUpdate = _attachementRepository.GetAll().FirstOrDefault(x => (x.MailId == id) && (x.Id == attId)); if (attachementToUpdate == null) { return(BadRequest()); } IHttpActionResult answerHttpActionResult; if (_attachementRepository.GetById(id) == null) { answerHttpActionResult = Created("/api/mails/" + id + "/attachments/" + attachment.Id, attachment); } else { answerHttpActionResult = Ok(attachment); } var isSuccess = _attachementRepository.Update(attachment); _unit.Save(); return(!isSuccess?InternalServerError() : answerHttpActionResult); }
public Attachement getAttachmentByID(int cardId, int attachmentID) { Card card = context.Cards.Find(n => n.CId == cardId).First(); Attachement attachement = card.Attachements.Find(n => n.AttachementId == attachmentID); return(attachement); }
internal static void CreateAttachment(int mailId, Attachement attachement) { FindMail(mailId); // <- to throw exception if not exist such mail attachement.Id = _attachements.Count() + 1; _attachements.Add(attachement); }
void BindForm(int id) { WR_Rule model = bll.GetModel(id); if (model == null) { Response.Redirect("RuleList.aspx", false); } lblID.Text = model.ID.ToString(); txtPublishDate.Value = model.Publish_Date.HasValue ? model.Publish_Date.Value.ToString("yyyy-MM-dd") : ""; ddlCategory.SelectedValue = model.Category_ID.ToString(); txtTitle.Text = model.Title; txtSummary.Text = model.Summary; //获取附件 List <WR_Attachment> items = new Attachement().GetListByRuleId(model.ID); List <AttachmentItem> attachmentItems = (from p in items select new AttachmentItem { Attachment_ID = p.Attachment_GUID, Created_On = p.Created_On, FileName = p.FileName, FileSize = p.FileSize, FilePath = p.FilePath }).ToList(); ViewState["Attachments"] = attachmentItems; rptAttachment.DataSource = attachmentItems; rptAttachment.DataBind(); }
public HttpResponseMessage GetAttachmentToMail(int id, int attId) { Attachement gettingAttachement = FindAttachmentToMail(id, attId); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, gettingAttachement); return(response); }
public void createAttachment(int cardID, Attachement attachement) { var filter = Builders <Card> .Filter.Eq(c => c.CId, cardID); var update = Builders <Card> .Update.Push(c => c.Attachements, attachement); context.Cards.FindOneAndUpdate(filter, update); }
public ActionResult DeleteConfirmed(int id) { Attachement attachement = db.Attachements.Find(id); db.Attachements.Remove(attachement); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult Post(long id, [FromBody] Attachement model) { if (model == null || !ModelState.IsValid) { return(BadRequest()); } model.Id = attachs[attachs.Count - 1].Id + 1; attachs.Add(model); return(CreatedAtRoute("GetAttachmentById", new { attId = model.Id }, model)); }
public HttpResponseMessage Put(int id, int attId, Attachement attachement) { bool isSuccessfulUpdate = _attachementRepository.Update(id, attId, attachement); if (!isSuccessfulUpdate) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public IHttpActionResult Post(int id, [FromBody] Attachement attachement) { if (attachement == null) { return(BadRequest("Attachement is null")); } DbFake.Attachements.Add(attachement); return(Ok()); }
private void mnuProcess_Mail_Click(object sender, EventArgs e) { string sBody = "Hello Yolanda Xie,\r\n" + "\r\n" + "Thank you for purchasing Naurtech software. Here are the registration keys for your software licenses. Please note that both the License ID and Registration keys are case sensitive. You can find instructions to manually register your license at:\r\n" + "http://www.naurtech.com/wiki/wiki.php?n=Main.TrainingVideoManualRegistration\r\n" + "\r\n" + " Order Number: 15109\r\n" + " Order Date: 4/10/2014\r\n" + " Your PO Number: PO93504\r\n" + " End Customer: Honeywell\r\n" + " Product: [NAU-1504] CETerm for Windows CE 6.0 / 5.0 / CE .NET\r\n" + " Quantity: 46\r\n" + "\r\n" + " Qty Ordered...............: 46\r\n" + " Qty Shipped To Date.......: 46\r\n" + "\r\n" + " Qty Shipped in this email.: 46\r\n" + "\r\n" + "\r\n" + "**** Registration Keys for Version 5.7 ***** \r\n" + "\r\n" + "\r\n" + "Version 5.1 and above support AUTOMATED LICENSE REGISTRATION. Please use the attached license file. This prevents you from having to type each key to register your copy of the software. Please refer to support wiki article http://www.naurtech.com/wiki/wiki.php?n=Main.AutoRegistration\r\n" + ""; string testFile = utils.helpers.getAppPath() + "LicenseXMLFileSample.xml"; System.IO.MemoryStream ms = new System.IO.MemoryStream(); //read file into memorystream using (System.IO.FileStream file = new System.IO.FileStream(testFile, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { byte[] bytes = new byte[file.Length]; file.Read(bytes, 0, (int)file.Length); ms.Write(bytes, 0, (int)file.Length); ms.Flush(); } Attachement[] atts = new Attachement[] { new Attachement(ms, "test.xml") }; MailMessage msg = new MailMessage("E841719", sBody, "License Keys - Order: 15476: [NAU-1504] CETerm for Windows CE 6.0 / 5.0 / CE .NET", atts, DateTime.Now); this.Cursor = Cursors.WaitCursor; this.Enabled = false; Application.DoEvents(); int i = _licenseMail.processMail(msg); this.Enabled = true; this.Cursor = Cursors.Default; Application.DoEvents(); //setLblStatus("Updated data. Use refresh"; doRefresh(); }
public async Task <IHttpActionResult> GetAttachement(string id) { Attachement attachement = attachmentService.GetById(id); if (attachement == null) { return(NotFound()); } return(Ok(attachement)); }
public HttpResponseMessage AddAttachment(int id, Attachement attachement) { if (ModelState.IsValid) //<- needing add attributes for attachment in class definition { CreateAttachment(id, attachement); return(new HttpResponseMessage(HttpStatusCode.Created)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public IHttpActionResult Put(int id, int attId, [FromBody] Attachement attachement) { if (attachement == null) { return(BadRequest("Attachement is null")); } var entity = DbFake.Attachements.Find(x => x.MailId == id && x.Id == attId); _mapper.Map(attachement, entity); return(Ok()); }
public bool updateAttachment(int cardID, int attachmentID, Attachement attachement) { //Card card = context.Cards.Find(n => n.CId == cardID).First(); //Attachement attachement1 = card.Attachements.First(n => n.AttachementId == attachement.AttachementId); var filter = Builders <Card> .Filter.Eq(n => n.CId, cardID); var update = Builders <Card> .Update.Set(e => e.Attachements.Find(n => n.AttachementId == attachmentID), attachement); var result = context.Cards.UpdateOneAsync(filter, update).Result; return(result.IsAcknowledged && result.ModifiedCount > 0); }
public bool removeAttachment(int cardId, int attachmentID) { Card card = context.Cards.Find(n => n.CId == cardId).First(); Attachement attachement = card.Attachements.Find(n => n.AttachementId == attachmentID); var filter = Builders <Card> .Filter.Eq(n => n.CId, cardId); var update = Builders <Card> .Update.Pull(e => e.Attachements, attachement); var updatedResult = context.Cards.UpdateOneAsync(filter, update).Result; return(updatedResult.IsAcknowledged && updatedResult.ModifiedCount > 0); }
public HttpResponseMessage Post(int id, Attachement attachement) { if (id != attachement.MailId) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } if (_attachementRepository.Add(attachement)) { return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.InternalServerError)); }
public ActionResult Edit([Bind(Include = "Id,UserId,TicketId,FileName,UpLoaded,Description,DateAttached,FileUNQName")] Attachement attachement) { if (ModelState.IsValid) { db.Entry(attachement).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", attachement.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "Name", attachement.UserId); return(View(attachement)); }
public async Task <IHttpActionResult> PostAttachement(Attachement attachement) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } attachmentService.Add(attachement); attachmentService.CommitAsync(); return(CreatedAtRoute("DefaultApi", new { id = attachement.AttachementId }, attachement)); }
// GET: Attachements/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Attachement attachement = db.Attachements.Find(id); if (attachement == null) { return(HttpNotFound()); } return(View(attachement)); }
public async Task <IHttpActionResult> DeleteAttachement(string id) { Attachement attachement = attachmentService.GetById(id); if (attachement == null) { return(NotFound()); } attachmentService.Delete(attachement); attachmentService.CommitAsync(); return(Ok(attachement)); }
internal static Attachement FindAttachmentToMail(int mailId, int attachmentId) { FindMail(mailId); // <- to throw exception if not exist such mail Attachement searchingAttachement = _attachements.FirstOrDefault(a => a.MailId == mailId && a.Id == attachmentId); if (searchingAttachement == null) { throw new NoExistItemException("Attachment", attachmentId); } return(searchingAttachement); }
public HttpResponseMessage UpdateAttachment(int id, int attid, Attachement updatedAttachement) { if (ModelState.IsValid) { Attachement oldAttachement = FindAttachmentToMail(id, attid); var mapper = new MapperConfiguration(cfg => cfg.CreateMap <Attachement, Attachement>()).CreateMapper(); // I prefer to use automapper to update fields of mail mapper.Map(updatedAttachement, oldAttachement); oldAttachement.Id = attid; return(new HttpResponseMessage(HttpStatusCode.NoContent)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public IHttpActionResult CreateAttachment(int id, [FromBody] Attachement attachment) { if ((attachment == null) || (id != attachment.MailId)) { return(BadRequest()); } var isSuccess = _attachementRepository.Add(attachment); _unit.Save(); if (!isSuccess) { return(BadRequest()); } return(Created("/api/mails/" + id + "/attachments/" + attachment.Id, attachment)); }
// GET: Attachements/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Attachement attachement = db.Attachements.Find(id); if (attachement == null) { return(HttpNotFound()); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", attachement.TicketId); ViewBag.UserId = new SelectList(db.Users, "Id", "Name", attachement.UserId); return(View(attachement)); }
public PostWebServiceResponse UploadMultipleAttachments(Attachement at, List <string> fileNames, List <byte[]> filesData, Dictionary <string, string> Headers = null, Dictionary <string, string> QueryStringParams = null) { var request = new HTTPWebServiceRequest(); request.MethodType = "POST"; request.URL = ServiceURL + "setAT"; if (Headers != null) { request.Headers = Headers; } if (QueryStringParams != null) { request.QueryStringParams = QueryStringParams; } return(request.PostAsyncWithMultipleAttachments <Attachement>(at, fileNames, filesData)); }
public ActionResult Create(AttachmentViewModel attachmentVm) { if (ModelState.IsValid) { if (attachmentVm.FileObj != null && attachmentVm.FileObj.ContentLength > 0) { var cu = User.Identity.GetUserName(); var usr = db.Users.Single(u => u.UserName == cu); var attachment = new Attachement() { UserId = usr.Id, DateAttached = DateTime.Now, FileUNQName = Guid.NewGuid().ToString() + attachmentVm.FileObj.FileName, Description = attachmentVm.Description, FileName = attachmentVm.FileObj.FileName, TicketId = attachmentVm.TicketId, UpLoaded = true }; var path = HttpContext.Server.MapPath("~/Repository/Attachments/" + attachmentVm.TicketId + "/"); var fullPath = Path.Combine(path, attachment.FileUNQName); if (!Directory.Exists(path)) { //Server.MapPath(path); Directory.CreateDirectory(path); } attachmentVm.FileObj.SaveAs(fullPath); db.Attachements.Add(attachment); var tick = db.Tickets.Single(i => i.Id == attachmentVm.TicketId); tick.Attachments = true; tick.LastedUpdated = DateTime.Now; db.Entry(tick).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", attachment.TicketId); //ViewBag.UserId = new SelectList(db.Users, "Id", "Name", attachment.UserId); //return View(attachment); } return(View()); }
public IHttpActionResult Put(long id, int attId, [FromBody] Attachement model) { if (model == null || !ModelState.IsValid) { return(BadRequest()); } var updatingAttach = attachs.Where(m => m.MailId == id).FirstOrDefault(m => m.Id == attId); if (updatingAttach == null) { return(NotFound()); } int updatingindex = attachs.IndexOf(updatingAttach); attachs[updatingindex] = model; return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutAttachement(string id, Attachement attachement) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != attachement.AttachementId) { return(BadRequest()); } attachmentService.Update(attachement); attachmentService.CommitAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public bool Update(int mailId, int attachementId, Attachement attachement) { if (mailId != attachement.MailId || attachementId != attachement.Id) { return(false); } var attachementToUpdate = _mails.FirstOrDefault(x => x.MailId == mailId && x.Id == attachementId); if (attachementToUpdate == null) { return(false); } _mails.Remove(attachementToUpdate); _mails.Add(attachement); return(true); }
public void DeleteAttachement(Attachement.Item item) { _settingsStorage.DeleteAttachement(item); }
public void AddAttachement(Attachement.Item item) { _settingsStorage.AddAttachement(item); }
public void Reload() { tasks = new List<Task>(); // Get tasks using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT id, name, description, date FROM tasks"; using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Task task = new Task() { Id = reader.GetInt32(0), Name = reader.GetString(1), Description = reader.IsDBNull(2) ? null : reader.GetString(2), Date = reader.IsDBNull(3) ? (DateTime?)null : DateTime.Parse(reader.GetString(3)) }; tasks.Add(task); } } } // Get parents using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT parent_id, child_id FROM tasks_relations"; using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { int parentId = reader.GetInt32(0); int childId = reader.GetInt32(1); Task parent = tasks.First(t => t.Id == parentId); Task child = tasks.First(t => t.Id == childId); parent.Children.Add(child); child.Parents.Add(parent); } } } Dictionary<int, Tag> tags = new Dictionary<int, Tag>(); // Get tags using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT id, name, color FROM tags"; using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Tag tag = new Tag() { Name = reader.GetString(1), Color = reader.IsDBNull(2) ? TagColor.None : (TagColor)Enum.Parse(typeof(TagColor), reader.GetString(2), true) }; tags.Add(reader.GetInt32(0), tag); } } } // Get task tags using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT task_id, tag_id FROM tasks_tags"; using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { int taskId = reader.GetInt32(0); int tagId = reader.GetInt32(1); Task task = tasks.First(t => t.Id == taskId); Tag tag = tags[tagId]; task.Tags.Add(tag); } } } // Get attachements using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT task_id, name, type_id, data FROM attachements"; using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Attachement attachement = new Attachement() { Name = reader.GetString(1), Type = reader.IsDBNull(2) ? AttachementType.Binary : (AttachementType)Enum.Parse(typeof(AttachementType), reader.GetString(2), true) }; attachement.Data = (byte[])reader.GetValue(3); /*using (Stream dataStream = reader.GetStream(3)) using (BinaryReader binaryStream = new BinaryReader(dataStream)) attachement.Data = binaryStream.ReadBytes((int)dataStream.Length);*/ int taskId = reader.GetInt32(0); Task task = tasks.First(t => t.Id == taskId); task.Attachements.Add(attachement); } } } // Get metadata using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT task_id, `key`, `value` FROM metadata"; using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { string key = reader.GetString(1); string value = reader.IsDBNull(2) ? null : reader.GetString(2); int taskId = reader.GetInt32(0); Task task = tasks.First(t => t.Id == taskId); task.Metadata.Add(key, value); } } } }
public void AddAttachement(Attachement.Item item) { lock (this) { if (_dbcon != null) { _dbcon.ExecuteNonQuery(string.Format("insert into attachm (gccode, filename, comments) values ('{0}','{1}','{2}')", item.GeocacheCode, item.FileName, item.Comment.Replace("'", "''"))); } } }
public void DeleteAttachement(Attachement.Item item) { lock (this) { if (_dbcon != null) { _dbcon.ExecuteNonQuery(string.Format("delete from attachm where gccode='{0}' and filename='{1}' and comments='{2}'", item.GeocacheCode, item.FileName, item.Comment.Replace("'", "''"))); } } }