예제 #1
0
 public int UpdateImage(VendorBrandSetQuery query)
 {
     try
     {
         return _vendorBrandSetDao.UpdateImage(query);
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetMgr-->UpdateImage-->"+ex.Message,ex);
     }
 }
예제 #2
0
 public List<VendorBrandSetQuery> GetImageInfo(VendorBrandSetQuery store)
 {
     try
     {
         return _vendorBrandSetDao.GetImageInfo(store);
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetMgr-->GetImageInfo-->" + ex.Message, ex);
     }
 }
예제 #3
0
        public HttpResponseBase UpdateSortByPicture()
        {
            string json = string.Empty;
            VendorBrandSetQuery query = new VendorBrandSetQuery();
            VendorBrandSetQuery old = new VendorBrandSetQuery();
            string name = Request.Params["picture"];
            name = name.Substring(name.LastIndexOf('/') + 1, name.Length - 1 - name.LastIndexOf('/'));
            _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
            old = _IvendorBrandSet.GetSingleImage(name);
            query.image_filename = name;
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["sort_id"]))
                {
                    query.image_sort = Convert.ToUInt32(Request.Params["sort_id"]);
                }
                else
                {
                    query.image_sort = old.image_sort;
                }
                if (!string.IsNullOrEmpty(Request.Params["this_type"]))
                {
                    query.image_state = Convert.ToUInt32(Request.Params["this_type"]);
                }
                else
                {
                    query.image_state = old.image_state;
                }
                if (_IvendorBrandSet.UpdateImage(query) > 0)
                {
                    json = "{success:true}";//返回json數據
                }
                else
                {
                    json = "{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);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json.ToString());
            this.Response.End();
            return this.Response;


        }
예제 #4
0
        /// <summary>
        /// 新增或修改供應商品牌信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase UpdVendorBrand()
        {
            List<VendorBrandSetQuery> stores = new List<VendorBrandSetQuery>();
            query = new VendorBrandSetQuery();
            VendorBrandSetQuery oldquery = new VendorBrandSetQuery();
            _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            string json = string.Empty;
            string errorInfo = string.Empty;

            try
            {
                #region 獲取數據
                query.Brand_Id = UInt32.Parse(Request.Params["Brand_Id"]);
                oldquery = _IvendorBrandSet.GetModelById(Int32.Parse(Request.Params["Brand_Id"]));
                try
                {
                    query.Brand_Name = Request.Params["brandName"].ToString();
                }
                catch (Exception)
                {
                    query.Brand_Name = oldquery.Brand_Name;
                }
                try
                {
                    query.vendor_id = uint.Parse(Request.Params["vendorid"].ToString());
                }
                catch (Exception)
                {
                    query.vendor_id = oldquery.vendor_id;
                }
                try
                {
                    query.Brand_Sort = uint.Parse(Request.Params["brandsort"].ToString());
                }
                catch (Exception)
                {
                    query.Brand_Sort = oldquery.Brand_Sort;
                }
                try
                {
                    query.Brand_Status = uint.Parse(Request.Params["brandstatus"].ToString());
                }
                catch (Exception)
                {
                    query.Brand_Status = oldquery.Brand_Status;
                }
                try
                {
                    query.Image_Status = uint.Parse(Request.Params["imagestatus"].ToString());
                }
                catch (Exception)
                {
                    query.Image_Status = oldquery.Image_Status;
                }
                try
                {
                    query.Image_Link_Mode = uint.Parse(Request.Params["imagelinkmode"].ToString());
                }
                catch (Exception)
                {
                    query.Image_Link_Mode = oldquery.Image_Link_Mode;
                }
                try
                {
                    query.Image_Link_Url = Request.Params["imagelinkurl"].ToString();
                }
                catch (Exception)
                {
                    query.Image_Link_Url = oldquery.Image_Link_Url;
                }
                try
                {
                    query.Resume_Image_Link = Request.Params["resumeimagelink"].ToString();
                }
                catch (Exception)
                {
                    query.Resume_Image_Link = oldquery.Resume_Image_Link;
                }
                try
                {
                    query.Media_Report_Link_Url = Request.Params["mediareportlinkurl"].ToString();
                }
                catch (Exception)
                {
                    query.Media_Report_Link_Url = oldquery.Media_Report_Link_Url;
                }
                try
                {
                    query.Brand_Msg = Request.Params["brandmsg"].ToString();
                }
                catch (Exception)
                {
                    query.Brand_Msg = oldquery.Brand_Msg;
                }
                long start = CommonFunction.GetPHPTime(Request.Params["begin_time"].ToString());
                long end = CommonFunction.GetPHPTime(Request.Params["end_time"].ToString());
                try
                {
                    query.Brand_Msg_Start_Time = uint.Parse(start.ToString());
                }
                catch (Exception)
                {
                    query.Brand_Msg_Start_Time = oldquery.Brand_Msg_Start_Time;
                }
                try
                {
                    query.Brand_Msg_End_Time = uint.Parse(end.ToString());
                }
                catch (Exception)
                {
                    query.Brand_Msg_End_Time = oldquery.Brand_Msg_End_Time;
                }
                try
                {
                    query.Brand_Createdate = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString());
                }
                catch (Exception)
                {
                    query.Brand_Createdate = oldquery.Brand_Createdate;
                }
                try
                {
                    query.classIds = Request["shopclass"].ToString();
                }
                catch (Exception)
                {
                    query.classIds = oldquery.classIds;
                }
                query.Brand_Ipfrom = Request.UserHostAddress;
                try
                {
                    query.Cucumber_Brand = uint.Parse(Request.Params["cucumberbrand"].ToString());
                }
                catch
                {
                    query.Cucumber_Brand = oldquery.Cucumber_Brand;
                }
                try
                {
                    query.Image_Name = Request.Params["imagename"].ToString();
                }
                catch (Exception)
                {
                    query.Image_Name = oldquery.Image_Name;
                }
                try
                {
                    query.Promotion_Banner_Image_Link = Request.Params["promotionbannerimagelink"].ToString();
                }
                catch (Exception)
                {
                    query.Promotion_Banner_Image_Link = oldquery.Promotion_Banner_Image_Link;
                }
                try
                {
                    query.short_description = Request.Params["short_description"].ToString();
                }
                catch (Exception)
                {
                    query.short_description = oldquery.short_description;
                }
                query.Image_Name = oldquery.Image_Name;
                query.Resume_Image = oldquery.Resume_Image;
                query.Promotion_Banner_Image = oldquery.Promotion_Banner_Image;
                query.brand_logo = oldquery.brand_logo;
                #endregion
                #region 上傳圖片
                string path = Server.MapPath(xmlPath);
                SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
                SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                //擴展名、最小值、最大值
                string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value;
                string minValue = minValue_config.Value == "" ? minValue_config.DefaultValue : minValue_config.Value;
                string maxValue = maxValue_config.Value == "" ? maxValue_config.DefaultValue : maxValue_config.Value;
                string localPromoPath = imgLocalPath + brandPath;//圖片存儲地址
                FileManagement fileLoad = new FileManagement();
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    string fileName = string.Empty;     //當前文件名
                    HttpPostedFileBase file = Request.Files[i];
                    fileName = Path.GetFileName(file.FileName);
                    if (string.IsNullOrEmpty(fileName))
                    {
                        continue;
                    }

                    fileLoad = new FileManagement();
                    string oldFileName = string.Empty;  //舊文件名
                    string fileExtention = string.Empty;//當前文件的擴展名
                    bool result = false;
                    string NewFileName = string.Empty;
                    string ServerPath = string.Empty;
                    string newRand = string.Empty;
                    string ErrorMsg = string.Empty;

                    newRand = hash.Md5Encrypt(fileLoad.NewFileName(fileName) + DateTime.Now.ToString(), "32");
                    fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                    NewFileName = newRand + fileExtention;

                    string folder1 = NewFileName.Substring(0, 2) + "/"; //圖片名前兩碼
                    string folder2 = NewFileName.Substring(2, 2) + "/"; //圖片名第三四碼

                    FTP f_cf = new FTP();
                    localPromoPath = imgLocalPath + brandPath + folder1 + folder2;  //圖片存儲地址
                    string s = localPromoPath.Substring(0, localPromoPath.Length - (brandPath + folder1 + folder2).Length + 1);
                    f_cf.MakeMultiDirectory(s, (brandPath + folder1 + folder2).Substring(1, (brandPath + folder1 + folder2).Length - 2).Split('/'), ftpuser, ftppwd);
                    ServerPath = Server.MapPath(imgLocalServerPath + brandPath + folder1 + folder2);
                    fileName = NewFileName;
                    NewFileName = localPromoPath + NewFileName;//絕對路徑
                    Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件

                    //上傳
                    result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                    if (result)//上傳成功
                    {
                        //圖片上傳成功后記錄新圖片名稱
                        switch (i)
                        {
                            case 0:
                                query.Image_Name = fileName;
                                break;
                            case 1:
                                query.Resume_Image = fileName;
                                break;
                            case 2:
                                query.Promotion_Banner_Image = fileName;
                                break;
                            case 3:
                                query.brand_logo = fileName;
                                break;
                            default:
                                break;
                        }

                        //圖片上傳成功后如果存在舊圖片則根據舊圖片名刪除舊圖片
                        if (!string.IsNullOrEmpty(oldFileName))
                        {
                            switch (i)
                            {
                                case 0:
                                    oldFileName = oldquery.Image_Name;
                                    break;
                                case 1:
                                    oldFileName = oldquery.Resume_Image;
                                    break;
                                case 2:
                                    oldFileName = oldquery.Promotion_Banner_Image;
                                    break;
                                case 3:
                                    oldFileName = oldquery.brand_logo;
                                    break;
                                default:
                                    break;
                            }
                            DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                        }
                    }
                    else
                    {
                        //圖片上傳失敗則圖片名稱為原有圖片名稱
                        switch (i)
                        {
                            case 0:
                                query.Image_Name = oldquery.Image_Name;//形象圖片
                                break;
                            case 1:
                                query.Resume_Image = oldquery.Resume_Image;//安心聲明圖片
                                break;
                            case 2:
                                query.Promotion_Banner_Image = oldquery.Promotion_Banner_Image;//促銷圖片
                                break;
                            case 3:
                                query.brand_logo = oldquery.brand_logo;//品牌logo
                                break;
                            default:
                                break;
                        }

                        errorInfo += "第" + (i + 1) + "張" + ErrorMsg + "<br/>";
                        //json = "{success:false,msg:\"第" + i + "張" + ErrorMsg + ",之後圖片未作處理" + "\"}";
                    }
                }
                #endregion
                //更新數據庫記錄
                if (_IvendorBrandSet.Update(query) > 0)
                {
                    if (_productMgr.UpdateSaleStatusByCondition(new Product { Vendor_Id = query.vendor_id, Brand_Id = query.Brand_Id }))
                    {
                        json = "{success:true,msg:\"數據保存成功!\"}";
                    }
                }
                if (!string.IsNullOrEmpty(errorInfo))
                {
                    json = "{success:true,msg:\"<div>數據保存成功!<br/>但<br/>" + errorInfo + "</div>\"}";
                }
            }
            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,msg:\"保存失敗,請稍后再試!\"}";
                if (!string.IsNullOrEmpty(errorInfo))
                {
                    json = "{success:false,msg:\"<div>保存失敗,請稍后再試!<br/>" + errorInfo + "</div>\"}";
                }
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
예제 #5
0
 public HttpResponseBase GetImageInfo()
 {
     VendorBrandSetQuery query = new VendorBrandSetQuery();
     string brandid = Request.Params["brand_id"].ToString();
     query.Brand_Id = uint.Parse(brandid);
     List<VendorBrandSetQuery> stores = new List<VendorBrandSetQuery>();
     string json = string.Empty;
     try
     {
         _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
         int totalCount = 0;
         stores = _IvendorBrandSet.GetImageInfo(query);
         foreach (var item in stores)
         {
             if (!string.IsNullOrEmpty(item.image_filename))
             {
                 item.image_filename = imgServerPath + vendorOriginalPath + item.image_filename.Substring(0, 2) + "/" + item.image_filename.Substring(2, 2) + "/" + item.image_filename;
             }
         }
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores) + "}";//返回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:true,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
예제 #6
0
 /// <summary>
 /// 品牌新增
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Save(VendorBrandSetQuery model)
 {
     model.Replace4MySQL();
     int id = 0;
     StringBuilder sbSql = new StringBuilder();
     MySqlCommand mySqlCmd = new MySqlCommand();
     MySqlConnection mySqlConn = new MySqlConnection(connStr);
     try
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
             mySqlConn.Open();
         mySqlCmd.Connection = mySqlConn;
         mySqlCmd.Transaction = mySqlConn.BeginTransaction();
         mySqlCmd.CommandType = System.Data.CommandType.Text;
         sbSql.Append(@"set sql_safe_updates = 0;update serial set serial_value= serial_value+1 where serial_id=14;set sql_safe_updates = 1;");
         sbSql.AppendFormat("INSERT INTO vendor_brand (brand_id,vendor_id,brand_name,brand_sort,brand_status,image_status,image_link_mode,image_link_url,promotion_banner_image_link,resume_image_link,media_report_link_url,brand_msg,brand_msg_start_time,brand_msg_end_time,brand_createdate,brand_updatedate,brand_ipfrom,cucumber_brand,`event`,image_name,resume_Image,promotion_banner_image,short_description,brand_logo) Values((select serial_value from serial where serial_id=14),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}'); ", model.vendor_id, model.Brand_Name, model.Brand_Sort, model.Brand_Status, model.Image_Status, model.Image_Link_Mode, model.Image_Link_Url, model.Promotion_Banner_Image_Link, model.Resume_Image_Link, model.Media_Report_Link_Url, model.Brand_Msg, model.Brand_Msg_Start_Time, model.Brand_Msg_End_Time, model.Brand_Createdate, model.Brand_Createdate, model.Brand_Ipfrom, model.Cucumber_Brand, model.Event, model.Image_Name, model.Resume_Image, model.Promotion_Banner_Image, model.short_description, model.brand_logo);
         string str = model.classIds.ToString();
         string[] classid = str.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
         foreach (var item in classid)
         {
             uint class_id = Convert.ToUInt32(item);
             sbSql.AppendFormat(@"Insert into vendor_brand_set (brand_id,class_id) Values ((select serial_value from serial where serial_id=14),'{0}');", class_id);
         }
         mySqlCmd.CommandText = sbSql.ToString();
         mySqlCmd.ExecuteScalar();
         mySqlCmd.Transaction.Commit();
     }
     catch (Exception ex)
     {
         mySqlCmd.Transaction.Rollback();
         throw new Exception("VendorBrandSetDao-->Save-->" + ex.Message + " sql:" + sbSql.ToString(), ex);
     }
     finally
     {
         mySqlConn.Close();
     }
     return id;
 }
예제 #7
0
 public int Save(VendorBrandSetQuery model)
 {
     return _vendorBrandSetDao.Save(model);
 }
예제 #8
0
 public bool GetSortIsRepeat(VendorBrandSetQuery query)
 {
     StringBuilder sql = new StringBuilder();
     sql.AppendFormat("SELECT count(image_sort) as count FROM vendor_brand_story where image_sort='{0}' and brand_id='{1}' ", query.image_sort, query.Brand_Id);
     try
     {
         DataTable _dt = _dbAccess.getDataTable(sql.ToString());
         int result = Convert.ToInt32(_dt.Rows[0]["count"]);
         if (result > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetDao-->GetSortIsRepeat-->sql:" + ex.Message + sql.ToString());
     }
 }
예제 #9
0
        public List<VendorBrandSetQuery> GetVendorBrandList(VendorBrandSetQuery store, out int totalCount)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder search = new StringBuilder();
            List<VendorBrandSetQuery> list = new List<VendorBrandSetQuery>();
            StringBuilder strCount = new StringBuilder();
            store.Replace4MySQL();
            try
            {
                strSql.AppendFormat(@"select vb.brand_id,vb.vendor_id,vb.brand_name,vb.brand_sort,vb.brand_status,vb.image_name, ");
                strSql.AppendFormat(" vb.image_status,vb.image_link_mode,vb.image_link_url,vb.media_report_link_url,vb.brand_msg, ");
                strSql.AppendFormat(" vb.brand_msg_start_time,brand_msg_end_time,vb.cucumber_brand,vb.promotion_banner_image,vb.resume_image, ");
                strSql.AppendFormat(" vb.promotion_banner_image_link,vb.resume_image_link, v.vendor_name_full, v.vendor_name_simple, v.vendor_invoice A  ,v.vendor_status as vendorstatus,vb.short_description,vb.brand_logo ");
                //strSql.AppendFormat(" ebh.event_money,ebh.event_statr_time,ebh.event_end_time,vb.`event`,ebh.createdate ");
                //strSql.AppendFormat("  from vendor_brand vb left join vendor v on vb.vendor_id=v.vendor_id ");
                //strSql.AppendFormat(" LEFT JOIN (SELECT b.* from event_brand_history b INNER JOIN (SELECT brand_id ,MAX(createdate) as 'time' FROM event_brand_history GROUP BY brand_id) a on b.brand_id=a.brand_id ");
                //strSql.AppendFormat(" AND createdate = a.time) ebh ON vb.brand_id = ebh.brand_id where 1=1 ");

                strSql.AppendFormat(" FROM vendor_brand vb, vendor v WHERE vb.vendor_id = v.vendor_id ");

                strCount = strCount.Append("select count(vb.brand_id) as search_total from vendor_brand vb left join vendor v on vb.vendor_id=v.vendor_id where 1=1");
                if (store.SearchType == 1)
                {
                    search.AppendFormat(" and vendor_name_simple like '%{0}%'", store.SearchCondition);
                    strSql.AppendFormat(search.ToString());
                    strCount.AppendFormat(search.ToString());
                }
                if (store.SearchType == 2)
                {

                    search.AppendFormat(" and v.vendor_invoice like '%{0}%'", store.SearchCondition);
                    strSql.AppendFormat(search.ToString());
                    strCount.AppendFormat(search.ToString());
                }
                if (store.SearchType == 3)
                {
                    search.AppendFormat(" and brand_name like '%{0}%'", store.SearchCondition);
                    strSql.AppendFormat(search.ToString());
                    strCount.AppendFormat(search.ToString());
                }
                if (store.SearchType == 4)
                {
                    search.AppendFormat(" and vb.brand_id='{0}'", store.SearchCondition);
                    strSql.AppendFormat(search.ToString());
                    strCount.AppendFormat(search.ToString());
                }
                if (store.Brand_Id != 0)
                {
                    strSql.AppendFormat(" and vb.brand_id='{0}'", store.Brand_Id);
                    strCount.AppendFormat(" and vb.brand_id='{0}'", store.Brand_Id);
                }
                strSql.AppendFormat(" order by vb.brand_sort desc,brand_id desc ");
                totalCount = 0;
                if (store.IsPage)
                {
                    System.Data.DataTable _dt = _dbAccess.getDataTable(strCount.ToString());
                    if (_dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(_dt.Rows[0]["search_total"]);
                    }
                    strSql.AppendFormat(" limit {0},{1}", store.Start, store.Limit);
                }
                list = _dbAccess.getDataTableForObj<VendorBrandSetQuery>(strSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("VendorBrandSetDao-->GetVendorBrandList-->" + ex.Message + "sql:" + strSql.ToString(), ex);
            }
            return list;
        }
예제 #10
0
 /// <summary>
 /// 新增圖片
 /// </summary>
 /// <param name="query"></param>
 public void SaveBrandStory(VendorBrandSetQuery query)
 {
     StringBuilder strSql = new StringBuilder();
     //   string[] filenames = query.image_filename.Split(new char[] { '|' }, System.StringSplitOptions.RemoveEmptyEntries);
     //   foreach (string item in filenames)
     //   {
     strSql.AppendFormat("INSERT INTO vendor_brand_story(brand_id,image_filename,image_sort,image_state,image_createdate) VALUES('{0}','{1}','{2}','{3}','{4}');", query.Brand_Id, query.image_filename, query.image_sort, query.image_state, query.image_createdate);
     //   }
     try
     {
         _dbAccess.execCommand(strSql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetDao-->SaveBrandStory-->" + ex.Message + strSql.ToString());
     }
 }
예제 #11
0
        /// <summary>
        /// 顯示圖片信息
        /// </summary>
        /// <param name="store">傳值</param>
        /// <returns></returns>
        public List<VendorBrandSetQuery> GetImageInfo(VendorBrandSetQuery store)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat("SELECT vendor_brand_story.brand_id, vendor_brand_story.image_filename,vendor_brand_story.image_sort,vendor_brand_story.image_state,vendor_brand_story.image_createdate FROM vendor_brand_story where  brand_id='{0}' ORDER BY image_sort DESC,image_createdate DESC;", store.Brand_Id);
            try
            {
                return _dbAccess.getDataTableForObj<VendorBrandSetQuery>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("VendorBrandSetDao-->GetImageInfo-->sql:" + ex.Message + sql.ToString());
            }

        }
예제 #12
0
 /// <summary>
 ///更新圖片
 /// </summary>
 /// <param name="query">傳值</param>
 /// <returns></returns>
 public int UpdateImage(VendorBrandSetQuery query)
 {
     StringBuilder sql = new StringBuilder();
     sql.AppendFormat("set sql_safe_updates=0;UPDATE vendor_brand_story SET image_sort='{0}' ,image_state='{1}' WHERE image_filename='{2}';set sql_safe_updates=1; ", query.image_sort, query.image_state, query.image_filename);
     try
     {
         return _dbAccess.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetDao-->GetSingleImage-->" + ex.Message + sql.ToString());
     }
 }
예제 #13
0
 public VendorBrandSetQuery GetModelById(int id)
 {
     StringBuilder sql = new StringBuilder();
     VendorBrandSetQuery m = new VendorBrandSetQuery();
     try
     {
         sql.Append("SELECT brand_id,vendor_id,brand_name,brand_sort,brand_status,image_name,image_status,image_link_mode,image_link_url,media_report_link_url,brand_msg,brand_msg_start_time,brand_msg_end_time,brand_createdate,brand_updatedate,brand_ipfrom,cucumber_brand,`event`,promotion_banner_image,resume_image,promotion_banner_image_link,resume_image_link,short_description,brand_logo ");
         sql.Append(" FROM vendor_brand ");
         sql.AppendFormat("  where 1=1 and brand_id={0}", id);
         m = _dbAccess.getSinggleObj<VendorBrandSetQuery>(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetDao-->GetModelById-->" + ex.Message + " sql:" + sql.ToString(), ex);
     }
     return m;
 }
예제 #14
0
 public int Update(VendorBrandSetQuery model)
 {
     model.Replace4MySQL();
     int id = 0;
     StringBuilder sb = new StringBuilder();
     MySqlCommand mySqlCmd = new MySqlCommand();
     MySqlConnection mySqlConn = new MySqlConnection(connStr);
     try
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
             mySqlConn.Open();
         mySqlCmd.Connection = mySqlConn;
         mySqlCmd.Transaction = mySqlConn.BeginTransaction();
         mySqlCmd.CommandType = System.Data.CommandType.Text;
         sb.AppendFormat(@"UPDATE vendor_brand SET vendor_id='{0}',brand_name='{1}',brand_sort='{2}',brand_status='{3}',image_status='{4}',image_link_mode='{5}',image_link_url='{6}',promotion_banner_image_link='{7}',resume_image_link='{8}',media_report_link_url='{9}',brand_msg='{10}',brand_msg_start_time='{11}',brand_msg_end_time='{12}',brand_createdate='{13}',brand_updatedate='{14}',brand_ipfrom='{15}',cucumber_brand='{16}',image_name='{17}',Resume_Image='{18}',Promotion_Banner_Image='{19}',short_description='{20}',brand_logo='{22}' where brand_id='{21}' ;", model.vendor_id, model.Brand_Name, model.Brand_Sort, model.Brand_Status, model.Image_Status, model.Image_Link_Mode, model.Image_Link_Url, model.Promotion_Banner_Image_Link, model.Resume_Image_Link, model.Media_Report_Link_Url, model.Brand_Msg, model.Brand_Msg_Start_Time, model.Brand_Msg_End_Time, model.Brand_Createdate, model.Brand_Createdate, model.Brand_Ipfrom, model.Cucumber_Brand, model.Image_Name, model.Resume_Image, model.Promotion_Banner_Image, model.short_description, model.Brand_Id, model.brand_logo);
         sb.AppendFormat("delete from vendor_brand_set where brand_id='{0}';", model.Brand_Id);
         string str = model.classIds.ToString();
         string[] classid = str.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
         foreach (var item in classid)
         {
             id = Convert.ToInt32(item);
             sb.AppendFormat(@"insert into vendor_brand_set(class_id,brand_id) values('{0}','{1}'); ", id, model.Brand_Id);
         }
         mySqlCmd.CommandText = sb.ToString();
         mySqlCmd.ExecuteScalar();
         mySqlCmd.Transaction.Commit();
     }
     catch (Exception ex)
     {
         mySqlCmd.Transaction.Rollback();
         throw new Exception("VendorBrandSetDao-->Update-->" + ex.Message + " sql:" + sb.ToString(), ex);
     }
     finally
     {
         mySqlConn.Close();
     }
     return id;
 }
예제 #15
0
 public bool GetSortIsRepeat(VendorBrandSetQuery query)
 {
     try
     {
         return _vendorBrandSetDao.GetSortIsRepeat(query);
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetMgr-->GetSortIsRepeat-->" + ex.Message, ex);
     }
 }
예제 #16
0
        /// <summary>
        /// 獲取供應商品牌列表數據
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetVendorBrandList()
        {
            string jsonStr = string.Empty;
            List<VendorBrandSetQuery> stores = new List<VendorBrandSetQuery>();
            try
            {
                query = new VendorBrandSetQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
                int totalCount = 0;
                query.SearchType = Convert.ToInt32(Request.Params["serchs"]);
                query.SearchCondition = Request.Params["serchcontent"];
                if (!string.IsNullOrEmpty(Request.Params["relation_id"]))
                {
                    query.Brand_Id = Convert.ToUInt32(Request.Params["relation_id"].ToString());
                }
                stores = _IvendorBrandSet.GetVendorBrandList(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                #region todo:自己优化的方法--代码较多,但速度快了很多
                string brandId = " ";
                if (totalCount != 0)
                {
                    foreach (var item in stores)
                    {
                        brandId += item.Brand_Id + ",";
                    }
                    brandId = brandId.Remove(brandId.LastIndexOf(','));
                    _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
                    DataTable dtShopName = _IvendorBrandSet.GetShop(brandId);
                    foreach (var item in stores)
                    {
                        DataRow[] rShopName = dtShopName.Select("Brand_Id='" + item.Brand_Id + "'");
                        string classIds = "";
                        string class_name = "";
                        if (rShopName.Length > 0)
                        {
                            foreach (var rows in rShopName)
                            {
                                classIds += rows["class_id"] + ",";
                                class_name += rows["class_name"] + "|";
                            }
                            item.classIds = classIds.Remove(classIds.LastIndexOf(','));
                            item.class_name = class_name.Remove(class_name.LastIndexOf('|'));
                        }

                        if (Convert.ToBoolean(Request.Params["isSecret"]))
                        {

                            if (!string.IsNullOrEmpty(item.vendor_name_full))
                            {
                                item.vendor_name_full = item.vendor_name_full.Substring(0, 1) + "**";
                            }

                            if (!string.IsNullOrEmpty(item.vendor_name_simple))
                            {
                                item.vendor_name_simple = item.vendor_name_simple.Substring(0, 1) + "**";
                            }
                        }

                        item.begin_time = CommonFunction.GetNetTime(item.Brand_Msg_Start_Time);
                        item.end_time = CommonFunction.GetNetTime(item.Brand_Msg_End_Time);
                        //顯示圖片的絕對路徑
                        if (!string.IsNullOrEmpty(item.Image_Name))
                        {
                            string folder1 = item.Image_Name.Substring(0, 2) + "/"; //圖片名前兩碼
                            string folder2 = item.Image_Name.Substring(2, 2) + "/"; //圖片名第三四碼
                            item.Image_Name = imgServerPath + brandPath + folder1 + folder2 + item.Image_Name;
                        }
                        else
                        {
                            item.Image_Name = defaultImg;
                        }
                        if (!string.IsNullOrEmpty(item.Resume_Image))
                        {
                            string folder3 = item.Resume_Image.Substring(0, 2) + "/"; //圖片名前兩碼
                            string folder4 = item.Resume_Image.Substring(2, 2) + "/"; //圖片名第三四碼
                            item.Resume_Image = imgServerPath + brandPath + folder3 + folder4 + item.Resume_Image;
                        }
                        else
                        {
                            item.Resume_Image = defaultImg;
                        }
                        if (!string.IsNullOrEmpty(item.Promotion_Banner_Image))
                        {
                            string folder5 = item.Promotion_Banner_Image.Substring(0, 2) + "/"; //圖片名前兩碼
                            string folder6 = item.Promotion_Banner_Image.Substring(2, 2) + "/"; //圖片名第三四碼
                            item.Promotion_Banner_Image = imgServerPath + brandPath + folder5 + folder6 + item.Promotion_Banner_Image;
                        }
                        else
                        {
                            item.Promotion_Banner_Image = defaultImg;
                        }
                        if (!string.IsNullOrEmpty(item.brand_logo))
                        {
                            string folder5 = item.brand_logo.Substring(0, 2) + "/"; //圖片名前兩碼
                            string folder6 = item.brand_logo.Substring(2, 2) + "/"; //圖片名第三四碼
                            item.brand_logo = imgServerPath + brandPath + folder5 + folder6 + item.brand_logo;
                        }
                        else
                        {
                            item.brand_logo = defaultImg;
                        }
                    }
                }
                #endregion

                jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Newtonsoft.Json.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);
                jsonStr = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
예제 #17
0
 public List<VendorBrandSetQuery> GetVendorBrandList(VendorBrandSetQuery store, out int totalCount)
 {
     return _vendorBrandSetDao.GetVendorBrandList(store, out totalCount);
 }
예제 #18
0
        /// <summary>
        /// 圖檔維護中上傳圖片
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase UploadPicture()
        {
            string json = string.Empty;
            string errorInfo = string.Empty;
            VendorBrandSetQuery query = new VendorBrandSetQuery();
            query.Brand_Id = uint.Parse(Request.Params["brand_id"]);
            query.image_sort = 0;
            query.image_state = 1;
            query.image_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(DateTime.Now.ToString());
            _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
            ImagePathConfig();
            string fileName = String.Empty, fileExtention = String.Empty, newFileName = String.Empty, oldFileName = String.Empty;
            //string localPromoPath = imgLocalPath + vendorPath;//圖片存儲地址
            string localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址
            FileManagement fileLoad;//+++++++++++++++++
            for (int i = 0; i < Request.Files.Count; i++)
            {
                fileLoad = new FileManagement();//+++++++++++++++
                HttpPostedFileBase file = Request.Files[i];
                fileName = Path.GetFileName(file.FileName);
                string newRand = hash.Md5Encrypt(fileLoad.NewFileName(fileName) + DateTime.Now.ToString(), "32");
                fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                newFileName = newRand + fileExtention;
                string folder1 = newFileName.Substring(0, 2) + "/";//圖片名前兩碼
                string folder2 = newFileName.Substring(2, 2) + "/";//圖片名第三四碼
                string ServerPath = string.Empty;

                FTP f_cf = new FTP();
                localPromoPath = imgLocalPath + vendorOriginalPath + folder1 + folder2;//圖片存儲地址
                string s = localPromoPath.Substring(0, localPromoPath.Length - (vendorOriginalPath + folder1 + folder2).Length + 1);
                f_cf.MakeMultiDirectory(s, (vendorOriginalPath + folder1 + folder2).Substring(1, (vendorOriginalPath + folder1 + folder2).Length - 2).Split('/'), ftpuser, ftppwd);
                ServerPath = Server.MapPath(imgLocalServerPath + vendorOriginalPath + folder1 + folder2);
                fileName = newFileName;
                newFileName = localPromoPath + newFileName;//絕對路徑

                string ErrorMsg = string.Empty;     //錯誤消息
                Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                try
                {
                    //bool result = fileLoad.UpLoadFile(file, ServerPath, newFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                    bool result = fileLoad.UpLoadFile(file, ServerPath, newFileName, extention, 150, int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                    if (result)//上傳成功
                    {
                        query.image_filename = fileName;
                        _IvendorBrandSet.SaveBrandStory(query);
                        //json = "{success:true,msg:\"圖片上傳成功!\"}";
                    }
                    else
                    {
                        errorInfo += "第" + (i + 1) + "張" + ErrorMsg + "<br/>";
                        //json = "{success:false,msg:\"<div>圖片上傳成功!<br/>但第" + countError + "張" + ErrorMsg + "</div>\"}";
                    }
                    json = "{success:true,msg:\"圖片上傳成功!\"}";
                    if (!string.IsNullOrEmpty(errorInfo))
                    {
                        json = "{success:true,msg:\"<div>操作完成!<br/>但<br/>" + errorInfo + "</div>\"}";
                    }
                }
                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,msg:\"操作失敗,請稍后再試!\"}";
                    if (!string.IsNullOrEmpty(errorInfo))
                    {
                        json = "{success:false,msg:\"<div>操作失敗,請稍后再試!<br/>" + errorInfo + "</div>\"}";
                    }
                }
                fileName = String.Empty; fileExtention = String.Empty; newFileName = String.Empty; oldFileName = String.Empty;//++++++++++++++++++
                localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址//++++++++++++++++++++
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
예제 #19
0
 public int Update(VendorBrandSetQuery model)
 {
     return _vendorBrandSetDao.Update(model);
 }
예제 #20
0
        public HttpResponseBase upLoadImg()
        {
            string json = string.Empty;
            string errorInfo = string.Empty;
            VendorBrandSetQuery query = new VendorBrandSetQuery();
            query.Brand_Id = uint.Parse(Request.Params["brand_id"]);
            query.image_sort = 0;
            query.image_state = 1;
            query.image_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(DateTime.Now.ToString());
            _IvendorBrandSet = new VendorBrandSetMgr(connectionString);
            ImagePathConfig();
            string fileName = String.Empty, fileExtention = String.Empty, newFileName = String.Empty, oldFileName = String.Empty;

            //string localPromoPath = imgLocalPath + vendorPath;//圖片存儲地址
            string localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址
            FileManagement fileLoad;//+++++++++++++++++
            Boolean sort_repeat = false;
            for (int i = 0; i < Request.Files.Count; i++)
            {
                fileLoad = new FileManagement();//+++++++++++++++
                HttpPostedFileBase file = Request.Files[i];
                fileName = Path.GetFileName(file.FileName);
                fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                string[] arrary = fileName.Split('_');
                if (arrary.Length < 3)
                {
                    errorInfo += "[" + file.FileName + "] ";
                    errorInfo += Resources.Product.FILE_NAME_ERROR;
                    errorInfo += " 例:brand_1_tupian" + fileExtention;
                    continue;
                }
                string brandStr = fileName.Split('_')[0].ToString();
                string sortStr = fileName.Split('_')[1].ToString();
                string filenameStr = fileName.Split('_')[2].ToString();

                Regex reg = new Regex("^?[1-9][0-9]*$");
                if (!brandStr.Equals("brand") || !reg.IsMatch(sortStr))
                {
                    errorInfo += "[" + file.FileName + "] ";
                    errorInfo += Resources.Product.FILE_NAME_ERROR;
                    errorInfo += " 例:brand_1_tupian" + fileExtention;
                    continue;
                }
                query.image_sort = Convert.ToUInt32(sortStr);
                if (query.image_sort > 255)
                    query.image_sort = 0;  //大於數據庫存儲範圍時,默認為0;

                string newRand = hash.Md5Encrypt(fileLoad.NewFileName(fileName) + DateTime.Now.ToString(), "32");
                fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                newFileName = newRand + fileExtention;
                string folder1 = newFileName.Substring(0, 2) + "/";//圖片名前兩碼
                string folder2 = newFileName.Substring(2, 2) + "/";//圖片名第三四碼
                string ServerPath = string.Empty;

                FTP f_cf = new FTP();
                localPromoPath = imgLocalPath + vendorOriginalPath + folder1 + folder2;//圖片存儲地址
                string s = localPromoPath.Substring(0, localPromoPath.Length - (vendorOriginalPath + folder1 + folder2).Length + 1);
                f_cf.MakeMultiDirectory(s, (vendorOriginalPath + folder1 + folder2).Substring(1, (vendorOriginalPath + folder1 + folder2).Length - 2).Split('/'), ftpuser, ftppwd);
                ServerPath = Server.MapPath(imgLocalServerPath + vendorOriginalPath + folder1 + folder2);
                fileName = newFileName;
                newFileName = localPromoPath + newFileName;//絕對路徑

                string ErrorMsg = string.Empty;     //錯誤消息
                //Resource.CoreMessage = new CoreResource("Vendor");//尋找product.resx中的資源文件
                try
                {
                    bool result = fileLoad.UpLoadFile(file, ServerPath, newFileName, extention, 150, int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                    if (result)//上傳成功
                    {
                        //查詢image_sort是否存在重複
                        if (_IvendorBrandSet.GetSortIsRepeat(query))
                        {
                            sort_repeat = true;
                        }
                        query.image_filename = fileName;
                        _IvendorBrandSet.SaveBrandStory(query);
                        errorInfo += "[" + file.FileName + "] " + "上傳成功!";
                    }
                    else
                    {
                        errorInfo += "[" + file.FileName + "] " + ErrorMsg;
                    }

                }
                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);
                    errorInfo += "[" + file.FileName + "] 上傳失敗<br/>";
                    //json = "{success:false,msg:\"操作失敗,請稍后再試!\"}";
                    //if (!string.IsNullOrEmpty(errorInfo))
                    //{
                    //    json = "{success:false,msg:\"<div>操作失敗,請稍后再試!<br/>" + errorInfo + "</div>\"}";
                    //}
                }
                fileName = String.Empty; fileExtention = String.Empty; newFileName = String.Empty; oldFileName = String.Empty;//++++++++++++++++++
                localPromoPath = imgLocalPath + vendorOriginalPath;//圖片存儲地址//++++++++++++++++++++
            }
            if (sort_repeat)//
                json = "{success:true,sort_repeat:true,msg:\"<div>" + errorInfo + "</div>\"}";
            else
                json = "{success:true,sort_repeat:false,msg:\"<div>" + errorInfo + "</div>\"}";

            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
예제 #21
0
 public void SaveBrandStory(VendorBrandSetQuery query)
 {
     try
     {
         _vendorBrandSetDao.SaveBrandStory(query);
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetMgr-->SaveBrandStory-->" + ex.Message, ex);
     }
 }
예제 #22
0
 public string GetShopName(uint id)
 {
     string str = string.Empty;
     StringBuilder strid = new StringBuilder();
     StringBuilder strb = new StringBuilder();
     VendorBrandSetQuery vbs = new VendorBrandSetQuery();
     try
     {
         string strSql = string.Format("SELECT class_name,class_id from shop_class where class_id IN (SELECT class_id FROM vendor_brand_set where brand_id ={0})", id);
         DataTable dt = _dbAccess.getDataTable(strSql);
         if (dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 strb.AppendFormat(dt.Rows[i][0].ToString());
                 strb.AppendFormat("|");
                 strid.AppendFormat(dt.Rows[i][1].ToString());
                 strid.AppendFormat(",");
             }
             str += strb.ToString().Remove(strb.ToString().LastIndexOf('|')) + "$";
             str += strid.ToString().Remove(strid.ToString().LastIndexOf(','));
         }
         else
         {
             str = "";
         }
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandSetDao-->GetShopName-->" + ex.Message + "sql:" + str.ToString(), ex);
     }
     return str;
 }