public static AgendaMapper GetData(string Data, User User) { XDocument d = XDocument.Parse(Data); var LolData = Convert.FromBase64String(d.Descendants(User.tempuri + "VulAgendaCDSResult").First().Value); BinairFormaat For = new BinairFormaat(LolData); return new AgendaMapper(For, User); }
public static Request Create(User User) { Request Req = new Request(); Req.Payload = String.Format(@"<?xml version=""1.0"" encoding=""utf-16""?><GetDDFields xmlns=""http://tempuri.org/""><clientID>{0}</clientID></GetDDFields>", User.InitData.Descendants(User.d2p1 + "ClientID").First().Value); Req.SoapAction = "http://tempuri.org/IMediusService/GetDDFields"; Req.Service = "Medius"; return Req; }
public async Task<string> Send(User U) { await U.SetBaseAddress(); ByteArrayContent C = new ByteArrayContent(Crypto.EncryptRequest(this)); C.Headers.Add("soapaction", "\"" + SoapAction + "\""); C.Headers.Add("content-type", "text/xml; charset=utf-8"); var Req = await U._client.PostAsync(String.Format("{0}Service.svc", this.Service), C); var ba = await Req.Content.ReadAsByteArrayAsync(); return Crypto.DecryptResponse(ba); }
public static Request Create(DateTime Start, DateTime End, User User, string Stamnummer) { Request Req = new Request(); Req.Payload = String.Format( @"<?xml version=""1.0"" encoding=""utf-16""?><VulAgendaCDS xmlns=""http://tempuri.org/""><clientID>{0}</clientID><isPersAgenda>false</isPersAgenda><pers></pers><stamnr>{1}</stamnr><gebr></gebr><dStart>{2:o}</dStart><dFinish>{3:o}</dFinish><bPersoonlijk>true</bPersoonlijk><bSchool>true</bSchool><bRooster>true</bRooster><bVerborgen>false</bVerborgen><bTaken>true</bTaken><useAgenda20>false</useAgenda20></VulAgendaCDS>", User.InitData.Descendants(User.d2p1 + "ClientID").First().Value, Stamnummer, Start, End); Req.Service = "Agenda"; XDocument D; Req.SoapAction = "http://tempuri.org/IAgendaService/VulAgendaCDS"; return Req; }
public AgendaMapper(BinairFormaat Formaat, User User) { Dictionary<int, string> TypeMappings = new Dictionary<int, string>(); TypeMappings[0] = "Niks"; foreach (var Item in User.InitData.Descendants(User.d2p1 + "AgendaLessoort")) { var Lessoort = int.Parse(Item.Descendants(User.d2p1 + "IdAgendaLessoort").First().Value); var Omschrijving = Item.Descendants(User.d2p1 + "Omschrijving").First().Value; TypeMappings[Lessoort] = Omschrijving; } Dictionary<string, Tuple<int, string>> Mappings = new Dictionary<string, Tuple<int, string>>(Formaat.Fields.Count); for (var i = 0; i < Formaat.Fields.Count; i++) { Mappings[Formaat.Fields[i].Name] = new Tuple<int, string>(i, Formaat.Fields[i].Description); } AgendaItems = new List<AgendaItem>(); foreach (var AgIt in Formaat.Rows) { int lesuurvan = (int) AgIt.Objects[Mappings["lesuurvan"].Item1]; int lesuurtm = (int)AgIt.Objects[Mappings["lesuurtm"].Item1]; for (int i = lesuurvan; i <= lesuurtm; i++) { AgendaItem Item = new AgendaItem(); Item.Start = (DateTime)AgIt.Objects[Mappings["dStart"].Item1]; Item.End = (DateTime)AgIt.Objects[Mappings["dFinish"].Item1]; Item.Lokatie = AgIt.Objects[Mappings["Lokatie"].Item1] as string; Item.Beschrijving = AgIt.Objects[Mappings["Omschrijving"].Item1] as string; Item.Actie = TypeMappings[(int)AgIt.Objects[Mappings["idAgendalessoort"].Item1]]; Item.Bericht = AgIt.Objects[Mappings["Bericht"].Item1] as string; Item.Lesuur = i+""; if(i == 0) Item.Lesuur = "!"; Item.RawData = new Dictionary<string,object>(Mappings.Count); foreach (var D in Mappings) { Item.RawData[D.Value.Item2] = AgIt.Objects[D.Value.Item1]; } AgendaItems.Add(Item); } } DataItems = new Dictionary<DateTime, List<AgendaItem>>(); foreach (var item in AgendaItems) { if (!DataItems.ContainsKey(item.Start.Date)) DataItems[item.Start.Date] = new List<AgendaItem>(); DataItems[item.Start.Date].Add(item); } }
public static Request Create(User User, IEnumerable<int> Ids) { string SThing = ""; foreach (var i in Ids) { SThing += "<d2p1:int>" + i + "</d2p1:int>"; } Request Req = new Request(); Req.Payload = String.Format("<?xml version=\"1.0\" encoding=\"utf-16\"?><GetLeerlingenData xmlns=\"http://tempuri.org/\">"+ "<clientID>{0}</clientID>"+ "<ids xmlns:d2p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" "+ "xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">{1}</ids>"+ "<getData>true</getData><getDescription>true</getDescription><getPicture>true</getPicture><getOndSoort>true</getOndSoort></GetLeerlingenData>", User.InitData.Descendants(User.d2p1 + "ClientID").First().Value, SThing); Req.Service = "Data"; Req.SoapAction = "http://tempuri.org/IDataService/GetLeerlingenData"; return Req; }
public async Task DoStuff(DateTime Week) { var WeekNum = DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(Week, CalendarWeekRule.FirstDay, DayOfWeek.Monday); var PI = new ProgressIndicator() { IsIndeterminate = false, Text = "Loading week " + WeekNum, Value = 0, IsVisible = true }; try { SystemTray.SetProgressIndicator(this, PI); var A = IsolatedStorageSettings.ApplicationSettings; var Username = A["Username"] as string; var Password = A["Password"] as string; var SchoolText = A["School"] as string; if (School != null && School.SchoolNaam != SchoolText) { School = null; User = null; } if (User != null && User.Username != Username) User = null; School = School ?? new School(SchoolText); await School.SchoolVersion(); PI.Value = 0.25; User = User ?? await School.Login(Username, Password); var Data = await User.GetLeerlingData(); PI.Value = 0.5; DateTime Start = Week; DateTime End = Week.AddDays(4); string Stamnummer = Data.stamnr + ""; var Requ = await AgendaRequest.Create(Start, End, User, Stamnummer).Send(User); PI.Value = 0.75; AgendaMapper Mapper = AgendaMapper.GetData(Requ, User); if(Week == StartOfWeek) this.DataContext = new Data() { Title = "Week " + WeekNum, Mapper = Mapper }; PI.Value = 1; await Task.Delay(2000); PI.IsVisible = false; } catch (Exception e) { PI.Text = "Error updating!"; Thread.Sleep(2000); PI.IsVisible = false; } }
/// <summary> /// Login to Magister /// </summary> /// <param name="Username">The username to login with</param> /// <param name="Password">The password to login with</param> /// <returns>The user that logged in</returns> public async Task<User> Login(string Username, string Password) { User U = new User(this); await U.GetInfo(Username, Password); return U; }