protected void Page_Load(object sender, EventArgs e) { try { int docID; if (!int.TryParse(Request.QueryString["id"], out docID)) { throw new Exception("Brak ID w wywołaniu"); } XmlReader xr = new DocumentDAO().GetDataMatrix(docID); BarcodeData data; XmlSerializer serializer = new XmlSerializer(typeof(BarcodeData)); data = serializer.Deserialize(xr) as BarcodeData; if (data == null) { return; } IDataMatrixService service = new DataMatrixService(); string content = service.GetDataMatrixAsHtml(data); Response.ClearContent(); Response.Write(content); Response.Flush(); } catch (Exception ex) { Response.Redirect("~/shared/error.aspx"); } }
protected void btnGenerate_click(object sender, EventArgs e) { int docID = CoreObject.GetId(Request); BarcodeData newData = GetBarcodeDataFromForm(); newData.SentBy = Membership.GetUser().Comment; //documentID temporary in notes! newData.Notes = docID.ToString() + "|" + newData.Notes; XmlSerializer serializer = new XmlSerializer(typeof(BarcodeData)); if (Button1.CommandName == "Cancel") { newData.SendDate = null; } using (Stream ms = new MemoryStream()) { serializer.Serialize(ms, newData); ms.Seek(0, SeekOrigin.Begin); XmlReader xr = XmlReader.Create(ms); IDataMatrixService service = new DataMatrixService(); new DocumentDAO().SetDataMatrix(docID, (Guid)Membership.GetUser().ProviderUserKey, xr); Response.Redirect(Request.Url.AbsoluteUri, true); } }
private void generatePreview(BarcodeData data) { IDataMatrixService service = new DataMatrixService(); byte[] imgContent = service.GetDataMatrix(data, ImageFormat.Png); imgPreview.Src = string.Format("data:image/png;base64,{0}", Convert.ToBase64String(imgContent)); }
void historyGrid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) { return; } IDataMatrixService service = new DataMatrixService(); DataMatrixHistoryItem historyItem = e.Row.DataItem as DataMatrixHistoryItem; System.Web.UI.WebControls.Image codePreview = e.Row.FindControl("imgCode") as System.Web.UI.WebControls.Image; XmlSerializer serializer = new XmlSerializer(typeof(BarcodeData)); BarcodeData data = serializer.Deserialize(new StringReader(historyItem.Content)) as BarcodeData; byte[] imgContent = service.GetDataMatrix(data, ImageFormat.Png); codePreview.ImageUrl = string.Format("data:image/png;base64,{0}", Convert.ToBase64String(imgContent)); (e.Row.FindControl("lName") as Literal).Text = data.Name; (e.Row.FindControl("lAddress") as Literal).Text = data.Address; (e.Row.FindControl("lPost") as Literal).Text = data.Post; (e.Row.FindControl("lAmount") as Literal).Text = data.Amount.ToString(); (e.Row.FindControl("lReceiving") as Literal).Text = data.Receiving.ToString(); (e.Row.FindControl("lNotes") as Literal).Text = data.Notes.IndexOf('|') >= 0 ? data.Notes.Remove(0, data.Notes.IndexOf('|') + 1) : data.Notes; (e.Row.FindControl("lDepartment") as Literal).Text = data.Department; Literal status = e.Row.FindControl("lStatusWysylki") as Literal; //if (!data.SendDate.HasValue && string.IsNullOrEmpty(data.SentBy)) //{ // status.Text = string.Format(""); //} if (data.SendDate.HasValue && !string.IsNullOrEmpty(data.SentBy) && string.IsNullOrEmpty(data.RKWNumber)) { status.Text = string.Format("Przekazano do wysyłki. Użytkownik: {0}", data.SentBy); } if (!data.SendDate.HasValue && !string.IsNullOrEmpty(data.SentBy)) { status.Text = string.Format("Anulowano przekazanie do wysyłki. Użytkownik: {0}", data.SentBy); } if (data.SendDate.HasValue && !string.IsNullOrEmpty(data.SentBy) && !string.IsNullOrEmpty(data.RKWNumber)) { status.Text = string.Format("Zarejestrowano w Rejestrze Korespondencji Wychodzącej dn. {2:yyyy-MM-dd} o godz. {2:HH:mm). Nr poz.: {0}. Użytkownik: {1}", data.RKWNumber, data.SentBy, data.SendDate); } }
protected void lnkGetAsPdf_click(object sender, EventArgs e) { BarcodeData data = GetBarcodeDataFromForm(); IDataMatrixService service = new DataMatrixService(); string[] address = new string[3]; address[0] = txtName.Text; address[1] = txtAddress.Text; address[2] = txtPost.Text; byte[] content = service.GetDataMatrixWithAddressAsPdf(data, address); if (content.Length == 0) { return; } Transmit(content, "doc_" + CoreObject.GetId(Request).ToString() + "_DataMatrix.pdf"); }