Exemplo n.º 1
0
 // Token: 0x06001BD9 RID: 7129 RVA: 0x000A07E8 File Offset: 0x0009E9E8
 public static bool RenderTaskIcon(TextWriter writer, UserContext userContext, string itemClass, int iconFlag, bool isRead, bool isIrmProtected)
 {
     if (itemClass == null)
     {
         return(false);
     }
     if (string.Equals(itemClass, "IPM.Note", StringComparison.InvariantCultureIgnoreCase) && isIrmProtected)
     {
         itemClass += ".irm";
     }
     SmallIconManager.RenderItemIcon(writer, userContext, itemClass, false, null, false, isRead, iconFlag, string.Empty, new string[0]);
     return(true);
 }
		// Token: 0x06002EBE RID: 11966 RVA: 0x0010C4DC File Offset: 0x0010A6DC
		private bool BindItemAndShowDialog(Event eventItem, string type)
		{
			MessageItem messageItem = null;
			bool result;
			try
			{
				messageItem = Item.BindAsMessage(base.UserContext.MailboxSession, eventItem.ObjectId);
				if (messageItem != null)
				{
					string text = ItemUtility.GetProperty<string>(messageItem, StoreObjectSchema.ItemClass, null);
					if (text == null)
					{
						text = "IPM.Note";
					}
					this.Writer.Write("shwNwItmDlg(\"");
					if (messageItem.From != null && messageItem.From.DisplayName != null)
					{
						Utilities.JavascriptEncode(Utilities.HtmlEncode(messageItem.From.DisplayName), this.Writer);
					}
					this.Writer.Write("\",\"");
					if (messageItem.Subject != null)
					{
						Utilities.JavascriptEncode(Utilities.HtmlEncode(messageItem.Subject), this.Writer);
					}
					this.Writer.Write("\",\"" + type + "\",\"");
					using (StringWriter stringWriter = new StringWriter())
					{
						SmallIconManager.RenderItemIcon(stringWriter, base.UserContext, text, false, "nwItmImg", new string[0]);
						Utilities.JavascriptEncode(stringWriter.ToString(), this.Writer);
					}
					this.Writer.Write("\");");
				}
				result = true;
			}
			catch (ObjectNotFoundException)
			{
				if (type != null)
				{
					if (!(type == "lnkNwMl"))
					{
						if (!(type == "lnkNwVMl"))
						{
							if (type == "lnkNwFx")
							{
								this.Writer.Write("shwNF(0);");
							}
						}
						else
						{
							this.Writer.Write("shwNVM(0);");
						}
					}
					else
					{
						this.Writer.Write("shwNM(0);");
					}
				}
				result = false;
			}
			finally
			{
				if (messageItem != null)
				{
					messageItem.Dispose();
				}
			}
			return result;
		}
        internal static bool GetReminderItemsInternal(UserContext userContext, ExDateTime actualizationTime, TextWriter output)
        {
            bool            result = false;
            string          name   = userContext.UserCulture.Name;
            List <object[]> list   = RemindersRenderingUtilities.QueryReminders(actualizationTime, userContext);

            if (list.Count == 0)
            {
                return(false);
            }
            foreach (object[] reminder in list)
            {
                ExDateTime exDateTime  = RemindersRenderingUtilities.GetItemProperty <ExDateTime>(reminder, ItemSchema.ReminderDueBy, ExDateTime.MinValue);
                ExDateTime exDateTime2 = RemindersRenderingUtilities.GetItemProperty <ExDateTime>(reminder, ItemSchema.ReminderNextTime, ExDateTime.MinValue);
                if (!(exDateTime == ExDateTime.MinValue) && !(exDateTime2 == ExDateTime.MinValue) && !(exDateTime2 == RemindersRenderingUtilities.MaxOutlookDate))
                {
                    string itemProperty  = RemindersRenderingUtilities.GetItemProperty <string>(reminder, StoreObjectSchema.ItemClass, string.Empty);
                    bool   itemProperty2 = RemindersRenderingUtilities.GetItemProperty <bool>(reminder, MessageItemSchema.IsDraft, false);
                    int    itemProperty3 = RemindersRenderingUtilities.GetItemProperty <int>(reminder, MessageItemSchema.SwappedToDoStore, -1);
                    if (itemProperty.IndexOf("IPM.Schedule.Meeting", StringComparison.OrdinalIgnoreCase) == -1 && (itemProperty.IndexOf("IPM.Note", StringComparison.OrdinalIgnoreCase) == -1 || !itemProperty2) && itemProperty3 == -1)
                    {
                        ExDateTime itemProperty4 = RemindersRenderingUtilities.GetItemProperty <ExDateTime>(reminder, CalendarItemInstanceSchema.StartTime, ExDateTime.MinValue);
                        ExDateTime itemProperty5 = RemindersRenderingUtilities.GetItemProperty <ExDateTime>(reminder, CalendarItemInstanceSchema.EndTime, ExDateTime.MinValue);
                        int        num           = (int)(itemProperty5 - itemProperty4).TotalMinutes;
                        if (num < 0)
                        {
                            num = 0;
                        }
                        bool        flag          = ObjectClass.IsCalendarItem(itemProperty);
                        VersionedId itemProperty6 = RemindersRenderingUtilities.GetItemProperty <VersionedId>(reminder, ItemSchema.Id);
                        bool        flag2         = false;
                        if (flag)
                        {
                            CalendarItemType itemProperty7 = RemindersRenderingUtilities.GetItemProperty <CalendarItemType>(reminder, CalendarItemBaseSchema.CalendarItemType, CalendarItemType.Single);
                            flag2 = (itemProperty7 == CalendarItemType.RecurringMaster);
                        }
                        VersionedId versionedId = null;
                        string      text;
                        string      text2;
                        if (flag2)
                        {
                            CalendarItemOccurrence calendarItemOccurrence = null;
                            Item item = null;
                            try
                            {
                                try
                                {
                                    item = Utilities.GetItem <Item>(userContext, itemProperty6.ObjectId, new PropertyDefinition[0]);
                                    if (item.Reminder != null)
                                    {
                                        calendarItemOccurrence = (item.Reminder.GetPertinentItem(actualizationTime) as CalendarItemOccurrence);
                                    }
                                    if (calendarItemOccurrence == null)
                                    {
                                        continue;
                                    }
                                    object obj  = calendarItemOccurrence.Reminder.DueBy;
                                    object obj2 = calendarItemOccurrence.Reminder.ReminderNextTime;
                                    if (obj == null || obj2 == null)
                                    {
                                        continue;
                                    }
                                    exDateTime2 = (ExDateTime)obj2;
                                    exDateTime  = (ExDateTime)obj;
                                    versionedId = calendarItemOccurrence.Id;
                                    text        = calendarItemOccurrence.Subject;
                                    text2       = calendarItemOccurrence.Location;
                                }
                                catch (StoragePermanentException ex)
                                {
                                    ExTraceGlobals.CalendarDataTracer.TraceDebug <string>(0L, "Unable to retrieve calendar item occurence for this reminder.  Exception: {0}", ex.Message);
                                    result = true;
                                    continue;
                                }
                                catch (StorageTransientException ex2)
                                {
                                    ExTraceGlobals.CalendarDataTracer.TraceDebug <string>(0L, "Unable to retrieve calendar item occurence for this reminder.  Exception: {0}", ex2.Message);
                                    result = true;
                                    continue;
                                }
                                goto IL_289;
                            }
                            finally
                            {
                                if (item != null)
                                {
                                    item.Dispose();
                                    item = null;
                                }
                                if (calendarItemOccurrence != null)
                                {
                                    calendarItemOccurrence.Dispose();
                                    calendarItemOccurrence = null;
                                }
                            }
                            goto IL_26D;
                        }
                        goto IL_26D;
IL_289:
                        using (StringWriter stringWriter = new StringWriter())
                        {
                            stringWriter.Write("<div _lnk=1 class=\"divNotificationsItem\" id=\"b");
                            Utilities.HtmlEncode(itemProperty6.ObjectId.ToBase64String(), stringWriter);
                            stringWriter.Write("\" ck=\"");
                            Utilities.HtmlEncode(itemProperty6.ChangeKeyAsBase64String(), stringWriter);
                            if (flag2)
                            {
                                stringWriter.Write("\" oid=\"");
                                Utilities.HtmlEncode(versionedId.ObjectId.ToBase64String(), stringWriter);
                            }
                            stringWriter.Write("\" t=\"");
                            Utilities.HtmlEncode(DateTimeUtilities.GetJavascriptDate(exDateTime), stringWriter);
                            stringWriter.Write("\" c=\"");
                            Utilities.HtmlEncode(itemProperty, stringWriter);
                            stringWriter.Write("\" r=\"");
                            Utilities.HtmlEncode(DateTimeUtilities.GetJavascriptDate(exDateTime2), stringWriter);
                            stringWriter.Write("\" d=\"");
                            stringWriter.Write(num);
                            SanitizedHtmlString sanitizedHtmlString = null;
                            if (!string.IsNullOrEmpty(text))
                            {
                                sanitizedHtmlString = Utilities.SanitizeHtmlEncode(text);
                            }
                            SanitizedHtmlString sanitizedHtmlString2 = null;
                            if (!string.IsNullOrEmpty(text2))
                            {
                                sanitizedHtmlString2 = Utilities.SanitizeHtmlEncode(text2);
                            }
                            stringWriter.Write("\" subj=\"");
                            stringWriter.Write(sanitizedHtmlString);
                            stringWriter.Write("\" loc=\"");
                            stringWriter.Write(sanitizedHtmlString2);
                            string text3 = string.Format(userContext.UserCulture, LocalizedStrings.GetHtmlEncodedFromKey(name, 580192567), new object[]
                            {
                                Utilities.HtmlEncode(exDateTime.ToString(DateTimeFormatInfo.CurrentInfo.LongDatePattern)),
                                Utilities.HtmlEncode(exDateTime.ToString(userContext.UserOptions.TimeFormat))
                            });
                            stringWriter.Write("\" due=\"");
                            stringWriter.Write(text3);
                            stringWriter.Write("\" tabindex=0>");
                            SmallIconManager.RenderItemIcon(stringWriter, userContext, itemProperty, false, -1, string.Empty, new string[]
                            {
                                "id=\"imgNtfyEnt\""
                            });
                            stringWriter.Write("<DIV id=\"c3\" class=\"divNotificationsColumn3\"><div id=\"c3Time\" class=\"divRemindersDueInTime\"></div><div id=\"c3Text\" class=\"divRemindersDueInText\"></div></div>");
                            stringWriter.Write("<DIV id=\"c2\" class=\"divNotificationsColumn2\"><div id=\"c2Time\" class=\"divRemindersDueInTime\"></div><div id=\"c2Text\" class=\"divRemindersDueInText\"></div></div>");
                            stringWriter.Write("<DIV id=\"c1\" class=\"divNotificationsColumn1\"><div id=\"c1Row1\" class=\"divNotificationsColumn1Row1\">{0}</div><div id=\"c1Row2\" class=\"divNotificationsColumn1Row2\">{1}</div>", (sanitizedHtmlString != null) ? sanitizedHtmlString.ToString() : string.Empty, text3);
                            if (sanitizedHtmlString2 != null)
                            {
                                stringWriter.Write("<div id=\"c1Row3\" class=\"divNotificationsColumn1Row3\">");
                                stringWriter.Write(sanitizedHtmlString2);
                                stringWriter.Write("</div>");
                            }
                            stringWriter.Write("</div></div>");
                            Utilities.JavascriptEncode(stringWriter.ToString(), output);
                        }
                        continue;
IL_26D:
                        text  = RemindersRenderingUtilities.GetItemProperty <string>(reminder, ItemSchema.Subject, null);
                        text2 = RemindersRenderingUtilities.GetItemProperty <string>(reminder, CalendarItemBaseSchema.Location, null);
                        goto IL_289;
                    }
                }
            }
            return(result);
        }
        // Token: 0x06001E1F RID: 7711 RVA: 0x000AE510 File Offset: 0x000AC710
        public static void RenderAttachments(TextWriter output, AttachmentWellType wellType, ArrayList attachmentList, UserContext userContext, bool isConversationAndIrmCopyRestricted)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (attachmentList == null || attachmentList.Count <= 0)
            {
                return;
            }
            bool flag = true;

            Utilities.GetEmbeddedDepth(HttpContext.Current.Request);
            ArrayList previousAttachmentDisplayNames = new ArrayList();
            Item      item = null;

            try
            {
                foreach (object obj in attachmentList)
                {
                    AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
                    AttachmentUtility.AttachmentLinkFlags attachmentLinkFlag = AttachmentUtility.GetAttachmentLinkFlag(wellType, attachmentWellInfo);
                    if (AttachmentUtility.AttachmentLinkFlags.Skip != (AttachmentUtility.AttachmentLinkFlags.Skip & attachmentLinkFlag))
                    {
                        ItemAttachment itemAttachment = null;
                        Item           item2          = null;
                        try
                        {
                            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
                            {
                                if (attachmentWellInfo.MessageId != null)
                                {
                                    if (item != null)
                                    {
                                        StoreObjectId storeObjectId = StoreId.GetStoreObjectId(item.Id);
                                        if (!storeObjectId.Equals(attachmentWellInfo.MessageId.StoreObjectId))
                                        {
                                            item.Dispose();
                                            item = null;
                                        }
                                    }
                                    if (item == null)
                                    {
                                        item = Utilities.GetItem <Item>(userContext, attachmentWellInfo.MessageId, false, null);
                                    }
                                    AttachmentCollection attachmentCollection = item.AttachmentCollection;
                                    if (userContext.IsIrmEnabled && Utilities.IrmDecryptIfRestricted(item, userContext))
                                    {
                                        attachmentCollection = ((RightsManagedMessageItem)item).ProtectedAttachmentCollection;
                                    }
                                    itemAttachment = (ItemAttachment)attachmentCollection.Open(attachmentWellInfo.AttachmentId);
                                }
                                else
                                {
                                    itemAttachment = (ItemAttachment)attachmentWellInfo.OpenAttachment();
                                }
                                item2 = itemAttachment.GetItemAsReadOnly(new PropertyDefinition[]
                                {
                                    TaskSchema.TaskType
                                });
                            }
                            if (!flag)
                            {
                                output.Write("; ");
                            }
                            else
                            {
                                flag = false;
                            }
                            output.Write("<span id=spnAtmt tabindex=\"-1\" ");
                            if (wellType == AttachmentWellType.ReadOnly && AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink != (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag))
                            {
                                output.Write("class=\"dsbl\"");
                            }
                            if (attachmentWellInfo.MessageId != null)
                            {
                                output.Write(" _sId=\"");
                                Utilities.SanitizeHtmlEncode(attachmentWellInfo.MessageId.ToString(), output);
                                output.Write("\"");
                            }
                            string text;
                            if (item2 != null)
                            {
                                text = AttachmentUtility.GetEmbeddedAttachmentDisplayName(item2);
                            }
                            else
                            {
                                text = attachmentWellInfo.AttachmentName;
                            }
                            output.Write(" _attid=\"");
                            output.Write(Utilities.SanitizeHtmlEncode(attachmentWellInfo.AttachmentId.ToBase64String()));
                            output.Write("\" _level=");
                            output.Write((int)attachmentWellInfo.AttachmentLevel);
                            output.Write(" _attname=\"");
                            output.Write(Utilities.SanitizeHtmlEncode(text));
                            output.Write("\" _attsize=\"");
                            output.Write(attachmentWellInfo.Size);
                            output.Write("\" _fIsItem=\"");
                            output.Write(item2 != null);
                            output.Write("\"");
                            if (attachmentWellInfo.AttachmentType != AttachmentType.EmbeddedMessage)
                            {
                                output.Write(" _protectable=\"");
                                bool flag2 = false;
                                try
                                {
                                    flag2 = ProtectorsManager.Instance.IsProtectorRegistered(attachmentWellInfo.FileExtension);
                                }
                                catch (AttachmentProtectionException)
                                {
                                }
                                output.Write(flag2 ? "1" : "0");
                                output.Write("\"");
                            }
                            if (item2 != null)
                            {
                                Task task = item2 as Task;
                                if ((task != null && !TaskUtilities.IsAssignedTask(task)) || item2 is Contact || item2 is DistributionList)
                                {
                                    output.Write(" _qs=\"ae=PreFormAction&a=OpenEmbedded&t=");
                                }
                                else
                                {
                                    output.Write(" _qs=\"ae=Item&t=");
                                }
                                Utilities.SanitizeHtmlEncode(Utilities.UrlEncode(item2.ClassName), output);
                                if (task != null && TaskUtilities.IsAssignedTask(task))
                                {
                                    output.Write("&s=Assigned");
                                }
                                output.Write("\"");
                            }
                            output.Write(">");
                            bool flag3 = AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink == (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag);
                            if (flag3)
                            {
                                string text2 = null;
                                if (item2 != null || attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Allow)
                                {
                                    text2 = "3";
                                }
                                else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.ForceSave)
                                {
                                    text2 = "2";
                                }
                                if (text2 != null)
                                {
                                    output.Write("<a class=\"lnkClickAtmt\" id=\"lnkAtmt\" _fAllwCM=\"1\" href=\"#\" target=_blank ");
                                    Utilities.RenderScriptHandler(output, "onclick", string.Concat(new string[]
                                    {
                                        "atLnk(event, ",
                                        text2,
                                        ", ",
                                        isConversationAndIrmCopyRestricted ? "1" : "0",
                                        ");"
                                    }));
                                    output.Write(" title=\"");
                                    Utilities.SanitizeHtmlEncode(text, output);
                                    if (text2 == "3" & item2 != null)
                                    {
                                        output.Write("\" oncontextmenu=\"return false;");
                                    }
                                    output.Write("\">");
                                }
                            }
                            if (item2 != null)
                            {
                                SmallIconManager.RenderItemIcon(output, userContext, item2.ClassName, false, "sI", new string[0]);
                            }
                            else
                            {
                                string fileExtension = string.Empty;
                                if (attachmentWellInfo.FileExtension != null)
                                {
                                    fileExtension = attachmentWellInfo.FileExtension;
                                }
                                SmallIconManager.RenderFileIcon(output, userContext, fileExtension, "sI", new string[0]);
                            }
                            if (item2 != null)
                            {
                                Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, true), output);
                            }
                            else
                            {
                                Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, false), output);
                                long size = attachmentWellInfo.Size;
                                if (size > 0L)
                                {
                                    output.Write(userContext.DirectionMark);
                                    output.Write(" ");
                                    output.Write(SanitizedHtmlString.FromStringId(6409762));
                                    Utilities.RenderSizeWithUnits(output, size, true);
                                    output.Write(userContext.DirectionMark);
                                    output.Write(SanitizedHtmlString.FromStringId(-1023695022));
                                }
                            }
                            if (flag3)
                            {
                                output.Write("</a>");
                            }
                            if (item2 == null && AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink == (AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink & attachmentLinkFlag))
                            {
                                AttachmentWell.RenderWebReadyLink(output, userContext);
                            }
                            if (wellType == AttachmentWellType.ReadWrite)
                            {
                                output.Write("<span class=\"delLnk\">");
                                userContext.RenderThemeImage(output, ThemeFileId.DeleteSmall, null, new object[]
                                {
                                    "id=delImg"
                                });
                                output.Write("</span>");
                            }
                            output.Write("</span>");
                        }
                        catch (ObjectNotFoundException)
                        {
                        }
                        catch (StorageTransientException)
                        {
                        }
                        finally
                        {
                            if (item2 != null)
                            {
                                item2.Dispose();
                                item2 = null;
                            }
                            if (itemAttachment != null)
                            {
                                itemAttachment.Dispose();
                                itemAttachment = null;
                            }
                        }
                    }
                }
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
            }
        }