/// <summary> /// Writes current data to a mzid file /// </summary> /// <param name="xml"> /// A <see cref="System.String"/> with the output file name /// </param> public void Save(string xml) { Data.creationDate = DateTime.UtcNow; // CommonOntology Data.cvList = ListOntology.ToArray(); // AnalysisSoftwareList Data.AnalysisSoftwareList = ListSW.ToArray(); // Provider Data.Provider = Provider; // AuditCollection Data.AuditCollection = new FuGECollectionAuditCollectionType(); Data.AuditCollection.Person = ListPeople.ToArray(); Data.AuditCollection.Organization = ListOrganizations.ToArray(); // SequenceCollection SequenceCollectionType seq = new SequenceCollectionType(); seq.DBSequence = ListProteins.ToArray(); seq.Peptide = ListPeptides.ToArray(); Data.SequenceCollection = seq; // Serialization XmlSerializer serializer = new XmlSerializer(typeof(PSIPIMainmzIdentMLType)); TextWriter writer = new StreamWriter(xml); serializer.Serialize(writer, Data); writer.Close(); System.GC.Collect(); }
public IActionResult CreatePeople(ListPeople listPeople) { var person = peoples(); person.Add(listPeople); Serialize(person); return(Ok(peoples())); }
public HttpResponseMessage PostPeopleList(ListPeople listPeople) { listPeople = Mypeople.Add(listPeople); var respond = Request.CreateResponse <ListPeople>(HttpStatusCode.Created, listPeople); string link = Url.Link("DefaultApi", new { id = listPeople.Name }); respond.Headers.Location = new Uri(link); return(respond); }
//To get product by Name public ListPeople GetListPeople(string name) { ListPeople listpeople = Mypeople.Get(name); if (listpeople == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(listpeople); }
private async void CBRandom_Click(object sender, RoutedEventArgs e) { // Para sortear, primeiro o aplicativo pega a lista de todas as pessoas que foram ObservableCollection <Person> go; if (peopleWithApp) { go = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes") && P.Has_app)); } else { go = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes"))); } // Se o total de itens na lista for maior que 0 if (go.Count > 0) { Random random = new Random(); // Ele criará um random de 0 até o número de pessoas na lista menos 1 int number = random.Next(go.Count); // E dará scroll até esta posição na lista, exibindo o nome da pessoa. ListPeople.ScrollIntoView(go[number], ScrollIntoViewAlignment.Leading); string localDate = DateTime.Now.ToString("HH:mm:ss dd/MM/yyyy"); string dbDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (MainPage.Instance.member != null && go[number].Id == MainPage.Instance.member.Id) { count = 0; timerBlock = false; StartTimer(); MessageDialog md = new MessageDialog("Você!\n\nSorteado às " + localDate); md.Commands.Add(new UICommand("Enviar", new UICommandInvokedHandler((c) => { timerBlock = true; SendRaffle(dbDate, count, _event); })) { Id = 0 }); md.Commands.Add(new UICommand("Cancelar", null) { Id = 1 }); await md.ShowAsync(); } else { Other.Other.ShowMessage(go[number].Name); } } }
/// <summary> /// Reads data from a mzid file /// </summary> /// <param name="xml"> /// A <see cref="System.String"/> with the input file name /// </param> public void Load(string xml) { Default(); // Deserialization XmlSerializer serializer = new XmlSerializer(typeof(MzIdentMLType)); TextReader reader = new StreamReader(xml); Data = (MzIdentMLType)serializer.Deserialize(reader); reader.Close(); //Data = MzIdentMLType.LoadFromFile( xml ); // Parse data if (Data.AnalysisSoftwareList != null) { ListSW = new List <AnalysisSoftwareType>(Data.AnalysisSoftwareList); } if (Data.AuditCollection != null) { ListOrganizations.Clear(); ListPeople.Clear(); foreach (IdentifiableType contact in Data.AuditCollection) { if (contact is OrganizationType) { ListOrganizations.Add(contact as OrganizationType); } else if (contact is PersonType) { ListPeople.Add(contact as PersonType); } } } if (Data.SequenceCollection == null || Data.SequenceCollection.DBSequence == null || Data.SequenceCollection.Peptide == null || Data.SequenceCollection.PeptideEvidence == null) { throw new ApplicationException("mzIdentML file without identification sequences"); } ListProteins = new List <DBSequenceType>(Data.SequenceCollection.DBSequence); ListPeptides = new List <PeptideType>(Data.SequenceCollection.Peptide); ListEvidences = new List <PeptideEvidenceType>(Data.SequenceCollection.PeptideEvidence); System.GC.Collect(); }
public IActionResult UpdatePeople(string name, ListPeople listpeople) { var people = peoples(); if (name != listpeople.Name) { return(BadRequest()); } var selectedPerson = people.FirstOrDefault(person => person.Name == name); selectedPerson.Name = listpeople.Name; selectedPerson.Surname = listpeople.Surname; selectedPerson.Gender = listpeople.Gender; selectedPerson.Province = listpeople.Province; selectedPerson.ContactNO = listpeople.ContactNO; return(Ok(peoples())); }
//Updating the list public void PutPeopleList(string name, ListPeople listing) { listing.Name = name; if (!Mypeople.Update(listing)) { throw new HttpResponseException(HttpStatusCode.NotFound); } //Deleting the list void DeleteListPeople(string naming) { ListPeople listPeople = Mypeople.Get(naming); if (listPeople == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } Mypeople.Remove(naming); } }
public IActionResult DeleteListPeople(string name) { var person = peoples(); var selectedPerson = from selected in person where selected.Name == name select selected; if (selectedPerson == null) { return(NotFound()); } ListPeople remove = null; foreach (var selected in selectedPerson) { remove = selected; } person.Remove(remove); Serialize(person); return(Ok(peoples())); }
public async Task <object> SerializeCharacters() { List <Characters> ListCharacters = new List <Characters>(); await SerializeCharacters(ListCharacters, "http://gateway.marvel.com/v1/public/characters"); foreach (var people in ListPeople) { var especie = await SerializeEspecie(people.Species.FirstOrDefault()); people.Species = new List <string>() { especie }; if (string.IsNullOrWhiteSpace(people.Mass) || people.Mass.ToLower() == "unknown") { people.Mass = "0"; } } List <Characters> Characters = new List <Characters>(); Characters.Clear(); Characters = ListPeople.Where((x => x.Species.Contains("Human"))).ToList(); var Retorno = new { QuantHumanos = Characters.Count(), PersonagensHumanos = Characters.OrderBy(x => x.Name), PesoFinal = Characters.Sum(x => Double.Parse(x.Mass, CultureInfo.InvariantCulture)), MediaDePeso = Characters.Sum(x => Double.Parse(x.Mass, CultureInfo.InvariantCulture)) / Characters.Count() }; return(Retorno); }
private void ListPeople_Loaded(object sender, RoutedEventArgs e) { _peopleScrollViewer = ListPeople.GetChildOfType <ScrollViewer>(); _peopleScrollerPropertySet = ElementCompositionPreview. GetScrollViewerManipulationPropertySet(_peopleScrollViewer); }
/// <summary> /// Método que solicita a lista de pessoas que deram alguma resposta ao evento e preenche a lista. /// </summary> public async void GetPeople() { string jsonString = ""; try { if (!Other.Other.GetSetting("refresh_token").Equals("")) { var client = new HttpClient(); client.MaxResponseContentBufferSize = 256000; HttpResponseMessage response = await client.PostAsync(Other.Other.GetRSVPSUrl(_event.Id), Other.Other.GetRefreshToken()); if (response.IsSuccessStatusCode) { jsonString = await response.Content.ReadAsStringAsync(); } else { throw new Exception(); } } else { jsonString = await new HttpClient().GetStringAsync(new Uri(Other.Other.GetRSVPSUrl(_event.Id))); } } catch { ShowMessage("Verifique sua conexão de internet"); return; } try { listPeople = JsonConvert.DeserializeObject <ObservableCollection <Person> >(jsonString); } catch { ShowMessage("Houve um erro ao receber a lista de pessoas"); return; } ListPeople.ItemsSource = listPeople.Where(P => P.Response.Equals("yes")); Loading.IsVisible = false; ToolbarItem randomButton = new ToolbarItem("Sortear", Device.OnPlatform(null, null, "Assets/Images/Random.png"), async() => { // Para sortear, primeiro o aplicativo pega a lista de todas as pessoas que foram ObservableCollection <Person> go; if (peopleWithApp) { go = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes") && P.Has_app)); } else { go = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes"))); } // Se o total de itens na lista for maior que 0 if (go.Count > 0) { Random random = new Random(); // Ele criará um random de 0 até o número de pessoas na lista menos 1 int number = random.Next(go.Count); // E dará scroll até esta posição na lista, exibindo o nome da pessoa. ListPeople.ScrollTo(go[number], ScrollToPosition.Start, true); string localDate = DateTime.Now.ToString("HH:mm:ss dd/MM/yyyy"); string dbDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (LinksPage.Instance.member != null && go[number].Id == LinksPage.Instance.member.Id) { count = 0; timerBlock = false; StartTimer(); bool message = await DisplayAlert("", "Você!\n\nSorteado às " + localDate, "Enviar", "Cancelar"); if (message) { timerBlock = true; await Navigation.PushAsync(new LoadingPage(dbDate, count, _event)); } } else { Other.Other.ShowMessage(go[number].Name, this); } } }); ToolbarItems.Add(randomButton); if (Device.OS == TargetPlatform.iOS) { var more = new ToolbarItem("Mais", "More.png", async() => { string action = ""; if (peopleWithApp) { action = await DisplayActionSheet("Menu", "Cancelar", null, "Todos"); } else { action = await DisplayActionSheet("Menu", "Cancelar", null, "Com o app"); } if (action != null) { if (action.Equals("Com o app") || action.Equals("Todos")) { peopleWithApp = !peopleWithApp; if (peopleWithApp) { ListPeople.ItemsSource = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes") && P.Has_app)); } else { ListPeople.ItemsSource = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes"))); } } } }); ToolbarItems.Add(more); } else { withApp = new ToolbarItem("Com o app", "Assets/Images/OpenMeetup.png", () => { peopleWithApp = !peopleWithApp; if (peopleWithApp) { ListPeople.ItemsSource = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes") && P.Has_app)); withApp.Text = "Todos"; } else { ListPeople.ItemsSource = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("yes"))); withApp.Text = "Com o app"; } }, ToolbarItemOrder.Secondary); ToolbarItems.Add(withApp); } Title = "Vão"; ObservableCollection <Person> wait = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("waitlist") || P.Response.Equals("watching"))); ObservableCollection <Person> no = new ObservableCollection <Person>(listPeople.Where(P => P.Response.Equals("no"))); if (wait.Count > 0) { TabbedPeoplePage.page.Children.Add(new PeoplePage(wait) { Title = "Esperando" }); } if (no.Count > 0) { TabbedPeoplePage.page.Children.Add(new PeoplePage(no) { Title = "Não vão" }); } ListPeople.IsVisible = true; }
// Creating a new List public ListPeople PostListPeople(ListPeople listPeople) { listPeople = Mypeople.Add(listPeople); return(listPeople); }