Exemplo n.º 1
0
        public static async Task <StoryPresentation> GetPresentationAsync(this SCLM sclm, int presentationId)
        {
            StoryPresentation presentation = await sclm.GETAsync <StoryPresentation>(new Uri($"{sclm.GetEndpoint(api)}{Version}/{PathPresentations}/{presentationId}", UriKind.Absolute), CancellationToken.None);

            presentation._sclm = sclm;
            return(presentation);
        }
Exemplo n.º 2
0
        public async void FindBrackets(int uc)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var storyTable = await Tables.GetTableAsync(sclm);

            Profile profile = await storyTable.InsertAsync(Profile.CreateProfile());

            Profile profile1 = await storyTable.InsertAsync(Profile.CreateProfile1());

            Profile profile2 = await storyTable.InsertAsync(Profile.CreateProfile2());

            Profile profile3 = await storyTable.InsertAsync(Profile.CreateProfile3());

            Profile profile4 = await storyTable.InsertAsync(Profile.CreateProfile4());

            List <Profile> profiles = new List <Profile>(await storyTable.InsertAsync(Profile.CreateProfiles()));

            //поле "name" начинается с символов "T" или "S" при этом возраст должен быть равен 22
            var results = storyTable.FindAsync("([name][sw][\"S\"][or][name][sw][\"T\"])[and][age][eq][22]", "age", 1, 0, 100).Result;

            Assert.True(results.Count() > 0);

            //Выбрать всех с возрастом НЕ в интервале [25,30] и с именами на "S" и "Т"
            results = storyTable.FindAsync("([age][lt][22][or][age][gt][30])[and]([name][sw][\"S\"][or][name][sw][\"T\"])", "age", 1, 0, 100).Result;
            // Assert.True(results.Count() > 0);
        }
Exemplo n.º 3
0
        private static IServiceCollection ConfigureServices()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

            services.AddLogging(s => s.AddConsole());

            services.AddOptions();
            services.Configure <StoryOptions>(_configuration.GetSection("Story"));
            services.Configure <SyncOptions>(_configuration.GetSection("Sync"));

            services.AddSingleton(s =>
            {
                var options = s.GetService <IOptionsSnapshot <StoryOptions> >().Value;
                var sclm    = new SCLM();
                sclm.SetEndpoint("content", options.AnalyticsEndpoint);
                return(sclm);
            });

            services.AddTransient <CustomEventsSynchronizer>();
            services.AddTransient <KpipSynchronizer>();
            services.AddTransient <KpisSynchronizer>();
            services.AddTransient <SessionsSynchronizer>();
            services.AddTransient <SlidesSynchronizer>();
            return(services);
        }
 protected SynchronizerBase(SCLM sclm, IOptionsSnapshot <SyncOptions> options,
                            ILogger logger)
 {
     Sclm    = sclm ?? throw new ArgumentNullException(nameof(sclm));
     Options = options.Value ?? throw new ArgumentNullException(nameof(options));
     Logger  = logger ?? throw new ArgumentException(nameof(logger));
 }
Exemplo n.º 5
0
        public static async Task <StoryToken> AuthAsync(this SCLM sclm, string clientId, string secret, string refreshToken)
        {
            StoryToken token = await AuthAsync(sclm.GetEndpoint(auth), clientId, secret, refreshToken);

            SetDecorator(sclm, clientId, secret, token);
            return(token);
        }
Exemplo n.º 6
0
 internal static void SetDecorator(SCLM sclm, string clientId, string secret, StoryToken token) =>
 sclm.AddHttpDecorator <OAuthDecorator>(new OAuthDecorator
 {
     ClientId = clientId,
     Secret   = secret,
     Token    = token
 });
Exemplo n.º 7
0
        public async Task ServiceLogin()
        {
            SCLM sclm = new SCLM();

            sclm.SetEndpoint("auth", Settings.AuthEndpoint);
            StoryToken token = await sclm.AuthAsync(Settings.ServiceClientId, Settings.ServiceSecret);

            Assert.NotNull(token);
            Assert.NotNull(token.AccessToken);

            Assert.Null(token.RefreshToken);

            IEnumerable <object> objects = await sclm.GETAsync <IEnumerable <object> >(new Uri($"{sclm.GetEndpoint("api")}/v1/users/"), CancellationToken.None);

            Assert.NotNull(objects);

            await Task.Delay(5000);

            objects = await sclm.GETAsync <IEnumerable <object> >(new Uri($"{sclm.GetEndpoint("api")}/v1/users/"), CancellationToken.None);

            Assert.NotNull(objects);

            await Assert.ThrowsAsync <Exception>(async() => await sclm.AuthAsync(Settings.ServiceClientId, null));

            await Assert.ThrowsAsync <Exception>(async() => await sclm.AuthAsync(null, Settings.ServiceSecret));

            await Assert.ThrowsAsync <Exception>(async() => await sclm.AuthAsync(Settings.ServiceClientId + "sdf", Settings.ServiceSecret));

            await Assert.ThrowsAsync <Exception>(async() => await sclm.AuthAsync(Settings.ServiceClientId, Settings.ServiceSecret + "sadf"));

            await Assert.ThrowsAsync <Exception>(async() => await sclm.AuthAsync(Settings.ServiceClientId + "sdf", Settings.ServiceSecret + "we"));
        }
Exemplo n.º 8
0
        public static async Task <StoryToken> AuthAsync(this SCLM sclm, string clientId, string secret, string username = null, string password = null)
        {
            StoryToken token = await AuthAsync(sclm.GetEndpoint(auth), clientId, secret, username, password);

            SetDecorator(sclm, clientId, secret, token);
            return(token);
        }
Exemplo n.º 9
0
        public async Task UserLogin()
        {
            SCLM       sclm  = new SCLM();
            StoryToken token = await sclm.AuthAsync(Settings.UserClientId, Settings.UserSecret, Settings.Username, Settings.Password);

            Assert.NotNull(token);
            Assert.NotNull(token.AccessToken);
            Assert.NotNull(token.RefreshToken);

            IEnumerable <object> objects = await sclm.GETAsync <IEnumerable <object> >(new Uri($"{sclm.GetEndpoint("api")}/v1/users/"), CancellationToken.None);

            Assert.NotNull(objects);

            await Task.Delay(5000);

            objects = await sclm.GETAsync <IEnumerable <object> >(new Uri($"{sclm.GetEndpoint("api")}/v1/users/"), CancellationToken.None);

            Assert.NotNull(objects);

            await Assert.ThrowsAsync <Exception>(() => sclm.AuthAsync(Settings.UserClientId, Settings.UserSecret, Settings.Username, null));

            await Assert.ThrowsAsync <Exception>(() => sclm.AuthAsync(Settings.UserClientId, Settings.UserSecret, null, Settings.Password));

            await Assert.ThrowsAsync <Exception>(() => sclm.AuthAsync(Settings.UserClientId, Settings.UserSecret, null, null));

            await Assert.ThrowsAsync <Exception>(() => sclm.AuthAsync(Settings.UserClientId, null, Settings.Username, Settings.Password));

            await Assert.ThrowsAsync <Exception>(() => sclm.AuthAsync(Settings.UserClientId, Settings.UserSecret + "w", Settings.Username, Settings.Password));

            await Assert.ThrowsAsync <Exception>(() => sclm.AuthAsync(Settings.UserClientId + "s", Settings.UserSecret, Settings.Username, Settings.Password));

            await Assert.ThrowsAsync <Exception>(() => sclm.AuthAsync(null, Settings.UserSecret, Settings.Username, Settings.Password));
        }
Exemplo n.º 10
0
        public static async Task <StoryUser> GetUserAsync(this SCLM sclm, string userId)
        {
            StoryUser user = await sclm.GETAsync <StoryUser>(new Uri($"{sclm.GetEndpoint(api)}/{Version}/{Path}/{userId}", UriKind.Absolute), CancellationToken.None);

            user.Context = sclm;
            return(user);
        }
Exemplo n.º 11
0
        public static async Task <StoryClient> GetClientAsync(this SCLM sclm, int clientId)
        {
            StoryClient client = await sclm.GETAsync <StoryClient>(new Uri($"{sclm.GetEndpoint(api)}{Version}/{PathClients}/{clientId}", UriKind.Absolute), CancellationToken.None);

            client._sclm = sclm;
            return(client);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Получитьтаблицу клиента по идентификатору.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sclm"></param>
        /// <param name="tableId"></param>
        /// <returns></returns>
        public static async Task <StoryTable <T> > GetTableAsync <T>(this SCLM sclm, int tableId) where T : class, new()
        {
            StoryTable <T> table = await sclm.GETAsync <StoryTable <T> >(new Uri($"{sclm.GetEndpoint(api)}{Version}/{Path}/{tableId}", UriKind.Absolute), CancellationToken.None);

            table._sclm = sclm;
            return(table);
        }
Exemplo n.º 13
0
        public async void GetPresentaionFromClient(int uc, int presentationId)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var presentation = await sclm.GetPresentationAsync(presentationId);

            Assert.NotNull(presentation);
        }
Exemplo n.º 14
0
        public async void Exists(int uc, string username)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var user = await sclm.UserExistsAsync(username);

            Assert.NotNull(user);
        }
Exemplo n.º 15
0
        public async void GetMediafile(int uc, int mediafileId)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var result = await sclm.GetMediafileAsync(mediafileId);

            Assert.NotNull(result);
        }
Exemplo n.º 16
0
        public async void GetClients(int uc)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var clients = await sclm.GetClientsAsync();

            Assert.True(clients.Count() > 0);
        }
Exemplo n.º 17
0
        public async void GetSlide(int uc, int slideId)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var result = await sclm.GetSlideAsync(slideId);

            Assert.NotNull(result);
        }
Exemplo n.º 18
0
        public async void GetClient(int uc, int clientId)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var client = await sclm.GetClientAsync(clientId);

            Assert.NotNull(client);
        }
Exemplo n.º 19
0
        public async void GetPackage(int uc, int presentationId)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var result = await sclm.GetContentPackageAsync(presentationId);

            Assert.NotNull(result);
        }
Exemplo n.º 20
0
        public async void Login(int uc, string username)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var user = await sclm.UserExistsAsync(username);

            SCLM s = new SCLM();
            //await s.AuthAsync(Settings.UserClientId, Settings.UserSecret, username, Settings.Password);
        }
Exemplo n.º 21
0
        public async void Create(int uc, string username)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            StoryCreateUserModel userForCreate = GetUserModel2(username);
            StoryUser            user          = await sclm.CreateUserAsync(userForCreate);

            Assert.NotNull(user);
        }
Exemplo n.º 22
0
        public async void LogAll(int uc)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var storyTable = await Tables.GetTableAsync(sclm);

            IEnumerable <StoryLogTable> logs = await storyTable.LogAsync();

            Assert.True(logs.Count() > 0);
        }
Exemplo n.º 23
0
        public static async Task <IEnumerable <StoryClient> > GetClientsAsync(this SCLM sclm)
        {
            IEnumerable <StoryClient> result = await sclm.GETAsync <IEnumerable <StoryClient> >(new Uri($"{sclm.GetEndpoint(api)}{Version}/{PathClients}", UriKind.Absolute), CancellationToken.None);

            foreach (var t in result)
            {
                t._sclm = sclm;
            }
            return(result);
        }
Exemplo n.º 24
0
        public async void GetMediafilePresentaion(int uc, int presentationId)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var presentation = await sclm.GetPresentationAsync(presentationId);

            var mediafile = await presentation.MediaFiles.First().LoadAsync();

            Assert.NotNull(mediafile);
        }
Exemplo n.º 25
0
        public async void LogWithDate(int uc)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var storyTable = await Tables.GetTableAsync(sclm);

            IEnumerable <StoryLogTable> logs = await storyTable.LogAsync(DateTime.Now.AddDays(-5));

            Assert.True(logs.Count() > 0);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Получить все таблицы клиента.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sclm"></param>
        /// <param name="clientId"></param>
        /// <returns></returns>
        public static async Task <IEnumerable <StoryTable <T> > > GetTablesAsync <T>(this SCLM sclm, int clientId) where T : class, new()
        {
            IEnumerable <StoryTable <T> > result = await sclm.GETAsync <IEnumerable <StoryTable <T> > >(new Uri($"{sclm.GetEndpoint(api)}{Version}/{Path}/{clientId}/tables", UriKind.Absolute), CancellationToken.None);

            foreach (var t in result)
            {
                t._sclm = sclm;
            }
            return(result);
        }
Exemplo n.º 27
0
        public async void LogCountWithDate(int uc)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var storyTable = await Tables.GetTableAsync(sclm);

            long count = await storyTable.LogCountAsync(DateTime.Now.AddDays(-5));

            Assert.True(count > 0);
        }
Exemplo n.º 28
0
        public async void LogCount(int uc)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var storyTable = await Tables.GetTableAsync(sclm);

            long count = await storyTable.LogCountAsync();

            Assert.True(count > 0);
        }
Exemplo n.º 29
0
        public async void CountWithQuery(int uc)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var storyTable = await Tables.GetTableAsync(sclm);

            long count = await storyTable.CountAsync("[Gender][eq][false]");

            Assert.True(count > 0);
        }
Exemplo n.º 30
0
        public async void GetUserFromPresentaion(int uc, int presentationId)
        {
            SCLM sclm = await Utilities.GetContextAsync(uc);

            var presentation = await sclm.GetPresentationAsync(presentationId);

            var user = await presentation.Users.First().LoadAsync();

            Assert.NotNull(user);
        }