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); }
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); }
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)); }
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); }
internal static void SetDecorator(SCLM sclm, string clientId, string secret, StoryToken token) => sclm.AddHttpDecorator <OAuthDecorator>(new OAuthDecorator { ClientId = clientId, Secret = secret, Token = token });
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")); }
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); }
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)); }
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); }
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); }
/// <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); }
public async void GetPresentaionFromClient(int uc, int presentationId) { SCLM sclm = await Utilities.GetContextAsync(uc); var presentation = await sclm.GetPresentationAsync(presentationId); Assert.NotNull(presentation); }
public async void Exists(int uc, string username) { SCLM sclm = await Utilities.GetContextAsync(uc); var user = await sclm.UserExistsAsync(username); Assert.NotNull(user); }
public async void GetMediafile(int uc, int mediafileId) { SCLM sclm = await Utilities.GetContextAsync(uc); var result = await sclm.GetMediafileAsync(mediafileId); Assert.NotNull(result); }
public async void GetClients(int uc) { SCLM sclm = await Utilities.GetContextAsync(uc); var clients = await sclm.GetClientsAsync(); Assert.True(clients.Count() > 0); }
public async void GetSlide(int uc, int slideId) { SCLM sclm = await Utilities.GetContextAsync(uc); var result = await sclm.GetSlideAsync(slideId); Assert.NotNull(result); }
public async void GetClient(int uc, int clientId) { SCLM sclm = await Utilities.GetContextAsync(uc); var client = await sclm.GetClientAsync(clientId); Assert.NotNull(client); }
public async void GetPackage(int uc, int presentationId) { SCLM sclm = await Utilities.GetContextAsync(uc); var result = await sclm.GetContentPackageAsync(presentationId); Assert.NotNull(result); }
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); }
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); }
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); }
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); }
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); }
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); }
/// <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); }
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); }
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); }
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); }
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); }