Example #1
0
 public NotamTextViewModel(Notam notam)
 {
     if (notam == null)
         throw new ArgumentNullException("notam");
     _notam = notam;
     
 }
Example #2
0
 public void Insert(Notam notam)
 {
     
     if (notam == null)
         throw new ArgumentNullException("notam");
     List<Notam> listNotams=_Notams;
     switch (notam.Status[0])
     {
         case 'H':
             listNotams = _HoldNotams;
             break;
         case 'A':
             listNotams = _ArchNotams;
             break;
     }
     if (!listNotams.Contains(notam))
     {
         listNotams.Add(notam);
         _dataContext.Notams.InsertOnSubmit(notam);
     }
     _dataContext.SubmitChanges();
     if (this.NotamAdded != null)
         this.NotamAdded(this, new EntityAddedEventArgs<Notam>(notam));
       
     
 }
Example #3
0
        public NotamViewModel(Notam notam, NotamService notamService)
        {
            if (notam == null)
                throw new ArgumentNullException("notam");

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

            _notam = notam;
            _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));
        }
Example #4
0
        public void Archive(Notam notam)
        {
            NotamArchive archive = null;

            if (notam.Status.Equals("D"))
            {
                notam.Status = "A";
                archive = new NotamArchive()
                {
                    Id = notam.Id,
                    Reason =
                        String.Format(NotamArchive.ForcedBy, DateTime.Now.ToString())
                };
                _NotamArchives.Add(archive);
                _dataContext.NotamArchives.InsertOnSubmit(archive);

                _dataContext.SubmitChanges();
                _Notams = LoadNotams(_dataContext);
                _ArchNotams = LoadArchiveNotams(_dataContext);
            }
        }
Example #5
0
        public void UpdateWithNumber(Notam notam)
        {
            if (string.IsNullOrEmpty(notam.Number))
            {
                var curNumber = (from n in _dataContext.Notams
                                 where (n.Type.Equals(notam.Type) && n.Year.Equals(DateTime.Now.Year.ToString().Substring(2)) && !n.Status.Equals("H"))
                                 orderby n.Number descending
                                 select n.Number).FirstOrDefault();
                if (string.IsNullOrEmpty(curNumber))
                    curNumber = "0";

                int iNextNum = (Int32.Parse(curNumber) + 1);
                notam.Number = string.Format("{0:0000}", iNextNum );
            }
            notam.Status = "D";
            Update(notam);
            if (notam.RefId > 0)
            {
                NotamArchive archive = null;
                var refNotam = _Notams.Where(n => n.Id.Equals(notam.RefId)).FirstOrDefault();
                if(refNotam==null)
                    return;
                refNotam.Status = "A";
                if (notam.NotamType.Equals("R"))
                    archive = new NotamArchive()
                    {
                        Id = refNotam.Id,
                        Reason =
                            String.Format(NotamArchive.ReplacedBy, DateTime.Now.ToString(), notam.Number)
                    };
                else if (notam.NotamType.Equals("C"))
                    archive = new NotamArchive()
                    {
                        Id = refNotam.Id,
                        Reason =
                            String.Format(NotamArchive.CancledBy, DateTime.Now.ToString(), notam.Number)
                    };

                if (archive != null)
                {
                    _NotamArchives.Add(archive);
                    _dataContext.NotamArchives.InsertOnSubmit(archive);
                    Archive();
                }
            }
            _dataContext.SubmitChanges();

        }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="origin"></param>
        public void Update(Notam notam)
        {
            //_dataContext.Origins.OnSubmit(origin);
            _dataContext.SubmitChanges();
            Reload();

        }
Example #7
0
        public void Hold(Notam notam)
        {
            if (notam == null)
                throw new ArgumentNullException("notam");

            if (!_Notams.Contains(notam))
            {
                _Notams.Add(notam);
                _dataContext.Notams.InsertOnSubmit(notam);
                _dataContext.SubmitChanges();
                if (this.NotamAdded != null)
                    this.NotamAdded(this, new EntityAddedEventArgs<Notam>(notam));
            }
        }
Example #8
0
        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;

        }
Example #9
0
        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;
            }
        }
Example #10
0
using System;
Example #11
0
 public NotamViewModel(Notam notam, NotamService notamService, ObservableCollection<WorkspaceViewModel> parent):this(notam,notamService)
 {
     parentWorkSpaces = parent;
 }
Example #12
0
 public NotamViewModel(Notam notam, NotamService notamService, ObservableCollection<WorkspaceViewModel> parent,string archiveReason)
     : this(notam, notamService,parent)
 {
     ArchiveReason = archiveReason;
 }
Example #13
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");
        }
Example #14
0
 public MainWindowViewModel(NotamDataContext dataContext, Notam notam):this(dataContext)
 {
   NotamViewModel workspace = new NotamViewModel(notam, _notamService, Workspaces);
     this.Workspaces.Add(workspace);
     this.SetActiveWorkspace(workspace);
 }
Example #15
0
        /// <summary>
        /// Returns true if the specified origin exists in the
        /// repository, or false if it is not.
        /// </summary>
        public bool ContainsNotam(Notam notam)
        {
            if (notam == null)
                throw new ArgumentNullException("notam");

            return _Notams.Contains(notam) || _HoldNotams.Contains(notam);
        }
Example #16
0
 /// <summary>
 /// Creates a new repository of origins.
 /// </summary>
 /// <param name="originDataFile">The relative path to an XML resource file that contains origin data.</param>
 public NotamSender(Notam notam)
 {
     _notam = notam;
 }
Example #17
0
 public static  Notam ConvertToNotam(IntlNotam nt)
 {
     Notam n=new Notam();
     n.Code_Id = nt.Code_Id;
     n.Id = nt.Id;
     n.Number = nt.Number;
     n.Origin = nt.Origin;
     n.DFreeText = nt.DFreeText;
     n.EFreeText = nt.EFreeText;
     n.FFreeText = nt.FFreeText;
     n.FIR = nt.FIR;
     n.Fir_Id = nt.Fir_Id;
     n.FirA2 = nt.FirA2;
     n.FirA3 = nt.FirA3;
     n.FirA4 = nt.FirA4;
     n.FirA5 = nt.FirA5;
     n.FirAero = nt.FirAero;
     n.FromDate = nt.FromDate;
     n.FromRDate = nt.FromRDate;
     n.GFreeText = nt.GFreeText;
     n.HigherLimit = nt.HigherLimit;
     n.Latitude = nt.Latitude;
     n.Longtitude = nt.Longtitude;
     n.LowerLimit = nt.LowerLimit;
     n.NotamCode = nt.NotamCode;
     n.NotamType = nt.NotamType;
     n.Origin_Id = nt.Origin_Id;
     n.PermEst = nt.PermEst;
     n.Radius = nt.Radius;
     n.RefId = nt.RefId;
     n.RefNum = nt.RefNum;
     n.RefType = nt.RefType;
     n.RefYear = nt.RefType;
     n.SendTime = nt.SendTime;
     n.Status = nt.Status;
     n.ToDate = nt.ToDate;
     n.ToRDate = nt.ToRDate;
     n.Type = nt.Type;
     n.Year = nt.Year;
     return n;
 }