public static void storeValue(string hostnames, SerializableArrayList toStore) { var bf = new BinaryFormatter(); var ms = new MemoryStream(); bf.Serialize(ms, toStore); var buf = ms.GetBuffer(); DAL.singleton().proc_HMB_UPDATE_BINARYSTORE(buf, hostnames); }
/// <summary> /// Forgets the specified word. /// </summary> /// <param name="word">The word.</param> /// <returns></returns> public static bool forget(string word) { DAL.Select q = new DAL.Select("COUNT(*)"); q.setFrom("keywords"); q.addWhere(new DAL.WhereConds("keyword_name", word)); if (DAL.singleton().executeScalarSelect(q) == "0") { return(false); } DAL.singleton().delete("keywords", 0, new DAL.WhereConds("keyword_name", word)); return(true); }
/// <summary> /// Learns the specified word. /// </summary> /// <param name="word">The word.</param> /// <param name="phrase">The phrase.</param> /// <param name="action">if set to <c>true</c> [action].</param> /// <returns></returns> public static bool learn(string word, string phrase, bool action) { DAL.Select q = new DAL.Select("COUNT(*)"); q.setFrom("keywords"); q.addLimit(1, 0); q.addWhere(new DAL.WhereConds("keyword_name", word)); if (DAL.singleton().executeScalarSelect(q) != "0") { return(false); } DAL.singleton().insert("keywords", "", word, phrase, (action ? "1" : "0 ")); return(true); }
public static SerializableArrayList retrieve(string blobName) { var q = new DAL.Select("bin_blob"); q.setFrom("binary_store"); q.addWhere(new DAL.WhereConds("bin_desc", blobName)); var result = DAL.singleton().executeSelect(q); var serializationStream = new MemoryStream(((byte[])(((object[])(result[0]))[0]))); if (serializationStream.Length != 0) { return((SerializableArrayList) new BinaryFormatter().Deserialize(serializationStream)); } return(new SerializableArrayList()); }
/// <summary> /// Gets the real link. /// </summary> /// <param name="destination">The destination.</param> /// <param name="link">The link.</param> /// <param name="useSecureServer">if set to <c>true</c> [use secure server].</param> /// <returns></returns> public static string getRealLink(string destination, string link, bool useSecureServer) { string iwprefix = link.Split(':')[0]; string url = DAL.singleton().proc_HMB_GET_IW_URL(iwprefix); if (link.Split(':').Length == 1 || url == string.Empty) { url = Configuration.singleton( )[ (useSecureServer ? "wikiSecureUrl" : "wikiUrl"), destination]; return(url + antispace(link)); } return(url.Replace("$1", antispace(string.Join(":", link.Split(':'), 1, link.Split(':').Length - 1)))); }
private static void initialiseBot(string configFile) { string username; string password; string schema; uint port = 0; string server = username = password = schema = ""; Configuration.readHmbotConfigFile(configFile, ref server, ref username, ref password, ref port, ref schema); _dbal = DAL.singleton(server, port, username, password, schema); if (!_dbal.connect()) { // can't connect to database, DIE return; } Configuration.singleton(); debugChannel = Configuration.singleton()["channelDebug"]; _ircNetwork = uint.Parse(Configuration.singleton()["ircNetwork"]); _trigger = Configuration.singleton()["commandTrigger"]; irc = new IAL(_ircNetwork); new IrcProxy(irc, int.Parse(Configuration.singleton()["proxyPort"]), Configuration.singleton()["proxyPassword"]); setupEvents(); if (!irc.connect()) { // if can't connect to irc, die return; } new MonitorService(62167, "Helpmebot v6 (Nagios Monitor service)"); // ACC notification monitor AccNotifications.getInstance(); }
/// <summary> /// Remembers the specified word. /// </summary> /// <param name="word">The word.</param> /// <returns></returns> public static RemeberedWord remember(string word) { DAL.Select q = new DAL.Select("keyword_action"); q.setFrom("keywords"); q.addWhere(new DAL.WhereConds("keyword_name", word)); string action = DAL.singleton().executeScalarSelect(q); q = new DAL.Select("keyword_response"); q.setFrom("keywords"); q.addWhere(new DAL.WhereConds("keyword_name", word)); string result = DAL.singleton().executeScalarSelect(q); RemeberedWord rW = new RemeberedWord { action = (action == "1" ? true : false), phrase = result }; return(rW); }
public IAL(uint ircNetwork) { this.floodProtectionWaitTime = 500; this.clientVersion = "Helpmebot IRC Access Layer 1.0"; _networkId = ircNetwork; DAL db = DAL.singleton(); DAL.Select q = new DAL.Select("in_host", "in_port", "in_nickname", "in_password", "in_username", "in_realname", "in_log", "in_nickserv"); q.setFrom("ircnetwork"); q.addLimit(1, 0); q.addWhere(new DAL.WhereConds("in_id", ircNetwork.ToString())); ArrayList configSettings = db.executeSelect(q); _ircServer = (string)(((object[])configSettings[0])[0]); _ircPort = (uint)((object[])configSettings[0])[1]; _myNickname = (string)(((object[])configSettings[0])[2]); _myPassword = (string)(((object[])configSettings[0])[3]); _myUsername = (string)(((object[])configSettings[0])[4]); _myRealname = (string)(((object[])configSettings[0])[5]); this.logEvents = (bool)(((object[])configSettings[0])[6]); _nickserv = (string)(((object[])configSettings[0])[7]); if (/*recieveWallops*/ true) { this.connectionUserModes += 4; } if (/*invisible*/ true) { this.connectionUserModes += 8; } initialiseEventHandlers(); }
/// <summary> /// Shortens the specified long URL. /// </summary> /// <param name="longUrl">The long URL.</param> /// <returns></returns> public static Uri shorten(Uri longUrl) { DAL.Select q = new DAL.Select("suc_shorturl"); q.setFrom("shorturlcache"); q.addWhere(new DAL.WhereConds("suc_fullurl", longUrl.ToString())); string cachelookup = DAL.singleton().executeScalarSelect(q); if (cachelookup == "") { try { string shorturl = getShortUrl(longUrl); DAL.singleton().insert("shorturlcache", "", longUrl.ToString(), shorturl); return(new Uri(shorturl)); } catch (WebException ex) { GlobalFunctions.errorLog(ex); return(longUrl); } } return(new Uri(cachelookup)); }
public User() { this._db = DAL.singleton(); }
/// <summary> /// Saves the specified log entry. /// </summary> /// <param name="logEntry">The log entry.</param> public bool save(AccessLogEntry logEntry) { return(DAL.singleton().insert("accesslog", "", logEntry.alUser.ToString(), logEntry.alUser.accessLevel.ToString(), logEntry.alReqaccesslevel.ToString(), "", logEntry.alClass.ToString(), (logEntry.alAllowed ? "1" : "0"), logEntry.alChannel, logEntry.alParams) != -1); }
public static AccessLogEntry[] get(params DAL.WhereConds[] conditions) { DAL.Select q = new DAL.Select("*"); q.addWhere(conditions); q.setFrom("accesslog"); List <string> columns; ArrayList al = DAL.singleton().executeSelect(q, out columns); AccessLogEntry[] entries = new AccessLogEntry[al.Count]; for (int j = 0; j < al.Count; j++) { string[] row = (string[])al[j]; AccessLogEntry entry = new AccessLogEntry(); string usermask = string.Empty; User.UserRights useraccess = User.UserRights.Normal; #region parse for (int i = 0; i < row.Length; i++) { switch (columns[i]) { case ACCESSLOG_ID: entry._alId = int.Parse(row[i]); break; case ACCESSLOG_USER: usermask = row[i]; break; case ACCESSLOG_USER_ACCESS: useraccess = (User.UserRights)Enum.Parse(typeof(User.UserRights), row[i]); break; case ACCESSLOG_COMMAND_ACCESS: entry._alReqaccesslevel = (User.UserRights)Enum.Parse(typeof(User.UserRights), row[i]); break; case ACCESSLOG_DATE: entry._alDate = DateTime.Parse(row[i]); break; case ACCESSLOG_COMMAND_CLASS: entry._alClass = Type.GetType(row[i]); break; case ACCESSLOG_ALLOWED: entry._alAllowed = row[i] == "0" ? false : true; break; case ACCESSLOG_CHANNEL: entry._channel = row[i]; break; case ACCESSLOG_ARGS: entry._params = row[i]; break; } entry._alUser = User.newFromStringWithAccessLevel(usermask, useraccess); } #endregion entries[j] = entry; } return(entries); }
public Message( ) { _dbal = DAL.singleton( ); }