示例#1
0
        public IntlNotamDetailViewModel(NotamDetail notam, NotamDetailService notamDetailService, IntlNotamService notamService, ObservableCollection<WorkspaceViewModel> parent, WorkspaceViewModel ntmWorkspace)
        {
            parentWorkSpaces = parent;
            NotamWorkspace = ntmWorkspace;
            if (notam == null)
                throw new ArgumentNullException("notam");

            if (notamService == null)
                throw new ArgumentNullException("notamService");
            if (notamDetailService == null)
                throw new ArgumentNullException("notamDetailService");

            _notam = notam;
            _notamDetailService = notamDetailService;
            _notamService = notamService;


            this.validators = this.GetType()
               .GetProperties()
               .Where(p => this.GetValidations(p).Length != 0)
               .ToDictionary(p => p.Name, p => this.GetValidations(p));

            this.propertyGetters = this.GetType()
                .GetProperties()
                .Where(p => this.GetValidations(p).Length != 0)
                .ToDictionary(p => p.Name, p => this.GetValueGetter(p));
        }
示例#2
0
        public IntlNotamsSearchViewModel(IntlNotamService notamService,NotamService notamServiceLocal, AerodomService aerodomService, NotamCodeService notamcodeService, ObservableCollection<WorkspaceViewModel> parent)
            : this(notamService, aerodomService, notamcodeService)
        {
            parentWorkSpaces = parent;
            _notamServiceLocal = notamServiceLocal;

        }
示例#3
0
        public NotamSummaryViewModel(NotamService notamService, IntlNotamService intlnotamService, AerodomService aerodomService, NotamCodeService notamcodeService, ObservableCollection<WorkspaceViewModel> parent)
            : this(notamService, aerodomService, notamcodeService)
        {
            parentWorkSpaces = parent;
            _intlNotamService = intlnotamService;

        }
示例#4
0
         public AllIntlNotamsViewModel(IntlNotamService notamService, ObservableCollection<WorkspaceViewModel> parent, NotamFilter filter)
      {

          bDisplayByList = false;
          ParentWorkspaces = parent;
          _notamFilter = filter;
          Setup(notamService, filter.notamStatus, filter);

      }
示例#5
0
       // public event EventHandler<IList<Notam>> Reload;

        #region Constructor

         public AllIntlNotamsViewModel(IntlNotamService notamService, ObservableCollection<WorkspaceViewModel> parent, string notamStatus)
      {

          bDisplayByList = false;
          ParentWorkspaces = parent;

          Setup(notamService, notamStatus,null);

      }
示例#6
0
        public IntlNotamViewModel(IntlNotam notam, IntlNotamService notamService)
        {
            if (notam == null)
                throw new ArgumentNullException("notam");

            if (notamService == null)
                throw new ArgumentNullException("notamService");
            _notam = notam.Clone();
            _notamService = notamService;


            this.validators = this.GetType()
               .GetProperties()
               .Where(p => this.GetValidations(p).Length != 0)
               .ToDictionary(p => p.Name, p => this.GetValidations(p));

            this.propertyGetters = this.GetType()
                .GetProperties()
                .Where(p => this.GetValidations(p).Length != 0)
                .ToDictionary(p => p.Name, p => this.GetValueGetter(p));
        }
示例#7
0
        public IntlNotamsSearchViewModel(IntlNotamService notamService, AerodomService aerodomService, NotamCodeService notamcodeService)
        {
            if (notamService == null)
                throw new ArgumentNullException("notamService");

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

            _notamService = notamService;
            _aerodomService = aerodomService;
            _notamcodeService = notamcodeService;

            this.validators = this.GetType()
              .GetProperties()
              .Where(p => this.GetValidations(p).Length != 0)
              .ToDictionary(p => p.Name, p => this.GetValidations(p));

            this.propertyGetters = this.GetType()
                .GetProperties()
                .Where(p => this.GetValidations(p).Length != 0)
                .ToDictionary(p => p.Name, p => this.GetValueGetter(p));
        }
示例#8
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();


        }
示例#9
0
      public void Setup(IntlNotamService notamService, string notamStatus, NotamFilter filter)
      {
          if (notamService == null)
              throw new ArgumentNullException("notamService");
          switch(notamStatus)
          {
              case "A":
                  base.DisplayName = Entity.ArchiveNotamsViewModel_DisplayName;
                  break;
              case "H":
                  base.DisplayName = Entity.HoldNotamsViewModel_DisplayName;
                  break;
              case "AD":
                  base.DisplayName = Entity.AllArchAndValidNotamsViewModel_DisplayName;
                  break;
              default:
                  base.DisplayName = Entity.AllNotamsViewModel_DisplayName;
                  break;
          }
          _notamService = notamService;

          // Subscribe for notifications of when a new customer is saved.
//           _notamService.NotamAdded += this.OnNotamAddedToRepository;
//           _notamService.NotamDeleted += this.OnNotamDeletedFromRepository;
          // Reload += this.OnReload;

          // Populate the AllCustomers collection with CustomerViewModels.

          _notamStatus = notamStatus;
          if (filter != null)
              this.GetFilterNotams(filter);
          else
              this.CreateAllNotams(notamStatus);
         
          
                  
      }
示例#10
0
 public IntlNotamViewModel(IntlNotam notam, IntlNotamService notamService, ObservableCollection<WorkspaceViewModel> parent)
     : this(notam, notamService)
 {
     parentWorkSpaces = parent;
 }
示例#11
0
 public IntlNotamViewModel(IntlNotam notam, IntlNotamService notamService, ObservableCollection<WorkspaceViewModel> parent,string archiveReason)
     : this(notam, notamService,parent)
 {
     ArchiveReason = archiveReason;
 }
示例#12
0
文件: App.xaml.cs 项目: ali60/NOTAM
        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);