示例#1
0
        /// <summary>
        /// 添加新的分类
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="adminname"></param>
        /// <param name="fcif"></param>
        /// <returns></returns>
        public int AddFileInfoByAdmin(FileResources fif)
        {
            //文件所在的文件夹不能为空
            if (fif.iClassId == 0)
            {
                return -1000000060;
            }

            //文件名称不能为空
            if (string.IsNullOrEmpty(fif.vcFileName))
            {
                return -1000000061;
            }

            //文件类型不能为空
            if (string.IsNullOrEmpty(fif.vcType))
            {
                return -1000000062;
            }

            //文件类型不能为空
            if (fif.iSize==0)
            {
                return -1000000063;
            }

            string sql= "INSERT INTO fileresources (iID,iClassId,vcFileName,iSize,vcType,dCreateDate,vcIP)"
                                        + "VALUES('" + fif.Id + "'," + fif.iClassId + ",'" + fif.vcFileName + "'," + fif.iSize + ",'"
                                        + fif.vcType + "',now(),'" + fif.vcIP + "')";

            string errText = string.Empty;
            return AccessFactory.conn.m_RunSQL(ref errText, sql);
        }
示例#2
0
        /// <summary>
        /// 添加新的分类
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="adminname"></param>
        /// <param name="fcif"></param>
        /// <returns></returns>
        public int AddFileInfoByAdmin(Admin adminf, FileResources fif)
        {
            int rtn = HandlersFactory.adminHandlers.CheckAdminPower(adminf);
            if (rtn < 0) return rtn;

            //文件所在的文件夹不能为空
            if (fif.iClassId == 0)
            {
                return -1000000060;
            }

            //文件名称不能为空
            if (string.IsNullOrEmpty(fif.vcFileName))
            {
                return -1000000061;
            }

            //文件类型不能为空
            if (string.IsNullOrEmpty(fif.vcType))
            {
                return -1000000062;
            }

            //文件类型不能为空
            if (fif.iSize==0)
            {
                return -1000000063;
            }

            return DataBaseFactory.FileHandlers.AddFileInfoByAdmin(fif);
        }
示例#3
0
 /// <summary>
 /// 从记录行中得到实体
 /// </summary>
 /// <param name="?"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public EntityBase GetEntityObjectFromRow(DataRow row, Type type)
 {
     if (row == null) return null;
     switch (type.ToString())
     {
         case "TCG.Entity.Categories":
             Categories categories = new Categories();
             categories.Id = row["Id"].ToString().Trim();
             categories.ResourceListTemplate = this.handlerService.skinService.templateHandlers.GetTemplateByID(row["iListTemplate"].ToString());
             categories.iOrder = (int)row["iOrder"];
             categories.Parent = row["Parent"].ToString().Trim();
             categories.ResourceTemplate = this.handlerService.skinService.templateHandlers.GetTemplateByID(row["iTemplate"].ToString());
             categories.vcClassName = row["vcClassName"].ToString().Trim();
             categories.vcDirectory = row["vcDirectory"].ToString().Trim();
             categories.vcName = row["vcName"].ToString().Trim();
             categories.vcUrl = row["vcUrl"].ToString().Trim();
             categories.dUpdateDate = (DateTime)row["dUpdateDate"];
             categories.cVisible = row["Visible"].ToString().Trim();
             categories.DataBaseService = row["DataBaseService"].ToString().Trim();
             //categories.SkinInfo = row["SkinId"].ToString().Trim();
             return (EntityBase)categories;
         case "TCG.Entity.Resources":
             Resources resources = new Resources();
             resources.Id = row["iId"].ToString();
             resources.vcTitle = row["vcTitle"].ToString();
             resources.Categorie = this.handlerService.skinService.categoriesHandlers.GetCategoriesById(row["iClassID"].ToString());
             resources.vcUrl = (string)row["vcUrl"].ToString();
             resources.vcContent = (string)row["vcContent"].ToString().Trim();
             resources.vcAuthor = (string)row["vcAuthor"].ToString().Trim();
             resources.iCount = (int)row["iCount"];
             resources.vcKeyWord = (string)row["vcKeyWord"].ToString().Trim();
             resources.vcEditor = (string)row["vcEditor"].ToString().Trim();
             resources.cCreated = (string)row["cCreated"].ToString().Trim();
             resources.vcSmallImg = (string)row["vcSmallImg"].ToString().Trim();
             resources.vcBigImg = (string)row["vcBigImg"].ToString().Trim();
             resources.vcShortContent = (string)row["vcShortContent"].ToString().Trim();
             resources.vcSpeciality = (string)row["vcSpeciality"].ToString().Trim();
             resources.cChecked = (string)row["cChecked"].ToString().Trim();
             resources.cDel = (string)row["cDel"].ToString().Trim();
             resources.cPostByUser = (string)row["cPostByUser"].ToString().Trim();
             resources.vcFilePath = (string)row["vcFilePath"].ToString().Trim();
             resources.dAddDate = (DateTime)row["dAddDate"];
             resources.dUpDateDate = (DateTime)row["dUpDateDate"];
             resources.vcTitleColor = (string)row["vcTitleColor"].ToString().Trim();
             resources.cStrong = (string)row["cStrong"].ToString().Trim();
             resources.SheifUrl = (string)row["SheifUrl"].ToString().Trim();
             CachingService.Set(resources.Id, resources, null);
             return (EntityBase)resources;
         case "TCG.Entity.Template":
             Template template = new Template();
             template.Id = row["Id"].ToString();
             //template.SkinInfo = row["SkinId"].ToString();
             template.TemplateType = this.handlerService.skinService.templateHandlers.GetTemplateType((int)row["TemplateType"]);
             template.iParentId = row["iParentId"].ToString();
             template.iSystemType = (int)row["iSystemType"];
             template.vcTempName = (string)row["vcTempName"];
             template.Content = (string)row["vcContent"];
             template.vcUrl = (string)row["vcUrl"];
             template.dAddDate = (DateTime)row["dAddDate"];
             template.dUpdateDate = (DateTime)row["dUpdateDate"];
             return (EntityBase)template;
         case "TCG.Entity.Skin":
             Skin skin = new Skin();
             skin.Id = row["Id"].ToString().Trim();
             skin.Name = row["Name"].ToString().Trim();
             skin.Pic = row["Pic"].ToString().Trim();
             //skin.Info = row["info"].ToString().Trim();
             skin.Filename = row["Filename"].ToString().Trim();
             return (EntityBase)skin;
         case "TCG.Entity.SheifSourceInfo":
             SheifSourceInfo sourceinfo = new SheifSourceInfo();
             sourceinfo.Id = row["ID"].ToString().Trim();
             sourceinfo.SourceName = row["SourceName"].ToString().Trim();
             sourceinfo.SourceUrl = row["SourceUrl"].ToString().Trim();
             sourceinfo.CharSet = row["CharSet"].ToString().Trim();
             sourceinfo.ListAreaRole = row["ListAreaRole"].ToString().Trim();
             sourceinfo.TopicListRole = row["TopicListRole"].ToString().Trim();
             sourceinfo.TopicListDataRole = row["TopicListDataRole"].ToString().Trim();
             sourceinfo.TopicRole = row["TopicRole"].ToString().Trim();
             sourceinfo.TopicDataRole = row["TopicDataRole"].ToString().Trim();
             sourceinfo.TopicPagerOld = row["TopicPagerOld"].ToString().Trim();
             sourceinfo.TopicPagerTemp = row["TopicPagerTemp"].ToString().Trim();
             sourceinfo.IsRss = (bool)row["IsRss"];
             return (EntityBase)sourceinfo;
         case "TCG.Entity.FileCategories":
             FileCategories filecagegories = new FileCategories();
             filecagegories.Id = row["iId"].ToString();
             filecagegories.iParentId = objectHandlers.ToInt(row["iParentId"]);
             filecagegories.dCreateDate = objectHandlers.ToTime(row["dCreateDate"].ToString());
             filecagegories.vcFileName = row["vcFileName"].ToString().Trim();
             filecagegories.vcMeno = row["vcMeno"].ToString().Trim();
             filecagegories.vcKey = row["vcKey"].ToString().Trim();
             filecagegories.MaxSpace = objectHandlers.ToLong(row["MaxSpace"]);
             filecagegories.Space = objectHandlers.ToLong(row["Space"]);
             return (EntityBase)filecagegories;
         case "TCG.Entity.FileResources":
             FileResources fileresource = new FileResources();
             fileresource.Id = row["iID"].ToString().Trim();
             fileresource.iClassId = (int)row["iClassId"];
             fileresource.iSize = (int)row["iSize"];
             fileresource.vcFileName = row["vcFileName"].ToString().Trim();
             fileresource.vcIP = row["vcIP"].ToString().Trim();
             fileresource.vcType = row["vcType"].ToString().Trim();
             fileresource.iRequest = (int)row["iRequest"];
             fileresource.iDowns = (int)row["iDowns"];
             fileresource.dCreateDate = (DateTime)row["dCreateDate"];
             return (EntityBase)fileresource;
         case "TCG.Entity.SheifCategorieConfig":
             SheifCategorieConfig sheifcategorieconfig = new SheifCategorieConfig();
             sheifcategorieconfig.Id = row["Id"].ToString();
             sheifcategorieconfig.SheifSourceId = row["SheifSourceId"].ToString().Trim();
             sheifcategorieconfig.LocalCategorieId = row["LocalCategorieId"].ToString().Trim();
             sheifcategorieconfig.ResourceCreateDateTime = objectHandlers.ToTime(row["ResourceCreateDateTime"].ToString().Trim());
             return (EntityBase)sheifcategorieconfig;
     }
     return null;
 }
示例#4
0
        public int UploadFile(byte[] _bytes, Admin adminname, string imagetype, int fileclassid, ref string imagepath)
        {
            if (!IsAllowImgExtension(imagetype))
            {
                return -1000000401;
            }

            MemoryStream ms = new MemoryStream(_bytes);

            Image image = Image.FromStream(ms);

            FileResources imgfile = new FileResources();

            imgfile.Id = this.GetFlieName();
            imgfile.iClassId = fileclassid;

            imgfile.vcFileName = imgfile.Id + imagetype;
            imgfile.vcType = imagetype;

            imgfile.iSize = 100;

            string filepatch = this.GetFilePath(imgfile.vcFileName, fileclassid, ref imagepath);
            FileStream fs = null;
            try
            {
                objectHandlers.SaveFile(filepatch, "");
                fs = new FileStream(filepatch, FileMode.Create);
                ms.WriteTo(fs);

                //int rtn = 0;
                //if (adminname != null)
                //{
                //    rtn = this.AddFileInfoByAdmin(adminname, imgfile);
                //}

                //if (rtn < 0)
                //{
                //    System.IO.File.Delete(filepatch);
                //}
                //else
                //{
                //    imagepath = "/attach.aspx?id=" + imgfile.Id;
                //}

                return 1;
            }
            catch (Exception ex)
            {
                return -1000000402;
            }
            finally
            {
                ms.Close();
                if (fs != null)
                {
                    fs.Close();
                }
                image.Dispose();
            }
        }
示例#5
0
        /// <summary>
        /// 获取文章中间外部网站的图片
        /// </summary>
        /// <param name="content"></param>
        /// <param name="url"></param>
        /// <param name="adminname"></param>
        /// <param name="fileclassid"></param>
        /// <returns></returns>
        public string ImgPatchInit(Resources resource, string url, Admin adminname, int fileclassid)
        {
            string parrten = "<(img|IMG)[^>]+src=\"([^\"]+)\"[^>]*>";
            MatchCollection matchs = Regex.Matches(resource.vcContent, parrten, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            string temp = "";
            foreach (Match item in matchs)
            {
                string text1 = item.Result("$2");
                string domainstr = string.Empty;// objectHandlers.GetDomainName(text1);
                string domainstr1 = objectHandlers.GetDomainName(ConfigServiceEx.baseConfig["WebSite"]);
                if (!string.IsNullOrEmpty(domainstr) && domainstr != domainstr1)
                {
                    FileResources imgfile = new FileResources();

                    imgfile.Id = this.GetFlieName();
                    imgfile.iClassId = fileclassid;
                    string text2 = UrlCheck(text1, resource);
                    bool isload = false;
                    try
                    {
                        WebRequest myre = WebRequest.Create(text2);
                        isload = true;
                    }
                    catch (Exception ex)
                    {

                    }

                    if (isload)
                    {
                        WebClient wc = new WebClient();
                        byte[] b = wc.DownloadData(text2);
                        Stream s = new MemoryStream(b);

                        System.Drawing.Image loadimage = null;
                        try
                        {
                            loadimage = System.Drawing.Image.FromStream(s);
                        }
                        catch { }

                        if (loadimage != null)
                        {
                            if (loadimage.RawFormat.Equals(ImageFormat.Jpeg))
                            {
                                imgfile.vcType = ".jpg";
                            }
                            else if (loadimage.RawFormat.Equals(ImageFormat.Png))
                            {
                                imgfile.vcType = ".png";
                            }
                            else if (loadimage.RawFormat.Equals(ImageFormat.Tiff))
                            {
                                imgfile.vcType = ".tiff";
                            }
                            else if (loadimage.RawFormat.Equals(ImageFormat.Bmp))
                            {
                                imgfile.vcType = ".bmp";
                            }
                            else if (loadimage.RawFormat.Equals(ImageFormat.Gif))
                            {
                                imgfile.vcType = ".gif";
                            }
                            else
                            {
                                imgfile.vcType = ".jpg";
                            }

                            imgfile.iSize = b.Length;
                            string filename = imgfile.Id + imgfile.vcType;

                            string imagepath1 = string.Empty;

                            string filepatch = this.GetFilePath(filename, fileclassid, ref imagepath1);
                            try
                            {
                                objectHandlers.SaveFile(filepatch, "");

                                loadimage.Save(filepatch);
                                //int rtn = this.AddFileInfoByAdmin(adminname, imgfile);
                                //if (rtn < 0)
                                //{
                                //    System.IO.File.Delete(filepatch);
                                //}
                                //else
                                //{
                                //    resource.vcContent = resource.vcContent.Replace(text1, imagepath1);
                                //}

                                resource.vcContent = resource.vcContent.Replace(text1, imagepath1);
                            }
                            catch
                            {
                            }
                        }

                        imgfile = null;
                        wc = null;
                    }
                }
            }
            return resource.vcContent;
        }
        /// <summary>
        /// ����µķ���
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="adminname"></param>
        /// <param name="fcif"></param>
        /// <returns></returns>
        public int AddFileInfoByAdmin(string adminname, FileResources fif)
        {
            if (!base.SetFileDatabase(fif.Id)) return -19000000;
            SqlParameter sp0 = new SqlParameter("@vcAdminName", SqlDbType.VarChar, 50); sp0.Value = adminname;
            SqlParameter sp1 = new SqlParameter("@vcip", SqlDbType.VarChar, 15); sp1.Value = objectHandlers.UserIp;
            SqlParameter sp2 = new SqlParameter("@iID", SqlDbType.BigInt, 8); sp2.Value = fif.Id;
            SqlParameter sp3 = new SqlParameter("@iClassId", SqlDbType.Int, 4); sp3.Value = fif.iClassId;
            SqlParameter sp4 = new SqlParameter("@vcFileName", SqlDbType.NVarChar, 100); sp4.Value = fif.vcFileName;
            SqlParameter sp5 = new SqlParameter("@iSize", SqlDbType.Int, 4); sp5.Value = fif.iSize;
            SqlParameter sp6 = new SqlParameter("@vcType", SqlDbType.VarChar, 10); sp6.Value = fif.vcType;
            SqlParameter sp7 = new SqlParameter("@reValue", SqlDbType.Int); sp7.Direction = ParameterDirection.Output;

            string[] reValues = base.conn.Execute("SP_Files_FileInfoManageByAdmin", new SqlParameter[] { sp0, sp1,
                sp2, sp3, sp4, sp5, sp6, sp7 }, new int[] { 7 });
            if (reValues != null)
            {
                int rtn = (int)Convert.ChangeType(reValues[0], typeof(int));
                return rtn;
            }
            return -19000000;
        }