/// <summary> /// 增加一条数据 /// </summary> public bool Add(LogEntity model) { LogWS.LogService ls = new QJVRMS.Business.LogWS.LogService(); return(ls.Add(model.id, model.userId, model.userName, model.EventType, model.EventResult, model.EventContent, model.IP, model.AddDate)); }
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(); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(LogEntity model) { LogWS.LogService ls = new QJVRMS.Business.LogWS.LogService(); return ls.Add(model.id, model.userId, model.userName, model.EventType, model.EventResult, model.EventContent, model.IP, model.AddDate); }
//删除文件 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(); }
//修改文件信息 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); }