如何知道用户在sharepoint 2010中创建的记录的时区

时间:2013-11-14 18:13:46

标签: web-services sharepoint-2010

我有一个在sharepoint 2010中的应用程序。实际上应用程序用户在多个位置的该应用程序中工作..如果一个用户在IST时间(UTC + 5:30)工作15天,接下来的10天工作到了美国然后他在CST或EST时区工作......所以我的用户根据他的位置改变了他的时区......但现在问题是......当他去生成他的报告时..这对于日期时间字段没有显示正确.... 如果他正确选择了IST时区,那么所有数据都显示在IST时区... EST和CST doest显示不正确用户也无法隔离他的不同 - 2时区数据......

实际上我已经提供了asmx webservices的报告..请在下面找到我写的代码..

              using System;
          using System.Collections;
          using System.Text;
          using System.Data;
          using System.Data.SqlTypes;
          using Microsoft.SqlServer.Server;
          using System.Security.Principal;
          using System.Net;
          using System.Xml;


          public class SharePointActivities
          {
              [SqlFunction(SystemDataAccess = SystemDataAccessKind.Read, FillRowMethodName = "GetActivitiesItemInfo")]
            public static IEnumerable GetActivitiesItems(SqlString url, SqlString listName, SqlString viewName, SqlString Query)
              {
                  DataTable t = new DataTable();
                  WindowsImpersonationContext ctx = null;

                  WindowsIdentity id = SqlContext.WindowsIdentity;

                  try
                  {
                      ctx = id.Impersonate();

                      WSS.Lists svc = new WSS.Lists();
                      svc.Url = url.ToString();

                      //svc.Credentials = new NetworkCredential("krishna", "google@123", "WKS10953");
                      //Or
                      //svc.Credentials = new System.Net.NetworkCredential("krishna", "google@123", "WKS10953");
                      //Or
                      svc.Credentials = CredentialCache.DefaultNetworkCredentials;
                      //Or
                      //svc.UseDefaultCredentials = true;
                      //svc.PreAuthenticate = true;
                      //Or
                      //oServices.Credentials = new NetworkCredential("krishna", "google@123", "wks10953");

                      //Query
                      XmlDocument xmlDoc = new XmlDocument();
                      XmlNode query = xmlDoc.CreateElement("Query");
                      query.InnerXml = Query.ToString();//"<Where><Gt><FieldRef Name=\"ID\" /><Value Type=\"Counter\">3</Value></Gt></Where>";

                      //ViewFields
                      XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
                      viewFields.InnerXml = "";// "<FieldRef Name=\"Title\" />";

                      //QueryOptions
                      XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
                      queryOptions.InnerXml = "";

                      XmlNode node = svc.GetListItems(listName.ToString(), viewName.ToString(), query, viewFields, "500000", queryOptions, null);
                      XmlTextReader rdr = new XmlTextReader(node.OuterXml,
                                                  XmlNodeType.Element, null);
                      DataSet ds = new DataSet();
                      ds.ReadXml(rdr);
                      t = ds.Tables[1];
                  }
                  finally
                  {
                      if (ctx != null)
                          ctx.Undo();
                  }

                  return t.Rows;
              }

              public static void GetActivitiesItemInfo(
                                  object obj,
                                  out SqlString ID,
                                  out SqlString Title,
                                  out SqlString RecordDate,
                                  out SqlString ClientVertical,
                                  out SqlString Client,
                                  out SqlString StoreUnits,
                                  out SqlString Process,
                                  out SqlString MainActivity,
                                  out SqlString SubActivity,
                                  out SqlString PeriodStartDate,
                                  out SqlString PeriodEndDate,
                                  out SqlString NoOfPeriod,
                                  out SqlString EntryType,
                                  out SqlString StartTime,
                                  out SqlString StopTime,
                                  out SqlString TimeTaken,
                                  //out SqlString VolumeCount,
                                  //out SqlString InputMode,
                                  //out SqlString Category,
                                  out SqlString Remarks)
              {
                  DataRow r = (DataRow)obj;
                  ID = new SqlString(Convert.ToString(r["ows_ID"]));
                  Title = new SqlString(Convert.ToString(r["ows_Title"]));
                  RecordDate = new SqlString(Convert.ToString(r["ows_RecordDate"]));
                  ClientVertical = new SqlString(Convert.ToString(r["ows_ClientVertical"]));
                  Client = new SqlString(Convert.ToString(r["ows_Client"]));
                  StoreUnits = new SqlString(Convert.ToString(r["ows_StoreUnits"]));
                  Process = new SqlString(Convert.ToString(r["ows_Process"]));
                  MainActivity = new SqlString(Convert.ToString(r["ows_MainActivity"]));
                  SubActivity = new SqlString(Convert.ToString(r["ows_SubActivity"]));
                  PeriodStartDate = new SqlString(Convert.ToString(r["ows_PeriodStartDate"]));
                  PeriodEndDate = new SqlString(Convert.ToString(r["ows_PeriodEndDate"]));
                  NoOfPeriod = new SqlString(Convert.ToString(r["ows_NoOfPeriod"]));
                  EntryType = new SqlString(Convert.ToString(r["ows_EntryType"]));
                  StartTime = new SqlString(Convert.ToString(r["ows_StartTime"]));
                  StopTime = new SqlString(Convert.ToString(r["ows_StopTime"]));
                  TimeTaken = new SqlString(Convert.ToString(r["ows_TimeTaken"]));
                  //VolumeCount = new SqlString(Convert.ToString(r["ows_VolumeCount"]));
                  //InputMode = new SqlString(Convert.ToString(r["ows_InputMode"]));
                  //Category = new SqlString(Convert.ToString(r["ows_Category"]));
                  Remarks = new SqlString(Convert.ToString(r["ows_Remarks"]));
              }
          }

在我的报告的代码中从Recorddate字段中获取参数开始日期和结束日期..但是如果用户选择了当前的IST时区..那么CST和EST记录的数据显示前一天不起作用..

所以我可以知道记录创建的时区和记录数据的utc值,以便在每个时区找到...或任何其他解决方案来查找实际日期..

0 个答案:

没有答案