public DataAccess() { DbClientInstance = new DbClient("DbConnection"); LoadDatabaseCommands(DbClientInstance); Utility = new Utilities(); Translator = new ExpQueryTranslator(); }
internal void RemoveDatabaseCommands(DbClient dbClient) { //Leerlas desde la Clase StoredProcedure FieldInfo[] SPFieldsInfo = typeof(StoredProcedures).GetFields(); foreach (var SPField in SPFieldsInfo) { dbClient.RemoveCommand((string)SPField.GetValue(null)); } }
/// <summary> /// 根据condition List获取相应Model集合 /// </summary> /// <param name="cons"></param> /// <returns></returns> public List <T> Get(List <IConditionalModel> cons) { return(DbClient.Queryable <T>().Where(cons).ToList()); }
private Client ConvertDbClientToClient(DbClient dbClient) { return(new Client(dbClient.DbClientId, dbClient.DbClientLastName, dbClient.DbClientFirstName, dbClient.DbClientMiddleName, dbClient.DbClientBirthday, dbClient.DbClientPhoneNumber, dbClient.DbClientEmail)); }
public AuditClient(ILog log, BerbotConnectionFactory connectionFactory) { this.log = log; db = connectionFactory.CreateDbClient(); }
/// <summary> /// 根据SQL Where字符串获取相应Model集合 /// </summary> /// <param name="whereString">where 字符串</param> /// <returns></returns> public List <T> Get(string whereString = null) { return(DbClient.Queryable <T>().Where(whereString).ToList()); }
public StudentAttendancesService() { _dbClient = DbClient.CreateDbClient(); }
public virtual void MarkAsFailed() { //This method is allowed to not be wrapped in Try, since try makes use of it. Status = SessionStatus.Failed; DbClient.MarkAsFailed(); }
public TeachersService() { _dbClient = DbClient.CreateDbClient(); }
public MunicipalityService(DbClient client) { this.client = client; }
public bool CreateClass() { DbClient.QueryExecute("INSERT INTO Class(name) VALUES(' " + name + " ')"); return(true); }
internal static Client ToModel(this DbClient s) { return(s == null ? null : Mapper.Map <Client>(s)); }
public LocationService(DbClient client, MunicipalityService municipalityService) { this.client = client; this.municipalityService = municipalityService; }
public UserHistoryCache(ILog log, BerbotConnectionFactory connectionFactory) { this.log = log; this.dbClient = connectionFactory.CreateDbClient(); this.redditClient = connectionFactory.CreateModRedditClient(); }
public TestService(DbClient client) { this.client = client; }
private Maybe <Client> MaybeClient(DbClient client) { return(client != null ? new Maybe <Client>(client.ToModel()) : Maybe <Client> .Fail); }
public StudentsService() { _dbClient = DbClient.CreateDbClient(); }
/// <summary> /// Main entry point for application. The main task /// of the program is to create database of Estate agency. /// </summary> /* * static void Main() { * DbClient.Connect(); * DbClient.SetClusterActive(true); * DbClient.CreateDatabase(); * } */ static void Main() { Console.OutputEncoding = System.Text.Encoding.UTF8; Console.InputEncoding = System.Text.Encoding.Unicode; DbClient.Connect(); DbClient.SetClusterActive(true); DbClient.GetDatabase(); Console.WriteLine("Caches:"); foreach (string i in DbClient.Client.GetCacheNames()) { Console.WriteLine(i); } Console.WriteLine("-----------------------------------------------------------"); char c = '0'; do { Console.WriteLine("Select variant: \n 1 - put Location \n 2 - get all locations \n 3 - reset counter \n 4 - delete all \n ~ - exit."); c = Console.ReadLine()[0]; switch (c) { case '1': Location loc = new Location(); Console.Write("[Region ]: "); loc.Region = Console.ReadLine(); Console.Write("[Town ]: "); loc.Town = Console.ReadLine(); Console.Write("[District]: "); loc.District = Console.ReadLine(); var v = loc.Validate; if (v.isValid) { Console.WriteLine("Success!"); DbClient.PutLocation(loc); } else { Console.WriteLine("Validation failed."); Console.WriteLine(v.Message); Console.WriteLine(loc.Region); Console.WriteLine(loc.Town); Console.WriteLine(loc.District); } break; case '2': int i = 0; foreach (var row in DbClient.LocationCache.Query(new SqlFieldsQuery("select _key, Region, Town, District from Locations;"))) { Console.WriteLine($" key : {row[0]}"); Console.WriteLine($" Region : {row[1]}"); Console.WriteLine($" Town : {row[2]}"); Console.WriteLine($" District : {row[3]}"); Console.WriteLine(); i++; } Console.WriteLine($" Total : {i} rows"); break; case '3': Console.Write("Sure? [y/n] "); c = Console.ReadLine()[0]; if (c == 'y') { DbClient.LastUsedKeys.Put("location", 0); Console.WriteLine("Counter was reset to 0!"); } else { Console.WriteLine("Okay, cancelling."); } break; case '4': Console.Write("Sure? [y/n] "); c = Console.ReadLine()[0]; if (c == 'y') { DbClient.LocationCache.RemoveAll(); DbClient.LastUsedKeys.Put("location", 0); Console.WriteLine("Everything was deleted!"); } else { Console.WriteLine("Okay, cancelling."); } break; default: break; } Console.WriteLine("-----------------------------------------------------------"); } while (c != '~'); DbClient.Disconnect(); Console.WriteLine("[Done. Press ENTER to continue.]"); Console.Read(); }
public CoughMedicineService() { _dbClient = DbClient.CreateDbClient(); }
public void AddGateway() { DbClient.SetNewGateway(_saAmount); }
public virtual ISession UpdateMany <T>(Expression <Func <T, bool> > predicate, Action <T> modifier) where T : class { Try(() => { Ensure.That(predicate, "predicate").IsNotNull(); Ensure.That(modifier, "modifier").IsNotNull(); var structureSchema = OnUpsertStructureSchema <T>(); CacheConsumeMode = CacheConsumeModes.DoNotUpdateCacheWithDbResult; Db.CacheProvider.CleanQueriesFor(structureSchema); var deleteIds = new HashSet <IStructureId>(); var keepQueue = new List <T>(Db.Settings.MaxUpdateManyBatchSize); var structureBuilder = Db.StructureBuilders.ResolveBuilderForUpdate(structureSchema); var structureInserter = Db.ProviderFactory.GetStructureInserter(DbClient); var queryBuilder = Db.ProviderFactory.GetQueryBuilder <T>(Db.StructureSchemas); var query = queryBuilder.Where(predicate).Build(); var sqlQuery = QueryGenerator.GenerateQuery(query); foreach (var structure in Db.Serializer.DeserializeMany <T>( DbClient.ReadJson(structureSchema, sqlQuery.Sql, sqlQuery.Parameters))) { var structureIdBefore = structureSchema.IdAccessor.GetValue(structure); modifier.Invoke(structure); var structureIdAfter = structureSchema.IdAccessor.GetValue(structure); if (!structureIdBefore.Value.Equals(structureIdAfter.Value)) { throw new SisoDbException(ExceptionMessages.WriteSession_UpdateMany_NewIdDoesNotMatchOldId.Inject( structureIdAfter.Value, structureIdBefore.Value)); } deleteIds.Add(structureIdBefore); keepQueue.Add(structure); if (keepQueue.Count < Db.Settings.MaxUpdateManyBatchSize) { continue; } Db.CacheProvider.Remove(structureSchema, deleteIds); DbClient.DeleteByIds(deleteIds, structureSchema); deleteIds.Clear(); var items = keepQueue.ToArray(); var structures = structureBuilder.CreateStructures(items, structureSchema); structureInserter.Insert(structureSchema, structures); keepQueue.Clear(); InternalEvents.NotifyUpdated(this, structureSchema, structures, items); } if (keepQueue.Count > 0) { Db.CacheProvider.Remove(structureSchema, deleteIds); DbClient.DeleteByIds(deleteIds, structureSchema); deleteIds.Clear(); var items = keepQueue.ToArray(); var structures = structureBuilder.CreateStructures(items, structureSchema); structureInserter.Insert(structureSchema, structures); keepQueue.Clear(); InternalEvents.NotifyUpdated(this, structureSchema, structures, items); } }); return(this); }
public ActionResult Post_Stage2() { if (HttpContext.Session.GetInt32("PersonID") == null) { return(new UnauthorizedResult()); } else { ViewData["LoggedIn"] = true; } EstateObject h; string variant = Request.Form["variant"]; switch (variant) { case "h": h = new House { PostDate = DateTime.UtcNow, LocationID = int.Parse(Request.Form["location"]), Variant = (byte)'h', StreetName = Request.Form["streetname"], HouseNumber = Request.Form["housenumber"], Description = Request.Form["description"], SellerID = (int)HttpContext.Session.GetInt32("PersonID"), Price = int.Parse(Request.Form["price"]), HomeArea = float.Parse(Request.Form["homearea"]), LandArea = float.Parse(Request.Form["landarea"]), FloorCount = short.Parse(Request.Form["floorcount"]), RoomCount = short.Parse(Request.Form["roomcount"]), State = byte.Parse(Request.Form["state"]), isVisible = true, isOpen = true }; break; case "f": h = new Flat { PostDate = DateTime.UtcNow, LocationID = int.Parse(Request.Form["location"]), Variant = (byte)'h', StreetName = Request.Form["streetname"], HouseNumber = Request.Form["housenumber"], FlatNumber = short.Parse(Request.Form["flatnumber"]), Description = Request.Form["description"], SellerID = (int)HttpContext.Session.GetInt32("PersonID"), Price = int.Parse(Request.Form["price"]), HomeArea = float.Parse(Request.Form["homearea"]), Floor = short.Parse(Request.Form["floor"]), RoomCount = short.Parse(Request.Form["roomcount"]), State = byte.Parse(Request.Form["state"]), isVisible = true, isOpen = true }; break; case "l": h = new Landplot { PostDate = DateTime.UtcNow, LocationID = int.Parse(Request.Form["location"]), Variant = (byte)'h', StreetName = Request.Form["streetname"], HouseNumber = Request.Form["housenumber"], Description = Request.Form["description"], SellerID = (int)HttpContext.Session.GetInt32("PersonID"), Price = int.Parse(Request.Form["price"]), LandArea = float.Parse(Request.Form["landarea"]), State = byte.Parse(Request.Form["state"]), isVisible = true, isOpen = true }; break; default: h = new EstateObject { PostDate = DateTime.UtcNow, LocationID = int.Parse(Request.Form["location"]), Variant = (byte)'h', StreetName = Request.Form["streetname"], HouseNumber = Request.Form["housenumber"], Description = Request.Form["description"], SellerID = (int)HttpContext.Session.GetInt32("PersonID"), Price = int.Parse(Request.Form["price"]), State = byte.Parse(Request.Form["state"]), isVisible = true, isOpen = true }; break; } string t = Request.Form["tags"]; h.Tags = t.Split(' '); var v = h.Validate; if (!v.isValid && v.FieldName != "PhotoUrls") // wheelchair { ViewData["ErrorMessage"] = v.Message; return(View("PostHouse", h)); } else { h.PhotoUrls = new List <string>(); var photos = Request.Form.Files.ToList(); if (photos.Count < 1) { ViewData["ErrorMessage"] = "There were no photos."; if (variant == "h") { return(View("PostHouse")); } else if (variant == "f") { return(View("PostFlat")); } else if (variant == "l") { return(View("PostLandplot")); } else { return(View("PostObject")); } } for (int i = 0; i < photos.Count & i < 10; i++) { if (photos[i].Length < (2 * 1024 * 1024)) { string ext = photos[i].ContentType.Split('/')[1]; string filename = $"{h.PostDate.ToBinary():X}_{i}.{ext}"; Console.WriteLine("File name: " + filename); h.PhotoUrls.Add(filename); using (FileStream s = new FileStream($"wwwroot/img/{filename}", FileMode.OpenOrCreate)) { photos[i].CopyTo(s); } } } try { DbClient.PutEstateObject(h); } catch (ReferentialException ee) { ViewData["ErrorMessage"] = ee.ReadableMessage; ViewData["location"] = Request.Form["location"]; ViewData["variant"] = "h"; if (variant == "h") { return(View("PostHouse")); } else if (variant == "f") { return(View("PostFlat")); } else if (variant == "l") { return(View("PostLandplot")); } else { return(View("PostObject")); } } } return(View("ViewObject", h)); }
public void GetAmount(string month_year, int amount) { DbClient.QueryExecute("update Staff set amount=" + amount + ",amountlog='" + month_year + "' WHERE Id=" + Id); }
/// <summary> /// 根据条件获取相应Model集合 /// </summary> /// <param name="exp">Lambda表达式</param> /// <returns></returns> public List <T> Get(Expression <Func <T, bool> > exp) { return(exp == null?DbClient.Queryable <T>().ToList() : DbClient.Queryable <T>().Where(exp).ToList()); }
public VodRepository(DbClient db) { _db = db; }
public FeedbackService() { _dbClient = DbClient.CreateDbClient(); _feedback = new Feedback(); }
public ActionResult DeleteObjectConfirm(int id) { DbClient.DeleteObject(id); return(RedirectToAction("Explore")); }
public AdminService() { _dbClient = DbClient.CreateDbClient(); }
public override async Task <TextProcessingServiceRespone> Invork(TextRequest textRequest) { var time = DateTime.Now; TextProcessingServiceRespone textProcessingServiceRespone = new TextProcessingServiceRespone() { Id = textRequest.Id.Value }; ApiAiSDK.Model.AIResponse aiResponse; ApiAiSDK.RequestExtras requestExtras; DbClient db = new DbClient(); var context = await db.GetContext(textRequest.Id.Value); if (context != null && !string.IsNullOrWhiteSpace(context.IntentContext)) { requestExtras = JsonConvert.DeserializeObject <ApiAiSDK.RequestExtras>(context.IntentContext); } else { requestExtras = new ApiAiSDK.RequestExtras(); } aiResponse = apiAi.TextRequest(textRequest.TextData, requestExtras); //TODO: Update Exceptions if (aiResponse == null) { throw new Exception("Invalid output message"); } requestExtras.Contexts = new List <ApiAiSDK.Model.AIContext>(); foreach (var outContext in aiResponse.Result.Contexts) { ApiAiSDK.Model.AIContext aIContext = new ApiAiSDK.Model.AIContext { Parameters = new Dictionary <string, string>(), Lifespan = outContext.Lifespan, Name = outContext.Name }; foreach (var param in outContext.Parameters) { string key = param.Key; string value; if (param.Value != null) { value = param.Value.ToString(); aIContext.Parameters.Add(key, value); } } requestExtras.Contexts.Add(aIContext); } if (requestExtras == null) { requestExtras = new ApiAiSDK.RequestExtras(); } if (context == null) { context = new DbModels.UserContext() { Id = textRequest.Id.Value, IntentContext = "", TalkContext = "", TalkReplicCount = 0 } } ; context.IntentContext = JsonConvert.SerializeObject(requestExtras); await db.AddOrUpdateContext(context); requestExtras = null; db.Dispose(); textProcessingServiceRespone.TextData = aiResponse.Result.Fulfillment.Speech; if (!string.IsNullOrWhiteSpace(aiResponse.Result.Action)) { foreach (var parametr in aiResponse.Result.Parameters) { if (!string.IsNullOrWhiteSpace(parametr.Value.ToString())) { textProcessingServiceRespone.Entities.Add(parametr.Key, parametr.Value.ToString()); if (parametr.Value.ToString().Contains("dress")) { textProcessingServiceRespone.WayPoint = "adidas"; } else if (parametr.Value.ToString().Contains("shop")) { textProcessingServiceRespone.WayPoint = "adidas"; } else if (parametr.Value.ToString().Contains("furniture")) { textProcessingServiceRespone.WayPoint = "adidas"; } else if (parametr.Value.ToString().ToLower().Contains("ikea")) { textProcessingServiceRespone.WayPoint = "adidas"; } else if (parametr.Value.ToString().ToLower().Contains("adidas")) { textProcessingServiceRespone.WayPoint = "adidas"; } } } if (aiResponse.Result.Action == "navigation_shops") { textProcessingServiceRespone.WayPoint = "adidas"; } if (aiResponse.Result.Action == "Cheese") { textProcessingServiceRespone.WayPoint = "cheese"; } textProcessingServiceRespone.IntentName = aiResponse.Result.Action; } else { textProcessingServiceRespone.IntentName = "none"; } //DEBUG INFO #region DebugInfo if (SHOW_DEBUG_INFO) { Console.WriteLine("Id: {0} | BOT PARAMS:", textRequest.Id.Value); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Intent {0}", textProcessingServiceRespone.IntentName); Console.WriteLine("\tName\t\t\t|Value"); Console.ForegroundColor = ConsoleColor.DarkGreen; foreach (var parametr in textProcessingServiceRespone.Entities) { Console.WriteLine("\t{0,-23} |{1}", parametr.Key, parametr.Value); } Console.WriteLine(textProcessingServiceRespone.WayPoint); Console.ForegroundColor = ConsoleColor.Gray; /* * Console.WriteLine("User: "******"Masha: " + outputText); * Console.ForegroundColor = ConsoleColor.DarkMagenta; * Console.WriteLine("BOT CONTEXTS:"); * foreach (var context in aiResponse.Result.Contexts) * { * Console.ForegroundColor = ConsoleColor.DarkCyan; * Console.WriteLine("## {0}", context.Name); * Console.ForegroundColor = ConsoleColor.Gray; * Console.WriteLine("\tName\t\t\t|Value"); * Console.ForegroundColor = ConsoleColor.DarkGreen; * foreach (var parameter in context.Parameters) * Console.WriteLine("\t{0,-23} |{1}", parameter.Key, parameter.Value); * } * Console.ForegroundColor = ConsoleColor.Gray; * * Console.ForegroundColor = ConsoleColor.DarkMagenta; * Console.WriteLine("BOT PARAMS:"); * Console.ForegroundColor = ConsoleColor.Gray; * Console.WriteLine("\tName\t\t\t|Value"); * Console.ForegroundColor = ConsoleColor.DarkGreen; * foreach (var parametr in aiResponse.Result.Parameters) * { * Console.WriteLine("\t{0,-23} |{1}", parametr.Key, parametr.Value); * } * Console.ForegroundColor = ConsoleColor.Gray; */ } #endregion Log.LogInformation(textRequest.Id.Value, 0, this.GetType().ToString(), $"service end work in {(DateTime.Now - time).Milliseconds} ms"); //Console.WriteLine("WayPoint: " + textProcessingServiceRespone.WayPoint); return(textProcessingServiceRespone); } }
public HomeWorksService() { _dbClient = DbClient.CreateDbClient(); }
public TimeTablesService() { _dbClient = DbClient.CreateDbClient(); }
public SQLite(DbClient dbClient) { this.dbClient = dbClient; }
public async Task ExecuteQuery() { if (!CanExecuteQuery) return; var dtNow = DateTime.Now; _cancellationTokenSource = new CancellationTokenSource(); IsExecutingQuery = true; Status = "Executing query."; var databaseQueryService = new DbClient(); var executeParameters = new ExecuteParameters { ConnectionString = ConnectionString, SqlStatement = CommandTextSource }; var cancellationToken = _cancellationTokenSource.Token; var updateStatusAction = OneTimeAction.Execute(1000, () => { Status = string.Format("Executing query in {0}. ", (DateTime.Now - dtNow).ToString(@"dd\.hh\:mm\:ss")); }); var results = await databaseQueryService.ExecuteSqlAsync(executeParameters, DefaultQueryTimeout, cancellationToken); // Reset updateStatusAction.Cancel(); Status = string.Empty; ResultsSets.Clear(); // Preccess results var i = 1; foreach (var executeResults in results) { var hasData = executeResults.ResultsData != null && executeResults.ResultsData.Rows.Count > 0; var resultsSetModel = new ResultsSetModel { Title = "Result Set " + i, StatusMessage = executeResults.StatusMessage, ExceptionDetails = executeResults.ExceptionDetails }; if (hasData) resultsSetModel.ResultsData = executeResults.ResultsData; else resultsSetModel.ResultsData = executeResults.StatusMessage; ResultsSets.Add(resultsSetModel); i++; } IsExecutingQuery = false; IsCancelingQuery = false; SelectedResultsSetsIndex = 0; }
internal DbClientConnection(DbClient client, DbConnection connection) { Client = client; Connection = connection; }