public void SendLetter(UpdateLetter updateLetter) { var letter = updateLetter.CreateLetter(); letter.ReplyTime = SqlDateTime.MinValue.Value; using (var content = new DefaultContext()) { content.Letters.Add(letter); content.SaveChanges(); } var dic = new Dictionary<string, string>(); dic.Add("ActionName", "Reply"); dic.Add("letter", letter.ToJson()); var resString = HttpWebResponseUtility.CreatePostHttpResponse("http://second.eagle.com/api/Message", dic.ToJson(), 30000); if (string.IsNullOrEmpty(resString) || resString == "0") { Flag = false; Message = "消息无响应"; return; } var result = resString.ToDeserialize<Cells>(); if (!result.Flag) { Flag = false; Message = result.Message; return; } Flag = true; }
public ActionResult Edit(UpdateLetter updateLetter) { var letterServices = ServiceLocator.Instance.GetService<ILetterServices>(); try { // TODO: Add update logic here updateLetter.ID = Guid.NewGuid(); letterServices.SendLetterWcf(updateLetter); var result = letterServices.GetResult(); return Json(result); } catch { return Json(0); } }
public void ReplyLetter(UpdateLetter updateLetter) { using (var content = new DefaultContext()) { var letter = content.Letters.AsNoTracking().FirstOrDefault(x => x.ID == updateLetter.ID); if (letter == null) { return; } letter.ReplyTime = DateTime.Now; letter.Reply = updateLetter.Message; content.ModifiedModel(letter); content.SaveChanges(); } Flag = true; }
public void SendLetterWcf(UpdateLetter updateLetter) { var binding = new NetMsmqBinding(); binding.Security.Mode = NetMsmqSecurityMode.None; var endpointAddress = new EndpointAddress("net.msmq://10.2.0.172/private/Message"); using (ChannelFactory<IMessageService> messageChannelFactory = new ChannelFactory<IMessageService>(binding, endpointAddress)) { try { IMessageService messageService = messageChannelFactory.CreateChannel(); messageService.GetTest(updateLetter); } catch (Exception exception) { throw exception; } } Flag = true; }
public void GetTest(UpdateLetter updateLetter) { LogUtility.SendInfo(updateLetter.ToJson()); }
public ActionResult Reply(UpdateLetter updateLetter) { var letterServices = ServiceLocator.Instance.GetService<ILetterServices>(); try { // TODO: Add update logic here letterServices.ReplyLetter(updateLetter); var result = letterServices.GetResult(); return Json(result); } catch { return View(); } }