Example #1
0
        /// <summary>
        /// Places the specified origin into the repository.
        /// If the origin is already in the repository, an
        /// exception is not thrown.
        /// </summary>
        public void Insert(IntlNotam notam)
        {

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

            if (!_Notams.Contains(notam))
            {
                _Notams.Add(notam);
                _dataContext.IntlNotams.InsertOnSubmit(notam);

                #region Refrence IntlNotam
                if (notam.RefId > 0)
                {
                    NotamArchive archive = null;
                    var refNotam = _Notams.Where(n => n.Id.Equals(notam.RefId)).First();
                    if (refNotam != null)
                        refNotam.Status = "A";
                    if (notam.NotamType.Equals("R"))
                        archive = new NotamArchive()
                        {
                            Id = refNotam.Id,
                            Reason =
                                String.Format(NotamArchive.ReplacedBy, DateTime.Now.ToString())
                        };
                    else if (notam.NotamType.Equals("C"))
                        archive = new NotamArchive()
                        {
                            Id = refNotam.Id,
                            Reason =
                                String.Format(NotamArchive.CancledBy, DateTime.Now.ToString())
                        };

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

                _dataContext.SubmitChanges();
                if (this.NotamAdded != null)
                    this.NotamAdded(this, new EntityAddedEventArgs<IntlNotam>(notam));

            }
        }
Example #2
0
        public  void Archive()
        {
            //add0519
            var archNotams =
                _Notams.Where(
                    n => n.Status.Equals("D") && !string.IsNullOrEmpty(n.ToDate) && string.IsNullOrEmpty(n.PermEst) 
                        && long.Parse(n.ToDate) < long.Parse(DateTime.Now.ToString("yyMMddHHmm"))).ToList();
            foreach (var item in archNotams)
            {
                item.Status = "A";

                #region Notam Archive

                var archive = new NotamArchive()
                                  {
                                      Id = item.Id,
                                      Reason =
                                          String.Format(NotamArchive.ToDateExpired, DateTime.Now.ToString())
                                  };


                _NotamArchives.Add(archive);
                _dataContext.NotamArchives.InsertOnSubmit(archive);
                _dataContext.SubmitChanges();

                #endregion
            }

            //cancel notam
            archNotams =
                _Notams.Where(
                    n => n.Status.Equals("D") && n.NotamType=="C").ToList();
            foreach (var item in archNotams)
            {
                item.Status = "A";

                #region Notam Archive

                var archive = new NotamArchive()
                {
                    Id = item.Id,
                    Reason =
                        String.Format(NotamArchive.IsCancel)
                };


                _NotamArchives.Add(archive);
                _dataContext.NotamArchives.InsertOnSubmit(archive);
                _dataContext.SubmitChanges();

                #endregion
            }
        }
Example #3
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 #4
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();

        }