public async static Task getSystemVersions(cServer ShareServer) { if (XMLSystemState == null) { using (var ftp = new cFTP(ShareServer, "APPS_CS")) { var Item = new DirectoryItem() { Server = ShareServer, IsDirectory = false, Name = "systems.xml", BaseUri = new UriBuilder("ftp://" + ShareServer.IP.ToString() + "/APPS_CS").Uri }; try { await ftp.DownloadItemAsync(Item, LOCAL_PATH + "systems.xml"); } catch (Exception ex) { //debugBox.AppendText(ex.Message); } XMLSystemState = XDocument.Load(LOCAL_PATH + "systems.xml"); } } }
public override async Task <bool> process() { var _xconn = xmlMsgIn.Data.Element("connection"); //get the connection data var _parameters = xmlMsgIn.Data.Element("parameterCollection").Elements("parameter"); //get the parameters list string _dataBase = _xconn.Element("DataBase").Value.ToString(); //get the database string _procedureName = xmlMsgIn.Data.Element("procedureName").Value.ToString(); // get the procedure name var _server = new cServer(_xconn.Element("server")); //create the server object from the connection data try { using (var _conn = new cAccesoDatosNet(_server, _dataBase)) //create the normal connection using (var _sp = new SP(_conn, _procedureName)) // create the normal SP { _parameters.ToList().ForEach(p => { _sp.AddParameterValue(p.Element("parameterName").Value.ToString(), p.Element("parameterValue").Value.ToString()); }); //adds the parameters and the values to the sp from the parameter list await _sp.ExecuteAsync(); //execute the sp if (_sp.LastMsg.Substring(0, 2) != "OK") { throw new Exception(_sp.LastMsg); //error message } XElement _msgOut = new XElement("result"); //create the msgout xml data _msgOut.Add(_sp.XOutParameters.Root); //adds the out parameters to the data xmlMsgOut = new XDocument(_msgOut); // returns } } catch (Exception ex) { xmlMsgOut = new XDocument(new XElement("result", "ERROR: " + ex.Message)); } MsgOut = xmlMsgOut.ToString(); return(true); }
public override async Task <bool> process() { var _xconn = xmlMsgIn.Data.Element("connection"); //get the connection data string _dataBase = _xconn.Element("DataBase").Value.ToString(); //get the database var _server = new cServer(_xconn.Element("server")); //create the server object from the connection data string _sql = xmlMsgIn.Data.Element("sql").Value.ToString(); //get the sql using (var _conn = new cAccesoDatosNet(_server, _dataBase)) //create the normal connection using (var _rs = new DynamicRS(_sql, _conn)) // create the normal recordset { try { await _rs.OpenAsync(); //execute the recordset xmlMsgOut = _rs.XMLData; //create the msgout xml data xmlMsgOut.Root.Name = "result"; } catch (Exception ex) { xmlMsgOut = XDocument.Parse((new XElement("result", "ERROR: " + ex.Message)).ToString()); //returns error } } MsgOut = xmlMsgOut.ToString(); return(true); }
//constructores public cAccesoDatosNet() { AdoCon = new SqlConnection(); //Provider = "SQLOLEDB"; Silent = false; IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); var lIP = ipHostInfo.AddressList.FirstOrDefault(x => x.GetAddressBytes()[0] == 10); if (lIP == null) { lIP = ipHostInfo.AddressList.First(x => x.GetAddressBytes()[0] == 192); } //foreach (IPAddress lIP in ipHostInfo.AddressList) //{ // if (lIP.AddressFamily.ToString() == "InterNetwork" && ((lIP.GetAddressBytes()[0] == 192 && lIP.GetAddressBytes()[1] == 168) || lIP.GetAddressBytes()[0] == 10)) // { //IPV4 // IP = lIP; // break; // } //} IP = lIP; if (oServer == null) { oServer = new cServer() { Type = ServerTypes.DATABASE }; } }
// Constructor (with args) -> Calls the base constructor and sets some properties public cAppBot(string pCode, string pDescription, string pDatabase, string pExeName, string ServiceZone, cServer pDBServer, cServer pShareServer, string pName, bool pSpecial = false, string pVersion = "") : this() { Code = pCode; Description = pDescription; DataBase = pDatabase; ExeName = pExeName; LocalPath = LOCAL_PATH + Code + "/" + ExeName; DBServer = pDBServer; ShareServer = pShareServer; lblDescriptionApp.Text = Description; pctApp.Image = AppIcon; Special = pSpecial; Name = pName; version = pVersion; lblVersionApp.Text = pVersion; // Set Initial Status. SetStatus(AppBotStatus.INIT); }
public override async Task <bool> process() { XElement _xServer = xmlMsgIn.Data.Element("server"); var _server = new cServer(); _server.xServer = _xServer; var _conn = new cAccesoDatosNet(_server, xmlMsgIn.Data.Element("DataBase").Value); try { await _conn.ConnectAsync(); xmlMsgOut = new XDocument(new XElement("result", "OK")); } catch (Exception ex) { xmlMsgOut = new XDocument(new XElement("result", "ERROR: " + ex.Message)); } MsgOut = xmlMsgOut.ToString(); return(true); }
public cAccesoDatosNet(cServer pServer, string pDataBase) : this() { oServer = pServer; DataBase = pDataBase; }
public async Task LogonCheck() { string _dbserver = ""; string _shareserver = ""; string _cod3 = ""; try { var _dnsDB = Dns.GetHostEntry("appdb.local"); _dbserver = _dnsDB.HostName; var _dnsShare = Dns.GetHostEntry("appshare.local"); _shareserver = _dnsShare.HostName; _cod3 = _dbserver.Substring(0, 3); } catch { //CTWin.InputBox("", "Enter database server name or IP.", ref _dbserver); External = true; } //#if DEBUG // _dbserver = "db01"; // _shareserver = "valsrv02"; //#endif // string _pathLogonHosts; ServicePointManager.DnsRefreshTimeout = 0; var _serverDB = new cServer() { HostName = _dbserver, // _line.Split('|')[1], COD3 = _cod3, //_line.Split('|')[4], Type = ServerTypes.DATABASE, User = "******", Password = "******" }; var _serverShare = new cServer() { HostName = _shareserver, //_line.Split('|')[2], COD3 = _cod3, //_line.Split('|')[4], Type = ServerTypes.DATABASE, User = "******", Password = "******" }; ShareServerList.Add(_serverShare); COD3 = _cod3;// _line.Split('|')[4]; await getSystemVersions(_serverShare); AppList.Add(new cAppBot("logon", "LOGON", "SISTEMAS", "logon.exe", "LOC", _serverDB, _serverShare, "")); if (!External) { var _clean = Values.AppList[0].CheckUpdatedXML(); if (!_clean) { AppList[0].Status = AppBotStatus.PENDING_UPDATE; } if (Values.AppList.PendingApps.Count != 0) { Message = "Updating LogOn."; Application.DoEvents(); System.Threading.Thread.Sleep(250); ActiveThreads++; var _thread = new Updater(Values.UpdateList); // launch task not async await _thread.Start(); } this.Message = "LogOn updated. Launching."; System.Threading.Thread.Sleep(250); } await AppList[0].LaunchApp(true); // }
public cFTP(cServer pServer, string pStartingPath) { server = pServer; startingPath = pStartingPath; }