/// <summary> /// Sets the Columns property with available columns in current table /// </summary> public static void GetColumns() { Columns = new List <string>(); var task1 = Task.Run(async() => await LogIn("Cris", "password")); task1.Wait(); var res1 = task1.Result; CloudApp.Init(code, key); Debug.WriteLine("TableName: " + Table); ArrayList res; var task = Task.Run(async() => await ServerUpDown.Load()); task.Wait(); res = task.Result; if (res.Count > 0) { CloudObject j = (CloudObject)res[0]; foreach (var item in j.Dictionary.Keys) { Columns.Add(item); } } }
static public Task <ArrayList> Load() { Debug.WriteLine("Fetching from server..."); CloudApp.Init(code, key); CloudQuery query = new CloudQuery(Table); return(query.FindAsync()); }
static public Task <CloudUser> LogIn(String uName, String uPas) { CloudApp.Init(code, key); var u2 = new CloudUser(); u2.Set("username", uName); u2.Set("password", uPas); Debug.WriteLine("Starting login"); return(u2.LoginAsync()); }
static public Task <CloudUser> SignUp(String uName, String uPas, String uEmail) { CloudApp.Init(code, key); var u2 = new CloudUser(); u2.Username = uName; u2.Password = uPas; u2.Email = uEmail; return(u2.SignupAsync()); }
static public async void Save(Dictionary <String, Item> items) { CloudApp.Init(code, key); foreach (KeyValuePair <String, Item> pair in items) { if (pair.Value.OnServer == false) { CloudObject obj = new CloudObject(Table); obj.ID = pair.Key; obj.Set("Name", pair.Value.Name); obj.Set("Type", pair.Value.Type); obj.Set("Quantity", pair.Value.Quantity); obj.Set("User", pair.Value.User); CloudObject savedObj = await obj.SaveAsync(); pair.Value.OnServer = true; } } }
protected void Application_Start(object sender, EventArgs e) { var rootDir = new DirectoryInfo(this.Server.MapPath("~/bin")); // app context var app = new CloudApp(); { IConfigRepository config; var configIni = new FileInfo(Path.Combine(rootDir.FullName, "config.ini")); if (configIni.Exists) { config = new IniFileConfigRepository(configIni); } else { config = new KeyValuePairConfigRepository(); } app.Config = config.MakeReadOnly(); } // principal repository var pricRepo = new PrincipalRepository(); { pricRepo.LocalDataDirectory = rootDir.FullName; { string temp; if (app.Config.TryGetValue <string>("Data", out temp, "Directories") && string.IsNullOrWhiteSpace(temp) == false) { pricRepo.LocalDataDirectory = temp.Trim(); } } var iniFile = new FileInfo(Path.Combine(rootDir.FullName, "users.ini")); if (iniFile.Exists) { pricRepo.UserRepository = new IniFileConfigRepository(iniFile); } pricRepo.Reload(); } // URL routes { // files RouteTable.Routes.Add(new Route ( "files", new FilesHttpHandler() )); // messages RouteTable.Routes.Add(new Route ( "messages", new MessagesHttpHandler() )); } // ServiceLocator { this.GlobalCompositionCatalog = new AggregateCatalog(); this.GlobalCompositionCatalog.Catalogs.Add(new AssemblyCatalog(typeof(global::MarcelJoachimKloubert.CloudNET.Classes.ICloudApp).Assembly)); this.GlobalCompositionContainer = new CompositionContainer(this.GlobalCompositionCatalog, true); this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CloudNET.Classes.ICloudApp>(app); this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CloudNET.Classes.Security.IPrincipalRepository>(pricRepo); this.GlobalCompositionContainer.ComposeExportedValue <global::System.Web.HttpApplication>(this); var innerLocator = new ExportProviderServiceLocator(this.GlobalCompositionContainer); this.GlobalServiceLocator = new DelegateServiceLocator(innerLocator); this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CLRToolbox.ServiceLocation.IServiceLocator>(this.GlobalServiceLocator); this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CLRToolbox.ServiceLocation.Impl.DelegateServiceLocator>(this.GlobalServiceLocator); this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CLRToolbox.ServiceLocation.Impl.ExportProviderServiceLocator>(innerLocator); ServiceLocator.SetLocator(this.GlobalServiceLocator); } this.Application[APP_VAR_APPCONTEXT] = app; this.Application[APP_VAR_PRINCIPALS] = pricRepo; }