public ActionResult Edit(SendMethod sendMethod) { try { var files = Utilities.SaveFiles(Request.Files, Utilities.GetNormalFileName(sendMethod.Title), StaticPaths.SendMethods); if (files.Count > 0) { sendMethod.Filename = files[0].Title; } sendMethod.LastUpdate = DateTime.Now; ViewBag.Success = true; if (sendMethod.ID == -1) { SendMethods.Insert(sendMethod); UserNotifications.Send(UserID, String.Format("جدید - روش ارسال '{0}'", sendMethod.Title), "/Admin/SendMethods/Edit/" + sendMethod.ID, NotificationType.Success); sendMethod = new SendMethod(); } else { SendMethods.Update(sendMethod); } } catch (Exception ex) { SetErrors(ex); } return(ClearView(sendMethod)); }
static void Main(string[] args) { string server = ConfigurationManager.AppSettings["server"]; SendMethods sm = new SendMethods(); sm.ConfirmOrder(new Order()); }
public JsonResult Get(int pageIndex, int pageSize, string pageOrder) { var list = SendMethods.Get(pageIndex, pageSize, pageOrder); int total = SendMethods.Count(); int totalPage = (int)Math.Ceiling((decimal)total / pageSize); if (pageSize > total) { pageSize = total; } if (list.Count < pageSize) { pageSize = list.Count; } JsonResult result = new JsonResult() { Data = new { TotalPages = totalPage, PageIndex = pageIndex, PageSize = pageSize, Rows = list }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(result); }
public ActionResult Edit(int?id) { SendMethod sendMethod; if (id.HasValue) { sendMethod = SendMethods.GetByID(id.Value); } else { sendMethod = new SendMethod(); } return(View(sendMethod)); }
private static string GetContentDisposition(SendMethods sendMethod) { if (sendMethod == SendMethods.Attachment) { return("attachment"); } else if (sendMethod == SendMethods.Inline) { return("inline"); } else { throw new NotSupportedException(); } }
private static string GetContentDisposition(SendMethods sendMethod) { if (sendMethod == SendMethods.Attachment) { return("attachment"); } else if (sendMethod == SendMethods.Inline) { return("inline"); } else { throw new Exception("调用的方法不受支持,或试图读取、查找或写入不支持调用功能的流"); } }
public ActionResult Index() { var activeSendMethods = SendMethods.GetActiveMethods(); var activePaymentMethods = PaymentMethods.GetActiveMethods(); ViewBuyerInfo buyer = new ViewBuyerInfo(); if (User.Identity.IsAuthenticated) { var user = OSUsers.GetByID(UserID); #region Mapp To Buyer buyer.Firstname = user.Firstname; buyer.Lastname = user.Lastname; buyer.Email = user.Email; // TODO: UserAddresses buyer.Phone = user.Phone; buyer.Mobile = user.Mobile; buyer.HomeAddress = user.HomeAddress; buyer.PostalCode = user.PostalCode; if (user.StateID.HasValue) { buyer.StateName = Cities.GetCityName(user.StateID.Value); } if (user.CityID.HasValue) { buyer.CityName = Cities.GetCityName(user.CityID.Value); } #endregion Mapp To Buyer } var send = Mapper.Map <List <ViewSendMethod> >(activeSendMethods); var payment = Mapper.Map <List <ViewPaymentMethod> >(activePaymentMethods); CartSettings cart = new CartSettings { PaymentMethods = payment, SendMethods = send, IsAuthentication = User.Identity.IsAuthenticated, BuyerInfo = buyer }; return(View(cart)); }
public JsonResult Delete(int id) { var jsonSuccessResult = new JsonSuccessResult(); try { SendMethods.Delete(id); jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
/// <summary> /// Valid in an ASP.NET context only. Sends this XlsDocument to the client with the /// given FileName as an attached or inline file, via the HttpResponse object. Clears /// the Response before sending and ends the Response after sending. /// </summary> /// <param name="sendMethod">Method to use to send document.</param> public void Send(SendMethods sendMethod) { //only applies in Classic ASP context? System.Web.HttpContext context = System.Web.HttpContext.Current; if (context == null) { throw new ApplicationException("Current System.Web.HttpContext not found - Send failed."); } if (!context.Response.Buffer) { context.Response.Buffer = true; context.Response.Clear(); } context.Response.ContentType = "application/vnd.ms-excel"; context.Response.AddHeader("Content-Disposition", string.Format("{0};filename={1}", GetContentDisposition(sendMethod), FileName)); context.Response.Flush(); context.Response.BinaryWrite(Bytes.ByteArray); }
/// <summary> /// Valid in an ASP.NET context only. Sends this XlsDocument to the client with the /// given FileName as an attached or inline file, via the HttpResponse object. Clears /// the Response before sending and ends the Response after sending. /// </summary> /// <param name="sendMethod">Method to use to send document.</param> public void Send(SendMethods sendMethod) { //only applies in Classic ASP context? System.Web.HttpContext context = System.Web.HttpContext.Current; if (context == null) throw new ApplicationException("Current System.Web.HttpContext not found - Send failed."); if (!context.Response.Buffer) { context.Response.Buffer = true; context.Response.Clear(); } context.Response.ContentType = "application/vnd.ms-excel"; context.Response.AddHeader("Content-Length", Bytes.ByteArray.Length.ToString()); context.Response.AddHeader("Content-Disposition", string.Format("{0};filename={1}", GetContentDisposition(sendMethod), FileName)); context.Response.Flush(); context.Response.BinaryWrite(Bytes.ByteArray); context.Response.End(); }
private static string GetContentDisposition(SendMethods sendMethod) { if (sendMethod == SendMethods.Attachment) return "attachment"; else if (sendMethod == SendMethods.Inline) return "inline"; else throw new NotSupportedException(); }
/// <summary> /// 发送消息 /// </summary> /// <param name="msg">消息内容</param> /// <param name="receiverList">如果类型是用户,则传入的是inspurId,如果是邮箱,则是邮箱列表</param> /// <param name="method">发送方式,支持邮件、app消息等多种</param> public static async void SendMessageAsync(IMessage msg, List <string> receiverList, SendMethods method) { try { if ((method & SendMethods.Mail) != 0) { await MailHelper.SendBySmtpAsync(receiverList, msg.Subject, msg.Content, msg.IsHtml); } if ((method & SendMethods.PushMessage) != 0) { await PushMessage.PushByInspurIDAsync(receiverList, msg.Content); } } catch (Exception e) { //todo:后期加日志,先暂时吞掉 Console.WriteLine(JsonConvert.SerializeObject(e)); } }
/// <summary> /// Envia notificaciones a Shaman AID. // Ejecuta InterClientesC.AIDServicios.GetMensajesPendientes (InterClientesC.GetMensajesPendientes()) // Armar un Json con los datos, dependiendo del tipo de mensaje (1...5) // (para los asignados (3) hay que calcular el tiempo con http://200.49.156.125:57779/Service.asmx?op=GetDistanciaTiempo) // Eliminar el mensaje pendiente de Shaman con InterClientesC.AIDServicios.SetPreIncidenteMensaje()) /// </summary> public void PushAidPreIncidente() { try { ConnectionStringCache connectionString = new ConnectionStringCache(ConfigurationManager.AppSettings["ConexionCache"]); InterClientesC.AIDServicios objServicios = new InterClientesC.AIDServicios(connectionString); List <MensajesPendientes> mensajes = objServicios.GetMensajesPendientes <MensajesPendientes>(); //mensajes = new List<MensajesPendientes>(); //mensajes.Add(new MensajesPendientes //{ // PreIncidenteId = "346046", // MensajeId = "10", // Mensaje = "No hay Novedad" //}); SendMethods jsonSend = new SendMethods(); if (mensajes != null && mensajes.Count > 0) { addLog(true, "PushAidPreIncidente: ", string.Format("Se encontraron {0} mensajes nuevos para enviar.", mensajes.Count)); foreach (var mensaje in mensajes) { bool result = false; ////TODO: Eliminar //mensaje.PreIncidenteId = 16; //mensaje.movLatitud = "-34.4381152"; //mensaje.movLongitud = "-58.8057913"; //mensaje.domLatitud = "-34.8008554"; //mensaje.domLongitud = "-58.447388"; switch (Convert.ToInt32(mensaje.MensajeId)) { case (int)TipoMensaje.Aceptacion: result = jsonSend.ConfirmOrder(new Order { preIncidentId = mensaje.PreIncidenteId, message = mensaje.Mensaje, NroServicio = mensaje.NroIncidente }); break; case (int)TipoMensaje.Cancelado: result = jsonSend.CancelOrder(new CancelOrder { preIncidentId = mensaje.PreIncidenteId, message = mensaje.Mensaje }); break; case (int)TipoMensaje.MovilAsignado: result = jsonSend.OrderMobileAssigned( new OrderMobileAssigned { preIncidentId = mensaje.PreIncidenteId, mobileNumber = mensaje.MovilId, doctor = mensaje.doctor, nurse = mensaje.nurse, driver = mensaje.driver, estimatedTime = GetEstimatedTime(mensaje), message = mensaje.Mensaje }); break; case (int)TipoMensaje.Finalizado: result = jsonSend.CompleteOrder( new CompleteOrder { preIncidentId = mensaje.PreIncidenteId, diagnostic = mensaje.diagnostic, treatment = mensaje.treatment }); break; case (int)TipoMensaje.ArriveOrder: result = jsonSend.ArriveOrder( new ArriveOrder { preIncidentId = mensaje.PreIncidenteId, message = "El movil ya se encuentra en su domicilio" }); break; default: break; } if (result) { objServicios.SetPreIncidenteMensaje(mensaje.PreIncidenteId, mensaje.MensajeId); } } } else { addLog(true, "PushAidPreIncidente: ", "No se encontraron mensajes nuevos para enviar."); } } catch (Exception ex) { addLog(false, "PushAidPreIncidente", "Fallo PushAidPreIncidente. " + ex.Message); } }
/// <summary> /// Initializes a new Invoice instance. Can be used to create an invoice. /// </summary> /// <param name="client"></param> /// <param name="action"></param> /// <param name="saveName">Required when Action is Save or Repeat</param> public Invoice(Client client, InvoiceActions action, SendMethods sendMethod) : this(client, action, null) { SendMethod = sendMethod; }