/// <summary>
 /// Copies the elements of the specified <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see> array to the end of the collection.
 /// </summary>
 /// <param name="value">An array of type <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see> containing the Components to add to the collection.</param>
 public void AddRange( Goodsattachmentinfo[] value)
 {
     for (int i = 0; (i < value.Length); i = (i + 1))
     {
         this.Add(value[i]);
     }
 }
예제 #2
0
 /// <summary>
 /// 产生附件
 /// </summary>
 /// <param name="attachmentinfo">附件描述类数组</param>
 /// <returns>附件id数组</returns>
 public static int[] CreateAttachments(Goodsattachmentinfo[] attachmentInfo)
 {
     int acount = attachmentInfo.Length;
     int icount = 0;
     int[] aid = new int[acount];
     for (int i = 0; i < acount; i++)
     {
         if (attachmentInfo[i] != null && attachmentInfo[i].Sys_noupload.Equals(""))
         {
             aid[i] = DbProvider.GetInstance().CreateGoodsAttachment(attachmentInfo[i]);
             icount++;
         }
     }
     return aid;
 }
예제 #3
0
        /// <summary>
        /// 绑定商品附件数组中的参数,返回无效商品附件个数
        /// </summary>
        /// <param name="attachmentinfo">附件类型</param>
        /// <param name="goodsid">商品id</param>
        /// <param name="msg">原有提示信息</param>
        /// <param name="categoryid">商品分类id</param>
        /// <param name="userid">用户id</param>
        /// <returns>无效商品附件个数</returns>
        public static int BindAttachment(Goodsattachmentinfo[] attachmentInfo, int goodsId, StringBuilder msg, int categoryId, int userId)
        {
            int acount = attachmentInfo.Length;
            // 附件查看权限
            string[] readperm = DNTRequest.GetString("readperm") == null ? null : DNTRequest.GetString("readperm").Split(',');
            string[] attachdesc = DNTRequest.GetString("attachdesc") == null ? null : DNTRequest.GetString("attachdesc").Split(',');
            string[] localid = DNTRequest.GetString("localid") == null ? null : DNTRequest.GetString("localid").Split(',');

            //设置无效附件计数器
            int errorAttachment = 0;
            for (int i = 0; i < acount; i++)
            {
                if (attachmentInfo[i] != null)
                {
                    if (Utils.IsNumeric(localid[i + 1]))
                        attachmentInfo[i].Sys_index = TypeConverter.ObjectToInt(localid[i + 1]);

                    attachmentInfo[i].Uid = userId;
                    attachmentInfo[i].Goodsid = goodsId;
                    attachmentInfo[i].Categoryid = categoryId;
                    attachmentInfo[i].Postdatetime = Utils.GetDateTime(); ;
                    
                    if (attachdesc != null && !attachdesc[i + 1].Equals(""))
                        attachmentInfo[i].Description = Utils.HtmlEncode(attachdesc[i + 1]);

                    if (!attachmentInfo[i].Sys_noupload.Equals(""))
                    {
                        msg.Append("<tr><td align=\"left\">");
                        msg.Append(attachmentInfo[i].Attachment);
                        msg.Append("</td>");
                        msg.Append("<td align=\"left\">");
                        msg.Append(attachmentInfo[i].Sys_noupload);
                        msg.Append("</td></tr>");
                        errorAttachment++;
                    }
                }
            }
            return errorAttachment;
        }
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(Goodsattachmentinfo value)
 {
     return(this.List.Contains(value));
 }
 public int Add(Goodsattachmentinfo value)
 {
     return(this.List.Add(value));
 }
 public void Remove(Goodsattachmentinfo value)
 {
     List.Remove(value);
 }
예제 #7
0
        /// <summary>
        /// 更新商品附件信息
        /// </summary>
        /// <param name="attachmentinfo">商品附件描述类实体</param>
        /// <returns></returns>
        public bool SaveGoodsAttachment(Goodsattachmentinfo goodsAttachmentInfo)
        {

            DbParameter[] parms = 
				{
						DbHelper.MakeInParam("@uid", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Uid),
						DbHelper.MakeInParam("@goodsid", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Goodsid),
						DbHelper.MakeInParam("@categoryid", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Categoryid),
						DbHelper.MakeInParam("@postdatetime", (DbType)SqlDbType.DateTime, 8,DateTime.Parse(goodsAttachmentInfo.Postdatetime)),
                        DbHelper.MakeInParam("@readperm", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Readperm),
						DbHelper.MakeInParam("@filename", (DbType)SqlDbType.NChar, 100,goodsAttachmentInfo.Filename),
						DbHelper.MakeInParam("@description", (DbType)SqlDbType.NChar, 100,goodsAttachmentInfo.Description),
						DbHelper.MakeInParam("@filetype", (DbType)SqlDbType.NChar, 50,goodsAttachmentInfo.Filetype),
						DbHelper.MakeInParam("@filesize", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Filesize),
						DbHelper.MakeInParam("@attachment", (DbType)SqlDbType.NChar, 100,goodsAttachmentInfo.Attachment),
                    	DbHelper.MakeInParam("@aid", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Aid)
				};
            string commandText = String.Format("Update [{0}goodsattachments]  Set [uid] = @uid, [goodsid] = @goodsid, [categoryid] = @categoryid, [postdatetime] = @postdatetime, [readperm] = @readperm, [filename] = @filename, [description] = @description, [filetype] = @filetype, [filesize] = @filesize, [attachment] = @attachment  WHERE [aid] = @aid", BaseConfigs.GetTablePrefix);

            DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);

            return true;
        }
예제 #8
0
 private static Goodsattachmentinfo LoadGoodsAttachmentinfo(IDataReader reader)
 {
     Goodsattachmentinfo goodsAttachmentInfo = new Goodsattachmentinfo();
     goodsAttachmentInfo.Aid = TypeConverter.ObjectToInt(reader["aid"]);
     goodsAttachmentInfo.Uid = TypeConverter.ObjectToInt(reader["uid"]);
     goodsAttachmentInfo.Goodsid = TypeConverter.ObjectToInt(reader["goodsid"]);
     goodsAttachmentInfo.Categoryid = TypeConverter.ObjectToInt(reader["categoryid"]);
     goodsAttachmentInfo.Postdatetime = reader["postdatetime"].ToString();
     goodsAttachmentInfo.Filename = reader["filename"].ToString().Trim();
     goodsAttachmentInfo.Description = reader["description"].ToString().Trim();
     goodsAttachmentInfo.Filetype = reader["filetype"].ToString().Trim();
     goodsAttachmentInfo.Filesize = TypeConverter.ObjectToInt(reader["filesize"]);
     goodsAttachmentInfo.Attachment = reader["attachment"].ToString().Trim();
     return goodsAttachmentInfo;
 }
예제 #9
0
 /// <summary>
 /// 保存附件信息
 /// </summary>
 /// <param name="goodsattachmentinfo">要保存的附件信息</param>
 /// <returns>是否保存成功</returns>
 public static bool SaveGoodsAttachment(Goodsattachmentinfo goodsAttachmentInfo)
 {
     return DbProvider.GetInstance().SaveGoodsAttachment(goodsAttachmentInfo);
 }
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(Goodsattachmentinfo value)
 {
     return this.List.Contains(value);
 }
 public int Add( Goodsattachmentinfo value)
 {
     return this.List.Add(value);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see> class containing the specified array of <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see> Components.
 /// </summary>
 /// <param name="value">An array of <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see> Components with which to initialize the collection. </param>
 public GoodsattachmentinfoCollection(Goodsattachmentinfo[] value)
 {                                       
     this.AddRange(value);
 }
 public void Remove(Goodsattachmentinfo value)
 {
     List.Remove(value);
 }
 public void Insert(int index, Goodsattachmentinfo value)
 {
     List.Insert(index, value);
 }
 /// <summary>
 /// Gets the index in the collection of the specified <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref=" GoodsattachmentinfoCollection">GoodsattachmentinfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(Goodsattachmentinfo value)
 {
     return this.List.IndexOf(value);
 }
 /// <summary>
 /// Gets the index in the collection of the specified <see cref=" GoodsattachmentinfoCollection"> GoodsattachmentinfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref=" GoodsattachmentinfoCollection">GoodsattachmentinfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(Goodsattachmentinfo value)
 {
     return(this.List.IndexOf(value));
 }
예제 #17
0
        public void GetGoodsAttachInfo(int attachmentid)
        {
            MallPluginBase mpb = MallPluginProvider.GetInstance();
            if (mpb == null)
            {
                AddErrLine("未安装商城插件");
                return;
            }
            goodsattachmentinfo = mpb.GetGoodsAttachmentsByAid(attachmentid);
            if (goodsattachmentinfo == null)
            {
                AddErrLine("不存在的附件ID");
                return;
            }
            // 获取该商品的信息
            goodsinfo = mpb.GetGoodsInfo(goodsattachmentinfo.Goodsid);
            if (goodsinfo == null)
            {
                AddErrLine("不存在的商品ID");
                return;
            }

            forum = Forums.GetForumInfo(mpb.GetCategoriesFid(goodsinfo.Categoryid));
            pagetitle = Utils.RemoveHtml(forum.Name);

            //添加判断特殊用户的代码
            if (!Forums.AllowViewByUserId(forum.Permuserlist, userid) && !Forums.AllowView(forum.Viewperm, usergroupid))
            {
                AddErrLine("您没有浏览该版块的权限");
                if (userid == -1)
                    needlogin = true;
                return;
            }

            //添加判断特殊用户的代码
            if (!UserAuthority.CheckUsertAttachAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                if (userid == -1)
                    needlogin = true;
                return;
            }
            // 检查用户是否拥有足够的阅读权限
            if (goodsattachmentinfo.Readperm > usergroupinfo.Readaccess && goodsattachmentinfo.Uid != userid && !Moderators.IsModer(useradminid, userid, forum.Fid))
            {
                AddErrLine("您的阅读权限不够");
                if (userid == -1)
                    needlogin = true;
                return;
            }
            if (goodsattachmentinfo.Filename.IndexOf("http") < 0 && !File.Exists(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, goodsattachmentinfo.Filename))))
            {
                AddErrLine("该附件文件不存在或已被删除");
                return;
            }

            if (goodsattachmentinfo.Filename.IndexOf("http") < 0)
                Utils.ResponseFile(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, goodsattachmentinfo.Filename)), Path.GetFileName(goodsattachmentinfo.Attachment), goodsattachmentinfo.Filetype);
            else
                HttpContext.Current.Response.Redirect(goodsattachmentinfo.Filename.Trim());
        }
 /// <summary>
 /// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
 /// </summary>
 /// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
 /// <param name="index">The index of the array at which to begin inserting.</param>
 public void CopyTo(Goodsattachmentinfo[] array, int index)
 {
     this.List.CopyTo(array, index);
 }
예제 #19
0
파일: Goods.cs 프로젝트: Vinna/DeepInSummer
        /// <summary>
        /// 获取加载附件信息的商品内容
        /// </summary>
        /// <param name="goodspramsinfo">参数列表</param>
        /// <param name="allowGetAttach">是否允许获取附件</param>
        /// <param name="attHidArray">隐藏在hide标签中的附件数组</param>
        /// <param name="attinfo">附件信息</param>
        /// <param name="message">内容信息</param>
        /// <returns>商品内容信息</returns>
        private static string GetMessageWithAttachInfo(GoodspramsInfo goodsPramsInfo, int allowGetAttach, string[] attHidArray, Goodsattachmentinfo attInfo, string message)
        {
            string forumPath = BaseConfigs.GetBaseConfig().Forumpath;
            string filesize;
            string replacement;
            if (Utils.InArray(attInfo.Aid.ToString(), attHidArray))
                return message;
        
            attInfo.Filename = attInfo.Filename.ToString().Replace("\\", "/");

            if (message.IndexOf("[attach]" + attInfo.Aid.ToString() + "[/attach]") != -1 || message.IndexOf("[attachimg]" + attInfo.Aid.ToString() + "[/attachimg]") != -1)
            {
                if (attInfo.Filesize > 1024)
                    filesize = Convert.ToString(Math.Round(Convert.ToDecimal(attInfo.Filesize) / 1024, 2)) + " K";
                else
                    filesize = attInfo.Filesize + " B";

                if (Utils.IsImgFilename(attInfo.Attachment))
                {
                    if (attInfo.Filename.ToLower().IndexOf("http") == 0)
                        replacement = "<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_" + attInfo.Aid + "\"><img border=\"0\" src=\"" + forumPath + "images/attachicons/attachimg.gif\" /></span><img src=\"" + attInfo.Filename + "\" onload=\"attachimg(this, 'load');\" onmouseover=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 0, event)\" /><div id=\"attach_" + attInfo.Aid + "_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"" + forumPath + "images/attachicons/image.gif\" /><a target=\"_blank\" href=\"" + attInfo.Filename + "\"><strong>" + attInfo.Attachment + "</strong></a>(" + filesize + ")<br/><div class=\"t_smallfont\">" + attInfo.Postdatetime + "</div></div>";
                    else
                        replacement = "<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_" + attInfo.Aid + "\"><img border=\"0\" src=\"" + forumPath + "images/attachicons/attachimg.gif\" /></span><img src=\"" + forumPath + "upload/" + attInfo.Filename + "\" onload=\"attachimg(this, 'load');\" onmouseover=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_" + attInfo.Aid + "', 0, event)\" /><div id=\"attach_" + attInfo.Aid + "_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"" + forumPath + "images/attachicons/image.gif\" /><a target=\"_blank\" href=\"" + forumPath + "upload/" + attInfo.Filename + "\"><strong>" + attInfo.Attachment + "</strong></a>(" + filesize + ")<br/><div class=\"t_smallfont\">" + attInfo.Postdatetime + "</div></div>";
                }
                else
                {
                    if (attInfo.Filename.ToLower().IndexOf("http") == 0)
                        replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/attachment.gif\" border=\"0\" /><span class=\"bold\">附件</span>: <a href=\""+ attInfo.Filename +"\" target=\"_blank\">{2}</a> ({3}, {4})", forumPath, attInfo.Aid.ToString(), attInfo.Attachment.ToString().Trim(), attInfo.Postdatetime, filesize);
                    else
                        replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/attachment.gif\" border=\"0\" /><span class=\"bold\">附件</span>: <a href=\"" + forumPath + "upload/" + attInfo.Filename + "\" target=\"_blank\">{2}</a> ({3}, {4})", forumPath, attInfo.Aid.ToString(), attInfo.Attachment.ToString().Trim(), attInfo.Postdatetime, filesize);
                }

                Regex r = new Regex(string.Format(@"\[attach\]{0}\[/attach\]|\[attachimg\]{0}\[/attachimg\]", attInfo.Aid));
                message = r.Replace(message, replacement, 1);
                message = message.Replace("[attach]" + attInfo.Aid.ToString() + "[/attach]", string.Empty);
                message = message.Replace("[attachimg]" + attInfo.Aid.ToString() + "[/attachimg]", string.Empty);
            }
            else if (attInfo.Goodsid == goodsPramsInfo.Goodsid)
            {
                ;
            }
            return message;
        }
예제 #20
0
        /// <summary>
        /// 保存上传的文件
        /// </summary>
        /// <param name="categoryid">商品分类id</param>
        /// <param name="MaxAllowFileCount">最大允许的上传文件个数</param>
        /// <param name="MaxSizePerDay">每天允许的附件大小总数</param>
        /// <param name="MaxFileSize">单个最大允许的文件字节数</param>/// 
        /// <param name="TodayUploadedSize">今天已经上传的附件字节总数</param>
        /// <param name="AllowFileType">允许的文件类型, 以string[]形式提供</param>
        /// <param name="config">附件保存方式 0=按年/月/日存入不同目录 1=按年/月/日/论坛存入不同目录 2=按论坛存入不同目录 3=按文件类型存入不同目录</param>
        /// <param name="watermarkstatus">图片水印位置</param>
        /// <param name="filekey">File控件的Key(即Name属性)</param>
        /// <returns>文件信息结构</returns>
        public static Goodsattachmentinfo[] SaveRequestFiles(int categoryId, int MaxAllowFileCount, int MaxSizePerDay, int MaxFileSize, int TodayUploadedSize, string AllowFileType, int waterMarkStatus, GeneralConfigInfo config, string fileKey)
        {
            string[] tmp = Utils.SplitString(AllowFileType, "\r\n");
            string[] AllowFileExtName = new string[tmp.Length];
            int[] MaxSize = new int[tmp.Length];

            for (int i = 0; i < tmp.Length; i++)
            {
                AllowFileExtName[i] = Utils.CutString(tmp[i], 0, tmp[i].LastIndexOf(","));
                MaxSize[i] = Utils.StrToInt(Utils.CutString(tmp[i], tmp[i].LastIndexOf(",") + 1), 0);
            }

            int saveFileCount = 0;

            int fCount = HttpContext.Current.Request.Files.Count;

            for (int i = 0; i < fCount; i++)
            {
                if (!HttpContext.Current.Request.Files[i].FileName.Equals("") && HttpContext.Current.Request.Files.AllKeys[i].Equals(fileKey))
                    saveFileCount++;
            }

            Goodsattachmentinfo[] attachmentInfo = new Goodsattachmentinfo[saveFileCount];
            if (saveFileCount > MaxAllowFileCount)
                return attachmentInfo;

            saveFileCount = 0;

            Random random = new Random(unchecked((int)DateTime.Now.Ticks));

            for (int i = 0; i < fCount; i++)
            {
                if (!HttpContext.Current.Request.Files[i].FileName.Equals("") && HttpContext.Current.Request.Files.AllKeys[i].Equals(fileKey))
                {
                    string fileName = Path.GetFileName(HttpContext.Current.Request.Files[i].FileName);
                    string fileExtName = Utils.CutString(fileName, fileName.LastIndexOf(".") + 1).ToLower();
                    string fileType = HttpContext.Current.Request.Files[i].ContentType.ToLower();
                    int fileSize = HttpContext.Current.Request.Files[i].ContentLength;
                    string newFileName = "";

                    attachmentInfo[saveFileCount] = new Goodsattachmentinfo();

                    attachmentInfo[saveFileCount].Sys_noupload = "";

                    // 判断 文件扩展名/文件大小/文件类型 是否符合要求
                    if (!(Utils.IsImgFilename(fileName) && !fileType.StartsWith("image")))
                    {
                        int extNameId = Utils.GetInArrayID(fileExtName, AllowFileExtName);

                        if (extNameId >= 0 && (fileSize <= MaxSize[extNameId]) && (MaxFileSize >= fileSize /*|| MaxAllSize == 0*/) && (MaxSizePerDay - TodayUploadedSize >= fileSize))
                        {
                            TodayUploadedSize = TodayUploadedSize + fileSize;
                            string UploadDir = Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/mall/");
                            StringBuilder saveDir = new StringBuilder("");
                            //附件保存方式 0=按年/月/日存入不同目录 1=按年/月/日/论坛存入不同目录 2=按论坛存入不同目录 3=按文件类型存入不同目录
                            if (config.Attachsave == 1)
                            {
                                saveDir.Append(DateTime.Now.ToString("yyyy"));
                                saveDir.Append(Path.DirectorySeparatorChar);
                                saveDir.Append(DateTime.Now.ToString("MM"));
                                saveDir.Append(Path.DirectorySeparatorChar);
                                saveDir.Append(DateTime.Now.ToString("dd"));
                                saveDir.Append(Path.DirectorySeparatorChar);
                                saveDir.Append(categoryId.ToString());
                                saveDir.Append(Path.DirectorySeparatorChar);
                            }
                            else if (config.Attachsave == 2)
                            {
                                saveDir.Append(categoryId);
                                saveDir.Append(Path.DirectorySeparatorChar);
                            }
                            else if (config.Attachsave == 3)
                            {
                                saveDir.Append(fileExtName);
                                saveDir.Append(Path.DirectorySeparatorChar);
                            }
                            else
                            {
                                saveDir.Append(DateTime.Now.ToString("yyyy"));
                                saveDir.Append(Path.DirectorySeparatorChar);
                                saveDir.Append(DateTime.Now.ToString("MM"));
                                saveDir.Append(Path.DirectorySeparatorChar);
                                saveDir.Append(DateTime.Now.ToString("dd"));
                                saveDir.Append(Path.DirectorySeparatorChar);
                            }


                            newFileName = (Environment.TickCount & int.MaxValue).ToString() + i + random.Next(1000, 9999) + "." + fileExtName;

                            //临时文件名称变量. 用于当启动远程附件之后,先上传到本地临时文件夹的路径信息
                            string tempFileName = "";
                            //当支持FTP上传附件且不保留本地附件时
                            if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                            {
                                // 如果指定目录不存在则建立临时路径
                                if (!Directory.Exists(UploadDir + "temp\\"))
                                    Utils.CreateDir(UploadDir + "temp\\");

                                tempFileName = "temp\\" + newFileName;
                            }
                            else
                            {
                                // 如果指定目录不存在则建立
                                if (!Directory.Exists(UploadDir + saveDir.ToString()))
                                    Utils.CreateDir(UploadDir + saveDir.ToString());
                            }
                            newFileName = saveDir.ToString() + newFileName;

                            try
                            {
                                // 如果是bmp jpg png图片类型
                                if ((fileExtName == "bmp" || fileExtName == "jpg" || fileExtName == "jpeg" || fileExtName == "png") && fileType.StartsWith("image"))
                                {

                                    Image img = Image.FromStream(HttpContext.Current.Request.Files[i].InputStream);
                                    if (config.Attachimgmaxwidth > 0 && img.Width > config.Attachimgmaxwidth)
                                        attachmentInfo[saveFileCount].Sys_noupload = "图片宽度为" + img.Width + ", 系统允许的最大宽度为" + config.Attachimgmaxwidth;

                                    if (config.Attachimgmaxheight > 0 && img.Height > config.Attachimgmaxheight)
                                        attachmentInfo[saveFileCount].Sys_noupload = "图片高度为" + img.Width + ", 系统允许的最大高度为" + config.Attachimgmaxheight;

                                    if (attachmentInfo[saveFileCount].Sys_noupload == "")
                                    {
                                        if (waterMarkStatus == 0)
                                        {
                                            //当支持FTP上传附件且不保留本地附件模式时,则先上传到临时目录下
                                            if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                                HttpContext.Current.Request.Files[i].SaveAs(UploadDir + tempFileName);
                                            else
                                                HttpContext.Current.Request.Files[i].SaveAs(UploadDir + newFileName);

                                            attachmentInfo[saveFileCount].Filesize = fileSize;
                                        }
                                        else
                                        {
                                            if (config.Watermarktype == 1 && File.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + "watermark/" + config.Watermarkpic)))
                                            {
                                                //当支持FTP上传附件且不保留本地附件模式时,则先上传到临时目录下
                                                if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                                    ForumUtils.AddImageSignPic(img, UploadDir + tempFileName, Utils.GetMapPath(BaseConfigs.GetForumPath + "watermark/" + config.Watermarkpic), config.Watermarkstatus, config.Attachimgquality, config.Watermarktransparency);
                                                else
                                                    ForumUtils.AddImageSignPic(img, UploadDir + newFileName, Utils.GetMapPath(BaseConfigs.GetForumPath + "watermark/" + config.Watermarkpic), config.Watermarkstatus, config.Attachimgquality, config.Watermarktransparency);
                                            }
                                            else
                                            {
                                                string watermarkText;
                                                watermarkText = config.Watermarktext.Replace("{1}", config.Forumtitle);
                                                watermarkText = watermarkText.Replace("{2}", "http://" + DNTRequest.GetCurrentFullHost() + "/");
                                                watermarkText = watermarkText.Replace("{3}", Utils.GetDate());
                                                watermarkText = watermarkText.Replace("{4}", Utils.GetTime());

                                                //当支持FTP上传附件且不保留本地附件模式时,则先上传到临时目录下
                                                if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                                    ForumUtils.AddImageSignText(img, UploadDir + tempFileName, watermarkText, config.Watermarkstatus, config.Attachimgquality, config.Watermarkfontname, config.Watermarkfontsize);
                                                else
                                                    ForumUtils.AddImageSignText(img, UploadDir + newFileName, watermarkText, config.Watermarkstatus, config.Attachimgquality, config.Watermarkfontname, config.Watermarkfontsize);
                                            }

                                            //当支持FTP上传附件且不保留本地附件模式时,则读取临时目录下的文件信息
                                            if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                                attachmentInfo[saveFileCount].Filesize = new FileInfo(UploadDir + tempFileName).Length;
                                            else
                                                attachmentInfo[saveFileCount].Filesize = new FileInfo(UploadDir + newFileName).Length;
                                        }
                                    }
                                }
                                else
                                {

                                    attachmentInfo[saveFileCount].Filesize = fileSize;
                                    //当支持FTP上传附件且不保留本地附件模式时,则先上传到临时目录下
                                    if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                        HttpContext.Current.Request.Files[i].SaveAs(UploadDir + tempFileName);
                                    else
                                        HttpContext.Current.Request.Files[i].SaveAs(UploadDir + newFileName);
                                }
                            }
                            catch
                            {
                                //当上传目录和临时文件夹都没有上传的文件时
                                if (!(Utils.FileExists(UploadDir + tempFileName)) && (!(Utils.FileExists(UploadDir + newFileName))))
                                {
                                    attachmentInfo[saveFileCount].Filesize = fileSize;
                                    //当支持FTP上传附件且不保留本地附件模式时,则先上传到临时目录下
                                    if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                        HttpContext.Current.Request.Files[i].SaveAs(UploadDir + tempFileName);
                                    else
                                        HttpContext.Current.Request.Files[i].SaveAs(UploadDir + newFileName);
                                }
                            }

                            try
                            {
                                //加载文件预览类指定方法
                                IPreview preview = PreviewProvider.GetInstance(fileExtName.Trim());
                                if (preview != null)
                                {
                                    preview.UseFTP = (FTPs.GetMallAttachInfo.Allowupload == 1) ? true : false;
                                    //当支持FTP上传附件且不保留本地附件模式时
                                    if (FTPs.GetMallAttachInfo.Allowupload == 1 && FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                        preview.OnSaved(UploadDir + tempFileName);
                                    else
                                        preview.OnSaved(UploadDir + newFileName);
                                }
                            }
                            catch
                            { }

                            //当支持FTP上传附件时,使用FTP上传远程附件
                            if (FTPs.GetMallAttachInfo.Allowupload == 1)
                            {
                                FTPs ftps = new FTPs();
                                //当不保留本地附件模式时,在上传完成之后删除本地tempfilename文件
                                if (FTPs.GetMallAttachInfo.Reservelocalattach == 0)
                                    ftps.UpLoadFile(newFileName.Substring(0, newFileName.LastIndexOf("\\")), UploadDir + tempFileName, FTPs.FTPUploadEnum.ForumAttach);
                                else
                                    ftps.UpLoadFile(newFileName.Substring(0, newFileName.LastIndexOf("\\")), UploadDir + newFileName, FTPs.FTPUploadEnum.ForumAttach);
                            }
                        }
                        else
                        {
                            if (extNameId < 0)
                                attachmentInfo[saveFileCount].Sys_noupload = "文件格式无效";
                            else if (MaxSizePerDay - TodayUploadedSize < fileSize)
                                attachmentInfo[saveFileCount].Sys_noupload = "文件大于今天允许上传的字节数";
                            else if (fileSize > MaxSize[extNameId])
                                attachmentInfo[saveFileCount].Sys_noupload = "文件大于该类型附件允许的字节数";
                            else
                                attachmentInfo[saveFileCount].Sys_noupload = "文件大于单个文件允许上传的字节数";
                        }
                    }
                    else
                        attachmentInfo[saveFileCount].Sys_noupload = "文件格式无效";

                    //当支持FTP上传附件时
                    if (FTPs.GetMallAttachInfo.Allowupload == 1)
                        attachmentInfo[saveFileCount].Filename = FTPs.GetMallAttachInfo.Remoteurl + "/" + newFileName.Replace("\\", "/");
                    else
                        attachmentInfo[saveFileCount].Filename = "mall/" + newFileName;

                    attachmentInfo[saveFileCount].Description = fileExtName;
                    attachmentInfo[saveFileCount].Filetype = fileType;
                    attachmentInfo[saveFileCount].Attachment = fileName;
                    attachmentInfo[saveFileCount].Postdatetime = DateTime.Now.ToString();
                    attachmentInfo[saveFileCount].Sys_index = i;
                    saveFileCount++;
                }
            }
            return attachmentInfo;
        }
예제 #21
0
            /// <summary>
            /// 获得商品附件信息(DTO)
            /// </summary>
            /// <param name="dt">要转换的数据表</param>
            /// <returns>返回商品附件信息</returns>
            public static Goodsattachmentinfo[] GetGoodsattachmentArray(DataTable dt)
            {
                if (dt == null || dt.Rows.Count == 0)
                    return null;

                Goodsattachmentinfo[] goodsAttachmentsInfoArray = new Goodsattachmentinfo[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    goodsAttachmentsInfoArray[i] = new Goodsattachmentinfo();
                    goodsAttachmentsInfoArray[i].Aid = TypeConverter.ObjectToInt(dt.Rows[i]["aid"]);
                    goodsAttachmentsInfoArray[i].Uid = TypeConverter.ObjectToInt(dt.Rows[i]["uid"]);
                    goodsAttachmentsInfoArray[i].Goodsid = TypeConverter.ObjectToInt(dt.Rows[i]["goodsid"]);
                    goodsAttachmentsInfoArray[i].Categoryid = TypeConverter.ObjectToInt(dt.Rows[i]["categoryid"]);
                    goodsAttachmentsInfoArray[i].Postdatetime = dt.Rows[i]["postdatetime"].ToString();
                    goodsAttachmentsInfoArray[i].Filename = dt.Rows[i]["filename"].ToString();
                    goodsAttachmentsInfoArray[i].Description = dt.Rows[i]["description"].ToString();
                    goodsAttachmentsInfoArray[i].Filetype = dt.Rows[i]["filetype"].ToString();
                    goodsAttachmentsInfoArray[i].Filesize = TypeConverter.ObjectToInt(dt.Rows[i]["filesize"]);
                    goodsAttachmentsInfoArray[i].Attachment = dt.Rows[i]["attachment"].ToString();
                }
                dt.Dispose();
                return goodsAttachmentsInfoArray;
            }
 public void Insert(int index, Goodsattachmentinfo value)
 {
     List.Insert(index, value);
 }
예제 #23
0
        /// <summary>
        /// 过滤临时内容中的本地临时标签
        /// </summary>
        /// <param name="aid">广告id</param>
        /// <param name="attachmentinfo">附件信息列表</param>
        /// <param name="tempMessage">临时信息内容</param>
        /// <returns>过滤结果</returns>
        public static string FilterLocalTags(int[] aid, Goodsattachmentinfo[] attachmentInfo, string tempMessage)
        {
            Match m;
            Regex r;
            for (int i = 0; i < aid.Length; i++)
            {
                if (aid[i] > 0)
                {
                    r = new Regex(@"\[localimg=(\d{1,}),(\d{1,})\]" + attachmentInfo[i].Sys_index + @"\[\/localimg\]", RegexOptions.IgnoreCase);
                    for (m = r.Match(tempMessage); m.Success; m = m.NextMatch())
                    {
                        tempMessage = tempMessage.Replace(m.Groups[0].ToString(), "[attachimg]" + aid[i] + "[/attachimg]");
                    }

                    r = new Regex(@"\[local\]" + attachmentInfo[i].Sys_index + @"\[\/local\]", RegexOptions.IgnoreCase);
                    for (m = r.Match(tempMessage); m.Success; m = m.NextMatch())
                    {
                        tempMessage = tempMessage.Replace(m.Groups[0].ToString(), "[attach]" + aid[i] + "[/attach]");
                    }
                }
            }

            tempMessage = Regex.Replace(tempMessage, @"\[localimg=(\d{1,}),\s*(\d{1,})\][\s\S]+?\[/localimg\]", string.Empty, RegexOptions.IgnoreCase);
            tempMessage = Regex.Replace(tempMessage, @"\[local\][\s\S]+?\[/local\]", string.Empty, RegexOptions.IgnoreCase);
            return tempMessage;
        }
예제 #24
0
        /// <summary>
        /// 产生商品附件
        /// </summary>
        /// <param name="attachmentinfo">商品附件描述类实体</param>
        /// <returns>商品附件id</returns>
        public int CreateGoodsAttachment(Goodsattachmentinfo goodsAttachmentInfo)
        {
            DbParameter[] parms = 
				{
						DbHelper.MakeInParam("@uid", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Uid),
						DbHelper.MakeInParam("@goodsid", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Goodsid),
						DbHelper.MakeInParam("@categoryid", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Categoryid),
						DbHelper.MakeInParam("@postdatetime", (DbType)SqlDbType.DateTime, 8,DateTime.Parse(goodsAttachmentInfo.Postdatetime)),
                        DbHelper.MakeInParam("@readperm", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Readperm),
						DbHelper.MakeInParam("@filename", (DbType)SqlDbType.NChar, 100,goodsAttachmentInfo.Filename),
						DbHelper.MakeInParam("@description", (DbType)SqlDbType.NChar, 100,goodsAttachmentInfo.Description),
						DbHelper.MakeInParam("@filetype", (DbType)SqlDbType.NChar, 50,goodsAttachmentInfo.Filetype),
						DbHelper.MakeInParam("@filesize", (DbType)SqlDbType.Int, 4,goodsAttachmentInfo.Filesize),
						DbHelper.MakeInParam("@attachment", (DbType)SqlDbType.NChar, 100,goodsAttachmentInfo.Attachment)
				};
            string commandText = String.Format("INSERT INTO [{0}goodsattachments] ([uid], [goodsid], [categoryid], [postdatetime], [readperm], [filename], [description], [filetype], [filesize], [attachment]) VALUES (@uid, @goodsid, @categoryid, @postdatetime, @readperm, @filename, @description, @filetype, @filesize, @attachment);SELECT SCOPE_IDENTITY()  AS aid", BaseConfigs.GetTablePrefix);
            return TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.Text, commandText, parms), -1);
        }