Exemplo n.º 1
0
        /// <summary>
        /// 根据资源类型生成对应的类,image video document 
        /// </summary>
        /// <param name="resourceType"></param>
        /// <returns></returns>
        public static IResourceType getResourceTypeByString(string resourceType)
        {
            IResourceType obj;

            resourceType = resourceType.ToLower();

            if (resourceType.Equals("image"))
            {
                obj = new ImageType();
            }
            else if (resourceType.Equals("video"))
            {
                obj = new VideoType();
            }
            else if (resourceType.Equals("document"))
            {
                obj = new DocumentType();
            }
            else
            {
                obj = new OtherType();
            }
            return obj;

        }
Exemplo n.º 2
0
        protected void GetVideoInfo(string itemId)
        {
             
            Resource r=new Resource();
            ResourceEntity vs = r.GetResourceInfoByItemId(itemId);

            VideoType obj = new VideoType();
            //yangguang
            //string previewPath = obj.PreviewPathRead;
            //if(string.IsNullOrEmpty(previewPath))
            //{
            //    return;
            //}

            if (vs != null)
            {
                folder = vs.FolderName;
                //yangguang
                //flvFilePath = previewPath + "/flv/" + vs.FolderName + "/" + vs.ItemSerialNum + ".flv";
                //imageFilePath = previewPath + "/image/" + vs.FolderName + "/" + vs.ItemSerialNum + ".jpg";
                //flvFilePath = obj.GetPreviewPath(vs.FolderName, vs.ItemSerialNum + ".flv", "flv");
                flvFilePath = obj.GetPreviewPathRead(vs.FolderName, vs.ItemSerialNum + ".flv", "flv");
                imageFilePath = obj.GetPreviewPathRead(vs.FolderName, vs.ItemSerialNum + ".jpg", "image");// + "/image/" + vs.FolderName + "/" + vs.ItemSerialNum + ".jpg";
                this.lb_Caption.Text = vs.Caption;
                this.lb_Description.Text = vs.Description;
                this.lb_enableDate.Text = string.Format("{0} -- {1}", vs.StartDate.ToShortDateString(), vs.EndDate.ToShortDateString());
                this.lb_FileName.Text = vs.FileName;
                this.lb_ItemSerialNum.Text = vs.ItemSerialNum;
                this.lb_Keyword.Text = vs.Keyword;
                this.lb_shotDate.Text = vs.shotDate.ToShortDateString();
                this.lb_uploadDate.Text = vs.uploadDate.ToShortDateString();
                this.lb_FileType.Text = Path.GetExtension(vs.FileName);
                this.lb_FileLength.Text = Tool.toFileSize( vs.FileSize);
                this.pageTitle.Text = vs.Caption;

                if (vs.ResourceType.Equals("video"))
                { 
                    VideoStorage v=r.GetVideoInfoBySN(vs.ItemSerialNum);
                    if (v != null)
                    {
                        if (v.ClipLength.Length > 8)
                        {
                            this.lb_duration.Text = v.ClipLength.Substring(0, 8);
                        }
                        this.lb_wh.Text = v.ClipSize;
                        this.lb_bitrate.Text = v.Bitrate;
                    }                    

                }
            
            }

            
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据文件扩展名来生成对应的资源类型
        /// </summary>
        /// <param name="fileExtention"></param>
        /// <returns></returns>
        public static IResourceType getResourceType(string fileExtention)
        {
            IResourceType obj;

            fileExtention = fileExtention.ToLower();

            if (ArrayContains(new ImageType().FileExtention, fileExtention))
            {
                obj = new ImageType();                
            }
            else if (ArrayContains(new VideoType().FileExtention, fileExtention))
            {
                obj = new VideoType();
            }
            else if (ArrayContains(new DocumentType().FileExtention, fileExtention))
            {
                obj = new DocumentType();
            }
            else
            {
                obj = new OtherType();
            }
            return obj;
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            HttpRequest Request = context.Request;
            HttpResponse Response = context.Response;

            Response.ContentType = "text/plain";

            string action = Request.QueryString["action"];

            if (string.IsNullOrEmpty(action))
            { 
                
            
            }
            else if (action.Trim().ToLower().Equals("validatealert"))
            {
                //是否提醒
                Resource obj = new Resource();
                string userId = Request.QueryString["userId"];
                string isSuperAdmin=Request.QueryString["isSuperAdmin"];

                if (!string.IsNullOrEmpty(userId))
                {
                    if(string.IsNullOrEmpty(isSuperAdmin))
                    {
                        isSuperAdmin="0";
                    }

                    if (obj.IsAlertAdmin(new Guid(userId),isSuperAdmin))
                    {
                        Response.Write("1"); //有新的图片等待审核
                        Response.End();
                    }
                    else
                    {
                        Response.Write("0"); //没有需要审核的图片
                        Response.End();
                    }



                }
                Response.Write("0"); //不用提醒
                Response.End();
            }
            else if (action.Trim().ToLower().Equals("delbatch"))
            { 
                //批量删除

                string itemIds = Request.Form["itemIds"];
                if (string.IsNullOrEmpty(itemIds))
                {
                    Response.Write("0"); //参数错误
                    Response.End();
                    
                }
                itemIds = itemIds.TrimEnd(";".ToCharArray());

                string userId = Request.QueryString["userId"];

                string[] arrId = itemIds.Split(";".ToCharArray());
                foreach (string id in arrId)
                {
                    //删除的图片要记录一下

                    byte[] buffer;

                    ResourceEntity re = null;
                    Resource r = new Resource();
                    re = r.GetResourceInfoByItemId(id);
                    
                    string ItemSerialNum = "";
                    string ImageType = "";
                    string str = "";//判断170图片或者400图片有没有被删除

                    ItemSerialNum = re.ItemSerialNum;
                    //ItemSerialNum = lb_ItemSerialNum.Text;
                    //ImageType = lb_ImageType.Text;
                    //bool isValidate = QJVRMS.Business.ImageStorageClass.DeleteImageStorage(new Guid(this.Hidden_ItemId.Value));

                    bool isValidate = Resource.DeleteResource(re.ItemId);
                    string attachmentFolder = string.Empty;

                    string sourceFolder = string.Empty;
                    string attachmentsFolder = string.Empty;
                    if (re.ResourceType.ToLower().Equals("image"))
                    {
                        string _170Folder;
                        string _400Folder;

                        ImageType obj = new ImageType();
                        
                        try
                        {
                            
                            //记录图片
                            
                            string img = obj.GetPreviewPath(re.FolderName, re.ServerFileName, "170");
                            ImageHelper objImgHelper = new ImageHelper(img);
                            objImgHelper.Resize(80);
                            using (MemoryStream ms = new MemoryStream())
                            {
                                objImgHelper.GetImage().Save(ms, ImageFormat.Jpeg);
                                buffer = ms.ToArray();
                            }
                            objImgHelper.Dispose();



                            //记录日志
                            if (!string.IsNullOrEmpty(userId))
                            {
                                User objUser = new MemberShipManager().GetUser(new Guid(userId));
                                if (objUser != null)
                                {

                                    //日志,所有的删除,只记录一次
                                    LogEntity model = new LogEntity();
                                    model.id = Guid.NewGuid();
                                    model.userId = objUser.UserId;
                                    model.userName = objUser.UserLoginName;
                                    model.EventType = ((int)LogType.DeleteResource).ToString();
                                    model.EventResult = "成功";
                                    model.EventContent = "图片序号:"+re.ItemSerialNum;
                                    model.IP = HttpContext.Current.Request.UserHostAddress;
                                    model.AddDate = DateTime.Now;
                                    new Logs().Add(model);

                                    r.SaveDeletedImage(model.id, buffer);
                                }

                            }


                            File.Delete(obj.GetSourcePath(re.FolderName, re.ServerFileName));
                            attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim();
                            File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "170"));
                            File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "400"));



                        }
                        catch { }
                    }
                    else if (re.ResourceType.ToLower().Equals("video"))
                    {
                        string _previewPolder = CommonInfo.VideoPreviewPath;

                        VideoType obj = new VideoType();
                        
                        try
                        {
                            File.Delete(obj.GetSourcePath(string.Empty, re.ServerFileName));
                            attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim();
                            File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "flv"));
                            File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "image"));
                            File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "smallflv"));
                        }
                        catch
                        {

                        }
                    }

                    //sourceFolder = Path.Combine(sourceFolder, CurrentUser.UserLoginName);
                    //sourceFolder = Path.Combine(sourceFolder, WebUI.UIBiz.CommonInfo.AttachFolder);

                    #region 删除物理文件 by ciqq 2010-4-2
                   
                    //删除所有的附件
                    //string sourceFolder = Path.Combine(WebUI.UIBiz.CommonInfo.ImageRootPath, this.hiFolder.Value);

                    //根据资源ID获得所有的附件

                    DataTable dt = Resource.GetAttachList(new Guid(id));

                    //dt.Columns.Add("fileNamefileLength");

                    //foreach (DataRow dr in dt.Rows)
                    //{
                    //    dr["fileNamefileLength"] = dr["filename"].ToString() + " ( " + Tool.toFileSize(Convert.ToInt64(dr["fileLength"].ToString())) + " ) ";

                    //}

                    //this.attList.DataSource = dt;
                    //this.attList.DataBind();


                    string fileName = "";
                    attachmentsFolder = Path.Combine(attachmentsFolder, re.FolderName);
                    attachmentsFolder = Path.Combine(attachmentsFolder, UIBiz.CommonInfo.AttachFolder);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        //fileName = this.attList.DataKeys[i].Values[1].ToString();
                        fileName = dt.Rows[i]["filename"].ToString();
                        fileName = Path.Combine(attachmentsFolder, fileName);
                        try
                        {
                            File.Delete(fileName);
                        }
                        catch (Exception ex)
                        {
                            LogWriter.WriteExceptionLog(ex);
                        }
                    }                   
                    #endregion
                }


                

                Response.Write("0"); //不用提醒
                Response.End();


                
              
                
            }


        }
Exemplo n.º 5
0
        //删除文件
        protected void btnDel_Click(object sender, EventArgs e) {

            ResourceEntity re = null;
            Resource r = new Resource();
            if (ViewState["model"] != null) {
                re = ViewState["model"] as ResourceEntity;
            }
            else {
                re = r.GetResourceInfoByItemId(this.Hidden_ItemId.Value);
            }

            string ItemSerialNum = "";
            string ImageType = "";
            string str = "";//判断170图片或者400图片有没有被删除
            ItemSerialNum = lb_ItemSerialNum.Text;
            //ImageType = lb_ImageType.Text;
            //bool isValidate = QJVRMS.Business.ImageStorageClass.DeleteImageStorage(new Guid(this.Hidden_ItemId.Value));

            bool isValidate = Resource.DeleteResource(re.ItemId);
            string attachmentFolder = string.Empty;

            string sourceFolder = string.Empty;
            string attachmentsFolder = string.Empty;
            if (re.ResourceType.ToLower().Equals("image")) {
                string _170Folder;
                string _400Folder;

                ImageType obj = new ImageType();
                //yangguang
                //sourceFolder = obj.SourcePath;
                //attachmentsFolder = obj.SourcePath;
                //_170Folder = obj.PreviewPath_170;
                //_400Folder = obj.PreviewPath_400;

                //sourceFolder = Path.Combine(sourceFolder, re.FolderName);
                //_170Folder = Path.Combine(_170Folder, re.FolderName);
                //_400Folder = Path.Combine(_400Folder, re.FolderName);

                //try {
                //    File.Delete(Path.Combine(sourceFolder, re.ServerFileName));
                //    File.Delete(Path.Combine(_170Folder, re.ServerFileName));
                //    File.Delete(Path.Combine(_400Folder, re.ServerFileName));
                //}
                //catch { }
                try {
                    File.Delete(obj.GetSourcePath(re.FolderName, re.ServerFileName));
                    attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim();
                    File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "170"));
                    File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "400"));
                }
                catch { }
            }
            else if (re.ResourceType.ToLower().Equals("video")) {
                string _previewPolder = CommonInfo.VideoPreviewPath;

                VideoType obj = new VideoType();
                //sourceFolder = obj.SourcePath;
                //attachmentsFolder = obj.SourcePath;
                //_previewPolder = obj.PreviewPath;

                //try {
                //    File.Delete(Path.Combine(sourceFolder, re.ServerFileName));
                //    File.Delete(Path.Combine(Path.Combine(Path.Combine(_previewPolder, "flv"), re.FolderName), re.ServerFileName));
                //    File.Delete(Path.Combine(Path.Combine(Path.Combine(_previewPolder, "image"), re.FolderName), re.ServerFileName));
                //    File.Delete(Path.Combine(Path.Combine(Path.Combine(_previewPolder, "smallflv"), re.FolderName), re.ServerFileName));
                //}
                //catch {

                //}
                try {
                    File.Delete(obj.GetSourcePath(string.Empty, re.ServerFileName));
                    attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim();
                    File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "flv"));
                    File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "image"));
                    File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "smallflv"));
                }
                catch {

                }
            }

            //sourceFolder = Path.Combine(sourceFolder, CurrentUser.UserLoginName);
            //sourceFolder = Path.Combine(sourceFolder, WebUI.UIBiz.CommonInfo.AttachFolder);

            #region 删除物理文件 by ciqq 2010-4-2
            //SlImageRootPath = WebUI.UIBiz.CommonInfo.SlImageRootPath170;
            //if (Directory.Exists(SlImageRootPath + "\\" + CurrentUser.UserLoginName))
            //{
            //    File.Delete(SlImageRootPath + "\\" + CurrentUser.UserLoginName + "\\" + ItemSerialNum + ImageType);
            //    str = "170目录下的图片已被删除!";
            //}
            //SlImageRootPath = WebUI.UIBiz.CommonInfo.SlImageRootPath400;

            //if (Directory.Exists(SlImageRootPath + "\\" + CurrentUser.UserLoginName))
            //{
            //    File.Delete(SlImageRootPath + "\\" + CurrentUser.UserLoginName + "\\" + ItemSerialNum + ImageType);
            //    str += "400目录下的图片已被删除!";
            //}
            //SlImageRootPath = WebUI.UIBiz.CommonInfo.ImageRootPath;
            //if (Directory.Exists(SlImageRootPath + "\\" + CurrentUser.UserLoginName))
            //{
            //    File.Delete(SlImageRootPath + "\\" + CurrentUser.UserLoginName + "\\" + ItemSerialNum + ImageType);
            //    str += "Source目录下的图片已被删除!";
            //}

            //删除所有的附件
            //string sourceFolder = Path.Combine(WebUI.UIBiz.CommonInfo.ImageRootPath, this.hiFolder.Value);
            string fileName = "";
            attachmentsFolder = Path.Combine(attachmentsFolder, re.FolderName);
            attachmentsFolder = Path.Combine(attachmentsFolder, UIBiz.CommonInfo.AttachFolder);
            for (int i = 0; i < this.attList.Rows.Count; i++) {
                fileName = this.attList.DataKeys[i].Values[1].ToString();
                fileName = Path.Combine(attachmentsFolder, fileName);
                try {
                    File.Delete(fileName);
                }
                catch(Exception ex) {
                    LogWriter.WriteExceptionLog(ex);
                }
            }
                //foreach (GridViewRow gvr in this.attList.Rows) {
                //    fileName = Path.Combine(attachmentFolder, gvr.Cells[0].Text);

                //    try {
                //        File.Delete(fileName);
                //    }
                //    catch (Exception ex) {
                //        LogWriter.WriteExceptionLog(ex);
                //    }
                //}
            #endregion


            LogEntity model = new LogEntity();
            model.id = Guid.NewGuid();
            model.userId = CurrentUser.UserId;
            model.userName = CurrentUser.UserLoginName;
            model.EventType = ((int)LogType.DeleteResource).ToString();
            model.EventResult = "成功";
            model.EventContent = "图片序号:" + re.ItemSerialNum;
            model.IP = HttpContext.Current.Request.UserHostAddress;
            model.AddDate = DateTime.Now;
            new Logs().Add(model);


                Response.Write("<script language='javascript'>window.close();</script>");
            Response.End();
        }
Exemplo n.º 6
0
        //图片路径
        protected string GetVideoImgUrl(string FolderName, string ItemSerialNum, int status) {
            string _ret = string.Empty;
            if (status == 2) {
                _ret = "/images/videoconverterror.gif";
            }
            else if (status == 0) {
                _ret = "/images/videoconverting.gif";
            }
            else {

                VideoType objV = new VideoType();
                string videoPreviewPath = objV.PreviewPathRead;
                if (!string.IsNullOrEmpty(videoPreviewPath)) {
                    _ret = videoPreviewPath + "/image/" + FolderName + "/" + ItemSerialNum + ".jpg";
                }
            }
            //return UIBiz.CommonInfo.GetImageUrl(170, FolderName, ItemSerialNum, ImageType);

            return _ret;
        }