protected void btnSave_ServerClick(object sender, System.EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } bool valid = true; txtTitle.Text = HttpUtility.HtmlEncode(txtTitle.Text); ftbDescription.Text = HttpUtility.HtmlEncode(ftbDescription.Text); TimeSpan ts; ArrayList alCategories = new ArrayList(); for (int i = 0; i < lbCategory.Items.Count; i++) { if (lbCategory.Items[i].Selected) { alCategories.Add(int.Parse(lbCategory.Items[i].Value)); } } ArrayList alIncidentCategories = new ArrayList(); for (int i = 0; i < lbIncidentCategory.Items.Count; i++) { if (lbIncidentCategory.Items[i].Selected) { alIncidentCategories.Add(int.Parse(lbIncidentCategory.Items[i].Value)); } } ts = new TimeSpan(ucTaskTime.Value.Ticks); int Minutes = (int)ts.TotalMinutes; ts = new TimeSpan(ucExpectedResponseTime.Value.Ticks); int ExpectedResponseTime = (int)ts.TotalMinutes; ts = new TimeSpan(ucExpectedAssignTime.Value.Ticks); int ExpectedAssignTime = (int)ts.TotalMinutes; ts = new TimeSpan(ucExpectedDuration.Value.Ticks); int ExpectedDuration = (int)ts.TotalMinutes; int IncidentBoxId = int.Parse(ddlFolder.SelectedValue); int CreatorId = Security.CurrentUser.UserID; if (ViewState["CreatorId"] != null) { CreatorId = (int)ViewState["CreatorId"]; } PrimaryKeyId orgUid = PrimaryKeyId.Empty; PrimaryKeyId contactUid = PrimaryKeyId.Empty; if (ClientControl.ObjectType == OrganizationEntity.GetAssignedMetaClassName()) { orgUid = ClientControl.ObjectId; } else { contactUid = ClientControl.ObjectId; } int iProjectId = ProjectId; if (!Configuration.ProjectManagementEnabled || ddProject.Visible) { iProjectId = ddProject.ObjectId; } if (IncidentId != 0) { Issue2.Update(IncidentId, txtTitle.Text, ftbDescription.Text, iProjectId, int.Parse(ddlType.SelectedValue), int.Parse(ddlPriority.SelectedValue), int.Parse(ddlSeverity.SelectedValue), Minutes, IncidentBoxId, contactUid, orgUid, ExpectedResponseTime, ExpectedDuration, ExpectedAssignTime, alCategories, alIncidentCategories); } else { if (EMailMessageId > 0) { IncidentId = Incident.CreateFromEmail(txtTitle.Text, ftbDescription.Text, iProjectId, int.Parse(ddlType.SelectedValue), int.Parse(ddlPriority.SelectedValue), int.Parse(ddlSeverity.SelectedValue), Minutes, ExpectedDuration, ExpectedResponseTime, ExpectedAssignTime, alCategories, alIncidentCategories, IncidentBoxId, EMailMessageId, orgUid, contactUid); } else if (rbFile.Checked && fAssetFile.PostedFile != null && fAssetFile.PostedFile.ContentLength > 0) { IncidentId = Incident.Create(txtTitle.Text, ftbDescription.Text, iProjectId, int.Parse(ddlType.SelectedValue), int.Parse(ddlPriority.SelectedValue), int.Parse(ddlSeverity.SelectedValue), Minutes, ExpectedDuration, ExpectedResponseTime, ExpectedAssignTime, CreatorId, alCategories, alIncidentCategories, fAssetFile.PostedFile.FileName, fAssetFile.PostedFile.InputStream, false, DateTime.UtcNow, IncidentBoxId, contactUid, orgUid); } else if (rbHTML.Checked && fckEditor.Text != null && fckEditor.Text != String.Empty) { MemoryStream memStream = new MemoryStream(); StreamWriter writer = new StreamWriter(memStream); writer.Write(fckEditor.Text); writer.Flush(); memStream.Seek(0, SeekOrigin.Begin); String title = String.Empty; if (tbHtmlFileTitle.Text != String.Empty) { title = tbHtmlFileTitle.Text; } else { title = "HTML Attachment"; } string html_filename = Mediachase.UI.Web.Util.CommonHelper.GetHtmlFileTitle(title); html_filename = String.Concat(html_filename, ".html"); IncidentId = Incident.Create(txtTitle.Text, ftbDescription.Text, iProjectId, int.Parse(ddlType.SelectedValue), int.Parse(ddlPriority.SelectedValue), int.Parse(ddlSeverity.SelectedValue), Minutes, ExpectedDuration, ExpectedResponseTime, ExpectedAssignTime, CreatorId, alCategories, alIncidentCategories, html_filename, memStream, false, DateTime.UtcNow, IncidentBoxId, contactUid, orgUid); } else if (rbLink.Checked && tbLink.Text != String.Empty) { string data = string.Format("[InternetShortcut]\r\nURL={0}", tbLink.Text); MemoryStream memStream = new MemoryStream(); StreamWriter writer = new StreamWriter(memStream, Encoding.Unicode); writer.Write(data); writer.Flush(); memStream.Seek(0, SeekOrigin.Begin); string title = tbLinkTitle.Text; string html_filename = Mediachase.UI.Web.Util.CommonHelper.GetHtmlFileTitle(title); if (html_filename.IndexOf(".url") < 0) { html_filename += ".url"; } IncidentId = Incident.Create(txtTitle.Text, ftbDescription.Text, iProjectId, int.Parse(ddlType.SelectedValue), int.Parse(ddlPriority.SelectedValue), int.Parse(ddlSeverity.SelectedValue), Minutes, ExpectedDuration, ExpectedResponseTime, ExpectedAssignTime, CreatorId, alCategories, alIncidentCategories, html_filename, memStream, false, DateTime.UtcNow, IncidentBoxId, contactUid, orgUid); } else if (fAssetFile.PostedFile == null) { IncidentId = Incident.Create(txtTitle.Text, ftbDescription.Text, iProjectId, int.Parse(ddlType.SelectedValue), int.Parse(ddlPriority.SelectedValue), int.Parse(ddlSeverity.SelectedValue), Minutes, ExpectedDuration, ExpectedResponseTime, ExpectedAssignTime, CreatorId, alCategories, alIncidentCategories, null, null, false, DateTime.UtcNow, IncidentBoxId, contactUid, orgUid); } else { vFile.Visible = true; valid = false; } } EditControl.Save(IncidentId); if (IncidentId != 0 && valid) { if (cbOneMore.Checked) { if (ProjectId > 0) { Response.Redirect("../Incidents/IncidentEdit.aspx?Checked=1&ProjectId=" + ProjectId); } else { Response.Redirect("../Incidents/IncidentEdit.aspx?Checked=1"); } } else { Response.Redirect("../Incidents/IncidentView.aspx?IncidentId=" + IncidentId + "&Tab=Forum"); } } }