IEnumerator Say() { yield return(new WaitUntil(() => !textDrawer.drawing)); Debug.Log(0); FoundInfo.Show(inventory.items[itemInsideIndex].sprite); }
private static void SearchDirectory(DirectoryInfo dirInfo) { if (!_cancellationTokenSource.IsCancellationRequested) { while (_pauseSearch) { // стоит на паузе } try { foreach (var info in dirInfo.GetFileSystemInfos(_searchParams.FileName)) { _count++; SearchInfo?.Invoke(new SearchInfoEventArgs(info, _count)); if (_cancellationTokenSource.IsCancellationRequested) { break; } while (_pauseSearch) { // стоит на паузе } if (MatchesRestrictions(info)) { _foundedCount++; FoundInfo?.Invoke(new FoundInfoEventArgs(info, _foundedCount)); } } if (_searchParams.IncludeSubDirsChecked) { foreach (var subDirInfo in dirInfo.GetDirectories()) { if (_cancellationTokenSource.IsCancellationRequested) { break; } while (_pauseSearch) { // стоит на паузе } SearchDirectory(subDirInfo); } } } catch (Exception) { // ignored } } }
/// <summary> /// This class handles creation/write updates to files. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void FileWatcher_Event(object sender, FileSystemEventArgs e) { //First, make sure we have a target type. MM_EMSReader_File FoundInfo; if (FileInfo.TryGetValue(e.Name, out FoundInfo)) { FoundInfo.Trigger(e); } }
public async Task PoteryashkaFoundAsync(FoundInfo info) { var client = GetClient(); var postUrl = url + "poteryashkafound/"; var responce = await client.PutAsync(postUrl, new StringContent( JsonConvert.SerializeObject(info), Encoding.UTF8, "text/plain")); }
private async void WasFoundToolStripMenuItem_Click(object sender, EventArgs e) { var poteryashka = this.poteryashkasListView.SelectedItems[0].Tag as Poteryashka; var foundPoteryashka = new FoundForm(); if (foundPoteryashka.ShowDialog() == DialogResult.OK) { var founInfo = new FoundInfo() { PoteryashkaId = poteryashka.Id, Date = foundPoteryashka.Date }; await clien.PoteryashkaFoundAsync(founInfo); LoadPoteryashkasWithFormParams(); } }
private static void SearchDirectory(DirectoryInfo dirInfo) { if (!stop) { try { foreach (String fileName in fileName) { FileSystemInfo[] infos = dirInfo.GetFileSystemInfos(fileName); foreach (FileSystemInfo info in infos) { if (stop) { break; } if (IsMatchingRestrictions(info)) { // We have found a matching FileSystemInfo, so let's raise an event: FoundInfo?.Invoke(new FileFoundInfoEventArgs(info)); } } } if (includeSubDirsChecked) { DirectoryInfo[] subDirInfos = dirInfo.GetDirectories(); foreach (DirectoryInfo subDirInfo in subDirInfos) { if (stop) { break; } // Recursion: new Thread(() => { SearchDirectory(subDirInfo); }).Start(); } } } catch (Exception) { } } }
void Start() { anim = GetComponent <Animator>(); instance = this; }
public async Task StartAsync() { listener.Start(); while (true) { var httpContext = await listener.GetContextAsync(); var request = httpContext.Request; var response = httpContext.Response; if (request.HttpMethod == "GET") { var dataString = ""; var splitUrl = request.RawUrl.Split('/', '?'); var requestType = splitUrl[1].ToLower(); var stream = response.OutputStream; if (requestType == "getpoteryashkas") { var data = await dbContext.Poteryashkas.ToListAsync(); var surname = request.QueryString["surname"]; var stringAge = request.QueryString["age"]; var stringLostFrom = request.QueryString["lostfrom"]; var stringLostTo = request.QueryString["lostto"]; if (!string.IsNullOrWhiteSpace(surname)) { data = data.Where(m => m.Surname.ToLower() == surname.ToLower()).ToList(); } if (!string.IsNullOrWhiteSpace(stringAge)) { if (int.TryParse(stringAge, out var age)) { data = data.Where(m => m.Age == age).ToList(); } } if (!string.IsNullOrWhiteSpace(stringLostFrom)) { if (DateTime.TryParse(stringLostFrom, out var lostFrom)) { data = data.Where(m => m.Lost?.ToShortDateString() == lostFrom.ToShortDateString()).ToList(); } } if (!string.IsNullOrWhiteSpace(stringLostTo)) { if (DateTime.TryParse(stringLostTo, out var lostTo)) { data = data.Where(m => m.Found?.ToShortDateString() == lostTo.ToShortDateString()).ToList(); } } dataString = JsonConvert.SerializeObject(data, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); } else if (requestType == "getpoteryashkaseen") { var stringId = splitUrl.Length > 2 ? splitUrl[2] : null; if (!string.IsNullOrWhiteSpace(stringId)) { if (!int.TryParse(stringId, out var id)) { httpContext.Response.StatusCode = 400; httpContext.Response.Close(); continue; } var data = await dbContext.Seens.Where(m => m.Who.Id == id).ToListAsync(); dataString = JsonConvert.SerializeObject(data, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); } else { httpContext.Response.StatusCode = 400; httpContext.Response.Close(); continue; } } else { httpContext.Response.StatusCode = 404; httpContext.Response.Close(); continue; } using (var writer = new StreamWriter(stream)) { await writer.WriteLineAsync(dataString); } httpContext.Response.StatusCode = 200; httpContext.Response.Close(); continue; } else if (request.HttpMethod == "POST") { var splitUrl = request.RawUrl.Split('/'); var dataType = splitUrl[1].ToLower(); if (dataType == "addpoteryashka") { Poteryashka poteryashka = null; var inputStream = request.InputStream; using (var streamReader = new StreamReader(inputStream)) { poteryashka = JsonConvert.DeserializeObject <Poteryashka>(streamReader.ReadToEnd()); } if (poteryashka != null) { dbContext.Poteryashkas.Add(poteryashka); await dbContext.SaveChangesAsync(); var dataString = JsonConvert.SerializeObject(poteryashka); var outputStream = response.OutputStream; using (var streamWriter = new StreamWriter(outputStream)) { await streamWriter.WriteLineAsync(dataString); } response.StatusCode = 200; response.Close(); continue; } response.StatusCode = 400; response.Close(); continue; } else if (dataType == "haveseenpoteryashka") { Seen seen = null; var inputStream = request.InputStream; using (var streamReader = new StreamReader(inputStream)) { seen = JsonConvert.DeserializeObject <Seen>(streamReader.ReadToEnd()); } if (seen != null) { var poteryashkas = dbContext.Poteryashkas.Find(seen.Who.Id); seen.Who = null; poteryashkas.Seen.Add(seen); await dbContext.SaveChangesAsync(); var dataString = JsonConvert.SerializeObject(seen, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); var outputStream = response.OutputStream; using (var streamWriter = new StreamWriter(outputStream)) { await streamWriter.WriteLineAsync(dataString); } response.StatusCode = 200; response.Close(); continue; } response.StatusCode = 400; response.Close(); continue; } else { httpContext.Response.StatusCode = 404; httpContext.Response.Close(); continue; } } else if (request.HttpMethod == "PUT") { var splitUrl = request.RawUrl.Split('/'); var dataType = splitUrl[1].ToLower(); if (dataType == "poteryashkafound") { FoundInfo info = null; var stream = request.InputStream; using (var streamReader = new StreamReader(stream)) { info = JsonConvert.DeserializeObject <FoundInfo>(streamReader.ReadToEnd()); } if (info != null) { var p = await dbContext.Poteryashkas.FindAsync(info.PoteryashkaId); p.IsFound = true; p.Found = info.Date; await dbContext.SaveChangesAsync(); response.StatusCode = 200; response.Close(); continue; } response.StatusCode = 400; response.Close(); } else if (dataType == "updatepoteryashka") { Poteryashka poteryashka = null; var inputStream = request.InputStream; using (var streamReader = new StreamReader(inputStream)) { poteryashka = JsonConvert.DeserializeObject <Poteryashka>(streamReader.ReadToEnd()); } if (poteryashka != null) { var originalPoteryashka = await dbContext.Poteryashkas.FindAsync(poteryashka.Id); originalPoteryashka.Name = poteryashka.Name; originalPoteryashka.Surname = poteryashka.Surname; originalPoteryashka.Age = poteryashka.Age; originalPoteryashka.AdditionalInfo = poteryashka.AdditionalInfo; originalPoteryashka.Phone = poteryashka.Phone; originalPoteryashka.Lost = poteryashka.Lost; await dbContext.SaveChangesAsync(); response.StatusCode = 200; response.Close(); continue; } response.StatusCode = 400; response.Close(); continue; } else { httpContext.Response.StatusCode = 404; httpContext.Response.Close(); continue; } } } }