/// <summary> /// This function shows how to checkout a document using encryption functionality of /// It does not set the ix.Ix.cryptDocuments session option. It assigns "&crypt=true" /// to the URL to direct IndexServer to decrypt the document. /// Using this method does not require an extra call to DM. But the file size and file extension /// in the DocVersion object comes from the encrypted document (ETF-file) rather the /// original document. /// </summary> /// <param name="ix"></param> /// <param name="CONST"></param> /// <param name="ci"></param> /// <param name="objId"></param> private void checkoutDocDecryptedUsingUrlExt(IXConnection ix, IXServicePortC CONST, string objId) { // Tell IndexServer not to encrypt/decrypt. setSessionOptionEncrypt(ix, false); // Provide external password of encryption set. string encrPwd = ix.EncryptPassword(encryptionPassword); ix.Ix.provideCryptPassword("" + encryptionSet, encrPwd); EditInfo ed = ix.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO); Logger.instance().log("encrypted.ext=" + ed.document.docs[0].ext); Logger.instance().log("encrypted.size=" + ed.document.docs[0].size); String tempName2 = internalMakeTempFileName(".tmp"); // append the special parameter to the URL String urlDecr = ed.document.docs[0].url + "&crypt=true"; Logger.instance().log("prepared download URL=" + urlDecr); // ------------------------------------------------------------------------------- // The URL to download the document should be a HTTPS URL in production environments! // IndexServer configuration option "ixUrlBase" might be helpful here. // ------------------------------------------------------------------------------- ix.Download(urlDecr, tempName2); // Show document in notepad: System.Diagnostics.Process.Start("notepad.exe", tempName2); System.Threading.Thread.Sleep(3000); System.IO.File.Delete(tempName2); }
public static SortedDictionary <string, bool> GetRules(IXConnection ixConn, List <string> jsTexts, string package) { String parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/Business Solutions/" + package + "/ELOas Base/Direct"; if (package.Equals("")) { parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/ELOas Base/Direct"; } List <Sord> sordRuleInfo = RepoUtils.FindChildren(parentId, ixConn, true); SortedDictionary <string, bool> dicRules = new SortedDictionary <string, bool>(); foreach (Sord s in sordRuleInfo) { string objId = s.id + ""; EditInfo editInfo = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO); if (editInfo.document.docs.Length > 0) { DocVersion dv = editInfo.document.docs[0]; string url = dv.url; Stream inputStream = ixConn.Download(url, 0, -1); string xmlText = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd(); try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlText); string rulesetname = ""; foreach (XmlNode nameNode in doc.SelectNodes("ruleset/base/name")) { foreach (XmlNode subNode in nameNode.ChildNodes) { switch (subNode.Name) { case "#text": rulesetname = subNode.InnerText; break; } } } if (!dicRules.ContainsKey(rulesetname)) { bool match = Unittests.Match(ixConn, rulesetname, package, jsTexts); dicRules.Add(rulesetname, match); } } catch (XmlException e) { Debug.WriteLine("Exception: {0}", e.Message); } } } ; return(dicRules); }
public static SortedDictionary <string, bool> GetRFs(IXConnection ixConn, List <string> jsTexts, string package) { String parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/Business Solutions/" + package + "/IndexServer Scripting Base"; if (package.Equals("")) { parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/IndexServer Scripting Base/_ALL/business_solutions"; } List <Sord> sordRFInfo = RepoUtils.FindChildren(parentId, ixConn, true); SortedDictionary <string, bool> dicRFs = new SortedDictionary <string, bool>(); foreach (Sord s in sordRFInfo) { string objId = s.id + ""; EditInfo editInfo = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO); if (editInfo.document.docs.Length > 0) { DocVersion dv = editInfo.document.docs[0]; string url = dv.url; Stream inputStream = ixConn.Download(url, 0, -1); string jsText = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd(); string[] jsLines = jsText.Split('\n'); foreach (string line in jsLines) { if (line.Contains("function RF_")) { string[] rf = line.Split(); string rfName = rf[1]; string[] rfNames = rfName.Split('('); rfName = rfNames[0]; if (!rfName.Equals("*")) { if (!dicRFs.ContainsKey(rfName)) { bool match = Unittests.Match(ixConn, rfName, package, jsTexts); dicRFs.Add(rfName, match); } } } } } } ; return(dicRFs); }
public static List <string> LoadTextDocs(String parentId, IXConnection ixConn) { List <Sord> sordRFInfo = RepoUtils.FindChildren(parentId, ixConn, true); List <string> docTexts = new List <string>(); foreach (Sord s in sordRFInfo) { string objId = s.id + ""; EditInfo editInfo = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO); if (editInfo.document.docs.Length > 0) { DocVersion dv = editInfo.document.docs[0]; string url = dv.url; Stream inputStream = ixConn.Download(url, 0, -1); string docText = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd(); docTexts.Add(docText); } } ; return(docTexts); }
static Dictionary <string, string> GetUnittestApp(IXConnection ixConn) { String parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/Business Solutions/development/ELOapps/ClientInfos"; List <Sord> sordELOappsClientInfo = RepoUtils.FindChildren(parentId, ixConn, false); string configApp = ""; string configId = ""; foreach (Sord s in sordELOappsClientInfo) { string objId = s.id + ""; EditInfo editInfo = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO); DocVersion dv = editInfo.document.docs[0]; string url = dv.url; Stream inputStream = ixConn.Download(url, 0, -1); string jsonString = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd(); jsonString = jsonString.Replace("namespace", "namespace1"); JsonConfig config = JsonConfig.ReadToObject(jsonString); string webId = config.web.id; if (webId != null) { if (webId.Contains("UnitTests")) { configApp = config.web.namespace1 + "." + config.web.id; configId = config.id; } } } ; Dictionary <string, string> dicApp = new Dictionary <string, string>(); dicApp.Add("configApp", configApp); dicApp.Add("configId", configId); return(dicApp); }
public void run() { IXConnFactory connFact = null; IXConnection ix = null; try { IXProperties connProps = IXConnFactory.CreateConnProperties(url); IXProperties sessOpts = IXConnFactory.CreateSessionOptions("IX-Examples", "1.0"); connFact = new IXConnFactory(connProps, sessOpts); Logger.instance().log("create IXConnFactory OK"); // Prepare ClientInfo object with language and country // ClientInfo ci = new ClientInfo(); // ci.language = "de"; // ci.country = "DE"; // LOGIN Logger.instance().log("login..."); ix = connFact.Create(userName, userPwd, "myComputer", null); // ci = ix.Login.ci Logger.instance().log("login OK"); // get constants Logger.instance().log("get const..."); IXServicePortC CONST = ix.CONST; Logger.instance().log("get const OK"); // 1. Create sord for document without version // Initialize Sord object EditInfo ed = ix.Ix.createDoc("1", "0", null, EditInfoC.mbSordDocAtt); ed.sord.name = "C# example CheckinAttachment"; // Create attachment file String attFile = internalCreateTestFile("CheckinNewAttachment attachment file", "txt"); // Supply the extension of the document ed.document.atts = new DocVersion[1]; ed.document.atts[0] = new DocVersion(); ed.document.atts[0].ext = ix.GetFileExt(attFile); ed.document.atts[0].pathId = ed.sord.path; // ed.document.atts[0].encryptionSet = ignored // CheckinDocBegin: let IndexServer generate an URL to upload the document ed.document = ix.Ix.checkinDocBegin(ed.document); Logger.instance().log("prepared upload URL=" + ed.document.atts[0].url + ", att-guid=" + ed.document.atts[0].guid); // Upload the document String uploadResult = ix.Upload(ed.document.atts[0].url, attFile); ed.document.atts[0].uploadResult = uploadResult; Logger.instance().log("upload succeeded"); System.IO.File.Delete(attFile); // CheckinDocEnd: uploadResult contains the document information from ELODM. // Pass this information to ed.document = ix.Ix.checkinDocEnd(ed.sord, SordC.mbAll, ed.document, LockC.NO); Logger.instance().log("inserted document:"); Logger.instance().log(" objId=" + ed.document.objId); Logger.instance().log(" attId=" + ed.document.atts[0].id); Logger.instance().log(" att-guid=" + ed.document.atts[0].guid); Logger.instance().log(" URL=" + ed.document.atts[0].url); // 2. Checkout and show document ed = ix.Ix.checkoutDoc(ed.sord.guid, null, EditInfoC.mbAll, LockC.NO); String tempName2 = internalMakeTempFileName(ed.document.atts[0].ext); ix.Download(ed.document.atts[0].url, tempName2); // Uncomment this to show document in notepad: // System.Diagnostics.Process.Start("notepad.exe", tempName2); // System.Threading.Thread.Sleep(3000); System.IO.File.Delete(tempName2); bool cleanUp = true; if (cleanUp) { // Delete Document DeleteOptions delOpts = new DeleteOptions(); delOpts.deleteFinally = true; ix.Ix.deleteSord(null, ed.sord.guid, LockC.NO, null); ix.Ix.deleteSord(null, ed.sord.guid, LockC.NO, delOpts); } } catch (Exception e) { throw e; } finally { // Logout // -- if (ix != null) { Logger.instance().log("IX logout..."); ix.Logout(); Logger.instance().log("IX logout OK"); } } }
private static void FindChildren(IXConnection conn, string arcPath, string winPath, bool exportReferences, string maskName) { FindInfo fi = null; FindResult fr = null; try { EditInfo ed = conn.Ix.checkoutSord(arcPath, EditInfoC.mbOnlyId, LockC.NO); int parentId = ed.sord.id; fi = new FindInfo(); fi.findChildren = new FindChildren(); fi.findChildren.parentId = Convert.ToString(parentId); fi.findChildren.endLevel = 1; SordZ sordZ = SordC.mbMin; int idx = 0; fr = conn.Ix.findFirstSords(fi, 1000, sordZ); while (true) { foreach (Sord sord in fr.sords) { bool isFolder = sord.type < SordC.LBT_DOCUMENT; bool isDocument = sord.type >= SordC.LBT_DOCUMENT && sord.type <= SordC.LBT_DOCUMENT_MAX; bool isReference = sord.parentId != parentId; bool doExportScript = false; // Keine Referenzen ausgeben if (!exportReferences) { if (!isReference) { doExportScript = true; } } // Referenzen mit ausgeben else { doExportScript = true; } // Prüfen, ob bestimmte Verschlagwortungsmaske angegeben if (doExportScript && isDocument) { if (maskName.Trim().Equals("")) { doExportScript = true; } else { if (sord.maskName.Equals(maskName)) { doExportScript = true; } else { doExportScript = false; } } } if (doExportScript) { // Wenn Ordner rekursiv aufrufen if (isFolder) { // Neuen Ordner in Windows anlegen, falls noch nicht vorhanden string subFolderPath = winPath + "\\" + sord.name; if (!Directory.Exists(subFolderPath)) { try { Directory.CreateDirectory(subFolderPath); } catch (System.IO.PathTooLongException e) { Console.WriteLine("Exception: " + e.Message + " " + subFolderPath); Debug.WriteLine("Exception: " + e.Message + " " + subFolderPath); return; } } FindChildren(conn, arcPath + "/" + sord.name, subFolderPath, exportReferences, maskName); } // Wenn Dokument Pfad und Name ausgeben if (isDocument) { // Dokument aus Archiv downloaden und in Windows anlegen ed = conn.Ix.checkoutDoc(Convert.ToString(sord.id), null, EditInfoC.mbDocument, LockC.NO); DocVersion dv = ed.document.docs[0]; String outFile = winPath + "\\" + sord.name + "." + dv.ext; if (File.Exists(outFile)) { File.Delete(outFile); } try { conn.Download(dv.url, outFile); Console.WriteLine("Arcpath=" + arcPath + "/" + sord.name + " Maskname=" + sord.maskName); Debug.WriteLine("Arcpath=" + arcPath + "/" + sord.name + " Maskname=" + sord.maskName); } catch (System.IO.PathTooLongException e) { Console.WriteLine("Exception: " + e.Message + " " + outFile); Debug.WriteLine("Exception: " + e.Message + " " + outFile); return; } } } } if (!fr.moreResults) { break; } idx += fr.sords.Length; fr = conn.Ix.findNextSords(fr.searchId, idx, 1000, sordZ); } } catch (byps.BException e) { if (e.Source != null) { Console.WriteLine("byps.BException message: {0}", e.Message); Debug.WriteLine("byps.BException message: {0}", e.Message); } } catch (System.IO.DirectoryNotFoundException e) { if (e.Source != null) { Console.WriteLine("System.IO.DirectoryNotFoundException message: {0}", e.Message); Debug.WriteLine("System.IO.DirectoryNotFoundException message: {0}", e.Message); } } catch (System.NotSupportedException e) { if (e.Source != null) { Console.WriteLine("System.NotSupportedException message: {0}", e.Message); Debug.WriteLine("System.NotSupportedException message: {0}", e.Message); } } finally { if (fr != null) { conn.Ix.findClose(fr.searchId); } } }
public void run() { IXConnFactory connFact = null; IXConnection ix = null; try { IXProperties connProps = IXConnFactory.CreateConnProperties(url); IXProperties sessOpts = IXConnFactory.CreateSessionOptions("IX-Examples", "1.0"); connFact = new IXConnFactory(connProps, sessOpts); Logger.instance().log("create IXConnFactory OK"); // Prepare ClientInfo object with language and country // ClientInfo ci = new ClientInfo(); // ci.language = "de"; // ci.country = "DE"; // LOGIN Logger.instance().log("login..."); ix = connFact.Create(userName, userPwd, "myComputer", null); // ci = ix.Login.ci Logger.instance().log("login OK"); // get constants Logger.instance().log("get const..."); IXServicePortC CONST = ix.CONST; Logger.instance().log("get const OK"); // Create a root folder Sord e1 = ix.Ix.createSord("1", "0", EditInfoC.mbSord).sord; e1.name = "e1"; e1.id = ix.Ix.checkinSord(e1, SordC.mbAll, LockC.NO); Logger.instance().log("created e1: id=" + e1.id); // Create 100 Sords String[] guids = new String[nbOfDocs]; long diffTicks = 0; for (int i = 0; i < nbOfDocs; i++) { // Initialize a EditInfo object long t1 = System.DateTime.Now.Ticks; EditInfo ed = ix.Ix.createDoc(e1.guid, "Email", null, EditInfoC.mbSordDocAtt); long t2 = System.DateTime.Now.Ticks; diffTicks += (t2 - t1); // Add some index attributes ed.sord.name = "e1." + i; for (int idx = 0; idx < ed.sord.objKeys.Length; idx++) { ed.sord.objKeys[idx].data = new String[] { ed.sord.name + ".idx" + idx }; } // Create a file String docFile = internalCreateTestFile("DocPerformance " + ed.sord.name, "txt"); // checkinDocBegin ed.document.docs = new DocVersion[1]; ed.document.docs[0] = new DocVersion(); ed.document.docs[0].ext = ix.GetFileExt(docFile); ed.document.docs[0].pathId = ed.sord.path; ed.document.docs[0].encryptionSet = ed.sord.details.encryptionSet; ed.document = ix.Ix.checkinDocBegin(ed.document); // upload t1 = System.DateTime.Now.Ticks; ed.document.docs[0].uploadResult = ix.Upload(ed.document.docs[0].url, docFile); t2 = System.DateTime.Now.Ticks; diffTicks += (t2 - t1); // checkinDocEnd t1 = System.DateTime.Now.Ticks; ed.document = ix.Ix.checkinDocEnd(ed.sord, SordC.mbAll, ed.document, LockC.NO); t2 = System.DateTime.Now.Ticks; diffTicks += (t2 - t1); guids[i] = ed.sord.guid; if ((i + 1) % 20 == 0) { Logger.instance().log("create: " + (i + 1) + "/" + nbOfDocs); } System.IO.File.Delete(docFile); } // Log time values logTimeValues("create", diffTicks, nbOfDocs); // 2. Read 100 Documents diffTicks = 0; for (int i = 0; i < nbOfDocs; i++) { // checkoutDoc long t1 = System.DateTime.Now.Ticks; EditInfo ed = ix.Ix.checkoutDoc(guids[i], null, EditInfoC.mbSordDocAtt, LockC.NO); // download String docFile = internalMakeTempFileName(ed.document.docs[0].ext); ix.Download(ed.document.docs[0].url, docFile); long t2 = System.DateTime.Now.Ticks; diffTicks += (t2 - t1); System.IO.FileInfo fi = new System.IO.FileInfo(docFile); if (fi.Length < fileSize) { throw new InvalidOperationException("download failed"); } if ((i + 1) % 20 == 0) { Logger.instance().log("read: " + (i + 1) + "/" + nbOfDocs); } System.IO.File.Delete(docFile); } // Log time values logTimeValues("read", diffTicks, nbOfDocs); // 3. Delete root folder logically (implicitly deletes the 100 included Sords) Logger.instance().log("delete logically..."); DateTime startTime = System.DateTime.Now; ix.Ix.deleteSord(null, e1.guid, LockC.NO, null); DateTime endTime = System.DateTime.Now; logTimeValues("delete logically", startTime, endTime, nbOfDocs); // 4. Delete root folder finally (implicitly deletes the 100 included Sords) Logger.instance().log("delete finally..."); startTime = System.DateTime.Now; DeleteOptions delOpts = new DeleteOptions(); delOpts.deleteFinally = true; ix.Ix.deleteSord(null, e1.guid, LockC.NO, delOpts); endTime = System.DateTime.Now; logTimeValues("delete finally", startTime, endTime, nbOfDocs); } catch (Exception e) { throw e; } finally { // Logout // -- if (ix != null) { Logger.instance().log("IX logout..."); ix.Logout(); Logger.instance().log("IX logout OK"); } } }
public void run() { IXConnFactory connFact = null; IXConnection ix = null; try { IXProperties connProps = IXConnFactory.CreateConnProperties(url); IXProperties sessOpts = IXConnFactory.CreateSessionOptions("IX-Examples", "1.0"); connFact = new IXConnFactory(connProps, sessOpts); Logger.instance().log("create IXConnFactory OK"); // Prepare ClientInfo object with language and country // ClientInfo ci = new ClientInfo(); // ci.language = "de"; // ci.country = "DE"; // LOGIN Logger.instance().log("login..."); ix = connFact.Create(userName, userPwd, "myComputer", null); // ci = ix.Login.ci Logger.instance().log("login OK"); // get constants Logger.instance().log("get const..."); IXServicePortC CONST = ix.CONST; Logger.instance().log("get const OK"); // 1. Create document without an associated file EditInfo ed = ix.Ix.createDoc("1", "0", null, EditInfoC.mbSord); ed.sord.name = "C# example CheckinNewDocument"; ed.sord.id = ix.Ix.checkinSord(ed.sord, SordC.mbAll, LockC.NO); // Create test file // 2. Checkout document ed = ix.Ix.checkoutDoc(ed.sord.guid, null, EditInfoC.mbSordDocAtt, LockC.YES); Logger.instance().log("checkout sord succeeded, objId=" + ed.document.objId); // Hint: Now the document is locked and will be unlocked by checkinDocEnd // 3. Checkin a file as a new Version String text = "version 1"; String testFile = internalCreateTestFile(text, "txt"); // Supply the extension of the document ed.document.docs = new DocVersion[1]; ed.document.docs[0] = new DocVersion(); ed.document.docs[0].ext = ix.GetFileExt(testFile); ed.document.docs[0].pathId = ed.sord.path; ed.document.docs[0].encryptionSet = ed.sord.details.encryptionSet; // CheckinDocBegin: let IndexServer generate an URL to upload the document ed.document = ix.Ix.checkinDocBegin(ed.document); // Upload the document String uploadResult = ix.Upload(ed.document.docs[0].url, testFile); ed.document.docs[0].uploadResult = uploadResult; // Set version comment ed.document.docs[0].version = "1.0"; ed.document.docs[0].comment = "IndexServer C# example"; // CheckinDocEnd: uploadResult contains the document information from ELODM. // Pass this information to ed.document = ix.Ix.checkinDocEnd(null, null, ed.document, LockC.YES); // Hint: It's not nessesary to pass a Sord object to IndexServer in checkinDocEnd, // if the indexing information was not changed. IndexServer gets the // object ID from ed.document.objId. Logger.instance().log("inserted document version:"); Logger.instance().log(" objId=" + ed.document.objId); Logger.instance().log(" docId=" + ed.document.docs[0].id); Logger.instance().log(" doc-guid=" + ed.document.docs[0].guid); Logger.instance().log(" URL=" + ed.document.docs[0].url); // 2. Checkout and show document ed = ix.Ix.checkoutDoc(ed.sord.guid, ed.document.docs[0].guid, EditInfoC.mbAll, LockC.YES); String tempName2 = internalMakeTempFileName(ed.document.docs[0].ext); ix.Download(ed.document.docs[0].url, tempName2); // Uncomment this to show document in notepad: //System.Diagnostics.Process.Start("notepad.exe", tempName2); //System.Threading.Thread.Sleep(3000); System.IO.File.Delete(tempName2); // insert second version //text = "version 2"; //testFile = internalCreateTestFile(text, "txt"); //ed.document.docs = new DocVersion[1]; //ed.document.docs[0] = new DocVersion(); //ed.document.docs[0].ext = IXClient.getFileExt(testFile); //ed.document = ix.Ix.checkinDocBegin(ed.document); //uploadResult = ix.Upload(ed.document.docs[0].url, testFile); //ed.document.docs[0].uploadResult = uploadResult; //ed.document.docs[0].version = "2.0"; //ed.document.docs[0].comment = "2.0 IndexServer C# example"; //ed.document = ix.Ix.checkinDocEnd(null, null, ed.document, LockC.YES); bool cleanUp = true; if (cleanUp) { // Delete Document DeleteOptions delOpts = new DeleteOptions(); delOpts.deleteFinally = true; ix.Ix.deleteSord(null, ed.sord.guid, LockC.NO, null); ix.Ix.deleteSord(null, ed.sord.guid, LockC.NO, delOpts); } } catch (Exception e) { throw e; } finally { // Logout // -- if (ix != null) { Logger.instance().log("IX logout..."); ix.Logout(); Logger.instance().log("IX logout OK"); } } }