public ActionResult Results(string inputText) { var queryString = new Search(); var model = new List <Search>(); var myDbConnection = new ServerAccess(); using (myDbConnection.DBConnect) { using (MySqlCommand getResults = new MySqlCommand(queryString.searchQuery, myDbConnection.DBConnect)) { getResults.Parameters.AddWithValue("@input", "%" + inputText + "%"); myDbConnection.DBConnect.Open(); MySqlDataReader reader = getResults.ExecuteReader(); while (reader.Read()) { var newTitle = new Search(); newTitle.MovieTitle = reader["movieDescription"].ToString(); newTitle.youtubeLink = reader["youtubelink"].ToString(); newTitle.thumbnail = reader["thumbnail"].ToString(); model.Add(newTitle); } } } // var result = search.getResults(); return(View(model)); }
public static void Initialize() { if (Accounts.Count == 0) { Console.WriteLine("This server has no accounts."); Console.Write("Do you want to create the owner account now? (y/n): "); var answer = Console.ReadLine(); if (answer is "y" or "Y") { Console.WriteLine(); Console.Write("Username: "******"Password: "******"Owner account created: {Username}", username); ServerAccess.AddProtectedAccount(a, true); } else { logger.Warning("No owner account created."); } }
public string ServerAddress = "https://nakap.sakura.ne.jp/php/calendar/logincheck.php"; //selecttest.phpを指定 public void Start() { ServerAccess serverAccess = GetComponent <ServerAccess> (); //IDが保存されていたらロードする if (PlayerPrefs.HasKey("Id")) { idInputField.text = PlayerPrefs.GetString("Id"); } //パスワードが保存されていたらロードする if (PlayerPrefs.HasKey("Password")) { passwordInputField.text = PlayerPrefs.GetString("Password"); } //IDチェックボックスが保存されていたらTRUE,されていなかったらFALSE if (PlayerPrefs.HasKey("IdToggle")) { idToggle.isOn = true; } else { idToggle.isOn = false; } //パスワードチェックボックスが保存されていたらTRUE,されていなかったらFALSE if (PlayerPrefs.HasKey("PasswordToggle")) { passwordToggle.isOn = true; } else { passwordToggle.isOn = false; } }
public override void StartPuzzle(HackerDevice device, ServerAccess _server) { base.StartPuzzle(device, _server); routersParent.SetActive(true); device.ShowInfo("Server acces needed: Please activate all 3 router switches to open access for security level codes"); }
public static void Initialize() { if (Accounts.Count == 0) { Console.WriteLine("This server has no accounts."); Console.Write("Do you want to create the owner account now? (y/n): "); var answer = Console.ReadLine(); if (answer is "y" or "Y") { Console.WriteLine(); Console.Write("Username: "******"Password: "******"Account created."); ServerAccess.AddProtectedAccount(a, true); Console.WriteLine("Added {0} to the protected accounts list.", a.Username); } else { Console.WriteLine(); Console.WriteLine("Account not created."); } }
private async Task ClientOnClickExecute(ServerAccess ba, string client, RestoreMode mode) { try { await Dispatcher.BeginInvoke(DispatcherPriority.Send, (ThreadStart)(() => { Files.Clear(); })); using (new NetworkConnection(ba.uri, new NetworkCredential(ba.username, ba.password))) { string path = Path.Combine(ba.uri, ba.dailyfolder, client); DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] files = dir.GetFiles("*.bak").OrderByDescending(p => p.CreationTime).ToArray(); if (files.Count() > 0) { await Dispatcher.BeginInvoke(DispatcherPriority.Send, (ThreadStart)(() => { SelectedTime = DateTime.Now; for (int i = 0; i < files.Count(); i++) { Files.Add(files[i]); } })); } } } catch (Exception ex) { Logger.Error(ex.Message); } }
private void RestoreAtDateExecute(ServerAccess ba, SqlServerAccess sa, FileInfo f, string dbName, RestoreOption opt) { try { using (new NetworkConnection(ba.uri, new NetworkCredential(ba.username, ba.password))) { var filePath = f.FullName; using (new NetworkConnection(sa.uri, new NetworkCredential(sa.username, sa.password))) { string destPath = Path.Combine(sa.uri, sa.folder, f.Name); if (File.Exists(destPath)) { File.Delete(destPath); } File.Copy(filePath, destPath); var bakFilePath = destPath; destPath = destPath.Replace(sa.uri, sa.disk); SMOHelper restoreInstance = new SMOHelper(sa); restoreInstance.Restore(destPath, dbName, opt); if (File.Exists(bakFilePath)) { File.Delete(bakFilePath); } } } } catch (Exception ex) { Logger.Error(ex.Message); } }
public override void StartPuzzle(HackerDevice device, ServerAccess _server) { base.StartPuzzle(device, _server); hackerDevice = device; buttons[currentButton].gameObject.SetActive(true); lazers[currentButton].SetActive(true); StartCoroutine(CountDown(timeForPuzzle)); }
private void RestoreAtTimeExecute(ServerAccess ba, SqlServerAccess sa, string c, string dbName, DateTime time, RestoreOption opt) { try { using (new NetworkConnection(ba.uri, new NetworkCredential(ba.username, ba.password))) { string path = Path.Combine(ba.uri, ba.dailyfolder, c); DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] files = dir.GetFiles("*.bak").OrderByDescending(p => p.CreationTime).ToArray(); var f = files.FirstOrDefault(); var filePath = f.FullName; var creationDate = f.CreationTime; FileInfo[] transactionFiles = dir.GetFiles("*.trn").OrderByDescending(p => p.CreationTime).ToArray(); using (new NetworkConnection(sa.uri, new NetworkCredential(sa.username, sa.password))) { string destPath = Path.Combine(sa.uri, sa.folder, f.Name); if (File.Exists(destPath)) { File.Delete(destPath); } File.Copy(filePath, destPath); var bakFilePath = destPath; var transactionFilesPath = CopyAllTransactionFiles(transactionFiles, sa, creationDate, time); destPath = destPath.Replace(sa.uri, sa.disk); var transactionFilesDestPath = new List <string>(); foreach (var tf in transactionFilesPath) { transactionFilesDestPath.Add(tf.Replace(sa.uri, sa.disk)); } SMOHelper restoreInstance = new SMOHelper(sa); restoreInstance.RestoreAtTime(destPath, transactionFilesDestPath, time, dbName, opt); if (File.Exists(bakFilePath)) { File.Delete(bakFilePath); } foreach (var fileToDel in transactionFilesPath) { if (File.Exists(fileToDel)) { File.Delete(bakFilePath); } } } } } catch (Exception ex) { Logger.Error(ex.Message); } }
private async Task SwitchExecute(ServerAccess ba, RestoreMode mode) { try { await Dispatcher.BeginInvoke(DispatcherPriority.Send, (ThreadStart)(() => { Clients.Clear(); })); using (new NetworkConnection(ba.uri, new NetworkCredential(ba.username, ba.password))) { var listClientRemote = Directory.GetDirectories(ba.uri); var path = Path.Combine(ba.uri, ba.dailyfolder); var listClient = Directory.GetDirectories(path); var cleanList = new List <string>(); foreach (var c in listClient) { var substring = c.Remove(c.IndexOf(path), path.Length + 1); cleanList.Add(substring); } var sortedList = cleanList.OrderBy(c => c).ToList(); await Dispatcher.BeginInvoke(DispatcherPriority.Send, (ThreadStart)(() => { foreach (var c in sortedList) { Clients.Add(c); } })); } } catch (Exception ex) { Logger.Error(ex.Message); } }
public int Process(SyncSettings settings) { int nbUploaded = 0; _currentAction = "Starting..."; IServerAccess source = null; IServerAccess destinationClient = null; string currentFile = null; string originalFile = null; try { var result = settings.Validate(); if (result.Any()) { foreach (var error in result) { _logger.Error(error.ErrorMessage); } return(0); } SetCurrentAction("Connecting to Source " + settings.sourceFTP.address); source = ServerAccess.CreateAccessTo(settings.sourceFTP); List <string> sourceList = source.GetFileList(settings.changeFileNamePrepend); _logger.Info($"{sourceList.Count} files found to transfer"); if (sourceList.Count == 0) { return(0); } if (Directory.Exists(_pathTemp)) { Directory.CreateDirectory(_pathTemp); } string prepend = settings.changeFileNamePrepend; foreach (string sourceFile in sourceList) { originalFile = sourceFile; currentFile = sourceFile; if (!string.IsNullOrWhiteSpace(prepend)) { currentFile = prepend + currentFile; SetCurrentAction($"Renaming {originalFile} => {currentFile}"); source.RenameFile(originalFile, currentFile); } string localFile = Path.Combine(_pathTemp, currentFile); SetCurrentAction("Downloading " + currentFile); source.DownloadFile(currentFile, localFile); source.Disconnect(); source = null; SetCurrentAction("Uploading " + localFile); destinationClient = ServerAccess.CreateAccessTo(settings.destinationFTP); if (destinationClient.UploadFile(localFile, currentFile, settings.destinationFTP, settings.changeFileNamePrepend)) { nbUploaded++; } SetCurrentAction("Connecting to Source " + settings.sourceFTP.address); // Reconnect to source do delete and do next download source = ServerAccess.CreateAccessTo(settings.sourceFTP); if (settings.sourceFTP.deleteFileAfterTransfer) { SetCurrentAction($"Delete {currentFile} on source {settings.sourceFTP.address} "); source.DeleteFile(currentFile); } else { if (currentFile != originalFile) { SetCurrentAction($"Renaming {currentFile} => {originalFile}"); source.RenameFile(currentFile, originalFile); } } currentFile = null; } _logger.Info( $"Done ! {sourceList.Count} file{(sourceList.Count > 1 ? "s" : "")} on source, {nbUploaded} file{(nbUploaded > 1 ? "s" : "")} uploaded"); } catch (Exception e) { LogExceptionCleanly(e); if (currentFile != null && originalFile != null && currentFile != originalFile) { //Need to rename the original file try { if (source == null) { SetCurrentAction("AFTER EXCEPTION Connecting to Source " + settings.sourceFTP.address); source = ServerAccess.CreateAccessTo(settings.sourceFTP); } SetCurrentAction($"AFTER EXCEPTION Renaming {currentFile} => {originalFile}"); source.RenameFile(currentFile, originalFile); } catch (Exception exception) { LogExceptionCleanly(exception); } finally { source?.Disconnect(); } } return(nbUploaded); } finally { EmptyTmpFolder(); source?.Disconnect(); destinationClient?.Disconnect(); } return(nbUploaded); }
public virtual void StartPuzzle(HackerDevice device, ServerAccess _server) { server = _server; }