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));
        }
Beispiel #2
0
        public void Hold()
        {
            if (string.IsNullOrEmpty(_notam.Number))
                if (ToDate != null && ToDate.Length > 0)
                {
                    CultureInfo MyCultureInfo = new CultureInfo("en-US");
                    DateTime dtfrom = DateTime.ParseExact(FromDate, "yyMMddHHmm", CultureInfo.InvariantCulture);
                    DateTime dtto = DateTime.ParseExact(ToDate, "yyMMddHHmm", CultureInfo.InvariantCulture);
                    TimeSpan s = dtto.Subtract(dtfrom);
                    if (s.Days > 90)
                    {
                        MessageBoxResult dresult = MessageBox.Show("Different between FromDate And ToDate is more than 90 days\nAre you sure want to hold?", "Caution", MessageBoxButton.YesNo);
                        if (dresult == MessageBoxResult.No)
                            return;

                    }
                }
            Localize();
            if (!_notam.IsValid)
                throw new InvalidOperationException(Entity.OriginViewModel_Exception_CannotSave);

            if (string.IsNullOrEmpty(_notam.HigherLimit))
                _notam.HigherLimit = "999";
            if (string.IsNullOrEmpty(_notam.LowerLimit))
                _notam.LowerLimit = "000";
            
            Notam nt = IntlNotamService.ConvertToNotam(_notam);
            var notamDetail = NOTAM.SERVICE.Model.NotamDetail.CreateNewNotamDetail(nt);
            var detailService = new NotamDetailService(_notamService._dataContext);
//             var result = detailService.GetByNotamId(_notam.Id);
//             if (result != null)
//                 notamDetail = result;
            var workspace = new IntlNotamDetailViewModel(notamDetail, detailService, _notamService, parentWorkSpaces, this);
            parentWorkSpaces.Add(workspace);
            workspace.FreeStyle = FreeStyle;


            this.SetActiveWorkspace(workspace);

        }
Beispiel #3
0
 public List<Notam> GetFilterNotams(NotamFilter notamFilter)
 {
     List<Notam> result = new List<Notam>();
     Reload();
     List<Notam> sourceNotams = _Notams;
     if (notamFilter.notamStatus == "A")
         sourceNotams = _ArchNotams;
     else if (notamFilter.notamStatus == "H")
         sourceNotams = _HoldNotams;
     else if (notamFilter.notamStatus == "AD")
         sourceNotams = GetAllNotams();
     if (_dataContext != null)
     {
         try
         {
             result = sourceNotams.Where(
                 n => (String.IsNullOrEmpty(notamFilter.TypeFilter) || n.Type.Equals(notamFilter.TypeFilter))).Where(
                     n =>
                     (String.IsNullOrEmpty(notamFilter.NumberFilter) || (!String.IsNullOrEmpty(n.Number) && n.Number.Equals(notamFilter.NumberFilter)))).Where(
                 n => (String.IsNullOrEmpty(notamFilter.YearFilter) || n.Year.Equals(notamFilter.YearFilter))).Where(
                     n =>
                     (String.IsNullOrEmpty(notamFilter.NotamCodeFilter) || (n.NotamCode != null && (n.NotamCode.ToString() == (notamFilter.NotamCodeFilter))))).
                     Where(
                     n =>
                     (String.IsNullOrEmpty(notamFilter.NotamAeroFilter) || (!String.IsNullOrEmpty(n.FirAero) && (n.FirAero).Equals(notamFilter.NotamAeroFilter))))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.FromDateFilter) || long.Parse(n.FromDate) >= long.Parse(notamFilter.FromDateFilter)))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.ToDateFilter) || (!String.IsNullOrEmpty(n.ToDate) && long.Parse(n.ToDate) <= long.Parse(notamFilter.ToDateFilter))))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.ItemEFilter) || (!String.IsNullOrEmpty(n.EFreeText)) && n.EFreeText.Contains(notamFilter.ItemEFilter)))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.NotamFirFilter) || (n.FIR != null) && n.FIR.Code.Equals(notamFilter.NotamFirFilter)))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.TrafficFilter) || (n.NotamCode != null && !String.IsNullOrEmpty(n.NotamCode.Traffic)) && n.NotamCode.Traffic.Equals(notamFilter.TrafficFilter)))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.PurposeFilter) || (n.NotamCode != null && !String.IsNullOrEmpty(n.NotamCode.Purpose)) && n.NotamCode.Purpose.Equals(notamFilter.PurposeFilter)))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.ScopeFilter) || (n.NotamCode != null && !String.IsNullOrEmpty(n.NotamCode.Scope)) && n.NotamCode.Scope.Equals(notamFilter.ScopeFilter)))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.SendTimeFilter) || (!String.IsNullOrEmpty(n.SendTime) && long.Parse(n.SendTime) >= long.Parse(notamFilter.SendTimeFilter))))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.SendTimeEndFilter) || (!String.IsNullOrEmpty(n.SendTime) && long.Parse(n.SendTime) <= long.Parse(notamFilter.SendTimeEndFilter))))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.PermEstFilter) || (!String.IsNullOrEmpty(n.PermEst)) && n.PermEst.Equals(notamFilter.PermEstFilter)))
                     .Where(n => (String.IsNullOrEmpty(notamFilter.PermEstFilter) || notamFilter.PermEstFilter.Equals("PERM") || (notamFilter.PermEstFilter.Equals("EST") && !(string.IsNullOrEmpty(n.ToDate)) 
                             && n.PermEst.Equals(notamFilter.PermEstFilter) && long.Parse(n.ToDate) <= long.Parse(DateTime.Now.ToString("yyMMddHHmm")))))
                     .ToList();
             if (!string.IsNullOrEmpty( notamFilter.UserFilter))
             {
                 NotamDetailService notamDetailService = new NotamDetailService(_dataContext);
                 result= notamDetailService.FilterByUser(result, notamFilter.UserFilter);
             }
         }
         catch (System.Exception ex)
         {
             string s = ex.Message;
         }
     }
     return result;
 }
Beispiel #4
0
        public void Hold()
        {
            
            if (string.IsNullOrEmpty(_notam.Number))
            if (ToDate != null && ToDate.Length > 0)
            {
                CultureInfo MyCultureInfo = new CultureInfo("en-US");
                DateTime dtfrom = DateTime.ParseExact(FromDate, "yyMMddHHmm", CultureInfo.InvariantCulture);
                DateTime dtto = DateTime.ParseExact(ToDate, "yyMMddHHmm", CultureInfo.InvariantCulture);
                TimeSpan s = dtto.Subtract(dtfrom);
                if (s.Days > 90)
                {
                    MessageBoxResult dresult = MessageBox.Show("Different between FromDate And ToDate is more than 90 days\nAre you sure want to hold?", "Caution", MessageBoxButton.YesNo);
                    if (dresult == MessageBoxResult.No)
                        return ;

                }
            }
            if (!_notam.IsValid)
                throw new InvalidOperationException(Entity.OriginViewModel_Exception_CannotSave);

            if (string.IsNullOrEmpty(_notam.HigherLimit))
                _notam.HigherLimit = "999";
            if (string.IsNullOrEmpty(_notam.LowerLimit))
                _notam.LowerLimit = "000";
            if (_FreeStyle)
            {
                if (!_notamService.CheckUnique(NotamNum, Type, Year))
                {
                    MessageBox.Show("Invalid NOTAM Number", "ERROR");
                    return;

                }
                _notamService.UpdateWithNumber(_notam);
            }
            else
            {
                if (this.IsNewNotam)
                {
                    _notamService.Insert(_notam);
                }
                else
                {
                    if (string.IsNullOrEmpty(_notam.Number))
                        _notamService.Update(_notam);
                    else
                        _notam = _notamService.GetByNumber(_notam.Number, _notam.Type, _notam.Year);
                }

            }
            var notamDetail = NOTAM.SERVICE.Model.NotamDetail.CreateNewNotamDetail(_notam);
            var detailService = new NotamDetailService(_notamService._dataContext);
            var result = detailService.GetByNotamId(_notam.Id);
            if (result != null)
                notamDetail = result;
            var workspace = new NotamDetailViewModel(notamDetail, detailService,_notamService, parentWorkSpaces,this);
            parentWorkSpaces.Add(workspace);
            workspace.FreeStyle = FreeStyle;


            this.SetActiveWorkspace(workspace);
            
            OnPropertyChanged("NotamNum");
        }
Beispiel #5
0
 public void Send()
 {
     _notamService.UpdateWithNumber(_notam);
     base.OnPropertyChanged("NotamNum");
     base.OnPropertyChanged("DisplayName");
    var notamDetail = NOTAM.SERVICE.Model.NotamDetail.CreateNewNotamDetail(_notam) ;
    var detailService = new NotamDetailService(_notamService._dataContext);
     var result = detailService.GetByNotamId(_notam.Id);
     if (result != null)
         notamDetail = result;
     var workspace = new NotamDetailViewModel(notamDetail, detailService,_notamService,parentWorkSpaces,this);
    parentWorkSpaces.Add(workspace);
    this.SetActiveWorkspace(workspace);
 }