Esempio n. 1
0
 /// <summary>
 /// Singleton method to Get the instance of Flaim Server
 /// </summary>
 /// <param name="config">Flaim configuration details</param>
 /// <returns>Static instance of FlaimServer</returns>
 internal static FlaimServer GetServer(ProviderConfig config)
 {
     lock (typeof(FlaimServer))
     {
         if (instance == null)
         {
             instance = new FlaimServer(config);
         }
         return(instance);
     }
 }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pResultSet"></param>
 /// <param name="count"></param>
 /// <param name="flaimServer"></param>
 public FlaimResultSet(IntPtr pResultSet, int count, FlaimServer flaimServer)
 {
     this.count    = count;
     this.pResults = pResultSet;
     Flaim         = flaimServer;
 }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="results"></param>
        /// <param name="flaimServer"></param>
        /// <returns></returns>
        internal FlaimError.Error Search(Query query, out FlaimResultSet results, FlaimServer flaimServer)
        {
            FlaimError.Error rc = FlaimError.Error.FERR_OK;

            results = null;
            int    count;
            IntPtr pFlaimResults;
            int    op            = 0;
            string sValue        = query.Value;
            int    caseSensitive = 0;

            switch (query.Operation)
            {
            case SearchOp.Equal:
                op = 103;                                       // FLM_EQ_OP
                break;

            case SearchOp.Not_Equal:
                op = 108;                                       // FLM_NE_OP
                break;

            case SearchOp.Begins:
                op = 105;                                       // FLM_MATCH_BEGIN_OP
                break;

            case SearchOp.Ends:
                op = 106;                                       // FLM_MATCH_END_OP
                break;

            case SearchOp.Contains:
                op = 107;                                       // FLM_CONTAINS_OP
                break;

            case SearchOp.Greater:
                op = 111;                                       // FLM_GT_OP
                break;

            case SearchOp.Less:
                op = 109;                                       // FLM_LT_OP
                break;

            case SearchOp.Greater_Equal:
                op = 112;                                       // FLM_GE_OP
                break;

            case SearchOp.Less_Equal:
                op = 110;                                       // FLM_LE_OP
                break;

            case SearchOp.Exists:
                switch (query.Type)
                {
                case Syntax.Boolean:
                    op     = 112;
                    sValue = "0";
                    break;

                case Syntax.Byte:
                case Syntax.Char:
                case Syntax.DateTime:
                case Syntax.Int16:
                case Syntax.Int32:
                case Syntax.Int64:
                case Syntax.SByte:
                case Syntax.TimeSpan:
                case Syntax.UInt16:
                case Syntax.UInt32:
                case Syntax.UInt64:
                    op     = 111;                                               // FLM_GT_OP
                    sValue = Int64.MinValue.ToString();
                    break;

                case Syntax.Relationship:
                case Syntax.String:
                case Syntax.Uri:
                case Syntax.XmlDocument:
                    op     = 105;
                    sValue = "*";
                    break;

                case Syntax.Single:
                    op     = 111;                                               // FLM_GT_OP
                    sValue = Single.MinValue.ToString();
                    break;
                }
                break;

            case SearchOp.CaseEqual:
                caseSensitive = 1;
                op            = 103;                            // FLM_EQ_OP
                break;
            }

            if (op != 0)
            {
                rc = FWSearch(pStore, query.CollectionId, query.Property, op, sValue, query.Type.ToString(), caseSensitive, out count, out pFlaimResults);
                if (FlaimError.IsSuccess(rc))
                {
                    results = new FlaimResultSet(pFlaimResults, count, flaimServer);
                }
            }

            return(rc);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryArray">Queries used for this search</param>
        /// <param name="results"></param>
        /// <param name="flaimServer"></param>
        /// <returns></returns>
        internal FlaimError.Error MQSearch(Query[] queryArray, out FlaimResultSet results, FlaimServer flaimServer)
        {
            FlaimError.Error rc = FlaimError.Error.FERR_OK;

            results = null;
            int    count         = 0;
            IntPtr pFlaimResults = new IntPtr();

            int[]    op            = new int[queryArray.Length];
            string[] sValue        = new String[queryArray.Length];
            string[] sName         = new String[queryArray.Length];
            string[] sType         = new String[queryArray.Length];
            int      caseSensitive = 0;
            int      arrayIndex    = 0;

            foreach (Query qry in queryArray)
            {
                sValue[arrayIndex] = String.Copy(qry.Value);
                sName[arrayIndex]  = String.Copy(qry.Property);
                sType[arrayIndex]  = String.Copy(qry.Type.ToString());
                switch (qry.Operation)
                {
                case SearchOp.Equal:
                    op[arrayIndex] = 103;                                       // FLM_EQ_OP
                    break;

                case SearchOp.Not_Equal:
                    op[arrayIndex] = 108;                                       // FLM_NE_OP
                    break;

                case SearchOp.Begins:
                    op[arrayIndex] = 105;                                       // FLM_MATCH_BEGIN_OP
                    break;

                case SearchOp.Ends:
                    op[arrayIndex] = 106;                                       // FLM_MATCH_END_OP
                    break;

                case SearchOp.Contains:
                    op[arrayIndex] = 107;                                       // FLM_CONTAINS_OP
                    break;

                case SearchOp.Greater:
                    op[arrayIndex] = 111;                                       // FLM_GT_OP
                    break;

                case SearchOp.Less:
                    op[arrayIndex] = 109;                                       // FLM_LT_OP
                    break;

                case SearchOp.Greater_Equal:
                    op[arrayIndex] = 112;                                       // FLM_GE_OP
                    break;

                case SearchOp.Less_Equal:
                    op[arrayIndex] = 110;                                       // FLM_LE_OP
                    break;

                case SearchOp.Exists:
                    switch (qry.Type)
                    {
                    case Syntax.Boolean:
                        op[arrayIndex]     = 112;
                        sValue[arrayIndex] = "0";
                        break;

                    case Syntax.Byte:
                    case Syntax.Char:
                    case Syntax.DateTime:
                    case Syntax.Int16:
                    case Syntax.Int32:
                    case Syntax.Int64:
                    case Syntax.SByte:
                    case Syntax.TimeSpan:
                    case Syntax.UInt16:
                    case Syntax.UInt32:
                    case Syntax.UInt64:
                        op[arrayIndex]     = 111;                                               // FLM_GT_OP
                        sValue[arrayIndex] = Int64.MinValue.ToString();
                        break;

                    case Syntax.Relationship:
                    case Syntax.String:
                    case Syntax.Uri:
                    case Syntax.XmlDocument:
                        op[arrayIndex]     = 105;
                        sValue[arrayIndex] = "*";
                        break;

                    case Syntax.Single:
                        op[arrayIndex]     = 111;                                               // FLM_GT_OP
                        sValue[arrayIndex] = Single.MinValue.ToString();
                        break;
                    }
                    break;

                case SearchOp.CaseEqual:
                    caseSensitive  = 1;
                    op[arrayIndex] = 103;                                       // FLM_EQ_OP
                    break;
                }

                if (arrayIndex++ >= 3)
                {
                    break;
                }
            }


            if (op[0] != 0)
            {
                if (queryArray.Length == 1)
                {
                    rc = FWMQSearch(pStore, queryArray[0].CollectionId, sName[0], op[0], sValue[0], sType[0], null, 0, null, null, null, 0, null, null, null, 0, null, null, (int)1, caseSensitive, out count, out pFlaimResults);
                }
                else if (queryArray.Length == 2)
                {
                    rc = FWMQSearch(pStore, queryArray[0].CollectionId, sName[0], op[0], sValue[0], sType[0], sName[1], op[1], sValue[1], sType[1], null, 0, null, null, null, 0, null, null, (int)2, caseSensitive, out count, out pFlaimResults);
                }
                else if (queryArray.Length == 3)
                {
                    rc = FWMQSearch(pStore, queryArray[0].CollectionId, sName[0], op[0], sValue[0], sType[0], sName[1], op[1], sValue[1], sType[1], sName[2], op[2], sValue[2], sType[2], null, 0, null, null, (int)3, caseSensitive, out count, out pFlaimResults);
                }
                else if (queryArray.Length == 4)
                {
                    rc = FWMQSearch(pStore, queryArray[0].CollectionId, sName[0], op[0], sValue[0], sType[0], sName[1], op[1], sValue[1], sType[1], sName[2], op[2], sValue[2], sType[2], sName[3], op[3], sValue[3], sType[3], (int)4, caseSensitive, out count, out pFlaimResults);
                }
                if (FlaimError.IsSuccess(rc))
                {
                    results = new FlaimResultSet(pFlaimResults, count, flaimServer);
                }
            }

            return(rc);
        }
Esempio n. 5
0
 /// <summary>
 /// Constructs a flaim provider.
 /// </summary>
 /// <param name="conf">The config object for this provider.</param>
 public FlaimProvider(ProviderConfig conf)
 {
     Flaim = FlaimServer.GetServer(conf);
 }