예제 #1
0
 internal static string GetQuery(QueryIndex qi, params object[] args)
 {
     string query = Queries.ToString(qi);
     if (args.Length <= 0) return query;
     query = string.Format(query, args);
     return query;
 }
예제 #2
0
        public static string ToString(QueryIndex queryIndex)
        {
            switch (queryIndex)
            {
            case QueryIndex.Login1:
                return("SELECT COUNT(*) FROM `login` WHERE `Username` = '{0}' AND `Password2` = '{1}';");

            case QueryIndex.Login2:
                return("SELECT * FROM `login` WHERE `Username` = '{0}' AND `Password2` = '{1}';");

            case QueryIndex.Devotion1:
                return("SELECT * FROM `devotion` ORDER BY `ID` DESC;");

            case QueryIndex.Logs1:
                return("SELECT * FROM coboam.log ORDER BY `ID` DESC");

            case QueryIndex.Logs2:
                return("SELECT * FROM `log` WHERE `Type`='{0}' ORDER BY `ID` DESC");

            case QueryIndex.Logs3:
                return("INSERT INTO `log`(`Type`,`Date`,`IP`,`Msg`) VALUES('{0}','{1}','{2}','{3}');");

            case QueryIndex.Devotion2:
                return("INSERT INTO `devotion` (`Month`,`Year`,`Quote`,`Scripture`,`Text`) VALUES('{0}','{1}','{2}','{3}','{4}');");

            case QueryIndex.Devotion3:
                return("UPDATE `devotion` SET `Quote`='{1}', `Scripture`='{2}', `Text`='{3}', `Month`='{4}', `Year`='{5}' WHERE `ID` = '{0}'");

            case QueryIndex.Devotion4:
                return("DELETE FROM `devotion` WHERE `Month`='{0}' AND `Year`='{1}'");

            case QueryIndex.Greetings1:
                return("SELECT * FROM `greetings` ORDER BY `ID` ASC");

            case QueryIndex.Greetings2:
                return("UPDATE `greetings` SET `Current`= 0");

            case QueryIndex.Greetings3:
                return("INSERT INTO `greetings` (Current, Title, Part1, Part2) VALUES('{0}','{1}','{2}','{3}')");

            case QueryIndex.Greetings4:
                return("UPDATE `greetings` SET `Current`='{0}',`Title`='{1}', `Part1`='{2}', `Part2`='{3}' WHERE `ID`='{4}'");

            case QueryIndex.Greetings5:
                return("DELETE FROM `greetings` WHERE `ID`='{0}'");

            case QueryIndex.Announcement1:
                return("SELECT * FROM `announcement` ORDER BY `ID` ASC");

            case QueryIndex.Announcement2:
                return("INSERT INTO `announcement` (Title, Text, StartDate, ExpDate) VALUES('{0}','{1}','{2}','{3}')");

            case QueryIndex.Announcement3:
                return("UPDATE `announcement` SET `Title`='{0}', `Text`='{1}', `StartDate`='{2}', `ExpDate`='{3}' WHERE `ID`='{4}'");

            case QueryIndex.Announcement4:
                return("DELETE FROM `announcement` WHERE `ID`='{0}'");
            }
            return("");
        }
예제 #3
0
        /// <summary>
        /// Asserts that two configurations have the same properties.
        /// </summary>
        private static void AssertConfigsAreEqual(QueryIndex x, QueryIndex y)
        {
            Assert.IsNotNull(x);
            Assert.IsNotNull(y);

            Assert.AreEqual(x.Name, y.Name);
            Assert.AreEqual(x.IndexType, y.IndexType);

            AssertConfigsAreEqual(x.Fields, y.Fields);
        }
예제 #4
0
        internal static string GetQuery(QueryIndex qi, params object[] args)
        {
            string query = Queries.ToString(qi);

            if (args.Length <= 0)
            {
                return(query);
            }
            query = string.Format(query, args);
            return(query);
        }
예제 #5
0
 public static string ToString(QueryIndex queryIndex)
 {
     switch (queryIndex)
     {
         case QueryIndex.Login1:
             return "SELECT COUNT(*) FROM `login` WHERE `Username` = '{0}' AND `Password2` = '{1}';";
         case QueryIndex.Login2:
             return "SELECT * FROM `login` WHERE `Username` = '{0}' AND `Password2` = '{1}';";
         case QueryIndex.Devotion1:
             return "SELECT * FROM `devotion` ORDER BY `ID` DESC;";
         case QueryIndex.Logs1:
             return "SELECT * FROM coboam.log ORDER BY `ID` DESC";
         case QueryIndex.Logs2:
             return "SELECT * FROM `log` WHERE `Type`='{0}' ORDER BY `ID` DESC";
         case QueryIndex.Logs3:
             return "INSERT INTO `log`(`Type`,`Date`,`IP`,`Msg`) VALUES('{0}','{1}','{2}','{3}');";
         case QueryIndex.Devotion2:
             return "INSERT INTO `devotion` (`Month`,`Year`,`Quote`,`Scripture`,`Text`) VALUES('{0}','{1}','{2}','{3}','{4}');";
         case QueryIndex.Devotion3:
             return "UPDATE `devotion` SET `Quote`='{1}', `Scripture`='{2}', `Text`='{3}', `Month`='{4}', `Year`='{5}' WHERE `ID` = '{0}'";
         case QueryIndex.Devotion4:
             return "DELETE FROM `devotion` WHERE `Month`='{0}' AND `Year`='{1}'";
         case QueryIndex.Greetings1:
             return "SELECT * FROM `greetings` ORDER BY `ID` ASC";
         case QueryIndex.Greetings2:
             return "UPDATE `greetings` SET `Current`= 0";
         case QueryIndex.Greetings3:
             return "INSERT INTO `greetings` (Current, Title, Part1, Part2) VALUES('{0}','{1}','{2}','{3}')";
         case QueryIndex.Greetings4:
             return "UPDATE `greetings` SET `Current`='{0}',`Title`='{1}', `Part1`='{2}', `Part2`='{3}' WHERE `ID`='{4}'";
         case QueryIndex.Greetings5:
             return "DELETE FROM `greetings` WHERE `ID`='{0}'";
         case QueryIndex.Announcement1:
             return "SELECT * FROM `announcement` ORDER BY `ID` ASC";
         case QueryIndex.Announcement2:
             return "INSERT INTO `announcement` (Title, Text, StartDate, ExpDate) VALUES('{0}','{1}','{2}','{3}')";
         case QueryIndex.Announcement3:
             return "UPDATE `announcement` SET `Title`='{0}', `Text`='{1}', `StartDate`='{2}', `ExpDate`='{3}' WHERE `ID`='{4}'";
         case QueryIndex.Announcement4:
             return "DELETE FROM `announcement` WHERE `ID`='{0}'";
     }
     return "";
 }
        public void GenerateQueryIndex()
        {
            if (!ValidateParameters())
            {
                return;
            }

            System.Reflection.Assembly           asm          = null;
            Alachisoft.NCache.Config.Dom.Class[] queryClasses = null;
            string failedNodes = string.Empty;
            string serverName  = string.Empty;

            try
            {
                string extension = ".dll";
                try
                {
                    asm       = System.Reflection.Assembly.LoadFrom(AssemblyPath);
                    extension = Path.GetExtension(asm.FullName);
                }
                catch (Exception e)
                {
                    string message = string.Format("Could not load assembly \"" + AssemblyPath + "\". {0}", e.Message);
                    OutputProvider.WriteErrorLine("Error : {0}", message);
                    _successful = false;
                    return;
                }

                if (asm == null)
                {
                    throw new Exception("Could not load specified Assembly");
                }

                System.Type type = asm.GetType(Class, true);

                QueryIndex queryIndices = new QueryIndex();
                queryIndices.Classes = GetSourceClass(GetClass(queryClasses, asm));

                ConfigurationBuilder cfg   = new ConfigurationBuilder();
                string configurationString = cfg.GetSectionXml(queryIndices, "query-indexes", 1);

                if (OutputFile == null || OutputFile.Equals(string.Empty))
                {
                    if (_successful)
                    {
                        OutputProvider.WriteLine(configurationString);
                    }
                }
                else
                {
                    WriteXmlToFile(configurationString);
                    if (_successful)
                    {
                        OutputProvider.WriteLine("Query Indexes generated for Class '{0}' at {1}", Class, OutputFile);
                    }
                }
            }
            catch (Exception e)
            {
                OutputProvider.WriteErrorLine("Error : {0}", e.Message);
                _successful = false;
            }
            finally
            {
                OutputProvider.WriteLine(Environment.NewLine);
            }
        }
예제 #7
0
파일: Query.cs 프로젝트: carbon/Data
 public Query(string indexName, params Expression[] expressions)
 {
     Index = new QueryIndex(indexName);
     Expressions = expressions;
 }