Exemple #1
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;
                    }                    

                }
            
            }

            
        }
Exemple #2
0
        protected void GetImageInfo(Guid itemId)
        {
            Resource rs = new Resource();
            ResourceEntity r = rs.GetResourceInfoByItemId(itemId.ToString());

            //更新浏览次数
            rs.UpdateResourceViewCount(itemId.ToString());


            folder = r.FolderName;

            //this.imgsrc.Src = yRootPath;
            this.lb_Description.Text = r.Description;
            this.lb_FileName.Text = r.FileName;
            this.lb_Caption.Text = r.Caption;
            this.lb_Author.Text = r.Author;
            this.lb_fileLength.Text = QJVRMS.Common.Tool.toFileSize(r.FileSize);
            this.lb_ImageType.Text = Path.GetExtension(r.FileName);
            this.lb_ItemSerialNum.Text = r.ItemSerialNum;
            this.lb_Keyword.Text = r.Keyword;
           
            this.lb_uploadDate.Text = r.uploadDate.ToString("yyyy-MM-dd");
          
            this.lb_viewCount.Text = r.ViewCount.ToString();
            string enableDate = "";
            if (r.StartDate.ToString("yyyy-MM-dd") != "1900-01-01")
            {
                enableDate += r.StartDate.ToString("yyyy-MM-dd");
            }
            enableDate += " -- ";
            if (r.EndDate.ToString("yyyy-MM-dd") != "1900-01-01")
            {
                enableDate += r.EndDate.ToString("yyyy-MM-dd");
            }
            if (enableDate != " -- ")
            {
                this.lb_enableDate.Text = enableDate;
            }

            if (r.HasCopyright == 1)
            {
                this.pSource.Visible = false;
            }
            else
            {
                this.pSource.Visible = true;
            }

            

        }
Exemple #3
0
        protected void btnSetCata_Click(object sender, EventArgs e)
        {
            ArrayList selNodes = new ArrayList();


            TreeNode parentNode = cataTree.RootNode;
            //获取checked的节点List
            selNodes = this.cataTree.ArrCheckbox(selNodes, parentNode);


            //QJVRMS.Business.ImageStorageClass imageClass = new QJVRMS.Business.ImageStorageClass();
            Resource objResource = new Resource();

            ArrayList catalogIds = new ArrayList(selNodes.Count);
            foreach (TreeNode node in selNodes)
            {
                // chNode = (TreeNode)(nodeList[i]);
                catalogIds.Add(new Guid(node.Value));

                //imageClass.CreateRelationshipImageAndCatalog(img.ItemId, new Guid(chNode.Value));
            }


            try
            {
                objResource.CreateRelationshipResourceAndCatalog(new Guid(Request["itemid"]), (Guid[])catalogIds.ToArray(typeof(Guid)));

                //imageClass.CreateRelationshipImageAndCatalog(new Guid(Request["itemid"]), (Guid[])catalogIds.ToArray(typeof(Guid)));
                ShowMessage("设置分类成功");

                //更新索引

                //根据itemId获得SN
                ResourceEntity model = objResource.GetResourceInfoByItemId(Request["itemid"].ToString());
                if (model != null)
                {
                    string[] SNs = new string[] { model.ItemSerialNum };
                    ResourceIndex.updateIndex(SNs);
                }

            }
            catch
            {
                ShowMessage("设置分类失败");
            }
        }
Exemple #4
0
        private void InitData()
        {
            GiftBiz biz = new GiftBiz();
            
            DataTable dt = biz.GetGiftTypeList();

            ddlGiftType.DataSource = dt;
            ddlGiftType.DataTextField = "TypeName";
            ddlGiftType.DataValueField = "TypeID";
            ddlGiftType.DataBind();

            if (ViewState["Id"] != null)
            {
                GiftInfo model = biz.GetModel(ViewState["Id"].ToString());
                if (model != null)
                {
                    txtTitle.Text = model.Title;
                    txtRemark.Text = model.Remark;
                    txtQuantity.Text = model.Quantity.ToString();
                    ddlGiftType.SelectedValue = model.TypeId;


                    Resource objResource = new Resource();
                    ResourceEntity model1 = null;
                    ImageType objImg = new ImageType();

                    model1 = objResource.GetResourceInfoByItemId(model.ImageId.ToString());

                    imgGift.ImageUrl = objImg.GetPreviewPathRead(model1.FolderName, model1.ServerFileName, "170");
                    //objImg.ge
                    /*
                    ImageStorage imageModel = ImageStorage.GetImageStorageModel(new Guid(model.ImageId));
                    imgGift.ImageUrl = UIBiz.CommonInfo.GetImageUrl(170, imageModel.FolderName, imageModel.ItemSerialNum, imageModel.ImageType);
                    */
                    
                    this.catalogTree.ImagesItemId = model.ImageId;
                }
            }
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                string ids = Request.QueryString["ids"];
                if (string.IsNullOrEmpty(ids))
                {
                    return;
                }

                ids = ids.TrimEnd(";".ToCharArray());
                string[] arrIds = ids.Split(";".ToCharArray());



                ImageType objImageType = new ImageType();
                IResourceType rt = null; 

                string physicalPath = string.Empty;
                List<string> zipFileList = new List<string>();
                foreach (string id in arrIds)
                {

                    ResourceEntity re = null;
                    Resource r = new Resource();
                    re = r.GetResourceInfoByItemId(id);

                    //physicalPath = objImageType.GetSourcePath(re.FolderName, re.ServerFileName);

                    rt = ResourceTypeFactory.getResourceTypeByString(re.ResourceType);
                    physicalPath = rt.GetSourcePath(re.FolderName, re.ServerFileName);

                    if (!string.IsNullOrEmpty(physicalPath))
                    {
                        zipFileList.Add(physicalPath);
                    }

                    //记录下载日志
                    Resource.Production_Hires_Down_Log(re.ItemSerialNum,Path.GetExtension(re.ServerFileName), CurrentUser.UserName, "", "", re.FolderName, false, re.ResourceType);


                }





                Response.ContentType = "application/octet-stream";
                Response.AppendHeader("content-disposition", "attachment; filename=\"Download.zip\"");
                Response.CacheControl = "Private";
                Response.Cache.SetExpires(DateTime.Now.AddMinutes(3));

                byte[] buffer = new byte[4096];

                ZipOutputStream zipOutputStream = new ZipOutputStream(Response.OutputStream);
                zipOutputStream.SetLevel(3);

                foreach (string fileName in zipFileList)
                {
                    

                    Stream fs = File.OpenRead(fileName);	// or any suitable inputstream

                    ZipEntry entry = new ZipEntry(ZipEntry.CleanName(Path.GetFileName(fileName)));
                    entry.Size = fs.Length;
                    zipOutputStream.PutNextEntry(entry);

                    int count = fs.Read(buffer, 0, buffer.Length);
                    while (count > 0)
                    {
                        zipOutputStream.Write(buffer, 0, count);
                        count = fs.Read(buffer, 0, buffer.Length);
                        if (!Response.IsClientConnected)
                        {
                            break;
                        }
                        Response.Flush();
                    }
                    fs.Close();
                }
                zipOutputStream.Close();

                Response.Flush();
                Response.End();
         

                

            }

        }
Exemple #6
0
        protected void GetImageInfo(Guid itemId)
        {
            Resource rs = new Resource();
            ResourceEntity r = rs.GetResourceInfoByItemId(itemId.ToString());

            if (!r.ResourceType.ToLower().Equals("image"))
            {
                return;
            
            }



            //水印图片
            FileStream s1 = new FileStream(Server.MapPath(IMAGEPATH), FileMode.Open, FileAccess.Read);
            byte[] b1 = new byte[int.Parse(s1.Length.ToString())];
            s1.Read(b1, 0, int.Parse(s1.Length.ToString()));
            s1.Close();

            

            ImageType obj = new ImageType();
            //yangguang
            //string strPhysicalPath = Path.Combine(Path.Combine(obj.SourcePath,r.FolderName),r.ServerFileName);
            string strPhysicalPath = obj.GetSourcePath(r.FolderName, r.ServerFileName);
            if (File.Exists(strPhysicalPath))
            {
                

                Stream iStream = null;
                String tmpFilePath=string.Empty;
                try
                {
                    byte[] buffer = new Byte[10000];
                    int length;
                    long dataToRead;
                    string filepath = strPhysicalPath;
                    string filename = Path.GetFileName(filepath);


                    //压缩
                    String tmpFileName=DateTime.Now.ToString("yyyyMMddhhmmss")+".bin";
                    //yangguang
                    //tmpFilePath=Path.Combine(obj.SourcePath,tmpFileName);
                    tmpFilePath = Path.Combine(obj.SourcePaths[obj.PathNumber].Trim(), tmpFileName);//obj.GetSourcePath(string.Empty, tmpFileName);

                    System.Drawing.Image srcImage = System.Drawing.Image.FromFile(filepath);
                    int imgWidth = srcImage.Width;
                    int imgHeight = srcImage.Height;


                    if (imgWidth > 1000 || imgHeight > 1000)
                    {
                        ArrayList sarray = new ArrayList();
                        sarray.Add(strPhysicalPath);
                        ArrayList aarray = new ArrayList();
                        aarray.Add(tmpFilePath);
                        ImageController.ToZipImage(sarray, aarray, 1000);

                        iStream = new FileStream(tmpFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    }
                    else
                    {
                        iStream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    }

                    //用户选择的原图
                    
                    byte[] b = new byte[int.Parse(iStream.Length.ToString())];
                    iStream.Read(b, 0, int.Parse(iStream.Length.ToString()));
                    iStream.Close();


                    QJImagePro.Handles.PictureHandle pic = QJImagePro.PictureFactory.CreateHandle(QJImagePro.PictureType.Jpeg);
                    string showType = GetShowType();
                    int type = string.IsNullOrEmpty(showType) ? 0 : int.Parse(showType);
                    byte[] by = pic.Watermarking(b, b1, 72, type);
                    Response.ContentType = "image/Jpeg";
                    Response.BinaryWrite(by);
                }
                catch (Exception ex)
                {
                    LogWriter.WriteExceptionLog(ex);
                }
                finally
                {
                    if (iStream != null)
                    {
                        iStream.Close();
                    }
                    if (File.Exists(tmpFilePath))
                    {
                        File.Delete(tmpFilePath);
                    }
                }
            
            }

        }
        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();


                
              
                
            }


        }
Exemple #8
0
        protected void GetImageInfo(Guid itemId) {
            Resource rs = new Resource();
            ResourceEntity r = rs.GetResourceInfoByItemId(itemId.ToString());

            //更新浏览次数
            rs.UpdateResourceViewCount(itemId.ToString());


            ImageType obj = new ImageType();
            //yangguang
            //string yRootPath = obj.PreviewPath_400_Read; // 400预览图路径
            folderName = r.FolderName;
            serviceFileName = r.ServerFileName;
            //yRootPath = yRootPath + r.FolderName + @"/" + r.ServerFileName;
            string yRootPath = obj.GetPreviewPathRead(r.FolderName, r.ServerFileName, "400");
            folder = r.FolderName;

            //this.imgsrc.Src = yRootPath;
            this.lb_Description.Text = GetString(r.Description, 25);
            this.lb_FileName.Text = r.FileName;
            this.lb_Caption.Text = GetString(r.Caption, 25);
            this.lb_Author.Text = r.Author;
            this.lb_fileLength.Text = QJVRMS.Common.Tool.toFileSize(r.FileSize);
            this.lb_ImageType.Text = Path.GetExtension(r.FileName);
            this.lb_ItemSerialNum.Text = r.ItemSerialNum;
            this.lb_Keyword.Text = r.Keyword;
            this.lb_shotDate.Text = r.shotDate.ToString("yyyy-MM-dd");
            this.lb_uploadDate.Text = r.uploadDate.ToString("yyyy-MM-dd");
            this.pageTitle.Text = r.Caption;
            this.lb_viewCount.Text = r.ViewCount.ToString();
            string enableDate = "";
            if (r.StartDate.ToString("yyyy-MM-dd") != "1900-01-01") {
                enableDate += r.StartDate.ToString("yyyy-MM-dd");
            }
            enableDate += " -- ";
            if (r.EndDate.ToString("yyyy-MM-dd") != "1900-01-01") {
                enableDate += r.EndDate.ToString("yyyy-MM-dd");
            }

            this.lb_SN.Text = r.ItemSerialNum;
            //if (enableDate != " -- ") {
            //    this.lb_enableDate.Text = enableDate;
            //}

            //if (r.HasCopyright == 1) {
            //    this.pSource.Visible = false;
            //}
            //else {
            //    this.pSource.Visible = true;
            //}

            if (r.ResourceType.Equals("image")) {
                ImageInfo o = rs.GetImageInfoBySN(r.ItemSerialNum);
                if (o != null) {
                    switch (o.Hvsp.ToUpper()) {
                        case "H": this.lb_Hvsp.Text = "横图"; break;
                        case "V": this.lb_Hvsp.Text = "竖图"; break;
                        case "S": this.lb_Hvsp.Text = "方图"; break;
                        case "P": this.lb_Hvsp.Text = "全景图"; break;
                        default: this.lb_Hvsp.Text = "横图"; break;
                    }
                    this.lb_Size.Text = o.Width.ToString() + "x" + o.Height.ToString();
                }
            }

            StringBuilder OutString = new StringBuilder("");
            using (DataSet ds = GetResourceCatalog(itemId.ToString()))
            {
                if (ds != null && ds.Tables[0].Rows.Count != 0)
                {
                    DataTable cataTable = ds.Tables[0];

                    for (int i = 0; i < cataTable.Rows.Count; i++)
                    {
                        OutString.Append(cataTable.Rows[i]["CatalogName"].ToString() + "   ");
                    }

                    this.lb_Category.Text = OutString.ToString();

                }
            }



            //判断是否具有下载权限
            this.pDownload.Visible = IsSuperAdmin || rs.IsUserResource(CurrentUser.UserId, r.ItemId, (int)OperatorMethod.Download);
            this.pEdit.Visible = IsSuperAdmin || rs.IsUserResource(CurrentUser.UserId, r.ItemId, (int)OperatorMethod.Modify);
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {   
            string[] ids = chbIds.Value.Split(",".ToCharArray());

            ResourceEntity re = null;
            Resource r = new Resource();

            foreach (string id in ids)
            {
                //单个删除
               
                re = r.GetResourceInfoByItemId(id);
               
                string ItemSerialNum = "";
                string ImageType = "";
                string str = "";//判断170图片或者400图片有没有被删除
           
                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 { }


                    //这里还要加上附件的删除
                    DataTable dt = Resource.GetAttachList(new Guid(id));

                    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 = dt.Rows[i]["fileName"].ToString();
                        fileName = Path.Combine(attachmentsFolder, fileName);
                        try
                        {
                            File.Delete(fileName);
                        }
                        catch (Exception ex)
                        {
                            LogWriter.WriteExceptionLog(ex);
                        }
                    }
                }
                
                
            }


            bind();
        }
Exemple #10
0
        protected void attList_RowDeleting(object sender, GridViewDeleteEventArgs 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 sourceFolder = string.Empty;
            ImageType imageType = new ImageType();
            if (re.ResourceType.ToLower().Equals("image")) {
                sourceFolder = imageType.SourcePath;//CommonInfo.ImageRootPath;
            }
            else if (re.ResourceType.ToLower().Equals("video")) {
                sourceFolder = imageType.VideoPath;//CommonInfo.VideoRootPath;

            }

            sourceFolder = Path.Combine(sourceFolder, re.FolderName);
            sourceFolder = Path.Combine(sourceFolder, WebUI.UIBiz.CommonInfo.AttachFolder);

            //sourceFolder = Path.Combine(WsourceFolder, this.hiFolder.Value);
            //sourceFolder = Path.Combine(sourceFolder, UIBiz.CommonInfo.AttachFolder);

            string fileName = this.attList.DataKeys[e.RowIndex].Values[1].ToString();//this.attList.Rows[e.RowIndex].Cells[0].Text;
            fileName = Path.Combine(sourceFolder, fileName);

            try {
                File.Delete(fileName);
                string key = this.attList.DataKeys[e.RowIndex].Values[0].ToString();
                Resource.DeleteAttach(new Guid(key));
                LoadAttach();
            }
            catch (Exception ex) {
                LogWriter.WriteExceptionLog(ex);
            }
        }
Exemple #11
0
        //按文件编号查询,获取资源详细信息
        public void SearchItemSerialNum(string ItemID) {
            Resource objResource = new Resource();
            ResourceEntity model = null;

            try {
                //oIImageStorage = ImageStorageClass.GetImageInfoByNum(imgItemSerialNum);
                //oIImageStorage = ImageStorageClass.GetImageInfoByItemId(new Guid(ItemID), CurrentUser.UserId);

                model = objResource.GetResourceInfoByItemId(ItemID);
                if (ViewState["model"] != null) {
                    ViewState["model"] = model;
                }

                if (model != null) {
                    //this.lb_ImageType.Text = "";
                    this.lb_ItemSerialNum.Text = model.ItemSerialNum;
                    this.TxtKeyword.Text = model.Keyword;
                    this.lb_uploadDate.Text = model.uploadDate.ToString("yyyy-MM-dd");
                    this.txt_Caption.Text = model.Caption;
                    //this.txt_Address.Text = oIImageStorage.Address;
                    //this.txt_Character.Text = oIImageStorage.Character;
                    this.hiFolder.Value = model.FolderName;
                    this.Hidden_ItemId.Value = ItemID;
                    this.Hidden_FolderName.Value = model.FolderName;
                    this.hiNum.Value = model.ItemSerialNum;
                    this.TxtDescription.Text = model.Description;
                    this.lb_FileName.Text = model.FileName;

                    this.Calendar_ShotDate.Text = model.shotDate.ToString("yyyy-MM-dd");
                    this.Calendar_StartDate.Text = model.StartDate.ToString("yyyy-MM-dd");
                    this.Calendar_EndDate.Text = model.EndDate.ToString("yyyy-MM-dd");
                    
                    this.resourceImage.Text = showImage(model.ServerFileName, model.FolderName, model.ResourceType, model.Status, ItemID);

                    
                    this.resourceType.Value = model.ResourceType;
                    this.serverFolder.Value = model.FolderName;

                    using (DataSet ds = GetResourceCatalog(ItemID)) {
                        if (ds != null && ds.Tables[0].Rows.Count != 0) {
                            DataTable cataTable = ds.Tables[0];

                            for (int i = 0; i < cataTable.Rows.Count; i++) {
                                OutString.Append(cataTable.Rows[i]["CatalogName"].ToString() + "   ");
                            }

                            lb_catalogs.Text = OutString.ToString();

                        }
                    }
                }
                #region
                //this.yRootPath = UIBiz.CommonInfo.GetImageUrl(400, oIImageStorage);

                //string imgSuffixStr = ",JPG,JPEG,GIF,BMP,TIFF,PCX,TGA,EXIF,FPX,";
                //if (imgSuffixStr.IndexOf("," + oIImageStorage.ImageType.ToUpper() + ",") < 0)
                //{
                //    this.tr_Hvsp.Visible = false;
                //    this.tr_shotDate.Visible = false;
                //}

                //this.imgsrc.Src = yRootPath;

                //switch (oIImageStorage.Hvsp.ToUpper())
                //{

                //    case "H": this.lb_Hvsp.Text = "横图"; break;
                //    case "V": this.lb_Hvsp.Text = "竖图"; break;
                //    case "S": this.lb_Hvsp.Text = "方图"; break;
                //    case "P": this.lb_Hvsp.Text = "全景图"; break;
                //    default: this.lb_Hvsp.Text = "横图"; break;
                //}

                //if (oIImageStorage.StartDate.ToString("yyyy-MM-dd") != "1900-01-01")
                //{
                //    this.Calendar_StartDate.Text = oIImageStorage.StartDate.ToString("yyyy-MM-dd");
                //}
                //else
                //{
                //    this.Calendar_StartDate.Text = "";
                //}
                //if (oIImageStorage.EndDate.ToString("yyyy-MM-dd") != "1900-01-01")
                //{
                //    this.Calendar_EndDate.Text = oIImageStorage.EndDate.ToString("yyyy-MM-dd");
                //}
                //else
                //{
                //    this.Calendar_EndDate.Text = "";
                //}
                //if (oIImageStorage.shotDate.ToString("yyyy-MM-dd") != "1900-01-01")
                //{
                //    this.Calendar_ShotDate.Text = oIImageStorage.shotDate.ToString("yyyy-MM-dd");
                //}
                //else
                //{
                //    this.Calendar_ShotDate.Text = "";
                //}
                #endregion
            }
            catch (Exception e2) {
                this.imagePanel.Visible = false;
                Response.Write("<script language='javascript'>alert('不存在此资源!');window.close();</script>");
                Response.End();
            }
        }
Exemple #12
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();
        }
Exemple #13
0
        //修改文件信息
        protected void BtnUpdate_Click(object sender, EventArgs e) {
            //验证日期
            DateTime sDate = new DateTime();
            DateTime eDate = new DateTime();
            DateTime shotDate = new DateTime();
            if (this.Calendar_ShotDate.Text == "") {
                this.Label2.Text = "拍摄时间不能为空!";
                return;
            }
            else {
                shotDate = Convert.ToDateTime(this.Calendar_ShotDate.Text);
                if (shotDate > Convert.ToDateTime(this.lb_uploadDate.Text)) {
                    this.Label2.Text = "拍摄时间应比图片上传日期早!";
                    return;
                }
            }
            if (this.Calendar_StartDate.Text != "") {
                sDate = Convert.ToDateTime(this.Calendar_StartDate.Text);
            }
            else {
                sDate = Convert.ToDateTime("1900-01-01");
            }
            if (this.Calendar_EndDate.Text != "") {
                eDate = Convert.ToDateTime(this.Calendar_EndDate.Text);

                if (sDate != Convert.ToDateTime("1900-01-01") && eDate < sDate) {
                    this.Label2.Text = "有效结束日期应比有效开始日期晚";
                    return;
                }
            }
            else {
                eDate = Convert.ToDateTime("1900-01-01");
            }

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

            re.Caption = this.txt_Caption.Text;
            re.Description = this.TxtDescription.Text;
            re.Keyword = this.TxtKeyword.Text;
            re.shotDate = shotDate;
            re.StartDate = sDate;
            re.EndDate = eDate;

            string editResult = "";
            try {
                r.Update(re);

                ShowMessage("修改文件信息成功!");
                editResult = "成功";
            }
            catch (Exception e1) {
                ShowMessage("修改文件信息失败!" + e1.Message);
                editResult = "失败";
            }


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



        }
        //修改文件信息
        protected void BtnUpdate_Click(object sender, EventArgs e)
        {

            string ids = Request.QueryString["ids"];
            if (string.IsNullOrEmpty(ids))
            {
                return;
            }

            ids = ids.TrimEnd(";".ToCharArray());
            string[] arrIds = ids.Split(";".ToCharArray());



            ResourceEntity re = null;
            Resource r = new Resource();



            foreach (string id in arrIds)
            {

                re = r.GetResourceInfoByItemId(id);
                re.Caption = this.txt_Caption.Text;
                re.Description = this.TxtDescription.Text;
                re.Keyword = this.TxtKeyword.Text;
                try
                {
                    r.Update(re);

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


                    ShowMessage("修改文件信息成功!");


                }
                catch (Exception e1)
                {
                    ShowMessage("修改文件信息失败!" + e1.Message);
                }
            }





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

            //re.Caption = this.txt_Caption.Text;
            //re.Description = this.TxtDescription.Text;
            //re.Keyword = this.TxtKeyword.Text;
            //re.shotDate = shotDate;
            //re.StartDate = sDate;
            //re.EndDate = eDate;

            //string editResult = "";
            //try
            //{
            //    r.Update(re);

            //    ShowMessage("修改文件信息成功!");
            //    editResult = "成功";
            //}
            //catch (Exception e1)
            //{
            //    ShowMessage("修改文件信息失败!" + e1.Message);
            //    editResult = "失败";
            //}


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



        }