Пример #1
0
 public GraphQLService(AppEngine appEngine, GraphQLSettings settings, CRUDService service, ILogger logger)
 {
     this.Settings    = settings;
     this.appEngine   = appEngine;
     this.CrudService = service;
     this.logger      = logger;
 }
Пример #2
0
 public JsDispatcher(EntityService entityService, CRUDService crudService)
 {
     {
         this.entityService = entityService;
         this.crudService   = crudService;
     }
 }
Пример #3
0
 public UsersController(
     ILogger <UsersController> logger,
     CRUDService <UsersModel, Users> service
     )
     : base(logger, service)
 {
 }
Пример #4
0
        public RawUserStore(AppEngine appEngine, ILogger logger, CRUDService service)
        {
            this.appEngine = appEngine;
            this.logger    = logger;
            this.service   = service;

            InitData().Wait();
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TagEditViewModel"/> class.
 /// </summary>
 /// <param name="dialogService">Dialog service dependency.</param>
 /// <param name="tagService">Tag service dependency.</param>
 /// <param name="tag">Tag to edit. Null means new tag creation.</param>
 public TagEditViewModel(DialogService dialogService, CRUDService <Tag> tagService, TagEdit?tag = null)
     : base(dialogService)
 {
     Tag = tag ?? new TagEdit();
     Tag.PropertyChanged += Tag_PropertyChanged;
     AllTags              = tagService.GetAll();
     AddIconCommand       = new AsyncDelegateCommand(AddIconAsync);
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GarnishSelectViewModel"/> class.
 /// </summary>
 /// <param name="dialogService">Dialog service dependency.</param>
 /// <param name="garnishService">Tag service dependency.</param>
 /// <param name="selectedGarnishes">Loc25 provider dependency.</param>
 public GarnishSelectViewModel(DialogService dialogService,
                               CRUDService <Recipe> garnishService,
                               IEnumerable <RecipeEdit> selectedGarnishes)
     : base(dialogService)
 {
     AllGarnishes = garnishService.GetMapped <RecipeEdit>(x => x.Tags.Any(t => t.Name == "Гарниры")).OrderBy(x => x.Name).ToList();
     SelectedItems.AddRange(AllGarnishes.Intersect(selectedGarnishes));
 }
Пример #7
0
        public GraphQLService(AppEngine appEngine, GraphQLSettings settings, CRUDService service, ILogger logger)
        {
            this.Settings    = settings;
            this.appEngine   = appEngine;
            this.CrudService = service;
            this.logger      = logger;
            var lambda = appEngine.Lambdas.Where(x => x.Name == "Entity Validation").First() as EntityValidation;

            Collections = lambda.GetCollections();
        }
Пример #8
0
    public void registerProductType()
    {
        if (proxy == null)
        {
            proxy = GigaSpacesFactory.FindSpace("/./xapTutorialSpace");

            service      = new CRUDService(proxy);
            spaceUtility = new SpaceUtility(proxy);
            userUtil     = new UserUtil(proxy);
        }
    }
Пример #9
0
        static void Main(string[] args)
        {
            CRUDService service = new CRUDService();
            var persons = service.GetAllPeople();
            var person = persons.ElementAt(0);

            person.FirstName = "Алена";
            person.PhoneNumbers.ElementAt(0).Number = "some";

            service.UpdatePerson(person);
        }
Пример #10
0
        public ActionResult <int> Add(Users param)
        {
            CRUDService crus = new CRUDService();

            Logger.Info(JsonConvert.SerializeObject(param));//此处调用日志记录函数记录日志
            Logger.Error("错误");
            Logger.Warn("警告");
            var ss = crus.QueryS();
            int s  = crus.Add(param);

            return(s);
        }
Пример #11
0
    /// <summary>
    /// Initializes a new instance of the <see cref="TagSelectViewModel"/> class.
    /// </summary>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="tagService">Tag service dependency.</param>
    /// <param name="selectedTags">Alredy existing tags for editing.</param>
    /// <param name="allTags">All tags to select from.</param>
    public TagSelectViewModel(DialogService dialogService,
                              CRUDService <Tag> tagService,
                              IEnumerable <TagEdit> selectedTags,
                              IList <TagEdit>?allTags = null)
        : base(dialogService)
    {
        this.tagService = tagService;
        AddTagCommand   = new DelegateCommand(AddTagAsync);
        AllTags         = new ObservableCollection <TagEdit>(allTags ?? tagService.GetProjected <TagEdit>());
        SelectedItems.AddRange(AllTags.Intersect(selectedTags));

        AllTags.CollectionChanged += AllTags_CollectionChanged;
    }
Пример #12
0
        private void LoadPluginSettings(List <Type> pluginTypes, IConfigurationRoot configuration, IServiceCollection services)
        {
            _logger.LogDebug($"LoadPluginSettings");

            MongoSettings instance   = MongoSettings.GetMongoSettings(configuration);
            var           tmpService = new CRUDService(new MongoService(instance, _logger), instance, this);

            foreach (var plugin in pluginTypes)
            {
                _logger.LogDebug($"checking {plugin.FullName}");
                Type confitf = plugin.GetInterface("IConfigurablePlugin`1");//TODO: remove hardcoded reference to generic
                if (confitf != null)
                {
                    _logger.LogDebug($" {plugin.FullName} need a configuration");
                    Type confType = confitf.GetGenericArguments()[0];

                    ItemList confItem = tmpService.Query("_configuration", new DataQuery()
                    {
                        PageNumber = 1,
                        PageSize   = 1,
                        RawQuery   = @"{""plugin_name"":""" + plugin.FullName + @"""}"
                    });

                    JObject confToSave = null;

                    if (confItem.TotalCount == 0)
                    {
                        _logger.LogDebug($" {plugin.FullName} no persisted configuration found. Using default");
                        confToSave = new JObject
                        {
                            ["plugin_name"] = plugin.FullName,
                            ["data"]        = JToken.FromObject(Activator.CreateInstance(confType))
                        };
                        tmpService.Insert("_configuration", confToSave);
                        _logger.LogDebug($" {plugin.FullName} default config saved to database");
                    }
                    else
                    {
                        confToSave = confItem.Items.First as JObject;
                        _logger.LogDebug($" {plugin.FullName} configuration found");
                    }

                    object objData = confToSave["data"].ToObject(confType);

                    _logger.LogDebug($" {plugin.FullName} configuration added to container");
                    services.AddSingleton(confType, objData);
                }
            }
        }
Пример #13
0
    /// <summary>
    /// Initializes a new instance of the <see cref="WeekSettingsViewModel"/> class.
    /// </summary>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="regionManager">Region manager for Prism navigation.</param>
    /// <param name="tagService">Tag service dependency.</param>
    /// <param name="container">IoC container.</param>
    /// <param name="recipeService">Recipe service dependency.</param>
    /// <param name="localization">Localization provider dependency.</param>
    /// <param name="mapper">Mapper dependency.</param>
    public WeekSettingsViewModel(DialogService dialogService,
                                 IRegionManager regionManager,
                                 CRUDService <Tag> tagService,
                                 IContainerExtension container,
                                 RecipeService recipeService,
                                 ILocalization localization,
                                 IMapper mapper)
    {
        this.dialogService = dialogService;
        this.regionManager = regionManager;
        this.tagService    = tagService;
        this.container     = container;
        this.recipeService = recipeService;
        this.localization  = localization;
        this.mapper        = mapper;

        Days = new List <DayPlan>()
        {
            new DayPlan(),
            new DayPlan {
                DayName = localization["Monday_Short"], DayOfWeek = DayOfWeek.Monday
            },
            new DayPlan {
                DayName = localization["Tuesday_Short"], DayOfWeek = DayOfWeek.Tuesday
            },
            new DayPlan {
                DayName = localization["Wednesday_Short"], DayOfWeek = DayOfWeek.Wednesday
            },
            new DayPlan {
                DayName = localization["Thursday_Short"], DayOfWeek = DayOfWeek.Thursday
            },
            new DayPlan {
                DayName = localization["Friday_Short"], DayOfWeek = DayOfWeek.Friday
            },
            new DayPlan {
                DayName = localization["Saturday_Short"], DayOfWeek = DayOfWeek.Saturday
            },
            new DayPlan {
                DayName = localization["Sunday_Short"], DayOfWeek = DayOfWeek.Sunday
            }
        };

        Days[0].PropertyChanged += OnHeaderValueChanged;
        AddMainIngredientCommand = new AsyncDelegateCommand <DayPlan>(AddMainIngredientAsync);
        AddDishTypesCommand      = new AsyncDelegateCommand <DayPlan>(AddDishTypesAsync);
        AddCalorieTypesCommand   = new AsyncDelegateCommand <DayPlan>(AddCalorieTypesAsync);
        CloseCommand             = new DelegateCommand(Close, CanClose);
        OkCommand = new DelegateCommand(Ok);
    }
Пример #14
0
        public HttpResponseMessage GetAplikacije(string uporabnikID)
        {
            CRUDService         service = new CRUDService();
            HttpResponseMessage response;

            try
            {
                List <Aplikacija> dto = service.GetAplikacije(uporabnikID);
                response = Request.CreateResponse(HttpStatusCode.OK, dto);
            }
            catch (ApplicationException ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }

            return(response);
        }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TagListViewModel"/> class.
 /// </summary>
 /// <param name="regionManager">Region manager for Prism navigation.</param>
 /// <param name="dialogService">Dialog service dependency.</param>
 /// <param name="tagService">Tag service dependency.</param>
 /// <param name="mapper">Mapper dependency.</param>
 /// <param name="localization">Localization provider dependency.</param>
 public TagListViewModel(IRegionManager regionManager,
                         DialogService dialogService,
                         CRUDService <Tag> tagService,
                         IMapper mapper,
                         ILocalization localization)
 {
     this.regionManager = regionManager;
     this.dialogService = dialogService;
     this.tagService    = tagService;
     this.mapper        = mapper;
     this.localization  = localization;
     LoadedCommand      = new AsyncDelegateCommand(OnLoaded, executeOnce: true);
     AddTagCommand      = new AsyncDelegateCommand(AddTagAsync);
     DeleteTagCommand   = new AsyncDelegateCommand <Guid>(DeleteTagAsync);
     ViewTagCommand     = new DelegateCommand <TagEdit>(ViewTag);
     EditTagCommand     = new AsyncDelegateCommand <TagEdit>(EditTagAsync);
 }
Пример #16
0
        public HttpResponseMessage GetPravice(int aplikacijaKLJ, int vlogaKLJ)
        {
            CRUDService         service = new CRUDService();
            HttpResponseMessage response;

            try
            {
                List <DVlogePravice> dto = service.GetPravice(aplikacijaKLJ, vlogaKLJ);
                response = Request.CreateResponse(HttpStatusCode.OK, dto);
            }catch (ApplicationException ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }


            return(response);
        }
Пример #17
0
        public HttpResponseMessage Save([FromBody] DVlogePravice dVlogePravice)
        {
            CRUDService         service  = new CRUDService();
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
            Entities            db       = new Entities();

            try
            {
                service.Save(CRUDService.ParsePravice(dVlogePravice), db.Pravices, dVlogePravice.PravicaKLJ);
            }
            catch (ApplicationException ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }


            return(response);
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="RecipeIngredientEditViewModel"/> class.
    /// </summary>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="ingredientService">Ingredient service dependency.</param>
    /// <param name="measureUnitService">Provider for a list of measurement units.</param>
    /// <param name="ingredient">Ingredient to edit.</param>
    public RecipeIngredientEditViewModel(DialogService dialogService,
                                         CRUDService <Ingredient> ingredientService,
                                         CRUDService <MeasureUnit> measureUnitService,
                                         RecipeIngredientEdit ingredient)
        : base(dialogService)
    {
        this.dialogService     = dialogService;
        this.ingredientService = ingredientService;

        Ingredient       = ingredient;
        MeasurementUnits = measureUnitService.GetAll();

        AddMultipleCommand      = new DelegateCommand(AddMultiple, canExecute: CanOk);
        RemoveIngredientCommand = new DelegateCommand <RecipeIngredientEdit>(RemoveIngredient);
        CreateIngredientCommand = new AsyncDelegateCommand(CreateIngredientAsync);

        AllIngredients = ingredientService.GetProjected <IngredientEdit>();
    }
Пример #19
0
        public HttpResponseMessage Save([FromBody] Uporabniki uporabniki)
        {
            CRUDService         service  = new CRUDService();
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
            Entities            db       = new Entities();

            try
            {
                service.Save(uporabniki, db.Uporabnikis, uporabniki.UporabnikKLJ);
            }
            catch (ApplicationException ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }


            return(response);
        }
Пример #20
0
        public HttpResponseMessage Get(string searchString, string asc, int pageIndex, int pageSizeSelected, string sortKey)
        {
            DResponse           dto     = new DResponse();
            CRUDService         service = new CRUDService();
            HttpResponseMessage response;

            try
            {
                dto      = service.GetDResponse(searchString, pageIndex, pageSizeSelected, sortKey, asc);
                response = Request.CreateResponse(HttpStatusCode.OK, dto);
            }
            catch (ApplicationException ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }

            return(response);
        }
Пример #21
0
        public HttpResponseMessage GetSifranti(string id)
        {
            CRUDService         service = new CRUDService();
            HttpResponseMessage response;

            try
            {
                List <DSifranti> dto = service.GetDSifranti(id);
                response = Request.CreateResponse(HttpStatusCode.OK, dto);
            }
            catch (ApplicationException ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }


            return(response);
        }
Пример #22
0
        public HttpResponseMessage Delete([FromBody] Aplikacija aplikacija)
        {
            CRUDService         service  = new CRUDService();
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
            Entities            db       = new Entities();

            try
            {
                service.Delete(aplikacija, db.Aplikacijas);
            }
            catch (ApplicationException ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
            }


            return(response);
        }
Пример #23
0
        public static async Task <IActionResult> GetClassByIdUT(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "UT/Class/{classId}")] HttpRequest req,
            [CosmosDB(ConnectionStringSetting = "cosmos-bl-tutorial-serverless")] DocumentClient documentClient,
            string classId,
            ILogger log)
        {
            try
            {
                var crudService = new CRUDService(new ClassRepository(documentClient));

                Dictionary <string, string> pk = null; // new Dictionary<string, string> { { "ClassCode", "test-class-code" } };
                var classById = await crudService.GetClassById(classId, pk);

                return(new OkObjectResult(classById));
            } catch (Exception e)
            {
                return(new BadRequestObjectResult(e.Message));
            }
        }
Пример #24
0
    /// <summary>
    /// Initializes a new instance of the <see cref="IngredientEditViewModel"/> class.
    /// </summary>
    /// <param name="ingredientService">Ingredient service dependency.</param>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="localization">Localization service dependency.</param>
    /// <param name="eventAggregator">Prism event aggregator.</param>
    /// <param name="ingredient">Ingredient to edit. Null means new ingredient.</param>
    public IngredientEditViewModel(CRUDService <Ingredient> ingredientService,
                                   DialogService dialogService,
                                   ILocalization localization,
                                   IEventAggregator eventAggregator,
                                   IngredientEdit?ingredient = null)
        : base(dialogService)
    {
        this.ingredientService = ingredientService;
        this.localization      = localization;
        this.eventAggregator   = eventAggregator;
        Ingredient             = ingredient ?? new IngredientEdit();

        AllIngredientNames = ingredientService.GetProperty(x => x.Name, filter: x => x.Name != null)
                             .ConvertAll(x => x !);

        LoadedCommand           = new DelegateCommand(OnLoaded);
        DeleteIngredientCommand = new DelegateCommand <Guid>(DeleteIngredientAsync);
        IngredientTypes         = Enum.GetValues(typeof(IngredientType)).Cast <IngredientType>().ToList();
    }
Пример #25
0
    /// <summary>
    /// Initializes a new instance of the <see cref="IngredientListViewModel"/> class.
    /// </summary>
    /// <param name="regionManager">Region manager for Prism navigation.</param>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="ingredientService">Ingredient service dependency.</param>
    /// <param name="eventAggregator">Prism event aggregator dependency.</param>
    /// <param name="mapper">Mapper dependency.</param>
    /// <param name="localization">Localization provider dependency.</param>
    public IngredientListViewModel(IRegionManager regionManager,
                                   DialogService dialogService,
                                   CRUDService <Ingredient> ingredientService,
                                   IEventAggregator eventAggregator,
                                   IMapper mapper,
                                   ILocalization localization)
    {
        this.regionManager     = regionManager;
        this.dialogService     = dialogService;
        this.ingredientService = ingredientService;
        this.eventAggregator   = eventAggregator;
        this.mapper            = mapper;
        this.localization      = localization;
        LoadedCommand          = new AsyncDelegateCommand(OnLoaded, executeOnce: true);
        AddIngredientCommand   = new AsyncDelegateCommand(AddIngredientAsync);
        EditIngredientCommand  = new AsyncDelegateCommand <IngredientEdit>(EditIngredientAsync);
        ViewIngredientCommand  = new DelegateCommand <IngredientEdit>(ViewIngredient);

        eventAggregator.GetEvent <IngredientDeletedEvent>().Subscribe(OnIngredientDeleted);
    }
Пример #26
0
    public void registerProductType()
    {
        if (proxy == null)
        {
            // Instatiate the embedded space
            proxy = GigaSpacesFactory.FindSpace("/./xapTutorialSpace");;

            spaceUtility = new SpaceUtility(proxy);
            userUtil     = new UserUtil(proxy);
            queryService = new QueryService(proxy);
            service      = new CRUDService(proxy);

            // Register the Space Document
        }

        // Create a user
        userUtil.loadUsers();

        service.registerProductType();
        service.createDocumemt();
    }
Пример #27
0
        public async Task GetClassByIdExists_ReturnClass(string classId)
        {
            // Arrange
            var repo = new Mock <IDocumentDBRepository <Class> >();

            IEnumerable <Class> classes = new List <Class>
            {
                { new Class()
                  {
                      Id = "class-1", Description = "abcd", ClassCode = "test-class-1"
                  } },
                { new Class()
                  {
                      Id = "class-2", Description = "xyz0", ClassCode = "test-class-2"
                  } }
            };

            var classData = classes.Where(o => o.Id == classId).FirstOrDefault();
            Dictionary <string, string> pk = null;

            repo.Setup(c => c.GetByIdAsync(
                           It.IsAny <string>(),
                           It.IsAny <Dictionary <string, string> >()
                           )).Returns(
                Task.FromResult(classData)
                );

            var svc = new CRUDService(repo.Object);

            // Act
            var classById = await svc.GetClassById(classId, pk);

            var actual = classById;

            // Assert
            Assert.Equal(classData.Description, actual.Description);
            Assert.Equal(classData.ClassCode, actual.ClassCode);
        }
Пример #28
0
        private void SetConfiguration(Plugin plugin, CRUDService crudService)
        {
            Type confitf = plugin.GetType().GetInterface("IConfigurablePlugin`1");

            if (confitf != null)
            {
                Type confType   = confitf.GetGenericArguments()[0];
                Type pluginType = plugin.GetType();

                ItemList confItem = crudService.Query("_configuration", new DataQuery()
                {
                    PageNumber = 1,
                    PageSize   = 1,
                    RawQuery   = @"{""plugin_name"":""" + pluginType.FullName + @"""}"
                });

                JObject confToSave = null;

                if (confItem.TotalCount == 0)
                {
                    confToSave = new JObject
                    {
                        ["plugin_name"] = plugin.GetType().FullName,
                        ["data"]        = JToken.FromObject(pluginType.GetMethod("GetDefaultConfig").Invoke(plugin, new object[] { }))
                    };
                    crudService.Insert("_configuration", confToSave);
                }
                else
                {
                    confToSave = confItem.Items.First as JObject;
                }

                object objData = confToSave["data"].ToObject(confType);

                pluginType.GetMethod("SetActualConfig").Invoke(plugin, new object[] { objData });
            }
        }
Пример #29
0
        public override void ConfigureServices(IServiceCollection services)
        {
            base.ConfigureServices(services);

            services.AddOptions();

            Logger.LogInformation(configuration["MongoSettings:ConnectionString"]);


            var envConnectionString = Environment.GetEnvironmentVariable("MongoSettings:ConnectionString") ?? Environment.GetEnvironmentVariable("MongoSettingsConnectionString") ?? configuration["MongoSettings:ConnectionString"];
            var envDBName           = Environment.GetEnvironmentVariable("MongoSettings:DBName") ?? Environment.GetEnvironmentVariable("MongoSettingsDBName") ?? configuration["MongoSettings:DBName"];



            MongoSettings instance = new MongoSettings
            {
                ConnectionString = envConnectionString,
                DBName           = envDBName
            };

            IOptions <MongoSettings> settingsOptions = Options.Create <MongoSettings>(instance);
            MongoService             mongoService    = new MongoService(settingsOptions, Logger);
            CRUDService crudService = new CRUDService(mongoService, settingsOptions);

            Engine.Service = crudService;

            services.AddSingleton <MongoService>(mongoService);
            services.AddSingleton <CRUDService>(crudService);
            services.AddSingleton <AppEngine>(Engine);
            services.AddHttpContextAccessor();

            crudService.EnsureCollection("_configuration");

            Engine.Plugins.ForEach(x => SetConfiguration(x, crudService));

            crudService.EnsureCollection("_schema");
        }
Пример #30
0
 public void SetCRUDService(CRUDService service)
 {
     this.service = service;
 }
Пример #31
0
 public JSPostSaveLambda(EntityService entityService, CRUDService crudService) : base(entityService, crudService)
 {
 }
Пример #32
0
    public void registerProductType()
    {
        if ( proxy == null)
        {
            // Instatiate the embedded space
            proxy =   GigaSpacesFactory.FindSpace("/./xapTutorialSpace");;

            spaceUtility = new SpaceUtility (proxy);
            userUtil = new UserUtil(proxy);
            queryService = new QueryService(proxy);
            service = new CRUDService(proxy);

            // Register the Space Document

        }

        // Create a user
        userUtil.loadUsers();

        service.registerProductType();
        service.createDocumemt();
    }
Пример #33
0
    public void registerProductType()
    {
        if (proxy == null)
          {
          proxy = GigaSpacesFactory.FindSpace("/./xapTutorialSpace");

          service = new CRUDService(proxy);
          spaceUtility = new SpaceUtility(proxy);
          userUtil = new UserUtil(proxy);
          }
    }