Exemple #1
0
        /// <summary>
        /// Get/Set ObjKey by name (group name)
        /// </summary>
        /// <param name="okeyName">ObjKey name</param>
        /// <returns>FWObjKey object</returns>
        /// <remarks>
        /// If no ObjKey with the given name exists, a new ObjKey Object is created.
        /// </remarks>
        public FWObjKey this[string okeyName]
        {
            get
            {
                FWObjKey ret = null;
                string   okeyNameLowerCase = okeyName.ToLower();
                ObjKey[] arr       = Items;
                int      maxOkeyId = -1;
                foreach (ObjKey o in arr)
                {
                    if (o.name.ToLower().Equals(okeyNameLowerCase))
                    {
                        ret = new FWObjKey(o, GetDML(okeyName));
                        break;
                    }
                    maxOkeyId = Math.Max(maxOkeyId, o.id);
                }
                if (ret == null)
                {
                    ObjKey      okey = new ObjKey();
                    DocMaskLine dml  = GetDML(okeyName);
                    if (dml != null)
                    {
                        okey.id   = dml.id;
                        okey.name = dml.key;
                    }
                    else
                    {
                        okey.id   = maxOkeyId + 1;
                        okey.name = "INDEX" + okey.id;
                    }

                    Items = AddObjKey(arr, okey);
                }
                return(ret);
            }
            set
            {
                ObjKey okey = value.okey;
                okey.name = okeyName.ToUpper();
                string okeyNameLowerCase = okeyName.ToLower();

                bool     found = false;
                ObjKey[] arr   = Items;
                for (int i = 0; i < arr.Length; i++)
                {
                    ObjKey o = arr[i];
                    if (o.name.ToLower().Equals(okeyNameLowerCase))
                    {
                        arr[i] = okey;
                        found  = true;
                        break;
                    }
                }
                if (!found)
                {
                    Items = AddObjKey(arr, okey);
                }
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public ObjKey[] ToArray()
        {
            updateInternalData(true);

            ObjKey[] okeys = new ObjKey[mapObjKeys.Count];
            int      i     = 0;

            foreach (ObjKey o in mapObjKeys.Values)
            {
                okeys[i++] = o;
            }

            return(okeys);
        }
Exemple #4
0
        /// <summary>
        /// Get/Set ObjKey by ID
        /// </summary>
        /// <param name="okeyId">ObjKey ID</param>
        /// <returns>FWObjKey object</returns>
        /// <remarks>
        /// If no ObjKey with the given ID exists, a new ObjKey Object is created.
        /// </remarks>
        public FWObjKey this[int okeyId]
        {
            get
            {
                FWObjKey ret = null;
                ObjKey[] arr = Items;
                foreach (ObjKey o in arr)
                {
                    if (o.id == okeyId)
                    {
                        ret = new FWObjKey(o, GetDML(okeyId));
                        break;
                    }
                }
                if (ret == null)
                {
                    ObjKey okey = new ObjKey();
                    okey.id = okeyId;
                    DocMaskLine dml = GetDML(okeyId);
                    okey.name = (dml != null) ?  dml.key : ("INDEX" + okeyId);
                    ret       = new FWObjKey(okey, dml);
                    Items     = AddObjKey(arr, okey);
                }
                return(ret);
            }
            set
            {
                ObjKey okey = value.okey;
                okey.id = okeyId;

                bool     found = false;
                ObjKey[] arr   = Items;
                for (int i = 0; i < arr.Length; i++)
                {
                    ObjKey o = arr[i];
                    if (o.id == okeyId)
                    {
                        arr[i] = okey;
                        found  = true;
                        break;
                    }
                }
                if (!found)
                {
                    Items = AddObjKey(arr, okey);
                }
            }
        }
Exemple #5
0
 protected void updateInternalData(bool save)
 {
     if (save)
     {
         foreach (int k in mapValues.Keys)
         {
             ObjKey o = null;
             if (mapObjKeys.TryGetValue(k, out o))
             {
                 o.data = mapValues[k].ToArray();
             }
         }
     }
     else
     {
     }
 }
        private FindInfo internalMakeFindInfo(String parentId,
                                              String author, String price)
        {
            FindInfo findInfo = new FindInfo();

            // constrain results to children of s1
            findInfo.findChildren          = new EloixClient.IndexServer.FindChildren();
            findInfo.findChildren.parentId = parentId;

            findInfo.findByIndex = new FindByIndex();

            ObjKey okeyAuthor = null;

            if (author.Length != 0)
            {
                okeyAuthor      = new ObjKey();
                okeyAuthor.name = "AUTHOR";
                okeyAuthor.data = new String[] { author };
            }

            ObjKey okeyPrice = null;

            if (price.Length != 0)
            {
                okeyPrice      = new ObjKey();
                okeyPrice.name = "PRICE";
                okeyPrice.data = new String[] { price };
            }

            int n = ((okeyAuthor != null) ? 1 : 0) + ((okeyPrice != null) ? 1 : 0);

            findInfo.findByIndex.objKeys = new ObjKey[n];
            int i = 0;

            if (okeyAuthor != null)
            {
                findInfo.findByIndex.objKeys[i++] = okeyAuthor;
            }
            if (okeyPrice != null)
            {
                findInfo.findByIndex.objKeys[i++] = okeyPrice;
            }

            return(findInfo);
        }
Exemple #7
0
        public void SetNameData(int id, String name, List <String> data)
        {
            List <String> v = FindData(id, name);

            if (v != null)
            {
                v.Clear();
                v.AddRange(data);
            }
            else
            {
                ObjKey okey = new ObjKey();
                okey.id       = id;
                okey.name     = name;
                this[id]      = okey;
                mapValues[id] = data;
            }
        }
Exemple #8
0
 public ObjKey this[int id]
 {
     get
     {
         ObjKey        o = null;
         List <String> v = null;
         if (mapObjKeys.TryGetValue(id, out o))
         {
             if (mapValues.TryGetValue(id, out v))
             {
                 o.data = v.ToArray();
             }
         }
         return(o);
     }
     set
     {
         mapObjKeys[id] = value;
         mapValues[id]  = value.data != null ? (new List <String>(value.data)) : (new List <String>());
         value.id       = id;
     }
 }
Exemple #9
0
 /// <summary>
 /// Copy the given array and add the ObjKey object.
 /// </summary>
 /// <param name="arr">ObjKey array</param>
 /// <param name="okey">ObjKey object to add</param>
 /// <returns>New ObjKey array</returns>
 private ObjKey[] AddObjKey(ObjKey[] arr, ObjKey okey)
 {
     ObjKey[] newArr = null;
     if (arr != null)
     {
         newArr = new ObjKey[arr.Length + 1];
         for (int i = 0, j = 0; i < newArr.Length; i++)
         {
             if (j < arr.Length && arr[j].id < okey.id)
             {
                 newArr[i] = arr[j++];
             }
             else
             {
                 newArr[i] = okey;
             }
         }
     }
     else
     {
         newArr = new ObjKey[] { okey };
     }
     return(newArr);
 }
Exemple #10
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 based on keywording form "Email".
                // Parent is the "imaginary" archive entry with object ID = 1.
                String   parentId = "1";
                String   maskId   = "email";
                EditInfo editInfo = ix.Ix.createSord(parentId, maskId, EditInfoC.mbAll);

                // Hint: Supply the constant EditInfoC.mbAll to get not only the Sord object data
                //       but the storage mask data too.

                Logger.instance().log("prepared sord with GUID=" + editInfo.sord.guid);

                DocMask mask = editInfo.mask;
                Sord    sord = editInfo.sord;

                // Set display name
                sord.name = "C# sord";

                // Set some index attributes
                for (int i = 0; i < mask.lines.Length; i++)
                {
                    DocMaskLine dml = mask.lines[i];
                    if (dml.name.Equals("From") ||
                        dml.key.Equals("ELOOUTL1"))                         // this line is just to make it work with all languages
                    {
                        sord.objKeys[i].data = new String[] { "*****@*****.**" };
                    }
                    else if (dml.name.Equals("To") ||
                             dml.key.Equals("ELOOUTL2"))                             // this line is just to make it work with all languages
                    {
                        sord.objKeys[i].data = new String[] { "*****@*****.**" };
                    }
                }

                // CHECKIN
                int objId = ix.Ix.checkinSord(sord, SordC.mbAll, LockC.NO);
                Logger.instance().log("Created sord successfully, objId=" + objId);

                // CHECKOUT
                String strObjId = (String)Convert.ChangeType(objId, typeof(String));
                editInfo = ix.Ix.checkoutSord(strObjId, EditInfoC.mbSord, LockC.NO);
                sord     = editInfo.sord;
                Logger.instance().log("Checkout sord successfully, GUID=" + sord.guid);
                Logger.instance().log("name=" + sord.name);
                for (int i = 0; i < sord.objKeys.Length; i++)
                {
                    ObjKey okey = sord.objKeys[i];
                    if (okey.data.Length != 0)
                    {
                        Logger.instance().log("okey, goup-name=" + okey.name + ", data=" + okey.data[0]);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Logout
                // --
                if (ix != null)
                {
                    Logger.instance().log("IX logout...");
                    ix.Logout();
                    Logger.instance().log("IX logout OK");
                }
            }
        }
Exemple #11
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
                // createSord does not create the new Sord object inside the database.
                // The purpose of this function is to initialize a new Sord object and
                // inherit ACL values and replication sets from the parent or
                // storage mask.

                // 1.
                // Create a root folder based on keywording form "Basic entry".
                // Parent is the "imaginary" archive entry with object ID = 1.
                String   parentId = "1";
                String   maskId   = "0";               // same as "" or "0"
                EditInfo editInfo = ix.Ix.createSord(parentId, maskId, EditInfoC.mbSord);

                Logger.instance().log("1. created sord, GUID=" + editInfo.sord.guid);

                // 2.
                // Create a folder inside the "Chaos Folder".
                // Hint: Chaos objects can only be retrieved by search.
                //       They are not visible in the archive hirarchie.
                parentId = null;                           // same as "" or "0"
                maskId   = "EMail";
                editInfo = ix.Ix.createSord(parentId, maskId, EditInfoC.mbAll);

                Logger.instance().log("2. created sord, GUID=" + editInfo.sord.guid);

                // for each DocMaskLine in "EMail" there is an ObjKey in Sord.
                Logger.instance().log("sord: #index-lines=" + editInfo.sord.objKeys.Length);
                Logger.instance().log("mask: #index-lines=" + editInfo.mask.lines.Length);
                for (int i = 0; i < editInfo.mask.lines.Length; i++)
                {
                    DocMaskLine dml  = editInfo.mask.lines[i];
                    ObjKey      okey = editInfo.sord.objKeys[i];
                    Logger.instance().log("label=" + dml.name +
                                          ", group-name=" + okey.name +
                                          ", #values=" + okey.data.Length);
                }

                // 3.
                // Create a root folder based on keywording form "Basic entry".
                // Parent is the "imaginary" archive entry with object ID = 1.
                //String parentId = "Sord GUID or ID";			// [x] put in any GUID or ID of an existing archive entry
                //String maskId = "keywording form name or ID";	// [X] put in any name or ID of an existing document mask, e. g. "Structure element", "EMail"
                //EditInfo editInfo = ix.Ix.createSord(parentId, maskId, EditInfoC.mbSord);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                // Logout
                // --
                if (ix != null)
                {
                    Logger.instance().log("IX logout...");
                    ix.Logout();
                    Logger.instance().log("IX logout OK");
                }
            }
        }
Exemple #12
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 test sords with search term in name, desc and index data

                // sord1 has search term in name attribute
                Sord sord1 = ix.Ix.createSord("1", null, EditInfoC.mbSord).sord;
                sord1.name = "C# example FindAll sord1 " + searchAllFor;
                sord1.id   = ix.Ix.checkinSord(sord1, SordC.mbAll, LockC.NO);
                Logger.instance().log("sord1.id=" + sord1.id);

                // sord2 has search term in desc attribute
                Sord sord2 = ix.Ix.createSord("1", null, EditInfoC.mbSord).sord;
                sord2.name = "C# example FindAll sord2";
                sord2.desc = searchAllFor;
                sord2.id   = ix.Ix.checkinSord(sord2, SordC.mbAll, LockC.NO);
                Logger.instance().log("sord2.id=" + sord2.id);

                // sord3 has search term in index attribute
                Sord sord3 = ix.Ix.createSord("1", null, EditInfoC.mbSord).sord;
                sord3.name = "C# example FindAll sord3";
                ObjKey okey = new ObjKey();
                okey.id       = 0;
                okey.name     = "IX-EXAMPLE";
                okey.data     = new String[] { "find " + searchAllFor + " in index line" };
                sord3.objKeys = new ObjKey[] { okey };
                sord3.id      = ix.Ix.checkinSord(sord3, SordC.mbAll, LockC.NO);
                Logger.instance().log("sord3.id=" + sord3.id);

                // 2. Execute find

                // Prepare FindInfo object
                Logger.instance().log("find ...");
                FindInfo findInfo = new FindInfo();
                findInfo.findByIndex      = new FindByIndex();
                findInfo.findByIndex.name = "#" + searchAllFor;

                // find
                FindResult findResult = ix.Ix.findFirstSords(findInfo, 1000, SordC.mbAll);
                if (findResult.sords != null)
                {
                    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)
                {
                    DeleteOptions delOpts = new DeleteOptions();
                    delOpts.deleteFinally = true;
                    ix.Ix.deleteSord(null, sord1.guid, LockC.NO, null);
                    ix.Ix.deleteSord(null, sord2.guid, LockC.NO, null);
                    ix.Ix.deleteSord(null, sord3.guid, LockC.NO, null);
                    ix.Ix.deleteSord(null, sord1.guid, LockC.NO, delOpts);
                    ix.Ix.deleteSord(null, sord2.guid, LockC.NO, delOpts);
                    ix.Ix.deleteSord(null, sord3.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");
                }
            }
        }
Exemple #13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="okey">ObjKey object</param>
 /// <param name="dml">Index value definition</param>
 public FWObjKey(ObjKey okey, DocMaskLine dml)
 {
     this.okey     = okey;
     this.okeyData = new FWObjKeyData(okey);
     this.dml      = dml;
 }
Exemple #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="okey">ObjKey object</param>
 public FWObjKeyData(ObjKey okey)
 {
     this.okey = okey;
 }