public bool build(Item item) { Hashtable hashtable = item.getBoxView(); Field field = (Field)hashtable[item.getIdField()]; if (!field.IsEmpty()) { Field field2 = null; ArrayList coll = new ArrayList(); foreach (string str in hashtable.Keys) { field2 = (Field)hashtable[str]; if (!str.Equals(item.getIdField()) && field2.Touched()) { coll.Add(str + "=" + field2.toSql()); } } if (coll.Count > 0) { StringTheory theory = new StringTheory(); theory.Join(coll, ", "); StringTheory val = new StringTheory("UPDATE %tableName% SET %pairListing% WHERE %idField% = %id%"); val.Replace("%tableName%", item.getStreamName()); val.Replace("%pairListing%", theory); val.Replace("%idField%", item.getIdField()); val.Replace("%id%", field.toSql()); base.Append(val); } } return(false); }
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); } } }
public bool build(Item item) { StringTheory theory = new StringTheory(); StringTheory theory2 = new StringTheory(); Field field = null; Hashtable hashtable = item.getBoxView(); ArrayList coll = new ArrayList(); ArrayList list2 = new ArrayList(); foreach (string str in hashtable.Keys) { field = (Field)hashtable[str]; if ((field != null) && field.Touched()) { coll.Add(str); list2.Add(field.toSql()); } } theory.Join(coll, ", "); theory2.Join(list2, ", "); if (coll.Count > 0) { StringTheory val = new StringTheory("INSERT INTO %tableName% (%fields%) VALUES (%values%)"); val.Replace("%tableName%", item.getStreamName()); val.Replace("%fields%", theory); val.Replace("%values%", theory2); base.Append(val); } return(false); }
public void build(Item item) { StringTheory val = new StringTheory("SELECT TOP 1 %idField% FROM %tableName% WHERE %idField% = '%id%'"); val.Replace("%idField%", item.getIdField()); val.Replace("%tableName%", item.getStreamName()); val.Replace("%id%", item.Id); base.Append(val); }
protected void AppendSelectQuery(string tableName, StringTheory conditions, StringTheory specifiers, int limit) { StringTheory val = new StringTheory("SELECT * FROM %tableName% WHERE %conditions% %specifiers%"); if (conditions.IsEmpty()) { val.Replace("WHERE ", ""); } val.Replace("%tableName%", tableName); val.Replace("%conditions%", conditions); val.Replace("%specifiers%", specifiers); base.Append(val); this.LimitRecordsReturned(this, limit); }
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)); }
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()); }
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()); }
public string toSql() { StringTheory theory = new StringTheory(this); string phrase = "'"; theory.Replace(phrase, phrase + phrase); theory.SingleQuote(); return(theory.ToString()); }
public void testReplace() { StringTheory theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); StringTheory theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); int num = theory2.Replace("$", " "); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace('$', ' '); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace('$', " "); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace("$", ' '); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); theory = new StringTheory("Lorem_$_ipsum._$_Ve_$_misdebus._$_U_$_misdebus._$_I_$_misdebus."); theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); num = theory2.Replace("$", "_$_"); Assert.True(theory2.Equals(theory), "(x)Chars didn't translate properly."); }
public void testTransWithACharacter() { StringTheory theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus."); StringTheory theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus."); int num = theory2.Replace('$', ' '); Assert.True(num == 7, "Reported number of tilted slashes was wrong."); Assert.True(theory2.Equals(theory), "Chars didn't translate properly."); }