Esempio n. 1
0
        public IHttpActionResult PutDateTable(int id, DateTable dateTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dateTable.Id)
            {
                return(BadRequest());
            }

            db.Entry(dateTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DateTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public void TestUpdatedOnWithTable()
        {
            var o = DateTable.AsLoad(1, "tom");

            DbEntry.Update(o);
            Assert.AreEqual("UPDATE [DateTable] SET [Name]=@Name_0,[UpdatedOn]=DATETIME(CURRENT_TIMESTAMP, 'localtime')  WHERE [Id] = @Id_1;\n<Text><30>(@Name_0=tom:String,@Id_1=1:Int64)", StaticRecorder.LastMessage);
        }
Esempio n. 3
0
        public static async Task InsertDateAsync()
        {
            await DateTable.InsertDate(CommandInsertModel.InsertDate());

            DateContextList.Add(CommandModel.GetDateContext());
            return;
        }
Esempio n. 4
0
        public static async Task <IList <string> > GetDatesAsync()
        {
            IList <string> Dates = new List <string>();

            Dates = await DateTable.ReadDateTable(CommandReadModel.ReadDateTable());

            return(Dates);
        }
Esempio n. 5
0
        public void TestCreatedOnWithTable()
        {
            var o = new DateTable {
                Name = "tom"
            };

            DbEntry.Insert(o);
            Assert.AreEqual("INSERT INTO [DateTable] ([CreatedOn],[Name]) VALUES (DATETIME(CURRENT_TIMESTAMP, 'localtime'),@Name_0);\nSELECT LAST_INSERT_ROWID();\n<Text><30>(@Name_0=tom:String)", StaticRecorder.LastMessage);
        }
Esempio n. 6
0
        private void PingOne(int index)
        {
            if (mainTable[index].Endpoint == string.Empty)
            {
                var ip = NetTest.GetIP(mainTable[index].HostsName);

                if (ip != null)
                {
                    mainTable[index].Endpoint = ip.AddressFamily == AddressFamily.InterNetwork ? $@"{ip}:{rawTable[index].Port}" : $@"[{ip}]:{rawTable[index].Port}";
                }
                else
                {
                    return;
                }
            }

            var    ipe     = IPFormatter.ToIPEndPoint(mainTable[index].Endpoint);
            double?latency = null;
            var    res     = Timeout;
            var    time    = DateTime.Now;

            try
            {
                latency = NetTest.TCPing(ipe.Address, ipe.Port, Timeout);
            }
            catch
            {
                // ignored
            }

            if (latency != null)
            {
                res = Convert.ToInt32(Math.Round(latency.Value));
            }
            else
            {
                //notifyIcon1.ShowBalloonTip(1000, time.ToString(CultureInfo.CurrentCulture), $"{mainTable[index].HostsName}\n{ipe}", ToolTipIcon.Error);
            }

            var log = new DateTable
            {
                Date    = time,
                Latency = res
            };

            mainTable[index].AddNewLog(log);

            if (MainList.SelectedRows.Count == 1)
            {
                var i = MainList.SelectedRows[0].Cells[0].Value as int?;
                if (i == index && DateList.Visible)
                {
                    DateList.Invoke(() => { LoadLogs(log); });
                }
            }
        }
Esempio n. 7
0
        public IHttpActionResult GetDateTable(int id)
        {
            DateTable dateTable = db.DateTables.Find(id);

            if (dateTable == null)
            {
                return(NotFound());
            }

            return(Ok(dateTable));
        }
Esempio n. 8
0
        public IHttpActionResult PostDateTable(DateTable dateTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DateTables.Add(dateTable);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = dateTable.Id }, dateTable));
        }
Esempio n. 9
0
        public IHttpActionResult DeleteDateTable(int id)
        {
            DateTable dateTable = db.DateTables.Find(id);

            if (dateTable == null)
            {
                return(NotFound());
            }

            db.DateTables.Remove(dateTable);
            db.SaveChanges();

            return(Ok(dateTable));
        }
Esempio n. 10
0
 private void LoadLogs(DateTable log)
 {
     try
     {
         DateTable.Add(log);
         if (DateList.SelectedRows.Count == 0)
         {
             DateList.Rows[0].Selected = true;
         }
     }
     catch
     {
         // ignored
     }
 }
Esempio n. 11
0
        public void TestCreatingCsvByteArray()
        {
            Car[] cars = new Car[10]
            {
                new Car(1, "52-XX-53", "red", 2020),
                new Car(1, "25-RR-66", "blue", 2015),
                new Car(1, "11-FF-98", "orange", 2014),
                new Car(1, "57-HH-35", "black", 2015),
                new Car(1, "85-NN-00", "orange", 2019),
                new Car(1, "35-VV-98", "red", 2010),
                new Car(1, "09-UU-85", "blue", 2019),
                new Car(1, "56-QQ-23", "blue", 2016),
                new Car(1, "00-DD-11", "red", 2012),
                new Car(1, "11-MM-25", "black", 2017)
            };

            var dataTable = new DateTable <Car>(cars);
            var result    = dataTable.ToByteArrayCsv();

            Assert.True(Encoding.ASCII.GetBytes(CsvStringExpected()).StructuralEquals(result));
        }
Esempio n. 12
0
        public bool TestCreatingCsvString()
        {
            Car[] cars = new Car[10]
            {
                new Car(1, "52-XX-53", "red", 2020),
                new Car(1, "25-RR-66", "blue", 2015),
                new Car(1, "11-FF-98", "orange", 2014),
                new Car(1, "57-HH-35", "black", 2015),
                new Car(1, "85-NN-00", "orange", 2019),
                new Car(1, "35-VV-98", "red", 2010),
                new Car(1, "09-UU-85", "blue", 2019),
                new Car(1, "56-QQ-23", "blue", 2016),
                new Car(1, "00-DD-11", "red", 2012),
                new Car(1, "11-MM-25", "black", 2017)
            };

            var dataTable = new DateTable <Car>(cars);
            var result    = dataTable.ToStringCsv();

            return(true);
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file =
                new System.IO.StreamReader("test03.TXT");

            myModel context = new myModel();

            while ((line = file.ReadLine()) != null)
            {
                char[] temp = line.ToCharArray();
                if (checkFirstFormat(temp) == true)
                {
                    string index0_12  = String.Empty;
                    string index13_20 = String.Empty;
                    string index21_28 = String.Empty;

                    for (int i = 0; i < temp.Count(); i++)
                    {
                        if (i >= 0 && i <= 12)
                        {
                            index0_12 = index0_12 + temp[i];
                        }
                        else if (i >= 13 && i <= 20)
                        {
                            index13_20 = index13_20 + temp[i];
                        }
                        else if (i >= 21 && i <= 28)
                        {
                            index21_28 = index21_28 + temp[i];
                        }
                    }

                    // Console.WriteLine(index0_12 + " " + index13_20 + " " + index21_28);

                    if (index13_20 == "99999999")
                    {
                        DateTable data = new DateTable()
                        {
                            TickNumber = index0_12,
                            FlyingDay  = DateTime.MaxValue,
                            Birthday   = DateTime.ParseExact(index21_28, "yyyyMMdd", null)
                        };

                        context.DateTable.Add(data);
                        context.SaveChanges();
                    }
                    else
                    {
                        DateTable data = new DateTable()
                        {
                            TickNumber = index0_12,
                            FlyingDay  = DateTime.ParseExact(index13_20, "yyyyMMdd", null),
                            Birthday   = DateTime.ParseExact(index21_28, "yyyyMMdd", null)
                        };

                        context.DateTable.Add(data);
                        context.SaveChanges();
                    }
                }
            }


            var list = context.DateTable.ToList();

            foreach (var l in list)
            {
                Console.WriteLine(l.TickNumber + " " + l.FlyingDay.ToString("yyyy/MM/dd") + " " + l.Birthday.ToString("yyyy/MM/dd"));
            }


            file.Close();
            Console.ReadLine();
        }