public HttpResponseMessage GetActiveteOrDeacuivate(int routeID, string city, string name, string time, string login, Boolean Activate) { //powinno string data = null; DriverModels driver = repo.GetDriverByNick(login); RouteModels route = repo.GetRouteByID(routeID); List <BusStopModels> busStops = (List <BusStopModels>)repo.GetAllBusStops(); int busStopId = 0; foreach (BusStopModels busStop in busStops) { if (busStop.City == city && busStop.Name == name) { busStopId = busStop.Id; } } repo.UpdateRoute(routeID, driver.Id, Activate); repo.UpdateDriver(driver.Id, routeID, busStopId, TimeSpan.Parse(time), Activate); route = repo.GetRouteByID(routeID); driver = repo.GetDriverByNick(login); data = " Driver id : " + driver.Id + " login : "******" route ID : " + driver.RouteID + " Route ID : " + route.Id + " busStop ID :" + driver.BusStopID + " time : " + driver.TimeFromBusStop.ToString() + " active : " + route.active + " driver ID : " + route.DriverID; return(Request.CreateResponse(HttpStatusCode.OK, data)); }
void Resample(RenderItem item) { byte[] data = null; try { uint hash = item.HashParameters(); data = cache.Get(hash); if (data == null) { CopySourceTemp(item); if (!resamplers.TryGetValue(item.ResamplerName, out var driver)) { driver = this.driver; } data = driver.DoResampler(DriverModels.CreateInputModel(item, 0), Log.Logger); if (data == null || data.Length == 0) { throw new Exception("Empty render result."); } cache.Put(hash, data); Log.Information($"Sound {hash:x} {item.Oto.Alias} {item.GetResamplerExeArgs()} resampled."); CopyBackMetaFiles(item); } } catch (Exception e) { Log.Error(e, $"Failed to render item {item.SourceFile} {item.Oto.Alias} {item.GetResamplerExeArgs()}."); } finally { item.Data = data ?? new byte[0]; item.OnComplete?.Invoke(item.Data); item.progress?.CompleteOne($"Resampling \"{item.phonemeName}\""); } }
public HttpResponseMessage LocationDriver(string login, double lat, double lon) { String result = ""; DriverModels driver = repo.GetDriverByNick(login); repo.UpdateDriver(driver.Id, lat, lon); driver = repo.GetDriverByNick(login); TimeSpan currentTime = DateTime.Now.TimeOfDay; int min = 0; bool driverWillNotStop = false; List <UserRequestModels> usersRequests = repo.GetAllUserRequest(); foreach (UserRequestModels usersRequest in usersRequests) { min = currentTime.Subtract(usersRequest.TimeAddRequest).Minutes; driverWillNotStop = (min > 5); if (!driverWillNotStop) { if (driver.Id == usersRequest.Driver.Id && !usersRequest.DriversGetRequest) { driver.UsersRequests.Add(usersRequest); repo.UpdateUserRequest(usersRequest.Id); result = result + usersRequest.Id + "," + usersRequest.UserCity + "," + usersRequest.UserBusStopName + "; "; } } else { repo.UpdateDriver(usersRequest.Driver, usersRequest.Id); repo.DeleteUserRequestByID(usersRequest.Id); } } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public ActionResult Edit(DriverModels model) { if (ModelState.IsValid) { repo.UpdateDriver(model); return(View("Drivers", repo.GetAllDrivers())); } return(View(model)); }
public ActionResult Create(DriverModels model) { if (ModelState.IsValid) { repo.AddDriver(model); return(View("Drivers", repo.GetAllDrivers())); } return(View(model)); }
public HttpResponseMessage GetAllRequestToDriver(string driverlogin) { String result = ""; DriverModels driver = repo.GetDriverByNick(driverlogin); foreach (UserRequestModels req in driver.UsersRequests) { result = result + req.Id + "," + req.UserCity + "," + req.UserBusStopName + ";"; } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
RenderItem ResamplePhonemeAsync(object state) { RenderItem item = state as RenderItem; Log.Verbose($"Sound {item.HashParameters():x} resampling {item.GetResamplerExeArgs()}"); var output = driver.DoResampler(DriverModels.CreateInputModel(item, 0)); item.Sound = MemorySampleProvider.FromStream(output); output.Dispose(); item.progress.CompleteOne($"Resampling \"{item.phonemeName}\""); return(item); }
public HttpResponseMessage Get(int routeID) { string result = "0"; RouteModels route = repo.GetRouteByID(routeID); DriverModels driver = repo.GetDriverByID(route.DriverID); if (route.active) { result = "1," + driver.Latitude + "," + driver.Longitude; return(Request.CreateResponse(HttpStatusCode.OK, result)); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage AnswearToUser(string login, int userRequestID, string message) { string result = ""; UserRequestModels userRequest = repo.GetUserRequestByID(userRequestID); repo.UpdateUserRequest(userRequestID, message); DriverModels driver = repo.GetDriverByNick(login); repo.UpdateDriver(driver, userRequestID); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public ActionResult Drivers(DriverModels model) { bool val1 = System.Web.HttpContext.Current.User.Identity.IsAuthenticated; if (val1) { return(View(repo.GetAllDrivers())); } else { return(RedirectToAction("Index", "Home")); } }
public HttpResponseMessage GetHasDriverActiveRoute(string login) { int result = 0; DriverModels driver = repo.GetDriverByNick(login); if (driver.RouteID != 0) { result = 1; return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { return(Request.CreateResponse(HttpStatusCode.OK, result)); } }
private List <RenderItem> RenderAsync(UVoicePart part, UProject project, IResamplerDriver engine, BackgroundWorker worker) { var renderItems = new List <RenderItem>(); var watch = new Stopwatch(); watch.Start(); Log.Information("Resampling start."); lock (part) { var cacheDir = PathManager.Inst.GetCachePath(project.FilePath); var cacheFiles = Directory.EnumerateFiles(cacheDir).ToArray(); int count = 0, i = 0; foreach (var note in part.Notes) { foreach (var phoneme in note.Phonemes) { count++; } } foreach (var note in part.Notes) { foreach (var phoneme in note.Phonemes) { if (string.IsNullOrEmpty(phoneme.Oto.File)) { Log.Warning($"Cannot find phoneme in note {note.Lyric}"); continue; } var item = new RenderItem(phoneme, part, project); //System.Diagnostics.Debug.WriteLine("Sound {0:x} resampling {1}", item.HashParameters(), item.GetResamplerExeArgs()); var engineArgs = DriverModels.CreateInputModel(item, 0); var output = engine.DoResampler(engineArgs); item.Sound = MemorySampleProvider.FromStream(output); output.Dispose(); renderItems.Add(item); worker.ReportProgress(100 * ++i / count, $"Resampling \"{phoneme.Phoneme}\" {i}/{count}"); } } } watch.Stop(); Log.Information($"Resampling end, total time {watch.Elapsed}"); return(renderItems); }
RenderItem ResamplePhonemeAsync(object state) { RenderItem item = state as RenderItem; uint hash = item.HashParameters(); byte[] data = cache.Get(hash); if (data == null) { data = driver.DoResampler(DriverModels.CreateInputModel(item, 0)); cache.Put(hash, data); Log.Information($"Sound {hash:x} {item.GetResamplerExeArgs()} resampled."); } else { Log.Information($"Sound {hash:x} {item.GetResamplerExeArgs()} cache retrieved."); } var stream = new MemoryStream(data); item.Sound = MemorySampleProvider.FromStream(stream); item.progress.CompleteOne($"Resampling \"{item.phonemeName}\""); return(item); }
private List <RenderItem> RenderAsync(UVoicePart part, UProject project, IResamplerDriver engine, BackgroundWorker worker) { List <RenderItem> renderItems = new List <RenderItem>(); System.Diagnostics.Stopwatch watch = new Stopwatch(); watch.Start(); System.Diagnostics.Debug.WriteLine("Resampling start"); lock (part) { string cacheDir = PathManager.Inst.GetCachePath(project.FilePath); string[] cacheFiles = Directory.EnumerateFiles(cacheDir).ToArray(); int count = 0, i = 0; foreach (UNote note in part.Notes) { foreach (UPhoneme phoneme in note.Phonemes) { count++; } } foreach (UNote note in part.Notes) { foreach (UPhoneme phoneme in note.Phonemes) { RenderItem item = BuildRenderItem(phoneme, part, project); var sound = RenderCache.Inst.Get(item.HashParameters()); if (sound == null) { string cachefile = Path.Combine(cacheDir, string.Format("{0:x}.wav", item.HashParameters())); if (!cacheFiles.Contains(cachefile)) { System.Diagnostics.Debug.WriteLine("Sound {0:x} resampling {1}", item.HashParameters(), item.GetResamplerExeArgs()); DriverModels.EngineInput engineArgs = DriverModels.CreateInputModel(item, 0); System.IO.Stream output = engine.DoResampler(engineArgs); sound = new CachedSound(output); } else { System.Diagnostics.Debug.WriteLine("Sound {0:x} found on disk {1}", item.HashParameters(), item.GetResamplerExeArgs()); sound = new CachedSound(cachefile); } RenderCache.Inst.Put(item.HashParameters(), sound, engine.GetInfo().ToString()); } else { System.Diagnostics.Debug.WriteLine("Sound {0} found in cache {1}", item.HashParameters(), item.GetResamplerExeArgs()); } item.Sound = sound; renderItems.Add(item); worker.ReportProgress(100 * ++i / count, string.Format("Resampling \"{0}\" {1}/{2}", phoneme.Phoneme, i, count)); } } } watch.Stop(); System.Diagnostics.Debug.WriteLine("Resampling end"); System.Diagnostics.Debug.WriteLine("Total cache size {0:n0} bytes", RenderCache.Inst.TotalMemSize); System.Diagnostics.Debug.WriteLine("Total time {0} ms", watch.Elapsed.TotalMilliseconds); return(renderItems); }