Esempio n. 1
0
        /// <summary>
        /// 創瑞
        /// </summary>
        /// <returns></returns>
        public ResponseBase <string> Post()
        {
            #region 宣告
            //參數宣告
            ResponseBase <string> RespBaseReturn = new ResponseBase <string>();
            //預設值
            RespBaseReturn.IsSuccess = true;
            RespBaseReturn.Msg       = "";
            RespBaseReturn.Data      = null;
            //DataModel
            StatusUp StatusUpClass = new StatusUp();
            //變數
            string strparameter = string.Empty;
            string client       = string.Empty;
            string strUrltoJson = string.Empty;
            var    httpRequest  = System.Web.HttpContext.Current.Request;
            #endregion
            try
            {
                if (httpRequest.InputStream.CanRead)                                  //將Url轉成Json格式
                {
                    var reader = new System.IO.StreamReader(httpRequest.InputStream); //用httpRequsest去讀取InputStream,InputStream的資料是從
                    strUrltoJson = reader.ReadToEnd();                                //停止讀取posman的json資料

                    StatusUpClass = JsonConvert.DeserializeObject <StatusUp>(strUrltoJson);
                }
                strparameter = "name=" + StatusUpClass.name + "&pwd=" + StatusUpClass.pwd + "&sendid=" + StatusUpClass.sendid + "&time=" + StatusUpClass.time + "&mobile=" + StatusUpClass.mobile + "&state=" + StatusUpClass.state;
                client       = FunWebClientPost(strparameter, Url);
                if (string.IsNullOrWhiteSpace(client))
                {
                    RespBaseReturn.Msg = "修改資料失敗!";
                    return(RespBaseReturn);
                }
                RespBaseReturn = JsonConvert.DeserializeObject <ResponseBase <string> >(client);
                return(RespBaseReturn);
            }
            catch (Exception ex)
            {
                return(RespBaseReturn);
            }
        }
Esempio n. 2
0
        public ResponseBase <string> SmsStatusUp(StatusUp StatusUpClass)
        {
            #region 宣告
            //參數宣告
            ResponseBase <string> RespBaseReturn = new ResponseBase <string>();
            //預設值
            RespBaseReturn.IsSuccess = true;
            RespBaseReturn.Data      = null;
            RespBaseReturn.Msg       = "";
            //變數
            string client       = string.Empty;
            string strparameter = string.Empty;
            //查詢結果
            string strResult = string.Empty;
            string strQuery  = string.Empty;
            //是否更新成功
            int intIsVaild = 0;
            //SQL 條件判斷
            string strWhere = string.Empty;
            //計算Mobile數量
            int      intMobileCount = 0;
            string[] strarrMobile;
            #endregion

            try
            {
                #region SQL 參數
                DynamicParameters sqlParm = new DynamicParameters();
                sqlParm.Add("@Status", StatusUpClass.state);
                sqlParm.Add("@Sendid", StatusUpClass.sendid);
                sqlParm.Add("@Mobile", StatusUpClass.mobile);
                #endregion

                intMobileCount = StatusUpClass.mobile.Split(',').Count();
                if (intMobileCount > 1)
                {
                    int    intN  = 0;
                    string strIn = string.Empty;
                    foreach (string item in StatusUpClass.mobile.Split(','))
                    {
                        SqlParameter parameter = new SqlParameter("@dd" + intN, SqlDbType.NVarChar, 50, item);
                        parameter.IsNullable = true;
                        parameter.Direction  = ParameterDirection.Output;

                        sqlParm.Add("@dd" + intN, item, System.Data.DbType.String);
                        strIn += "@dd" + intN + ",";

                        intN++;
                    }
                    strWhere = string.Format(" And Mobile in ({0} ) ", strIn.TrimEnd(','));
                }
                else
                {
                    strWhere = " And Mobile=@Mobile ";
                }


                #region SQL 語法
                strQuery = @"UPDATE SMSCNStatus
                             SET [Status] =@Status
                             WHERE Sendid=@Sendid  {0} ";
                strQuery = string.Format(strQuery, strWhere);
                #endregion
                #region SQL 執行
                //using (SqlConnection conn = new SqlConnection(DBList.LionExAPI))
                //{
                //    intIsVaild = conn.Execute(strQuery, sqlParm);

                //}
                //if (intIsVaild == 0)
                //{
                //    //Proj.send_ErrorEmail("更新失敗", string.Format("<h4>SQLUpdate:</h4><ul><li>{0};</li></ul><h4>StatusUpClass:</h4><ul><li>{1}</li></ul>", strQuery, JsonConvert.SerializeObject(StatusUpClass)));

                //}

                #endregion
                RespBaseReturn.Data = intIsVaild.ToString();
                return(RespBaseReturn);
            }
            catch (Exception ex)
            {
                RespBaseReturn.IsSuccess = false;
                RespBaseReturn.Data      = null;
                RespBaseReturn.Msg       = "API System error";
                //new Log().ErrorLog(strThisPageName + "/SmsStatusUp", ex.Message);
                #region 記錄LOG
                //SmsCNLogs LogData = new SmsCNLogs();
                //LogData.ActionData = strThisPageName + "/SmsStatusUp";
                //LogData.SourceJsonString = JsonConvert.SerializeObject(StatusUpClass);
                //LogData.ReturnJsonString = string.Format("SQLUpdate={0};RespBaseReturn={1}", strQuery, RespBaseReturn);
                //LogData.CreateDateTime = DateTime.Now;
                //LogData.MagData = ex.Message;
                //LogData.Sort = "1";
                //ProjectFun.FunAddLogData(LogData);
                #endregion
                return(RespBaseReturn);
            }
        }
Esempio n. 3
0
        // GET: api/TestIISError/5
        public string Post(StatusUp StatusUpClass)
        {
            string aa = "";

            return("value");
        }