/// <summary> /// Return all services that the user subscribed. /// </summary> /// <returns>all services that the user subscribed</returns> public List <Service> GetSubscribedServices() { if (!_registered) { return(null); } Storage.StorageManager sto = new Storage.StorageManager(); Storage.User us = sto.getEntityByID <Storage.User>(_userId); //TODO: aspettare metodo getSubscribedService da storage List <Service> list = ExternalService.List(); return(list); }
/// <summary> /// Return a list of /// </summary> /// <returns></returns> public List <FilledWorkflowReference> GetCompiledForms() { List <FilledWorkflowReference> ret = new List <FilledWorkflowReference>(); if (!_registered) { return(ret); } Storage.StorageManager db = new Storage.StorageManager(); Storage.User user = db.getEntityByID <Storage.User>(_userId); foreach (Storage.Publication pub in user.Publication) { ret.Add(new FilledWorkflowReference(pub.publicationID)); } return(ret); }
/// <summary> /// FORSE QUESTO METODO NON SERVE /// SERVE ECCOMEEEE!! /// </summary> /// <returns>una lista vuota</returns> public List <ComputableWorkflowReference> GetToBeCompiledWorkflows() { List <ComputableWorkflowReference> ret = new List <ComputableWorkflowReference>(); if (!_registered) { return(ret); } Storage.StorageManager db = new Storage.StorageManager(); Storage.User user = db.getEntityByID <Storage.User>(_userId); List <Storage.StorageManager.Pair <string, int> > tempcontacts = new List <Storage.StorageManager.Pair <string, int> >(); foreach (Storage.ExternalAccount extAcc in user.ExternalAccount) { Storage.StorageManager.Pair <string, int> pair = new Storage.StorageManager.Pair <string, int>(); pair.First = extAcc.username; pair.Second = extAcc.serviceID; tempcontacts.Add(pair); } List <Storage.Contact> mycontacts = db.getContactsByExtID(tempcontacts); foreach (Storage.Contact mycontact in mycontacts) { List <Storage.Publication> pubs = db.getListPublicationsByContactID(mycontact.contactID); foreach (Storage.Publication pub in pubs) { Storage.CompilationRequest req = db.getCompilationRequestByPulicationAndContact(mycontact.contactID, pub.publicationID); if (!req.compiled) { ret.Add(new ComputableWorkflowReference(_userId, pub.publicationID, pub.namePublication, pub.description, pub.themeID, req.compilReqID, !pub.isPublic, true, pub.expirationDate)); } } } return(ret); }
public User Create(Storage.User user) =>
/// <summary> /// Register the user on the database saving all external accounts that the user subscribed. On success, UserID property will be changed. /// </summary> /// <param name="Nickname">The nickname of the user</param> /// <param name="Email">The email of the user</param> /// <returns>True on succes or if already registered, false otherwise (in this case nothing is saved on the database)</returns> public RegisterMeResult RegisterMe(string Nickname, string Email, out string messageError) { messageError = ""; if (_registered) { return(RegisterMeResult.OK); } if (String.IsNullOrEmpty(Nickname)) { messageError = "Nickname is not valid."; return(RegisterMeResult.E_EMAIL); } if (String.IsNullOrEmpty(Email)) { messageError = "Email is not valid."; return(RegisterMeResult.E_EMAIL); } try { new System.Net.Mail.MailAddress(Email); } catch (Exception) { messageError = "Email is not valid."; return(RegisterMeResult.E_EMAIL); } Storage.StorageManager sto = new Storage.StorageManager(); Storage.User tempUser = sto.addUser(Nickname, Email); if (tempUser == null) { messageError = "An error has occured saving the new user on the database."; return(RegisterMeResult.E_GENERIC); } _userId = tempUser.userID; List <string> groupNames = new List <string>(); groupNames.Add(defGroup); List <Storage.Group> groupResult = sto.addGroups(groupNames, _userId); if (groupResult == null) { //rollback sto.removeEntity <Storage.User>(_userId); _userId = -1; { messageError = "An error has occured during the creation of default group."; return(RegisterMeResult.E_GENERIC); } } // Save all externalAccount foreach (int serviceID in _loggedServices.Keys) { Storage.ExternalAccount extAcc = sto.addExternalAccount(_userId, _loggedServices[serviceID].getUsername(), serviceID); if (extAcc == null) { //rollback sto.removeEntity <Storage.User>(_userId); sto.removeEntity <Storage.Group>(groupResult.First().groupID); _userId = -1; messageError = "An error has occured saving currently logged accounts."; return(RegisterMeResult.E_GENERIC); } } _username = Nickname; _email = Email; _registered = true; return(RegisterMeResult.OK); }