private bool InsertFile(HttpPostedFile file, int projectID, bool isPublicFeedback, int feedbacksID) { string tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; string folderName = string.Empty; folderName = projectID.ToString(); string fileName = file.FileName; string savePath = Server.MapPath(tempPath) + folderName; string sExtension = Path.GetExtension(fileName); if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } string sNewFileName = string.Format("{0}_{1}{2}", feedbacksID, DateTime.Now.ToString("yyMMddssmm"), sExtension);; file.SaveAs(savePath + @"\" + sNewFileName); FilesEntity fileEntity = new FilesEntity(); fileEntity.ContentType = sExtension.ToLower(); fileEntity.CreatedBy = UserInfo.UserID; fileEntity.FilePath = tempPath.Substring(2) + folderName + @"/" + sNewFileName; fileEntity.FileSize = Convert.ToDecimal(file.ContentLength); fileEntity.FileTitle = fileName.Substring(0, fileName.LastIndexOf('.')); fileEntity.IsPublic = isPublicFeedback; fileEntity.FeedbackId = feedbacksID; fileEntity.TicketId = TicketID; fileEntity.ProjectId = projectID; fileEntity.SourceType = (int)FileSourceType.FeedBack; fileEntity.ThumbPath = ""; fileEntity.CreatedOn = DateTime.Now.Date; fileEntity.CompanyID = ticketApp.GetCompanyIdByTicketId(TicketID); return(fileApp.AddFile(fileEntity) > 0); }
protected void btnSave_Click(object sender, EventArgs e) { int id = QS("id", 0); int workRequestId = QS("wid", 0); if (fileProject.HasFile || lblFile.Visible == true) { FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("WorkRequest", workRequestId, fileProject.PostedFile);; model.WorkRequestId = workRequestId; model.ContentType = fileProject.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileProject.PostedFile.ContentLength; if (string.IsNullOrEmpty(txtFileTitle.Text)) { model.FileTitle = Path.GetFileName(fileProject.FileName); model.FileTitle = model.FileTitle.Substring(0, model.FileTitle.LastIndexOf(".")); } else { model.FileTitle = txtFileTitle.Text; } model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.WorkRequest; model.ThumbPath = Path.GetFileName(fileProject.PostedFile.FileName); model.IsDelete = false; model.Tags = txtTags.Text.Trim(); bool result = true; if (id > 0) { model.FileID = id; result = fileApp.UpdateFile(model); } else { result = fileApp.AddFile(model) > 0 ? true : false; } if (!result) { this.ShowFailMessageToClient(fileApp.BrokenRuleMessages, false); } else { this.ShowSuccessMessageToClient(); } } else { this.ShowFailMessageToClient("Please select a file"); } }
protected void btnSaveFiles_Click(object sender, EventArgs e) { int id = QS("id", 0); int companyid = QS("companyid", 0); if (fileProject.HasFile) { FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("Project", id, fileProject.PostedFile);; model.CompanyID = companyid; model.ContentType = fileProject.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileProject.PostedFile.ContentLength; if (string.IsNullOrEmpty(txtFileTitle.Text)) { model.FileTitle = Path.GetFileName(fileProject.FileName); model.FileTitle = model.FileTitle.Substring(0, model.FileTitle.LastIndexOf(".")); } else { model.FileTitle = txtFileTitle.Text; } model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.Project; model.ProjectId = id; model.ThumbPath = Path.GetFileName(fileProject.PostedFile.FileName); model.IsDelete = false; FileApplication fileApp = new FileApplication(); int result = fileApp.AddFile(model); OperateDocManagements.OperateDocManagementSoapClient client = new OperateDocManagements.OperateDocManagementSoapClient(); List <FilesEntity> clientFiles = new List <FilesEntity>(); clientFiles.Add(model); client.AddDocManagement(Newtonsoft.Json.JsonConvert.SerializeObject(clientFiles)); if (result <= 0) { this.ShowFailMessageToClient(fileApp.BrokenRuleMessages, false); } else { InitFiles(); this.ShowSuccessMessageToClient(false, false); txtFileTitle.Text = ""; } } }
protected void btnSave_Click(object sender, EventArgs e) { string msg = string.Empty; if (!CheckInput(out msg)) { ShowMessageToClient(msg, 2, false, false); return; } if (rbtnNewDirectory.Checked) { DirectoryEntity model = GetDirectory(); int id = fileApp.UpdateDirectory(model); if (id > 0) { Session["CreatedDirectory"] = string.Format("{0}-{1}", ddlCurrent.SelectedValue, id.ToString()); this.ShowSuccessMessageToClient(); } else { this.ShowFailMessageToClient(fileApp.BrokenRuleMessages, false); } } else if (rbtnNewFile.Checked) { FilesEntity model = GetFile(); FileApplication fileApp = new FileApplication(); int result = fileApp.AddFile(model); if (result <= 0) { ShowFailMessageToClient(fileApp.BrokenRuleMessages, false); return; } else { DirectoryObjectsEntity objecttoadd = GetObject(result); int id = fileApp.PushObjectToDirectory(objecttoadd); if (id > 0) { ShowSuccessMessageToClient(true, true); } else { ShowFailMessageToClient(fileApp.BrokenRuleMessages, false); return; } } } }
private int InsertFile(string file, int shareID) { var realFileName = file.Replace(string.Format("{0}_", UserInfo.ID), ""); string tempPath = Config.UploadPath; string tmpFile = Server.MapPath(Config.UploadPath + "/" + file); if (!File.Exists(tmpFile)) { return(0); } string folderName = UserInfo.CompanyID.ToString(); string savePath = Path.Combine(Server.MapPath(tempPath), folderName); string sExtension = Path.GetExtension(file); if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } string sNewFileName = string.Format("{0}_{1}{2}", shareID, DateTime.Now.ToString("yyMMddssmm"), sExtension);; FilesEntity fileEntity = new FilesEntity(); fileEntity.ContentType = sExtension.ToLower(); fileEntity.CreatedBy = UserInfo.UserID; fileEntity.FilePath = string.Format("{0}{1}/{2}", tempPath.Substring(1), folderName, sNewFileName); fileEntity.FileSize = Convert.ToDecimal(new FileInfo(tmpFile).Length); fileEntity.FileTitle = realFileName.Substring(0, realFileName.LastIndexOf('.')); fileEntity.IsPublic = true; fileEntity.FeedbackId = 0; fileEntity.TicketId = 0; fileEntity.ProjectId = 0; fileEntity.SourceID = shareID; fileEntity.SourceType = (int)FileSourceType.KnowledgeShare; fileEntity.ThumbPath = ""; fileEntity.CreatedOn = DateTime.Now.Date; fileEntity.CompanyID = UserInfo.CompanyID; if (FileHelper.Move(file, Server.MapPath(fileEntity.FilePath))) { return(_fileApp.AddFile(fileEntity)); } return(0); }
protected void btnSave_Click(object sender, EventArgs e) { if (!fileUpload.HasFile) { ShowFailMessageToClient("Please upload file"); return; } ProposalTrackerEntity proposaltrackerEntity = new App.ProposalTrackerApplication().Get(QS("ID", 0)); if (proposaltrackerEntity == null) { ShowFailMessageToClient("unauthorized access."); return; } FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("ProposalTracker", proposaltrackerEntity.ProjectID, fileUpload.PostedFile);; model.ProposalTrackerId = proposaltrackerEntity.ProposalTrackerID; model.ContentType = fileUpload.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileUpload.PostedFile.ContentLength; model.FileTitle = Path.GetFileName(fileUpload.PostedFile.FileName); model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.WorkRequest; model.ThumbPath = txtFileTitle.Text; model.IsDelete = false; model.Tags = txtTags.Text.Trim(); bool result = true; result = fileApp.AddFile(model) > 0; if (!result) { ShowFailMessageToClient(fileApp.BrokenRuleMessages); } else { Redirect(EmptyPopPageUrl, false, true); } }
protected void btnSaveFiles_Click(object sender, EventArgs e) { if (fileProject.HasFile) { FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("Company", CompanyID, fileProject.PostedFile);; model.CompanyID = CompanyID; model.ContentType = Path.GetExtension(fileProject.FileName); model.FileID = 0; model.FileSize = fileProject.PostedFile.ContentLength; if (string.IsNullOrEmpty(txtFileTitle.Text)) { model.FileTitle = Path.GetFileName(fileProject.FileName); model.FileTitle = model.FileTitle.Substring(0, model.FileTitle.LastIndexOf(".")); } else { model.FileTitle = txtFileTitle.Text; } model.IsDelete = false; model.IsPublic = BaseWebsitePage.UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.Company; model.ThumbPath = Path.GetFileName(fileProject.PostedFile.FileName); model.IsDelete = false; FileApplication fileApp = new FileApplication(); int result = fileApp.AddFile(model); if (result <= 0) { BaseWebsitePage.ShowFailMessageToClient(fileApp.BrokenRuleMessages, false); } else { BaseWebsitePage.ShowSuccessMessageToClient(false, false); InitFiles(); txtFileTitle.Text = ""; } } }
private int InsertFile(string file, int projectID, int ticketID, bool isPublicFeedback, int feedbacksID, HttpServerUtility Server, out string realFileName) { realFileName = file.Replace(string.Format("{0}_", UserID), ""); var fileLength = (int)FileHelper.GetFileLength(file); string tempPath = Config.UploadPath; string folderName = projectID.ToString(); string fileName = file; string savePath = Path.Combine(Server.MapPath(tempPath), folderName); string sExtension = Path.GetExtension(fileName); if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } string sNewFileName = string.Format("{0}_{1}_{2}{3}", ticketID, Path.GetFileNameWithoutExtension(file), DateTime.Now.ToString("ssmmfff"), sExtension); FilesEntity fileEntity = new FilesEntity(); fileEntity.ContentType = sExtension.ToLower(); fileEntity.CreatedBy = UserInfo.UserID; fileEntity.FilePath = string.Format("{0}{1}/{2}", tempPath.Substring(1), folderName, sNewFileName); fileEntity.FileSize = Convert.ToDecimal(fileLength); fileEntity.FileTitle = realFileName.Substring(0, realFileName.LastIndexOf('.')); fileEntity.IsPublic = isPublicFeedback; fileEntity.FeedbackId = feedbacksID; fileEntity.TicketId = ticketID; fileEntity.ProjectId = projectID; fileEntity.SourceType = (int)FileSourceType.FeedBack; fileEntity.ThumbPath = ""; fileEntity.CreatedOn = DateTime.Now.Date; fileEntity.CompanyID = ticketApp.GetCompanyIdByTicketId(ticketID); if (FileHelper.Move(file, Server.MapPath(fileEntity.FilePath))) { return(fileApp.AddFile(fileEntity)); } return(0); }
protected void btnSave_Click(object sender, EventArgs e) { int id = QS("id", 0); if (id == 0) { ShowFailMessageToClient("unauthorized access."); return; } else { ProjectsEntity projectEntity = new ProjectApplication().Get(id); if (projectEntity == null) { ShowFailMessageToClient("unauthorized access."); return; } if (fileUpload.PostedFile.ContentLength == 0) { ShowFailMessageToClient("Please specify a file to upload."); return; } FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("Project", id, fileUpload.PostedFile);; model.CompanyID = projectEntity.CompanyID; model.ContentType = fileUpload.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileUpload.PostedFile.ContentLength; if (string.IsNullOrEmpty(txtFileTitle.Text)) { model.FileTitle = Path.GetFileName(fileUpload.FileName); model.FileTitle = model.FileTitle.Substring(0, model.FileTitle.LastIndexOf(".")); } else { model.FileTitle = txtFileTitle.Text; } model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.Project; model.ProjectId = id; model.ThumbPath = Path.GetFileName(fileUpload.PostedFile.FileName); model.IsDelete = false; FileApplication fileApp = new FileApplication(); int result = fileApp.AddFile(model); OperateDocManagements.OperateDocManagementSoapClient client = new OperateDocManagements.OperateDocManagementSoapClient(); List <FilesEntity> clientFiles = new List <FilesEntity>(); clientFiles.Add(model); client.AddDocManagement(Newtonsoft.Json.JsonConvert.SerializeObject(clientFiles)); if (result <= 0) { Redirect("File upload error.", "AddProjectFile.aspx?ID" + QS("ID")); } else { Redirect(EmptyPopPageUrl, false, true); } } }
protected void btnSave_Click(object sender, EventArgs e) { bool result = true; WorkRequestEntity entity = GetEntity(); if (IsAdd) { if (fileProject.HasFile) { string fileContentType = fileProject.PostedFile.ContentType; if ((fileContentType == "application/msword" || fileContentType == "application/pdf" || fileContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")) { int id = wqApp.AddWorkRequest(entity); if (id > 0) { FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("WorkRequest", id, fileProject.PostedFile);; model.WorkRequestId = id; model.ContentType = fileProject.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileProject.PostedFile.ContentLength; model.FileTitle = Path.GetFileName(fileProject.FileName); model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.WorkRequestScope; model.ThumbPath = Path.GetFileName(fileProject.PostedFile.FileName); result = fileApp.AddFile(model) > 0 ? true : false; BaseWebsitePage.ShowSuccessMessageToClient(); } else { BaseWebsitePage.ShowFailMessageToClient(wqApp.BrokenRuleMessages); } } else { BaseWebsitePage.ShowFailMessageToClient("Please select a file to upload ( *.doc, *.docx, *.pdf)"); } } else { BaseWebsitePage.ShowFailMessageToClient("Please upload Work Scope"); } } //edit else { if (fileProject.HasFile) { string fileContentType = fileProject.PostedFile.ContentType; if ((fileContentType == "application/msword" || fileContentType == "application/pdf" || fileContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")) { if (wqApp.UpdateWorkRequest(entity)) { FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("WorkRequest", entity.WorkRequestID, fileProject.PostedFile);; model.WorkRequestId = entity.WorkRequestID; model.ContentType = fileProject.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileProject.PostedFile.ContentLength; model.FileTitle = Path.GetFileName(fileProject.FileName); model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.WorkRequestScope; model.ThumbPath = Path.GetFileName(fileProject.PostedFile.FileName); result = fileApp.AddFile(model) > 0 ? true : false; BaseWebsitePage.ShowSuccessMessageToClient(true, false); } } else { BaseWebsitePage.ShowFailMessageToClient("Please select a file to upload ( *.doc, *.docx, *.pdf)"); } } else { if (!lblFile.Visible) { BaseWebsitePage.ShowFailMessageToClient("Please upload Work Scope"); } else { if (wqApp.UpdateWorkRequest(entity)) { BaseWebsitePage.ShowSuccessMessageToClient(true, false); } else { BaseWebsitePage.ShowFailMessageToClient(wqApp.BrokenRuleMessages); } } } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; try { if (IdentityContext.UserID <= 0) { return; } #region get value int tid = Convert.ToInt32(context.Request["tid"]); int pId = Convert.ToInt32(context.Request["pId"]); String tType = context.Request["tType"]; String ckbEn = context.Request["ckbEn"]; String pty = context.Request["pty"]; String title = context.Request["title"].NoHTML(); String url = context.Server.UrlEncode(context.Request["url"]); String descr = context.Request["descr"].NoHTML(); String imageList = context.Request["imageList"]; String imageSizeList = context.Request["imageSizeList"]; String StartDate = context.Request["StartDate"]; String DeliveryDate = context.Request["DeliveryDate"]; String satus = context.Request["satus"]; String IsSunnet = context.Request["isSunnet"]; #endregion bool update = true; TicketsEntity ticketEntity = TicketApp.GetTickets(tid);//get original model #region set original value { originalDesc = ticketEntity.FullDescription; originalState = ticketEntity.Status.ToString(); originalTitle = ticketEntity.Title; } #endregion #region set satus value switch (satus) { case "save": ticketEntity.Status = ticketEntity.Status; break; case "cancle": ticketEntity.Status = TicketsState.Cancelled; break; case "submit": IsSend = true; ticketEntity.Status = TicketsState.Submitted; break; } #endregion #region ticket ticketEntity.ProjectID = pId; ticketEntity.URL = url; ticketEntity.FullDescription = descr; ticketEntity.Title = title.NoHTML(); ticketEntity.TicketType = tType == "0" ? TicketsType.Bug : TicketsType.Request; ticketEntity.IsEstimates = ckbEn == "checked" ? true : false; ticketEntity.Priority = (PriorityState)Convert.ToInt32(pty); ticketEntity.ModifiedBy = IdentityContext.UserID; if (IsSunnet == "true") { ticketEntity.StartDate = !string.IsNullOrEmpty(StartDate.ToString()) ? DateTime.Parse(StartDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); ticketEntity.DeliveryDate = !string.IsNullOrEmpty(DeliveryDate.ToString()) ? DateTime.Parse(DeliveryDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); } else { ticketEntity.StartDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); ticketEntity.DeliveryDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); } #region record,when title or descr or status changed if (originalTitle != title || originalDesc != descr) { ticketEntity.ModifiedOn = DateTime.Now; } if ((TicketsState)Enum.Parse(typeof(TicketsState), originalState) != ticketEntity.Status) { ticketEntity.PublishDate = DateTime.Now; } #endregion #region record history, when descr changed if (originalDesc != descr && ticketEntity.Status != TicketsState.Draft) { TicketHistorysEntity history = new TicketHistorysEntity(); history.TicketID = ticketEntity.TicketID; history.ModifiedBy = IdentityContext.UserID; history.ModifiedOn = DateTime.Now; history.Description = originalDesc; TicketApp.AddTicketHistory(history); } #endregion update = TicketApp.UpdateTickets(ticketEntity); #region send email if (IsSend) { TicketStatusManagerApplication EX = new TicketStatusManagerApplication(); EX.SendEmailToQaAndDevWhenStatusChanged(ticketEntity); } #endregion #endregion #region file FilesEntity fileEntity = new FilesEntity(); FolderName = ticketEntity.ProjectID.ToString(); string sNewFileName = ""; tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; string[] listStringName = imageList.Split(','); string[] listStringSize = imageSizeList.Split(','); foreach (string Name in listStringName) { if (Name.Length == 0) { break; } string sExtension = Path.GetExtension(Name).Replace(".", "").Trim(); foreach (string Size in listStringSize) { sNewFileName = FolderName + Name; fileEntity.ContentType = "." + sExtension.ToLower(); fileEntity.CreatedBy = IdentityContext.UserID;; fileEntity.FilePath = tempPath.Substring(2) + FolderName + @"/" + sNewFileName; fileEntity.FileSize = Convert.ToDecimal(Size.ToLower().Replace("kb", "")); fileEntity.FileTitle = Name.Substring(0, Name.LastIndexOf('.')); fileEntity.IsPublic = true; fileEntity.TicketId = tid; //ticketID fileEntity.ProjectId = pId; //ticketID fileEntity.SourceType = (int)FileSourceType.Ticket; fileEntity.ThumbPath = context.Server.MapPath(tempPath) + FolderName + sNewFileName;; // fileEntity.CreatedOn = DateTime.Now; int responseFile = fileApp.AddFile(fileEntity); if (responseFile <= 0) { HasFileMsG = false; stringErrorMsg.Add(fileEntity.FileTitle); } break; } } #endregion #region response if (update) { if (HasFileMsG) { context.Response.Write("Update Ticket Success!"); } else { string error = ""; foreach (string item in stringErrorMsg) { error += item + "File Upload Failed!"; } context.Response.Write(error); } } else { context.Response.Write("Update Fail!"); } #endregion } catch (Exception ex) { context.Response.Write("para error!"); WebLogAgent.Write(string.Format("Error Ashx:DoEditTicketHandler.ashx Messages:\r\n{0}", ex)); return; } }
private void AddFile(int tid, int pId, int i) { HttpContext context = HttpContext.Current; string image = ""; string DeleteImg = ""; if (i == 0) { image = this.AddTicket1.File; DeleteImg = this.AddTicket1.DeleteFile; } else if (i == 1) { image = this.AddTicket2.File; DeleteImg = this.AddTicket2.DeleteFile; } else { image = this.AddTicket3.File; DeleteImg = this.AddTicket3.DeleteFile; } string imageList = AnalysisString(image, 1); string imageSizeList = AnalysisString(image, 2); string deleteImglist = AnalysisString(DeleteImg, 1); ProjectsEntity pentity = projectApp.Get(Convert.ToInt32(pId)); if (null != pentity) { FolderName = pentity.ProjectID.ToString(); } string sNewFileName = ""; tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; string[] listStringName = imageList.Split(','); string[] listStringSize = imageSizeList.Split(','); string[] listdelImage = deleteImglist.Split(','); foreach (string Name in listStringName) { fileEntity = new FilesEntity(); string sExtension = Path.GetExtension(Name).Replace(".", "").Trim(); foreach (string Size in listStringSize) { if (listdelImage.Contains(Name)) { continue; } sNewFileName = FolderName + Name; fileEntity.ContentType = "." + sExtension.ToLower(); fileEntity.CreatedBy = UserInfo.UserID; fileEntity.FilePath = tempPath.Substring(2) + FolderName + @"/" + sNewFileName; fileEntity.FileSize = Convert.ToDecimal(Size.ToLower().Replace("kb", "")); fileEntity.FileTitle = Name.Substring(0, Name.LastIndexOf('.')); fileEntity.IsPublic = true; fileEntity.TicketId = tid;//ticketID fileEntity.ProjectId = pId; fileEntity.FeedbackId = 0; fileEntity.SourceType = (int)FileSourceType.Ticket; fileEntity.ThumbPath = context.Server.MapPath(tempPath) + FolderName + sNewFileName;;// fileEntity.CreatedOn = DateTime.Now.Date; fileEntity.CompanyID = IdentityContext.CompanyID; int responseResult = fileApp.AddFile(fileEntity); if (responseResult <= 0) { HasFileMsG = false; stringErrorMsg.Add(fileEntity.FileTitle); } break; } } }
protected void btnSave_Click(object sender, EventArgs e) { bool result = false; ProposalTrackerEntity entity = GetEntity(); //Check Work Scope Format First David02/25/2016 if (fileUpload.HasFile) { string fileContentType = fileUpload.PostedFile.ContentType; if ((fileContentType != "application/msword" && fileContentType != "application/pdf" && fileContentType != "application/vnd.openxmlformats-officedocument.wordprocessingml.document")) { ShowFailMessageToClient("Please select a file to upload ( *.doc, *.docx, *.pdf)"); return; } } int id = wrApp.AddProposalTracker(entity); if (id > 0) { if (fileUpload.HasFile) //Save Work Scope to 'Fiels' Table { FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = entity.WorkScope; model.ProposalTrackerId = id; model.ContentType = fileUpload.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileUpload.PostedFile.ContentLength; model.FileTitle = Path.GetFileName(fileUpload.FileName); model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.WorkRequestScope; model.ThumbPath = Path.GetFileName(fileUpload.PostedFile.FileName); result = fileApp.AddFile(model) > 0 ? true : false; } Redirect(entity.Status < 4 ? "index.aspx" : "EditProposalTracker.aspx?ID=" + id + "&returnurl=/OA/ProposalTracker/Index.aspx"); } else { ShowFailMessageToClient(wrApp.BrokenRuleMessages); } /* David 0225 Changed the work scope is not required * if (fileUpload.HasFile) * { * string fileContentType = fileUpload.PostedFile.ContentType; * if ((fileContentType == "application/msword" || fileContentType == "application/pdf" || fileContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")) || { || int id = wrApp.AddProposalTracker(entity); || if (id > 0) || { || FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance<ISystemDateTime>()); || model.FilePath = entity.WorkScope; || || model.ProposalTrackerId = id; || model.ContentType = fileUpload.PostedFile.ContentType; || model.FileID = 0; || model.FileSize = fileUpload.PostedFile.ContentLength; || model.FileTitle = Path.GetFileName(fileUpload.FileName); || model.IsDelete = false; || model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; || model.SourceType = (int)FileSourceType.WorkRequestScope; || model.ThumbPath = Path.GetFileName(fileUpload.PostedFile.FileName); || result = fileApp.AddFile(model) > 0 ? true : false; || Redirect("Index.aspx"); || } || else || { || ShowFailMessageToClient(wrApp.BrokenRuleMessages); || } || } || else || { || ShowFailMessageToClient("Please select a file to upload ( *.doc, *.docx, *.pdf)"); || } ||} ||else ||{ || ShowFailMessageToClient("Please upload Work Scope"); ||} || */ }
protected void btnSave_Click(object sender, EventArgs e) { bool result = true; if (fileUpload.HasFile) { string fileContentType = fileUpload.PostedFile.ContentType; if ((fileContentType != "application/msword" && fileContentType != "application/pdf" && fileContentType != "application/vnd.openxmlformats-officedocument.wordprocessingml.document")) { ShowFailMessageToClient("Please select a file to upload ( *.doc, *.docx, *.pdf)"); return; } } ProposalTrackerEntity entity = new App.ProposalTrackerApplication().Get(QS("ID", 0)); // basic infomation entity.ProjectID = Convert.ToInt32(ddlProject.SelectedValue); //entity.Payment = Convert.ToInt32(this.ddlPayment.SelectedValue); entity.InvoiceNo = ""; bool sendEmailToTeam = entity.Status != Convert.ToInt32(ddlStatus.SelectedValue); string oldStatusName = ((ProposalTrackerStatusEnum)entity.Status).ToString().Replace("_", " "); entity.Status = Convert.ToInt32(ddlStatus.SelectedValue); string newStatusName = ((ProposalTrackerStatusEnum)entity.Status).ToString().Replace("_", " "); entity.Title = txtTitle.Text.Trim(); entity.Description = txtDescription.Text.Trim(); entity.ModifyOn = DateTime.Now; entity.ModifyBy = UserInfo.UserID; entity.ProposalSentTo = txtProposalSentTo.Text.Trim(); DateTime proposalSentOn; if (DateTime.TryParse(txtProposalSentOn.Text.Trim(), out proposalSentOn)) { entity.ProposalSentOn = proposalSentOn; } else { entity.ProposalSentOn = null; } entity.PoTotalLessThenProposalTotal = chkLessThen.Checked; entity.PONo = txtPO.Text.Trim(); entity.ApprovedBy = txtApprovedBy.Text.Trim(); DateTime approvedOn; if (DateTime.TryParse(txtApprovedOn.Text.Trim(), out approvedOn)) { entity.ApprovedOn = approvedOn; } else { entity.ApprovedOn = null; } //DateTime invoiceSentOn; //if (DateTime.TryParse(txtInvoiceSentOn.Text.Trim(), out invoiceSentOn)) //{ // entity.InvoiceSentOn = invoiceSentOn; //} //else //{ // entity.InvoiceSentOn = null; //} if (fileUpload.HasFile) { string fileContentType = fileUpload.PostedFile.ContentType; entity.WorkScope = UtilFactory.Helpers.FileHelper.SaveUploadFiles("WorkScope", entity.ProjectID, fileUpload.PostedFile); entity.WorkScopeDisplayName = fileUpload.FileName; if (wrApp.UpdateProposalTracker(entity)) { if (sendEmailToTeam) { string subject = "[ " + entity.Title + " ]" + " -- " + "[ " + newStatusName + " ]"; string content = UserInfo.FirstAndLastName + " changed [" + entity.Title + "]'s status from [" + oldStatusName + "] to " + "[" + newStatusName + "] on " + entity.ModifyOn; ObjectFactory.GetInstance <IEmailSender>().SendMail("*****@*****.**", Config.DefaultSendEmail, subject, content); } FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>()); model.FilePath = entity.WorkScope; model.ProposalTrackerId = entity.ProposalTrackerID; model.ContentType = fileUpload.PostedFile.ContentType; model.FileID = 0; model.FileSize = fileUpload.PostedFile.ContentLength; model.FileTitle = Path.GetFileName(fileUpload.FileName); model.IsDelete = false; model.IsPublic = UserInfo.Role == RolesEnum.CLIENT; model.SourceType = (int)FileSourceType.WorkRequestScope; model.ThumbPath = Path.GetFileName(fileUpload.PostedFile.FileName); result = fileApp.AddFile(model) > 0 ? true : false; if (string.IsNullOrEmpty(QS("returnurl"))) { Redirect("index.aspx"); } else { Redirect(QS("returnurl")); } //Redirect(string.Format("EditProposalTracker.aspx?ID={0}&returnurl={1}", entity.ProposalTrackerID, QS("returnurl"))); } else { ShowFailMessageToClient(wrApp.BrokenRuleMessages); return; } } else { if (wrApp.UpdateProposalTracker(entity)) { if (sendEmailToTeam) { string subject = "[ " + entity.Title + " ]" + " -- " + "[ " + newStatusName + " ]"; string content = UserInfo.FirstAndLastName + " changed [" + entity.Title + "]'s status from [" + oldStatusName + "] to " + "" + newStatusName + "] on " + entity.ModifyOn; ObjectFactory.GetInstance <IEmailSender>().SendMail("*****@*****.**", Config.DefaultSendEmail, subject, content); } Redirect(QS("returnurl")); //Redirect(string.Format("EditProposalTracker.aspx?ID={0}&returnurl={1}", entity.ProposalTrackerID, QS("returnurl"))); } else { ShowFailMessageToClient(wrApp.BrokenRuleMessages); return; } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; try { if (IdentityContext.UserID <= 0) { return; } int result = 0; #region getValue int pId = Convert.ToInt32(context.Request["pId"]); string tType = context.Request["tType"]; string ckbEn = context.Request["ckbEn"]; string pty = context.Request["pty"]; string title = context.Request["title"]; string url = context.Request["url"]; string description = context.Request["descr"]; string imageList = context.Request["imageList"]; string imageSizeList = context.Request["imageSizeList"]; string StartDate = context.Request["StartDate"]; string DeliveryDate = context.Request["DeliveryDate"]; string satus = context.Request["satus"]; string IsSunnet = context.Request["isSunnet"]; string userlist = context.Request["userlist"]; #endregion UsersEntity entity = userApp.GetUser(IdentityContext.UserID); ProjectsEntity projectsEntity = projectApp.Get(pId); #region add ticket TicketsEntity ticketEntity = new TicketsEntity(); pty = string.IsNullOrEmpty(pty) ? "1" : pty; ticketEntity.ProjectID = pId; ticketEntity.CompanyID = projectsEntity.CompanyID; ticketEntity.Priority = (PriorityState)Convert.ToInt32(pty); ticketEntity.TicketType = (TicketsType)Convert.ToInt32(tType); ticketEntity.Title = title.NoHTML(); ticketEntity.URL = context.Server.UrlEncode(url); ticketEntity.FullDescription = description.NoHTML(); ticketEntity.CreatedBy = IdentityContext.UserID; ticketEntity.CreatedOn = DateTime.Now; ticketEntity.ModifiedOn = DateTime.Now; ticketEntity.IsEstimates = ckbEn == "checked" ? true : false; ticketEntity.TicketCode = new TicketsApplication().ConvertTicketTypeToTicketCode(ticketEntity.TicketType); ticketEntity.IsInternal = IsSunnet == "true" ? true : false; ticketEntity.ModifiedBy = 0; ticketEntity.PublishDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); ticketEntity.ConvertDelete = CovertDeleteState.Normal; ticketEntity.Source = entity.Role; if (IsSunnet == "true") { ticketEntity.StartDate = !string.IsNullOrEmpty(StartDate.ToString()) ? DateTime.Parse(StartDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); ticketEntity.DeliveryDate = !string.IsNullOrEmpty(DeliveryDate.ToString()) ? DateTime.Parse(DeliveryDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); if (entity.Role == RolesEnum.Supervisor) { ticketEntity.Status = TicketsState.Submitted; } else { ticketEntity.Status = TicketsState.PM_Reviewed; } } else { ticketEntity.StartDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); ticketEntity.DeliveryDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); ticketEntity.Status = satus == "0" ? TicketsState.Draft : TicketsState.Submitted; } result = ticketAPP.AddTickets(ticketEntity); if (result > 0) { TicketUsersEntity ticketUserEntity = new TicketUsersEntity(); //add pm user ticketUserEntity.Type = TicketUsersType.PM; ticketUserEntity.TicketID = result; ProjectsEntity projectEntity = projectApp.Get(ticketEntity.ProjectID); if (projectEntity != null) { ticketUserEntity.UserID = projectEntity.PMID; ticketAPP.AddTicketUser(ticketUserEntity); } else { WebLogAgent.Write(string.Format("Add Pm To Ticket User Error:Project :{0},Ticket:{1},CreateDate:{2}", ticketEntity.ProjectID, ticketEntity.TicketID, DateTime.Now)); } //add create user ticketUserEntity.Type = TicketUsersType.Create; ticketUserEntity.TicketID = result; ticketUserEntity.UserID = ticketEntity.CreatedBy; ticketAPP.AddTicketUser(ticketUserEntity); } #endregion #region send email TicketStatusManagerApplication ex = new TicketStatusManagerApplication(); if (!ticketEntity.IsInternal) { ex.SendEmailToPMWhenTicketAdd(result, ticketEntity.TicketType); } #endregion #region add file FilesEntity fileEntity = new FilesEntity(); if (null != projectsEntity) { FolderName = projectsEntity.ProjectID.ToString(); } string sNewFileName = ""; tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; string[] listStringName = imageList.Split(','); string[] listStringSize = imageSizeList.Split(','); foreach (string Name in listStringName) { if (Name.Length == 0) { break; } string sExtension = Path.GetExtension(Name).Replace(".", "").Trim(); foreach (string Size in listStringSize) { sNewFileName = FolderName + Name; fileEntity.ContentType = "." + sExtension.ToLower(); fileEntity.CreatedBy = entity.UserID; fileEntity.FilePath = tempPath.Substring(2) + FolderName + @"/" + sNewFileName; fileEntity.FileSize = Convert.ToDecimal(Size.ToLower().Replace("kb", "")); fileEntity.FileTitle = Name.Substring(0, Name.LastIndexOf('.')); fileEntity.IsPublic = !ticketEntity.IsInternal; fileEntity.ProjectId = pId; fileEntity.TicketId = result; fileEntity.CreatedOn = DateTime.Now.Date; fileEntity.FeedbackId = 0; fileEntity.SourceType = (int)FileSourceType.Ticket; fileEntity.ThumbPath = context.Server.MapPath(tempPath) + FolderName + sNewFileName;;// fileEntity.CompanyID = IdentityContext.CompanyID; int response = fileApp.AddFile(fileEntity); if (response <= 0) { HasFileMsG = false; stringErrorMsg.Add(fileEntity.FileTitle); } break; } } #endregion #region response msg if (result > 0) { if (HasFileMsG) { context.Response.Write("The ticket has been added."); } else { string error = ""; foreach (string item in stringErrorMsg) { error += item + "File Upload Failed!"; } context.Response.Write(error); } } else { context.Response.Write("Add Fail!"); } #endregion #region assign user and send email TicketUsersEntity tuEntity = new TicketUsersEntity();; string[] userWithRoleList = userlist.TrimEnd(',').Split(','); int assignResult = 0; if (userWithRoleList.Length > 0) { foreach (string item in userWithRoleList) { if (item.Length > 0) { string[] userWithRole = item.Split('-'); if (userWithRole.Length > 0) { tuEntity.TicketID = result; tuEntity.UserID = Convert.ToInt32(userWithRole[0]); tuEntity.Type = GetUserTypeByRoleID(userWithRole[1]); //Convert.ToInt32(userWithRole[0]); assignResult = ticketAPP.AddTicketUser(tuEntity); if (assignResult > 0) { ex.SendEmailToAssignedUser(tuEntity); } } } } } #endregion } catch (Exception ex) { context.Response.Write("Input special symbol is not allowed,please check title and description!"); WebLogAgent.Write(string.Format("Error Ashx:DoAddTicketHandler.ashx Messages:\r\n{0}", ex)); return; } }