internal bool OpenDatabase() { try { SystemPlusClientData tmpDB; if (DatabaseExists()) { Builder.Output(ClassName + ": Archivo de datos de configuracion existente. Se abre.", System.Diagnostics.TraceEventType.Verbose); tmpDB = DeSerializarDeDisco(DatabaseName); } else { Builder.Output(ClassName + ": No existe archivo de datos de configuracion. Se crea nuevo.", System.Diagnostics.TraceEventType.Verbose); tmpDB = new SystemPlusClientData(); SerializarADisco(tmpDB, DatabaseName); } _dbRoot = tmpDB; return(true); } catch (Exception ex) { // guardar msg de error _dbRoot = null; ErrorMsg = ex.Message; return(false); } }
private void SerializarADisco(SystemPlusClientData obj, string file) { if (obj != null) { Serializer.Serialize <SystemPlusClientData>(obj, file); } else { Builder.Output("Intentando serializar referencia nula.", System.Diagnostics.TraceEventType.Warning); } }
public void DefaultConstructorTest() { SystemPlusClientData spc = new SystemPlusClientData(); Assert.IsNotNull(spc.ClientManager); Assert.IsNotNull(spc.SystemConfig); Assert.AreEqual(Constants.UdpServerPort, spc.SystemConfig.UdpServerPort); Assert.AreEqual(Constants.ZyanServerName, spc.SystemConfig.ZyanServerName); Assert.AreEqual(Constants.ZyanServerPort, spc.SystemConfig.ZyanServerPort); }
//Solicitud de importar configuracion completa internal bool ImportConfig(string filename) { Builder.Output("Importar file: " + filename); try { SystemPlusClientData tmpDB = DeSerializarDeDisco(filename); _dbRoot = tmpDB; return(true); } catch (Exception ex) { ErrorMsg = ex.Message; return(false); } }
internal void OpenDatabase() { SystemPlusClientData tmpDB; if (File.Exists(DatabaseName)) { Console.WriteLine("Db Existente"); tmpDB = Serializer.Deserialize <SystemPlusClientData>(DatabaseName); // implementar uso stream memoria } else { Console.WriteLine("Db Nueva creacion"); tmpDB = new SystemPlusClientData(); Serializer.Serialize <SystemPlusClientData>(tmpDB, DatabaseName); } _dbRoot = tmpDB; }
internal void ExportData(string file) { StartDbHandler(); Dictionary <string, ClientData> clDict = _dbHandler.ClientConfigDict; SystemConfigData sysConfig = _dbHandler.SystemConfig; SystemPlusClientData localData = new SystemPlusClientData(clDict, sysConfig); SystemPlusClientToSerialize toSer = SystemPlusClientToSerialize.ToSerial(localData); XmlSerializer xmlSer = new XmlSerializer(typeof(SystemPlusClientToSerialize)); StreamWriter myWriter = new StreamWriter(file); xmlSer.Serialize(myWriter, toSer); myWriter.Close(); StopDbHandler(); }
internal void ImportData(string file) { XmlSerializer xmlSer = new XmlSerializer(typeof(SystemPlusClientToSerialize)); Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read); SystemPlusClientToSerialize myObject = (SystemPlusClientToSerialize)xmlSer.Deserialize(stream); stream.Close(); SystemPlusClientData obj = SystemPlusClientToSerialize.FromSerial(myObject); StartDbHandler(); _dbHandler.CreateNewDb(); _dbHandler.ClientConfigDict = obj.ClientList; _dbHandler.SystemConfig = obj.SystemConfig; _dbHandler.SaveAllData(); StopDbHandler(); }
private void StopComponent() { CloseDatabase(); _dbRoot = null; }
internal void CreateTestConfig() { ClientDataManager cdm = new ClientDataManager(); /* * Cliente con clave Id, puerto automatico * * client.Name = "WinClt01"; * client.Id = "WC0001"; * client.AppFilePath = "c:\\Tmp\\ClientUdp\\wcudp1.exe"; * client.LogFilePath = "c:\\Tmp\\ClientUdp\\wcudp1.txt"; * client.MailEnabled = true; * client.Timeout = 55; * client.Port = 0; * client.QueueSize = 12; */ cdm.CreateClient(ClientIdType.KeyByIdString, "WC0001", 0, "WinClt01", "c:\\Tmp\\ClientUdp\\wcudp1.exe", "c:\\Tmp\\ClientUdp\\wcudp1.txt", 55, true, false, 12); /* * Cliente con clave Port, puerto 50100 * * client = new ClientData(); * client.Name = "WinClt02"; * client.Id = "WC0002"; * client.AppFilePath = "c:\\Tmp\\ClientUdp\\wcudp2.exe"; * client.LogFilePath = "c:\\Tmp\\ClientUdp\\wcudp2.txt"; * client.MailEnabled = true; * client.LogAttachEnabled = false; * client.Timeout = 65; * client.Port = 50100; * client.QueueSize = 24; */ cdm.CreateClient(ClientIdType.KeyByUdpPort, null, 50100, "WinClt02", "c:\\Tmp\\ClientUdp\\wcudp2.exe", "c:\\Tmp\\ClientUdp\\wcudp2.txt", 65, true, false, 24); //// ... and again //client = new ClientData(); //client.Name = "CConsole1"; //client.Id = HeartBeat.DefaultClientID; //client.AppFilePath = "c:\\Tmp\\ClientUdp\\cudp.cmd"; //client.LogFilePath = "c:\\Tmp\\ClientUdp\\cudp.txt"; //client.MailEnabled = false; //client.LogAttachEnabled = false; //client.Timeout = 70; //client.Port = 50200; //client.QueueSize = 48; cdm.CreateClient(ClientIdType.KeyByUdpPort, null, 50200, "CConsole1", "c:\\Tmp\\ClientUdp\\cudp.cmd", "c:\\Tmp\\ClientUdp\\cudp.txt", 70, false, false, 48); // config system SystemConfigData tmpSys = new SystemConfigData(); tmpSys.ServerIpAdr = "127.0.0.1"; tmpSys.UdpServerPort = 8888; tmpSys.ZyanServerName = Constants.ZyanServerName; tmpSys.ZyanServerPort = Constants.ZyanServerPort; tmpSys.SMtpServer = "localhost"; tmpSys.Source = "*****@*****.**"; tmpSys.Password = "******"; tmpSys.Destination = "[email protected], [email protected]"; tmpSys.TimeoutStartRestart = 180; tmpSys.RestartAttemps = 2; SystemPlusClientData tmpDb = new SystemPlusClientData(cdm, tmpSys); _dbRoot = tmpDb; CommitDatabase(); }