Esempio n. 1
0
        public HttpResponseBase GetArrivalNoticeList()
        {
            List<ArrivalNoticeQuery> store = new List<ArrivalNoticeQuery>();
            ArrivalNoticeQuery query = new ArrivalNoticeQuery();
            int totalCount = 0;
            string json = string.Empty;
            try
            {

                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                if (!string.IsNullOrEmpty(Request.Params["condition"]))
                {
                    query.condition = Convert.ToInt32(Request.Params["condition"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["searchCon"]))
                {
                    query.searchCon = Request.Params["searchCon"].ToString().Trim();
                }
                if (!string.IsNullOrEmpty(Request.Params["status"]))
                {
                    query.status = Convert.ToInt32(Request.Params["status"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["searchNum"]))
                {
                    query.item_stock = Convert.ToInt32(Request.Params["searchNum"]);
                }
                _IArrivalNoticeMgr = new ArrivalNoticeMgr(mySqlConnectionString);
                store = _IArrivalNoticeMgr.ArrivalNoticeList(query, out totalCount);
                foreach (var item in store)
                {
                    if (!string.IsNullOrEmpty(item.user_name.ToString()))
                    {
                        item.user_name = item.user_name.Substring(0, 1) + "**";
                    }
                    item.user_email = item.user_email.Split('@')[0] + "@***";

                    item.s_create_time = CommonFunction.GetNetTime(item.create_time);
                    if (item.coming_time != 0)
                    {
                        item.s_coming_time = CommonFunction.DateTimeToString(CommonFunction.GetNetTime(item.coming_time));
                    }
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Esempio n. 2
0
        public HttpResponseBase NoOrComing()
        {
            List<ArrivalNoticeQuery> list = new List<ArrivalNoticeQuery>();
            ArrivalNoticeQuery query = null;
            string json = string.Empty;
            string mailBody;
            MailHelper mailHelper = new MailHelper();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["rowID"]))
                {
                    string select_id = Request.Params["rowID"];
                    if (select_id.IndexOf("∑") != -1)
                    {
                        foreach (string id in select_id.Split('∑'))
                        {
                            if (!string.IsNullOrEmpty(id))
                            {
                                query = new ArrivalNoticeQuery();
                                string[] data = id.Split(',');
                                query.status = Convert.ToInt32(Request.Params["type"]);
                                query.id = Convert.ToUInt32(data[0]);
                                query.user_email = _usmgr.getModel(Convert.ToInt32(data[1].ToString())).user_email;
                                query.product_name = data[2];
                                if (!string.IsNullOrEmpty(Request.Params["coming_time"]))
                                {
                                    query.coming_time = Convert.ToInt32(CommonFunction.GetPHPTime(Request.Params["coming_time"].ToString()));
                                }
                                if (!string.IsNullOrEmpty(Request.Params["recommend"]))
                                {
                                    query.recommend = Request.Params["recommend"].ToString();
                                }
                                list.Add(query);
                            }
                        }
                    }
                }
                _IArrivalNoticeMgr = new ArrivalNoticeMgr(mySqlConnectionString);
                if (_IArrivalNoticeMgr.IgnoreNotice(list))
                {
                    FileStream fs = new FileStream(Server.MapPath("../ImportUserIOExcel/ArrivalNotice.html"), FileMode.OpenOrCreate, FileAccess.Read);
                    StreamReader sr = new StreamReader(fs, Encoding.UTF8);
                    string strTemp = sr.ReadToEnd();
                    for (int i = 0; i < list.Count; i++)
                    {

                        #region 不再補貨
                        if (list[i].status == 2)
                        {
                            if (!string.IsNullOrEmpty(list[i].recommend))
                            {
                                mailBody = "您關注補貨的商品" + "【" + list[i].product_name + "】" + "已不再進貨/販售,建議您購買我們推薦的類似商品:" + list[i].recommend;
                            }
                            else
                            {
                                mailBody = "您關注補貨的商品" + "【" + list[i].product_name + "】" + "已不再進貨/販售。  ";
                            }
                            strTemp = strTemp.Replace("{{$serviceAnwser$}}", mailBody);
                        }
                        #endregion

                        #region 預計補貨
                        if (list[i].status == 3)
                        {
                            mailBody = "您關注補貨的商品" + "【" + list[i].product_name + "】" + "將預計在" + CommonFunction.DateTimeToString(CommonFunction.GetNetTime(list[i].coming_time)) + "補貨,敬請及早購買,以免向隅。  ";
                            strTemp = strTemp.Replace("{{$serviceAnwser$}}", mailBody);
                        }
                        #endregion
                        try
                        {
                            mailHelper.SendMailAction(list[i].user_email, "吉甲地市集補貨通知信", strTemp);
                        }
                        catch (Exception ex)
                        {
                            json = "{success:true,msg:1}";
                        }
                    }

                    json = "{success:true,msg:0}";
                }
                else
                {
                    json = "{failure:true}";
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{failure:true}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
 public HttpResponseBase SaveArrivaleNotice()
 {
     ArrivalNotice arr = new ArrivalNotice();
    
      string jsonStr = String.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["id"]))
         { 
             arr.id=uint.Parse(Request.Params["id"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["product_id"]))
         {
             arr.product_id = uint.Parse(Request.Params["product_id"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["item_id"]))
         {
             arr.item_id = uint.Parse(Request.Params["item_id"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["user_id"]))
         {
             arr.user_id = uint.Parse(Request.Params["user_id"]);
         }
         arr.source_type = 2;
         arr.status = 0;
         arr.send_notice_time = 0;
         arr.create_time = uint.Parse(CommonFunction.GetPHPTime().ToString());
         arr.muser_id = (Session["caller"] as Caller).user_id;
         _arrivalMgr = new ArrivalNoticeMgr(mySqlConnectionString);
         if (arr.id == 0)//新增
         {
             int result=_arrivalMgr.SaveArrivaleNotice(arr);
             if (result == 1)
             {
                 jsonStr = "{success:true,msg:\"" + 1 + "\"}";
             }
             if (result == 98)
             {
                 jsonStr = "{success:true,msg:\"" + 98 + "\"}";//此人員已在未通知列表中
             }
             else 
             {
                 jsonStr = "{success:true,msg:\"" + 99 + "\"}";
             }
            
         }
         else //修改
         {
             int result = _arrivalMgr.UpArrivaleNoticeStatus(arr);
             if (result==100)
             {
                 jsonStr = "{success:true,msg:\"" + 100 + "\"}";
                 //jsonStr = "{success:true,msg:\"此此人不在補貨通知以內貨已取消通知!\"}";
             }
             else
             {
                 jsonStr = "{success:true,msg:\"" + 99 + "\"}";
             }
         }
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         jsonStr = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(jsonStr.ToString());
     this.Response.End();
     return this.Response;
 }