예제 #1
0
 /// <summary>
 /// 通過查詢條件獲取PromoShareCondition列表
 /// </summary>
 /// <param name="query">查詢條件</param>
 /// <param name="totalCount">數據總條數</param>
 /// <returns>PromoShareCondition列表</returns>
 public List<PromoShareConditionQuery> GetList(PromoShareConditionQuery query)
 {
     try
     {
         return _pscDao.GetList(query);
     }
     catch (Exception ex)
     {
         throw new Exception("PromoShareConditionMgr-->GetList-->" + ex.Message, ex);
     }
 }
예제 #2
0
        public void InsertIntoPromoShareCon(PromoShareCondition query)
        {
            List<PromoShareCondition> list = new List<PromoShareCondition>();
            PshareConMgr = new PromoShareConditionMgr(mySqlConnectionString);
            string json = string.Empty;
             DataTable _dt=new DataTable();
            try
            {
                for (int i = 0; i < condition.Length; i++)
                {
                    if (!string.IsNullOrEmpty(Request.Params[condition[i]]))
                    {
                        query = new PromoShareConditionQuery();
                        query.promo_id = Convert.ToInt32(Request.Params["promo_id"]);
                        query.condition_name = condition[i];
                        query.condition_value = Request.Params[ condition[i]];
                        if (query.condition_name == "picture")
                        {
                            #region 上傳圖片
                            string ErrorMsg = string.Empty;
                            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_Min_Element");
                            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 + promoPath;//圖片存儲地址
                            FileManagement fileLoad = new FileManagement();
                            if (Request.Files.Count > 0)
                            {
                                HttpPostedFileBase file = Request.Files[0];
                                string fileName = string.Empty;//當前文件名
                                string fileExtention = string.Empty;//當前文件的擴展名
                                fileName = fileLoad.NewFileName(file.FileName);
                                if (fileName != "")
                                {
                                    fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                                    fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                                    string NewFileName = string.Empty;
                                    HashEncrypt hash = new HashEncrypt();
                                    NewFileName = hash.Md5Encrypt(fileName, "32");
                                    string ServerPath = string.Empty;
                                    FTP f_cf = new FTP();
                                    f_cf.MakeMultiDirectory(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'), ftpuser, ftppwd);
                                    fileName = NewFileName + fileExtention;
                                    NewFileName = localPromoPath + NewFileName + fileExtention;//絕對路徑
                                    ServerPath = Server.MapPath(imgLocalServerPath + promoPath);

                                    //上傳之前刪除已有的圖片
                                    if (query.promo_id != 0)
                                    {
                                        _dt = PshareConMgr.Get(condition, query);
                                        if (_dt.Rows[0]["picture"].ToString() != "")
                                        {
                                            string oldFileName = _dt.Rows[0]["picture"].ToString();
                                            CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                            FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                            List<string> tem = ftp.GetFileList();
                                            if (tem.Contains(oldFileName))
                                            {
                                                FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                                ftps.DeleteFile(localPromoPath + oldFileName);
                                            }
                                        }
                                    }
                                    try
                                    {
                                        Resource.CoreMessage = new CoreResource("Product");
                                        bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                        if (result)
                                        {
                                            query.condition_value = fileName;
                                        }

                                    }
                                    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);
                                    }
                                    if (!string.IsNullOrEmpty(ErrorMsg))
                                    {
                                        string jsonStr = string.Empty;
                                        json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                                        this.Response.Clear();
                                        this.Response.Write(json);
                                        this.Response.End();
                                    }

                                }
                            }
                            else
                            {
                                query.condition_value = _dt.Rows[0]["picture"].ToString();
                            }
                            #endregion
                        }
                        list.Add(query);
                    }
                }
             
                PshareConMgr.AddSql(list);
            }
            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}";
            }
        }
예제 #3
0
 public HttpResponseBase PromoShareConditionList()
 {
     PromoShareConditionQuery query = new PromoShareConditionQuery();
     List<PromoShareConditionQuery> store = new List<PromoShareConditionQuery>();
     string json = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["promo_id"]))
         {
             query.promo_id = Convert.ToInt32(Request.Params["promo_id"]);
         }
         PshareConMgr = new PromoShareConditionMgr(mySqlConnectionString);
         store = PshareConMgr.GetList(query);
         if (store.Count>0)
         {
             for (int i = 0; i < store.Count; i++)
             {
                 //處理數據使"條件名稱"與"對應值"顯示對應描述
                 //store[i].
             }   
         }
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,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:true,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
예제 #4
0
 /// <summary>
 /// 通過查詢條件獲取PromoShareCondition列表
 /// </summary>
 /// <param name="query">查詢條件</param>
 /// <param name="totalCount">數據總條數</param>
 /// <returns>PromoShareCondition列表</returns>
 public List<PromoShareConditionQuery> GetList(PromoShareConditionQuery query)
 {
     List<PromoShareConditionQuery> list = new List<PromoShareConditionQuery>();
     StringBuilder sbSql = new StringBuilder();
     StringBuilder sbSqlCondition = new StringBuilder();
     sbSql.Append("SELECT condition_id,condition_name,condition_value,promo_id ");
     sbSqlCondition.Append(" FROM promo_share_condition WHERE 1=1 ");
     if (query.condition_id != 0)
     {
         sbSqlCondition.AppendFormat(" and condition_id in({0}) ", query.condition_id);
     }
     if (query.condition_type_id!=0)
     {
         sbSqlCondition.AppendFormat(" and condition_type_id in({0}) ", query.condition_type_id);
     }
     if (!string.IsNullOrEmpty(query.condition_name))
     {
         sbSqlCondition.AppendFormat(" and condition_name like '%{0}%' ", query.condition_name);
     }
     if (!string.IsNullOrEmpty(query.condition_value))
     {
         sbSqlCondition.AppendFormat(" and condition_value like '%{0}%' ", query.condition_value);
     }
     if (query.promo_id!=0)
     {
         sbSqlCondition.AppendFormat(" and promo_id in({0}) ", query.promo_id);
     }
     try
     {
         list = _access.getDataTableForObj<PromoShareConditionQuery>(sbSql.Append(sbSqlCondition).ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("PromoShareConditionDao-->GetList-->" + ex.Message + sbSql.Append(sbSqlCondition).ToString(), ex);
     }
     return list;
 }