Exemple #1
0
        public static Com.Martin.SMS.Data.SMSIncoming SaveIncomingMessage(String Sender, String Receiver, String Message)
        {
            SMSIncoming incoming = new SMSIncoming();

            incoming.ID          = CreateIdNumber(TypeSMS.Input);
            incoming.DateReceive = DateTime.Now;
            incoming.Sender      = Sender;
            incoming.MessageText = Message;
            try {
                conn.Open();
                MySqlCommand command = conn.CreateCommand();
                command.CommandText = "select nama_class, nama_assembly from daftar_register where reg_type = ?type and reg_name = ?name";
                command.Parameters.Clear();
                //command.Parameters.AddWithValue("type", CommandType);
                //command.Parameters.AddWithValue("name", CommandName);

                MySqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                }
            } finally {
                conn.Close();
            }


            return(new SMS.Data.SMSIncoming());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SMSIncoming sMSIncoming = db.SMSIncomings.Find(id);

            db.SMSIncomings.Remove(sMSIncoming);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "sms_id,message,receive_date,process_date,process_remarks")] SMSIncoming sMSIncoming)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sMSIncoming).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sMSIncoming));
 }
        public ActionResult Create([Bind(Include = "sms_id,message,receive_date,process_date,process_remarks")] SMSIncoming sMSIncoming)
        {
            if (ModelState.IsValid)
            {
                db.SMSIncomings.Add(sMSIncoming);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sMSIncoming));
        }
        // GET: SMSIncoming/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SMSIncoming sMSIncoming = db.SMSIncomings.Find(id);

            if (sMSIncoming == null)
            {
                return(HttpNotFound());
            }
            return(View(sMSIncoming));
        }
        public async Task <IHttpActionResult> PostSMSIncoming([FromBody] JToken jsonbody)
        {
            try
            {
                if (jsonbody.HasValues)
                {
                    string processResult = "";
                    if (((JProperty)jsonbody.First).Name == "error")
                    {
                        processResult = ((JProperty)jsonbody.First).Value.ToString();
                    }
                    else if (((JProperty)jsonbody.First).Name == "inboundSMSMessageList")
                    {
                        globe_sms_mo sms_mo = JsonConvert.DeserializeObject <globe_sms_mo>(jsonbody.ToString());
                        processResult = processMessage(sms_mo);
                    }
                    else
                    {
                        processResult = "Message not supported";
                    }

                    SMSIncoming sms = new SMSIncoming
                    {
                        message      = jsonbody.ToString(),
                        receive_date = DateTime.UtcNow
                    };


                    // do message processing
                    sms.process_date    = DateTime.UtcNow;
                    sms.process_remarks = processResult;// processResult;

                    db.SMSIncomings.Add(sms);

                    await db.SaveChangesAsync();

                    return(Ok(sms));
                }

                return(BadRequest());
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }