コード例 #1
0
 private static void TimerThread()
 {
     while (true)
     {
         TimeStamp = WocketsTimer.GetUnixTime();
         Thread.Sleep(20);
     }
 }
コード例 #2
0
        private static DayFolderNode[] GetDayFolderInformation(FileSystemInfo[] fia)
        {
            if (fia == null || fia.Length < 1)
            {
                return(null);
            }

            System.Collections.ArrayList ret = new System.Collections.ArrayList();

            DayFolderNode dfn;

            HourFolderNode[] hours = null;

            DateTime dt;

            foreach (FileSystemInfo fsi in fia)
            {
                //fill the info
                dfn = new DayFolderNode();

                dfn.folderName  = fsi.FullName;
                dfn.dayAsString = fsi.Name;


                if (!DirectoryStructure.TimeFromDayFolderName(fsi.Name, out dt))
                {
                    return(null);
                }

                dfn.startUnixTime = WocketsTimer.GetUnixTime(dt);
                dfn.endUnixTime   = dfn.startUnixTime + WocketsTimer.MilliInDay - 1;

                //Get the hour information
                hours = DirectoryStructure.GetHourFolderInformation(fsi.FullName, dfn.startUnixTime);
                if (hours == null || hours.Length < 1)
                {
                    continue;
                }

                dfn.hours = hours;

                //add to the list
                ret.Add(dfn);

                hours = null;
                dfn   = null;
            }

            if (ret.Count > 0)
            {
                //Create the array to return
                return((DayFolderNode[])ret.ToArray(typeof(DayFolderNode)));
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: Logger.cs プロジェクト: katadam/wockets
 public static void Log(String msg)
 {
     try
     {
         DateTime now        = DateTime.Now;
         string   hourlyPath = now.ToString("yyyy-MM-dd") + "\\" + now.Hour;
         if (!Directory.Exists(_FilePath + "\\" + hourlyPath))
         {
             Directory.CreateDirectory(_FilePath + "\\" + hourlyPath);
         }
         TextWriter tw = new StreamWriter(_FilePath + "\\" + hourlyPath + "\\log.csv", true);
         tw.WriteLine(WocketsTimer.GetUnixTime() + "," + DateTime.Now + "," + msg);
         tw.Flush();
         tw.Close();
     }
     catch
     {
     }
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="unixTime"></param>
        /// <param name="retBytes"></param>
        public static void GetUnixTimeBytes(double unixTime, byte[] retBytes)
        {
            if (BitConverter.IsLittleEndian == false)
            {
                Console.WriteLine("ERROR: assumes littleendian!");
            }

            short ms  = WocketsTimer.GetUnixTimeMSecond(unixTime);
            int   sec = WocketsTimer.GetUnixTimeSecond(unixTime);

            byte[] temp;
            temp = System.BitConverter.GetBytes(sec);

            retBytes[0] = temp[0];
            retBytes[1] = temp[1];
            retBytes[2] = temp[2];
            retBytes[3] = temp[3];

            temp = System.BitConverter.GetBytes(ms);

            retBytes[4] = temp[0];
            retBytes[5] = temp[1];
        }