public void SetUp()
        {
            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _trackTransmitter    = new TrackTransmitter();
            _dateTimeBuilder     = new DateTimeBuilder();

            _trackObjectifier = new TrackObjectifier(_dateTimeBuilder);

            _trackReciever = new TrackReciever(_transponderReceiver,
                                               _trackObjectifier, _trackTransmitter);
            _output                 = Substitute.For <IOutput>();
            _tracksManager          = Substitute.For <ITracksManager>();
            _airspaceChecker        = Substitute.For <IAirspaceChecker>();
            _uut                    = new TagsManager(_airspaceChecker);
            _courseCalculator       = Substitute.For <ICourseCalculator>();
            _velocityCalculator     = Substitute.For <IVelocityCalculator>();
            _seperationEventChecker = Substitute.For <ISeperationEventChecker>();

            _trackWarehouse = new TrackWarehouse(_uut, _courseCalculator,
                                                 _velocityCalculator, _tracksManager, _seperationEventChecker);
            _atmController = new AtmController(_trackTransmitter, _output, _trackWarehouse);


            _list = new List <string> {
                "ATR423;39045;12932;14000;20151006213456000"
            };

            _trackTransmitter.TrackReady += (o, args) => { _recievedTracks = args.TrackList; };


            // Act
            _transponderReceiver.TransponderDataReady +=
                Raise.EventWith(new RawTransponderDataEventArgs(_list));
        }
Exemple #2
0
        public void Setup()
        {
            //Arrange
            _output = Substitute.For <IOutput>();

            _filePath = @"...\...\...\";
            FileStream   output     = new FileStream(_filePath + "SeperationLogFile.txt", FileMode.Create, FileAccess.Write);
            StreamWriter fileWriter = new StreamWriter(output);

            fileWriter.Write("");
            fileWriter.Close();

            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _trackTransmitter    = new TrackTransmitter();
            _dateTimeBuilder     = new DateTimeBuilder();

            _trackObjectifier = new TrackObjectifier(_dateTimeBuilder);

            _trackReciever = new TrackReciever(_transponderReceiver,
                                               _trackObjectifier, _trackTransmitter);
            _output                 = Substitute.For <IOutput>();
            _tracksManager          = new TracksManager();
            _courseCalculator       = new CourseCalculator();
            _velocityCalculator     = new VelocityCalculator();
            _seperationEventChecker = new SeperationEventChecker();

            _airspace = new Airspace()
            {
                MaxAltitude = 20000, MinAltitude = 500,
                Northeast   = new Corner()
                {
                    X = 90000, Y = 90000
                },
                Southwest = new Corner()
                {
                    X = 10000, Y = 10000
                }
            };

            _airspaceChecker = new AirspaceChecker(_airspace);
            _tagsManager     = new TagsManager(_airspaceChecker);
            _trackWarehouse  = new TrackWarehouse(_tagsManager, _courseCalculator,
                                                  _velocityCalculator, _tracksManager, _seperationEventChecker);
            _atmController = new AtmController(_trackTransmitter, _output, _trackWarehouse);

            _uut = new SeperationEventLogger(_output, _seperationEventChecker);

            _list = new List <string>
            {
                "ATR423;11000;11000;14000;20151006213456000",
                "ATR424;11000;11000;14000;20151006213456000"
            };

            _trackTransmitter.TrackReady += (o, args) => { _recievedTracks = args.TrackList; };

            //Act
            _transponderReceiver.TransponderDataReady +=
                Raise.EventWith(new RawTransponderDataEventArgs(_list));
        }
Exemple #3
0
        public void Create_WrongFormat_Exception()
        {
            var subject = new DateTimeBuilder();

            PropertyInfo wrongFormat = this.Property(nameof(WrongFormat));

            Assert.That(() => subject.Create(wrongFormat, null), Throws.InstanceOf <FormatException>());
        }
Exemple #4
0
        public void Create_NotAProperty_NoOp()
        {
            var    subject      = new DateTimeBuilder();
            object notAProperty = typeof(int);
            var    noOp         = subject.Create(notAProperty, null);

            Assert.That(noOp, Is.InstanceOf <NoSpecimen>());
        }
Exemple #5
0
        public void Create_SortableFormat_Utc()
        {
            var subject = new DateTimeBuilder();

            PropertyInfo rightFormat = this.Property(nameof(RightFormat));
            var          utc         = (DateTime)subject.Create(rightFormat, null);

            Assert.That(utc.Kind, Is.EqualTo(DateTimeKind.Utc));
        }
Exemple #6
0
        public void Create_SortableFormat_Date()
        {
            var subject = new DateTimeBuilder();

            PropertyInfo rightFormat = this.Property(nameof(RightFormat));
            var          date        = subject.Create(rightFormat, null);

            Assert.That(date, Is.InstanceOf(rightFormat.PropertyType));
        }
Exemple #7
0
        public void Create_NotADate_NoOp()
        {
            var subject = new DateTimeBuilder();

            PropertyInfo notADate = this.Property(nameof(NotADate));
            var          noOp     = subject.Create(notADate, null);

            Assert.That(noOp, Is.InstanceOf <NoSpecimen>());
        }
Exemple #8
0
        public void Parse_Failure(string text)
        {
            // arrange
            var parser = new DateTimeParser(new TokenEnumerator(new StringTokenReader(text)));

            // act
            var builder = new DateTimeBuilder(Reference);
            var result  = parser.TryMake(builder);

            // assert
            Assert.False(result);
        }
Exemple #9
0
        public override IFacet CreateFacet(FacetMoniker moniker)
        {
            try
            {
                var builder = DateTimeBuilder.FromXml(moniker.FactoryData);
                return(new DateTimeFacet(builder.DateTime, builder.Type));
            }
            catch (Exception)
            {
            }

            return(null);
        }
Exemple #10
0
        public override bool CanCreateFacet(FacetMoniker moniker)
        {
            try
            {
                DateTimeBuilder.FromXml(moniker.FactoryData);
                return(true);
            }
            catch (Exception)
            {
            }

            return(false);
        }
Exemple #11
0
        public void Parse_Success(string text, DateTime expected)
        {
            // arrange
            var parser = new DateTimeParser(new TokenEnumerator(new StringTokenReader(text)));

            // act
            var builder = new DateTimeBuilder(Reference);
            var result  = parser.TryMake(builder);

            // assert
            Assert.True(result);
            Assert.Equal(expected, builder.Build());
        }
Exemple #12
0
        public void SetUp()
        {
            _airspace = new Airspace()
            {
                MaxAltitude = 20000, MinAltitude = 500, Northeast = new Corner()
                {
                    X = 90000, Y = 90000
                }, Southwest = new Corner()
                {
                    X = 10000, Y = 10000
                }
            };
            FileStream    fs         = new FileStream(@"...\...\...\Airspace.xml", FileMode.Create);
            XmlSerializer serializer = new XmlSerializer(typeof(Airspace));

            serializer.Serialize(fs, _airspace);
            fs.Close();

            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _trackTransmitter    = new TrackTransmitter();
            _dateTimeBuilder     = new DateTimeBuilder();

            _trackObjectifier = new TrackObjectifier(_dateTimeBuilder);

            _trackReciever = new TrackReciever(_transponderReceiver,
                                               _trackObjectifier, _trackTransmitter);
            _output                 = Substitute.For <IOutput>();
            _tracksManager          = new TracksManager();
            _courseCalculator       = new CourseCalculator();
            _velocityCalculator     = new VelocityCalculator();
            _seperationEventChecker = new SeperationEventChecker();
            _seperationEventLogger  = new SeperationEventLogger(_output, _seperationEventChecker);
            _uut = new AirspaceFileReader();

            _airspaceChecker = new AirspaceChecker(_uut.Read());
            _tagsManager     = new TagsManager(_airspaceChecker);
            _trackWarehouse  = new TrackWarehouse(_tagsManager, _courseCalculator,
                                                  _velocityCalculator, _tracksManager, _seperationEventChecker);
            _atmController = new AtmController(_trackTransmitter, _output, _trackWarehouse);

            _list = new List <string>
            {
                "ATR423;11000;11000;14000;20151006213456000"
            };

            _trackTransmitter.TrackReady += (o, args) => { _recievedTracks = args.TrackList; };

            //Act
            _transponderReceiver.TransponderDataReady +=
                Raise.EventWith(new RawTransponderDataEventArgs(_list));
        }
Exemple #13
0
        public void SetUp()
        {
            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _trackTransmitter    = Substitute.For <ITrackTransmitter>();
            _uut = new DateTimeBuilder();

            _trackObjectifier = new TrackObjectifier(_uut);

            _trackReciever = new TrackReciever(_transponderReceiver, _trackObjectifier, _trackTransmitter);

            _list = new List <string> {
                "ATR423;39045;12932;14000;20151006213456000"
            };
        }
        static void Main(string[] args)
        {
            var airspace = new Airspace();

            try
            {
                AirspaceFileReader airspaceFileReader = new AirspaceFileReader();

                airspace = airspaceFileReader.Read();
            }
            catch (Exception e)
            {
                Console.WriteLine("Invalid Airspace" + e.ToString());
                Console.ReadKey();
            }

            var transponderReceiver = TransponderReceiverFactory.CreateTransponderDataReceiver();

            var dateTimeBuilder  = new DateTimeBuilder();
            var trackObjectifier = new TrackObjectifier(dateTimeBuilder);

            var trackTransmitter = new TrackTransmitter();

            var trackReciever = new TrackReciever(transponderReceiver, trackObjectifier, trackTransmitter);

            var airspaceChecker = new AirspaceChecker(airspace);

            var seperationEventChecker = new SeperationEventChecker();
            var output = new Output();
            var seperationEventLogger = new SeperationEventLogger(output, seperationEventChecker);

            var courseCalculator   = new CourseCalculator();
            var velocityCalculator = new VelocityCalculator();
            var tracksManager      = new TracksManager();
            var tagsManager        = new TagsManager(airspaceChecker);


            var trackWarehouse = new TrackWarehouse(tagsManager, courseCalculator, velocityCalculator,
                                                    tracksManager, seperationEventChecker);

            var atmController = new AtmController(trackTransmitter, output, trackWarehouse);

            Console.ReadKey();
        }
        public void SetUp()
        {
            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _uut             = new TrackTransmitter();
            _dateTimeBuilder = new DateTimeBuilder();

            _trackObjectifier = new TrackObjectifier(_dateTimeBuilder);

            _trackReciever = new TrackReciever(_transponderReceiver, _trackObjectifier, _uut);

            _list = new List <string> {
                "ATR423;39045;12932;14000;20151006213456000"
            };

            _uut.TrackReady += (o, args) => { _recievedTracks = args.TrackList; };

            // Act
            _transponderReceiver.TransponderDataReady +=
                Raise.EventWith(new RawTransponderDataEventArgs(_list));
        }
Exemple #16
0
        private void GetData()
        {
            DataTable dt       = new ExcelOper(FilePath).GetContentFromExcel();
            int       startRow = DataTableHelper.RowIndex(dt, "执行时间", 0);

            //生成模型
            for (int i = startRow + 1; i < dt.Rows.Count; i++)
            {
                PrintLogViewModel printLog = new PrintLogViewModel();
                printLog.ExecuteTime  = DateTimeBuilder.dtDateTime(dt.Rows[i][0].ToString());
                printLog.UserName     = dt.Rows[i][1].ToString();
                printLog.IPAddress    = dt.Rows[i][2].ToString();
                printLog.ComputerName = dt.Rows[i][3].ToString();
                printLog.MACAddress   = dt.Rows[i][4].ToString();
                printLog.ProgramName  = dt.Rows[i][5].ToString();
                printLog.PrintType    = dt.Rows[i][6].ToString();
                printLog.FileName     = dt.Rows[i][7].ToString();
                if (ShareDataEntity.GetSingleton().PrintLogCollection.Where(p => p.ExecuteTime == printLog.ExecuteTime && p.UserName == printLog.UserName && p.IPAddress == printLog.IPAddress && p.FileName == printLog.FileName).ToList().Count == 0)
                {
                    PrintLogList.Add(printLog);
                }
            }
        }
Exemple #17
0
        protected override IEnumerable <ParseResult> ParseImpl(ParseInput input, ParseMode mode, IList <Type> facetTypes)
        {
            var builder = new DateTimeBuilder();

            ParseInputTerm termMin     = null;
            ParseInputTerm termMax     = null;
            ParseInputTerm termCurrent = null;

            Func <bool> updateTermIndexes =
                () =>
            {
                if (termMin == null)
                {
                    termMin = termCurrent;
                }

                if (termMax != null && termMax != termCurrent && termMax.Ordinal != termCurrent.Ordinal - 1)
                {
                    return(false);
                }

                termMax = termCurrent;

                return(true);
            };

            Func <Group, Action <string>, bool> parseGroup =
                (grp, parse) =>
            {
                if (grp.Success)
                {
                    if (!updateTermIndexes())
                    {
                        return(false);
                    }

                    parse(grp.Value);
                }

                return(true);
            };

            var gotAmPm = false;

            foreach (var t in input.Terms)
            {
                termCurrent = t;

                foreach (var match in
                         from r in s_regexes
                         let m = r.Match(termCurrent.Text)
                                 where m.Success
                                 select m)
                {
                    if (!builder.Hour.HasValue && !parseGroup(match.Groups["hour"], val => builder.Hour = int.Parse(val)))
                    {
                        break;
                    }

                    if (!builder.Minute.HasValue && !parseGroup(match.Groups["minute"], val => builder.Minute = int.Parse(val)))
                    {
                        break;
                    }

                    if (!gotAmPm && !parseGroup(match.Groups["ampm"],
                                                val =>
                    {
                        gotAmPm = true;
                        builder.Hour += char.ToLower(val[0]) == 'p' ? 12 : 0;
                    }))
                    {
                        break;
                    }

                    //var hourminute = match.Groups["hourminute"];

                    //if (hourminute.Success)
                    //{}

                    if (!parseGroup(match.Groups["relativeday"],
                                    val =>
                    {
                        switch (val)
                        {
                        case "yesterday":
                            builder.SetDayFrom(DateTime.Today.AddDays(-1));
                            break;

                        case "today":
                            builder.SetDayFrom(DateTime.Today);
                            break;

                        case "tomorrow":
                            builder.SetDayFrom(DateTime.Today.AddDays(1));
                            break;
                        }
                    }))
                    {
                        break;
                    }
                }
            }

            if (builder.Type != 0)
            {
                var moniker = new FacetMoniker(GetType(), typeof(DateTimeFacet), builder.ToXml(),
                                               builder.ToString(), extraData: FacetExtraData.BeginWith(typeof(IDateTimeFacet), "Type", builder.Type.ToString()), iconPath: null);
                var parseResult = new ParseResult(input, input.GetTermsRange(termMin, termMax), moniker, 1.0);

                return(new[] { parseResult });
            }

            return(null);
        }
Exemple #18
0
        public void AddNewModelToMailQueueCollection(List <MailQueueModel> queueList)
        {
            int c = queueList.Count / 50;

            for (int i = 0; i < c; i++)
            {
                StringBuilder value = new StringBuilder();
                for (int j = 0; j < 50; j++)
                {
                    var    queueLog = queueList[i * 50 + j];
                    string temp     = string.Format("('{0}','{1}','{2}',{3},N'{4}',{5},N'{6}',N'{7}'),", queueLog.Guid, DateTimeBuilder.CommonStrDateTime(queueLog.StartTime), DateTimeBuilder.CommonStrDateTime(queueLog.EndTime), queueLog.Mask.ToString(), queueLog.SendMailAddress, queueLog.SendSize.ToString(), queueLog.Details, queueLog.MailID);
                    value.Append(temp);
                }
                string sql = string.Format("insert into T_QueueLog values {0}", value.ToString().TrimEnd(','));
                sqlo.getSomeDate(sql);
            }

            if (queueList.Count - c * 50 > 0)
            {
                string value2 = "";
                for (int i = c * 50; i < queueList.Count; i++)
                {
                    var    queueLog = queueList[i];
                    string temp     = string.Format("('{0}','{1}','{2}',{3},N'{4}',{5},N'{6}',N'{7}'),", queueLog.Guid, DateTimeBuilder.CommonStrDateTime(queueLog.StartTime), DateTimeBuilder.CommonStrDateTime(queueLog.EndTime), queueLog.Mask.ToString(), queueLog.SendMailAddress, queueLog.SendSize.ToString(), queueLog.Details, queueLog.MailID);
                    value2 += temp;
                }
                string sql2 = string.Format("insert into T_QueueLog values {0}", value2.TrimEnd(','));
                sqlo.getSomeDate(sql2);
            }
        }
Exemple #19
0
        public void AddNewModelToMailSmtpCollection(List <MailSmtpModel> smtpList)
        {
            int c = smtpList.Count / 5;

            for (int i = 0; i < c; i++)
            {
                StringBuilder value = new StringBuilder();
                for (int j = 0; j < 5; j++)
                {
                    var    smtpLog = smtpList[i * 5 + j];
                    string temp    = string.Format("('{0}','{1}','{2}',{3},N'{4}',N'{5}',N'{6}',{7},{8},N'{9}'),", smtpLog.Guid, DateTimeBuilder.CommonStrDateTime(smtpLog.StartTime), DateTimeBuilder.CommonStrDateTime(smtpLog.EndTime), smtpLog.Mask.ToString(), smtpLog.IPAddress, smtpLog.SendMailAddress, smtpLog.ReserveMailAddress, smtpLog.MaxSize.ToString(), smtpLog.ReserveSize.ToString(), smtpLog.Details);
                    value.Append(temp);
                }
                string sql = string.Format("insert into T_SmtpLog values {0}", value.ToString().TrimEnd(','));
                sqlo.getSomeDate(sql);
            }

            if (smtpList.Count - c * 5 > 0)
            {
                string value2 = "";
                for (int i = c * 5; i < smtpList.Count; i++)
                {
                    var    smtpLog = smtpList[i];
                    string temp    = string.Format("('{0}','{1}','{2}',{3},N'{4}',N'{5}',N'{6}',{7},{8},N'{9}'),", smtpLog.Guid, DateTimeBuilder.CommonStrDateTime(smtpLog.StartTime), DateTimeBuilder.CommonStrDateTime(smtpLog.EndTime), smtpLog.Mask.ToString(), smtpLog.IPAddress, smtpLog.SendMailAddress, smtpLog.ReserveMailAddress, smtpLog.MaxSize.ToString(), smtpLog.ReserveSize.ToString(), smtpLog.Details);
                    value2 += temp;
                }
                string sql2 = string.Format("insert into T_SmtpLog values {0}", value2.TrimEnd(','));
                sqlo.getSomeDate(sql2);
            }
        }
Exemple #20
0
        public void AddNewModelToPrintLogCollection(List <PrintLogViewModel> printLogList)
        {
            int c = printLogList.Count / 50;

            for (int i = 0; i < c; i++)
            {
                StringBuilder value = new StringBuilder();
                for (int j = 0; j < 50; j++)
                {
                    var    printLog = printLogList[i * 50 + j];
                    string temp     = string.Format("('{0}','{1}',N'{2}',N'{3}',N'{4}',N'{5}',N'{6}',N'{7}',N'{8}'),", printLog.Guid, DateTimeBuilder.CommonStrDateTime(printLog.ExecuteTime), printLog.UserName, printLog.IPAddress, printLog.ComputerName, printLog.MACAddress, printLog.ProgramName, printLog.PrintType, printLog.FileName);

                    value.Append(temp);
                }
                string sql = string.Format("insert into T_PrintLog values {0}", value.ToString().TrimEnd(','));
                sqlo.getSomeDate(sql);
            }

            if (printLogList.Count - c * 50 > 0)
            {
                string value2 = "";
                for (int i = c * 50; i < printLogList.Count; i++)
                {
                    var    printLog = printLogList[i];
                    string temp     = string.Format("('{0}','{1}',N'{2}',N'{3}',N'{4}',N'{5}',N'{6}',N'{7}',N'{8}'),", printLog.Guid, DateTimeBuilder.CommonStrDateTime(printLog.ExecuteTime), printLog.UserName, printLog.IPAddress, printLog.ComputerName, printLog.MACAddress, printLog.ProgramName, printLog.PrintType, printLog.FileName);
                    value2 += temp;
                }
                string sql2 = string.Format("insert into T_PrintLog values {0}", value2.TrimEnd(','));
                sqlo.getSomeDate(sql2);
            }

            UpdatePrintLogCollection();
        }