예제 #1
0
 private PSSenderInfo(SerializationInfo info, StreamingContext context)
 {
     if (info != null)
     {
         string source = null;
         try
         {
             source = info.GetValue("CliXml", typeof(string)) as string;
         }
         catch (Exception)
         {
             return;
         }
         if (source != null)
         {
             try
             {
                 PSSenderInfo info2 = DeserializingTypeConverter.RehydratePSSenderInfo(PSObject.AsPSObject(PSSerializer.Deserialize(source)));
                 this.userPrinicpal = info2.userPrinicpal;
                 this.clientTimeZone = info2.ClientTimeZone;
                 this.connectionString = info2.connectionString;
                 this.applicationArguments = info2.applicationArguments;
             }
             catch (Exception)
             {
                 return;
             }
         }
     }
 }
예제 #2
0
        public AConnectorBase()
        {
            this.hubSpotAPIKey = UConfig.getAppConfigValue("HubSpotAPIKey", bool.Parse(UConfig.getAppConfigValue("EncryptedCredentials", false)));
            this.connectionString = UConfig.getAppConfigValue("SQLConnectionString", bool.Parse(UConfig.getAppConfigValue("EncryptedCredentials", false)));
            //***** MHM Contacts – Replaced *****//
            //this.hubSpotAPIUrl = UConfig.getAppConfigValue("HubSpotURL", false) + hubSpotAPIKey;
            if (UConfig.getAppConfigValue("HubSpotContact", false) == "true")
                this.hubSpotAPIUrl = UConfig.getAppConfigValue("HubSpotContactURL", false) + hubSpotAPIKey;
            else
                this.hubSpotAPIUrl = UConfig.getAppConfigValue("HubSpotURL", false) + hubSpotAPIKey;
            //***** MHM Contacts ****************//

            this.hubSpotAPIVersion = UConfig.getAppConfigValue("HubSpotAPIVersion", false).ToLower();
            this.databaseVersion = AppGlobal.getDatabaseVersion(UConfig.getAppConfigValue("DatabaseVersion", false));
            this.sqlConnection = new SqlConnection(connectionString);
            this.debugLogPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\OLD_Log.txt";
            this.dataMaps = new Hashtable();
            this.pushPullDateTimeFormat = AppGlobal.getPushPullDateTimeFormat();
            this.timeZone = AppGlobal.getCurrentTimeZone();
            this.hubSpotMaps = new Hashtable();
            this.endpoint = new HubSpotEndpoint(hubSpotAPIVersion, hubSpotAPIKey);
            this.hubSpotTimePivot = UConfig.getAppConfigValue("HubSpotTimePivot", false);
            this.sqlBatchSize = UConfig.getAppConfigValue("SQLBatchSize", false);

            int batchSize; // need to make sure that sqlBatchSize is a valid integer
            if (Int32.TryParse(sqlBatchSize, out batchSize) == false)
            {
                sqlBatchSize = "0";
            }

            loadDataMaps();
        }
예제 #3
0
	private void CET (TimeZone t1) 
	{
		AssertEquals("A01", "CET", t1.StandardName);
		AssertEquals("A02", "CEST", t1.DaylightName);
	
		DaylightTime d1 = t1.GetDaylightChanges (2002);
		AssertEquals("A03", "03/31/2002 01:00:00", d1.Start.ToString ("G"));
		AssertEquals("A04", "10/27/2002 01:00:00", d1.End.ToString ("G"));
		AssertEquals("A05", 36000000000L, d1.Delta.Ticks);
	
		DaylightTime d2 = t1.GetDaylightChanges (1996);
		AssertEquals("A06", "03/31/1996 01:00:00", d2.Start.ToString ("G"));
		AssertEquals("A07", "10/27/1996 01:00:00", d2.End.ToString ("G"));
		AssertEquals("A08", 36000000000L, d2.Delta.Ticks);
	
		DateTime d3 = new DateTime (2002,2,25);
		AssertEquals("A09", false, t1.IsDaylightSavingTime (d3));
		DateTime d4 = new DateTime (2002,4,2);
		AssertEquals("A10", true, t1.IsDaylightSavingTime (d4));
		DateTime d5 = new DateTime (2002,11,4);
		AssertEquals("A11", false, t1.IsDaylightSavingTime (d5));
	
		AssertEquals("A12", 36000000000L, t1.GetUtcOffset (d3).Ticks);
		AssertEquals("A13", 72000000000L, t1.GetUtcOffset (d4).Ticks);
		AssertEquals("A14", 36000000000L, t1.GetUtcOffset (d5).Ticks);
	}
예제 #4
0
파일: timezone.cs 프로젝트: ArildF/masters
 //This method is called by CultureInfo.ClearCachedData in response to control panel
 //change events.  It must be synchronized because otherwise there is a race condition 
 //with the CurrentTimeZone property above.
 internal static void ResetTimeZone() {
     if (currentTimeZone!=null) {
         lock(typeof(TimeZone)) {
             currentTimeZone = null;
         }
     }
 }
예제 #5
0
        private void radTimeZone_CheckedChanged(object sender, System.EventArgs e)
        {
            cboTimeZone.Enabled = radSpecified.Checked;

            System.TimeZone current = GetValue();
            SetButtonEnabled(DialogResult.OK, (current != null && !current.Equals(m_original)));
        }
예제 #6
0
 internal Gregorian(Time time, TimeZone timezone)
 {
     this.time = time;
     if (timezone == null)
         timezone = time.Context.Gmt ();
     this.timezone = timezone;
 }
예제 #7
0
 //This method is called by CultureInfo.ClearCachedData in response to control panel
 //change events.  It must be synchronized because otherwise there is a race condition 
 //with the CurrentTimeZone property above.
 internal static void ResetTimeZone() {
     if (currentTimeZone!=null) {
         lock(InternalSyncObject) {
             currentTimeZone = null;
         }
     }
 }
예제 #8
0
파일: TimeZoneTest.cs 프로젝트: caomw/mono
	private void CET (TimeZone t1) 
	{
		Assert.AreEqual("CET", t1.StandardName, "A01");
		Assert.AreEqual("CEST", t1.DaylightName, "A02");
	
		DaylightTime d1 = t1.GetDaylightChanges (2002);
		Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "A03");
		Assert.AreEqual("10/27/2002 03:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "A04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "A05");
	
		DaylightTime d2 = t1.GetDaylightChanges (1996);
		Assert.AreEqual("03/31/1996 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "A06");
		Assert.AreEqual("10/27/1996 03:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "A07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "A08");
	
		DateTime d3 = new DateTime (2002,2,25);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "A09");
		DateTime d4 = new DateTime (2002,4,2);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "A10");
		DateTime d5 = new DateTime (2002,11,4);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "A11");
	
		Assert.AreEqual(36000000000L, t1.GetUtcOffset (d3).Ticks, "A12");
		Assert.AreEqual(72000000000L, t1.GetUtcOffset (d4).Ticks, "A13");
		Assert.AreEqual(36000000000L, t1.GetUtcOffset (d5).Ticks, "A14");

		// Test TimeZone methods with UTC DateTime in DST.
		DateTime d6 = d4.ToUniversalTime ();
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "A15");
		Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "A16");
	}
예제 #9
0
    static int IsDaylightSavingTime(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <System.DateTime, System.Globalization.DaylightTime>(L, 1))
            {
                System.DateTime arg0 = StackTraits <System.DateTime> .To(L, 1);

                System.Globalization.DaylightTime arg1 = (System.Globalization.DaylightTime)ToLua.ToObject(L, 2);
                bool o = System.TimeZone.IsDaylightSavingTime(arg0, arg1);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <System.TimeZone, System.DateTime>(L, 1))
            {
                System.TimeZone obj  = (System.TimeZone)ToLua.ToObject(L, 1);
                System.DateTime arg0 = StackTraits <System.DateTime> .To(L, 2);

                bool o = obj.IsDaylightSavingTime(arg0);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.TimeZone.IsDaylightSavingTime"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #10
0
		static DateTimeConverter()
		{
			LocalZoneInfo = TimeZoneInfo.Local;
			CurrentZone = TimeZone.CurrentTimeZone;
			var offset = LocalZoneInfo.BaseUtcOffset;
			var sbWithout = new StringBuilder();
			if (offset.TotalSeconds >= 0)
				sbWithout.Append('+');
			sbWithout.Append(offset.Hours.ToString("00"));
			sbWithout.Append(':');
			sbWithout.Append(offset.Minutes.ToString("00"));
			//tough luck if you have seconds in timezone offset
			TimeZoneWithoutDaylightSaving = sbWithout.ToString();
			var rules = LocalZoneInfo.GetAdjustmentRules();
			if (rules.Length == 1 && rules[0].DateStart == DateTime.MinValue && rules[0].DateEnd == DateTime.MinValue)
			{
				var sbWith = new StringBuilder();
				var totalOffset = offset.Add(rules[0].DaylightDelta);
				if (totalOffset.TotalSeconds >= 0)
					sbWith.Append('+');
				sbWith.Append(totalOffset.Hours.ToString("00"));
				sbWith.Append(':');
				sbWith.Append(totalOffset.Minutes.ToString("00"));
				TimeZoneWithDaylightSaving = sbWith.ToString();
			}
		}
예제 #11
0
	private void CET (TimeZone t1) 
	{
		Assert.AreEqual("CET", t1.StandardName, "A01");
		Assert.AreEqual("CEST", t1.DaylightName, "A02");
	
		DaylightTime d1 = t1.GetDaylightChanges (2002);
		Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G"), "A03");
		Assert.AreEqual("10/27/2002 03:00:00", d1.End.ToString ("G"), "A04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "A05");
	
		DaylightTime d2 = t1.GetDaylightChanges (1996);
		Assert.AreEqual("03/31/1996 02:00:00", d2.Start.ToString ("G"), "A06");
		Assert.AreEqual("10/27/1996 03:00:00", d2.End.ToString ("G"), "A07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "A08");
	
		DateTime d3 = new DateTime (2002,2,25);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "A09");
		DateTime d4 = new DateTime (2002,4,2);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "A10");
		DateTime d5 = new DateTime (2002,11,4);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "A11");
	
		Assert.AreEqual(36000000000L, t1.GetUtcOffset (d3).Ticks, "A12");
		Assert.AreEqual(72000000000L, t1.GetUtcOffset (d4).Ticks, "A13");
		Assert.AreEqual(36000000000L, t1.GetUtcOffset (d5).Ticks, "A14");
	}
예제 #12
0
	private void EST (TimeZone t1) 
	{
		// It could be EST though...
		//Assert.AreEqual("Eastern Standard Time", t1.StandardName, "B01");
		//Assert.AreEqual("Eastern Daylight Time", t1.DaylightName, "B02");

		DaylightTime d1 = t1.GetDaylightChanges (2002);
		Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G"), "B03");
		Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G"), "B04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05");

		DaylightTime d2 = t1.GetDaylightChanges (1996);
		Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString ("G"), "B06");
		Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G"), "B07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08");

		DateTime d3 = new DateTime (2002,2,25);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "B09");
		DateTime d4 = new DateTime (2002,4,8);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "B10");
		DateTime d5 = new DateTime (2002,11,4);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "B11");

		Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d3).Ticks, "B12");
		Assert.AreEqual(-144000000000L, t1.GetUtcOffset (d4).Ticks, "B13");
		Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d5).Ticks, "B14");
	}
예제 #13
0
        public DateFormat(string format, string newZone)
        {
            if (newZone == null ||
                (newZone != "GMT" &&
                 newZone != "LOCAL"))
            {
                throw new ArgumentException();
            }

            DateFormatPattern = format;
            gmtTimeZone       =
                System.TimeZone.CurrentTimeZone.GetUtcOffset(
                    System.DateTime.Now);               // timezone from GMT

            if (newZone == "LOCAL")
            {
                TimeZone = localTimeZone;
                tz       = System.TimeZone.CurrentTimeZone;
            }
            else
            {
                TimeZone = gmtTimeZone;
                tz       = null;
            }
        }
예제 #14
0
	private void EST (TimeZone t1) 
	{
		Assert.IsTrue("EST" == t1.StandardName || "Eastern Standard Time" == t1.StandardName, "B01");
		Assert.IsTrue("EDT" == t1.DaylightName || "Eastern Daylight Time" == t1.DaylightName, "B02");

		DaylightTime d1 = t1.GetDaylightChanges (2002);
		Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "B03");
		Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "B04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05");

		DaylightTime d2 = t1.GetDaylightChanges (1996);
		Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "B06");
		Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "B07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08");

		DateTime d3 = new DateTime (2002,2,25);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "B09");
		DateTime d4 = new DateTime (2002,4,8);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "B10");
		
		DateTime d5 = new DateTime (2002,11,4);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "B11");

		Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d3).Ticks, "B12");
		Assert.AreEqual(-144000000000L, t1.GetUtcOffset (d4).Ticks, "B13");
		Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d5).Ticks, "B14");

		// Test TimeZone methods with UTC DateTime in DST.
		DateTime d6 = d4.ToUniversalTime ();
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "B15");
		Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "B16");
	}
예제 #15
0
파일: Server.cs 프로젝트: uotools/PlayUO
        int IComparable.CompareTo(object o)
        {
            if (o == null)
            {
                return(1);
            }
            Server server = o as Server;

            if (server == null)
            {
                throw new ArgumentException();
            }
            System.TimeZone currentTimeZone = System.TimeZone.CurrentTimeZone;
            DateTime        now             = DateTime.Now;
            int             hours           = currentTimeZone.GetUtcOffset(now).Hours;
            int             num2            = -this.m_TimeZone;
            int             num3            = -server.m_TimeZone;
            int             num4            = Math.Abs((int)(hours - num2));
            int             num5            = Math.Abs((int)(hours - num3));
            int             num6            = num4.CompareTo(num5);

            if (num6 == 0)
            {
                num6 = server.m_PercentFull.CompareTo(this.m_PercentFull);
                if (num6 == 0)
                {
                    num6 = this.m_Name.CompareTo(server.m_Name);
                    if (num6 == 0)
                    {
                        num6 = this.m_ServerID.CompareTo(server.m_ServerID);
                    }
                }
            }
            return(num6);
        }
예제 #16
0
		private TestDateTimeFactory(DateTime seedTime, double acceleration, TimeSpan increment)
		{
			this.seedTime = seedTime.Add(new TimeSpan(-increment.Ticks)).ToUniversalTime();
			this.ticksLastCall = 0;
			this.acceleration = acceleration;
			this.increment = increment;
			this.currentTimeZone = TimeZone.CurrentTimeZone;
		}
예제 #17
0
 public Gregorian(ITimeContext context, int year, Month month, int day, int hour = 0, int minute = 0, int second = 0, int milliseconds = 0, TimeZone timezone = null)
 {
     if (timezone == null)
         timezone = context.Gmt ();
     this.timezone = timezone;
     //TODO: Validate input
     this.time = new DateTime (year, (int)month, day, hour, minute, second, milliseconds, System.DateTimeKind.Utc).ToTime (context);
 }
        /// <summary>
        /// <para>Converts a given <see cref='System.DateTime'/> object to DMTF format.</para>
        ///
        /// </summary>
        /// <param name='date'>A <see cref='System.DateTime'/> object representing the datetime to be converted to DMTF datetime.</param>
        /// <returns>
        /// <para>A string that represents the DMTF datetime for the given DateTime object.</para>
        /// </returns>
        /// <remarks>
        ///			<para> Date and time in WMI is represented in DMTF datetime format. This format is explained in WMI SDK documentation.
        ///				The DMTF datetime string represented will be with respect to the UTC offset of the
        ///				current timezone. The lowest precision in DMTF is microseconds and
        ///				in <see cref='System.DateTime'/> is Ticks , which is equivalent to 100 of nanoseconds.
        ///				 During conversion these Ticks are converted to microseconds and rounded
        ///				 off to the the nearest microsecond.
        ///			</para>
        /// </remarks>
        /// <example>
        ///    <code lang='C#'>
        ///	// Convert the current time in System.DateTime to DMTF format
        ///	string dmtfDateTime = ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now);
        ///    </code>
        ///    <code lang='VB'>
        ///	' Convert the current time in System.DateTime to DMTF format
        ///	Dim dmtfDateTime as String = ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now)
        ///    </code>
        /// </example>
        public static string ToDmtfDateTime(DateTime date)
        {
            string UtcString = String.Empty;

            // Fill up the UTC field in the DMTF date with the current
            // zones UTC value
            System.TimeZone curZone    = System.TimeZone.CurrentTimeZone;
            System.TimeSpan tickOffset = curZone.GetUtcOffset(date);
            long            OffsetMins = (tickOffset.Ticks / System.TimeSpan.TicksPerMinute);
            IFormatProvider frmInt32   = (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int32));

            // If the offset is more than that what can be specified in DMTF format, then
            // convert the date to UniversalTime
            if (Math.Abs(OffsetMins) > MAXSIZE_UTC_DMTF)
            {
                date      = date.ToUniversalTime();
                UtcString = "+000";
            }
            else
            if ((tickOffset.Ticks >= 0))
            {
                UtcString = "+" + ((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)).ToString(frmInt32).PadLeft(3, '0');
            }
            else
            {
                string strTemp = OffsetMins.ToString(frmInt32);
                UtcString = "-" + strTemp.Substring(1, strTemp.Length - 1).PadLeft(3, '0');
            }

            string dmtfDateTime = date.Year.ToString(frmInt32).PadLeft(4, '0');

            dmtfDateTime = (dmtfDateTime + date.Month.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Day.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Hour.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Minute.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Second.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + ".");

            // Construct a DateTime with with the precision to Second as same as the passed DateTime and so get
            // the ticks difference so that the microseconds can be calculated
            DateTime dtTemp = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);

            System.Int64 microsec = ((date.Ticks - dtTemp.Ticks) * 1000) / System.TimeSpan.TicksPerMillisecond;

            // fill the microseconds field
            String strMicrosec = microsec.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int64)));

            if (strMicrosec.Length > 6)
            {
                strMicrosec = strMicrosec.Substring(0, 6);
            }
            dmtfDateTime = dmtfDateTime + strMicrosec.PadLeft(6, '0');
            // adding the UTC offset
            dmtfDateTime = dmtfDateTime + UtcString;

            return(dmtfDateTime);
        }
예제 #19
0
        public override string ToString()
        {
            string result = null;

            switch (SelectedIndex)
            {
            case 1:
                string          dateFormat = string.Empty;
                string          timeFormat = string.Empty;
                Regex           r1         = new Regex(@"(y*[-\/]*M*[-\/]*[Dd]*)(M*[-\/]*[Dd]*[-\/]*y*)([Dd]*[-\/]*M*[-\/]*y*)([Hh]*[:]*m*[:]*s*[ ]*t*)");
                MatchCollection mc         = r1.Matches(DateTimeFormat);
                foreach (Match match in mc)
                {
                    if (match.Value.Trim().Length > 0 && match.Value.Contains('d'))
                    {
                        dateFormat = match.Value;
                    }
                    if (match.Value.Trim().Length > 0 && match.Value.Contains('m'))
                    {
                        timeFormat = match.Value;
                    }
                }
                System.TimeZone zone    = System.TimeZone.CurrentTimeZone;
                TimeSpan        span    = zone.GetUtcOffset(DateTime.Now);
                DateTime        dtLocal = DateTime.Now.Add(TimeZone.UtcOffset - span);
                // if GAT is behind Now, return +1
                int addDays = ExactTimeValidDays;
                if (ExactTimeValidDays == 0 && DateTime.Parse(dtLocal.ToShortTimeString()) >= DateTime.Parse(ExactTime.ToShortTimeString()))
                {
                    addDays = 1;
                }

                result  = DateTimeFormat.Replace(dateFormat, dtLocal.AddDays(addDays).ToString(dateFormat));
                result  = result.Replace(timeFormat, ExactTime.ToString(timeFormat));
                result += TimeZone != null ? " " + TimeZone.Id : "";
                //System.Diagnostics.Debug.WriteLine("GTD: " + result);

                break;

            case 2:
                //result =  OrderTime.AddSeconds(Seconds).ToString(DateTimeFormat);
                // assume using current timezone setting
                result = DateTime.Now.AddSeconds(Seconds).ToString(DateTimeFormat);
                break;

            case 3:
                int div = (int)Math.Ceiling((float)(OrderTime.Minute / (int)BarInterval));
                // in case of the beginning of bar
                if (OrderTime.Minute % (int)BarInterval == 0)
                {
                    div++;
                }
                result = DateTime.Now.AddMinutes((int)BarInterval * div).ToString(DateTimeFormat);
                break;
            }
            return(result);
        }
예제 #20
0
        public static DateTime FromUnix(Double TimeStamp, System.TimeZone Zone)
        {
            DateTime d = Convert.ToDateTime("1970-01-01T00:00:00Z");
            TimeSpan t = new TimeSpan(( long )(( Double )TimeStamp * ( Double )10000000));

            d = d.ToUniversalTime();
            d = d.Add(t);
            return(Zone.ToLocalTime(d));
        }
예제 #21
0
파일: IeTime56.cs 프로젝트: ame89/IEC-60870
        public long GetTimestamp(int startOfCentury, TimeZone timeZone)
        {
            var century = startOfCentury/100*100;
            if (value[6] < startOfCentury%100)
            {
                century += 100;
            }

            return -1;
        }
예제 #22
0
        protected override void WriteAllSettings(XmlWriter writer)
        {
            // Message Reader

            StartSection(writer, SectionMessageReader);
            WriteSetting(writer, SettingRemoveWhenReading, XmlConvert.ToString(RemoveWhenReading));
            WriteSetting(writer, SettingMaxCountToAutoStart, XmlConvert.ToString(MaxCountToAutoStart));
            EndSection(writer);

            // Visual

            StartSection(writer, SectionVisual);
            WriteSetting(writer, SettingMainWindow, MainWindow);
            WriteSetting(writer, SettingLogWindow, LogWindow);
            WriteSetting(writer, SettingDetailsWindow, DetailsWindow);
            WriteSetting(writer, SettingExceptionWindow, ExceptionWindow);
            WriteSetting(writer, SettingGenericEditorWindow, GenericEditorWindow);
            WriteSetting(writer, SettingLogColumnWidths, LogColumnWidths);
            WriteSetting(writer, SettingLogSplitterRatio, XmlConvert.ToString(LogSplitRatio));
            WriteSetting(writer, SettingDetailsSplitterRatioTop, XmlConvert.ToString(DetailsSplitterRatioTop));
            WriteSetting(writer, SettingDetailsSplitterRatioBottom, XmlConvert.ToString(DetailsSplitterRatioBottom));
            WriteSetting(writer, SettingDetailColumnWidths, DetailColumnWidths);
            WriteSetting(writer, SettingParameterColumnWidths, ParameterColumnWidths);
            EndSection(writer);

            // View

            StartSection(writer, SectionView);
            WriteSetting(writer, SettingPreviewPane, XmlConvert.ToString(PreviewPane));
            WriteSetting(writer, SettingStatusBar, XmlConvert.ToString(StatusBar));
            WriteSetting(writer, SettingAutoScrollMessages, XmlConvert.ToString(AutoScrollMessages));

            // Write the standard name of the time zone or "(CurrentTimeZone)" for the current time zone.

            System.TimeZone timeZone = DisplayTimeZone;
            if (timeZone == null || timeZone == System.TimeZone.CurrentTimeZone)
            {
                WriteSetting(writer, SettingDisplayTimeZone, CurrentTimeZoneName);
            }
            else
            {
                Debug.Assert(timeZone is LinkMeType.TimeZone, "Unexpected type of TimeZone: " + timeZone.GetType().FullName);
                WriteSetting(writer, SettingDisplayTimeZone, ((LinkMeType.TimeZone)timeZone).StandardName);
            }

            EndSection(writer);

            // Recently used

            StartSection(writer, SectionRecentlyUsed);
            WriteSetting(writer, SettingMaxRecentlyUsed, XmlConvert.ToString(MaxRecentlyUsed));
            WriteSetting(writer, SettingRecentlyUsedList, RecentlyUsedList);
            WriteSetting(writer, SettingLastActive, LastActive);
            EndSection(writer);
        }
예제 #23
0
        public void setTimeZone(System.TimeZone timezone)
        {
            if (timezone != null &&       // catch GMT+00:00 case, treat as just GMT
                timezone.StandardName == "GMT+00:00")
            {
                timezone = null;
            }

            tz            = timezone;
            this.TimeZone = (tz == null)? gmtTimeZone : localTimeZone;
        }
예제 #24
0
 static public int get_StandardName(IntPtr l)
 {
     try {
         System.TimeZone self = (System.TimeZone)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.StandardName);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #25
0
 private void cboTimeZone_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (cboTimeZone.SelectedIndex == -1)
     {
         SetButtonEnabled(DialogResult.OK, false);
     }
     else
     {
         System.TimeZone current = GetValue();
         SetButtonEnabled(DialogResult.OK, (current != null && !current.Equals(m_original)));
     }
 }
예제 #26
0
 public void RangeTime()
 {
     var timeZone = new TimeZone("Default");
     timeZone.AddRangeTime(DayOfWeek.Monday, 9, 10);
     Assert.AreEqual(1, timeZone.WorkingDays.Count());
     var workingDay = timeZone.WorkingDays.FirstOrDefault();
     Assert.AreEqual(2, workingDay.WorkingHours.Count());
     timeZone.AddRangeTime(DayOfWeek.Monday, 9, 10);
     Assert.AreEqual(1, timeZone.WorkingDays.Count());
     workingDay = timeZone.WorkingDays.FirstOrDefault();
     Assert.AreEqual(2, workingDay.WorkingHours.Count());
 }
예제 #27
0
        public void DisplayValue(System.TimeZone value)
        {
            EnsureInitialised();

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (value == System.TimeZone.CurrentTimeZone)
            {
                radCurrent.Checked = true;
            }
            else
            {
                LinkMeType.TimeZone typeTz = value as LinkMeType.TimeZone;
                if (typeTz == null)
                {
                    throw new ArgumentException("Unsupported type of TimeZone object: "
                                                + value.GetType().FullName, "value");
                }

                if (typeTz.Equals(LinkMeType.TimeZone.UTC))
                {
                    radUtc.Checked = true;
                }
                else
                {
                    radSpecified.Checked = true;

                    bool found = false;
                    for (int index = 0; index < cboTimeZone.Items.Count; index++)
                    {
                        if (typeTz.StandardName == (string)cboTimeZone.Items[index])
                        {
                            found = true;
                            cboTimeZone.SelectedIndex = index;
                            break;
                        }
                    }

                    if (!found)
                    {
                        cboTimeZone.Items.Insert(0, value.StandardName);
                        cboTimeZone.SelectedIndex = 0;
                    }
                }
            }

            m_original = value;
            SetButtonEnabled(DialogResult.OK, false);
        }
예제 #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region dtUserOffSet
            if (ghFunctions.dtUserOffSet == 0)
            {
                /// Switch this to a user determined variable
                /// Possibly in the MasterPage
                Int32           dtOffSet  = 5;
                DateTime        dtCurrent = DateTime.Now;
                System.TimeZone localZone = System.TimeZone.CurrentTimeZone;
                if (localZone.IsDaylightSavingTime(dtCurrent))
                {
                    dtOffSet = 4;
                }
                else
                {
                    dtOffSet = 5;
                }
                ghFunctions.dtUserOffSet = dtOffSet;
            }
            #endregion dtUserOffSet

            #region Site Mode
            if (tglMode == "Live")
            {
                lblMode.Text      = "Live";
                lblMode.ForeColor = System.Drawing.Color.Blue;
                lblJRE.ForeColor  = System.Drawing.Color.Blue;
            }
            else if (tglMode == "Test" || tglMode == "Stage")
            {
                lblMode.Text = "Testing";
                //lblMode.Font.Size = 24;
            }
            else if (tglMode == "Maintenance")
            {
                lblMode.Text = "Maintenance Mode";
            }
            else
            {
            }
            lblMode.Text += " - " + ghFunctions.portalVersion;
            #endregion Site Mode
        }


        Load_Call_Links();
    }
예제 #29
0
 static public int GetDaylightChanges(IntPtr l)
 {
     try {
         System.TimeZone self = (System.TimeZone)checkSelf(l);
         System.Int32    a1;
         checkType(l, 2, out a1);
         var ret = self.GetDaylightChanges(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #30
0
 static public int ToUniversalTime(IntPtr l)
 {
     try {
         System.TimeZone self = (System.TimeZone)checkSelf(l);
         System.DateTime a1;
         checkValueType(l, 2, out a1);
         var ret = self.ToUniversalTime(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #31
0
	private void TST (TimeZone t1) 
	{
		Assert.AreEqual("Tokyo Standard Time", t1.StandardName, "C01");
		Assert.AreEqual("Tokyo Standard Time", t1.DaylightName, "C02");

		DateTime d3 = new DateTime (2002,2,25);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "C09");
		DateTime d4 = new DateTime (2002,4,8);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d4), "C10");
		DateTime d5 = new DateTime (2002,11,4);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "C11");

		Assert.AreEqual(324000000000L, t1.GetUtcOffset (d3).Ticks, "C12");
		Assert.AreEqual(324000000000L, t1.GetUtcOffset (d4).Ticks, "C13");
		Assert.AreEqual(324000000000L, t1.GetUtcOffset (d5).Ticks, "C14");
	}
예제 #32
0
 static int GetDaylightChanges(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         System.TimeZone obj  = (System.TimeZone)ToLua.CheckObject <System.TimeZone>(L, 1);
         int             arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         System.Globalization.DaylightTime o = obj.GetDaylightChanges(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #33
0
    static int ToLocalTime(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            System.TimeZone obj  = (System.TimeZone)ToLua.CheckObject <System.TimeZone>(L, 1);
            System.DateTime arg0 = StackTraits <System.DateTime> .Check(L, 2);

            System.DateTime o = obj.ToLocalTime(arg0);
            ToLua.PushValue(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #34
0
    static int get_StandardName(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            System.TimeZone obj = (System.TimeZone)o;
            string          ret = obj.StandardName;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index StandardName on a nil value"));
        }
    }
예제 #35
0
        static StackObject *GetUtcOffset_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.DateTime @time = (System.DateTime) typeof(System.DateTime).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.TimeZone instance_of_this_method = (System.TimeZone) typeof(System.TimeZone).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.GetUtcOffset(@time);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
예제 #36
0
        private static string GetTimezone()
        {
            System.TimeZone tz    = System.TimeZone.CurrentTimeZone;
            System.TimeSpan tspan = tz.GetUtcOffset(System.DateTime.Now);

            // TimeZone.  Format should be '+|-HH:MM' (e.g., -07:00).
            String tzformat;

            if (tspan.Hours >= 0)
            {
                tzformat = String.Format("+{0}:{1}", tspan.Hours.ToString("D2"), tspan.Minutes.ToString("D2"));
            }
            else
            {
                tzformat = String.Format("{0}:{1}", tspan.Hours.ToString("D2"), tspan.Minutes.ToString("D2"));
            }
            return(tzformat);
        }
예제 #37
0
 private TimeZone CreateTimeZone()
 {
     if (this._timeZoneService.GetTimeZone(_default) != null)
         return this._timeZoneService.GetTimeZone(_default);
     var timeZone = new TimeZone(_default);
     foreach (DayOfWeek dayOfWeek in Enum.GetValues(typeof(DayOfWeek)))
     {
         if (dayOfWeek != DayOfWeek.Sunday && dayOfWeek != DayOfWeek.Saturday)
         {
             timeZone.AddRangeTime(dayOfWeek, 9, 12);
             timeZone.AddRangeTime(dayOfWeek, 13, 19);
             timeZone.RemoveRangeTime(dayOfWeek, 18.5, 19);
         }
     }
     timeZone.AddSpecialDay(DateTime.Now, 6, 12);
     timeZone.AddExceptionDay(DateTime.Now.AddDays(1));
     this._timeZoneService.Create(timeZone);
     return timeZone;
 }
예제 #38
0
파일: IeTime56.cs 프로젝트: ame89/IEC-60870
        public IeTime56(long timestamp, TimeZone timeZone, bool invalid)
        {
            var datetime = new DateTime(timestamp);
            var ms = datetime.Millisecond + 1000*datetime.Second;

            value[0] = (byte) ms;
            value[1] = (byte) (ms >> 8);
            value[2] = (byte) datetime.Minute;

            if (invalid)
            {
                value[2] |= 0x80;
            }
            value[3] = (byte) datetime.Hour;
            if (datetime.IsDaylightSavingTime())
            {
                value[3] |= 0x80;
            }
            value[4] = (byte) (datetime.Day + ((((int) datetime.DayOfWeek + 5)%7 + 1) << 5));
            value[5] = (byte) (datetime.Month + 1);
            value[6] = (byte) (datetime.Year%100);
        }
예제 #39
0
 internal static System.TimeZone ConvertFromByteToTimeZone(byte[] data)
 {
     System.TimeZone result = null;
     if (data != null)
     {
         try
         {
             MemoryStream    serializationStream = new MemoryStream(data);
             BinaryFormatter formatter           = new BinaryFormatter();
             LanguagePrimitives.TryConvertTo <System.TimeZone>(formatter.Deserialize(serializationStream), out result);
             return(result);
         }
         catch (ArgumentNullException)
         {
         }
         catch (SerializationException)
         {
         }
         catch (SecurityException)
         {
         }
     }
     return(result);
 }
예제 #40
0
 public static AlcoholicMergePolicy NewAlcoholicMergePolicy(Random r, TimeZone tz)
 {
     return new AlcoholicMergePolicy(tz, new Random(r.Next()));
 }
 public static Boolean IsDaylightSavingTime(this DateTime time, DaylightTime daylightTimes)
 {
     return(TimeZone.IsDaylightSavingTime(time, daylightTimes));
 }
예제 #42
0
 /// <summary>返回一个值,用以指示指定日期和时间是否处于指定的夏时制期间。</summary>
 /// <returns>如果 <paramref name="time" /> 处于 <paramref name="daylightTimes" />,则为 true;否则为 false。</returns>
 /// <param name="time">日期和时间。</param>
 /// <param name="daylightTimes">夏时制期间。</param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="daylightTimes" /> 为 null。</exception>
 /// <filterpriority>1</filterpriority>
 public static bool IsDaylightSavingTime(DateTime time, DaylightTime daylightTimes)
 {
     return(TimeZone.CalculateUtcOffset(time, daylightTimes) != TimeSpan.Zero);
 }
        /// <summary>
        /// <para>Converts a given DMTF datetime to <see cref='System.DateTime'/> object. The returned DateTime will be in the
        ///			current TimeZone of the system.</para>
        /// </summary>
        /// <param name='dmtfDate'>A string representing the datetime in DMTF format.</param>
        /// <returns>
        /// <para>A <see cref='System.DateTime'/> object that represents the given DMTF datetime.</para>
        /// </returns>
        /// <remarks>
        ///			<para> Date and time in WMI is represented in DMTF datetime format. This format is explained in WMI SDK documentation.
        ///				DMTF datetime string has an UTC offset which this datetime string represents.
        ///				 During conversion to <see cref='System.DateTime'/>, UTC offset is used to convert the date to the
        ///				current timezone. According to DMTF format a particular field can be represented by the character
        ///				'*'. This will be converted to the MinValue of this field that can be represented in <see cref='System.DateTime'/>.
        ///			</para>
        /// </remarks>
        /// <example>
        ///    <code lang='C#'>
        ///	// Convert a DMTF datetime to System.DateTime
        ///	DateTime date = ManagementDateTimeConverter.ToDateTime("20020408141835.999999-420");
        ///    </code>
        ///    <code lang='VB'>
        ///	' Convert a DMTF datetime to System.DateTime
        ///	Dim date as DateTime = ManagementDateTimeConverter.ToDateTime("20020408141835.999999-420")
        ///    </code>
        /// </example>
        public static DateTime ToDateTime(string dmtfDate)
        {
            int      year     = DateTime.MinValue.Year;
            int      month    = DateTime.MinValue.Month;
            int      day      = DateTime.MinValue.Day;
            int      hour     = DateTime.MinValue.Hour;
            int      minute   = DateTime.MinValue.Minute;
            int      second   = DateTime.MinValue.Second;
            int      millisec = 0;
            string   dmtf     = dmtfDate;
            DateTime datetime = DateTime.MinValue;

            // If the string passed is empty or null then throw
            // an exception
            if (dmtf == null)
            {
                throw new System.ArgumentOutOfRangeException();
            }
            if (dmtf.Length == 0)
            {
                throw new System.ArgumentOutOfRangeException();
            }

            // if the length of the string is not equal to the
            // standard length of the DMTF datetime then throw an exception
            if (dmtf.Length != SIZEOFDMTFDATETIME)
            {
                throw new System.ArgumentOutOfRangeException();
            }

            System.Int64 ticks = 0;
            try
            {
                string tempString = System.String.Empty;
                tempString = dmtf.Substring(0, 4);
                if (("****" != tempString))
                {
                    year = System.Int32.Parse(tempString);
                }
                tempString = dmtf.Substring(4, 2);
                if (("**" != tempString))
                {
                    month = System.Int32.Parse(tempString);
                }
                tempString = dmtf.Substring(6, 2);
                if (("**" != tempString))
                {
                    day = System.Int32.Parse(tempString);
                }
                tempString = dmtf.Substring(8, 2);
                if (("**" != tempString))
                {
                    hour = System.Int32.Parse(tempString);
                }
                tempString = dmtf.Substring(10, 2);
                if (("**" != tempString))
                {
                    minute = System.Int32.Parse(tempString);
                }
                tempString = dmtf.Substring(12, 2);
                if (("**" != tempString))
                {
                    second = System.Int32.Parse(tempString);
                }
                tempString = dmtf.Substring(15, 6);
                if (("******" != tempString))
                {
                    ticks = (System.Int64.Parse(tempString)) * (System.TimeSpan.TicksPerMillisecond / 1000);
                }
                if (year < 0 || month < 0 || day < 0 || hour < 0 || minute < 0 || second < 0 || ticks < 0)
                {
                    throw new System.ArgumentOutOfRangeException();
                }
            }
            catch
            {
                throw new System.ArgumentOutOfRangeException();
            }


            // Construct a new System.DateTime object
            datetime = new System.DateTime(year, month, day, hour, minute, second, millisec);
            // Then add the ticks calculated from the microseconds
            datetime = datetime.AddTicks(ticks);

            // Adjust the UTC time to reflect the current zone time
            System.TimeZone curZone    = System.TimeZone.CurrentTimeZone;
            System.TimeSpan tickOffset = curZone.GetUtcOffset(datetime);
            long            OffsetMins = tickOffset.Ticks / System.TimeSpan.TicksPerMinute;

            // Adjusting the DateTime for the current UTC
            int    UTCOffset          = 0;
            string tempString1        = dmtf.Substring(22, 3);
            long   OffsetToBeAdjusted = 0;

            if (("***" != tempString1))
            {
                tempString1 = dmtf.Substring(21, 4);
                try
                {
                    UTCOffset = System.Int32.Parse(tempString1);
                }
                catch
                {
                    throw new System.ArgumentOutOfRangeException();
                }

                OffsetToBeAdjusted = UTCOffset - OffsetMins;

                // We have to substract the minutes from the time
                datetime = datetime.AddMinutes(OffsetToBeAdjusted * -1);
            }
            return(datetime);
        }
예제 #44
0
	private void GMT (TimeZone t1) {
		// Probably wont work on MS.NET, but is better than nothing. Where do
		// we change our implementation to match theirs?
		
		Assert.AreEqual("GMT", t1.StandardName, "D01");
		Assert.IsTrue("BST" == t1.DaylightName || "IST" == t1.DaylightName, "D02");
	
		DaylightTime d1 = t1.GetDaylightChanges (2002);
		Assert.AreEqual("03/31/2002 01:00:00", d1.Start.ToString ("G"), "D03");
		Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G"), "D04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "D05");
	
		DaylightTime d2 = t1.GetDaylightChanges (1996);
		Assert.AreEqual("03/31/1996 01:00:00", d2.Start.ToString ("G"), "D06");
		Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G"), "D07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "D08");
	
		DateTime d3 = new DateTime (2002,2,25);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "D09");
		DateTime d4 = new DateTime (2002,4,2);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "D10");
		DateTime d5 = new DateTime (2002,11,4);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "D11");
	
		Assert.AreEqual(0L, t1.GetUtcOffset (d3).Ticks, "D12");
		Assert.AreEqual(36000000000L, t1.GetUtcOffset (d4).Ticks, "D13");
		Assert.AreEqual(0L, t1.GetUtcOffset (d5).Ticks, "D14");
	}
예제 #45
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SecureCheck();
        if (Session["userstatus"] == null)
        {
            Response.Redirect("logout.aspx", false);
        }
        if (Session["userid"] == null || Session["UserFullName"] == null)
        {
            identity_get_user();
        }
        if (Session["UserFullName"] != null)
        {
            UserFullName.Text = Session["UserFullName"].ToString();
        }
        else
        {
            UserFullName.Text = "n/a";
        }
        ghFunctions.portalVersion = System.Configuration.ConfigurationManager.AppSettings["portal_version"];
        #region dtUserOffSet
        if (ghFunctions.dtUserOffSet == 0)
        {
            /// Switch this to a user determined variable
            /// Possibly in the MasterPage
            Int32           dtOffSet  = 5;
            DateTime        dtCurrent = DateTime.Now;
            System.TimeZone localZone = System.TimeZone.CurrentTimeZone;
            if (localZone.IsDaylightSavingTime(dtCurrent))
            {
                dtOffSet = 4;
            }
            else
            {
                dtOffSet = 5;
            }
            ghFunctions.dtUserOffSet = dtOffSet;
        }
        #endregion dtUserOffSet
        #region ARC Color
        lblMasterHeader.Text = "Portal - ARC";
        masterColor          = "#EEEEEE";
        if (System.Configuration.ConfigurationManager.AppSettings["DBMode"] == "Stage")
        {
            lblMasterHeader.Text = "Stage - Portal - ARC";
            masterColor          = "orange";
        }
        #endregion ARC Color
        if (!IsPostBack)
        {
            //Literal1.Text = Page.User.Identity.IsAuthenticated.ToString();
            //Literal2.Text = Page.User.Identity.Name;
            #region Perform certain action if user is authenticated
            if (Page.User.Identity.IsAuthenticated)
            {
                Literal3.Text = "";
                #region Load the Menu
                //Menue_Load();
                PopulateMenu(this.Page.User.Identity.Name);
                #endregion Load the Menu
                #region If User is a Sys Admin we add more menu options
                #endregion If User is a Sys Admin we add more menu options
                if (Page.User.IsInRole("System Administrator") == true)
                {
                    Literal3.Text      += "System Administrator<br />";
                    Session["UserRole"] = "System Administrator";
                    Panel1.Visible      = true;
                }
                if (Page.User.IsInRole("Administrator") == true)
                {
                    Literal3.Text      += "Administrator<br />";
                    Session["UserRole"] = "Administrator";
                }
                if (Page.User.IsInRole("Manager") == true)
                {
                    Literal3.Text      += "Manager<br />";
                    Session["UserRole"] = "Manager";
                }
                if (Page.User.IsInRole("Advisor") == true)
                {
                    Literal3.Text      += "Advisor<br />";
                    Session["UserRole"] = "Advisor";
                }
                if (Page.User.IsInRole("Agent") == true)
                {
                    Literal3.Text      += "Agent<br />";
                    Session["UserRole"] = "Agent";
                }
                if (Page.User.IsInRole("Client") == true)
                {
                    Literal3.Text      += "Client";
                    Session["UserRole"] = "Client";
                    if (Page.User.IsInRole("Capella") == true)
                    {
                        Literal3.Text        += " | Capella";
                        Session["UserClient"] = "Capella";
                    }
                    else if (Page.User.IsInRole("Troy") == true)
                    {
                        Literal3.Text        += " | Troy";
                        Session["UserClient"] = "Troy";
                    }
                    else if (Page.User.IsInRole("Strayer") == true)
                    {
                        Literal3.Text        += " | Strayer";
                        Session["UserClient"] = "Strayer";
                    }
                    else if (Page.User.IsInRole("Full Sail") == true)
                    {
                        Literal3.Text        += " | Full Sail";
                        Session["UserClient"] = "Full Sail";
                    }
                    Literal3.Text += "<br />";
                }
                DBMode.Text = Connection.GetDBMode();
                if (DBMode.Text == "Stage")
                {
                    DBMode.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    DBMode.ForeColor = System.Drawing.Color.Green;
                }
                DBMode.Text += "|" + Connection.GetConnectionType();
            }
            #endregion Perform certain action if user is authenticated
            //Simple Menu
            //G:\Documents and Settings\All Users\Desktop\Admin\Software\Web\dotNet\CSSFriendly_Adapter_1.0\CSSFriendly_1.0\Web\WalkThru
            //MenuLoad();
            //PopulateMenu(DeBug_Footer, Menu1, mi);

            // The header bar that labels the menu
            MessageLabel.Text = String.Format("Page: {0} - {1}"
                                              , MyTitle
                                              , PageTitle
                                              );
            // Highlight Active Menu..?
            lblTitleHeader.Text = " - " + PageTitle;
            Menu_Selected_Check(Menu1, PageTitle);
            /// This will verify that the user has access to the page
            /// This is done by checking that the page is in the Menu
            /// Change this so it's done through a query: is user allowed to see page
            /// This way we do not need to have the item in the menu section in order for the user to see it
            if (!verify_access() && Page.User.IsInRole("System Administrator") == false)
            {
                // Response.Redirect("access.aspx");
                Response.Redirect("~/access.aspx?p=" + PageTitle, true);
                // Server.Transfer("~/access.aspx", false); // This crashes
            }
            string currentPage = new System.IO.FileInfo(HttpContext.Current.Request.Url.LocalPath).Name;
            if (!(currentPage.ToLower().Contains("user_profile.aspx")) && Session["userstatus"] != null && Session["userstatus"].ToString() == "5")
            {
                Response.Redirect("user_profile.aspx", false);
                Context.ApplicationInstance.CompleteRequest();
            }
        }
    }
예제 #46
0
 /// <summary>返回一个值,用以指示指定日期和时间是否处于夏时制期间。</summary>
 /// <returns>如果 <paramref name="time" /> 处于夏时制期间,则为 true;否则为 false。</returns>
 /// <param name="time">日期和时间。</param>
 /// <filterpriority>2</filterpriority>
 public virtual bool IsDaylightSavingTime(DateTime time)
 {
     return(TimeZone.IsDaylightSavingTime(time, this.GetDaylightChanges(time.Year)));
 }
예제 #47
0
 void ITimeZoneService.Delete(TimeZone timeZone)
 {
     _repository.Remove(timeZone);
 }
예제 #48
0
	private void NZST(TimeZone t1) {
		Assert.AreEqual("NZST", t1.StandardName, "E01");
		Assert.AreEqual("NZDT", t1.DaylightName, "E02");

		DaylightTime d1 = t1.GetDaylightChanges (2013);
		Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString ("G"), "E03");
		Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString ("G"), "E04");
		Assert.AreEqual(36000000000L, d1.Delta.Ticks, "E05");

		DaylightTime d2 = t1.GetDaylightChanges (2001);
		Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString ("G"), "E06");
		Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString ("G"), "E07");
		Assert.AreEqual(36000000000L, d2.Delta.Ticks, "E08");

		DateTime d3 = new DateTime(2013,02,15);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d3), "E09");
		DateTime d4 = new DateTime(2013,04,30);
		Assert.AreEqual(false, t1.IsDaylightSavingTime (d4), "E10");
		DateTime d5 = new DateTime(2013,11,03);
		Assert.AreEqual(true, t1.IsDaylightSavingTime (d5), "E11");

		Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d3).Ticks, "E12");
		Assert.AreEqual(36000000000L /*hour*/ * 12L, t1.GetUtcOffset (d4).Ticks, "E13");
		Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d5).Ticks, "E14");
	}
예제 #49
0
 void ITimeZoneService.Create(TimeZone timeZone)
 {
     if (_repository.FindByName(timeZone.Name) != null)
         throw new InvalidOperationException("已经存在同名的时区信息");
     _repository.Add(timeZone);
 }
예제 #50
0
 void ITimeZoneService.Update(TimeZone timeZone)
 {
     _repository.Update(timeZone);
 }
예제 #51
0
파일: DayEntry.cs 프로젝트: plntxt/dasblog
		/// <summary>
		/// Returns true if the specified DayEntry is within the same month as <c>month</c>;
		/// </summary>
		/// <param name="dayEntry"></param>
		/// <param name="timeZone"></param>
		/// <param name="month"></param>
		/// <returns></returns>
		public static bool OccursInMonth(DayEntry dayEntry, TimeZone timeZone, 
			DateTime month)
		{
			DateTime startOfMonth = new DateTime(month.Year, month.Month, 1, 0, 0, 0);
			DateTime endOfMonth = new DateTime(month.Year, month.Month, 1, 0, 0, 0);
			endOfMonth = endOfMonth.AddMonths(1);
			endOfMonth = endOfMonth.AddSeconds(-1);
			
			TimeSpan offset = timeZone.GetUtcOffset(endOfMonth);
			endOfMonth = endOfMonth.AddHours(offset.Negate().Hours);
			return ( OccursBetween(dayEntry, timeZone, startOfMonth, endOfMonth) );
		}
예제 #52
0
파일: DayEntry.cs 프로젝트: plntxt/dasblog
		public static bool OccursBetween(DayEntry dayEntry, TimeZone timeZone, 
			DateTime startDateTime, DateTime endDateTime)
		{
			//return ((timeZone.ToLocalTime(dayEntry.DateUtc) >= startDateTime)
			//	&& (timeZone.ToLocalTime(dayEntry.DateUtc) <= endDateTime) );
			return ((dayEntry.DateUtc >= startDateTime)
				&& (dayEntry.DateUtc <= endDateTime) );
		}
예제 #53
0
 /**
  *  Given an Excel date with either 1900 or 1904 date windowing,
  *  converts it to a java.util.Date.
  *  
  *  Excel Dates and Times are stored without any timezone 
  *  information. If you know (through other means) that your file 
  *  uses a different TimeZone to the system default, you can use
  *  this version of the getJavaDate() method to handle it.
  *   
  *  @param date  The Excel date.
  *  @param tz The TimeZone to evaluate the date in
  *  @param use1904windowing  true if date uses 1904 windowing,
  *   or false if using 1900 date windowing.
  *  @param roundSeconds round to closest second
  *  @return Java representation of the date, or null if date is not a valid Excel date
  */
 public static DateTime GetJavaDate(double date, bool use1904windowing, TimeZone tz, bool roundSeconds)
 {
     return GetJavaCalendar(date, use1904windowing, roundSeconds);
 }
예제 #54
0
 public ServerInfo( string name, int fullPercent, TimeZone tz, IPEndPoint address )
 {
     m_Name = name;
     m_FullPercent = fullPercent;
     m_TimeZone = tz.GetUtcOffset( Core.Now ).Hours;
     m_Address = address;
 }
예제 #55
0
    public void Populate()
    {
        #region Types of Keywords

        FieldPublicDynamic = new { PropPublic1 = "A", PropPublic2 = 1, PropPublic3 = "B", PropPublic4 = "B", PropPublic5 = "B", PropPublic6 = "B", PropPublic7 = "B", PropPublic8 = "B", PropPublic9 = "B", PropPublic10 = "B", PropPublic11 = "B", PropPublic12 = new { PropSubPublic1 = 0, PropSubPublic2 = 1, PropSubPublic3 = 2 } };
        FieldPublicObject  = new StringBuilder("Object - StringBuilder");
        FieldPublicInt32   = int.MaxValue;
        FieldPublicInt64   = long.MaxValue;
        FieldPublicULong   = ulong.MaxValue;
        FieldPublicUInt    = uint.MaxValue;
        FieldPublicDecimal = 100000.999999m;
        FieldPublicDouble  = 100000.999999d;
        FieldPublicChar    = 'A';
        FieldPublicByte    = byte.MaxValue;
        FieldPublicBoolean = true;
        FieldPublicSByte   = sbyte.MaxValue;
        FieldPublicShort   = short.MaxValue;
        FieldPublicUShort  = ushort.MaxValue;
        FieldPublicFloat   = 100000.675555f;

        FieldPublicInt32Nullable   = int.MaxValue;
        FieldPublicInt64Nullable   = 2;
        FieldPublicULongNullable   = ulong.MaxValue;
        FieldPublicUIntNullable    = uint.MaxValue;
        FieldPublicDecimalNullable = 100000.999999m;
        FieldPublicDoubleNullable  = 100000.999999d;
        FieldPublicCharNullable    = 'A';
        FieldPublicByteNullable    = byte.MaxValue;
        FieldPublicBooleanNullable = true;
        FieldPublicSByteNullable   = sbyte.MaxValue;
        FieldPublicShortNullable   = short.MaxValue;
        FieldPublicUShortNullable  = ushort.MaxValue;
        FieldPublicFloatNullable   = 100000.675555f;

        #endregion

        #region System

        FieldPublicDateTime         = new DateTime(2000, 1, 1, 1, 1, 1);
        FieldPublicTimeSpan         = new TimeSpan(1, 10, 40);
        FieldPublicEnumDateTimeKind = DateTimeKind.Local;

        // Instantiate date and time using Persian calendar with years,
        // months, days, hours, minutes, seconds, and milliseconds
        FieldPublicDateTimeOffset = new DateTimeOffset(1387, 2, 12, 8, 6, 32, 545,
                                                       new System.Globalization.PersianCalendar(),
                                                       new TimeSpan(1, 0, 0));

        FieldPublicIntPtr         = new IntPtr(100);
        FieldPublicTimeZone       = TimeZone.CurrentTimeZone;
        FieldPublicTimeZoneInfo   = TimeZoneInfo.Utc;
        FieldPublicTuple          = Tuple.Create <string, int, decimal>("T-string\"", 1, 1.1m);
        FieldPublicType           = typeof(object);
        FieldPublicUIntPtr        = new UIntPtr(100);
        FieldPublicUri            = new Uri("http://www.site.com");
        FieldPublicVersion        = new Version(1, 0, 100, 1);
        FieldPublicGuid           = new Guid("d5010f5b-0cd1-44ca-aacb-5678b9947e6c");
        FieldPublicSingle         = Single.MaxValue;
        FieldPublicException      = new Exception("Test error", new Exception("inner exception"));
        FieldPublicEnumNonGeneric = EnumTest.ValueA;
        FieldPublicAction         = () => true.Equals(true);
        FieldPublicAction2        = (a, b) => true.Equals(true);
        FieldPublicFunc           = () => true;
        FieldPublicFunc2          = (a, b) => true;

        #endregion

        #region Arrays and Collections

        FieldPublicArrayUni    = new string[2];
        FieldPublicArrayUni[0] = "[0]";
        FieldPublicArrayUni[1] = "[1]";

        FieldPublicArrayTwo       = new string[2, 2];
        FieldPublicArrayTwo[0, 0] = "[0, 0]";
        FieldPublicArrayTwo[0, 1] = "[0, 1]";
        FieldPublicArrayTwo[1, 0] = "[1, 0]";
        FieldPublicArrayTwo[1, 1] = "[1, 1]";

        FieldPublicArrayThree          = new string[1, 1, 2];
        FieldPublicArrayThree[0, 0, 0] = "[0, 0, 0]";
        FieldPublicArrayThree[0, 0, 1] = "[0, 0, 1]";

        FieldPublicJaggedArrayTwo    = new string[2][];
        FieldPublicJaggedArrayTwo[0] = new string[5] {
            "a", "b", "c", "d", "e"
        };
        FieldPublicJaggedArrayTwo[1] = new string[4] {
            "a1", "b1", "c1", "d1"
        };

        FieldPublicJaggedArrayThree          = new string[1][][];
        FieldPublicJaggedArrayThree[0]       = new string[1][];
        FieldPublicJaggedArrayThree[0][0]    = new string[2];
        FieldPublicJaggedArrayThree[0][0][0] = "[0][0][0]";
        FieldPublicJaggedArrayThree[0][0][1] = "[0][0][1]";

        FieldPublicMixedArrayAndJagged = new int[3][, ]
        {
            new int[, ] {
                { 1, 3 }, { 5, 7 }
            },
            new int[, ] {
                { 0, 2 }, { 4, 6 }, { 8, 10 }
            },
            new int[, ] {
                { 11, 22 }, { 99, 88 }, { 0, 9 }
            }
        };

        FieldPublicDictionary = new System.Collections.Generic.Dictionary <string, string>();
        FieldPublicDictionary.Add("Key1", "Value1");
        FieldPublicDictionary.Add("Key2", "Value2");
        FieldPublicDictionary.Add("Key3", "Value3");
        FieldPublicDictionary.Add("Key4", "Value4");

        FieldPublicList = new System.Collections.Generic.List <int>();
        FieldPublicList.Add(0);
        FieldPublicList.Add(1);
        FieldPublicList.Add(2);

        FieldPublicQueue = new System.Collections.Generic.Queue <int>();
        FieldPublicQueue.Enqueue(10);
        FieldPublicQueue.Enqueue(11);
        FieldPublicQueue.Enqueue(12);

        FieldPublicHashSet = new System.Collections.Generic.HashSet <string>();
        FieldPublicHashSet.Add("HashSet1");
        FieldPublicHashSet.Add("HashSet2");

        FieldPublicSortedSet = new System.Collections.Generic.SortedSet <string>();
        FieldPublicSortedSet.Add("SortedSet1");
        FieldPublicSortedSet.Add("SortedSet2");
        FieldPublicSortedSet.Add("SortedSet3");

        FieldPublicStack = new System.Collections.Generic.Stack <string>();
        FieldPublicStack.Push("Stack1");
        FieldPublicStack.Push("Stack2");
        FieldPublicStack.Push("Stack3");

        FieldPublicLinkedList = new System.Collections.Generic.LinkedList <string>();
        FieldPublicLinkedList.AddFirst("LinkedList1");
        FieldPublicLinkedList.AddLast("LinkedList2");
        FieldPublicLinkedList.AddAfter(FieldPublicLinkedList.Find("LinkedList1"), "LinkedList1.1");

        FieldPublicObservableCollection = new System.Collections.ObjectModel.ObservableCollection <string>();
        FieldPublicObservableCollection.Add("ObservableCollection1");
        FieldPublicObservableCollection.Add("ObservableCollection2");

        FieldPublicKeyedCollection = new MyDataKeyedCollection();
        FieldPublicKeyedCollection.Add(new MyData()
        {
            Data = "data1", Id = 0
        });
        FieldPublicKeyedCollection.Add(new MyData()
        {
            Data = "data2", Id = 1
        });

        var list = new List <string>();
        list.Add("list1");
        list.Add("list2");
        list.Add("list3");

        FieldPublicReadOnlyCollection = new ReadOnlyCollection <string>(list);

        FieldPublicReadOnlyDictionary           = new ReadOnlyDictionary <string, string>(FieldPublicDictionary);
        FieldPublicReadOnlyObservableCollection = new ReadOnlyObservableCollection <string>(FieldPublicObservableCollection);
        FieldPublicCollection = new Collection <string>();
        FieldPublicCollection.Add("collection1");
        FieldPublicCollection.Add("collection2");
        FieldPublicCollection.Add("collection3");

        FieldPublicArrayListNonGeneric = new System.Collections.ArrayList();
        FieldPublicArrayListNonGeneric.Add(1);
        FieldPublicArrayListNonGeneric.Add("a");
        FieldPublicArrayListNonGeneric.Add(10.0m);
        FieldPublicArrayListNonGeneric.Add(new DateTime(2000, 01, 01));

        FieldPublicBitArray    = new System.Collections.BitArray(3);
        FieldPublicBitArray[2] = true;

        FieldPublicSortedList = new System.Collections.SortedList();
        FieldPublicSortedList.Add("key1", 1);
        FieldPublicSortedList.Add("key2", 2);
        FieldPublicSortedList.Add("key3", 3);
        FieldPublicSortedList.Add("key4", 4);

        FieldPublicHashtableNonGeneric = new System.Collections.Hashtable();
        FieldPublicHashtableNonGeneric.Add("key1", 1);
        FieldPublicHashtableNonGeneric.Add("key2", 2);
        FieldPublicHashtableNonGeneric.Add("key3", 3);
        FieldPublicHashtableNonGeneric.Add("key4", 4);

        FieldPublicQueueNonGeneric = new System.Collections.Queue();
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric1");
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric2");
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric3");

        FieldPublicStackNonGeneric = new System.Collections.Stack();
        FieldPublicStackNonGeneric.Push("StackNonGeneric1");
        FieldPublicStackNonGeneric.Push("StackNonGeneric2");

        FieldPublicIEnumerable = FieldPublicSortedList;

        FieldPublicBlockingCollection = new System.Collections.Concurrent.BlockingCollection <string>();
        FieldPublicBlockingCollection.Add("BlockingCollection1");
        FieldPublicBlockingCollection.Add("BlockingCollection2");

        FieldPublicConcurrentBag = new System.Collections.Concurrent.ConcurrentBag <string>();
        FieldPublicConcurrentBag.Add("ConcurrentBag1");
        FieldPublicConcurrentBag.Add("ConcurrentBag2");
        FieldPublicConcurrentBag.Add("ConcurrentBag3");

        FieldPublicConcurrentDictionary = new System.Collections.Concurrent.ConcurrentDictionary <string, int>();
        FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary1", 0);
        FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary2", 0);

        FieldPublicConcurrentQueue = new System.Collections.Concurrent.ConcurrentQueue <string>();
        FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue1");
        FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue2");

        FieldPublicConcurrentStack = new System.Collections.Concurrent.ConcurrentStack <string>();
        FieldPublicConcurrentStack.Push("ConcurrentStack1");
        FieldPublicConcurrentStack.Push("ConcurrentStack2");

        // FieldPublicOrderablePartitioner = new OrderablePartitioner();
        // FieldPublicPartitioner;
        // FieldPublicPartitionerNonGeneric;

        FieldPublicHybridDictionary = new System.Collections.Specialized.HybridDictionary();
        FieldPublicHybridDictionary.Add("HybridDictionaryKey1", "HybridDictionary1");
        FieldPublicHybridDictionary.Add("HybridDictionaryKey2", "HybridDictionary2");

        FieldPublicListDictionary = new System.Collections.Specialized.ListDictionary();
        FieldPublicListDictionary.Add("ListDictionaryKey1", "ListDictionary1");
        FieldPublicListDictionary.Add("ListDictionaryKey2", "ListDictionary2");
        FieldPublicNameValueCollection = new System.Collections.Specialized.NameValueCollection();
        FieldPublicNameValueCollection.Add("Key1", "Value1");
        FieldPublicNameValueCollection.Add("Key2", "Value2");

        FieldPublicOrderedDictionary = new System.Collections.Specialized.OrderedDictionary();
        FieldPublicOrderedDictionary.Add(1, "OrderedDictionary1");
        FieldPublicOrderedDictionary.Add(2, "OrderedDictionary1");
        FieldPublicOrderedDictionary.Add("OrderedDictionaryKey2", "OrderedDictionary2");

        FieldPublicStringCollection = new System.Collections.Specialized.StringCollection();
        FieldPublicStringCollection.Add("StringCollection1");
        FieldPublicStringCollection.Add("StringCollection2");

        #endregion

        #region Several

        PropXmlDocument = new XmlDocument();
        PropXmlDocument.LoadXml("<xml>something</xml>");

        var tr = new StringReader("<Root>Content</Root>");
        PropXDocument         = XDocument.Load(tr);
        PropStream            = GenerateStreamFromString("Stream");
        PropBigInteger        = new System.Numerics.BigInteger(100);
        PropStringBuilder     = new StringBuilder("StringBuilder");
        FieldPublicIQueryable = new List <string>()
        {
            "IQueryable"
        }.AsQueryable();

        #endregion

        #region Custom

        FieldPublicMyCollectionPublicGetEnumerator           = new MyCollectionPublicGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsPublicGetEnumerator   = new MyCollectionInheritsPublicGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionExplicitGetEnumerator         = new MyCollectionExplicitGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsExplicitGetEnumerator = new MyCollectionInheritsExplicitGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsTooIEnumerable        = new MyCollectionInheritsTooIEnumerable("a b c", new char[] { ' ' });

        FieldPublicEnumSpecific = EnumTest.ValueB;
        MyDelegate            = MethodDelegate;
        EmptyClass            = new EmptyClass();
        StructGeneric         = new ThreeTuple <int>(0, 1, 2);
        StructGenericNullable = new ThreeTuple <int>(0, 1, 2);
        FieldPublicNullable   = new Nullable <ThreeTuple <int> >(StructGeneric);

        #endregion
    }
예제 #56
0
 /**
  *  Given an Excel date with either 1900 or 1904 date windowing,
  *  converts it to a java.util.Date.
  *  
  *  Excel Dates and Times are stored without any timezone 
  *  information. If you know (through other means) that your file 
  *  uses a different TimeZone to the system default, you can use
  *  this version of the getJavaDate() method to handle it.
  *   
  *  @param date  The Excel date.
  *  @param tz The TimeZone to evaluate the date in
  *  @param use1904windowing  true if date uses 1904 windowing,
  *   or false if using 1900 date windowing.
  *  @return Java representation of the date, or null if date is not a valid Excel date
  */
 public static DateTime getJavaDate(double date, bool use1904windowing, TimeZone tz)
 {
     return GetJavaCalendar(date, use1904windowing, false);
 }
예제 #57
0
        /// <summary> Writes a Molecule to an OutputStream in MDL sdf format.
        ///
        /// </summary>
        /// <param name="container"> Molecule that is written to an OutputStream
        /// </param>
        /// <param name="isVisible">Should a certain atom be written to mdl?
        /// </param>
        public virtual void writeMolecule(IMolecule container, bool[] isVisible)
        {
            System.String line = "";
            // taking care of the $$$$ signs:
            // we do not write such a sign at the end of the first molecule, thus we have to write on BEFORE the second molecule
            if (moleculeNumber == 2)
            {
                writer.Write("$$$$");
                //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                writer.WriteLine();
            }
            // write header block
            // lines get shortened to 80 chars, that's in the spec
            System.String title = (System.String)container.getProperty(CDKConstants.TITLE);
            if (title == null)
            {
                title = "";
            }
            if (title.Length > 80)
            {
                title = title.Substring(0, (80) - (0));
            }
            writer.Write(title + "\n");

            /* From CTX spec
             * This line has the format:
             * IIPPPPPPPPMMDDYYHHmmddSSssssssssssEEEEEEEEEEEERRRRRR
             * (FORTRAN: A2<--A8--><---A10-->A2I2<--F10.5-><---F12.5--><-I6-> )
             * User's first and last initials (l), program name (P),
             * date/time (M/D/Y,H:m), dimensional codes (d), scaling factors (S, s),
             * energy (E) if modeling program input, internal registry number (R)
             * if input through MDL form.
             * A blank line can be substituted for line 2.
             */
            writer.Write("  CDK    ");
            //UPGRADE_ISSUE: Constructor 'java.text.SimpleDateFormat.SimpleDateFormat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextSimpleDateFormat'"
            //UPGRADE_TODO: The equivalent in .NET for method 'java.util.Calendar.getTime' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            System.TimeZone generatedAux3 = System.TimeZone.CurrentTimeZone;
            //writer.Write(SupportClass.FormatDateTime(new SimpleDateFormat("M/d/y,H:m", new System.Globalization.CultureInfo("en-US")), SupportClass.CalendarManager.manager.GetDateTime(new System.Globalization.GregorianCalendar())));
            writer.Write('\n');

            System.String comment = (System.String)container.getProperty(CDKConstants.REMARK);
            if (comment == null)
            {
                comment = "";
            }
            if (comment.Length > 80)
            {
                comment = comment.Substring(0, (80) - (0));
            }
            writer.Write(comment + "\n");

            // write Counts line
            int upToWhichAtom = 0;

            for (int i = 0; i < isVisible.Length; i++)
            {
                if (isVisible[i])
                {
                    upToWhichAtom++;
                }
            }
            line += formatMDLInt(upToWhichAtom, 3);
            int numberOfBonds = 0;

            if (upToWhichAtom < container.AtomCount)
            {
                for (int i = 0; i < container.getBondCount(); i++)
                {
                    if (isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[1])])
                    {
                        numberOfBonds++;
                    }
                }
            }
            else
            {
                numberOfBonds = container.getBondCount();
            }
            line += formatMDLInt(numberOfBonds, 3);
            line += "  0  0  0  0  0  0  0  0999 V2000\n";
            writer.Write(line);

            // write Atom block
            IAtom[] atoms = container.Atoms;
            for (int f = 0; f < atoms.Length; f++)
            {
                if (isVisible[f])
                {
                    IAtom atom = atoms[f];
                    line = "";
                    if (atom.getPoint3d() != null)
                    {
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.X3d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.Y3d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += (formatMDLFloat((float)atom.Z3d) + " ");
                    }
                    else if (atom.getPoint2d() != null)
                    {
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.X2d);
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLFloat((float)atom.Y2d);
                        line += "    0.0000 ";
                    }
                    else
                    {
                        // if no coordinates available, then output a number
                        // of zeros
                        line += formatMDLFloat((float)0.0);
                        line += formatMDLFloat((float)0.0);
                        line += (formatMDLFloat((float)0.0) + " ");
                    }
                    if (container.getAtomAt(f) is IPseudoAtom)
                    {
                        line += formatMDLString(((IPseudoAtom)container.getAtomAt(f)).Label, 3);
                    }
                    else
                    {
                        line += formatMDLString(container.getAtomAt(f).Symbol, 3);
                    }
                    line += " 0  0  0  0  0  0  0  0  0  0  0  0";
                    writer.Write(line);
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }

            // write Bond block
            IBond[] bonds = container.Bonds;
            for (int g = 0; g < bonds.Length; g++)
            {
                if (upToWhichAtom == container.AtomCount || (isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[1])]))
                {
                    IBond bond = bonds[g];
                    if (bond.getAtoms().Length != 2)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        //logger.warn("Skipping bond with more/less than two atoms: " + bond);
                    }
                    else
                    {
                        if (bond.Stereo == CDKConstants.STEREO_BOND_UP_INV || bond.Stereo == CDKConstants.STEREO_BOND_DOWN_INV)
                        {
                            // turn around atom coding to correct for inv stereo
                            line  = formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3);
                            line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3);
                        }
                        else
                        {
                            line  = formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3);
                            line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3);
                        }
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        line += formatMDLInt((int)bond.Order, 3);
                        line += "  ";
                        switch (bond.Stereo)
                        {
                        case CDKConstants.STEREO_BOND_UP:
                            line += "1";
                            break;

                        case CDKConstants.STEREO_BOND_UP_INV:
                            line += "1";
                            break;

                        case CDKConstants.STEREO_BOND_DOWN:
                            line += "6";
                            break;

                        case CDKConstants.STEREO_BOND_DOWN_INV:
                            line += "6";
                            break;

                        default:
                            line += "0";
                            break;
                        }
                        line += "  0  0  0 ";
                        writer.Write(line);
                        //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                        writer.WriteLine();
                    }
                }
            }

            // write formal atomic charges
            for (int i = 0; i < atoms.Length; i++)
            {
                IAtom atom   = atoms[i];
                int   charge = atom.getFormalCharge();
                if (charge != 0)
                {
                    writer.Write("M  CHG  1 ");
                    writer.Write(formatMDLInt(i + 1, 3));
                    writer.Write(" ");
                    writer.Write(formatMDLInt(charge, 3));
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }

            // write formal isotope information
            for (int i = 0; i < atoms.Length; i++)
            {
                IAtom atom = atoms[i];
                if (!(atom is IPseudoAtom))
                {
                    int atomicMass = atom.MassNumber;
                    int majorMass  = IsotopeFactory.getInstance(atom.Builder).getMajorIsotope(atom.Symbol).MassNumber;
                    if (atomicMass != 0 && atomicMass != majorMass)
                    {
                        writer.Write("M  ISO  1 ");
                        writer.Write(formatMDLInt(i + 1, 3));
                        writer.Write(" ");
                        writer.Write(formatMDLInt(atomicMass, 3));
                        //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                        writer.WriteLine();
                    }
                }
            }

            // close molecule
            writer.Write("M  END");
            //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            writer.WriteLine();
            //write sdfields, if any
            if (sdFields != null)
            {
                //UPGRADE_TODO: Method 'java.util.Map.keySet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilMapkeySet'"
                CSGraphT.SupportClass.SetSupport set_Renamed = new CSGraphT.SupportClass.HashSetSupport(sdFields.Keys);
                System.Collections.IEnumerator   iterator    = set_Renamed.GetEnumerator();
                //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                while (iterator.MoveNext())
                {
                    //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                    System.Object element = iterator.Current;
                    writer.Write("> <" + ((System.String)element) + ">");
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    writer.Write(sdFields[element].ToString());
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                    //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    writer.WriteLine();
                }
            }
            // taking care of the $$$$ signs:
            // we write such a sign at the end of all except the first molecule
            if (moleculeNumber != 1)
            {
                writer.Write("$$$$");
                //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                writer.WriteLine();
            }
            moleculeNumber++;
            writer.Flush();
        }
예제 #58
0
 public void AddServer( string name, int fullPercent, TimeZone tz, IPEndPoint address )
 {
     m_Servers.Add( new ServerInfo( name, fullPercent, tz, address ) );
 }
예제 #59
0
파일: TimeZone.cs 프로젝트: yfakariya/mono
 internal static void ClearCachedData()
 {
     currentTimeZone = null;
 }