protected void Session_Start(object sender, EventArgs e) { Session["SessionID"] = System.Web.HttpContext.Current.Session.SessionID.ToString(); try { BarcodeMode.DeleteFolder(Session["SessionID"].ToString()); Session.Timeout = 20; } catch { } BarcodeMode.CreateFolder(Session["SessionID"].ToString()); }
private void Initial() { string strFilesPath = ""; string strSelectPath = ""; string strFilePath = Server.MapPath("."); int index = strFilePath.LastIndexOf("Samples"); if (index != -1) { strFilePath = strFilePath.Substring(0, index) + "Images\\"; } else { strFilePath = strFilePath + "\\Images\\DemoImages\\"; } string[] files = Directory.GetFiles(strFilePath); if (files != null && files.Length > 0) { bool isFirst = true; for (int i = 0; i < files.Length; i++) { string strFileExt = files[i].Substring(files[i].LastIndexOf('.') + 1).ToLower(); if (!BarcodeMode.IfFileExt(strFileExt)) { continue; } if (isFirst) { SetFilesPath(files[i], true, ref strFilesPath); strSelectPath = strFilesPath; isFirst = false; } else { SetFilesPath(files[i], false, ref strFilesPath); } } } hide_allImgURL.Value = strFilesPath; hide_ImgFileName.Value = strSelectPath; Image1.ImageUrl = strSelectPath; }
private string DoBarcodeInner(string strImgID, Int64 iFormat, string strSessionID) { string strReturnValue = ""; string strResult = ""; try { string strBarcodeInfo = BarcodeMode.Barcode(strImgID, iFormat, strSessionID, ref strResult); strReturnValue = "OK;" + strBarcodeInfo + ";" + strResult; } catch (Exception exp) { strReturnValue = "EXP;" + exp.Message.ToString() + ";" + strResult; } finally { } return(strReturnValue); }
public bool SetFilesPath(string strFilePath, bool bFirst, ref string strFilesPath) { string strReturnPath = BarcodeMode.LoadImage(strFilePath, SessionID); if (strReturnPath != "") { string strPath = BarcodeAccess.GetUploadFolder() + System.IO.Path.DirectorySeparatorChar + SessionID + System.IO.Path.DirectorySeparatorChar + strReturnPath; strPath = strPath.Replace("\\", "/"); if (bFirst) { strFilesPath = "Images/Upload/" + SessionID + "/" + strReturnPath; } else { strFilesPath = strFilesPath + ":Images/Upload/" + SessionID + "/" + strReturnPath; } return(true); } return(false); }
protected void Session_End(object sender, EventArgs e) { BarcodeMode.DeleteFolder(Session["SessionID"].ToString()); }
protected void Page_Load(object sender, EventArgs e) { try { SessionID = Session["SessionID"].ToString(); if (hide_State.Value == "1") { strReturnPath = BarcodeMode.UpLoadImage(upLoadFile, SessionID); } else if (hide_State.Value == "2") { strReturnPath = BarcodeMode.FetchImageFromURL(txtImgURL.Text.Trim(), SessionID); } if (strReturnPath != "") { Bitmap objImage = null; string strRestult = ""; try { string[] strAryPath = strReturnPath.Split(':'); string strPath = BarcodeAccess.GetUploadFolder() + System.IO.Path.DirectorySeparatorChar + SessionID + System.IO.Path.DirectorySeparatorChar + strAryPath[0]; strPath = strPath.Replace("\\", "/"); objImage = new Bitmap(strPath); iWidth = objImage.Width; iHeight = objImage.Height; foreach (string strTemp in strAryPath) { if (strRestult.Length == 0) { strRestult = strRestult + "Images/Upload/" + SessionID + "/" + strTemp; } else { strRestult = strRestult + ":Images/Upload/" + SessionID + "/" + strTemp; } } } catch { } finally { if (objImage != null) { objImage.Dispose(); } } strReturnPath = strRestult; } } catch (BarcodeException exp) { Page.ClientScript.RegisterStartupScript(Page.GetType(), null, "alert('" + exp.Message + "');", true); } catch { if (hide_State.Value == "1") { Page.ClientScript.RegisterStartupScript(Page.GetType(), null, "alert('Error uploading image.');", true); } else if (hide_State.Value == "2") { Page.ClientScript.RegisterStartupScript(Page.GetType(), null, "alert('Error loading image from remote URL.');", true); } } finally { } }