Ejemplo n.º 1
0
		/// <summary>
		/// Builds a FILETIME structure using a DateTime value.
		/// </summary>
		/// <param name="dt">DateTime value used to initialize the FILETIME structure.</param>
		public  FILETIME  ( DateTime  dt )
		   {
			ulong		value	=  ( ulong )  dt. ToFileTime ( ) ;

			__dwHighDateTime	=  ( uint ) ( ( value  >>  32 )  &  0xFFFFFFFF ) ;
			__dwLowDateTime		=  ( uint ) ( value  &  0xFFFFFFFF ) ;
			Value	=  ( ulong ) dt. ToFileTime ( ) ;
		    }
Ejemplo n.º 2
0
        public static void SetSeedFromSystemTime()
        {
            System.DateTime dt = System.DateTime.Now;
            long            x  = dt.ToFileTime();

            SetSeed((uint)(x >> 16), (uint)(x % 4294967296));
        }
Ejemplo n.º 3
0
		public ZipFileInfo (DateTime fileTime)
		{
			date = new ZipTime (fileTime);
			dosDate = new IntPtr ((int)fileTime.ToFileTime ());
			internalFileAttributes = IntPtr.Zero;
			externalFileAttributes = IntPtr.Zero;
		}
Ejemplo n.º 4
0
        public static SimpleRNG FromSystemTime()
        {
            System.DateTime dt = System.DateTime.Now;
            long            x  = dt.ToFileTime();

            return(new SimpleRNG((uint)(x >> 16), (uint)(x % 4294967296)));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns an equivalent <see cref="System.Runtime.InteropServices.ComTypes.FILETIME"/> of the <see cref="System.DateTime"/> object.
 /// </summary>
 /// <param name="dateTime">The date time.</param>
 /// <returns></returns>
 public static FILETIME DateTimeToFiletime( DateTime dateTime )
 {
     FILETIME ft;
     long hFT1 = dateTime.ToFileTime();
     ft.dwLowDateTime = (int) ( ( hFT1 << 32 ) >> 32 );
     ft.dwHighDateTime = (int) ( hFT1 >> 32 );
     return ft;
 }
Ejemplo n.º 6
0
        public timeval(System.DateTime when)
        {
            long ticks = when.ToFileTime() - UNIXEpoch;

            ticks /= 10000000;

            seconds = (uint)ticks;
        }
Ejemplo n.º 7
0
 public WakeupTimer(DateTime time, Action runAction)
 {
     _runAction = runAction;
     var worker = new BackgroundWorker();
     worker.DoWork += DoWork;
     worker.RunWorkerCompleted += RunWorkerCompleted;
     worker.RunWorkerAsync(time.ToFileTime());
 }
Ejemplo n.º 8
0
 private Win32Native.SystemTime ToSystemTime(DateTime dateTime)
 {
     long fileTime = dateTime.ToFileTime();
     var systemTime = new Win32Native.SystemTime();
     if (!Win32Native.FileTimeToSystemTime(ref fileTime, systemTime))
         Win32ErrorHelper.ThrowExceptionIfGetLastErrorIsNotZero();
     return systemTime;
 }
        }//getFiles

        /// <summary>
        /// SortFilesByTime
        /// AnalyseAllFileName in filelist, and add in map
        /// eg. 11	"c://HistoryMarketData//20131220.csv"
        /// </summary>
        /// <param name="filelist"></param>
        /// <param name="logIndexFileMap"></param>
        /// <returns></returns>
        private int SortFilesByTime(FileInfo[] filelist, IDictionary <long, string> mapTimeAndFileName)
        {
            int nFunRes = 0;

            System.String strFileFullPath     = ""; //"c://HistoryMarketData//20131220.csv"
            System.String strFileName         = ""; //20131220.csv
            System.String strFileNameTime     = ""; //20131220
            long          nFileNameTimeToLong = -1; //2
            int           nfindSunStr         = -1;


            try
            {
                foreach (FileInfo item in filelist)
                {
                    nfindSunStr     = -1;
                    strFileFullPath = item.FullName;
                    strFileName     = item.Name;

                    //get time
                    //20131220.csv
                    if (strFileName.Length > 0)
                    {
                        nfindSunStr = -1;
                        nfindSunStr = strFileName.IndexOf(".");
                    }
                    if (nfindSunStr > 0)
                    {
                        //20131220
                        strFileNameTime = strFileName.Substring(0, nfindSunStr);//get index
                        nfindSunStr     = -1;
                    }

                    //add to map
                    if (strFileNameTime.Length > 0)
                    {
                        //20131220
                        //"c://HistoryMarketData//20131220.csv"
                        nfindSunStr = -1;
                        System.DateTime nFileTime = System.DateTime.ParseExact(strFileNameTime, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                        nFileNameTimeToLong = nFileTime.ToFileTime();//January 1, 1601 C.E. UTC
                        mapTimeAndFileName.Add(nFileNameTimeToLong, strFileFullPath);
                    }
                }//foreach
            }
            catch
            {
                Console.WriteLine("SortFilesByTime error!");
                nFunRes = -1;
            }
            finally
            {
                //
                //Console.WriteLine("finally");
            }

            return(nFunRes);
        }//getLogIndexFileMap
Ejemplo n.º 10
0
 private static string GenerateETag(DateTime lastModified, DateTime now) {
     long num = lastModified.ToFileTime();
     long num2 = now.ToFileTime();
     string str = num.ToString("X8", CultureInfo.InvariantCulture);
     if ((num2 - num) <= 0x1c9c380L) {
         return ("W/\"" + str + "\"");
     }
     return ("\"" + str + "\"");
 }
Ejemplo n.º 11
0
 public static string GenerateETag(DateTime lastModified, DateTime now)
 {
     long lastModifiledFileTime = lastModified.ToFileTime();
     long dateNow = now.ToFileTime();
     string str = lastModifiledFileTime.ToString("X8", CultureInfo.InvariantCulture);
     if ((dateNow - lastModifiledFileTime) <= TimeSpan.TicksPerSecond) // There are 10 million ticks in one second.
     {
         return ("W/\"" + str + "\"");
     }
     return ("\"" + str + "\"");
 }
Ejemplo n.º 12
0
 public void SetWakeUpTime(DateTime time)
 {
     try
     {
         bgWorker.RunWorkerAsync(time.ToFileTime());
     }
     catch (Exception)
     {
         Log.AppLog.WriteEntry(this, Localise.GetPhrase("Background timer already running, cannot start another event"), Log.LogEntryType.Warning, true);
     }
 }
Ejemplo n.º 13
0
        private static string GenerateETag(HttpContext context, DateTime lastModified, DateTime now) {
            // Get 64-bit FILETIME stamp
            long lastModFileTime = lastModified.ToFileTime();
            long nowFileTime = now.ToFileTime();
            string hexFileTime = lastModFileTime.ToString("X8", CultureInfo.InvariantCulture);

            // Do what IIS does to determine if this is a weak ETag.
            // Compare the last modified time to now and if the difference is
            // less than or equal to 3 seconds, then it is weak
            if ((nowFileTime - lastModFileTime) <= 30000000) {
                return "W/\"" + hexFileTime + "\"";
            }
            return  "\"" + hexFileTime + "\"";
        }
 //ExStart:ConvertDateTime
 private static byte[] ConvertDateTime(DateTime t)
 {
     long filetime = t.ToFileTime();
     byte[] d = new byte[8];
     d[0] = (byte)(filetime & 0xFF);
     d[1] = (byte)((filetime & 0xFF00) >> 8);
     d[2] = (byte)((filetime & 0xFF0000) >> 16);
     d[3] = (byte)((filetime & 0xFF000000) >> 24);
     d[4] = (byte)((filetime & 0xFF00000000) >> 32);
     d[5] = (byte)((filetime & 0xFF0000000000) >> 40);
     d[6] = (byte)((filetime & 0xFF000000000000) >> 48);
     d[7] = (byte)(((ulong)filetime & 0xFF00000000000000) >> 56);
     return d;
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Console.WriteLine(Win32ApiHelper.IsSystemResumeAutomatic());

            DateTime lastBootUpTime = new DateTime();
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_OperatingSystem");
            foreach (ManagementObject queryObj in searcher.Get())
            {
                var timeStr = Convert.ToString(queryObj["LastBootUpTime"]);
                Console.WriteLine(timeStr);
                lastBootUpTime = ManagementDateTimeConverter.ToDateTime(timeStr);
                Console.WriteLine(lastBootUpTime);
            }

            IntPtr status = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(long)));
            Win32ApiHelper.CallNtPowerInformation(
              Win32ApiHelper.POWER_INFORMATION_LEVEL.LastSleepTime,
              (IntPtr)null,
              0,
              status,
              (UInt32)Marshal.SizeOf(typeof(long))
              );

            long lastSleepTime = (long) Marshal.PtrToStructure(status, typeof(long));
            Console.WriteLine(DateTime.FromFileTime(lastBootUpTime.ToFileTime() + lastSleepTime));

            Win32ApiHelper.CallNtPowerInformation(
              Win32ApiHelper.POWER_INFORMATION_LEVEL.LastWakeTime,
              (IntPtr)null,
              0,
              status,
              (UInt32)Marshal.SizeOf(typeof(long))
              );

            long lastWakeTime = (long)Marshal.PtrToStructure(status, typeof(long));
            Console.WriteLine(DateTime.FromFileTime(lastBootUpTime.ToFileTime() + lastWakeTime));
        }
        /// <summary>
        /// Construct empty BarData, for this dateTime.
        /// </summary>
        public BarData(DateTime dateTime)
        {
            _dateTime = dateTime.ToFileTime();
            _volume = double.NaN;
            _open = double.NaN;
            _close = double.NaN;
            _high = double.NaN;
            _low = double.NaN;
            isHigherPrev = false;
            //_arrow = 0;
            isCompleted = true;
            //_stopLoss = 0;
            //_gainTip = 0;
            //_stopGain = 0;
            sar = double.NaN;
            cr = double.NaN;
            isReverse = false;
            rsi = double.NaN;

            rsi2 = double.NaN;
            rsi3 = double.NaN;
            rsi4 = double.NaN;
            actPrice = double.NaN;
            stopLossPrice = double.NaN;
            stopGainPrice = double.NaN;
            signalList = new List<CandleSignal>();
            exHigh = _high;
            exLow = _low;
            ar = double.NaN;
            ar2 = double.NaN;
            br = double.NaN;
            cci = double.NaN;
            cci2 = double.NaN;
            cci3 = double.NaN;
            indicators = new Dictionary<string, double>();
            lwr = new Dictionary<string, double>();
            wr = double.NaN;
            wr2 = double.NaN;
            lwr.Add(LWR.LWR1, 0);
            lwr.Add(LWR.LWR2, 0);
            boll = new Dictionary<string, double>();
            boll.Add(BOLL.UPPER, 0);
            boll.Add(BOLL.MID, 0);
            boll.Add(BOLL.LOWER, 0);
        }
        public void Add(HttpContent content, string name, string fileName, FileAttributes attributes, DateTime lastWriteTimeUtc)
        {
            if (content.Headers.ContentDisposition == null)
            {
                content.Headers.ContentDisposition = new ContentDispositionHeaderValue("dir-sync-data")
                                                         {
                                                             Name = name,
                                                             FileName = fileName,
                                                             FileNameStar = fileName,
                                                         };
                var parameters = content.Headers.ContentDisposition.Parameters;

                parameters.Add(new NameValueHeaderValue("fileAttributes", HttpUtility.UrlEncode(attributes.ToString())));
                parameters.Add(new NameValueHeaderValue("lastWriteTimeUtc", lastWriteTimeUtc.ToFileTime().ToString(CultureInfo.InvariantCulture)));
            }

            base.Add(content);
        }
Ejemplo n.º 18
0
 public static long DateTimeToLong(DateTime dt)
 {
     if (dt==DateTime.MinValue)
     {
         return 0;
     }
     else
     {
         try
         {
             return dt.ToFileTime();
         }
         catch
         {
             return 0;
         }
     }
 }
Ejemplo n.º 19
0
        //<Snippet1>
        static void Main(string[] args)
        {
            System.Console.WriteLine("Enter the file path:");
            string filePath = System.Console.ReadLine();

            if (System.IO.File.Exists(filePath))
            {
                System.DateTime fileCreationDateTime =
                    System.IO.File.GetCreationTime(filePath);

                long fileCreationFileTime = fileCreationDateTime.ToFileTime();

                System.Console.WriteLine("{0} in file time is {1}.",
                                         fileCreationDateTime,
                                         fileCreationFileTime);
            }
            else
            {
                System.Console.WriteLine("{0} is an invalid file", filePath);
            }
        }
Ejemplo n.º 20
0
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1: The current dateTime equals 1601/1/1");
     try
     {
         DateTime date1 = new DateTime(1601, 1, 1).ToLocalTime().ToUniversalTime();
         long result = date1.ToFileTime();
         if (result != 0)
         {
             TestLibrary.TestFramework.LogError("001", "The ActualResult is not the ExpectResult");
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Ejemplo n.º 21
0
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2: The current dateTime lager 1601/1/1");
     try
     {
         DateTime date1 = new DateTime(1999, 1, 1).ToLocalTime().ToUniversalTime();
         DateTime date2 = new DateTime(1601, 1, 1).ToLocalTime().ToUniversalTime();
         TimeSpan timeSpan = date1.Subtract(date2);
         long result = date1.ToFileTime();
         long expect = timeSpan.Days * 864000000000; //8640000000 = 24*3600*1000*1000*1000/100
         if (result != expect)
         {
             TestLibrary.TestFramework.LogError("003", "The ActualResult is not the ExpectResult");
             retVal = false;
         }                      
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Ejemplo n.º 22
0
Archivo: Util.cs Proyecto: 89sos98/npoi
 /// <summary>
 /// Converts a {@link DateTime} into a filetime.
 /// </summary>
 /// <param name="dateTime">The DateTime To be Converted</param>
 /// <returns>The filetime</returns>
 public static long DateToFileTime(DateTime dateTime)
 {
     //long ms_since_19700101 = DateTime.Ticks;
     //long ms_since_16010101 = ms_since_19700101 + EPOCH_DIFF;
     //return ms_since_16010101 * (1000 * 10);
     return dateTime.ToFileTime();
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Sets the time at which the file or directory was last written to (UTC)
 /// </summary>
 /// <param name="pathInfo">Affected file or directory</param>     
 /// <param name="utcTime">The time that is to be used (UTC)</param>
 public static void SetLastWriteTimeUtc( QuickIOPathInfo pathInfo, DateTime utcTime )
 {
     var longTime = utcTime.ToFileTime( );
     using ( var fileHandle = OpenReadWriteFileSystemEntryHandle( pathInfo.FullNameUnc ) )
     {
         if ( !Win32SafeNativeMethods.SetLastWriteFileTime( fileHandle, IntPtr.Zero, IntPtr.Zero, ref longTime ) )
         {
             var win32Error = Marshal.GetLastWin32Error( );
             InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
         }
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Sets the dates and times of given directory or file.
        /// </summary>
        /// <param name="pathInfo">Affected file or directory</param>     
        /// <param name="creationTimeUtc">The time that is to be used (UTC)</param>
        /// <param name="lastAccessTimeUtc">The time that is to be used (UTC)</param>
        /// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param>
        public static void SetAllFileTimes( QuickIOPathInfo pathInfo, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc )
        {
            var longCreateTime = creationTimeUtc.ToFileTime( );
            var longAccessTime = lastAccessTimeUtc.ToFileTime( );
            var longWriteTime = lastWriteTimeUtc.ToFileTime( );

            using ( var fileHandle = OpenReadWriteFileSystemEntryHandle( pathInfo.FullNameUnc ) )
            {
                if ( Win32SafeNativeMethods.SetAllFileTimes( fileHandle, ref longCreateTime, ref longAccessTime, ref longWriteTime ) == 0 )
                {
                    var win32Error = Marshal.GetLastWin32Error( );
                    InternalQuickIOCommon.NativeExceptionMapping( pathInfo.FullName, win32Error );
                }
            }
        }
Ejemplo n.º 25
0
		public void ToFileTimeUtc ()
		{
			// Randomly generated time outside DST.
			var utc = new DateTime (1993, 01, 28, 08, 49, 48, DateTimeKind.Utc);
			var local = utc.ToLocalTime ();
			var unspecified = new DateTime (1993, 01, 28, 08, 49, 48);

			Assert.AreEqual (DateTimeKind.Utc, utc.Kind);
			Assert.AreEqual (DateTimeKind.Local, local.Kind);
			Assert.AreEqual (DateTimeKind.Unspecified, unspecified.Kind);

			Assert.AreEqual (628638077880000000, utc.Ticks);
			Console.WriteLine (local.Ticks - utc.Ticks);

			var offset = TimeZone.CurrentTimeZone.GetUtcOffset (local);

			var utcFt = utc.ToFileTime ();
			var localFt = local.ToFileTime ();
			var unspecifiedFt = unspecified.ToFileTime ();

			var utcUft = utc.ToFileTimeUtc ();
			var localUft = local.ToFileTimeUtc ();
			var unspecifiedUft = unspecified.ToFileTimeUtc ();

			Assert.AreEqual (123726845880000000, utcFt);
			Assert.AreEqual (utcFt, localFt);

			Assert.AreEqual (offset.Ticks, utcFt - unspecifiedFt);

			Assert.AreEqual (utcFt, utcUft);
			Assert.AreEqual (utcFt, localUft);
			Assert.AreEqual (utcFt, unspecifiedUft);
		}
Ejemplo n.º 26
0
 public static void AddDateTime(Dictionary <string, object> outDict, string key, System.DateTime value)
 {
     outDict.Add(key, (System.Int64)value.ToFileTime());
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Converts a DateTime to an Int64 FileTime
 /// </summary>
 /// <param name="xInput"></param>
 /// <returns></returns>
 public static long DateTimeToLong(DateTime xInput)
 {
     try { return xInput.ToFileTime(); }
     catch { return DateTime.Now.ToFileTime(); }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Get list of records bounded by specified start message timestamp and message count
        /// </summary>
        /// <param name="StartTimestamp">Starting message timestamp</param>
        /// <param name="MessageCount"></param>
        /// <returns>List of Log Records</returns>
        public List<LogRecord> GetRecordsByStartTimestampAndCount(DateTime StartTimestamp, int MessageCount = 1000)
        {
            log.DebugFormat("StartTimestamp - {0}", StartTimestamp);
            log.DebugFormat("MaximumMessageCount - {0}", MessageCount);

            return this.GetRecordsByStartFileTimeAndCount((ulong)StartTimestamp.ToFileTime(), MessageCount);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Get list of records bounded by the start and end timestamp
        /// </summary>
        /// <param name="StartTimeStamp">Starting timestamp for search</param>
        /// <param name="EndTimeStamp">Ending timestamp for search</param>
        /// <returns>List of Log Records</returns>
        public List<LogRecord> GetRecordsByStartAndEndTimeStamp(DateTime StartTimeStamp, DateTime EndTimeStamp)
        {
            log.DebugFormat("StartTimeStamp - {0}", StartTimeStamp);
            log.DebugFormat("EndTimeStamp - {0}", EndTimeStamp);

            return this.GetRecordsByStartAndEndFileTime((ulong)StartTimeStamp.ToFileTime(), (ulong)EndTimeStamp.ToFileTime());
        }
Ejemplo n.º 30
0
 /// <summary>
 ///  Return a single log record identified by the specific message timestamp.  If no record is found a blank log record is returned.
 /// </summary>
 /// <param name="MessageTimestamp">Message timestamp to use when searching</param>
 /// <param name="TimestampEarlyOrLate">Earliest = Message immediately before timestamp, Latest = Message immediately after timestamp</param>
 /// <returns>A single log record</returns>
 public LogRecord GetRecordByTimestamp(DateTime MessageTimestamp, EarliestOrLatest TimestampEarlyOrLate = EarliestOrLatest.Earliest)
 {
     log.DebugFormat("MessageTimestamp - {0}", MessageTimestamp);
        return this.GetRecordByFileTime((ulong)MessageTimestamp.ToFileTime(), TimestampEarlyOrLate);
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Get the log file path for a specific message timestamp
 /// </summary>
 /// <param name="MessageTimestamp">Message timestamp to search for</param>
 /// <returns>Complete paths to log files containing specific message timestamp.  Will return "" if no log file found</returns>
 public List<string> GetLogFilePathsForMessageTimestamp(DateTime MessageTimestamp)
 {
     return this.GetLogFilePathsForMessageFileTime((ulong)MessageTimestamp.ToFileTime());
 }
Ejemplo n.º 32
0
 private static SystemTime ToSystemTime(DateTime dateTime)
 {
     long fileTime = dateTime.ToFileTime();
     SystemTime systemTime;
     Check(NativeMethods.FileTimeToSystemTime(ref fileTime, out systemTime));
     return systemTime;
 }
Ejemplo n.º 33
0
            //DateTime ========>  UTC Local time
            public static long DateTime2DbTime(System.DateTime dt)
            {
                long l = dt.ToFileTime();

                return((long)((l - 116444736000000000) / 10000000));
            }
Ejemplo n.º 34
0
        internal static unsafe int BuildChain (IntPtr hChainEngine,
                                               SafeCertContextHandle pCertContext,
                                               X509Certificate2Collection extraStore,
                                               OidCollection applicationPolicy,
                                               OidCollection certificatePolicy,
                                               X509RevocationMode revocationMode,
                                               X509RevocationFlag revocationFlag,
                                               DateTime verificationTime,
                                               TimeSpan timeout,
                                               ref SafeCertChainHandle ppChainContext) {
            if (pCertContext == null || pCertContext.IsInvalid)
                throw new ArgumentException(SecurityResources.GetResourceString("Cryptography_InvalidContextHandle"), "pCertContext");

            SafeCertStoreHandle hCertStore = SafeCertStoreHandle.InvalidHandle;
            if (extraStore != null && extraStore.Count > 0)
                hCertStore = X509Utils.ExportToMemoryStore(extraStore);

            CAPI.CERT_CHAIN_PARA ChainPara = new CAPI.CERT_CHAIN_PARA();

            // Initialize the structure size.
            ChainPara.cbSize = (uint) Marshal.SizeOf(ChainPara);

            // Application policy
            SafeLocalAllocHandle applicationPolicyHandle = SafeLocalAllocHandle.InvalidHandle;
            if (applicationPolicy != null && applicationPolicy.Count > 0) {
                ChainPara.RequestedUsage.dwType = CAPI.USAGE_MATCH_TYPE_AND;
                ChainPara.RequestedUsage.Usage.cUsageIdentifier = (uint) applicationPolicy.Count;
                applicationPolicyHandle = X509Utils.CopyOidsToUnmanagedMemory(applicationPolicy);
                ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = applicationPolicyHandle.DangerousGetHandle();
            }

            // Certificate policy
            SafeLocalAllocHandle certificatePolicyHandle = SafeLocalAllocHandle.InvalidHandle;
            if (certificatePolicy != null && certificatePolicy.Count > 0) {
                ChainPara.RequestedIssuancePolicy.dwType = CAPI.USAGE_MATCH_TYPE_AND;
                ChainPara.RequestedIssuancePolicy.Usage.cUsageIdentifier = (uint) certificatePolicy.Count;
                certificatePolicyHandle = X509Utils.CopyOidsToUnmanagedMemory(certificatePolicy);
                ChainPara.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = certificatePolicyHandle.DangerousGetHandle();
            }

            ChainPara.dwUrlRetrievalTimeout = (uint) timeout.Milliseconds;

            _FILETIME ft = new _FILETIME();
            *((long*) &ft) = verificationTime.ToFileTime();

            uint flags = X509Utils.MapRevocationFlags(revocationMode, revocationFlag);

            // Build the chain.
            if (!CAPI.CAPISafe.CertGetCertificateChain(hChainEngine,
                                                       pCertContext,
                                                       ref ft,
                                                       hCertStore,
                                                       ref ChainPara,
                                                       flags,
                                                       IntPtr.Zero,
                                                       ref ppChainContext))
                return Marshal.GetHRForLastWin32Error();

            applicationPolicyHandle.Dispose();
            certificatePolicyHandle.Dispose();

            return CAPI.S_OK;
        }
        public static int SetLastWriteTime(string filename, DateTime mtime)
        {
            IntPtr hFile  = (IntPtr) CreateFileCE(filename,
                                                  (uint)0x40000000L, // (uint)FileAccess.Write,
                                                  (uint)0x00000002L, // (uint)FileShare.Write,
                                                  0,
                                                  (uint) 3,  // == open existing
                                                  (uint)0, // flagsAndAttributes
                                                  0);

            if((int)hFile == -1)
            {
                // workitem 7944: don't throw on failure to set file time
                // throw new ZipException(String.Format("CreateFileCE Failed ({0})",
                //                                      Interop.Marshal.GetLastWin32Error()));
                return Interop.Marshal.GetLastWin32Error();
            }

            SetFileTime(hFile, null, null,
                        BitConverter.GetBytes(mtime.ToFileTime()));

            CloseHandle(hFile);
            return 0;
        }
Ejemplo n.º 36
0
 public static long ToUnixTime(DateTime dt)
 {
     return (dt.ToFileTime() - EpochFileTime) / 10000000;
 }
Ejemplo n.º 37
0
 public static long ConvertDateTimeToJavaMillisecond(DateTime dateTime)
 {
     return dateTime.ToFileTime(); // (dateTime.Ticks - 621355968000000000L) / 10000;
 }
Ejemplo n.º 38
0
 public static DateTime timestamp2DateTime(Int64 timestamp)
 {
     return(DateTime.FromFileTime((timestamp * 10000000 + UnixEpoch.ToFileTime())));
 }