コード例 #1
0
ファイル: SqlServerDeleteQuery.cs プロジェクト: built/BoxBoy
        protected override void build(Item item, int limit)
        {
            string       val       = item.getStreamName();
            string       str2      = item.getIdField();
            StringTheory condition = new StringTheory();

            base.BuildCondition(condition, item);
            if (limit > -1)
            {
                StringTheory theory2 = new StringTheory("SELECT TOP %limit% %id_field% FROM %table%");
                theory2.Replace("%limit%", limit);
                theory2.Replace("%id_field%", item.getIdField());
                theory2.Replace("%table%", val);
                if ((condition != null) && (condition.Length > 0))
                {
                    theory2.Append(" WHERE ");
                    theory2.Append(condition);
                }
                base.Append("DELETE FROM ");
                base.Append(val);
                base.Append(" WHERE ");
                base.Append(string.Concat(new object[] { item.getIdField(), " IN (", theory2, ")" }));
            }
            else
            {
                base.Append("DELETE FROM ");
                base.Append(val);
                if ((condition != null) && (condition.Length > 0))
                {
                    base.Append(" WHERE ");
                    base.Append(condition);
                }
            }
        }
コード例 #2
0
ファイル: MySqlSelectQuery.cs プロジェクト: built/BoxBoy
 protected override void LimitRecordsReturned(StringTheory query, int limit)
 {
     if (limit > -1)
     {
         query.Append(" LIMIT ");
         query.Append(limit.ToString());
         query.Append(" ");
     }
 }
コード例 #3
0
ファイル: OracleSelectQuery.cs プロジェクト: built/BoxBoy
 protected override void LimitRecordsReturned(StringTheory query, int limit)
 {
     if (limit > -1)
     {
         query.Prepend("SELECT * FROM (");
         query.Append(") WHERE rownum < ");
         query.Append((limit + 1).ToString());
         query.Append(" ");
     }
 }
コード例 #4
0
ファイル: SqlBox.cs プロジェクト: built/BoxBoy
        public bool createStream(Item item)
        {
            SqlBoxQuery query = new SqlBoxQuery();

            if (item.UsesAutoId)
            {
                query.Append("CREATE TABLE %table%(%pk% int IDENTITY(1,1) PRIMARY KEY CLUSTERED%fields%)");
            }
            else
            {
                query.Append("CREATE TABLE %table%(%pk% int PRIMARY KEY CLUSTERED%fields%)");
            }
            string       val    = ", %name% varchar(255) DEFAULT NULL";
            string       strA   = item.getIdField();
            StringTheory theory = new StringTheory();

            foreach (string str3 in item.getBoxView().Keys)
            {
                if (string.Compare(strA, str3, true) != 0)
                {
                    theory.Append(val);
                    theory.Replace("%name%", str3);
                }
            }
            query.Replace("%table%", item.getStreamName());
            query.Replace("%pk%", strA);
            query.Replace("%fields%", theory);
            Console.WriteLine(query);
            this.SqlDatabase.process(query);
            return(this.streamExists(item));
        }
コード例 #5
0
 public void testAppend()
 {
     string str = "xyzabc";
     StringTheory theory = new StringTheory("xyz");
     theory.Append("abc");
     Assert.True(str.Equals(theory.ToString()), "simple string append failed:" + theory.ToString());
     str = "xyzabc";
     theory = new StringTheory("xyz");
     StringTheory val = new StringTheory("abc");
     theory.Append(val);
     Assert.True(str.Equals(theory.ToString()), "string theory append failed");
     str = "xyzFooFooFoo";
     theory = new StringTheory("xyz");
     string[] strArray = new string[] { "Foo", "Foo", "Foo" };
     theory.Append((object[])strArray);
     Assert.True(str.Equals(theory.ToString()), "string theory append(array) failed");
     str = "xyzFooFooFoo";
     theory = new StringTheory("xyz");
     ArrayList list = new ArrayList();
     list.Add("Foo");
     list.Add("Foo");
     list.Add("Foo");
     theory.Append((ICollection)list);
     Assert.True(str.Equals(theory.ToString()), "string theory append(ArrayList) failed" + theory.ToString());
 }
コード例 #6
0
        public XmlDocument Describe()
        {
            XmlDocument  document = new XmlDocument();
            StringTheory theory   = new StringTheory("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            ArrayList    list     = new ArrayList();

            theory.Append("<streams>\n");
            this.ListStreams(list);
            foreach (Hashtable hashtable in list)
            {
                theory.Append(this.DescribeStream(hashtable["TABLE_NAME"].ToString()));
            }
            theory.Append("</streams>\n");
            document.LoadXml(theory.ToString());
            return(document);
        }
コード例 #7
0
ファイル: SqlBoxSelectQuery.cs プロジェクト: built/BoxBoy
        protected void AppendSortSpecification(StringTheory spec, Item entity)
        {
            ArrayList coll = entity.getSortList();

            if (coll.Count > 0)
            {
                spec.Append(" ORDER BY ");
                spec.Join(coll, ", ");
            }
        }
コード例 #8
0
ファイル: Item.cs プロジェクト: built/BoxBoy
        public string getXml()
        {
            StringTheory theory  = new StringTheory("<%islandName%>%body%</%islandName%>\n");
            StringTheory val     = new StringTheory();
            StringTheory theory3 = new StringTheory();

            foreach (string str in this.getFieldNames())
            {
                val.Renew("    <%fieldName%>%fieldValue%</%fieldName%>\n");
                val.Replace("%fieldName%", str.ToLower());
                val.Replace("%fieldValue%", ((Field)this[str]).getValue());
                theory3.Append(val);
            }
            theory.Replace("%islandName%", this.StreamName.ToLower());
            theory.Replace("%body%", theory3);
            return(theory.ToString());
        }
コード例 #9
0
        public string DescribeStream(string stream)
        {
            StringTheory theory  = new StringTheory("<stream name=\"%stream%\">\n%fields%</stream>\n");
            StringTheory theory2 = new StringTheory();
            ArrayList    list    = new ArrayList();

            this.ListColumns(stream, list);
            theory.Replace("%stream%", stream);
            foreach (Hashtable hashtable in list)
            {
                theory2.Append("<field name=\"%COLUMN_NAME%\" type=\"%DATA_TYPE%\" identity=\"%IDENTITY%\"/>\n");
                theory2.Populate(hashtable, "%*%");
                theory2.Replace("%IDENTITY%", this.IsIdentity(hashtable));
            }
            theory.Replace("%fields%", theory2);
            return(theory.ToString());
        }
コード例 #10
0
ファイル: SqlBoxQuery.cs プロジェクト: built/BoxBoy
        // Methods
        protected void BuildCondition(StringTheory condition, Item entity)
        {
            Hashtable hashtable = entity.getBoxView();
            Field     field     = null;

            foreach (string str in hashtable.Keys)
            {
                field = (Field)hashtable[str];
                if (field.Touched())
                {
                    if (condition.Length > 0)
                    {
                        condition.Append(" AND ");
                    }
                    if (field.Length < 1)
                    {
                        condition.Append(" ( len(" + str + ") < 1 or " + str + " IS NULL ) ");
                    }
                    else
                    {
                        condition.Append(str);
                        condition.Append("=");
                        condition.Append(field.toSql());
                    }
                }
                if (field.hasAttributes())
                {
                    string[] strArray = field.getAttributes();
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        if (condition.Length > 0)
                        {
                            condition.Append(" AND ");
                        }
                        condition.Append(str);
                        condition.Append(strArray[i]);
                    }
                }
            }
        }
コード例 #11
0
 public void testTouched()
 {
     StringTheory theory = new StringTheory("mares eat oats");
     theory.Append(theory.Cut(5, 4));
     Assert.True(theory.Touched(), "str doesn't think it was touched.");
     theory = new StringTheory("mares eat oats");
     theory.Upper(7);
     Assert.True(theory.Touched(), "str doesn't think it was touched. 2");
 }