public MailConnect() { try { string strPath = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); INIManager manager = new INIManager(strPath + @"\settings.ini"); imap = manager.GetPrivateString("MailSettings", "imap"); port = int.Parse(manager.GetPrivateString("MailSettings", "port")); mail = manager.GetPrivateString("MailSettings", "mail"); password = manager.GetPrivateString("MailSettings", "password"); } catch (Exception ex) { Logger.Log.Error(ex.ToString()); } }
public DBConnect() { try { string strPath = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); INIManager manager = new INIManager(strPath + @"\settings.ini"); host = manager.GetPrivateString("DatabaseConnect", "host"); db = manager.GetPrivateString("DatabaseConnect", "database"); user = manager.GetPrivateString("DatabaseConnect", "user"); password = manager.GetPrivateString("DatabaseConnect", "password"); } catch (Exception ex) { Logger.Log.Error(ex.ToString()); } }
private void SendPrivateMessage(string message_, string to_) { try { string strPath = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); INIManager manager = new INIManager(strPath + @"\settings.ini"); PrivateMessage PM = new PrivateMessage(); PM.UserTo = to_; PM.UserFrom = "0"; PM.Msg = message_; PM.hash = ""; PM.APIStype = "c#"; PM.ServerKey = "iddqd"; string json_send_message = JsonConvert.SerializeObject(PM); TcpClient client = new TcpClient(); client.Connect(manager.GetPrivateString("MyChatSettings", "host"), int.Parse(manager.GetPrivateString("MyChatSettings", "port"))); StreamWriter sw = new StreamWriter(client.GetStream(), Encoding.GetEncoding(1251)); sw.AutoFlush = true; string message = "mc5.20" + PM.CRLF; sw.WriteLine(message); StreamReader sr = new StreamReader(client.GetStream(), Encoding.GetEncoding(1251)); sr.ReadLine(); sw.WriteLine(PM.MagicPacket + PM.cs_integration_api + PM.iFlag + PM.MCIAPI_CS_SendPrivateMessage + json_send_message + PM.CRLF); client.Close(); } catch (Exception ex) { Logger.Log.Error(ex.ToString()); } }