Ejemplo n.º 1
0
         public AftnViewModel(Aftn aftn, AftnService aftnService)
        {
            if (aftn == null)
                throw new ArgumentNullException("aftn");

            if (aftnService == null)
                throw new ArgumentNullException("aftnService");

            _aftn = aftn;
            _aftnService = aftnService;
             AftnList = AftnList2;
           // _customerType = Strings.CustomerViewModel_CustomerTypeOption_NotSpecified;
        }
Ejemplo n.º 2
0
        private void Setup(AftnService aftnService)
        {
            if (aftnService == null)
                throw new ArgumentNullException("aftnService");

            base.DisplayName = Entity.AllAftnsViewModel_DisplayName;

            _aftnService = aftnService;

            // Subscribe for notifications of when a new customer is saved.
            _aftnService.AftnAdded += this.OnAftnAddedToRepository;

            // Populate the AllCustomers collection with CustomerViewModels.
            this.CreateAllAftns();
        }
Ejemplo n.º 3
0
        public MainWindowViewModel(NotamDataContext  dataContext )
        {
            base.DisplayName = Entity.MainWindowViewModel_DisplayName;

            _originService = new OriginService(dataContext);
            _firService = new FIRService(dataContext);
            _notamService = new NotamService(dataContext);
            _aerodomService = new AerodomService(dataContext);
            _notamCodeService = new NotamCodeService(dataContext);
            _snowtamService = new SnowtamService(dataContext);
            _authService = new AuthenticationService(dataContext);
            _aftnService = new AftnService(dataContext);
            _intlNotamService = new IntlNotamService(dataContext);
            var workspace = new NotamSearchViewModel(_notamService, Workspaces);
            this.Workspaces.Add(workspace);
            this.SetActiveWorkspace(workspace);
            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0,1,0);
            dispatcherTimer.Start();


        }
Ejemplo n.º 4
0
 public AllAftnsViewModel(AftnService aftnService)
 {
     Setup(aftnService); 
 }
Ejemplo n.º 5
0
   public AllAftnsViewModel(AftnService aftnService, ObservableCollection<WorkspaceViewModel> parent)
 {
       parentWorkSpaces = parent;
       Setup(aftnService);
 }
Ejemplo n.º 6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            CustomPrincipal customPrincipal = new CustomPrincipal();
            AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal);
            AuthenticationService authenticationService = new AuthenticationService(App._dataDC);
            if (e != null && e.Args != null && e.Args.Count<string>() > 0)
            {
                try
                {
                    Dictionary<string, string> dic = this.MakeDictionary(e.Args);
                    if (dic != null)
                    {
                        try
                        {
                            User user = authenticationService.AuthenticateUser(dic["User"], dic["Pass"]);
                            customPrincipal = (Thread.CurrentPrincipal as CustomPrincipal);
                            if (customPrincipal == null)
                            {
                                throw new ArgumentException("The application's default thread principal must be set to a CustomPrincipal object on startup.");
                            }
                            customPrincipal.Identity = new CustomIdentity(user.Username, user.Role);
                        }
                        catch (UnauthorizedAccessException exp)
                        {
                            MessageBox.Show("Login failed! Please provide some valid credentials.");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("ERROR: {0}", ex.Message);
                        }
                        if (this.IsAuthenticated)
                        {
                            MainWindowViewModel viewModel = null;
                            MainWindow window = new MainWindow();
                            string notamType = null;
                            try
                            {
                            if (dic.ContainsKey("GetAddr"))
                            {
                                var aftnService = new AftnService(App._dataDC2);
                                var AftnList = aftnService.GetAftnList().OrderBy(t => t.Series).ToList();
                                string strFinal="";
                                foreach(var aftn in AftnList)
                                {
                                    strFinal += aftn.Series + "=" + aftn.AftnList+"\n";
                                }
                                System.IO.File.WriteAllText("C:\\NOTDIR\\ADDR.TXT", strFinal);
                                Application.Current.Shutdown();
                                return;
                            }
                            if (dic["NotamType"] != null)
                            {
                                notamType = dic["NotamType"].Substring(dic["NotamType"].Length - 1);
                            }
                            if (dic["NotamType"].Contains("NOTAM"))
                            {
                                if (dic["Originat"].IndexOf("OI") != 0)
                                {
                                    IntlNotam notam = new IntlNotam
                                    {
                                        Number = dic.ContainsKey("Num") ? dic["Num"] : "",
                                        NotamType = notamType,
                                        SendTime = dic.ContainsKey("Filling") ? dic["Filling"] : "",
                                        Type = dic.ContainsKey("Type") ? dic["Type"] : "",
                                        Year = dic.ContainsKey("year") ? dic["year"] : "",
                                        RefType = dic.ContainsKey("RefT") ? dic["RefT"] : "",
                                        RefYear = dic.ContainsKey("RefY") ? dic["RefY"] : "",
                                        RefNum = dic.ContainsKey("RefN") ? dic["RefN"] : "",
                                        LowerLimit = dic.ContainsKey("Lower") ? dic["Lower"] : "",
                                        HigherLimit = dic.ContainsKey("Upper") ? dic["Upper"] : "",
                                        Latitude = dic.ContainsKey("Latitude") ? dic["Latitude"] : "",
                                        Longtitude = dic.ContainsKey("Longtitude") ? dic["Longtitude"] : "",
                                        Radius = dic.ContainsKey("Radius") ? dic["Radius"] : "",
                                        FirAero = dic.ContainsKey("FirAd") ? dic["FirAd"] : "",
                                        FromDate = dic.ContainsKey("FromDate") ? dic["FromDate"] : "",
                                        ToDate = dic.ContainsKey("ToDate") ? dic["ToDate"] : "",
                                        PermEst = dic.ContainsKey("EstPerm") ? dic["EstPerm"] : "",
                                        EFreeText = dic.ContainsKey("ItemE") ? dic["ItemE"] : "",
                                        DFreeText = dic.ContainsKey("ItemD") ? dic["ItemD"] : "",
                                        FFreeText = dic.ContainsKey("ItemF") ? dic["ItemF"] : "",
                                        GFreeText = dic.ContainsKey("ItemG") ? dic["ItemG"] : "",
                                        Origin = dic.ContainsKey("FIR") ? (
                                            from o in App._dataDC2.Origins
                                            where o.Code.Equals(dic["Originat"])
                                            select o).FirstOrDefault<Origin>() : null,
                                        FIR = dic.ContainsKey("FIR") ? 
                                            App._dataDC2.FIRs.Where(n =>  (n.Code.Length==4) && n.Code.Substring(0,2).Equals(dic["FIR"].Substring(0,2))).FirstOrDefault()
                                             : null,
                                        Status = "D",
                                        NotamCode = dic.ContainsKey("QCode") ? (
                                            from o in App._dataDC2.NotamCodes
                                            where (o.Subject + o.Condition).Equals(dic["QCode"])
                                            select o).FirstOrDefault<NotamCode>() : null
                                    };
                                    IntlNotamService intlNotamService = new IntlNotamService(App._dataDC2);
                                    if (!intlNotamService.ContainsNotam(notam))
                                    {
                                        intlNotamService.Insert(notam);
//                                      MessageBox.Show("International NOTAM Inserted To Database Successfully");
                                    }
                                    else
                                    {
//                                        MessageBox.Show("International NOTAM Already Inserted To Database");
                                    }
                                    Application.Current.Shutdown();
                                    return;
                                }
//                                 if (!dic.ContainsKey("FIR"))
//                                 {
//                                     dic.Add("FIR", "OIIX");
//                                 }
//                                 Notam notam2 = new Notam
//                                 {
//                                     Number = "",
//                                     NotamType = notamType,
//                                     SendTime = dic.ContainsKey("Filling") ? dic["Filling"] : "",
//                                     Type = dic.ContainsKey("Type") ? dic["Type"] : "",
//                                     Year = dic.ContainsKey("year") ? dic["year"] : "",
//                                     RefType = dic.ContainsKey("RefT") ? dic["RefT"] : "",
//                                     RefYear = dic.ContainsKey("RefY") ? dic["RefY"] : "",
//                                     RefNum = dic.ContainsKey("RefN") ? dic["RefN"] : "",
//                                     LowerLimit = dic.ContainsKey("Lower") ? dic["Lower"] : "",
//                                     HigherLimit = dic.ContainsKey("Upper") ? dic["Upper"] : "",
//                                     Latitude = dic.ContainsKey("Latitude") ? dic["Latitude"] : "",
//                                     Longtitude = dic.ContainsKey("Longtitude") ? dic["Longtitude"] : "",
//                                     Radius = dic.ContainsKey("Radius") ? dic["Radius"] : "",
//                                     FirAero = dic.ContainsKey("FirAd") ? dic["FirAd"] : "",
//                                     FromDate = dic.ContainsKey("FromDate") ? dic["FromDate"] : "",
//                                     ToDate = dic.ContainsKey("ToDate") ? dic["ToDate"] : "",
//                                     PermEst = dic.ContainsKey("EstPerm") ? dic["EstPerm"] : "",
//                                     EFreeText = dic.ContainsKey("ItemE") ? dic["ItemE"] : "",
//                                     DFreeText = dic.ContainsKey("ItemD") ? dic["ItemD"] : "",
//                                     FFreeText = dic.ContainsKey("ItemF") ? dic["ItemF"] : "",
//                                     GFreeText = dic.ContainsKey("ItemG") ? dic["ItemG"] : "",
//                                     Origin = (
//                                         from o in App._dataDC2.Origins
//                                         where o.Code.Equals(dic["Originat"])
//                                         select o).FirstOrDefault<Origin>(),
//                                     FIR = (
//                                         from o in App._dataDC2.FIRs
//                                         where o.Code.Equals(dic["FIR"])
//                                         select o).FirstOrDefault<FIR>(),
//                                     Status = "D",
//                                     NotamCode = dic.ContainsKey("QCode") ? (
//                                         from o in App._dataDC2.NotamCodes
//                                         where (o.Subject + o.Condition).Equals(dic["QCode"])
//                                         select o).FirstOrDefault<NotamCode>() : null
//                                 };
//                                 viewModel = new MainWindowViewModel(App._dataDC2, notam2);
                            }
                            else
                            {
                                if (dic["NotamType"].Contains("RQN"))
                                {
                                    SendRQN(dic, App._dataDC2);
                                }
                                else
                                {
                                    SendRQL(dic);
                                }
                                Application.Current.Shutdown();
                                return;
                            }
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                                Application.Current.Shutdown();
                                return;
                            }
                            EventHandler handler = null;
                            handler = delegate
                            {
                                viewModel.RequestClose -= handler;
                                window.Close();
                            };
                            viewModel.RequestClose += handler;
                            window.DataContext = viewModel;
                            window.ShowDialog();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            if (!IsAuthenticated)
            {
                //Show the login view
                AuthenticationViewModel viewModel = new AuthenticationViewModel(authenticationService);
Ejemplo n.º 7
0
  public AftnViewModel(Aftn aftn, AftnService aftnService, ObservableCollection<WorkspaceViewModel> parent):this(aftn,aftnService)
 {
     parentWorkSpaces = parent;
 }
Ejemplo n.º 8
0
using System;