protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (string.IsNullOrEmpty(Request.QueryString["id"]) || string.IsNullOrEmpty(Request.QueryString["type"]) || (QS("id", 0) == 0)) { ShowArgumentErrorMessageToClient(); return; } int id = int.Parse(Request.QueryString["id"]); string type = Request.QueryString["type"]; if (type == DirectoryObjectType.Directory.ToString()) { rbtnNewDirectory.Checked = true; rbtnNewFile.Checked = false; DirectoryEntity model = fileApp.GetDirectory(int.Parse(Request.Params["id"])); DirectoryEntity parent = fileApp.GetDirectory(model.ParentID); List <DirectoryEntity> list = fileApp.GetDirectories(parent.ParentID); list.BindDropdown <DirectoryEntity>(ddlCurrent, "Title", "ID", "Please Select", "0"); ddlCurrent.SelectedValue = model.ParentID.ToString(); txtTitle.Text = model.Title; txtDesc.Text = model.Description; } else if (type == DirectoryObjectType.File.ToString()) { int direid = 0; if (!string.IsNullOrEmpty(Request.Params["direid"]) && int.TryParse(Request.Params["direid"], out direid)) { DirectoryObjectsEntity objects = fileApp.GetObjects(direid); if (!ISReadOnlyRole || UserInfo.ID == objects.CreatedBy) { DirectoryEntity parent = fileApp.GetDirectory(objects.DirectoryID); ddlCurrent.Items.Add(new ListItem(parent.Title, parent.ID.ToString(), true)); FilesEntity file = fileApp.Get(objects.ObjectID); txtDesc.Text = file.ThumbPath; } else { ShowArgumentErrorMessageToClient(); return; } } rbtnNewDirectory.Checked = false; rbtnNewFile.Checked = true; } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string strFileID = context.Request.QueryString["FileID"]; string strSize = context.Request.QueryString["size"]; string tableType = context.Request.QueryString["tableType"]; int fileId = 0; if (!int.TryParse(strFileID, out fileId)) { context.Response.Write("File not found."); return; } string filename = ""; string fileurl = ""; int tableTypeValue = 0; int.TryParse(tableType, out tableTypeValue); if (tableTypeValue == 2) { OperateDocManagements.OperateDocManagementSoapClient client = new OperateDocManagements.OperateDocManagementSoapClient(); string str = client.GetFileInfo(fileId); filename = str.Substring(str.IndexOf("|") + 1); fileurl = str.Substring(0, str.IndexOf("|")); } else { FilesEntity fileEntity = fileApp.Get(fileId); filename = fileEntity.FileTitle; fileurl = fileEntity.FilePath; } if (fileurl == "") { context.Response.Write("File not found."); return; } string filePath = HttpContext.Current.Server.MapPath(string.Format("/{0}", fileurl)); if (System.IO.File.Exists(filePath)) { if (filename.IndexOf(".") < 0) { filename += Path.GetExtension(filePath); } filename = filename.Replace(" ", "_"); context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename.NoHTML())); context.Response.TransmitFile(filePath); return; } else { context.Response.Write("File not found."); return; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = QS("id", 0); if (id > 0) { FilesEntity entity = fileApp.Get(id); BindDataModel(entity); } } }
public string AddFeedback(int projectID, int ticketID, string content, bool isPublic, bool isWaitClient, bool isWaitSunnetFeedback, string file, string clientsIds, HttpServerUtility Server) { try { ProjectsEntity ProjectEntity = projectApp.Get(projectID); FeedBacksEntity feedbacksEntity = GetFeedbacksEntity(ticketID, content, isPublic, isWaitClient, isWaitSunnetFeedback); TicketsEntity ticket = ticketApp.GetTickets(ticketID); var canAddWaiting = ticketApp.CanFeedbackWaiting(ticketID); if (!canAddWaiting) { feedbacksEntity.WaitPMFeedback = feedbacksEntity.WaitClientFeedback = FeedbackReplyStatus.Normal; } string fileuploadErrMsg = string.Empty; feedbacksEntity.ID = fbAPP.AddFeedBacks(feedbacksEntity); if (feedbacksEntity.ID <= 0) { var msg = fbAPP.BrokenRuleMessages != null && fbAPP.BrokenRuleMessages.Count > 0 ? fbAPP.BrokenRuleMessages[0].Message : ""; return(ResponseMessage.GetResponse(false, msg)); } // 产生气泡提示 if (UserInfo.Role == RolesEnum.CLIENT || isPublic) { ticketApp.CreateNotification(ticketID, UserInfo.UserID, false); } else { ticketApp.CreateNotification(ticketID, UserInfo.UserID); } var extraStatus = new Dictionary <string, bool>(); // 在添加FeedbackMessage时要更新Ticket 对相关人员的状态, 并且不能覆盖状态 if (ticket.Status != TicketsState.Wait_Sunnet_Feedback && ticket.Status != TicketsState.Wait_Client_Feedback && canAddWaiting) { if ((UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.Sales) && isWaitClient) { ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitClientFeedback, UserID); extraStatus.Add("waitSunnet", ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitClientFeedback, TicketUsersType.Create)); new SendHandler(() => ticketStatusMgr.SendEmailtoClientForFeedBack(feedbacksEntity)) .BeginInvoke(null, null); ProcessOtherClients(clientsIds, ticketID); } else if (UserInfo.Role == RolesEnum.CLIENT) { if (isWaitSunnetFeedback) { ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitSunnetFeedback, UserID); extraStatus.Add("waitClient", ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitSunnetFeedback, TicketUsersType.PM)); } new SendHandler(() => ticketStatusMgr.SendEmailtoPMForFeedBack(feedbacksEntity)) .BeginInvoke(null, null); } } else { // 相关状态人员可以通过回复清除自己的状态标识 if ((UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.Sales) && ticket.Status == TicketsState.Wait_Sunnet_Feedback && isPublic) { // Sunnet 直接清除PM的标识 if (ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.Normal, TicketUsersType.PM) && fbAPP.ReplyFeedback(ticketID, true, false)) { ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.Normal, TicketUsersType.Create, TicketUsersType.Client); ticket.ResponsibleUser = PmReplyClient(ProjectEntity, ticket); extraStatus.Add("clearSunnet", true); var createrId = ticketApp.GetTicketCreateUser(ticketID); var creater = _userApp.GetUser(createrId.UserID); new SendHandler(() => ticketStatusMgr.SendEmailFeedbackReplied(UserInfo, creater, ticketID)) .BeginInvoke(null, null); } } if (UserInfo.Role == RolesEnum.CLIENT && ticket.Status == TicketsState.Wait_Client_Feedback) { // 客户方面只能清除自己的标识,因为可能需要多个客户回复 if (ticketApp.TryClearWaiting(ticketID, UserID, TicketUsersType.Create, TicketUsersType.Client) && fbAPP.ReplyFeedback(ticketID, false, true)) { ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.Normal, TicketUsersType.PM); extraStatus.Add("clearClient", true); var pmId = ticketApp.GetTicketPM(ticketID); var pm = _userApp.GetUser(pmId.UserID); new SendHandler(() => ticketStatusMgr.SendEmailFeedbackReplied(UserInfo, pm, ticketID)) .BeginInvoke(null, null); ticketApp.DeleteUserFromTicket(ticketID, TicketUsersType.Client); } } } ticket.ModifiedOn = DateTime.Now; if (UserInfo.Role == RolesEnum.CLIENT && isWaitSunnetFeedback) { ChangeResponsUserToProjectManager(ProjectEntity, ticket); } ticketApp.UpdateTickets(ticket, false); #region add file int fileID = 0; string realFileName = ""; string[] files = file.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); Dictionary <string, int> uploadedFiles = new Dictionary <string, int>(); foreach (var f in files) { if ((fileID = InsertFile(f, ProjectEntity.ProjectID, ticketID, feedbacksEntity.IsPublic, feedbacksEntity.ID, Server, out realFileName)) < 1) { fileuploadErrMsg += realFileName + " Upload failed."; } uploadedFiles.Add(realFileName, fileID); } #endregion if (string.IsNullOrEmpty(fileuploadErrMsg)) { ResponseMessage response = new ResponseMessage(); response.Success = true; object attachement = null; object attachementBasicInfo = null; if (uploadedFiles.Count > 0) { attachement = uploadedFiles; string[] imgFormat = ".gif,.jpg,.jpeg,.bmp,.png,.svg,.raw".Split(new char[] { ',' }); attachementBasicInfo = uploadedFiles.Select(it => new { Key = it.Key, Value = imgFormat.Any(format => format == Path.GetExtension(it.Key.ToLower())) ? fileApp.Get(it.Value).FilePath : "/Images/icons/file.png" }).ToDictionary(it => it.Key, it => it.Value); } feedbacksEntity.Description = new HtmlHelper().ReplaceUrl(feedbacksEntity.Description); response.Data = new { content = feedback.FormatHTML(feedbacksEntity.Description, Server).Replace("\n", "<br/>"), id = feedbacksEntity.ID, date = feedbacksEntity.CreatedOn.ToString("MM/dd/yyyy"), time = feedbacksEntity.CreatedOn.ToString("hh:mm tt"), order = feedbacksEntity.Order, createdBy = feedbacksEntity.CreatedBy, firstname = UserInfo.FirstName, lastname = UserInfo.LastName, file = attachement, basicInfo = attachementBasicInfo, extraStatus = extraStatus, tdCss = feedbacksEntity.IsPublic && UserInfo.Role == RolesEnum.PM ? "fdcontentBox3" : "fdcontentBox2" }; return(response.ToString()); } else { return(ResponseMessage.GetResponse(false, fileuploadErrMsg)); } } catch (Exception ex) { WebLogAgent.Write(string.Format("Error Ascx:FeedbackList.ascx Messages:\r\n{0}", ex)); return(ResponseMessage.GetResponse(false, ex.Message)); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string strFileID = context.Request.QueryString["FileID"]; string strSize = context.Request.QueryString["size"]; string tableType = context.Request.QueryString["tableType"]; int fileId = 0; if (!int.TryParse(strFileID, out fileId)) { context.Response.Write("File not found."); return; } string filename = ""; string fileurl = ""; int tableTypeValue = 0; int.TryParse(tableType, out tableTypeValue); if (tableTypeValue == 2) { SunNet.PMNew.PM2014.OperateDocManagements.OperateDocManagementSoapClient client = new SunNet.PMNew.PM2014.OperateDocManagements.OperateDocManagementSoapClient(); string str = client.GetFileInfo(fileId); filename = str.Substring(str.IndexOf("|") + 1); fileurl = str.Substring(0, str.IndexOf("|")); } else { FilesEntity fileEntity = fileApp.Get(fileId); filename = fileEntity.FileTitle; fileurl = fileEntity.FilePath; } if (fileurl == "") { context.Response.Write("File not found."); return; } string filePath = HttpContext.Current.Server.MapPath(string.Format("/{0}", fileurl)); if (System.IO.File.Exists(filePath)) { if (!filename.ToLower().EndsWith(Path.GetExtension(filePath).ToLower())) //检查filename 是否带了扩展名 { filename += Path.GetExtension(filePath); } System.IO.FileInfo file = new System.IO.FileInfo(filePath); switch (file.Extension.ToLower()) { case ".png": context.Response.ContentType = "image/png"; ShowImage(context, filePath, ".png"); return; case ".gif": context.Response.ContentType = "image/GIF"; ShowImage(context, filePath, ".gif"); return; case ".jpg": case ".jpeg": context.Response.ContentType = "image/jpeg"; ShowImage(context, filePath, ".jpg"); return; case ".bmp": context.Response.ContentType = "image/bmp"; ShowImage(context, filePath, ".bmp"); return; case ".zip": context.Response.ContentType = "application/octet-stream"; break; case ".rar": context.Response.ContentType = "application/octet-stream"; break; case ".txt": context.Response.ContentType = "text/plain"; break; case ".wps": context.Response.ContentType = "application/octet-stream"; break; case ".doc": context.Response.ContentType = "application/ms-word"; break; case ".xls": context.Response.ContentType = "application/ms-excel"; break; case ".swf": context.Response.ContentType = "application/x-shockwave-flash"; break; case ".ppt": context.Response.ContentType = "application/ms-powerpoint"; break; case ".fla": context.Response.ContentType = "application/octet-stream"; break; case ".mp3": context.Response.ContentType = "audio/mp3"; break; default: context.Response.ContentType = "text/plain"; break; } //解决Firefox等下载文件名乱码问题 //1、添加编码规则Response.HeaderEncoding Response.ContentEncoding 为 utf-8 context.Response.HeaderEncoding = System.Text.Encoding.UTF8; context.Response.ContentEncoding = System.Text.Encoding.UTF8; context.Response.AddHeader("Content-Length", file.Length.ToString()); //context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", System.Web.HttpUtility.UrlEncode(filename.NoHTML(), Encoding.UTF8))); //2、头部分 Content-Disposition 的设置要按照 rfc231 要求, 应该按照如下格式设置: "Content-Disposition","attachment;filename*=utf-8'zh_cn'文件名.xx" // 关键是 filename的设置,*= 后面是 两个单引号,分成三部分(编码 语言 文件名) 如:*=utf-8'zh_cn'文件名.xx 或者 *=utf-8' '文件名.xx context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename*=utf-8''{0}", HttpUtility.UrlPathEncode(filename.NoHTML()))); context.Response.TransmitFile(filePath); context.Response.End(); } else { context.Response.Write("File not found."); return; } }