示例#1
0
        private void SetUpDisplayValues(LearnerAssignmentState learnerAssignmentStatus)
        {
            lblTitle.Text       = Server.HtmlEncode(AssignmentProperties.Title);
            lblDescription.Text = SlkUtilities.ClickifyLinks(SlkUtilities.GetCrlfHtmlEncodedText(AssignmentProperties.Description));

            SetUpAssignmentSiteLink();
            SetUpScoreAndGradeDisplayValues(learnerAssignmentStatus);

            SPTimeZone timeZone = SPWeb.RegionalSettings.TimeZone;

            lblStartValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.StartDate));
            if (AssignmentProperties.DueDate.HasValue)
            {
                lblDueValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.DueDate.Value));
            }

            if (LearnerAssignmentProperties.InstructorComments.Length != 0)
            {
                lblCommentsValue.Text = SlkUtilities.GetCrlfHtmlEncodedText(LearnerAssignmentProperties.InstructorComments);
            }
            else
            {
                tgrComments.Visible = false;
            }

            lblStatusValue.Text = Server.HtmlEncode(SlkUtilities.GetLearnerAssignmentState(learnerAssignmentStatus));

            DisplayCustomProperties();
            DisplayMixes();
        }
        public override object ConvertFieldValueToPropertyValue(PropertyInfo propertyInfo, object fieldValue)
        {
            //Время в версионном представлении храниться в Гринвиче
            SPTimeZone timeZone = Web.RegionalSettings.TimeZone;

            // конвертирование даты и времени в локальные:
            return(timeZone.UTCToLocalTime((DateTime)fieldValue));
        }
示例#3
0
        public ChatMessageListResult ChatMessages(int SenderID)
        {
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache");
            ChatMessageListResult result = null;

            try
            {
                if (SPUtility.ValidateFormDigest())
                {
                    IChatMessageRepository repo = new ChatMessageRepository();
                    // get the users timezone
                    SPTimeZone zone = SPContext.Current.Web.RegionalSettings.TimeZone;
                    if (SPContext.Current.Web.CurrentUser.RegionalSettings != null)
                    {
                        SPRegionalSettings rs = SPContext.Current.Web.CurrentUser.RegionalSettings;
                        zone = rs.TimeZone;
                    }
                    result = new ChatMessageListResult()
                    {
                        LastRequested = DateTime.Now.ToString(),
                        ChatMessages  = repo.GetUnReadByUserIDAndSenderID(SPContext.Current.Web.CurrentUser.ID, SenderID)
                                        .Select(m => new ChatMessageServiceView()
                        {
                            ID              = m.ID,
                            Created         = (zone.UTCToLocalTime(m.Created)).ToString(),
                            CreatedDateOnly = (zone.UTCToLocalTime(m.Created).Date).ToShortDateString(),
                            CreatedTimeOnly = (zone.UTCToLocalTime(m.Created)).ToString("HH:mm"),
                            CreatedBy       = m.CreatedBy.Name,
                            Message         = m.Message,
                            Receivers       = m.Receivers.Select(r => new ChatContactServiceView()
                            {
                                ID       = r.ID,
                                Name     = r.Name,
                                Username = r.Username.Split('\\').Last()
                            }).ToArray()
                        }).ToArray()
                    };
                    if (result.ChatMessages.Length > 0)
                    {
                        repo.SetChatMessagesRead(result.ChatMessages.Select(i => i.ID).ToArray());
                    }
                }
                else
                {
                    WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.Unauthorized;
                    WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.UserNotValidated;
                }
            }
            catch (Exception ex)
            {
                Config.WriteException(ex);
                WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.InternalServerError;
                WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.GetMessagesError;
            }
            return(result);
        }
        public ExpandedRosterEvent(RosterEvent item, bool withInit, SPTimeZone timeZone)
        {
            this.m_item      = item;
            this.EventTypeId = this.m_item.EventTypeId;

            if (withInit)
            {
                this.InitNonRecurrenceExpandedRoster(timeZone);
            }
        }
        public void InitNonRecurrenceExpandedRoster(SPTimeZone timeZone)
        {
            bool     isAllDayEvent = this.m_item.GetIsAllDayEvent();
            DateTime sDate         = this.m_item.GetStartDate();
            DateTime eDate         = this.m_item.GetEndDate();

            RecurrenceTimeZoneConverter converter = new RecurrenceTimeZoneConverter(timeZone, timeZone, sDate, eDate);

            this.StartDate  = isAllDayEvent ? sDate : converter.ToLocal(sDate);
            this.EndDate    = isAllDayEvent ? eDate : converter.ToLocal(eDate);
            this.InstanceID = this.m_item.Id.ToString();
        }
示例#6
0
 public static TimeZoneInfo GetZoneInfoById(this SPTimeZoneCollection instance, int id)
 {
     for (int i = 0; i < instance.Count; i++)
     {
         SPTimeZone zone = instance[i];
         if (zone.ID == id)
         {
             //return TimeZoneInfo.FindSystemTimeZoneById(zone.KeyName);
         }
     }
     throw new ArgumentOutOfRangeException("id");
 }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            try
            {
                SetResourceText();
                LoadGradingList();

                if (!pageHasErrors)
                {
                    if (SPWeb.ID != AssignmentProperties.SPWebGuid)
                    {
                        Response.Redirect(SlkUtilities.UrlCombine(SPWeb.Url, Request.Path + "?" + Request.QueryString.ToString()));
                    }

                    AddReactivationCheck();

                    lblTitle.Text       = Server.HtmlEncode(AssignmentProperties.Title);
                    lblDescription.Text = SlkUtilities.ClickifyLinks(Server.HtmlEncode(AssignmentProperties.Description).Replace("\r\n", "<br />\r\n"));

                    if (AssignmentProperties.PointsPossible.HasValue)
                    {
                        lblPointsValue.Text = AssignmentProperties.PointsPossible.Value.ToString(Constants.RoundTrip, NumberFormatInfo);
                    }
                    SPTimeZone timeZone = SPWeb.RegionalSettings.TimeZone;
                    lblStartValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.StartDate));

                    if (AssignmentProperties.DueDate.HasValue)
                    {
                        lblDueValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.DueDate.Value));
                    }

                    tblAutoReturn.Visible = AssignmentProperties.AutoReturn;
                    tblAnswers.Visible    = AssignmentProperties.ShowAnswersToLearners;
                    tgrAutoReturn.Visible = tblAutoReturn.Visible || tblAnswers.Visible;
                }
            }
            catch (ThreadAbortException)
            {
                // make sure this exception isn't caught
                throw;
            }
            catch (Exception ex)
            {
                contentPanel.Visible = false;
                errorBanner.AddException(SlkStore, ex);
            }
        }
示例#8
0
        /// <summary>
        /// 获取两种排行:k=0,当日签到排行;k=1,签到总排行,第一次签到前总排行标记为“-”;
        /// </summary>
        /// <param name="web"></param>
        /// <param name="list"></param>
        /// <param name="userName"></param>
        /// <param name="k"></param>
        /// <param name="lastTime"></param>
        /// <returns></returns>
        public int GetRank(SPWeb web, SPList list, string userName, int k, DateTime lastTime)
        {
            int     rank  = 0;
            SPQuery query = new SPQuery();

            if (k == 0)//本次签到排行
            {
                SPTimeZone timeZone = web.RegionalSettings.TimeZone;
                DateTime   dt1      = lastTime.Date;
                DateTime   dt2      = lastTime.Date.AddDays(1);
                lastTime = timeZone.LocalTimeToUTC(lastTime);
                //dt1= timeZone.LocalTimeToUTC(dt1);
                //dt2= timeZone.LocalTimeToUTC(dt2);
                query.Query = "<Where><And><Geq><FieldRef Name='LastTime'/><Value Type='DateTime' IncludeTimeValue='TRUE'>" + dt1 + "</Value></Geq><Lt><FieldRef Name='LastTime'/><Value Type='DateTime' IncludeTimeValue='TRUE'>" + dt2 + "</Value></Lt></And></Where><OrderBy><FieldRef Name ='LastTime'/></OrderBy>";//查询所有今天的用户签到记录
            }
            else//签到总排行
            {
                query.Query = "<OrderBy><FieldRef Name ='AllScore' Ascending='FALSE'/></OrderBy>";//查询所有今天的用户签到记录
            }
            int i = 0;
            SPListItemCollection listItems = list.GetItems(query);

            if (listItems.Count > 0)
            {
                foreach (SPListItem lItem in listItems)
                {
                    if (lItem["Title"].ToString() == userName)
                    {
                        break;
                    }
                    i++;
                }
            }
            if (i != listItems.Count)
            {
                rank = i;
            }
            return(rank);
        }
        private void GetDiscussions()
        {
            string myul = "<fieldset style='border: 1px dotted #ff4500; padding: 5px;'>";

            myul += "<legend style='text-align:center;background-color: #ff4500; color:#f5fffa;padding:5px'>讨论KPI</legend>";
            myul += "<ul class='activiesUl'>";
            string myli    = "";
            string todays  = "";
            SPSite mysite  = SPContext.Current.Site;
            SPWeb  rootWeb = mysite.RootWeb;
            SPWeb  web     = SPContext.Current.Web;
            SPList spList  = web.Lists.TryGetList("讨论列表");

            if (spList != null)
            {
                string  author = GetAuthor();
                SPQuery qry    = new SPQuery();

                //1、由我发布
                qry.Query = @"<Where><Eq><FieldRef Name = 'Author' /><Value Type = 'Integer'><UserID /></Value></Eq></Where>";
                SPListItemCollection myItems = spList.GetItems(qry);
                myli += "<li>由我发布:" + myItems.Count + "</li>";

                //2、为我点赞
                int likes = 0;
                foreach (SPListItem item in myItems)
                {
                    if (item["LikesCount"] != null)
                    {
                        likes += int.Parse(item["LikesCount"].ToString());
                    }
                }
                myli += "<li>为我点赞:" + likes + "</li>";

                //3、今日更新
                DateTime   dt       = DateTime.Now;
                SPTimeZone timeZone = web.RegionalSettings.TimeZone;
                dt = timeZone.LocalTimeToUTC(dt);
                string dtToday = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(dt.ToString()));
                qry = new SPQuery();
                qry.ViewAttributes = "";
                qry.Query          = "<OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy><Where><Geq><FieldRef Name='Created' /><Value Type='DateTime'>" + dtToday + "</Value></Geq></Where>";//筛选近24小时内发布的记录
                SPListItemCollection todayItems = spList.GetItems(qry);
                myli += "<li>今日更新:" + todayItems.Count + "</li>";

                //4、本周更新
                qry = new SPQuery();
                dt  = dt.AddDays(-7);
                string dtWeek = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(dt.ToString()));
                qry.Query = "<Where><Geq><FieldRef Name = 'Created'/><Value Type = 'DateTime' IncludeTimeValue = 'TRUE'>" + dtWeek + "</Value></Geq></Where>";//筛选近7天内发布的记录
                SPListItemCollection WeekItems = spList.GetItems(qry);
                myli += "<li>本周更新:<span>" + WeekItems.Count + "</span></li>";

                //5、主题总数
                qry       = new SPQuery();
                qry.Query = @"<OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy>";
                SPListItemCollection allItems = spList.GetItems(qry);
                myli += "<li>主题总数:" + allItems.Count + "</li>";
                myul += myli + "</ul>";

                if (todayItems.Count > 0)
                {
                    todays += "<fieldset style='border: 1px dotted #ff4500; padding: 5px;'>";
                    todays += "<legend style='text-align:center;background-color: #ff4500; color:#f5fffa;padding:5px'>今日主题</legend>";

                    todays += "<ul>";
                    foreach (SPListItem todayItem in todayItems)
                    {
                        //string iUrl=todayItem.ServerRedirectedPreviewUrl;
                        //所有赞:myItem["DescendantLikesCount"];主题点赞: myItem["LikesCount"]
                        todays += "<li style='margin-left:10px;padding-bottom:10px;word-break:break-all;word-wrap:break-word;'><a href='" + rootWeb.Url + todayItem["FileRef"] + "' target='_bank'>" + todayItem["Title"] + "</a>";
                        if (todayItem["LikesCount"] != null)
                        {
                            todays += "&nbsp;&nbsp;&nbsp;&nbsp;<img src= '../_layouts/15/images/like.11x11x32.png'title = '赞数目' /> <b>" + todayItem["LikesCount"] + "</b>";
                        }
                        todays += "</li>";
                    }
                    todays += "</ul>";
                    todays += "</fieldset>";
                }
                else
                {
                    todays += "<dl><dt style='color:red;'>今日无主题更新!</dt></dl>";
                }
            }
            discussions.InnerHtml = myul + "</fieldset>";
            mychanges.InnerHtml   = todays;
        }
示例#10
0
        private void ExportHistory(string[] items, string listID)
        {
            SPTimeZone    serverzone = SPContext.Current.Web.RegionalSettings.TimeZone;
            StringBuilder sb         = new StringBuilder();
            SPList        list       = SPContext.Current.Web.Lists[new Guid(listID)];
            bool          isLibrary  = false;

            if (list.BaseType == SPBaseType.DocumentLibrary)
            {
                isLibrary = true;
            }
            HtmlTable versionTable = new HtmlTable();

            versionTable.Border      = 1;
            versionTable.CellPadding = 3;
            versionTable.CellSpacing = 3;
            HtmlTableRow  htmlrow;
            HtmlTableCell htmlcell;

            // Add header row in HTML table
            htmlrow            = new HtmlTableRow();
            htmlcell           = new HtmlTableCell();
            htmlcell.InnerHtml = "Item ID";
            htmlrow.Cells.Add(htmlcell);
            if (isLibrary)
            {
                htmlcell           = new HtmlTableCell();
                htmlcell.InnerHtml = "File Name";
                htmlrow.Cells.Add(htmlcell);
                htmlcell           = new HtmlTableCell();
                htmlcell.InnerHtml = "Comment";
                htmlrow.Cells.Add(htmlcell);
                htmlcell           = new HtmlTableCell();
                htmlcell.InnerHtml = "Size";
                htmlrow.Cells.Add(htmlcell);
            }
            htmlcell           = new HtmlTableCell();
            htmlcell.InnerHtml = "Version No.";
            htmlrow.Cells.Add(htmlcell);
            htmlcell           = new HtmlTableCell();
            htmlcell.InnerHtml = "Modified Date";
            htmlrow.Cells.Add(htmlcell);
            htmlcell           = new HtmlTableCell();
            htmlcell.InnerHtml = "Modified By";
            htmlrow.Cells.Add(htmlcell);

            foreach (SPField field in list.Fields)
            {
                if (field.ShowInVersionHistory)
                {
                    htmlcell           = new HtmlTableCell();
                    htmlcell.InnerHtml = field.Title;
                    htmlrow.Cells.Add(htmlcell);
                }
            }
            versionTable.Rows.Add(htmlrow);
            foreach (string item in items)
            {
                SPListItem listItem = list.GetItemById(Convert.ToInt32(item));
                SPListItemVersionCollection itemVersions = listItem.Versions;
                SPFileVersionCollection     fileVersions = null;
                if (isLibrary && listItem.FileSystemObjectType == SPFileSystemObjectType.File)
                {
                    fileVersions = listItem.File.Versions;
                }
                for (int i = 0; i < itemVersions.Count; i++)
                {
                    SPListItemVersion currentVersion  = itemVersions[i];
                    SPListItemVersion previousVersion = itemVersions.Count > i + 1 ? itemVersions[i + 1] : null;
                    htmlrow = new HtmlTableRow();
                    if (i == 0)
                    {
                        htmlcell           = new HtmlTableCell();
                        htmlcell.RowSpan   = itemVersions.Count;
                        htmlcell.InnerHtml = listItem.ID.ToString();
                        htmlrow.Cells.Add(htmlcell);
                    }
                    if (isLibrary)
                    {
                        if (i == 0)
                        {
                            htmlcell           = new HtmlTableCell();
                            htmlcell.RowSpan   = itemVersions.Count;
                            htmlcell.InnerHtml = listItem.File.Name;
                            htmlrow.Cells.Add(htmlcell);
                        }

                        htmlcell = new HtmlTableCell();
                        HtmlTableCell sizeCell = new HtmlTableCell();
                        if (i == 0 && listItem.FileSystemObjectType == SPFileSystemObjectType.File)
                        {
                            htmlcell.InnerHtml = currentVersion.ListItem.File.CheckInComment;

                            // Implicit conversion from long to double
                            double bytes = currentVersion.ListItem.File.Length;
                            sizeCell.InnerHtml = Convert.ToString(Math.Round((bytes / 1024) / 1024, 2)) + " MB";
                        }
                        else
                        {
                            if (null != fileVersions)
                            {
                                foreach (SPFileVersion fileVersion in fileVersions)
                                {
                                    if (fileVersion.VersionLabel == currentVersion.VersionLabel)
                                    {
                                        htmlcell.InnerHtml = fileVersion.CheckInComment;

                                        // Implicit conversion from long to double
                                        double bytes = fileVersion.Size;
                                        sizeCell.InnerHtml = Convert.ToString(Math.Round((bytes / 1024) / 1024, 2)) + " MB";
                                        break;
                                    }
                                }
                            }
                        }
                        htmlrow.Cells.Add(htmlcell);
                        htmlrow.Cells.Add(sizeCell);
                    }
                    htmlcell           = new HtmlTableCell();
                    htmlcell.InnerHtml = currentVersion.VersionLabel;
                    htmlrow.Cells.Add(htmlcell);

                    htmlcell = new HtmlTableCell();
                    DateTime localDateTime = serverzone.UTCToLocalTime(currentVersion.Created);
                    htmlcell.InnerHtml = localDateTime.ToShortDateString() + " " + localDateTime.ToLongTimeString();
                    htmlrow.Cells.Add(htmlcell);
                    htmlcell           = new HtmlTableCell();
                    htmlcell.InnerHtml = currentVersion.CreatedBy.User.Name;
                    htmlrow.Cells.Add(htmlcell);
                    foreach (SPField field in currentVersion.Fields)
                    {
                        if (field.ShowInVersionHistory)
                        {
                            htmlcell = new HtmlTableCell();
                            htmlcell.Attributes.Add("class", "textmode");
                            if (null != currentVersion[field.StaticName])
                            {
                                if (null == previousVersion)
                                {
                                    htmlcell.InnerHtml = GetFieldValue(field, currentVersion);
                                }
                                else
                                {
                                    if (null != previousVersion[field.StaticName] && currentVersion[field.StaticName].ToString().Equals(previousVersion[field.StaticName].ToString()))
                                    {
                                        htmlcell.InnerHtml = string.Empty;
                                    }

                                    else
                                    {
                                        htmlcell.InnerHtml = GetFieldValue(field, currentVersion);
                                    }
                                }
                            }
                            else
                            {
                                htmlcell.InnerHtml = string.Empty;
                            }
                            htmlrow.Cells.Add(htmlcell);
                        }
                    }
                    versionTable.Rows.Add(htmlrow);
                }
            }

            ExportTableToExcel(versionTable, list.Title);
        }
        private void StatisticList(SPUser logUser)
        {
            string lstNames = WebPartObj.ListName;

            if (lstNames == "")
            {
                kpiDiv.InnerHtml = "尚未指定任何列表名称进行数据统计!";
            }
            else
            {
                string[]  lstName = WebPartObj.ListName.Split(';');
                SPQuery   oQuery;
                SPList    sList;
                int[]     itmCounts = new int[6];
                DataTable datatable = newTable();
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                    {
                        using (SPWeb web = site.AllWebs[SPContext.Current.Web.ID])
                        {
                            string myac  = "";
                            string lName = "";
                            //设置sharepoint时间格式
                            SPTimeZone timeZone = web.RegionalSettings.TimeZone;
                            string listsHtml    = "<fieldset style='border: 1px dotted #ff4500; padding: 5px;'><legend style='text-align:center;background-color: #ff4500; color:#f5fffa;padding:5px'>活动量化明细表</legend><table class='mytable'>";
                            listsHtml          += "<tr><th rowspan='2'>KPI</th><th rowspan='2'>由我发布</th><th colspan='2'>今日更新</th><th colspan='2'>本周更新</th><th rowspan='2'>站内总数</th></tr>";
                            listsHtml          += "<tr><td>本人</td><td>本站</td><td>本人</td><td>本站</td></tr>";
                            itmCounts           = NewsCount;//微博
                            listsHtml          += "<tr>";
                            listsHtml          += "<th><a href='" + web.Url + "/newsfeed.aspx' target='_blank'>微 博</a></th>";
                            listsHtml          += "<td>" + itmCounts[0].ToString() + "</td>";
                            listsHtml          += "<td>" + itmCounts[2].ToString() + "</td>";
                            listsHtml          += "<td>" + itmCounts[3].ToString() + "</td>";
                            listsHtml          += "<td>" + itmCounts[4].ToString() + "</td>";
                            listsHtml          += "<td>" + itmCounts[5].ToString() + "</td>";
                            listsHtml          += "<td>" + itmCounts[1].ToString() + "</td>";
                            listsHtml          += "</tr>";
                            datatable.Rows.Add("微 博", itmCounts[0], itmCounts[1]);
                            if (itmCounts[4] == 0)
                            {
                                if (myac != "")
                                {
                                    myac += "、";
                                }
                                myac += "“<b><a href='" + SPContext.Current.Web.Url + "/newsfeed.aspx' target='_blank'>微 博</a></b>”";
                            }

                            foreach (string mList in lstName)
                            {
                                try
                                {
                                    if (mList == "Posts" && WebPartObj.SubWebUrl != "")//统计备忘录
                                    {
                                        SPWeb subWeb = web.Webs[WebPartObj.SubWebUrl];
                                        sList        = subWeb.Lists.TryGetList(mList);
                                    }
                                    else
                                    {
                                        sList = web.Lists.TryGetList(mList);
                                    }
                                    lName = "<a href='" + sList.DefaultViewUrl + "' target='_blank'>" + mList + "</a>";


                                    if (mList == "Posts")
                                    {
                                        lName = "<a href='" + sList.DefaultViewUrl + "' target='_blank'>备忘录</a>";
                                    }

                                    if (mList == "讨论列表")
                                    {
                                        lName = "<a href='" + sList.DefaultViewUrl + "' target='_blank'>讨 论</a>";
                                    }
                                    if (mList == "文档")
                                    {
                                        lName = "<a href='" + sList.DefaultViewUrl + "' target='_blank'>文 档</a>";
                                    }

                                    oQuery = new SPQuery();
                                    oQuery.ViewAttributes         = "Scope='RecursiveAll'";
                                    oQuery.Query                  = "<Where><Eq><FieldRef Name='Author'/><Value Type='Text'>" + logUser.Name + "</Value></Eq></Where>";
                                    SPListItemCollection lstItems = sList.GetItems(oQuery);
                                    itmCounts[0]                  = lstItems.Count;  //个人
                                    itmCounts[1]                  = sList.ItemCount; //全部

                                    /***********今日更新******************/
                                    oQuery = new SPQuery();
                                    DateTime currentDate          = DateTime.Now;
                                    DateTime yesterdayDate        = currentDate.AddDays(-1);
                                    DateTime yesterdayUTCDate     = timeZone.LocalTimeToUTC(yesterdayDate);
                                    string yesterdayUTCDateString = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(yesterdayUTCDate.ToString()));
                                    oQuery.ViewAttributes         = "Scope='RecursiveAll'";
                                    oQuery.Query = "<Where><And><Eq><FieldRef Name='Author'/><Value Type='Text'>" + logUser.Name + "</Value></Eq><Geq><FieldRef Name='Created'/><Value Type='DateTime'>" + yesterdayUTCDateString + "</Value></Geq></And></Where>";
                                    lstItems     = sList.GetItems(oQuery);
                                    itmCounts[2] = lstItems.Count;//个人当日更新

                                    oQuery = new SPQuery();
                                    oQuery.ViewAttributes = "Scope='RecursiveAll'";
                                    oQuery.Query          = "<Where><Geq><FieldRef Name='Created'/><Value Type='DateTime'>" + yesterdayUTCDateString + "</Value></Geq></Where>";
                                    lstItems     = sList.GetItems(oQuery);
                                    itmCounts[3] = lstItems.Count;//站内当日更新

                                    /***********本周更新******************/
                                    DateTime lastWeekDate        = currentDate.AddDays(-7);
                                    DateTime lastWeekUTCDate     = timeZone.LocalTimeToUTC(lastWeekDate);
                                    string lastWeekUTCDateString = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(lastWeekUTCDate.ToString()));
                                    oQuery = new SPQuery();
                                    oQuery.ViewAttributes = "Scope='RecursiveAll'";
                                    oQuery.Query          = "<Where><And><Eq><FieldRef Name='Author'/><Value Type='Text'>" + logUser.Name + "</Value></Eq><Geq><FieldRef Name='Created'/><Value Type='DateTime'>" + lastWeekUTCDateString + "</Value></Geq></And></Where>";
                                    lstItems     = sList.GetItems(oQuery);
                                    itmCounts[4] = lstItems.Count;//个人本周更新

                                    oQuery = new SPQuery();
                                    oQuery.ViewAttributes = "Scope='RecursiveAll'";
                                    oQuery.Query          = "<Where><Geq><FieldRef Name='Created'/><Value Type='DateTime'>" + lastWeekUTCDateString + "</Value></Geq></Where>";
                                    lstItems     = sList.GetItems(oQuery);
                                    itmCounts[5] = lstItems.Count;//站内本周更新

                                    listsHtml += "<tr>";
                                    listsHtml += "<th>" + lName + "</th>";
                                    listsHtml += "<td>" + itmCounts[0].ToString() + "</td>";
                                    listsHtml += "<td>" + itmCounts[2].ToString() + "</td>";
                                    listsHtml += "<td>" + itmCounts[3].ToString() + "</td>";
                                    listsHtml += "<td>" + itmCounts[4].ToString() + "</td>";
                                    listsHtml += "<td>" + itmCounts[5].ToString() + "</td>";
                                    listsHtml += "<td>" + itmCounts[1].ToString() + "</td>";
                                    listsHtml += "</tr>";
                                    datatable.Rows.Add(lName, itmCounts[0], itmCounts[1]);
                                    if (itmCounts[4] == 0)
                                    {
                                        if (myac != "")
                                        {
                                            myac += "、";
                                        }
                                        myac += "“<b>" + lName + "</b>”";
                                    }
                                }
                                catch
                                { }
                            }

                            listsHtml += "</table></fieldset>";

                            if (myac != "")
                            {
                                listsHtml = "<div class='kpidiv'>亲,你好。<br/>系统发现你近一周都没有参与发布过:" + myac + ",<br/>快快参与站内活动赢取积分赶超其它小伙伴吧!</div>" + listsHtml;
                            }
                            kpiDiv.InnerHtml = listsHtml;
                            if (datatable.Rows.Count > 0)
                            {
                            }
                        }
                    }
                });
            }
        }
示例#12
0
 private static SPTimeZone GetTimeZone(SPItem item, SPTimeZone localTZ)
 {
     return(localTZ);
 }
示例#13
0
        private static IList <SPItem> ExpandSeriesItem(SPItem masterItem, string beginFieldName, string endFieldName, DateTime localTimeRangeBegin, DateTime localTimeRangeEnd, SPTimeZone localTZ)
        {
            DateTime       time;
            DateTime       time2;
            RecurrenceRule rule                   = new RecurrenceRule(SafeFieldAccessor.GetStringFieldValue(masterItem, "RecurrenceData"));
            bool           boolFieldValue         = SafeFieldAccessor.GetBoolFieldValue(masterItem, "fAllDayEvent");
            SPTimeZone     timeZone               = GetTimeZone(masterItem, localTZ);
            DateTime       dateTimeFieldValue     = SafeFieldAccessor.GetDateTimeFieldValue(masterItem, beginFieldName);
            DateTime       rangeEnd               = SafeFieldAccessor.GetDateTimeFieldValue(masterItem, endFieldName);
            RecurrenceTimeZoneConverter converter = new RecurrenceTimeZoneConverter(timeZone, localTZ, dateTimeFieldValue, rangeEnd);

            if (boolFieldValue)
            {
                time  = dateTimeFieldValue;
                time2 = rangeEnd;
            }
            else
            {
                time  = converter.ToOriginal(dateTimeFieldValue);
                time2 = converter.ToOriginal(rangeEnd);
            }
            TimeSpan itemLength = CalculateItemLength(time, time2);
            DateTime rangeBegin = converter.ToOriginal(localTimeRangeBegin);
            DateTime time6      = converter.ToOriginal(localTimeRangeEnd);

            if (boolFieldValue)
            {
                rangeBegin = localTimeRangeBegin;
                time6      = localTimeRangeEnd;
            }
            DateTime time7 = new DateTime(dateTimeFieldValue.Ticks) + itemLength;

            if (time7.Day != dateTimeFieldValue.Day)
            {
                rangeBegin = rangeBegin.AddDays(-1.0);
            }
            rangeBegin = ComputeExpandBegin(rangeBegin, time, rule);
            time6      = ComputeExpandEnd(time6, time, time2, rule, timeZone);
            List <SPItem> list = new List <SPItem>();
            DateTime      date = rangeBegin.Date;

            while (true)
            {
                DateTime itemBegin = ComputeTargetBegin(date, time, rule);
                DateTime time10    = ComputeTargetEnd(itemBegin, itemLength);
                TimeSpan span2     = (TimeSpan)(time10 - itemBegin);
                bool     flag2     = span2.Ticks == 0L;
                if ((time6 < itemBegin) || ((time6 == itemBegin) && !flag2))
                {
                    return(list);
                }
                if (0x3e7 <= list.Count)
                {
                    return(list);
                }
                if (((rule.Type == RecurrenceRule.RecurrenceType.Daily) && rule.IsWeekday) && ((itemBegin.DayOfWeek == DayOfWeek.Saturday) || (itemBegin.DayOfWeek == DayOfWeek.Sunday)))
                {
                    date = IncrementDate(date, rule);
                }
                else if ((rule.Type == RecurrenceRule.RecurrenceType.Weekly) && !rule.DaysOfWeek.Contains(itemBegin.DayOfWeek))
                {
                    date = IncrementDate(date, rule);
                }
                else
                {
                    ExpandedCalendarItem item = null;
                    if ((rangeBegin < time10) || ((rangeBegin == time10) && (itemLength.Ticks == 0L)))
                    {
                        item = new ExpandedCalendarItem(masterItem);
                        if (boolFieldValue)
                        {
                            item[beginFieldName] = itemBegin;
                            item[endFieldName]   = time10;
                        }
                        else
                        {
                            item[beginFieldName] = converter.ToLocal(itemBegin);
                            item[endFieldName]   = converter.ToLocal(time10);
                        }
                        string str2 = GenerateRecurrenceItemId(SafeFieldAccessor.GetIntegerFieldValue(masterItem, "ID"), (DateTime)item[beginFieldName], localTZ, boolFieldValue);
                        item["ID"] = str2;
                        if (0x3e7 > list.Count)
                        {
                            list.Add(item);
                        }
                    }
                    date = IncrementDate(date, rule);
                }
            }
        }
示例#14
0
 // Methods
 private static void ApplyRelatedItems(SPItem masterItem, IList <SPItem> expanded, IEnumerable <SPItem> related, IEnumerable <int> excludeExceptionIds, string beginFieldName, string endFieldName, SPTimeZone localTimeZone)
 {
     foreach (SPItem item in related)
     {
         int      integerFieldValue  = SafeFieldAccessor.GetIntegerFieldValue(masterItem, "ID");
         DateTime dateTimeFieldValue = SafeFieldAccessor.GetDateTimeFieldValue(item, "RecurrenceID");
         string   id    = GenerateRecurrenceItemId(integerFieldValue, dateTimeFieldValue, localTimeZone, false);
         SPItem   item2 = FindItemById(expanded, id);
         if (item2 != null)
         {
             expanded.Remove(item2);
         }
         int eventType = GetEventType(item);
         if ((eventType == 4) && ((excludeExceptionIds == null) || !excludeExceptionIds.Contains <int>(item.ID)))
         {
             DateTime start = SafeFieldAccessor.GetDateTimeFieldValue(item, beginFieldName);
             DateTime end   = SafeFieldAccessor.GetDateTimeFieldValue(item, endFieldName);
             item2 = FindItemByBeginEnd(expanded, beginFieldName, endFieldName, start, end);
             if (item2 != null)
             {
                 if (GetEventType(item2) == 4)
                 {
                     continue;
                 }
                 expanded.Remove(item2);
             }
             SPItem item3 = new ExpandedCalendarItem(item);
             string str2  = GenerateExceptionItemId(item.ID, integerFieldValue, eventType);
             item3["ID"] = str2;
             expanded.Add(item3);
         }
     }
 }
示例#15
0
        public RenderedCell[] RenderQueryRowCells(DataRow dataRow, int[,] columnMap, SPWebResolver spWebResolver, SPTimeZone timeZone)
        {
            if (dataRow == null)
            {
                throw new ArgumentNullException("dataRow");
            }
            if (columnMap == null)
            {
                throw new ArgumentNullException("columnMap");
            }

            RenderedCell[] renderedCells     = new RenderedCell[m_columnDefinitions.Count];
            int            iColumnDefinition = 0;

            foreach (ColumnDefinition columnDefinition in m_columnDefinitions)
            {
                // set <cellValue> to the rendered value to be displayed in this cell (i.e. this
                // column of this row); set <cellSortKey> to the cell's sort key value (i.e. the value
                // to use for sorting); set <cellId> to the LearningStoreItemIdentifier associated
                // with this cell (null if none); set <cellToolTip> to the tooltip associated with
                // this cell (null if none)
                object cellValue, cellSortKey;
                LearningStoreItemIdentifier cellId;
                string cellToolTip;
                string text, textNotRounded;
                Guid?  cellSiteGuid = null, cellWebGuid = null;
                string cellWebUrl   = null;
                bool   renderAsLink = false;
                switch (columnDefinition.RenderAs)
                {
                case ColumnRenderAs.Default:

                    cellValue = dataRow[columnMap[iColumnDefinition, 0]];
                    if (cellValue is DBNull)
                    {
                        cellValue   = (columnDefinition.NullDisplayString ?? String.Empty);
                        cellSortKey = String.Empty;
                        cellId      = null;
                        cellToolTip = null;
                    }
                    else
                    {
                        if ((cellId = cellValue as LearningStoreItemIdentifier) != null)
                        {
                            cellValue = cellSortKey = cellId.GetKey();
                        }
                        else
                        {
                            cellSortKey = cellValue;
                        }
                        if (columnDefinition.ToolTipFormat != null)
                        {
                            cellToolTip = culture.Format(columnDefinition.ToolTipFormat, cellValue);
                        }
                        else
                        {
                            cellToolTip = null;
                        }
                        if (columnDefinition.CellFormat != null)
                        {
                            text        = FormatValue(cellValue, columnDefinition.CellFormat);
                            cellValue   = text;
                            cellSortKey = text.ToLower(culture.Culture);
                        }
                    }
                    break;

                case ColumnRenderAs.UtcAsLocalDateTime:

                    cellValue = dataRow[columnMap[iColumnDefinition, 0]];
                    if (cellValue is DBNull)
                    {
                        cellValue   = (columnDefinition.NullDisplayString ?? String.Empty);
                        cellSortKey = String.Empty;
                        cellId      = null;
                        cellToolTip = null;
                    }
                    else
                    {
                        DateTime dateTime;
                        try
                        {
                            dateTime = timeZone.UTCToLocalTime((DateTime)cellValue);
                        }
                        catch (InvalidCastException)
                        {
                            throw new SlkSettingsException(columnDefinition.LineNumber, culture.Resources.SlkUtilitiesViewColumnNameNonDateTime);
                        }
                        cellValue = cellSortKey = dateTime;
                        if (columnDefinition.CellFormat != null)
                        {
                            cellValue = FormatValue(dateTime, columnDefinition.CellFormat);
                        }
                        cellId = null;
                        if (columnDefinition.ToolTipFormat != null)
                        {
                            cellToolTip = culture.Format(columnDefinition.ToolTipFormat, dateTime);
                        }
                        else
                        {
                            cellToolTip = null;
                        }
                    }
                    break;

                case ColumnRenderAs.SPWebTitle:
                case ColumnRenderAs.SPWebName:

                    renderAsLink = (columnDefinition.RenderAs == ColumnRenderAs.SPWebName);
                    cellWebGuid  = GetQueryCell <Guid>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0);
                    cellSiteGuid = GetQueryCell <Guid>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1);
                    if (spWebResolver != null)
                    {
                        spWebResolver(cellWebGuid.Value, cellSiteGuid.Value, out text, out cellWebUrl);
                    }
                    else
                    {
                        text = null;
                    }

                    if (text == null)
                    {
                        text = cellWebGuid.Value.ToString();
                    }

                    cellValue   = text;
                    cellSortKey = text.ToLower(culture.Culture);
                    cellId      = null;
                    if (columnDefinition.ToolTipFormat != null)
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, text);
                    }
                    else
                    {
                        cellToolTip = null;
                    }

                    break;

                case ColumnRenderAs.Link:

                    text        = GetQueryCell <string>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0);
                    cellId      = GetQueryCell <LearningStoreItemIdentifier>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1);
                    cellValue   = text;
                    cellSortKey = text.ToLower(culture.Culture);
                    if (columnDefinition.ToolTipFormat != null)
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, text);
                    }
                    else
                    {
                        cellToolTip = null;
                    }
                    break;

                case ColumnRenderAs.LearnerAssignmentStatus:

                    bool unused;
                    LearnerAssignmentState learnerAssignmentState =
                        (LearnerAssignmentState)GetQueryCell <int>(dataRow, columnMap,
                                                                   columnDefinition, iColumnDefinition, 0, out unused);
                    text        = SlkUtilities.GetLearnerAssignmentState(learnerAssignmentState);
                    cellValue   = text;
                    cellSortKey = learnerAssignmentState;
                    cellId      = null;
                    if (columnDefinition.ToolTipFormat != null)
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, text);
                    }
                    else
                    {
                        cellToolTip = null;
                    }
                    break;

                case ColumnRenderAs.IfEmpty:
                    cellToolTip = null;
                    bool   noColumn1;
                    object column1 = GetQueryCell <object>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0, out noColumn1);
                    bool   noColumn2;
                    object column2 = GetQueryCell <object>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1, out noColumn2);

                    if (noColumn1 == false)
                    {
                        cellValue = column1;
                        if (noColumn2 == false)
                        {
                            if (columnDefinition.ToolTipFormat != null)
                            {
                                cellToolTip = culture.Format("{0} ({1})", cellValue, column2);
                            }
                        }
                    }
                    else if (noColumn2)
                    {
                        cellValue = culture.Resources.SlkUtilitiesPointsNoValue;
                    }
                    else
                    {
                        cellValue = column2;
                    }

                    cellId      = null;
                    cellSortKey = cellValue.ToString().ToLower(culture.Culture);
                    if (string.IsNullOrEmpty(cellToolTip))
                    {
                        cellToolTip = cellValue.ToString();
                    }

                    break;

                case ColumnRenderAs.ScoreAndPossible:

                    // get <finalPoints> and <pointsPossible> from <dataRow>
                    bool  noFinalPoints;
                    float finalPoints = GetQueryCell <float>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0, out noFinalPoints);
                    bool  noPointsPossible;
                    float pointsPossible = GetQueryCell <float>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1, out noPointsPossible);

                    // round to two decimal places
                    float finalPointsRounded    = (float)Math.Round(finalPoints, 2);
                    float pointsPossibleRounded = (float)Math.Round(pointsPossible, 2);

                    // format the result
                    if (!noFinalPoints)
                    {
                        // FinalPoints is not NULL
                        text           = culture.Format(culture.Resources.SlkUtilitiesPointsValue, FormatValue(finalPointsRounded, columnDefinition.CellFormat));
                        textNotRounded = culture.Format(culture.Resources.SlkUtilitiesPointsValue, finalPoints);
                    }
                    else
                    {
                        // FinalPoints is NULL
                        text           = culture.Resources.SlkUtilitiesPointsNoValue;
                        textNotRounded = culture.Resources.SlkUtilitiesPointsNoValue;
                    }
                    if (!noPointsPossible)
                    {
                        // PointsPossible is not NULL
                        text = culture.Format(culture.Resources.SlkUtilitiesPointsPossible, text,
                                              FormatValue(pointsPossibleRounded, columnDefinition.CellFormat));
                        textNotRounded = culture.Format(culture.Resources.SlkUtilitiesPointsPossible, textNotRounded,
                                                        pointsPossible);
                    }
                    cellValue = text;
                    cellId    = null;
                    if ((columnDefinition.ToolTipFormat != null) &&
                        (!noFinalPoints || !noPointsPossible))
                    {
                        cellToolTip = culture.Format(columnDefinition.ToolTipFormat, textNotRounded);
                    }
                    else
                    {
                        cellToolTip = null;
                    }

                    // set <cellSortKey>
                    if (!noFinalPoints)
                    {
                        if (!noPointsPossible)
                        {
                            cellSortKey = ((double)finalPoints) / pointsPossible;
                        }
                        else
                        {
                            cellSortKey = (double)finalPoints;
                        }
                    }
                    else
                    {
                        cellSortKey = (double)0;
                    }
                    break;

                case ColumnRenderAs.Submitted:

                    int countCompletedOrFinal = GetQueryCell <int>(dataRow, columnMap, columnDefinition, iColumnDefinition, 0);
                    int countTotal            = GetQueryCell <int>(dataRow, columnMap, columnDefinition, iColumnDefinition, 1);
                    text        = culture.Format(culture.Resources.SlkUtilitiesSubmitted, countCompletedOrFinal, countTotal);
                    cellValue   = text;
                    cellId      = null;
                    cellToolTip = null;
                    cellSortKey = countCompletedOrFinal;
                    break;

                default:

                    throw new SlkSettingsException(columnDefinition.LineNumber, culture.Resources.SlkUtilitiesUnknownRenderAsValue, columnDefinition.RenderAs);
                }

                // add to <renderedCells>
                RenderedCell renderedCell;
                if (cellSiteGuid != null)
                {
                    renderedCell = new WebNameRenderedCell(cellValue, cellSortKey, cellId, cellToolTip, columnDefinition.Wrap, cellSiteGuid.Value, cellWebGuid.Value, cellWebUrl);
                    ((WebNameRenderedCell)renderedCell).RenderAsLink = renderAsLink;
                }
                else
                {
                    renderedCell = new RenderedCell(cellValue, cellSortKey, cellId, cellToolTip, columnDefinition.Wrap);
                }
                renderedCells[iColumnDefinition++] = renderedCell;
            }

            return(renderedCells);
        }
示例#16
0
        private static DateTime ComputeExpandEnd(DateTime rangeEnd, DateTime orgTimeItemBegin, DateTime orgTimeItemEnd, RecurrenceRule rule, SPTimeZone orgTZ)
        {
            DateTime time;
            DateTime time2 = new DateTime(orgTimeItemBegin.Ticks);
            DateTime time3 = new DateTime(orgTimeItemEnd.Ticks);

            if (rule.HasWindowEnd)
            {
                time3 = orgTZ.UTCToLocalTime(rule.WindowEnd).Date.AddDays(1.0);
            }
            if (time3 < rangeEnd)
            {
                time = new DateTime(time3.Ticks);
            }
            else
            {
                time = new DateTime(rangeEnd.Ticks);
            }
            int repeatInstances = rule.RepeatInstances;

            if (((repeatInstances == 0) && !rule.HasWindowEnd) || (repeatInstances > 0x3e7))
            {
                repeatInstances = 0x3e7;
            }
            if (repeatInstances > 0)
            {
                int      num2 = 0;
                DateTime date = time2.Date;
                while (date < rangeEnd)
                {
                    DateTime time5 = ComputeTargetBegin(date, orgTimeItemBegin, rule);
                    if (((rule.Type == RecurrenceRule.RecurrenceType.Daily) && rule.IsWeekday) && ((time5.DayOfWeek == DayOfWeek.Saturday) || (time5.DayOfWeek == DayOfWeek.Sunday)))
                    {
                        date = IncrementDate(date, rule);
                    }
                    else if ((rule.Type == RecurrenceRule.RecurrenceType.Weekly) && !rule.DaysOfWeek.Contains(time5.DayOfWeek))
                    {
                        date = IncrementDate(date, rule);
                    }
                    else
                    {
                        if (time5 >= time2)
                        {
                            num2++;
                            if (num2 == repeatInstances)
                            {
                                return(time5.AddDays(1.0).Date);
                            }
                        }
                        date = IncrementDate(date, rule);
                    }
                }
            }
            return(time);
        }
        private static IList <ExpandedRosterEvent> ExpandSeriesItem(RosterEvent masterItem, string beginFieldName, string endFieldName, DateTime localTimeRangeBegin, DateTime localTimeRangeEnd, SPTimeZone localTZ)
        {
            DateTime       time;
            DateTime       time2;
            RecurrenceRule rule               = new RecurrenceRule(masterItem.GetRecurrence());
            bool           isAllDayEvent      = masterItem.GetIsAllDayEvent();
            SPTimeZone     timeZone           = GetTimeZone(masterItem, localTZ);
            DateTime       dateTimeFieldValue = masterItem.GetStartDate();
            DateTime       rangeEnd           = masterItem.GetEndDate();

            RecurrenceTimeZoneConverter converter = new RecurrenceTimeZoneConverter(timeZone, localTZ, dateTimeFieldValue, rangeEnd);

            if (isAllDayEvent)
            {
                time  = dateTimeFieldValue;
                time2 = rangeEnd;
            }
            else
            {
                time  = converter.ToOriginal(dateTimeFieldValue);
                time2 = converter.ToOriginal(rangeEnd);
            }
            TimeSpan itemLength = CalculateItemLength(time, time2);
            DateTime rangeBegin = converter.ToOriginal(localTimeRangeBegin);
            DateTime time6      = converter.ToOriginal(localTimeRangeEnd);

            if (isAllDayEvent)
            {
                rangeBegin = localTimeRangeBegin;
                time6      = localTimeRangeEnd;
            }
            DateTime time7 = new DateTime(dateTimeFieldValue.Ticks) + itemLength;

            if (time7.Day != dateTimeFieldValue.Day)
            {
                rangeBegin = rangeBegin.AddDays(-1.0);
            }
            rangeBegin = ComputeExpandBegin(rangeBegin, time, rule);
            time6      = ComputeExpandEnd(time6, time, time2, rule, timeZone);

            List <ExpandedRosterEvent> list = new List <ExpandedRosterEvent>();
            DateTime date = rangeBegin.Date;

            while (true)
            {
                DateTime itemBegin = ComputeTargetBegin(date, time, rule);
                DateTime time10    = ComputeTargetEnd(itemBegin, itemLength);
                TimeSpan span2     = (TimeSpan)(time10 - itemBegin);
                bool     flag2     = span2.Ticks == 0L;
                if ((time6 < itemBegin) || ((time6 == itemBegin) && !flag2))
                {
                    return(list);
                }
                if (999 <= list.Count)
                {
                    return(list);
                }
                if (((rule.Type == RecurrenceRule.RecurrenceType.Daily) && rule.IsWeekday) && ((itemBegin.DayOfWeek == DayOfWeek.Saturday) || (itemBegin.DayOfWeek == DayOfWeek.Sunday)))
                {
                    date = IncrementDate(date, rule);
                }
                else if ((rule.Type == RecurrenceRule.RecurrenceType.Weekly) && !rule.DaysOfWeek.Contains(itemBegin.DayOfWeek))
                {
                    date = IncrementDate(date, rule);
                }
                else
                {
                    ExpandedRosterEvent item = null;
                    if ((rangeBegin < time10) || ((rangeBegin == time10) && (itemLength.Ticks == 0L)))
                    {
                        item = new ExpandedRosterEvent(masterItem, false, null);
                        if (isAllDayEvent)
                        {
                            item.StartDate = itemBegin;
                            item.EndDate   = time10;
                        }
                        else
                        {
                            item.StartDate = converter.ToLocal(itemBegin);
                            item.EndDate   = converter.ToLocal(time10);
                        }
                        //item["ID"] = str2;
                        item.InstanceID = GenerateRecurrenceItemId(masterItem.Id, item.StartDate, localTZ, isAllDayEvent);
                        if (999 > list.Count)
                        {
                            list.Add(item);
                        }
                    }
                    date = IncrementDate(date, rule);
                }
            }
        }
示例#18
0
        internal static IEnumerable <SPItem> Expand(IEnumerable <SPItem> items, IEnumerable <int> excludeExceptionIds, DateTime rangeBegin, DateTime rangeEnd, string beginFieldName, string endFieldName, SPTimeZone timeZone)
        {
            List <SPItem>                     list        = new List <SPItem>();
            Dictionary <int, SPItem>          dictionary  = new Dictionary <int, SPItem>();
            Dictionary <int, IList <SPItem> > dictionary2 = new Dictionary <int, IList <SPItem> >();

            foreach (SPItem item in items)
            {
                if (SafeFieldAccessor.GetBoolFieldValue(item, "fRecurrence") && (GetEventType(item) == 1))
                {
                    int integerFieldValue = SafeFieldAccessor.GetIntegerFieldValue(item, "ID");
                    if (!dictionary2.ContainsKey(integerFieldValue))
                    {
                        dictionary2.Add(integerFieldValue, new List <SPItem>());
                        dictionary.Add(integerFieldValue, item);
                    }
                }
            }
            foreach (SPItem item2 in items)
            {
                int masterId = GetMasterId(item2);
                if (masterId != item2.ID)
                {
                    if (!dictionary.ContainsKey(masterId))
                    {
                        switch (GetEventType(item2))
                        {
                        case 3:
                        {
                            continue;
                        }

                        case 4:
                        {
                            SPItem     item3 = item2;
                            SPListItem item4 = item2 as SPListItem;
                            if (item4 != null)
                            {
                                item3       = new ExpandedCalendarItem(item4);
                                item3["ID"] = item4.RecurrenceID;
                            }
                            list.Add(item3);
                            continue;
                        }
                        }
                        list.Add(item2);
                    }
                    else
                    {
                        dictionary2[masterId].Add(item2);
                    }
                }
            }
            foreach (int num3 in dictionary.Keys)
            {
                IList <SPItem> expanded = ExpandSeriesItem(dictionary[num3], beginFieldName, endFieldName, rangeBegin, rangeEnd, timeZone);
                ApplyRelatedItems(dictionary[num3], expanded, dictionary2[num3], excludeExceptionIds, beginFieldName, endFieldName, timeZone);
                list.AddRange(expanded);
            }
            return(list);
        }
        internal static IEnumerable <ExpandedRosterEvent> Expand(IEnumerable <RosterEvent> items, IEnumerable <int> excludeExceptionIds, DateTime rangeBegin, DateTime rangeEnd, string beginFieldName, string endFieldName, SPTimeZone timeZone)
        {
            List <ExpandedRosterEvent>              list        = new List <ExpandedRosterEvent>();
            Dictionary <Guid, RosterEvent>          dictionary  = new Dictionary <Guid, RosterEvent>();
            Dictionary <Guid, IList <RosterEvent> > dictionary2 = new Dictionary <Guid, IList <RosterEvent> >();

            foreach (RosterEvent item in items)
            {
                if (item.GetIsRecurrence() && item.GetShPEventType() == 1)
                {
                    if (!dictionary2.ContainsKey(item.Id))
                    {
                        dictionary2.Add(item.Id, new List <RosterEvent>());
                        dictionary.Add(item.Id, item);
                    }
                }
                else
                {
                    // non-recurrence event
                    var ere = new ExpandedRosterEvent(item, true, timeZone);
                    list.Add(ere);
                }
            }

            foreach (Guid itmId in dictionary.Keys)
            {
                IList <ExpandedRosterEvent> expanded = ExpandSeriesItem(dictionary[itmId], beginFieldName, endFieldName, rangeBegin, rangeEnd, timeZone);
                //ApplyRelatedItems(dictionary[itmId], expanded, dictionary2[itmId], excludeExceptionIds, beginFieldName, endFieldName, timeZone);
                list.AddRange(expanded);
            }
            return(list);
        }
示例#20
0
        private static string GenerateRecurrenceItemId(int masterId, DateTime time, SPTimeZone timeZone, bool isAllDay)
        {
            DateTime time2 = isAllDay ? time : timeZone.LocalTimeToUTC(time);

            return(string.Format(CultureInfo.InvariantCulture, "{0}.0.{1}", new object[] { masterId, SPUtility.CreateISO8601DateTimeFromSystemDateTime(time2) }));
        }
 private static SPTimeZone GetTimeZone(RosterEvent item, SPTimeZone localTZ)
 {
     return(localTZ);
 }
 // Methods
 internal RecurrenceTimeZoneConverter(SPTimeZone originalTimeZone, SPTimeZone localTimeZone, DateTime rangeBegin, DateTime rangeEnd)
 {
     this.m_localTZ = localTimeZone;
     this.m_orgTZ   = originalTimeZone;
     this.CheckIfProblematicTimeZone(rangeBegin, rangeEnd);
 }
示例#23
0
        /// <summary>
        /// 统计文档的数量(将统计的文档当成字符串,作为参数),以及当前用户所发的量Author
        /// </summary>
        private void StatisticList(SPUser logUser)
        {
            string[] lstName = ListName.Split(';');

            SPQuery oQuery;
            SPList  sList;

            int[] itmCounts = new int[4];
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb web = site.AllWebs[SPContext.Current.Web.ID])
                    {
                        //设置sharepoint时间格式
                        SPTimeZone timeZone = web.RegionalSettings.TimeZone;
                        foreach (string mList in lstName)
                        {
                            try
                            {
                                if (mList == "Posts" && SubWebUrl != "")
                                {
                                    SPWeb subWeb = web.Webs[SubWebUrl];
                                    sList        = subWeb.Lists.TryGetList(mList);
                                }
                                else
                                {
                                    sList = web.Lists.TryGetList(mList);
                                }
                                oQuery = new SPQuery();
                                oQuery.ViewAttributes         = "Scope='RecursiveAll'";
                                oQuery.Query                  = "<Where><Eq><FieldRef Name='Author'/><Value Type='Text'>" + logUser.Name + "</Value></Eq></Where>";
                                SPListItemCollection lstItems = sList.GetItems(oQuery);
                                itmCounts[0]                  = lstItems.Count;  //个人
                                itmCounts[1]                  = sList.ItemCount; //全部
                                oQuery = new SPQuery();
                                DateTime currentDate = DateTime.Now;
                                DateTime qDate       = currentDate.AddDays(-1);
                                DateTime cDate       = timeZone.LocalTimeToUTC(qDate);
                                string dt            = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(cDate.ToString()));

                                oQuery.ViewAttributes = "Scope='RecursiveAll'";
                                oQuery.Query          = "<Where><And><Eq><FieldRef Name='Author'/><Value Type='Text'>" + logUser.Name + "</Value></Eq><Geq><FieldRef Name='Created'/><Value Type='DateTime'>" + dt + "</Value></Geq></And></Where>";
                                lstItems     = sList.GetItems(oQuery);
                                itmCounts[2] = lstItems.Count;    //当日更新


                                qDate = currentDate.AddDays(-7);
                                cDate = timeZone.LocalTimeToUTC(qDate);
                                dt    = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(cDate.ToString()));

                                oQuery.ViewAttributes = "Scope='RecursiveAll'";
                                oQuery.Query          = "<Where><And><Eq><FieldRef Name='Author'/><Value Type='Text'>" + logUser.Name + "</Value></Eq><Geq><FieldRef Name='Created'/><Value Type='DateTime'>" + dt + "</Value></Geq></And></Where>";
                                lstItems     = sList.GetItems(oQuery);
                                itmCounts[3] = lstItems.Count;    //本周更新

                                this.Controls.Add(new LiteralControl(mList + "<br/>"));
                                this.Controls.Add(new LiteralControl("个人总数 : " + itmCounts[0].ToString() + "<br/>"));
                                this.Controls.Add(new LiteralControl("团队总数 : " + itmCounts[1].ToString() + "<br/>"));
                                this.Controls.Add(new LiteralControl("当日更新 : " + itmCounts[2].ToString() + "<br/>"));
                                this.Controls.Add(new LiteralControl("本周总数 : " + itmCounts[3].ToString() + "<br/>"));
                            }
                            catch
                            { }
                        }
                    }
                }
            }
                                                 );
        }