Esempio n. 1
0
 public Paciente(string nome, string cpf, string numero, DataTime nascimento)
 {
     this.nome       = nome;
     this.cpf        = cpf;
     this.numero     = numero;
     this.nascimento = nascimento;
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     DataTime dt = new DataTime(2020, 08, 19, 07, 23, 07);
     
     WriteLine("{0:yyyy-MM-dd HH:mm:ss (dddd)}", dt);
     CultureInfo ciKo = new CultureInfo("ko-KR);
     WriteLine(dt.ToString("yyyy-MM-dd tt hh:mm:ss (ddd)", ciKo));
 }
Esempio n. 3
0
 public pessoa(string nomeDaPessoa, DataTime dataDeNascimento, string categodiraDaCnh)
 {
     this.nome         = nomeDaPessoa;
     this.nascimento   = dataDeNascimento;
     this.Cpf          = Cpf;
     this.CategoriaCnh = categodiraDaCnh;
     CarrosPossuidos   = new List <Carro>();
     CarrosDirigidos   = new List <Carro>();
 }
Esempio n. 4
0
    // Reset the data manager, init vars and set update flag
    public void Reset()
    {
        // Init vars
        score         = 0;
        lastShapeSize = 2;
        lastscore     = PlayerPrefs.GetInt(DataPrefs.LastScore);
        highscore     = PlayerPrefs.GetInt(DataPrefs.Highscore);
        timePlayed    = new DataTime();

        // Enable data update and set gameoverpanel deactivate
        updateData = true;
    }
Esempio n. 5
0
        public ObjectBase(string name, object target, bool locked, int priority)
        {
            if (target == null)
            {
                throw;
            }

            m_Name        = name ?? string.Empty;
            m_Target      = target;
            m_Locked      = locked;
            m_Priority    = priority;
            m_LastUseTime = DateTime.Now;
        }
Esempio n. 6
0
        public static string stat(string strg)
        {
            if (strg == null || strg == "")
            {
                return(string.Empty);
            }
            int             mediane, range, average = 0;
            List <DataTime> ListResultsRace = new List <DataTime>();

            foreach (string e in strg.Split(','))
            {
                ListResultsRace.Add(new DataTime(e));
            }
            ListResultsRace.Sort(delegate(DataTime dt, DataTime dt2) { return(dt.TimeInSeconds.CompareTo(dt2.TimeInSeconds)); });
            range   = FindRange();
            average = FindAverage();
            mediane = FindMediane();

            return(string.Format("Range: {0} Average: {1} Median: {2}",
                                 DataTime.FormatSecondsToHMS(range),
                                 DataTime.FormatSecondsToHMS(average),
                                 DataTime.FormatSecondsToHMS(mediane)));

            #region SupportFunctions

            int FindRange()
            {
                int rangeMax = 0;

                ListResultsRace.ForEach(delegate(DataTime dt) { rangeMax = dt.TimeInSeconds > rangeMax ? dt.TimeInSeconds : rangeMax; });
                int rangeMin = rangeMax;

                ListResultsRace.ForEach(delegate(DataTime dt) { rangeMin = dt.TimeInSeconds < rangeMin ? dt.TimeInSeconds : rangeMin; });
                return(rangeMax - rangeMin);
            }

            int FindMediane()
            {
                return(ListResultsRace.Count % 2 == 1 ? ListResultsRace[ListResultsRace.Count / 2].TimeInSeconds :
                       (ListResultsRace[ListResultsRace.Count / 2 - 1].TimeInSeconds + ListResultsRace[ListResultsRace.Count / 2].TimeInSeconds) / 2);
            }

            int FindAverage()
            {
                ListResultsRace.ForEach(delegate(DataTime dt) { average += dt.TimeInSeconds; });
                return(average / ListResultsRace.Count);
            }

            #endregion
        }
Esempio n. 7
0
        //przykladowe generowanie tokena
        public string BuildToken(User user, string secret, string issure, DataTime expirationDate, string serverPath)
        {
            var key         = new SymetricSecutiryKey(Encoding.UTF8.GetBytes(secret));
            var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);

            var claims = new[]
            {
                new Claim(ClaimTypes.GivenName, user.UserName),
                new Claim(ClaimTypes.Role, "Admin")
            };

            //(strona ktora odbiera validacje, nasz front wysyla zapytanie, mozemy wogle nie podawać, kiedy token wygasa- mozemy nie podawac, uzyskujemy credentiale)
            var token = new JwtSecurityToken(serverPath, issuer, claims, expirationDate, SigningCredentials: credentials);

            //sprawdzamy czy w naglowku jest nasz token
            return(new JwtSecurityTokenHandler().WriteToken(token));
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            int[] notas = { 100, 50, 20, 10, 5, 2, 1 };
            System.Console.WriteLine("Digite o valor do saque: ");
            int saque = int.Parse(Console.ReadLine());

            int qtNotas = 0;

            for (int i = 0; i < notas.Length; i++)
            {
                qtNotas = saque / notas[i];
                saque   = saque % notas[i];
                if (qtNotas != 0)
                {
                    System.Console.WriteLine($"Você recebeu {qtNotas} notas de {notas[i]}");
                }
            }

            DataTime data = DataTime.Parse(Console.ReadLine());
        }
Esempio n. 9
0
        public void Recv(Queue queue)
        {
            IPAddress  ipaddr     = IPAddress.Any;
            Socket     server     = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint iPEndPoint = new IPEndPoint(ipaddr, port);

            server.Bind(iPEndPoint);
            server.Listen(10);
            //while (true)
            //{
            Socket s = server.Accept();

            //Task task = new Task(() =>
            //{
            //    Socket sc = s;
            while (true)
            {
                byte[] recvmsg = new byte[1024];
                Console.WriteLine("in recv func");
                try
                {
                    s.Receive(recvmsg);
                    string data = Encoding.UTF8.GetString(recvmsg);
                    Console.WriteLine(data);
                    queue.Enqueue(data);
                    //执行委托通知UI该绘制了
                    //CanvasUI();
                    func();
                    WriteLog.WriteL(DataTime.GetTime() + data);
                    s.Send(Encoding.UTF8.GetBytes("ok"));
                }catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    break;
                }
            }

            //});
            //task.Start();
            //}
        }
Esempio n. 10
0
    public string Idade()
    {
        DataTime dataAtual = DataTime.Now;

        return($"idade: {dataAtual.Year - nascimento.Year}");
    }
Esempio n. 11
0
 public TimeInterval(DataTime start,DateTime end)
 {
      if(start.Kind!=end.Time)
         throw new ArgumentException("Incompatible DataTimes");
 }
Esempio n. 12
0
 public TimeInterval(DataTime start,TimeSpan duration)
 {
 }
Esempio n. 13
0
 public string Idade () {
   DataTime dataAtual = DataTime.Now;
   get { return $"idade: { dataAtual.Year - nascimento.Year } }";
 }
Esempio n. 14
0
        public void InsertN1DataV3(string city, string routeName)
        {
            try
            {
                //橘9路線資料
                RestClient    client   = new RestClient($"http://ptx.transportdata.tw/MOTC/v3/Bus/EstimatedTimeOfArrival/City/{city}/{routeName}?&$format=JSON");
                IRestResponse response = GetResponse(client);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var APIResult = JsonConvert.DeserializeObject <BusN1DataV3>(response.Content);
                    if (APIResult != null)
                    {
                        string   RouteUID, RouteID, RouteName, SubRouteUID, SubRouteID, SubRouteName, DestinationStopID, DestinationStopName, StopUID, StopID, StopName, PlateNumb, ScheduledTime, CurrentStop;
                        int      Direction, EstimateTime, StopStatus, StopCountDown;
                        DateTime DataTime, RecTime, TransTime;
                        bool     IsLastBus;
                        string   CreateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                        string   Result     = string.Empty;
                        foreach (N1DataV3 PTXData in APIResult.N1Datas)
                        {
                            RouteUID            = PTXData.RouteUID;
                            RouteID             = PTXData.RouteID;
                            RouteName           = PTXData.RouteName.Zh_tw;
                            SubRouteUID         = PTXData.SubRouteUID;
                            SubRouteID          = PTXData.SubRouteID;
                            SubRouteName        = PTXData.SubRouteName.Zh_tw;
                            Direction           = PTXData.Direction;
                            DestinationStopID   = PTXData.DestinationStopID;
                            DestinationStopName = PTXData.DestinationStopName.Zh_tw;
                            StopUID             = PTXData.StopUID;
                            StopID        = PTXData.StopID;
                            StopName      = PTXData.StopName.Zh_tw;
                            PlateNumb     = PTXData.PlateNumb;
                            EstimateTime  = PTXData.EstimateTime;
                            ScheduledTime = PTXData.ScheduledTime;
                            IsLastBus     = PTXData.IsLastBus;
                            CurrentStop   = PTXData.CurrentStop;
                            StopStatus    = PTXData.StopStatus;
                            StopCountDown = PTXData.StopCountDown;
                            DataTime      = PTXData.DataTime;
                            RecTime       = PTXData.RecTime;
                            TransTime     = PTXData.TransTime;

                            Result = Result +

                                     "INSERT INTO N1DataV3(RouteUID,  RouteID,  RouteName, SubRouteUID, SubRouteID, SubRouteName,  Direction,  DestinationStopID,  DestinationStopName,  StopUID,  StopID,  StopName,  PlateNumb, EstimateTime, ScheduledTime, IsLastBus,  CurrentStop,  StopStatus, StopCountDown,  DataTime,  RecTime,  TransTime)" +
                                     "VALUES(" +
                                     " '" + RouteUID + "' " +
                                     ",'" + RouteID + "' " +
                                     ",'" + RouteName + "' " +
                                     ",'" + SubRouteUID + "' " +
                                     ",'" + SubRouteID + "' " +
                                     ",'" + SubRouteName + "' " +
                                     ",'" + Direction + "' " +
                                     ",'" + DestinationStopID + "' " +
                                     ",'" + DestinationStopName + "' " +
                                     ",'" + StopUID + "' " +
                                     ",'" + StopID + "' " +
                                     ",'" + StopName + "' " +
                                     ",'" + PlateNumb + "' " +
                                     ",'" + EstimateTime + "' " +
                                     ",'" + ScheduledTime + "' " +
                                     ",'" + IsLastBus + "' " +
                                     ",'" + CurrentStop + "' " +
                                     ",'" + StopStatus + "' " +
                                     ",'" + StopCountDown + "' " +
                                     ",'" + DataTime.ToString("yyyy/MM/dd HH:mm:ss") + "' " +
                                     ",'" + RecTime.ToString("yyyy/MM/dd HH:mm:ss") + "' " +
                                     ",'" + TransTime.ToString("yyyy/MM/dd HH:mm:ss") + "' " +
                                     ") ;";
                        }
                        //寫入資料
                        if (Result != "")
                        {
                            SqlConnection connnew = new SqlConnection(strconnection);

                            try
                            {
                                connnew.Open();
                                SqlCommand cmmdnew = new SqlCommand(Result, connnew);
                                cmmdnew.ExecuteNonQuery();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("N1DataV3 error ");
                                Console.WriteLine(ex.Message);
                            }
                            finally
                            {
                                connnew.Close();
                            }
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1.Message);
            }
        }
 public static int AddHours(DataTime source, int hours)
 {
     // don't need any implementation
     throw new Exception();
 }
Esempio n. 16
0
        private void LoadData(String Filename)
        {
            String CurLine;                                         // 存讀取器抓到的字串
            int    Section = 0;                                     // 設定變數存狀態,預設為0

            String[] Piecewise;                                     // 存字串陣列

            StreamReader TaskCSV = new StreamReader(Filename);      // 用資料流讀取器抓資料

            //-------讀檔,要做檢查跳出的判斷式-------//
            while ((CurLine = TaskCSV.ReadLine()) != null)
            {
                int fileEnd = 0;
                if (CurLine.ToUpper().Contains("DATA_TIME"))        // 先將字串矩陣轉大寫,在檢查裡面是否包含特定字串
                //if (CurLine.ToUpper().Contains("NUM1"))        // 先將字串矩陣轉大寫,在檢查裡面是否包含特定字串
                {
                    Section = 1;                                    // Section = 1,這行要跳過
                }
                else if (CurLine.ToUpper().Contains("0"))
                {
                    Section = 2;                                   // Section = 2,數值資料的部分
                }

                switch (Section)
                {
                case 1:
                    Piecewise    = CurLine.Trim().Split(',');
                    ItemsNumbers = Piecewise.Length;
                    break;

                case 2:
                    Piecewise = CurLine.Trim().Split(',');
                    //------判斷是否讀到空字串了------------//
                    if (Piecewise[0] == "" || Piecewise[0] == string.Empty || Piecewise[0] == null)
                    {
                        fileEnd = 1;
                        break;
                    }
                    else     //解析字串內容並存進矩陣
                    {
                        for (int j = 0; j < ItemsNumbers; j++)
                        {
                            //------把各項數值放進對應的List裡------//
                            if (j == 0)
                            {
                                Index.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 1)
                            {
                                DataTime.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 5)
                            {
                                Gap.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 6)
                            {
                                Feed.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 7)
                            {
                                Hipwr.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 8)
                            {
                                WaterR.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            //else if (j == 9) Label3.Add(Convert.ToDouble(Piecewise[j]));
                            else if (j == 10)
                            {
                                Label4.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 11)
                            {
                                Label5.Add(Convert.ToDouble(Piecewise[j]));
                            }

                            /*
                             * if (j == 0) Gap.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 1) Feed.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 2) Hipwr.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 3) WaterR.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 4) Label5.Add(Convert.ToDouble(Piecewise[j]));
                             */
                        }
                    }
                    break;
                }
                if (fileEnd == 1)
                {
                    break;
                }
            }
        }