当前位置: 首页>>代码示例>>C#>>正文


C# TimeZone.FromServerTime方法代码示例

本文整理汇总了C#中System.TimeZone.FromServerTime方法的典型用法代码示例。如果您正苦于以下问题:C# TimeZone.FromServerTime方法的具体用法?C# TimeZone.FromServerTime怎么用?C# TimeZone.FromServerTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.TimeZone的用法示例。


在下文中一共展示了TimeZone.FromServerTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendDetailViewFields


//.........这里部分代码省略.........
											objDATA_FIELD[i] = SplendidCache.CustomList(arrLIST_NAME[i], Sql.ToString(rdr[arrDATA_FIELD[i]]), ref bCustomCache);
											if ( bCustomCache )
												continue;
											// 02/12/2008   If the list contains XML, then treat as a multi-selection. 
											if ( Sql.ToString(rdr[arrDATA_FIELD[i]]).StartsWith("<?xml") )
											{
												StringBuilder sb = new StringBuilder();
												XmlDocument xml = new XmlDocument();
												xml.LoadXml(Sql.ToString(rdr[arrDATA_FIELD[i]]));
												XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
												foreach ( XmlNode xValue in nlValues )
												{
													if ( sb.Length > 0 )
														sb.Append(", ");
													sb.Append(L10n.Term("." + arrLIST_NAME[i] + ".", xValue.InnerText));
												}
												objDATA_FIELD[i] = sb.ToString();
											}
											else
											{
												objDATA_FIELD[i] = L10n.Term("." + arrLIST_NAME[i] + ".", rdr[arrDATA_FIELD[i]]);
											}
										}
										else
											objDATA_FIELD[i] = String.Empty;
									}
								}
								else if ( !Sql.IsEmptyString(arrDATA_FIELD[i]) )
								{
									if ( rdr != null && rdr[arrDATA_FIELD[i]] != DBNull.Value)
									{
										// 12/05/2005   If the data is a DateTime field, then make sure to perform the timezone conversion. 
										if ( rdr[arrDATA_FIELD[i]].GetType() == Type.GetType("System.DateTime") )
											objDATA_FIELD[i] = T10n.FromServerTime(rdr[arrDATA_FIELD[i]]);
										// 02/16/2010   Add MODULE_TYPE so that we can lookup custom field IDs. 
										// 02/16/2010   Move ToGuid to the function so that it can be captured if invalid. 
										else if ( !Sql.IsEmptyString(sMODULE_TYPE) )
											objDATA_FIELD[i] = Crm.Modules.ItemName(Application, sMODULE_TYPE, rdr[arrDATA_FIELD[i]]);
										else
											objDATA_FIELD[i] = rdr[arrDATA_FIELD[i]];
									}
									else
										objDATA_FIELD[i] = String.Empty;
								}
							}
							if ( rdr != null )
							{
								// 01/09/2006   Allow DATA_FORMAT to be optional.   If missing, write data directly. 
								if ( sDATA_FORMAT == String.Empty )
								{
									for ( int i=0; i < arrDATA_FIELD.Length; i++ )
										arrDATA_FIELD[i] = Sql.ToString(objDATA_FIELD[i]);
									litField.Text = String.Join(" ", arrDATA_FIELD);
								}
								else if ( sDATA_FORMAT == "{0:c}" && C10n != null )
								{
									// 03/30/2007   Convert DetailView currencies on the fly. 
									// 05/05/2007   In an earlier step, we convert NULLs to empty strings. 
									// Attempts to convert to decimal will generate an error: Input string was not in a correct format.
									if ( !(objDATA_FIELD[0] is string) )
									{
										Decimal d = C10n.ToCurrency(Convert.ToDecimal(objDATA_FIELD[0]));
										litField.Text = d.ToString("c");
									}
								}
								else
开发者ID:huamouse,项目名称:Taoqi,代码行数:67,代码来源:SplendidDynamic.cs

示例2: SetEditViewFields


//.........这里部分代码省略.........
							}
						}
					}
				}
				// 04/02/2009   Add support for FCKEditor to the EditView. 
				else if ( String.Compare(sFIELD_TYPE, "HtmlEditor", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 09/18/2011   Upgrade to CKEditor 3.6.2. 
						CKEditorControl txtField = Parent.FindControl(sDATA_FIELD) as CKEditorControl;
						if ( txtField != null )
						{
							try
							{
								txtField.Text = Sql.ToString(rdr[sDATA_FIELD]);
							}
							catch(Exception ex)
							{
								SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
								txtField.Text = ex.Message;
							}
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DatePicker", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						try
						{
						DatePicker ctlDate = Parent.FindControl(sDATA_FIELD) as DatePicker;
							if ( ctlDate != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateTimePicker", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						try
						{
							DateTimePicker ctlDate = Parent.FindControl(sDATA_FIELD) as DateTimePicker;
							if ( ctlDate != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateTimeEdit", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						try
						{
							DateTimeEdit ctlDate = Parent.FindControl(sDATA_FIELD) as DateTimeEdit;
							if ( ctlDate != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
开发者ID:huamouse,项目名称:Taoqi,代码行数:67,代码来源:SplendidDynamic.cs

示例3: ToJson

		// 05/05/2013   We need to convert the date to the user's timezone. 
		private static Dictionary<string, object> ToJson(string sBaseURI, string sModuleName, DataRow dr, TimeZone T10n)
		{
			Dictionary<string, object> d       = new Dictionary<string, object>();
			Dictionary<string, object> results = new Dictionary<string, object>();
			Dictionary<string, object> drow    = new Dictionary<string, object>();
			
			// 06/28/2011   Now that we have switched to using views, the results may not have an ID column. 
			if ( dr.Table.Columns.Contains("ID") )
			{
				Guid gID = Sql.ToGuid(dr["ID"]);
				if ( !Sql.IsEmptyString(sBaseURI) && !Sql.IsEmptyString(sModuleName) )
				{
					Dictionary<string, object> metadata = new Dictionary<string, object>();
					metadata.Add("uri", sBaseURI + "?ModuleName=" + sModuleName + "&ID=" + gID.ToString() + "");
					metadata.Add("type", "Taoqi." + sModuleName);
					if ( dr.Table.Columns.Contains("DATE_MODIFIED_UTC") )
					{
						DateTime dtDATE_MODIFIED_UTC = Sql.ToDateTime(dr["DATE_MODIFIED_UTC"]);
						metadata.Add("etag", gID.ToString() + "." + dtDATE_MODIFIED_UTC.Ticks.ToString() );
					}
					drow.Add("__metadata", metadata);
				}
			}
			
			for (int i = 0; i < dr.Table.Columns.Count; i++)
			{
				if ( dr.Table.Columns[i].DataType.FullName == "System.DateTime" )
				{
					// 05/05/2013   We need to convert the date to the user's timezone. 
					drow.Add(dr.Table.Columns[i].ColumnName, ToJsonDate(T10n.FromServerTime(dr[i])) );
				}
				else
				{
					drow.Add(dr.Table.Columns[i].ColumnName, dr[i]);
				}
			}
			
			results.Add("results", drow);
			d.Add("d", results);
			return d;
		}
开发者ID:huamouse,项目名称:Taoqi,代码行数:42,代码来源:Rest.svc.cs

示例4: AppendEditViewFields


//.........这里部分代码省略.........
						try
						{
							if ( bLayoutMode )
								litField.Text = sDATA_FIELD;
/*
							else if ( sDATA_FIELD.IndexOf(".") >= 0 )
								litField.Text = L10n.Term(sDATA_FIELD);
							else if ( rdr != null )
								litField.Text = Sql.ToString(rdr[sDATA_FIELD]);
*/
							// 10/07/2010   Allow a label to contain multiple data entries. 
							else
							{
								string[] arrDATA_FIELD = sDATA_FIELD.Split(' ');
								object[] objDATA_FIELD = new object[arrDATA_FIELD.Length];
								for ( int i=0 ; i < arrDATA_FIELD.Length; i++ )
								{
									if ( arrDATA_FIELD[i].IndexOf(".") >= 0 )
									{
										objDATA_FIELD[i] = L10n.Term(arrDATA_FIELD[i]);
									}
									else if ( !Sql.IsEmptyString(arrDATA_FIELD[i]) )
									{
										bIsReadable = true;
										if ( SplendidInit.bEnableACLFieldSecurity )
										{
											Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, gASSIGNED_USER_ID);
											bIsReadable  = acl.IsReadable();
										}
										if ( bIsReadable && rdr != null && rdr[arrDATA_FIELD[i]] != DBNull.Value)
										{
											// 12/05/2005   If the data is a DateTime field, then make sure to perform the timezone conversion. 
											if ( rdr[arrDATA_FIELD[i]].GetType() == Type.GetType("System.DateTime") )
												objDATA_FIELD[i] = T10n.FromServerTime(rdr[arrDATA_FIELD[i]]);
											// 02/16/2010   Add MODULE_TYPE so that we can lookup custom field IDs. 
											// 02/16/2010   Move ToGuid to the function so that it can be captured if invalid. 
											else if ( !Sql.IsEmptyString(sMODULE_TYPE) )
												objDATA_FIELD[i] = Crm.Modules.ItemName(Application, sMODULE_TYPE, rdr[arrDATA_FIELD[i]]);
											else
												objDATA_FIELD[i] = rdr[arrDATA_FIELD[i]];
										}
										else
											objDATA_FIELD[i] = String.Empty;
									}
								}
								// 08/28/2012   We do not need the record to display a label. 
								//if ( rdr != null )
								{
									// 10/07/2010   There is a special case where we are show a date and a user name. 
									if ( arrDATA_FIELD.Length == 3 && objDATA_FIELD.Length == 3 && arrDATA_FIELD[1] == ".LBL_BY" && Sql.IsEmptyString(objDATA_FIELD[0]) && Sql.IsEmptyString(objDATA_FIELD[2]) )
										litField.Text = String.Empty;
									else
									// 01/09/2006   Allow DATA_FORMAT to be optional.   If missing, write data directly. 
									if ( sDATA_FORMAT == String.Empty )
									{
										for ( int i=0; i < arrDATA_FIELD.Length; i++ )
											arrDATA_FIELD[i] = Sql.ToString(objDATA_FIELD[i]);
										litField.Text = String.Join(" ", arrDATA_FIELD);
									}
									else if ( sDATA_FORMAT == "{0:c}" && C10n != null )
									{
										// 03/30/2007   Convert DetailView currencies on the fly. 
										// 05/05/2007   In an earlier step, we convert NULLs to empty strings. 
										// Attempts to convert to decimal will generate an error: Input string was not in a correct format.
										if ( !(objDATA_FIELD[0] is string) )
										{
开发者ID:huamouse,项目名称:Taoqi,代码行数:67,代码来源:SplendidDynamic.cs

示例5: RowsToDictionary

		// 05/05/2013   We need to convert the date to the user's timezone. 
		// http://schotime.net/blog/index.php/2008/07/27/dataset-datatable-to-json/
		private static List<Dictionary<string, object>> RowsToDictionary(string sBaseURI, string sModuleName, DataTable dt, TimeZone T10n)
		{
			List<Dictionary<string, object>> objs = new List<Dictionary<string, object>>();
			// 10/11/2012   dt will be null when no results security filter applied. 
			if ( dt != null )
			{
				foreach (DataRow dr in dt.Rows)
				{
					// 06/28/2011   Now that we have switched to using views, the results may not have an ID column. 
					Dictionary<string, object> drow = new Dictionary<string, object>();
					if ( dt.Columns.Contains("ID") )
					{
						Guid gID = Sql.ToGuid(dr["ID"]);
						if ( !Sql.IsEmptyString(sBaseURI) && !Sql.IsEmptyString(sModuleName) )
						{
							Dictionary<string, object> metadata = new Dictionary<string, object>();
							metadata.Add("uri", sBaseURI + "?ModuleName=" + sModuleName + "&ID=" + gID.ToString() + "");
							metadata.Add("type", "Taoqi." + sModuleName);
							if ( dr.Table.Columns.Contains("DATE_MODIFIED_UTC") )
							{
								DateTime dtDATE_MODIFIED_UTC = Sql.ToDateTime(dr["DATE_MODIFIED_UTC"]);
								metadata.Add("etag", gID.ToString() + "." + dtDATE_MODIFIED_UTC.Ticks.ToString() );
							}
							drow.Add("__metadata", metadata);
						}
					}
				
					for (int i = 0; i < dt.Columns.Count; i++)
					{
						if ( dt.Columns[i].DataType.FullName == "System.DateTime" )
						{
							// 05/05/2013   We need to convert the date to the user's timezone. 
							drow.Add(dt.Columns[i].ColumnName, ToJsonDate(T10n.FromServerTime(dr[i])) );
						}
						else
						{
							drow.Add(dt.Columns[i].ColumnName, dr[i]);
						}
					}
					objs.Add(drow);
				}
			}
			return objs;
		}
开发者ID:huamouse,项目名称:Taoqi,代码行数:46,代码来源:Rest.svc.cs


注:本文中的System.TimeZone.FromServerTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。