private void SendRQL(Dictionary<string, string> dic) { if (dic["NotamType"].Contains("RQL")) { if (!dic.ContainsKey("FIR")) { MessageBox.Show("No FIR in RQL"); return; } string strFir = dic["FIR"]; if (strFir.Length != 4) return; Notam nt = new Notam(); nt.Type = dic["RQLT"]; nt.FIR = App._dataDC2.FIRs.Where(n => (n.Code.Length == 4) && n.Code.Substring(0, 2).Equals(strFir.Substring(0, 2))).FirstOrDefault(); nt.SendTime = DateTime.Now.ToString("yyMMddHHmm"); nt.Origin = ( from x in App._dataDC2.Origins where x.Code.Equals("OIIIYNYX") select x).FirstOrDefault<Origin>(); NotamSender notamSender = new NotamSender(nt); List<Notam> notamList = ( from o in App._dataDC2.Notams where o.Type.Equals(nt.Type) && o.Status.Equals("D") select o).ToList<Notam>(); if (!strFir.Substring(0, 2).Equals("OI")) { List<IntlNotam> innotamList = ( from o in App._dataDC2.IntlNotams where o.Type.Equals(nt.Type) && o.Status.Equals("D") && o.FIR == nt.FIR select o).ToList<IntlNotam>(); notamList = IntlNotamService.ConvertList(innotamList); } if (dic.ContainsKey("Originat")) { notamSender.SendRQLNotam(dic["Originat"], notamList); } return; } }
private void SendRQN(Dictionary<string, string> dic,NotamDataContext dcontext) { if (!dic.ContainsKey("FIR")) { MessageBox.Show("No FIR in RQN"); return; } string strFir = dic["FIR"]; if (strFir.Length != 4) return; Notam notam2=null; if (!strFir.Substring(0, 2).Equals("OI")) { FIR fir = dcontext.FIRs.Where(n => n.Code.Equals(strFir)).FirstOrDefault(); IntlNotam innotam = ( from o in App._dataDC2.IntlNotams where o.Number.Equals(dic["RQNN"]) && (o.Type.Equals(dic["RQNT"]) && o.Year.Equals(dic["RQNY"]) && o.FIR == fir) select o).FirstOrDefault<IntlNotam>(); if (innotam == null) { innotam = new IntlNotam(); innotam.Type = dic["RQNT"]; innotam.Number = dic["RQNN"]; innotam.Year = dic["RQNY"]; innotam.FIR = dcontext.FIRs.Where(n => (n.Code.Length == 4) && n.Code.Substring(0, 2).Equals(strFir.Substring(0, 2))).FirstOrDefault(); innotam.SendTime = DateTime.Now.ToString("yyMMddHHmm"); innotam.Origin = ( from x in App._dataDC2.Origins where x.Code.Equals("OIIIYNYX") select x).FirstOrDefault<Origin>(); innotam.Status = "N"; IntlNotam notam3 = ( from o in App._dataDC2.IntlNotams where o.Type.Equals(dic["RQNT"]) && o.Year.Equals(dic["RQNY"]) && o.FIR == fir select o into x orderby x.Number descending select x).FirstOrDefault<IntlNotam>(); if (int.Parse(notam3.Number) > int.Parse(notam2.Number)) { innotam.Status = "BL"; } } notam2 = IntlNotamService.ConvertToNotam(innotam); } else { notam2 = ( from o in App._dataDC2.Notams where o.Number.Equals(dic["RQNN"]) && (o.Type.Equals(dic["RQNT"]) && o.Year.Equals(dic["RQNY"])) select o).FirstOrDefault<Notam>(); if (notam2 == null) { notam2 = new Notam(); notam2.Type = dic["RQNT"]; notam2.Number = dic["RQNN"]; notam2.Year = dic["RQNY"]; notam2.FIR = dcontext.FIRs.Where(n => (n.Code.Length==4) && n.Code.Substring(0,2).Equals(strFir.Substring(0,2))).FirstOrDefault(); notam2.SendTime = DateTime.Now.ToString("yyMMddHHmm"); notam2.Origin = ( from x in App._dataDC2.Origins where x.Code.Equals("OIIIYNYX") select x).FirstOrDefault<Origin>(); notam2.Status = "N"; Notam notam3 = ( from o in App._dataDC2.Notams where o.Type.Equals(dic["RQNT"]) && o.Year.Equals(dic["RQNY"]) select o into x orderby x.Number descending select x).FirstOrDefault<Notam>(); if (int.Parse(notam3.Number) > int.Parse(notam2.Number)) { notam2.Status = "BL"; } } } NotamSender notamSender = new NotamSender(notam2); if (dic.ContainsKey("Originat")) { notamSender.SendRQNNotam(dic["Originat"]); } return; }
void RunReport() { string strText = ""; var ntmBuilder = new StringBuilder(); if (!string.IsNullOrEmpty(strUser)) ntmBuilder.Append("NOTAMS FOR USER :\t" + strUser + Environment.NewLine); strText = "TOTALS NOTAMS:\t" + AllNotams.Count.ToString() + Environment.NewLine; ntmBuilder.Append(strText); foreach (NotamViewModel cvm in AllNotams) { NotamSender ns = new NotamSender(cvm.Notam); ntmBuilder.Append("__________________________________________________________________" + Environment.NewLine); strText = ns.GenerateNotamText(); ntmBuilder.Append(strText + Environment.NewLine); } string subPath = "c:\\AISADMin\\"; // your code goes here bool exists = System.IO.Directory.Exists((subPath)); if (!exists) System.IO.Directory.CreateDirectory((subPath)); string strFile = subPath + "report.txt"; System.IO.File.WriteAllText(strFile, ntmBuilder.ToString()); System.Diagnostics.Process.Start(strFile); }