Пример #1
0
        public bool Upload(int uploadType)
        {
            if (!CheckInputData())
            {
                //return false;
            }
            string sizeConfigName = "";

            switch (uploadType)
            {
            case 0: break;

            case 1: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["CategorySPImagesPath"].Trim();    //类目活动图片上传
                sizeConfigName    = "CategorySPImages";
                break;

            case 2: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["EBWebsiteImagesPath"].Trim();    //电商图片上传
                sizeConfigName    = "EBWebsiteImages";
                break;

            case 3: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["ProductSummaryImagesPath"].Trim();    //电商图片上传
                sizeConfigName    = "ProductSummaryImages";
                break;

            case 4: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["SeoTitleImagePath"].Trim();    //手工内容图片上传
                sizeConfigName    = "SeoTitleImages";
                break;

            case 5: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\QHMProductImage";    //抢红米产品图片上传
                sizeConfigName    = "QHMProductImages";
                break;

            case 6: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\QHMHome";    //抢红米首页图片上传
                sizeConfigName    = "QHMHomeImages";
                break;

            case 7: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\QHMContentImage";    //抢红米产品描述图片上传
                sizeConfigName    = "QHMContentImages";
                break;

            case 8: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QFQImage"].Trim() + "\\QFQHome";    //抢红米产品描述图片上传
                sizeConfigName    = "QFQImages";
                break;

            case 9: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\TwoClassImages";    //专题二级分类图片上传
                sizeConfigName    = "TwoClassImages";
                break;

            case 10: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\LotteryImage\\";    //牛败商城转盘抽奖图片上传
                sizeConfigName     = "LotteryImages";
                break;

            case 11: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\WX0BuyImages\\"; //微信0元购推广图片上传
                sizeConfigName     = "QHMProductImages";                                                                            //使用抢红米产品图片尺寸
                break;

            case 12: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\QHMTopicImages\\";    //牛败商城专题图
                sizeConfigName     = "QHMTopicImages";
                break;

            case 13: this.RootPath = System.Configuration.ConfigurationManager.AppSettings["QHMImage"].Trim() + "\\QHMBrandImages\\";    //牛败商城品牌图
                sizeConfigName     = "QHMBrandImages";
                break;
            }

            string imgSerPhyPath      = m_RootPath + GetImagePath(m_ImageSn, "0x0");
            string sourceImagePhyPath = m_RootPath + GetImagePath(m_ImageSn, "origin");

            ErrorMessage.WriteLog("", "imgSerPhyPath:" + imgSerPhyPath + "  sourceImagePhyPath:" + sourceImagePhyPath);
            try
            {
                // if (File.Exists(imgSerPhyPath)) File.Delete(imgSerPhyPath);
                if ((int)m_BuildImgUploadSite == 0)
                {
                    CheckDirectory(imgSerPhyPath, true);
                }
                CheckDirectory(sourceImagePhyPath, true);
                // 注释
                if (this.m_FullImgFilePath != "" && this.m_FullImgFilePath != null)
                {
                    File.Copy(this.m_FullImgFilePath, sourceImagePhyPath, true);
                }
                else
                {
                    this.m_PostedFile.SaveAs(sourceImagePhyPath);
                }
                if ((int)m_BuildImgUploadSite != 0)
                {
                    if (m_BuildImgUploadSite == ImgUploadSite.Both)
                    {
                        bool fromConfig = (m_AddStampAry == null || m_ThumbnailAry == null);
                        bool success    = false;
                        m_BuildImgUploadSite = ImgUploadSite.IT168;
                        if (fromConfig)
                        {
                            LoadSizeFromConfig(ImgUploadSite.IT168, sizeConfigName);
                        }
                        success = BuildImage();
                        m_BuildImgUploadSite = ImgUploadSite.PCPOP;
                        if (fromConfig)
                        {
                            LoadSizeFromConfig(ImgUploadSite.PCPOP, sizeConfigName);
                        }
                        return(BuildImage() && success);
                    }
                    else
                    {
                        if (m_AddStampAry == null || m_ThumbnailAry == null)
                        {
                            LoadSizeFromConfig(m_BuildImgUploadSite, sizeConfigName);
                        }
                        return(BuildImage());
                    }
                }
                else
                {
                    return(BuildImage());
                }
            }
            catch (Exception ee)
            {
                ErrorMessage.WriteLog("", "错误信息为: " + ee.ToString());
                m_ErrMsg = ee.Message;
                return(false);
            }
        }
Пример #2
0
 protected virtual void OnErrorMessage(ErrorMessageEventArgs e)
 {
     ErrorMessage?.Invoke(this, e);
 }
Пример #3
0
        public bool Upload()
        {
            if (!CheckInputData())
            {
                //return false;
            }
            string imgSerPhyPath      = m_RootPath + GetImagePath(m_ImageSn, "0x0");
            string sourceImagePhyPath = m_RootPath + GetImagePath(m_ImageSn, "origin");

            try
            {
                // if (File.Exists(imgSerPhyPath)) File.Delete(imgSerPhyPath);
                if ((int)m_BuildImgUploadSite == 0)
                {
                    CheckDirectory(imgSerPhyPath, true);
                }
                CheckDirectory(sourceImagePhyPath, true);

                // 注释
                if (this.m_FullImgFilePath != "" && this.m_FullImgFilePath != null)
                {
                    File.Copy(this.m_FullImgFilePath, sourceImagePhyPath, true);
                }
                else
                {
                    this.m_PostedFile.SaveAs(sourceImagePhyPath);
                }
                if ((int)m_BuildImgUploadSite != 0)
                {
                    if (m_BuildImgUploadSite == ImgUploadSite.Both)
                    {
                        bool fromConfig = (m_AddStampAry == null || m_ThumbnailAry == null);
                        bool success    = false;
                        m_BuildImgUploadSite = ImgUploadSite.IT168;
                        if (fromConfig)
                        {
                            LoadSizeFromConfig(ImgUploadSite.IT168);
                        }
                        success = BuildImage();
                        m_BuildImgUploadSite = ImgUploadSite.PCPOP;
                        if (fromConfig)
                        {
                            LoadSizeFromConfig(ImgUploadSite.PCPOP);
                        }
                        return(BuildImage() && success);
                    }
                    else
                    {
                        if (m_AddStampAry == null || m_ThumbnailAry == null)
                        {
                            LoadSizeFromConfig(m_BuildImgUploadSite);
                        }
                        return(BuildImage());
                    }
                }
                else
                {
                    return(BuildImage());
                }
            }
            catch (Exception ee)
            {
                ErrorMessage.WriteLog("", "错误信息为: " + ee.ToString());
                m_ErrMsg = ee.Message;
                return(false);
            }
        }