Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a Sord object.
        /// </summary>
        /// <param name="ix">IndexServer connection</param>
        /// <param name="CONST">IndexServer constants</param>
        /// <param name="ci">Client information (ticket)</param>
        /// <returns>Sord GUID</returns>
        private String internalCreateDocument(IXConnection ix,
                                              IXServicePortC CONST)
        {
            Sord sord = ix.Ix.createSord("1", null, EditInfoC.mbSord).sord;

            sord.name = "C# Workflow example " + DateTime.Now;
            int objId = ix.Ix.checkinSord(sord, SordC.mbAll, LockC.NO);

            return(Convert.ToString(objId));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Removes the lock that was set by LockDocument or LockFolder.
 /// </summary>
 public virtual void Unlock()
 {
     if (sordVal.id > 1)
     {
         Sord sord = new Sord();
         sord.id   = sordVal.id;
         sord.guid = sordVal.guid;
         Conn.Ix.checkinSord(sord, SordC.mbOnlyUnlock, LockC.YES);
         sordVal.lockId = -1;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor. Normally, the constructor is called from FWConnFactory.
        /// </summary>
        /// <param name="innerConn">Inner connection</param>
        public FWConnection(IXConnection innerConn)
        {
            internalConnection     = innerConn;
            contentInterfaceVal    = new Content.FWContentInterface();
            sessionInterfaceVal    = new Session.FWSessionInterface(this, internalConnection.ConnProperties);
            workflowInterfaceVal   = new Workflow.FWWorkflowInterface(this, internalConnection.ConnProperties);
            masterDataInterfaceVal = new MasterData.FWMasterDataInterface(this, internalConnection.ConnProperties);

            arcSord = internalConnection.Ix.checkoutSord("1", EditInfoC.mbSordLean, LockC.NO).sord;
            contentInterfaceVal.Init(this, arcSord.name, internalConnection.ConnProperties);
        }
Ejemplo n.º 5
0
		private Sord internalCreateEmail(IXConnection ix,  
			IXServicePortC CONST, String parentId, String name, String from, String to) 
		{
			Sord d1 = ix.Ix.createDoc(parentId, "Email", null, EditInfoC.mbSord).sord;
			d1.name = name;
			d1.objKeys[0].data = new String[] {from};
			d1.objKeys[1].data = new String[] {to};
			d1.id = ix.Ix.checkinSord(d1, SordC.mbAll, LockC.NO);
			Logger.instance().log("name=" + name + ", from=" + from + ", to=" + to);
			return d1;
		}
Ejemplo n.º 6
0
        /// <summary>
        /// Try to read a document.
        /// </summary>
        /// <param name="objId">Object ID</param>
        /// <param name="accessMode">A combination of the FWAccessMode constants.</param>
        /// <returns>Null, if throwEx=false and the document does not exist.
        /// Otherwise a FWDocument object is returned.</returns>
        public override FWDocument TryGetDocument(String objId, FWAccessModes accessMode)
        {
            FWDocument xdoc = null;

            if (FWLockMode.HasLock(accessMode))
            {
                try
                {
                    // The document must be checked out via ELOFS.
                    // Thus we have to find out the file system path of the document first.

                    // call checkoutDoc to read the archive path
                    Sord sord = Conn.Ix.checkoutDoc(objId, null,
                                                    new EditInfoZ(0L, new SordZ(SordC.mbId | SordC.mbType | SordC.mbLockId | SordC.mbRefPaths | SordC.mbDocVersionMembers)),
                                                    LockC.NO).sord;

                    if (sord.id == 1 || sord.type < SordC.LBT_DOCUMENT)
                    {
                        throw new InvalidOperationException("Object " + objId + " is not a document.");
                    }

                    // checkout: set file attribute archive, reset file attribute read-only
                    String         winPath = GetFileSystemPath(sord, sord.docVersion);
                    FileAttributes attrs   = File.GetAttributes(winPath);
                    attrs |= FileAttributes.Archive;
                    attrs &= ~FileAttributes.ReadOnly;
                    File.SetAttributes(winPath, attrs);

                    // get all required values
                    xdoc = base.TryGetDocument(objId, FWAccessModes.Nothing);
                }
                catch (Exception e)
                {
                    if ((accessMode & FWAccessModes.MustExist) != 0)
                    {
                        throw e;
                    }
                    if (e.Message.IndexOf("[ELOIX:" + IXExceptionC.NOT_FOUND) < 0)
                    {
                        throw e;
                    }
                }
            }
            else
            {
                xdoc = base.TryGetDocument(objId, accessMode);
            }

            return(xdoc);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Checkout/checkin document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkoutDocument_Click(object sender, EventArgs e)
        {
            try {
                FWSord    sord    = conn.Content.GetSord(edObjId.Text);
                ArcPath[] arcPath = sord.RefPaths;

                Sord      sord2    = conn.Ix.checkoutSord(edObjId.Text, EditInfoC.mbAll, LockC.NO).sord;
                ArcPath[] arcPath2 = sord2.refPaths;


                // Get document locked
                FWDocument doc = conn.Content.LockDocument(edObjId.Text);
                if (doc == null)
                {
                    return;
                }

                // Download the documents file
                String file = doc.File; // same as doc.Version.File

                // Start application to edit the file
                System.Diagnostics.Process.Start(file);

                if (MessageBox.Show("Checkin?", "Checkin or unlock", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    MD5 md5 = new MD5(doc.File);
                    if (!md5.ToString().Equals(doc.Version.Core.md5))
                    {
                        doc.Version.Version = conn.DateToIso(DateTime.Now);
                        doc.Version.Comment = "New version " + doc.Version.Version;
                        doc.Checkin();
                    }
                    else
                    {
                        doc.Unlock();
                    }
                }
                else
                {
                    doc.Unlock();
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Is called before the version is checked in to supply the
        /// storage path ID and encryption set ID from the given Sord object.
        /// </summary>
        /// <param name="sord">Sord object with path and encryption set.</param>
        internal void prepareCheckinDocBegin(Sord sord)
        {
            dvVal.pathId = sord.path;

            // set the name and id of the owner of the DocVersion to the
            // currently logded on user's values.
            if (Conn != null && Conn.Valid && Conn.Session != null && Conn.Session.User != null)
            {
                dvVal.ownerId   = Conn.Session.User.id;
                dvVal.ownerName = Conn.Session.User.name;
            }

            if (typeVal == FWDocVersionType.TYPE_VERSION)
            {
                dvVal.encryptionSet = sord.details.encryptionSet;
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructs for each Sord object in the given FindResult a framework object.
 /// For Sord objects that refer to documents, FWDocument objects are created.
 /// For Sord objects that refer to folders, FWFolder objects are created.
 /// </summary>
 /// <param name="fr">FindResult object</param>
 /// <returns>Array of framework objects</returns>
 protected override T[] GetItemsFromResult(FindResult fr)
 {
     Sord[] sords  = fr.sords;
     T[]    xsords = new T[sords.Length];
     for (int i = 0; i < sords.Length; i++)
     {
         Sord sord = sords[i];
         if (sord.id > 1 && sord.type >= SordC.LBT_DOCUMENT)
         {
             T x = (T)(object)new FWDocument(ifc, sord);
             xsords[i] = x;
         }
         else
         {
             xsords[i] = (T)(object)new FWFolder(ifc, sord);
         }
     }
     return(xsords);
 }
Ejemplo n.º 11
0
        private Sord internalCreateBook(IXConnection ix,
                                        IXServicePortC CONST, String parentId, String name, String author, String price)
        {
            Sord d1 = ix.Ix.createDoc(parentId, "0", null, EditInfoC.mbSord).sord;

            d1.name            = name;
            d1.objKeys         = new ObjKey[2];
            d1.objKeys[0]      = new ObjKey();
            d1.objKeys[0].id   = 0;
            d1.objKeys[0].name = "AUTHOR";
            d1.objKeys[0].data = new String[] { author };
            d1.objKeys[1]      = new ObjKey();
            d1.objKeys[1].id   = 1;
            d1.objKeys[1].name = "PRICE";
            d1.objKeys[1].data = new String[] { price };
            d1.id = ix.Ix.checkinSord(d1, SordC.mbAll, LockC.NO);
            Logger.instance().log("name=" + name + ", author=" + author);
            return(d1);
        }
Ejemplo n.º 12
0
        static void createDocument(string file, string actFolder)
        {
            Document doc = new Document();
            //Step 1
            EditInfo ed   = conn.Ix.createDoc(actFolder, "", null, EditInfoC.mbSordDocAtt);
            Sord     sord = ed.sord;

            sord.name     = nameItem(file);
            sord.IDateIso = DateTime.Now.ToString("u");
            //Step 2
            doc.docs                  = new DocVersion[] { new DocVersion() };
            doc.docs[0].pathId        = sord.path;
            doc.docs[0].encryptionSet = sord.details.encryptionSet;
            doc.docs[0].ext           = conn.GetFileExt(file);
            doc = conn.Ix.checkinDocBegin(doc);
            // Step 3
            doc.docs[0].uploadResult = conn.Upload(doc.docs[0].url, file);
            // Step 4
            doc = conn.Ix.checkinDocEnd(sord, SordC.mbAll, doc, LockC.NO);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Makes a file system path in ELOFS for the given Sord object.
        /// </summary>
        /// <param name="sord">Sord object with valid sord.refPaths</param>
        /// <returns>File system path</returns>
        public String GetFileSystemPath(Sord sord, DocVersion dv)
        {
            FSConnection fsConn  = (FSConnection)Conn;
            String       winPath = fsConn.Config.Drive + "\\" + FSFileHelper.EscapeFileName(fsConn.ArcName);

            IdName[] arcPathObjs = sord.refPaths[0].path;
            for (int i = 0; i < arcPathObjs.Length; i++)
            {
                winPath += "\\" + FSFileHelper.EscapeFileName(arcPathObjs[i].name);
            }

            winPath += "\\" + FSFileHelper.EscapeFileName(sord.name);

            if (dv != null)
            {
                winPath += ".";
                winPath += dv.ext;
            }

            return(winPath);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates an archive path, if it does not exist.
        /// </summary>
        /// <param name="arcPath">Archive path to be created. First character is used as path delimiter.</param>
        /// <returns>Folder object of the last path segment.</returns>
        public virtual FWFolder MakeArcPath(String arcPath)
        {
            String      delim = arcPath.Substring(0, 1);
            List <Sord> sords = new List <Sord>();

            String[] toks = arcPath.Substring(1).Split(delim[0]);
            for (int i = 0; i < toks.Length; i++)
            {
                Sord sord = new Sord();
                sord.name = toks[i];
                sords.Add(sord);
            }
            if (sords.Count == 0)
            {
                return(RootFolder);
            }
            int[]    ids = Conn.Ix.checkinSordPath("1", sords.ToArray(), new SordZ(SordC.mbName));
            FWFolder f   = GetFolder(Convert.ToString(ids[ids.Length - 1]));

            return(f);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// This function adds the events to the list view.
        /// </summary>
        /// <param name="subsId">Subscriber ID</param>
        /// <param name="events">Events</param>
        private void ShowEvents(long subsId, Event[] events)
        {
            foreach (Event e in events)
            {
                ListViewItem item = new ListViewItem();
                item.Text = Convert.ToString(e.type);
                item.SubItems.Add(e.param2);
                Object[] args = (Object[])AnyToObject.ToObject(e.any);
                Sord     sord = (Sord)args[0];
                item.SubItems.Add(sord.name);
                int what = (int)args[2];
                switch (what)
                {
                case EventBusC.WATCH_INSERT: item.SubItems.Add("inserted"); break;

                case EventBusC.WATCH_UPDATE: item.SubItems.Add("updated"); break;

                case EventBusC.WATCH_DELETE: item.SubItems.Add("deleted"); break;
                }
                this.lvEvents.Items.Add(item);
            }
        }
Ejemplo n.º 16
0
        private void internalDumpLinks(IXConnection ix, IXServicePortC CONST,
                                       String guid)
        {
            // Checkout sord to get the new links
            Sord sord = ix.Ix.checkoutSord(guid, EditInfoC.mbSord, LockC.NO).sord;

            Logger.instance().log("links of " + sord.name + " {");
            for (int i = 0; i < sord.linksGoOut.Length; i++)
            {
                Sord linkToSord = ix.Ix.checkoutSord(sord.linksGoOut[i].id,
                                                     EditInfoC.mbSordLean, LockC.NO).sord;

                Logger.instance().log("    ->" + linkToSord.name);                 // + ", guid=" + sord.linksGoOut[i].id + ", linkId=" + sord.linksGoOut[i].linkId);
            }
            for (int i = 0; i < sord.linksComeIn.Length; i++)
            {
                Sord linkFromSord = ix.Ix.checkoutSord(sord.linksComeIn[i].id,
                                                       EditInfoC.mbSordLean, LockC.NO).sord;

                Logger.instance().log("    <-" + linkFromSord.name);                 // + ", guid=" + sord.linksComeIn[i].id + ", linkId=" + sord.linksComeIn[i].linkId);
            }
            Logger.instance().log("}");
        }
Ejemplo n.º 17
0
        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 Sord s1
                Sord s1 = ix.Ix.createSord("1", null, EditInfoC.mbSord).sord;
                s1.name = "s1 C# example MoveSord";
                s1.id   = ix.Ix.checkinSord(s1, SordC.mbAll, LockC.NO);
                Logger.instance().log("s1.id=" + s1.id);

                // create Sord o1
                Sord o1 = ix.Ix.createSord(s1.guid, null, EditInfoC.mbSord).sord;
                o1.name = "o1";
                o1.id   = ix.Ix.checkinSord(o1, SordC.mbAll, LockC.NO);
                Logger.instance().log("o1.id=" + o1.id);

                // create Sord r1
                Sord r1 = ix.Ix.createSord(o1.guid, null, EditInfoC.mbSord).sord;
                r1.name = "r1";
                r1.id   = ix.Ix.checkinSord(r1, SordC.mbAll, LockC.NO);
                Logger.instance().log("r1.id=" + r1.id);

                // create Sord o2
                Sord o2 = ix.Ix.createSord(s1.guid, null, EditInfoC.mbSord).sord;
                o2.name = "o2";
                o2.id   = ix.Ix.checkinSord(o2, SordC.mbAll, LockC.NO);
                Logger.instance().log("o2.id=" + o2.id);

                // VERIFY o1 contains r1
                String childIdsO1 = internalFindSordIdsInParent(ix, o1.guid);
                String childIdsO2 = internalFindSordIdsInParent(ix, o2.guid);
                Logger.instance().log("before move: o1:(" + childIdsO1 + "), o2:(" + childIdsO2 + ")");

                // MOVE r1 -> o2
                ix.Ix.copySord(o2.guid, r1.guid, null, CopySordC.MOVE);

                // VERIFY o2 contains r1
                childIdsO1 = internalFindSordIdsInParent(ix, o1.guid);
                childIdsO2 = internalFindSordIdsInParent(ix, o2.guid);
                Logger.instance().log("after move: o1:(" + childIdsO1 + "), o2:(" + childIdsO2 + ")");


                // Clean up?
                bool cleanUp = true;
                if (cleanUp)
                {
                    ix.Ix.deleteSord(null, s1.guid, LockC.NO, null);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Logout
                // --
                if (ix != null)
                {
                    Logger.instance().log("IX logout...");
                    ix.Logout();
                    Logger.instance().log("IX logout OK");
                }
            }
        }
Ejemplo n.º 18
0
        /// <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);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ifc">Content interface object</param>
 /// <param name="sord">Sord object</param>
 public FSDocument(FSContentInterface ifc, Sord sord)
     : base(ifc, sord)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Create new FWDoc object.
 /// </summary>
 /// <param name="sord">Sord object</param>
 /// <returns>FWDoc object</returns>
 public override FWDocument NewDocument(Sord sord)
 {
     return(new FSDocument((FSContentInterface)ifc, sord));
 }
Ejemplo n.º 21
0
        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 archive hirarchie

                // 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);

                // create sords
                Logger.instance().log("create sords...");
                for (int i = 0; i < nbOfChildren; 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 + "-o-" + namePrefix;
                    sord.id   = ix.Ix.checkinSord(sord, SordC.mbAll, LockC.NO);
                }
                Logger.instance().log("create sords OK");

                // 2. List hirarchie
                Logger.instance().log("find...");

                // Prepare FindInfo object
                FindInfo findInfo = new FindInfo();
                findInfo.findChildren          = new EloixClient.IndexServer.FindChildren();
                findInfo.findChildren.parentId = sordRoot.guid;

                // find
                FindResult findResult = ix.Ix.findFirstSords(findInfo, 1000, SordC.mbAll);
                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);
                }
                ix.Ix.findClose(findResult.searchId);
                Logger.instance().log("find OK");

                bool cleanUp = true;
                if (cleanUp)
                {
                    Logger.instance().log("clean up...");
                    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);
                    Logger.instance().log("clean up OK");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Logout
                // --
                if (ix != null)
                {
                    Logger.instance().log("IX logout...");
                    ix.Logout();
                    Logger.instance().log("IX logout OK");
                }
            }
        }
Ejemplo n.º 22
0
        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 archive structure
                Logger.instance().log("create structure...");

                // create root folder s1
                EditInfo ed = ix.Ix.createSord("1", "0", EditInfoC.mbAll);
                Sord     s1 = ed.sord;
                s1.name = "s1 C# example FindByIndexValues";
                s1.id   = ix.Ix.checkinSord(s1, SordC.mbAll, LockC.NO);

                ///     d1, name=The Inner Circle,		AUTHOR=T. Coraghessan Boyle,	PRICE=039
                ///     d2  name=The Shifting Tide,		AUTHOR=Anne Perry,				PRICE=037
                ///     d3  name=Feel,					AUTHOR=Robbie Williams,			PRICE=142
                ///     d4	name=The Da Vinci Code,     AUTHOR=Dan Brown,				PRICE=032
                ///
                Sord d1 = internalCreateBook(ix, CONST, s1.guid, "The Inner Circle", "T. Coraghessan Boyle", "039");
                Sord d2 = internalCreateBook(ix, CONST, s1.guid, "The Shifting Tide", "Anne Perry", "037");
                Sord d3 = internalCreateBook(ix, CONST, s1.guid, "Feel", "Robbie Williams", "142");
                Sord d4 = internalCreateBook(ix, CONST, s1.guid, "The Da Vinci Code", "Dan Brown", "032");

                Logger.instance().log("create structure OK");

                // 2. Find books from Authors with names from "A" to "J"
                internalFindBooks(ix, CONST, s1.guid, "A* ... J*", "");
                // Finds: The Da Vinci Code,The Shifting Tide

                // 3. Find books from Authors with names from "J"
                internalFindBooks(ix, CONST, s1.guid, "J*...*", "");
                // Finds: Feel,The Inner Circle

                // 4. Find books from Authors with names from "J" and price higher than 100
                internalFindBooks(ix, CONST, s1.guid, "J*...", "100...*");
                // Finds: Feel

                bool cleanUp = true;
                if (cleanUp)
                {
                    Logger.instance().log("clean up...");
                    ix.Ix.deleteSord(null, s1.guid, LockC.NO, null);
                    Logger.instance().log("clean up OK");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Logout
                // --
                if (ix != null)
                {
                    Logger.instance().log("IX logout...");
                    ix.Logout();
                    Logger.instance().log("IX logout OK");
                }
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes the internal objects by the given Sord.
 /// </summary>
 /// <param name="sord">Sord object</param>
 /// <remarks>This function is called in the constructor and in Refresh()</remarks>
 private void Init(Sord sord)
 {
     this.sordVal    = sord;
     this.objKeysVal = new MyObjKeys(this);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ifc">Content interface object</param>
 /// <param name="sord">Sord object from IndexServer API</param>
 public FWSord(FWContentInterface ifc, Sord sord)
     : base(ifc)
 {
     Init(sord);
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Reads the object from the IndexServer.
        /// </summary>
        /// <remarks>
        /// All modifications get lost.
        /// A possibly existing lock is not released.
        /// </remarks>
        public virtual void Refresh()
        {
            Sord sord = Conn.Ix.checkoutSord(Id.ToString(), Conn.Content.EditZ, LockC.NO).sord;

            Init(sord);
        }
Ejemplo n.º 26
0
 public abstract void onReadSord(IXServerEventsContext ec, Sord sord, SordZ sordZ, Document doc, LockZ lockZ);
Ejemplo n.º 27
0
        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");
                }
            }
        }
Ejemplo n.º 28
0
        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 Sord object to generate some report information
                Logger.instance().log("create sord...");
                Sord sord = ix.Ix.createSord("1", null, EditInfoC.mbSord).sord;
                sord.name = "C# Example Report";
                sord.id   = ix.Ix.checkinSord(sord, SordC.mbLean, LockC.NO);
                Logger.instance().log("create sord OK");

                // Wait some seconds. Report information is wirtten with a little
                // time delay after the action was taken.
                Logger.instance().log("sleep two seconds ...");
                System.Threading.Thread.Sleep(2000);
                Logger.instance().log("sleep two seconds OK");

                // Find report entries to sord
                Logger.instance().log("find report...");
                FindReportInfo findReport = new FindReportInfo();
                findReport.objId = sord.guid;
                FindResult findResult = ix.Ix.findFirstReportInfos(findReport, 10);

                int idx = 0;
                while (true)
                {
                    ReportInfo[] rinfos = findResult.reportInfos;
                    Logger.instance().log("find report OK, #infos=" + rinfos.Length);

                    // Dump report information.
                    // There could be more information since already deleted sord objects
                    // could have had the same ID.
                    for (int i = 0; i < rinfos.Length; i++)
                    {
                        Logger.instance().log("  action=" + rinfos[i].action);
                        Logger.instance().log("    time=" + rinfos[i].actTimeISO);
                        Logger.instance().log("    user="******"    text=" + rinfos[i].text);
                    }

                    if (!findResult.moreResults)
                    {
                        break;
                    }

                    idx       += rinfos.Length;
                    findResult = ix.Ix.findNextReportInfos(findResult.searchId, idx, 10);
                }

                DeleteOptions delOpts = new DeleteOptions();
                delOpts.deleteFinally = true;
                ix.Ix.deleteSord(null, sord.guid, LockC.NO, null);
                ix.Ix.deleteSord(null, 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");
                }
            }
        }
Ejemplo n.º 29
0
 public abstract bool onCheckSordAccess(IXServerEventsContext ec, Sord sord, SordZ sordZ, int lur, CheckAccessOptions opts);
Ejemplo n.º 30
0
        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 structure
                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);

                Sord e2 = ix.Ix.createSord(e1.guid, "0", EditInfoC.mbSord).sord;
                e2.name = "e2";
                e2.id   = ix.Ix.checkinSord(e2, SordC.mbAll, LockC.NO);
                Logger.instance().log("created e2: id=" + e2.id);

                Sord e3 = ix.Ix.createSord(e2.guid, "0", EditInfoC.mbSord).sord;
                e3.name = "e3";
                e3.id   = ix.Ix.checkinSord(e3, SordC.mbAll, LockC.NO);
                Logger.instance().log("created e3: id=" + e3.id);

                Sord e4 = ix.Ix.createSord(e3.guid, "0", EditInfoC.mbSord).sord;
                e4.name = "e4";
                e4.id   = ix.Ix.checkinSord(e4, SordC.mbAll, LockC.NO);
                Logger.instance().log("created e4: id=" + e4.id);

                // 2. Checkout Sord by archive path: /e1/e2/e3/e4
                Sord sord = ix.Ix.checkoutSord("ARCPATH:¶e1¶e2¶e3¶e4",
                                               EditInfoC.mbSord, LockC.NO).sord;
                Logger.instance().log("¶e1¶e2¶e3¶e4, id=" + sord.id + " == e4.id=" + e4.id);

                // Hint: The first character in the archive path defines the delimiter
                //       character used to seperate the archive levels.
                //       Thus you can use any character as delimiter. But consider
                //		 that this character should not be used in Sord names.

                sord = ix.Ix.checkoutSord("ARCPATH:\\e1\\e2\\e3\\e4",
                                          EditInfoC.mbSord, LockC.NO).sord;
                Logger.instance().log("\\e1\\e2\\e3\\e4, id=" + sord.id + " == e4.id=" + e4.id);

                bool cleanUp = true;
                if (cleanUp)
                {
                    DeleteOptions delOpts = new DeleteOptions();
                    delOpts.deleteFinally = true;
                    ix.Ix.deleteSord(null, e1.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");
                }
            }
        }