/// <summary> /// Returns all of the contacts indexed by DB logic key (email, serviceId). /// </summary> /// <returns>User's contacts.</returns> public Dictionary <Storage.StorageManager.Pair <string, int>, Contact> GetContacts() { if (!_registered) { return(null); } Storage.StorageManager sto = new Storage.StorageManager(); List <Storage.Contact> contacts = sto.getContactsByUserID(_userId); Dictionary <Storage.StorageManager.Pair <string, int>, Contact> ret = new Dictionary <Storage.StorageManager.Pair <string, int>, Contact>(); if (contacts == null) { return(null); } foreach (Storage.Contact contact in contacts) { Storage.StorageManager.Pair <string, int> temPair = new Storage.StorageManager.Pair <string, int>(); Contact tempContact = new Contact(contact.nameContact, contact.externalUserID, new Service(contact.Service.nameService, contact.Service.serviceID)); temPair.First = contact.externalUserID; temPair.Second = contact.externalServiceID; //Controllo per evitare duplicati nel dictionary if (!ret.ContainsKey(temPair)) { ret.Add(temPair, tempContact); } } return(ret); }
public void RaiseCallbackEvent(string eventArgument) { result = ""; Dictionary <string, Storage.StorageManager.Pair <string, string> > dic = Security.Token.GetPublicFormsLinks(); foreach (KeyValuePair <string, Storage.StorageManager.Pair <string, string> > w in dic) { Storage.StorageManager.Pair <string, string> pair = w.Value; result += pair.First + "\\|)//" + pair.Second + "\\|//" + w.Key + "\\||//"; } if (result == "") { result = "Doens't exist any public form"; } }
/// <summary> /// Get the workflow's result /// </summary> /// <returns>A list of pair composte of: contact that fill and xmlDocument that contain the result. If the form is anonim, the value of the contact is always null</returns> public List <Storage.StorageManager.Pair <Contact, XmlDocument> > getFilledDocument() { List <Storage.StorageManager.Pair <Contact, XmlDocument> > results = new List <Storage.StorageManager.Pair <Contact, XmlDocument> >(); Storage.StorageManager db = new Storage.StorageManager(); Storage.Publication pub = db.getEntityByID <Storage.Publication>(publicationId); if (pub == null) { return(null); } if (pub.anonymResult || pub.isPublic) { foreach (Storage.Result res in pub.Result) { Storage.StorageManager.Pair <Contact, XmlDocument> el = new Storage.StorageManager.Pair <Contact, XmlDocument>(); el.First = null; el.Second = Storage.StorageManager.XElementToXmlDocument(res.xmlResult); results.Add(el); } } else { //private non anonime foreach (Storage.CompilationRequest req in pub.CompilationRequest) { if (req.contactID != -1) { foreach (Storage.Result res in req.Result) { Storage.StorageManager.Pair <Contact, XmlDocument> el = new Storage.StorageManager.Pair <Contact, XmlDocument>(); el.First = new Contact(req.Contact.nameContact, req.Contact.externalUserID, new Service(req.Contact.Service.nameService, req.Contact.Service.serviceID)); el.Second = Storage.StorageManager.XElementToXmlDocument(res.xmlResult); results.Add(el); } } } } return(results); }
/// <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); }
/// <summary> /// Get all public forms links with names and descriptions /// </summary> /// <returns>A Dictionary containing pairs of FormLink/<FormName,FormDescription&rt;</returns> public static Dictionary <string, Storage.StorageManager.Pair <string, string> > GetPublicFormsLinks() { int fakeId = 1; Storage.StorageManager sto = new Storage.StorageManager(); // We likes very long types List <Storage.StorageManager.Pair < Storage.StorageManager.PartialPublication, Storage.CompilationRequest > > completelypublicpubs = sto.getPublicationsCompilationRequestByContactID(fakeId); List <Storage.StorageManager.PartialPublication> publicpubs = sto.getPublicationsPublic(); Dictionary <string, Storage.StorageManager.Pair <string, string> > result = new Dictionary <string, Storage.StorageManager.Pair <string, string> >(); int i = 0; foreach (Storage.StorageManager.PartialPublication pub in publicpubs) { Storage.CompilationRequest creq = null; if (pub.publicationID == completelypublicpubs[i].First.publicationID) { // Completely public creq = completelypublicpubs[i].Second; i++; // If reached the last one, stay there if (i == completelypublicpubs.Count) { i--; } } Storage.StorageManager.Pair <string, string> pair = new Storage.StorageManager.Pair <string, string>(); pair.First = pub.namePublication; pair.Second = pub.descr; result.Add(ToLink(pub, creq), pair); Console.WriteLine(ToLink(pub, creq)); } return(result); }
/// <summary> /// Convert a list of Security.Contact in a list of StorageManager.Contact /// </summary> /// <param name="contactsList"></param> /// <returns></returns> private List <Storage.Contact> ConvertToStorageContact(List <Security.Contact> contactsList) { if (!_registered) { return(null); } if (contactsList == null) { return(null); } Storage.StorageManager sto = new Storage.StorageManager(); List <Storage.StorageManager.Pair <string, int> > mycontacts = new List <Storage.StorageManager.Pair <string, int> >(); foreach (Contact secContact in contactsList) { Storage.StorageManager.Pair <string, int> pair; pair = new Storage.StorageManager.Pair <string, int>(); pair.First = secContact.Email; pair.Second = secContact.Service.ServiceId; mycontacts.Add(pair); } return(sto.getContactsByExtID(mycontacts)); }