コード例 #1
0
 public int UpdateModel(SphinxExcludeQuery model)
 {
     StringBuilder sqlStr = new StringBuilder();
     try
     {
         if(model.product_id!=model.product_id_old)
         {
             sqlStr.AppendFormat("select count(product_id) from sphinx_exclude where product_id={0}", model.product_id);
             if (accessMySql.getDataTable(sqlStr.ToString()).Rows[0][0].ToString() != "0")
             {
                 return -1;
             }
             sqlStr.Clear();
             sqlStr.AppendFormat("select count(product_id) from product where product_id={0}", model.product_id);
             if (accessMySql.getDataTable(sqlStr.ToString()).Rows[0][0].ToString() == "0")
             {
                 return -2;
             }
             sqlStr.Clear();
         }
         sqlStr.AppendFormat("update sphinx_exclude set product_id={0} where product_id={1}",model.product_id,model.product_id_old);
         return accessMySql.execCommand(sqlStr.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("SphinxExcludeDao-->UpdateModel-->" + ex.Message + sqlStr.ToString(), ex);
     }
 }
コード例 #2
0
 public int InsertModel(SphinxExcludeQuery model)
 {
     StringBuilder sqlStr = new StringBuilder();
     try
     {
         sqlStr.AppendFormat("select count(product_id) from sphinx_exclude where product_id={0}", model.product_id);
         if(accessMySql.getDataTable(sqlStr.ToString()).Rows[0][0].ToString()!="0")
         {
             return -1;
         }
         sqlStr.Clear();
         sqlStr.AppendFormat("select count(product_id) from product where product_id={0}",model.product_id);
         if (accessMySql.getDataTable(sqlStr.ToString()).Rows[0][0].ToString() == "0")
         {
             return -2;
         }
         sqlStr.Clear();
         sqlStr.AppendFormat("insert sphinx_exclude(product_id,kdate,kuser) values({0},'{1}','{2}')", model.product_id, Common.CommonFunction.DateTimeToString(DateTime.Now),(System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
         return accessMySql.execCommand(sqlStr.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("SphinxExcludeDao-->InsertModel-->" + ex.Message + sqlStr.ToString(), ex);
     }
 }
コード例 #3
0
 public int DeleteModel(SphinxExcludeQuery model)
 {
     try
     {
         return dao.DeleteModel(model);
     }
     catch (Exception ex)
     {
         throw new Exception("SphinxExcludeMgr-->DeleteModel-->" + ex.Message, ex);
     }
 }
コード例 #4
0
 public List<SphinxExcludeQuery> GetList(SphinxExcludeQuery model, out int total)
 {
     try
     {
         return dao.GetList(model, out total);
     }
     catch (Exception ex)
     {
         throw new Exception("SphinxExcludeMgr-->GetList-->" + ex.Message, ex);
     }
 }
コード例 #5
0
 public List<SphinxExcludeQuery> GetList(SphinxExcludeQuery model, out int total)
 {
     StringBuilder sqlStr = new StringBuilder();
     StringBuilder sqlWhr = new StringBuilder();
     StringBuilder sqlCount = new StringBuilder();
     StringBuilder sqlPage = new StringBuilder();
     try
     {
         sqlStr.Append("SELECT se.product_id,se.kdate,mu.user_username,p.product_name FROM sphinx_exclude se");
         sqlStr.Append(" left join product p on se.product_id=p.product_id");
         sqlStr.Append(" left join manage_user mu on se.kuser=mu.user_id");
         sqlStr.Append(" WHERE 1=1 ");
         if (model.product_id != 0)
         {
             sqlWhr.AppendFormat(" and se.product_id={0}", model.product_id);
         }
         if (model.created_start != DateTime.MinValue && model.created_end != DateTime.MinValue)
         {
             sqlWhr.AppendFormat(" and se.kdate between '{0}' and '{1}'", Common.CommonFunction.DateTimeToString(model.created_start), Common.CommonFunction.DateTimeToString(model.created_end));
         }
         if(model.product_name!=string.Empty)
         {
             sqlWhr.AppendFormat(" and p.product_name like '%{0}%'",model.product_name);
         }
         if (model.IsPage)
         {
             sqlPage.AppendFormat(" limit {0},{1}", model.Start, model.Limit);
         }
         sqlCount.Append("SELECT count(se.product_id)FROM sphinx_exclude se left join product p on se.product_id=p.product_id ");
         total = int.Parse(accessMySql.getDataTable(sqlCount.ToString() + sqlWhr.ToString()).Rows[0][0].ToString());
         return accessMySql.getDataTableForObj<SphinxExcludeQuery>(sqlStr.ToString() + sqlWhr.ToString() + sqlPage.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("SphinxExcludeDao-->GetList-->" + ex.Message + sqlStr.ToString(), ex);
     }
 }
コード例 #6
0
 public int DeleteModel(SphinxExcludeQuery model)
 {
     StringBuilder sqlStr = new StringBuilder();
     try
     {
         sqlStr.AppendFormat("delete from sphinx_exclude  where product_id in({0})", model.product_ids);
         return accessMySql.execCommand(sqlStr.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("SphinxExcludeDao-->DeleteModel-->" + ex.Message + sqlStr.ToString(), ex);
     }
 }
コード例 #7
0
 public JsonResult DeleteById()
 {
     SphinxExcludeQuery query = new SphinxExcludeQuery();
     if (!string.IsNullOrEmpty(Request.Params["rid"]))
     {
         query.product_ids = Request.Params["rid"].TrimEnd(',');
     }
     try
     {
         sphinxExcludeMgr = new SphinxExcludeMgr(SqlConnectionString);
         if (sphinxExcludeMgr.DeleteModel(query) > 0)
         {
             return Json(new { success = "true" });
         }
         else
         {
             return Json(new { success = "false" });
         }
     }
     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);
         return Json(new { success = "false" });
     }
 }
コード例 #8
0
 public JsonResult SphinxExcludeSave()
 {
     SphinxExcludeQuery query = new SphinxExcludeQuery();
     query.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
     query.kdate = DateTime.Now;
     string pid = Request.Params["pid"].Trim();
     query.product_id_old = int.Parse(pid);
     if (!string.IsNullOrEmpty(Request.Params["productid"].Trim()))
     {
         query.product_id = int.Parse(Request.Params["productid"].Trim());
     }
     try
     {
         sphinxExcludeMgr = new SphinxExcludeMgr(SqlConnectionString);
         if (pid == "0")
         {
             int row = sphinxExcludeMgr.InsertModel(query);
             if (row == 1)
             {
                 return Json(new { success = "true" });
             }
             else
             {
                 return Json(new { success = row });
             }
         }
         else
         {
             int row = sphinxExcludeMgr.UpdateModel(query);
             if (row == 1)
             {
                 return Json(new { success = "true" });
             }
             else
             {
                 return Json(new { success = row });
             }
         }
     }
     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);
         return Json(new { success = "false" });
     }
 }
コード例 #9
0
 public HttpResponseBase GetSphinxExclude()
 {
     string json = string.Empty;
     try
     {
         SphinxExcludeQuery query = new SphinxExcludeQuery();
         query.Start = string.IsNullOrEmpty(Request.Params["start"]) ? 0 : int.Parse(Request.Params["start"]);
         query.Limit = string.IsNullOrEmpty(Request.Params["limit"]) ? 25 : int.Parse(Request.Params["limit"]);
         query.product_name = string.IsNullOrEmpty(Request.Params["productname"]) ? "" : Request.Params["productname"].Trim();
         System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"^\d+$");
         string oid = Request.Params["oid"].Trim();
         if (oid != "")
         {
             if (rex.IsMatch(oid))
             {
                 query.product_id = int.Parse(oid);
             }
             else
             {
                 query.product_id = -1;
             }
         }
         DateTime datetime;
         if (DateTime.TryParse(Request.Params["time_start"], out datetime))
         {
             query.created_start = DateTime.Parse(datetime.ToString("yyyy-MM-dd HH:mm:ss"));
         }
         if (DateTime.TryParse(Request.Params["time_end"], out datetime))
         {
             query.created_end = DateTime.Parse(datetime.ToString("yyyy-MM-dd HH:mm:ss"));
         }
         int totalCount = 0;
         sphinxExcludeMgr = new SphinxExcludeMgr(SqlConnectionString);
         List<SphinxExcludeQuery> list = sphinxExcludeMgr.GetList(query, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(list, Formatting.Indented, timeConverter) + "}";//返回json數據
     }
     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;
 }
コード例 #10
0
        public HttpResponseBase RemoveSystemKeyWord()
        {
            string json = string.Empty;
            ///返回的状态
            int state = 0;
            List<SphinxKeywordQuery> stores = new List<SphinxKeywordQuery>();
            SphinxExcludeQuery query = new SphinxExcludeQuery();
            seMgr = new SphinxExcludeMgr(SqlConnectionString);
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["Product_Id"]))
                {
                  query.product_id=Convert.ToInt32( Request.Params["Product_Id"]);
                }
                query.kdate = DateTime.Now;
                state = seMgr.InsertModel(query);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,state:" + state + "}";//返回json數據
            }
            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}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }