public void GetDataFromMongoDB_AND_Condition_Success() { DBQuery query = new DBQuery() { Filters = new FilterQuery() { new Filter("name", "Khanin", FilterOperator.Equal, FilterCondition.AND), new Filter("address", "Pune", FilterOperator.Equal) } }; IDBService dbService = GetDBInstance(); dbService.Delete(CollectionName, query.Filters); JObject data = new JObject { ["name"] = "Khanin", ["address"] = "Pune" }; dbService.WriteData(CollectionName, data, false); data = new JObject { ["name"] = "Khanin", ["address"] = "Assam" }; dbService.WriteData(CollectionName, data, false); var dbData = dbService.Get(CollectionName, query); Assert.AreEqual(dbData.Count, 1); }
public void GetDataFromMongoDB_Projection_Success() { DBQuery query = new DBQuery() { Filters = new FilterQuery(), Fields = new List <Field>() { new Field("name"), new Field("address.pin") } }; IDBService dbService = GetDBInstance(); dbService.Delete(CollectionName, query.Filters); JObject data = new JObject { ["name"] = "X", ["age"] = 11, ["address"] = new JObject { ["pin"] = "123", ["street"] = "Baner" } }; dbService.WriteData(CollectionName, data, false); var dbData = dbService.Get(CollectionName, query); Assert.AreEqual(dbData[0].Count(), 2); Assert.AreNotEqual(dbData[0]["name"], null); Assert.AreNotEqual(dbData[0]["address"], null); Assert.AreNotEqual(dbData[0]["address"]["pin"], null); Assert.AreEqual(dbData[0]["age"], null); }
public void GetDataFromMongoDB_Success() { DBQuery query = new DBQuery() { Filters = new FilterQuery() { new Filter("name", "Khanin") } }; IDBService dbService = GetDBInstance(); dbService.Delete(CollectionName, query.Filters); JObject data = new JObject { ["name"] = "Khanin" }; dbService.WriteData(CollectionName, data, false); var dbData = dbService.Get(CollectionName, query); Assert.AreEqual(dbData.Count, 1); }
public void GetDataFromMongoDB_EQ_IgnoreCase_False_Operator_Success() { DBQuery query = new DBQuery() { Filters = new FilterQuery() { new Filter("name", "khanin", FilterOperator.Equal) } }; IDBService dbService = GetDBInstance(); dbService.Delete(CollectionName, query.Filters); JObject data = new JObject { ["name"] = "Khanin", ["age"] = 11 }; dbService.WriteData(CollectionName, data, false); data = new JObject { ["name"] = "khanin", ["age"] = 10 }; dbService.WriteData(CollectionName, data, false); var dbData = dbService.Get(CollectionName, query); Assert.AreEqual(dbData.Count, 1); }
public static byte[] GetContent(IDBService dbProxy, ILogger logger, string path) { string wwwrootpath = ApplicationConfig.AppWWWRootPath; JObject document = (JObject)dbProxy.Get(CommonConst.Collection.STATIC_CONTECT, GetFilter(path)).First; if (document != null) { var data = document[CommonConst.CommonField.DATA]; if (data != null) { if (CommonUtility.IsTextConent(document[CommonConst.CommonField.CONTENT_TYPE].ToString())) { return(Encoding.ASCII.GetBytes(data.ToString())); } else { byte[] dataByte = System.Convert.FromBase64String(data.ToString()); return(dataByte); } } } else { string filePath = string.Format("{0}{1}", wwwrootpath, path); if (File.Exists(filePath)) { return(File.ReadAllBytes(filePath)); } } return(null); }
public Logger(IHttpContextAccessor httpContextAccessor, IHttpContextProxy httpContextProxy, IDBService dbService) { _dbService = dbService; var loggerdb = CommonUtility.GetAppConfigValue("LoggerDb"); if (string.IsNullOrEmpty(loggerdb)) { loggerdb = "ZNxt_Log"; } _dbService.Init(loggerdb); _httpContextAccessor = httpContextAccessor; if (_httpContextAccessor.HttpContext != null) { _httpContextProxy = httpContextProxy; double.TryParse(_httpContextAccessor.HttpContext.Response.Headers[CommonConst.CommonField.CREATED_DATA_DATE_TIME], out double starttime); TransactionStartTime = starttime; TransactionId = _httpContextAccessor.HttpContext.Response.Headers[CommonConst.CommonField.TRANSACTION_ID]; } if (LogLevels == null) { LogLevels = new List <string>(); var levels = CommonUtility.GetAppConfigValue("LogLevel"); if (!string.IsNullOrEmpty(levels)) { LogLevels.AddRange(levels.Split(",").Select(f => f.Trim()).ToList()); } else { LogLevels.Add("Error"); } } }
public JObject SaveToDB(IDBService dbProxy, string fileName, string baseFolder, string collection, string updateFilter = null, string fileBase64Data = null) { string destination = string.Format("{0}\\{1}{2}", ApplicationConfig.AppTempFolderPath, CommonUtility.RandomString(5), fileName); if (!string.IsNullOrEmpty(Save(fileName, destination, fileBase64Data))) { FileInfo fi = new FileInfo(destination); var contentType = GetContentType(fi); var fileUploadData = JObjectHelper.GetJObjectDbDataFromFile(fi, contentType, ApplicationConfig.AppTempFolderPath, "ZNxtAppUpload", baseFolder); File.Delete(destination); if (string.IsNullOrEmpty(updateFilter)) { _logger.Debug(string.Format("SaveToDB Writing new file Name {0} ", fileName)); dbProxy.Write(collection, fileUploadData); return(dbProxy.FirstOrDefault(collection, CommonConst.CommonField.DISPLAY_ID, fileUploadData[CommonConst.CommonField.DISPLAY_ID].ToString())); } else { _logger.Debug(string.Format("SaveToDB updating file Name {0} ", fileName)); fileUploadData.Remove(CommonConst.CommonField.DISPLAY_ID); dbProxy.Write(collection, fileUploadData, updateFilter, true, MergeArrayHandling.Replace); return(dbProxy.Get(collection, updateFilter, new List <string>() { CommonConst.CommonField.DISPLAY_ID, CommonConst.CommonField.FILE_PATH }).First as JObject); } } return(null); }
public ConfigController(IResponseBuilder responseBuilder, IDBService dbService, IHttpContextProxy httpContextProxy, ILogger logger) { _responseBuilder = responseBuilder; _dbService = dbService; _httpContextProxy = httpContextProxy; _logger = logger; }
/// <summary> /// Konstruktor klasy LayoutService /// </summary> public LayoutService(IDBService dbService, IUmbracoHelperService umbHelperService, IAccountService accountService) { _umbracoHelper = new UmbracoHelper(UmbracoContext.Current); _dbService = dbService; _umbHelperService = umbHelperService; _accountService = accountService; }
private void HandleAuthTokenKey(IDBService dbProxy, IEncryption encryption) { if (AuthTokenHelper.IsAuthTokenExits(_httpProxy)) { var userId = AuthTokenHelper.GetUserId(_httpProxy, dbProxy, encryption); var userTempData = _httpProxy.GetTempValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (userTempData == null) { ISessionProvider session = new SessionProvider(_httpProxy, dbProxy, _logger); var userData = session.GetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (userData != null && userData.user_id != userId) { throw new Exception("Session user conflict with authtoken"); } if (userData == null) { userData = dbProxy.FirstOrDefault <UserModel>(CommonConst.Collection.USERS, CommonConst.CommonField.USER_ID, userId); if (userData == null) { throw new Exception("User not found for authtoken"); } } _httpProxy.SetTempValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY, userData); } } }
/// /// <param name="osoba"></param> /// <param name="service"></param> public string UnExecuteV(int id, IDBService service){ var osoba = new Vezbac(); osoba.ID = id; osoba.Role = 1; return service.DeleteTrening(osoba, trening); }
public static long GetID(Context Context, string TableName, int Count = 1) { IDBService oDBService = Kingdee.BOS.Contracts.ServiceFactory.GetService <IDBService>(Context); long[] oReturnIDS = oDBService.GetSequenceInt64(Context, TableName, Count).ToArray(); return(oReturnIDS[0]); }
private void WriteY() { m_reportsService = new ReportsService(); Type reportsServiceType = m_reportsService.GetType(); FieldInfo fi = reportsServiceType.GetField("m_dbService", BindingFlags.NonPublic | BindingFlags.Instance); m_dbService = (IDBService)fi.GetValue(m_reportsService); }
public AccountController(UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, IOptions <ApplicationConfigurations> options, IDBService dbs) { this._userManager = userManager; this._signInManager = signInManager; this._options = options; this._dbs = dbs; }
public static ICutting Create(HouseSpot houseSpot) { ICutting cutting; insService = new InsolationSection(); if (dbService == null) { dbService = new DBService(); } else { dbService.ResetSections(); } if (houseSpot.IsTower) { cutting = null; } else { cutting = new CuttingOrdinary(houseSpot, dbService, insService); } return(cutting); }
public AccountController ( IDBService _DBService ) { this._DBService = _DBService; }
public ProjectPageViewModel(IFrameNavigationService navigationService, IOpenFileDialogService openFileDialogService, ILogger loggerService, IDBService dBService) { _navigationService = navigationService; _openFileDialogService = openFileDialogService; _logService = loggerService; _dbService = dBService; OutputMessages = new ObservableCollection <OutputMessage>(); _project = ((NavigationServiceParameter)_navigationService.Parameter).ObjParam as Project; OutputMessages.Add(new OutputMessage { Message = _project.Name + " details", Level = "" }); ProjectName = _project.Name; Leader = _project.Leader; Goal = _project.Goal; Description = _project.Description; Plans = new ObservableCollection <byte[]>(); foreach (var item in _project.ProjectPlanByreArrays) { Plans.Add(item); } Reactions = new ObservableCollection <ReactionInfo>(); Modify = null; ConfigNavigationCommands(); Modify = new RelayCommand(ModifyCommand); AddPlan = new RelayCommand(AddPlanCommand); GetResources = new RelayCommand(GetResourcesCommand); ViewReaction = new RelayCommand <ReactionInfo>(ViewReactionCommand); DeleteReaction = new RelayCommand <ReactionInfo>(DeleteReactionCommand); SaveProject = new RelayCommand(SaveProjectCommand); }
public static string ServerSidePageHandler(string requestUriPath, IDBService dbProxy, IHttpContextProxy httpProxy, IViewEngine viewEngine, IActionExecuter actionExecuter, ILogger logger, Dictionary <string, dynamic> pageModel = null) { var fi = new FileInfo(requestUriPath); var data = StaticContentHandler.GetStringContent(dbProxy, logger, requestUriPath); if (data != null) { if (pageModel == null) { pageModel = new Dictionary <string, dynamic>(); } var folderPath = requestUriPath.Replace(fi.Name, ""); UpdateBaseModel(pageModel, requestUriPath, fi.Name); data = viewEngine.Compile(data, requestUriPath, ServerPageModelHelper.SetDefaultModel(dbProxy, httpProxy, logger, viewEngine, actionExecuter, pageModel, folderPath)); if (pageModel.ContainsKey(CommonConst.CommonValue.PAGE_TEMPLATE_PATH)) { FileInfo fiTemplete = new FileInfo(pageModel[CommonConst.CommonValue.PAGE_TEMPLATE_PATH]); var templateFileData = StaticContentHandler.GetStringContent(dbProxy, logger, pageModel[CommonConst.CommonValue.PAGE_TEMPLATE_PATH]); pageModel[CommonConst.CommonValue.RENDERBODY_DATA] = data; data = viewEngine.Compile(templateFileData, pageModel[CommonConst.CommonValue.PAGE_TEMPLATE_PATH], ServerPageModelHelper.SetDefaultModel(dbProxy, httpProxy, logger, viewEngine, actionExecuter, pageModel, pageModel[CommonConst.CommonValue.PAGE_TEMPLATE_PATH].Replace(fiTemplete.Name, ""))); } return(data); } else { return(string.Empty); } }
public RequestService(IHttpService httpService, IDBService dbService, IRequestDBService requestDBService, IOptions <ServicesOptions> options) { _httpService = httpService; _dbService = dbService; _requestDBService = requestDBService; _config = options.Value; }
public static ParamContainer CreateParamContainer(RoutingModel route, IHttpContextProxy httpProxy, ILogger loggerController, IActionExecuter actionExecuter) { var paramContainer = CreateParamContainer(loggerController, actionExecuter); ILogReader logReader = Logger.GetLogReader(); IDBService dbService = paramContainer.GetKey(CommonConst.CommonValue.PARAM_DBPROXY); IViewEngine viewEngine = paramContainer.GetKey(CommonConst.CommonValue.PARAM_VIEW_ENGINE); ResponseBuilder responseBuilder = new ResponseBuilder(loggerController, logReader, httpProxy); ISessionProvider sessionProvider = new SessionProvider(httpProxy, dbService, loggerController); IwwwrootContentHandler ContentHandler = new WwwrootContentHandler(httpProxy, dbService, viewEngine, actionExecuter, loggerController); (dbService as MongoDBService).User = () => { string result = string.Empty; var user = sessionProvider.GetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY); if (user != null) { result = string.Format("{0}::{1}", user.id, user.name); } return(result); }; (loggerController as Logger).DBProxy = dbService; paramContainer.AddKey(CommonConst.CommonValue.PARAM_ROUTE, () => { return(route); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_HTTPREQUESTPROXY, () => { return(httpProxy); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_RESPONBUILDER, () => { return(responseBuilder); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_SESSION_PROVIDER, () => { return(sessionProvider); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_CONTENT_HANDLER, () => { return(ContentHandler); }); return(paramContainer); }
public SQLBindingAsyncCollector(SQLBindingAttribute attribute, IDBService dbService, INameResolver nameResolver) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } if (dbService == null) { throw new ArgumentNullException(nameof(dbService)); } if (nameResolver == null) { throw new ArgumentNullException(nameof(nameResolver)); } this._attribute = attribute; this._nameResolver = nameResolver; this._dbService = dbService; this._dbService.SetConfiguration(new DBConfiguration() { ConnectionString = attribute.ConnectionString }); }
public WxController(ILogger <WxController> logger, IDBService dbService, IWxService wxService, WxContext wxContext) : base(logger, dbService) { this.wxContext = wxContext; this.wxService = wxService; }
public static ParamContainer CreateParamContainer(ILogger loggerController, IActionExecuter actionExecuter) { ILogReader logReader = Logger.GetLogReader(); IAppSettingService appSettingService = AppSettingService.Instance; ParamContainer paramContainer = new ParamContainer(); IDBService dbService = ApplicationConfig.DependencyResolver.GetInstance <IDBService>(); IPingService pingService = ApplicationConfig.DependencyResolver.GetInstance <IPingService>(); IViewEngine viewEngine = ApplicationConfig.DependencyResolver.GetInstance <IViewEngine>(); IEncryption encryption = ApplicationConfig.DependencyResolver.GetInstance <IEncryption>(); IKeyValueStorage keyValueStorage = ApplicationConfig.DependencyResolver.GetInstance <IKeyValueStorage>(); ISMSService smsService = new SMSService(loggerController, dbService, actionExecuter, viewEngine, paramContainer); IEmailService emailService = new EmailService(loggerController, dbService, actionExecuter, viewEngine, paramContainer); IOTPService otpService = new OTPService(loggerController, dbService, smsService, emailService, appSettingService); paramContainer.AddKey(CommonConst.CommonValue.PARAM_DBPROXY, () => { return(dbService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_LOGGER, () => { return(loggerController); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_ACTIONEXECUTER, () => { return(actionExecuter); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_PING_SERVICE, () => { return(pingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_PING_SERVICE, () => { return(pingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_APP_SETTING, () => { return(appSettingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_VIEW_ENGINE, () => { return(viewEngine); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_OTP_SERVICE, () => { return(otpService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_SMS_SERVICE, () => { return(smsService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_EMAIL_SERVICE, () => { return(emailService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_ENCRYPTION_SERVICE, () => { return(encryption); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_KEY_VALUE_STORAGE, () => { return(keyValueStorage); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_HTTP_CLIENT, () => { return(new HttpRestClient()); }); return(paramContainer); }
public string UnExecuteA(int id, IDBService service) { var osoba = new Admin(); osoba.ID = id; osoba.Role = 0; return service.DeleteTrening(osoba, trening); }
public MiscModel(IDBService _dbs) { this.Pages = _dbs.GetAllPages(); this.TagsSelect = _dbs.GetAllTags().Select(x => new SelectListItem { Value = x.TagId.ToString(), Text = x.Name }).ToList(); }
public void BeforeEachTest() { m_reportsService = new ReportsService.ReportsService(); Type reportsServiceType = m_reportsService.GetType(); FieldInfo fi = reportsServiceType.GetField("m_dbService", BindingFlags.NonPublic | BindingFlags.Instance); m_dbService = (IDBService)fi.GetValue(m_reportsService); }
public ReactionPageViewModel(IFrameNavigationService navigationService, IOpenFileDialogService openFileDialogService, ILogger loggerService, IDBService dBService) { _navigationService = navigationService; _openFileDialogService = openFileDialogService; _logService = loggerService; _dbService = dBService; // _reaction = (ReactionInfo)_navigationService.Parameter; _reaction = ((NavigationServiceParameter)_navigationService.Parameter).ObjParam as ReactionInfo; _reactionId = _reaction.ReactionID; ConfigNavigationCommands(); FinishSketchEnabled = null; FinishSketch = new RelayCommand(FinishSketchCommand); SketchAvailable = null; StartingMaterial = new ObservableCollection <StartingMaterial>(); Reagents = new ObservableCollection <Reagent>(); Solvents = new ObservableCollection <Solvent>(); Products = new ObservableCollection <Product>(); ObservationImgsByteArray = new ObservableCollection <byte[]>(); ObservationImgsFilePaths = new ObservableCollection <string>(); GetResources = new RelayCommand(GetResourcesCommand); SelectObservationImg = new RelayCommand(SelectObservationImgCommand); DeleteObservationImg = new RelayCommand <string>(DeleteObservationImgCommand); SaveReaction = new RelayCommand(SaveReactionCommandAsync); OutputMessages = new ObservableCollection <OutputMessage>(); }
/// /// <param name="adminId"></param> /// <param name="service"></param> /// <param name="trening"></param> public string AddTreningAdmin(int adminId, IDBService service, Trening trening){ string message = ""; undoRedo.InsertInUnDoRedoForAdd(adminId, 0, service, trening, out message); return message; //return service.AddTreningAdmin(adminId, trening); }
/// <summary> /// 生成id和编码 /// </summary> /// <param name="bardCodes"></param> private void MakeBillNo(List <DynamicObject> lstDynamicObj) { IDBService service = Kingdee.BOS.Contracts.ServiceFactory.GetService <IDBService>(this.Context); long[] ids = service.GetSequenceInt64(Context, "JN_T_SAL_ForecastChange", lstDynamicObj.Count()).ToArray(); Dictionary <string, object> options = new Dictionary <string, object>(); options["CodeTime"] = 1; options["UpdateMaxNum"] = 1; List <BillNoInfo> billNos = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.GetBillNo(this.Context, "JN_YDL_SAL_ForecastChange", lstDynamicObj.ToArray(), options); for (int i = 0; i < billNos.Count; i++) { lstDynamicObj[i]["FBillNo"] = billNos[i].BillNo; lstDynamicObj[i]["Id"] = ids[i]; var entitys = lstDynamicObj[i]["FEntity"] as DynamicObjectCollection; if (entitys != null && entitys.Count > 0) { long[] entryIds = DBServiceHelper.GetSequenceInt64(this.Context, "JN_T_SAL_ForecastChangeEntry", entitys.Count()).ToArray(); for (int j = 0; j < entitys.Count; j++) { entitys[j]["Id"] = entryIds[j]; } } } }
/// /// <param name="osoba"></param> /// <param name="trening"></param> /// <param name="service"></param> public string DeleteTrening(Osoba osoba, Trening trening, IDBService service){ string message = ""; undoRedo.InsertInUnDoRedoForDelete(osoba, service, trening, out message); return message; //return service.DeleteTrening(osoba, trening); }
private JObject GetFileData(string fileHash, IDBService dbProxy) { JObject filter = new JObject(); filter[ImageProcessor.FILE_HASH] = fileHash; return(dbProxy.FirstOrDefault(ImageProcessor.MYPHOTO_COLLECTION, filter.ToString())); }
/// /// <param name="vezbacId"></param> /// <param name="service"></param> /// <param name="trening"></param> public string AddTreningVezbac(int vezbacId, IDBService service, Trening trening){ string message = ""; undoRedo.InsertInUnDoRedoForAdd(vezbacId, 1, service, trening, out message); return message; //return service.AddTreningVezbac(vezbacId, trening); }
public void SetDBService(IDBService dbService) { DBService = dbService; }
public IngredientController(IDBService<CupcakeModel, IngredientModel> service) { _service = service; }