private void incrSordCounter(IXConnection conn, int objId) { SordZ sordZ = new SordZ(SordC.mbObjKeys); Sord sord = null; try { sord = readSord(conn, objId, sordZ); foreach (ObjKey okey in sord.objKeys) { if (okey.name == "COUNTER") { int current = Convert.ToInt32(okey.data[0]); okey.data = new String[] { Convert.ToString(current + 1) }; break; } } } catch (Exception e) { Console.WriteLine("Cannot increment Sord counter, sord.id=" + objId + ", error=" + e); } finally { if (sord != null) { writeSord(conn, sord, sordZ); } } }
private void internalFindBooks(IXConnection ix, IXServicePortC CONST, String parentId, String author, String price) { Logger.instance().log("find author=" + author + ", price=" + price); // select names only SordZ mbName = new SordZ(); mbName.bset = SordC.mbName; // find FindInfo findInfo = internalMakeFindInfo(parentId, author, price); Sord[] sords = ix.Ix.findFirstSords(findInfo, 1000, mbName).sords; String nameList = ""; for (int i = 0; i < sords.Length; i++) { if (i != 0) { nameList += ","; } nameList += sords[i].name; } Logger.instance().log("find OK, sords=" + nameList); }
/// <summary> /// Constructor. /// </summary> /// <param name="ifc">Content interface object</param> /// <param name="findInfo">Find info object</param> /// <param name="sordZ">Element selector</param> public FWFindSordsCache(FWContentInterface ifc, FindInfo findInfo, SordZ sordZ) : base(ifc.Conn.Ix, findInfo) { this.ifc = ifc; this.sordZVal = new SordZ(sordZ != null ? sordZ.bset : 0L); this.sordZVal.bset |= SordC.mbMinMembers; }
public static List <Sord> FindChildren(String objId, IXConnection ixConn, bool references) { Console.WriteLine("FindChildren: objId " + objId, " ixConn " + ixConn); try { ixConn.Ix.checkoutSord(objId, SordC.mbAll, LockC.NO); } catch (Exception) { return(new List <Sord>()); } List <Sord> children = new List <Sord>(); FindInfo findInfo = new FindInfo(); FindChildren findChildren = new FindChildren(); FindByType findByType = new FindByType(); FindByIndex findByIndex = new FindByIndex(); Boolean includeReferences = references; SordZ sordZ = SordC.mbAll; Boolean recursive = true; int level = 3; ObjKey[] objKeys = new ObjKey[] { }; findChildren.parentId = objId; findChildren.mainParent = !includeReferences; findChildren.endLevel = (recursive) ? level : 1; findInfo.findChildren = findChildren; findInfo.findByIndex = findByIndex; FindResult findResult = new FindResult(); try { int idx = 0; findResult = ixConn.Ix.findFirstSords(findInfo, 1000, sordZ); while (true) { for (int i = 0; i < findResult.sords.Length; i++) { children.Add(findResult.sords[i]); } if (!findResult.moreResults) { break; } idx += findResult.sords.Length; findResult = ixConn.Ix.findNextSords(findResult.searchId, idx, 1000, sordZ); } } finally { if (findResult != null) { ixConn.Ix.findClose(findResult.searchId); } } return(children); }
/// <summary> /// Initialize /// </summary> /// <param name="conn">Connection object</param> /// <param name="arcName">Archive name</param> /// <param name="connProps">Connection properties</param> /// <returns></returns> public virtual void Init(FWConnection conn, string arcName, IXProperties connProps) { this.connVal = conn; this.classFactoryVal = new FWContentClassFactory(this); this.sordZVal = new SordZ(SordC.mbLeanMembers | SordC.mbDocVersionMembers); this.editZVal = new EditInfoZ(EditInfoC.mbDocumentMembers | EditInfoC.mbSignatureMembers | EditInfoC.mbAttachmentMembers, sordZVal); // try to get the temporary directory from the connection properties String tmpDir = (connProps != null) ? connProps[FWConnFactory.PROP_TEMP_DIR] : null; if (tmpDir != null && tmpDir.Length != 0) { tempDirVal = makeTempDir(tmpDir, Path.Combine(arcName, "Temp")); checkoutDirVal = makeTempDir(tmpDir, Path.Combine(arcName, "Checkout")); } else { try { // not found: use the users APPDATA directory tempDirVal = makeTempDir(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ELO Digital Office"), Path.Combine(arcName, "Temp")); checkoutDirVal = makeTempDir(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ELO Digital Office"), Path.Combine(arcName, "Checkout")); } catch (Exception) { try { tempDirVal = makeTempDir(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ELO Digital Office"), Path.Combine(arcName, "Temp")); checkoutDirVal = makeTempDir(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ELO Digital Office"), Path.Combine(arcName, "Checkout")); } catch (Exception) { // Konto "Local System" unter Windows 2003 kann nicht auf APPDATA zugreifen. tempDirVal = makeTempDir(Path.Combine(Path.GetTempPath(), "ELO Digital Office"), Path.Combine(arcName, "Temp")); checkoutDirVal = makeTempDir(Path.Combine(Path.GetTempPath(), "ELO Digital Office"), Path.Combine(arcName, "Checkout")); } } } // Initialize the FWDownloadManager object downloadManagerVal = ClassFactory.NewDownloadManager( tempDirVal, connProps.Get(FWConnFactory.PROP_CACHE_DOCUMENT_LIFETIME_SECONDS, FWConnFactory.PROP_CACHE_DOCUMENT_LIFETIME_DEFAULT)); checkedOutDocumentsManagerVal = ClassFactory.NewCheckedOutDocumentsManager(checkoutDirVal); }
/// <summary> /// Writes all changes to the sord object into the archive and removes the lock. /// </summary> public virtual void Checkin() { if (sordVal.deleted) { // set the deleted flag according to success or failure of the operation sordVal.deleted = Conn.Ix.deleteSord(null, sordVal.guid, LockC.YES, null); } else { SordZ sordZ = new SordZ(sordVal.changedMembers); int objId = Conn.Ix.checkinSord(sordVal, sordZ, LockC.YES); sordVal.id = objId; sordVal.lockId = -1; } }
/// <summary> /// Checkin or delete the object. /// </summary> /// <remarks> /// This function uploads all modified versions, attachments, previews, signatures /// and resets the lockId. /// </remarks> public override void Checkin() { if (sordVal.deleted) { InvalidateFiles(); Conn.Ix.deleteSord(null, sordVal.guid, LockC.YES, null); sordVal.lockId = -1; } else { // Upload all modified versions. // This makes the files read-only and the DownloadManager will // delete them. Document doc = uploadAllModifiedVersions(); // Write all changed members. SordZ sordZ = new SordZ(sordVal.changedMembers); doc = Conn.Ix.checkinDocEnd(sordVal, sordZ, doc, LockC.YES); sordVal.lockId = -1; sordVal.id = Convert.ToInt32(doc.objId); // try to refresh internal data // fails if user lacks read rights try { Refresh(); } catch (Exception ex) { if (Conn != null && Conn.Valid) { IXExceptionData exceptionData = Conn.Ix.parseException(ex.Message); if (exceptionData == null || exceptionData.exceptionType != IXExceptionC.ACCESS_DENIED) { throw; } } else { throw; } } InvalidateFiles(); } }
private Sord readSord(IXConnection conn, int objId, SordZ sordZ) { Sord ret = null; try { EditInfoZ editZ = new EditInfoZ(0, sordZ); EditInfo ed = conn.Ix.checkoutSord(Convert.ToString(objId), editZ, LockC.IF_FREE); ret = ed.sord; } catch (Exception e) { throw new IOException("Cannot read sord, sord.id=" + objId, e); } return(ret); }
private void internalFindEmailsFromTo(IXConnection ix, IXServicePortC CONST, String parentId, String from, String to) { Logger.instance().log("find from=" + from + ", to=" + to + "..."); // select names only SordZ mbName = new SordZ(); mbName.bset = SordC.mbName; // find FindInfo findInfo = internalMakeFindInfo(parentId, from, to); Sord[] sords = ix.Ix.findFirstSords(findInfo, 1000, mbName).sords; String nameList = ""; for (int i = 0; i < sords.Length; i++) { if (i != 0) nameList += ","; nameList += sords[i].name; } Logger.instance().log("find OK, sords=" + nameList); }
public abstract void onAfterCheckinActivity(IXServerEventsContext ec, Activity act, bool isNew, Sord sord, SordZ sordZ, LockZ unlockZ);
public abstract void onAfterCheckinReminder(IXServerEventsContext ec, Reminder[] remiArray, Sord sord, SordZ sordZ, LockZ unlockZ);
public abstract void onAfterStartWorkFlow(IXServerEventsContext ec, WFDiagram workflow, Sord sord, SordZ sordZ);
public abstract void onAfterEndEditWorkFlowNode(IXServerEventsContext ec, WFDiagram workflow, int nodeId, Sord sord, SordZ sordZ);
private void writeSord(IXConnection conn, Sord sord, SordZ sordZ) { conn.Ix.checkinSord(sord, sordZ, LockC.YES); }
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 a root folder Sord sordRoot = ix.Ix.createSord("1", null, EditInfoC.mbSord).sord; sordRoot.name = "C# example FindFirstFindNext"; sordRoot.id = ix.Ix.checkinSord(sordRoot, SordC.mbAll, LockC.NO); // 2. Create 30 sords under the root folder with a name that contains the search term Logger.instance().log("create " + nbOfSords + " sords..."); for (int i = 0; i < nbOfSords; i++) { String namePrefix = "" + i; while (namePrefix.Length < 4) { namePrefix = "0" + namePrefix; } Sord sord = ix.Ix.createSord(sordRoot.guid, null, EditInfoC.mbSord).sord; sord.name = namePrefix + "-" + searchTerm + "-" + namePrefix; sord.id = ix.Ix.checkinSord(sord, SordC.mbAll, LockC.NO); } Logger.instance().log("create sords OK"); // 3. Execute find Logger.instance().log("find..."); // Prepare FindInfo object FindInfo findInfo = new FindInfo(); findInfo.findByIndex = new FindByIndex(); findInfo.findByIndex.name = "*" + searchTerm + "*"; // find int maxSordsPerLoop = 9; int idx = 0; SordZ sordZ = new SordZ(); FindResult findResult = ix.Ix.findFirstSords(findInfo, maxSordsPerLoop, SordC.mbAll); do { // log find results Logger.instance().log("found #=" + findResult.sords.Length); for (int i = 0; i < findResult.sords.Length; i++) { Logger.instance().log("sord.id=" + findResult.sords[i].id + ", sord.name=" + findResult.sords[i].name); } // more results? if (!findResult.moreResults) { break; } // next results idx += findResult.sords.Length; findResult = ix.Ix.findNextSords(findResult.searchId, idx, maxSordsPerLoop, SordC.mbAll); } while (true); // release find result buffer in IndexServer ix.Ix.findClose(findResult.searchId); Logger.instance().log("find OK"); // clean up bool cleanUp = true; if (cleanUp) { DeleteOptions delOpts = new DeleteOptions(); delOpts.deleteFinally = true; ix.Ix.deleteSord(null, sordRoot.guid, LockC.NO, null); ix.Ix.deleteSord(null, sordRoot.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"); } } }
public abstract void onReadSord(IXServerEventsContext ec, Sord sord, SordZ sordZ, Document doc, LockZ lockZ);
public abstract bool onCheckSordAccess(IXServerEventsContext ec, Sord sord, SordZ sordZ, int lur, CheckAccessOptions opts);
/* * Example: start workflow for new document * public override void onAfterCheckinSord(EloixClient.IndexServer.IXServerEventsContext ec, EloixClient.IndexServer.Sord sord, EloixClient.IndexServer.Sord sordDB, EloixClient.IndexServer.Sord parentSord, EloixClient.IndexServer.SordZ sordZ, EloixClient.IndexServer.LockZ unlockZ) * { * // new sord? * if (sordDB == null && sord.type >= SordC.LBT_DOCUMENT) * { * FWConnection conn = connMap.getConn(ec); * conn.Ix.startWorkFlow("myHttpHandlerWorkflow", sord.name + "-workflow", sord.guid); * } * } */ ///<summary>See IX documentation</summary> ///<param name="ec">See IX documentation</param> ///<param name="sord">See IX documentation</param> ///<param name="sordDB">See IX documentation</param> ///<param name="parentSord">See IX documentation</param> ///<param name="sordZ">See IX documentation</param> ///<param name="unlockZ">See IX documentation</param> public abstract void onBeforeCheckinSord(IXServerEventsContext ec, Sord sord, Sord sordDB, Sord parentSord, SordZ sordZ, LockZ unlockZ);
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); } } }
///<summary>See IX documentation</summary> ///<param name="ec">See IX documentation</param> ///<param name="sord">See IX documentation</param> ///<param name="sordDB">See IX documentation</param> ///<param name="parentSord">See IX documentation</param> ///<param name="doc">See IX documentation</param> ///<param name="sordZ">See IX documentation</param> ///<param name="unlockZ">See IX documentation</param> public abstract void onAfterCheckinDocEnd(IXServerEventsContext ec, Sord sord, Sord sordDB, Sord parentSord, Document doc, SordZ sordZ, LockZ unlockZ);
/// <summary> /// Checkin the modified file and Sord data into the archive. /// </summary> public override void Checkin() { if (sordVal.deleted) { String winPath = File; if (winPath != null) { if (sordVal.lockId != Conn.Session.User.id) { // if not locked by me, checkout first Version.FileModified = true; } // delete file via ELOFS System.IO.File.Delete(File); FSFileHelper.CheckinFile(winPath, "", "", 0, 0, 0); } else { base.Checkin(); } } else { if (Version.FileModified) { if (!isFileInArchiveFolder(File)) { // Die zuzuweisende Datei darf nicht schreibgeschützt sein, sonst // wird das ELOFS sie mglw. gleich einchecken, wenn sie unten kopiert wird. { FileAttributes attrs = System.IO.File.GetAttributes(File); if ((attrs & FileAttributes.ReadOnly) != 0) { System.IO.File.SetAttributes(File, attrs & ~FileAttributes.ReadOnly); } } // Wenn neues Dokument, oder noch keine Version zugewiesen... if (Version.Id == 0) { // Dateiendung in DocVersion setzen, damit unten GetFileSystemPath // eine Endung zuweisen kann. string ext = Path.GetExtension(File); Version.Core.ext = ext; // Sicherstellen, dass DocVersion objekt auch im Sord eingetragen ist. sordVal.docVersion = Version.Core; } // Ensure RefPaths are read string s = ArcPathString; string orgFilePath = ((FSContentInterface)ifc).GetFileSystemPath(Core, Version.Core); if (System.IO.File.Exists(orgFilePath)) { // sollte bereits ausgecheckt sein. wenn nicht, dann jetzt auschecken FileAttributes attrs = System.IO.File.GetAttributes(orgFilePath); if ((attrs & FileAttributes.ReadOnly) != 0) { FSFileHelper.CheckoutFile(orgFilePath); } // nochmal zur Sicherheit prüfen, dass die Datei ausgecheckt ist attrs = System.IO.File.GetAttributes(orgFilePath); if ((attrs & FileAttributes.ReadOnly) != 0) { throw new System.InvalidOperationException("File " + orgFilePath + " expected to be writable."); } // Originaldatei löschen (wird nicht im Archiv gelöscht) System.IO.File.Delete(orgFilePath); } // Arbeitsdatei drüberkopieren System.IO.File.Copy(File, orgFilePath); File = orgFilePath; } Version.prepareCheckinDocBegin(Core); String verNo = mysubstring(Version.Version, Conn.CONST.DOC_VERSION.lnVersion); String verDesc = mysubstring(Version.Comment, Conn.CONST.DOC_VERSION.lnComment); FSFileHelper.CheckinFile(File, verNo, verDesc, Core.mask, Version.Core.pathId, Version.Core.encryptionSet); if (sordVal.id == -1) { string arcPath = FSFileHelper.MakeArcPathFromFileName(File); Sord sordDB = ifc.Conn.Ix.checkoutSord("FSPATH:" + arcPath, EditInfoC.mbOnlyId, LockC.NO).sord; sordVal.id = sordDB.id; sordVal.guid = sordDB.guid; sordVal.doc = sordDB.doc; FWSord fwsordDB = new FWSord(ifc, sordDB); OriginalFileName = fwsordDB.OriginalFileName; } Version.Modified = false; } Document doc = uploadAllModifiedVersions(); SordZ sordZ = new SordZ(sordVal.changedMembers); doc = Conn.Ix.checkinDocEnd(sordVal, sordZ, doc, LockC.YES); sordVal.id = Convert.ToInt32(doc.objId); } }
/// <summary> /// Search for archive content. /// </summary> /// <param name="findInfo">FindInfo object that describes the search.</param> /// <param name="sordZ">Members to be returned.</param> /// <returns>Result cache object.</returns> public virtual FWFindSordsCache <FWSord> FindSords(FindInfo findInfo, SordZ sordZ) { return(new FWFindSordsCache <FWSord>(this, findInfo, sordZ)); }