Hello,
My team is developing a mobile application that is going to be used when load/unloading trailers to process shipment data. Part of the process requires that a picture is taken of the Load/Trailer to prevent damage claims.
I am looking for a way to pass the picture(s) and Metadata to Laserfiche directly. The images will be saved as JPG files, but I cannot find a way to pass the information directly to Laserfiche. My thought is to pass the information via ByteArray, but cannot find any code samples to accomplish this.
I have tried to work with the Sample Web API Code (below) provided as part of the Steve's Doors Case Study. This appears to be saving the image to a Web Server, then Laserfiche is picking up the image from there. We are trying to bypass the Web Server step and link our Mobile Application directly to Laserfiche through code. Can anyone provide guidance on how this can be done? Or steer me in the right direction?
[WebMethod] public string PostToLF(string sPalletID, byte[] Pic1 = null, byte[] Pic2 = null, byte[] Pic3 = null) { string stemp = ""; //clear directory if (File.Exists(@"c:\temp\pic1.jpg")) { File.Delete(@"c:\temp\pic1.jpg"); } if (File.Exists(@"c:\temp\pic2.jpg")) { File.Delete(@"c:\temp\pic2.jpg"); } if (File.Exists(@"c:\temp\pic3.jpg")) { File.Delete(@"c:\temp\pic3.jpg"); } //Save Pictures to disk if (Pic1.Length > 100) { try { BinaryWriter writer = new BinaryWriter(File.Open(@"c:\temp\pic1.jpg", FileMode.Create)); writer.Write(Pic1); writer.Close(); writer = null; stemp += "Uploaded Image 1" + Environment.NewLine; } catch (Exception ex) { stemp += ex.ToString() + Environment.NewLine; } } if (Pic2.Length > 100) { try { BinaryWriter writer = new BinaryWriter(File.Open(@"c:\temp\pic2.jpg", FileMode.Create)); writer.Write(Pic2); writer.Close(); writer = null; stemp += "Uploaded Image 2" + Environment.NewLine; } catch (Exception ex) { stemp += ex.ToString() + Environment.NewLine; } } if (Pic3.Length > 100) { try { BinaryWriter writer = new BinaryWriter(File.Open(@"c:\temp\pic3.jpg", FileMode.Create)); writer.Write(Pic3); writer.Close(); writer = null; stemp += "Uploaded Image 3" + Environment.NewLine; } catch (Exception ex) { stemp += ex.ToString() + Environment.NewLine; } } //get SONUM, TLID, CARNUM for this order to store in LF. string queryString = "SQL Query Here"; SqlConnection connection = new SqlConnection(“SQL Connection String Here”); connection.Open(); SqlCommand command = new SqlCommand(queryString, connection); SqlDataAdapter da = new SqlDataAdapter(command); DataTable dtResults = new DataTable(); da.Fill(dtResults); da = null; command = null; connection.Close(); connection = null; string sSONum = ""; string sTLID = ""; string sCARNUM = ""; string sPONUM = ""; if (dtResults.Rows.Count > 0) { sSONum = dtResults.Rows[0]["SONUM"].ToString(); sTLID = dtResults.Rows[0]["TLID"].ToString(); sCARNUM = dtResults.Rows[0]["CARNUM"].ToString(); sPONUM = dtResults.Rows[0]["PONUM"].ToString(); } else { return "ERROR: Invalid PalletID"; } //upload files into laserfiche //create a connection to the Laserfiche repository RepositoryRegistration myRegistration = new RepositoryRegistration("Laserfiche Server Address", " Laserfiche Repository Name"); Session mySession = new Session(); try { mySession.LogIn("Laserfiche User Name", " Laserfiche Password", myRegistration); if (mySession != null) { //push into laserfiche FolderInfo rootFolder; rootFolder = Folder.GetFolderInfo(@"Laserfiche Directory", mySession); //import selected pictures for (int i = 1; i < 4; i++) { if (File.Exists(@"c:\temp\pic" + i.ToString() + ".jpg")) { DocumentInfo docInfo = new DocumentInfo(mySession); docInfo.Create(rootFolder, sPalletID + " - Picture " + i.ToString(), "GENERAL", EntryNameOption.AutoRename); docInfo.SetTemplate("PICS"); FieldValueCollection myFields = new FieldValueCollection(); myFields.Add("Pallet ID", sPalletID); myFields.Add("Truckload ID", sTLID); myFields.Add("Shipping Order Number", sSONum); myFields.Add("CARNUM", sCARNUM); myFields.Add("PONUM", sPONUM); docInfo.SetFieldValues(myFields); docInfo.Save(); DocumentImporter myImporter = new DocumentImporter(); myImporter.Document = docInfo; myImporter.ImportEdoc("JPG", @"c:\temp\pic" + i.ToString() + ".jpg"); } } } else { stemp = "ERROR: Unable to connect to Laserfiche. \nPlease try again later."; } } catch (Exception exc) { stemp = "ERROR:" + exc.ToString(); } finally { if (mySession.LogInTime.Year.ToString() != "1") { mySession.LogOut(); } mySession = null; myRegistration = null; } return stemp; }
Any help is much appreciated!
Cheers,
Nate