protected void Page_Load(object sender, System.EventArgs e)
		{
			try
			{

				if(Request["btnCancel"] != null)
				{
					DocumentTransaction.End();
					Response.Redirect("~/CloseWindow.html");		
					return;
				}

			if(!DocumentTransaction.IsActive())
				throw new BipFatalException();
				doc = DocumentTransaction.Current.Document;
                if(doc.Id < 1)
					btnUpdate.Visible = false;
				else	btnCreate.Visible = false;
				CtrlDocInfoView.Document = doc;
				DataBind();


			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}
			
		}
Exemplo n.º 2
0
 public static void Begin(DocumentEnt doc)
 {
     if (IsActive())
     {
         End();
     }
     HttpContext.Current.Session["DocumentTransaction"] = new DocumentTransaction(doc);
 }
Exemplo n.º 3
0
 public void Dispose()
 {
     // make sure connection is closed
     if (m_Document != null)
     {
         m_Document.Dispose();
         m_Document = null;
     }
 }
		protected void Page_Load(object sender, System.EventArgs e)
		{
			try
			{
				DocumentEnt doc = new DocumentEnt();
				doc.New();
				DocumentTransaction.Begin(doc);
				Response.Redirect("DocFileUpload.aspx");
			}
			catch(Exception ex)
			{
				this.ProcessException(ex);
			}

		}
Exemplo n.º 5
0
		protected void Page_Load(object sender, System.EventArgs e)
		{
			try
			{
				int id = Convert.ToInt32(Request["Id"]);
				DocumentEnt doc = new DocumentEnt();
				doc.Load(id);
				DocumentTransaction.Begin(doc);
				Response.Redirect("DocumentEdit.aspx");
			}

			catch(Exception ex)
			{
				this.ProcessException(ex);
			}
		}
		private void Page_Load(object sender, System.EventArgs e)
		{
			
			try
			{
				if(Request["btnCancel"] != null)
				{
					DocumentTransaction.End();
					Response.Redirect("~/CloseWindow.html");	
					return;
				}
				PanPreview.Visible = false;

				if(!DocumentTransaction.IsActive())
					throw new BipFatalException();

				doc = DocumentTransaction.Current.Document;
				lblFileName.Text=doc.FileName;
				if(Page.IsPostBack == false)
				{
					ddlFileType.DataSource = DocFileType.FindAll();
					ddlFileType.DataTextField = "Name";
					ddlFileType.DataValueField = "Id";
					ddlFileType.DataBind();
					//ddlFileType.Items.Insert(0, new ListItem("", "0"));
					ListUtils.SelectSingleListItem(ddlFileType.Items, doc.FileTypeId.ToString());

				}
				else
				{
					int fileType = Convert.ToInt32(ddlFileType.SelectedItem.Value);
					if(fileType == 0)
						throw new BipGenericException(Bip.Components.BipResources.GetString("StMustSelectFileType"));
					doc.ConfigureFileType( Convert.ToInt32(ddlFileType.SelectedItem.Value));
				}

				if(doc.Id > 0)
					btnBack.Visible = false;
			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}
			
		}
Exemplo n.º 7
0
		private void ShowParentDocLink(DocumentEnt doc)
		{
			if(doc.ParentId < 1)
				PanParentDocView.Visible = false;
			else
			{
				ArrayList docEnum = new ArrayList();
				docEnum.Add(doc.ParentId);
				DataTable tab = DocumentEnt.FindEnum(docEnum);
				if(tab == null || tab.Rows.Count <1)
					PanParentDocView.Visible = false;
				else
				{
					PanParentDocView.Visible = true;
					//PanParentDocView.Rows[0].Cells[1].InnerText= DbConvert.ToString(tab.Rows[0]["Id"]);
					PanParentDocView.Rows[0].Cells[2].InnerText= DbConvert.ToString(tab.Rows[0]["Header"]);
				}
			}
		}
Exemplo n.º 8
0
		private void Page_Load(object sender, System.EventArgs e)
		{

			if(Request["Id"] == null && ViewState["Id"] == null)
			{
				ProcessException(new BipFatalException());
				return;
			}

			try
			{
				if(Request["Id"] != null)
					m_DocumentId = Convert.ToInt32(Request["Id"]);
				else	m_DocumentId = Convert.ToInt32(ViewState["Id"]);

				if(!Page.IsPostBack)
					ViewState["Id"] = m_DocumentId.ToString();

				m_Document = new DocumentEnt();
				m_Document.Load(m_DocumentId);

				Control header = Page.FindControl("PageHeader");
				if(header != null)
				{
					Bip.WebControls.DocumentMenuCtrl docMenu = (Bip.WebControls.DocumentMenuCtrl)Page.LoadControl("~/WebControls/DocumentMenuCtrl.ascx");
					docMenu.DocumentId = m_DocumentId;
					header.Controls.Add(docMenu );
					docMenu.DataBind();
				
					string strJSTitleValue = m_Document.Header.Replace("\\", "\\\\").Replace("\"", "\\\"");
					string strSetTitleCtrl = "<script language=javascript>	window.document.title=\"" + strJSTitleValue + 
						"\";   if(window.parent != null)  window.parent.document.title = \"" +strJSTitleValue + 
						"\"; </script>";
					header.Controls.Add( new LiteralControl(strSetTitleCtrl));
				}
			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}

		}
		protected void Page_Load(object sender, System.EventArgs e)
		{
			try
			{
			
				if(Page.IsPostBack)
				{
					if(Request["btnCancel"] != null)
					{
						DocumentTransaction.End();
						Response.Redirect("~/CloseWindow.html");		
						return;
					}

					if(UploadedFile.PostedFile == null  ||
						UploadedFile.PostedFile.ContentLength ==0 ||
						UploadedFile.PostedFile.FileName == null)
						throw new BipGenericException(Bip.Components.BipResources.GetString("StrFileUploadError"));

					DocumentEnt doc = null;
					if(!DocumentTransaction.IsActive())
					{
						doc = new DocumentEnt();
						doc.New();
						DocumentTransaction.Begin(doc);
					}
					else
						doc = DocumentTransaction.Current.Document;

					doc.UploadFile(	UploadedFile.PostedFile.InputStream, System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName));
					//doc.FileName = ;
					Response.Redirect("DocFileTypeEdit.aspx");
				}
			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}

				// Put user code to initialize the page here
		}
Exemplo n.º 10
0
		protected void Page_Load(object sender, System.EventArgs e)
		{
			
			try
			{
				if(!DocumentTransaction.IsActive())
					throw new BipFatalException();
				
				doc = DocumentTransaction.Current.Document;

				if(Request["btnCancel"] != null)
				{
					DocumentTransaction.End();
					Response.Redirect("~/CloseWindow.html");		
					return;
				}
			
			
				if(Page.IsPostBack == false)
				{
					if(doc.Id<1)
					{
						PanExistingDocAttrs.Visible = false;
						btnBack.Text = "< " + BipResources.GetString("StrBtnBackCaption");
						btnBack.Width = new Unit("100px");
					}

					LoadDropDownList(ddlDocCategory, DocCategoryEnt.FindAll());
					LoadDropDownList(ddlDocType, DocTypeEnt.FindAll());
					LoadDropDownList(ddlDocSource, DocSourceEnt.FindAll());

					dlGroups.DataSource = Bip.Components.GroupEnt.FindAll();
					dlGroups.DataBind();


					LoadAttributes();
				}

				// ParentDocID ---------------------------------
				if(Page.IsPostBack ==false || 
					Request["_BIP_ACTION"] == "SelectParentDoc")
				{
					if(Request["_BIP_ACTION"]  == "SelectParentDoc")
						doc.ParentId = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
					ShowParentDocLink(doc);
				}

				// PreviousVersionDocID ---------------------------------
				if(Page.IsPostBack ==false || 
					Request["_BIP_ACTION"] == "SelectPreviousVersionDoc")
				{
					if(Request["_BIP_ACTION"]  == "SelectPreviousVersionDoc")
						doc.PreviousVersionId = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
					ShowPreviousVersionDocLink(doc);
				}

				// RelatedDocs ---------------------------------
				if(Page.IsPostBack ==false || 
					Request["_BIP_ACTION"] == "AddRelatedDoc" ||
					Request["_BIP_ACTION"] == "RemoveRelatedDoc")
				{
					if(Request["_BIP_ACTION"] == "AddRelatedDoc" ||
						Request["_BIP_ACTION"] == "RemoveRelatedDoc")
					{
						ArrayList docEnum = new ArrayList();
						if(doc.RefDocuments != null)
						{
							foreach(int ids in doc.RefDocuments)
								docEnum.Add(ids);
						}

						int id = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
						if(Request["_BIP_ACTION"] == "AddRelatedDoc")
						{
							if(docEnum.IndexOf(id) == -1)
								docEnum.Add(id);
						}
						else docEnum.Remove(id);

						doc.RefDocuments = docEnum;
					}

					grdDocRefRelated.DataSource = DocumentEnt.FindEnum(doc.RefDocuments);
					grdDocRefRelated.DataBind();
				}

				string s1, s2;
				bool showInBrowser = false;
				DocFileType.GetTypeInfo(doc.FileTypeId, out s1, out s2,  out showInBrowser);
				btnShowHidePreview.Visible = showInBrowser;


			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}
			
		}
		public override void DataBind()
		{
				if(Request["Id"] != null)
				{
					IsEditMode = false;
					doc = new DocumentEnt();
					doc.Load(Convert.ToInt32(Request["Id"]) );

					hlDownloadFile.NavigateUrl = "~/Documents/DocFileDownload.aspx?Org=1&Id=" + doc.Id.ToString();
					if(Page.IsPostBack == false && 
						Request.UrlReferrer != null &&
						Session["MAIN_PAGE"] == null)
					{
						if(Request.UrlReferrer.AbsolutePath.ToLower().IndexOf("Documents") == -1)
							Session["MAIN_PAGE"] = Request.UrlReferrer.ToString();
					}
				}
				else
				{
					//Session.Remove("MAIN_PAGE");
					IsEditMode = true;
					if(!DocumentTransaction.IsActive())
						throw new BipFatalException();
					doc = DocumentTransaction.Current.Document;

					hlDownloadFile.NavigateUrl = "~/Documents/DocFileDownload.aspx?Org=1&TC=1";
				}

				if(doc.Id <1 )
					PanExistingDocAttrs.Visible = false;
				else
				{
					lblId.Text = doc.Id.ToString();
					lblCreationTime.Text = doc.CreationTime.ToString();
				}



				ShowParentDocLink();
				ShowPreviousVersionDocLink();

				if(doc.RefDocuments != null)
					doc.RefDocuments.GetEnumerator().Reset();
				if(doc.RefDocuments == null ||
					!doc.RefDocuments.GetEnumerator().MoveNext())
					PanRelatedDocView.Visible=false;
				else
				{
					grdRelatedDocs.DataSource = DocumentEnt.FindEnum(doc.RefDocuments);
					grdRelatedDocs.DataBind();
				}

			if(doc.Groups != null)
			{
				dlGroups.DataSource = GroupEnt.FindEnum(doc.Groups);
				dlGroups.DataBind();
			}
			else dlGroups.Visible = false;
				


				LoadAttributes();
		}
		protected void Page_Load(object sender, System.EventArgs e)
		{
			try
			{
				bool isInFrame = (Request["frame"] != null);
				PanFileNotShown.Visible = false;
				try
				{
					string s_id = Request["Id"];
					string s_transaction = Request["TC"];
					bool original = true;
					if(Request["Org"] == null || Request["Org"].Length == 0)
						original = false;
					bool isInline = (Request["inline"] != null && 
						Request["inline"].Length > 0);
			
					DocumentEnt doc = new DocumentEnt();

					if(s_id != null && s_id.Length >0)
					{
						int id = Convert.ToInt32(s_id);
						doc.Load(id);
					}
					else
						if(s_transaction == "1" && DocumentTransaction.IsActive())
						doc = DocumentTransaction.Current.Document;
					else throw new BipFatalException();



					DocFileType fileType = new DocFileType(doc.FileTypeId);
					bool isText = (fileType.ContentType.Trim().ToLower() == "text/plain");
					if(isInline == false)
					{

						Response.Clear();
						Response.ContentType = fileType.ContentType;
						Response.AppendHeader("Content-Disposition","attachment; filename=\"" + doc.FileName + "\"");
						Response.BinaryWrite(doc.DownloadFile(original));
						Response.End(); 
						return;
					}

					if(isText == false)
					{
						if(fileType.ShowInBrowser == false)
						{
							PanFileNotShown.Visible = true;
							lblFileType.Text = fileType.Name;
							if(s_transaction == null)
								hlDownload.NavigateUrl = "~/Documents/DocFileDownload.aspx?id=" + doc.Id.ToString();
							else	hlDownload.NavigateUrl = "~/Documents/DocFileDownload.aspx?TC=1";
							hlDownload.Text = doc.FileName;
							return;
						}

						Response.Clear();
						Response.ContentType = fileType.ContentType;
						Response.AppendHeader("Content-Disposition","inline; filename=\"" + doc.FileName + "\"");
						Response.BinaryWrite(doc.DownloadFile(original));
						Response.End(); 
						return;
					}


					byte [] buffer = doc.DownloadFile(original);
					// this should not be hardcoded
					Decoder d = Encoding.GetEncoding("Windows-1252").GetDecoder();
					char [] chars = new char[buffer.Length];
					d.GetChars(buffer,0,buffer.Length,chars,0);
					textFileContents.InnerText= new string(chars);
				}
				catch(Exception ex)
				{
					if(ex is System.Threading.ThreadAbortException ||
						ex is System.Threading.ThreadInterruptedException)
						throw ex;

					if(!isInFrame)
						throw ex;
					Response.Clear();
					Response.Redirect("~/Error.aspx?error=" + HttpUtility.UrlEncode(ex.Message));
				}
			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}
			//HttpUtility.HtmlEncode(
		}
Exemplo n.º 13
0
		public void Dispose() 
		{
			// make sure connection is closed
			if (m_Document != null) 
			{
				m_Document.Dispose();
				m_Document = null;
			}				
		}
Exemplo n.º 14
0
		DocumentTransaction(DocumentEnt doc)
		{
			m_Document = doc;
		}
Exemplo n.º 15
0
		public static void Begin(DocumentEnt doc)
		{
			if(IsActive())
				End();
			HttpContext.Current.Session["DocumentTransaction"] = new DocumentTransaction(doc);
		}
Exemplo n.º 16
0
 DocumentTransaction(DocumentEnt doc)
 {
     m_Document = doc;
 }