private void GetMeetingHeaders(MeetingItem item, out string smallHead, string[] exclusions) { StringBuilder header = new StringBuilder(); if (!exclusions.Contains("title", StringComparer.OrdinalIgnoreCase)) { header.Append("<p>"); AppendTitle(item, header, true); } AppendPplAndTime(item, header, exclusions); var appointment = item.GetAssociatedAppointment(false); if (appointment != null) { string when = appointment.Start.Date.Equals(appointment.End.Date) ? string.Format("from {0:h:mm tt} to {1:h:mm tt}, {2:dddd, MMMM d yyyy}", appointment.Start, appointment.End, appointment.Start) : string.Format("from {0:h:mm tt dddd, MMMM d yyyy} to {1:h:mm tt dddd, MMMM d yyyy}", appointment.Start, appointment.End); header.AppendFormat("<br/>{0}", when); if (!string.IsNullOrWhiteSpace(appointment.Location)) header.AppendFormat("<br/>at {0}", appointment.Location); } AddAttachments(header, item.Attachments); if (!exclusions.Contains("title", StringComparer.OrdinalIgnoreCase)) header.Append("</p>"); smallHead = header.ToString(); }
private void GetMeetingHeaders(MeetingItem item, out string smallHead, string[] exclusions) { StringBuilder header = new StringBuilder(); if (!exclusions.Contains("title", StringComparer.OrdinalIgnoreCase)) { header.Append("<p>"); AppendTitle(item, header, true); } AppendPplAndTime(item, header, exclusions); var appointment = item.GetAssociatedAppointment(false); if (appointment != null) { string when = appointment.Start.Date.Equals(appointment.End.Date) ? string.Format("from {0:h:mm tt} to {1:h:mm tt}, {2:dddd, MMMM d yyyy}", appointment.Start, appointment.End, appointment.Start) : string.Format("from {0:h:mm tt dddd, MMMM d yyyy} to {1:h:mm tt dddd, MMMM d yyyy}", appointment.Start, appointment.End); header.AppendFormat("<br/>{0}", when); if (!string.IsNullOrWhiteSpace(appointment.Location)) { header.AppendFormat("<br/>at {0}", appointment.Location); } } AddAttachments(header, item.Attachments); if (!exclusions.Contains("title", StringComparer.OrdinalIgnoreCase)) { header.Append("</p>"); } smallHead = header.ToString(); }
public static void DisplayMeetingItem(MeetingItem item) { try { Console.WriteLine("[Sender] {0} - ({1})", item.SenderName, item.SenderEmailAddress); Console.WriteLine("[Subject] " + item.Subject); Console.WriteLine("[ID] " + item.EntryID); if (item.Attachments.Count > 0) { Console.Write("[Attachments]"); foreach (Attachment attach in item.Attachments) { Console.Write(" " + attach.FileName); } Console.WriteLine(); } if (Common.display) { Console.WriteLine("[Body] " + item.Body); } } catch (System.Exception e) { Console.WriteLine("[ERROR] " + e.Message); } Console.WriteLine(); }
public Meeting Initialize(MeetingTemplate meetingTemplate, DateTime dateTime) { var meeting = new Meeting { DateTime = dateTime, Items = new List <MeetingItem>(), }; foreach (var meetingItem in meetingTemplate.Items) { var item = new MeetingItem { Description = meetingItem.Role.Description, Role = meetingItem.Role, StartTime = meetingItem.StartTime, MinTime = meetingItem.MinTime, MedTime = meetingItem.MedTime, MaxTime = meetingItem.MaxTime, Member = meetingItem.Member, }; meeting.Items.Add(item); } return(meeting); }
private void MeetingItemAction(MeetingItem meetingMail) { meetingMail.Move(MeetingFolder); var folderName = "Meeting Folder"; Log.Information($"Move meeting:{meetingMail.Subject} to {folderName}."); }
private void UpdateMeeting(MeetingList meetingList, string creatorName, string createTime) { var currentMeeting = meetingList.MeetingInfos.FirstOrDefault(o => o.MeetingId == (int)AppCache.TryGet(CacheKey.MeetingId)); if (currentMeeting == null) { MeetingItem meetingItem = new MeetingItem() { LastActivityTime = DateTime.Now, MeetingId = (int)AppCache.TryGet(CacheKey.MeetingId), CreatorName = creatorName, IsClose = false, CreatorId = AppCache.TryGet(CacheKey.HostId).ToString(), }; if (!string.IsNullOrEmpty(createTime)) { meetingItem.CreateTime = DateTime.Parse(createTime); } meetingList.MeetingInfos.Add(meetingItem); } else { currentMeeting.LastActivityTime = DateTime.Now; } _localDataManager.SaveMeetingList(meetingList); }
public void OnAction(IRibbonControl ribbonUI) { if (ribbonUI.Id.ToLower() == "buttoncredits") { creditsForm = new CreditsForm(); creditsForm.CreditsViewer.DocumentText = (string)resmgr.GetObject("Credits", ci); creditsForm.Show(); } else if (ribbonUI.Id.ToLower() == "buttonsettings") { settingsForm = new SettingsForm(setting, ci); settingsForm.TextBoxLanguage.Text = setting.Language; settingsForm.CheckBoxMeetingAcceptButton.Checked = setting.AcceptButton; settingsForm.NumericUpDownRibbonMaxWidth.Value = setting.RibbonMaxWidth; settingsForm.Show(); } else if (new [] { "label11", "label22", "label33", "label44" }.Contains(ribbonUI.Id.ToLower())) { // nothing } else if (new[] { "directaccept1", "directaccept2", "directaccept3", "directaccept4" }.Contains(ribbonUI.Id.ToLower())) { // https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentitem.respond // https://docs.microsoft.com/en-us/office/client-developer/outlook/pia/how-to-automatically-accept-a-meeting-request MeetingItem meetItem = labels[4].AppointmentItem.Respond(OlMeetingResponse.olMeetingAccepted, true); DPrint(meetItem, 2); meetItem.Send(); } }
public ActionResult DeleteConfirmed(int id) { MeetingItem meetingitem = _db.MeetingItems.Find(id); _db.MeetingItems.Remove(meetingitem); _db.SaveChanges(); return(RedirectToAction("Index")); }
static void DisplayMeetingItem(MeetingItem item) { Console.WriteLine("[Sender] {0} - ({1})", item.SenderName, item.SenderEmailAddress); Console.WriteLine("[Subject] " + item.Subject); if (display) { Console.WriteLine("[Body] " + item.Body); } Console.WriteLine(); }
public ActionResult Edit([Bind(Include = "MeetingItemId,PersonId,MeetingItemDescription,StartDate,DueDate,Priority,Status,PercentageCompleted,CompletedDate")] MeetingItem meetingitem) { if (ModelState.IsValid) { _db.Entry(meetingitem).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonId = new SelectList(_db.Persons, "PersonId", "FirstName", meetingitem.PersonId); return(View(meetingitem)); }
private void Load(MeetingItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } Content = $"进入:{item.LastActivityTime} 创建者:{item.CreatorName} 课堂号:{item.MeetingId} 创建:{item.CreateTime}"; BtnContent = "进入课堂"; BtnEnable = true; }
/// <summary> /// Applies the appropiate rule to the meeting parameter /// </summary> /// <param name="meetingItem">The meeting that needs processing</param> /// <param name="rule">the associated decline rule for the folder of this meetingItem</param> private static void ProcessRule(MeetingItem meetingItem, DeclineRuleSetting rule) { // if it's a Cancelation, delete it from calendar if (meetingItem.Class == OlObjectClass.olMeetingCancellation) { if (meetingItem.GetAssociatedAppointment(false) != null) { meetingItem.GetAssociatedAppointment(false).Delete(); return; } meetingItem.Delete(); return; // if deleted by user/app, delete the whole message } // get associated appointment AppointmentItem appointment = meetingItem.GetAssociatedAppointment(false); string globalAppointmentID = appointment.GlobalAppointmentID; // optional, send notification back to sender appointment.ResponseRequested &= rule.SendResponse; // set decline to the meeting MeetingItem responseMeeting = appointment.Respond(rule.Response, true); // https://msdn.microsoft.com/en-us/VBA/Outlook-VBA/articles/appointmentitem-respond-method-outlook // says that Respond() will return a new meeting object for Tentative response // optional, add a meesage to the Body if (!String.IsNullOrEmpty(rule.Message)) { (responseMeeting ?? meetingItem).Body = rule.Message; } // send decline //if(rule.Response == OlMeetingResponse.olMeetingDeclined) (responseMeeting ?? meetingItem).Send(); // and delete the appointment if tentative if (rule.Response == OlMeetingResponse.olMeetingTentative) { appointment.Delete(); } // after Sending the response, sometimes the appointment doesn't get deleted from calendar, // but appointmnent could become and invalid object, so we need to search for it and delete it AppointmentItem newAppointment = (AppointmentItem)Globals.AddIn.Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar).Items .Find("@SQL=\"http://schemas.microsoft.com/mapi/id/{6ED8DA90-450B-101B-98DA-00AA003F1305}/00030102\" = '" + globalAppointmentID + "' "); if (newAppointment != null) { newAppointment.Delete(); } }
// GET: /MeetingItem/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MeetingItem meetingitem = _db.MeetingItems.Find(id); if (meetingitem == null) { return(HttpNotFound()); } return(View(meetingitem)); }
public static MeetingItemDto Build(MeetingItem arg) { if (arg == null) { throw new ArgumentNullException(nameof(arg)); } return(new MeetingItemDto { Name = arg.Name, Url = arg.UrlPath, ScoId = arg.ScoId, }); }
// GET: /MeetingItem/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MeetingItem meetingitem = _db.MeetingItems.Find(id); if (meetingitem == null) { return(HttpNotFound()); } ViewBag.PersonId = new SelectList(_db.Persons, "PersonId", "FirstName", meetingitem.PersonId); return(View(meetingitem)); }
public static T GetUserProperty <T>(MeetingItem currentMeetingItem, string propName) { if (currentMeetingItem == null) { return(default(T)); } var markdownModeProperty = currentMeetingItem.UserProperties.Find(propName); if (markdownModeProperty != null) { return(Convert.ChangeType(markdownModeProperty.Value, typeof(T))); } return(default(T)); }
public IHttpActionResult Put(int Id, [FromBody] MeetingItem item) { using (var entities = new MeetingContext()) { var entity = entities.MeetingItems.FirstOrDefault(x => x.Id == Id); if (entity == null) { return(NotFound()); } else { entity.Description = item.Description; entity.DueDate = item.DueDate; entity.MeetingId = item.MeetingId; entity.Responsible = item.Responsible; entities.SaveChanges(); return(Ok(entity)); } } }
private async Task AddCarriedOverItems(Meeting meeting, CreateMeetingEntity createMeetingEntity) { if (createMeetingEntity.CarriedOverItemIds != null) { foreach (var id in createMeetingEntity.CarriedOverItemIds) { var currentStatus = _itemRepository.Where(i => i.Id == id).FirstOrDefault().ItemStatusId; var meetingItem = new MeetingItem { MeetingId = meeting.Id, ItemId = id, }; _meetingItemRepository.Add(meetingItem); await _meetingItemRepository.SaveAsync(); } ; } }
public IHttpActionResult createMeetingItem([FromBody] MeetingItem item) { if (item == null) { return(BadRequest("Meeting Item is empty")); } if (ModelState.IsValid) { using (var entities = new MeetingContext()) { entities.MeetingItems.Add(item); entities.SaveChanges(); return(Created("MeetingItem", item)); } } else { return(BadRequest(ModelState)); } }
public async Task <ItemEntity> AddItemAsync(ItemEntity meetingItemEntity) { var item = new Item { UserId = meetingItemEntity.UserId, Description = meetingItemEntity.Description, DueDate = meetingItemEntity.DueDate, ItemStatusId = _itemStatusRepository.All().FirstOrDefault().Id, CreatedAt = DateTimeOffset.Now, UpdatedAt = DateTimeOffset.Now }; _itemRepository.Add(item); await _itemRepository.SaveAsync(); var meetingItem = new MeetingItem { MeetingId = meetingItemEntity.Meeting.Id, ItemId = item.Id, CreatedAt = DateTimeOffset.Now, UpdatedAt = DateTimeOffset.Now }; _meetingItemRepository.Add(meetingItem); await _meetingItemRepository.SaveAsync(); return(new ItemEntity { Id = item.Id, Description = item.Description, DueDate = item.DueDate, UserId = item.UserId, CreatedAt = item.CreatedAt, UpdatedAt = item.UpdatedAt, Meeting = new MeetingEntity { Id = item.MeetingItem.MeetingId } }); }
/// <summary> /// Return an appropriate outbound transducer for this item. /// </summary> /// <param name="item">The item.</param> /// <returns>An appropriate transducer.</returns> public static AbstractOutboundTransducer GetOutbound(MeetingItem item) { return(new OutboundMeetingTransducer()); }
public ItemMeeting(MeetingItem item) { _item = item; }
private void CopyBodyToMeeting(AppointmentItem ai, ref MeetingItem meetingItem) { ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem enter"); Word.Document Doc = new Word.Document(); Word.Document Doc2 = new Word.Document(); //Word.Application App1; //Word.Selection Sel; Doc = ai.GetInspector.WordEditor as Word.Document; // Word.Application App2; // Word.Selection Sel2; if (Doc != null) { ThisAddIn.g_log.Info(string.Format("appointmentItem doc length is {0}.", Doc.Content.Text.Length)); Doc.Activate(); Doc.Select(); //App1 = Doc.Windows.Application; //Sel = App1.Selection; //Sel.WholeStory(); //Sel.Copy(); Doc.Range().WholeStory(); Doc.Range().Copy(); Doc2 = meetingItem.GetInspector.WordEditor as Word.Document; if (Doc2 != null) { Doc2.Activate(); object start = 0; Range newRang = Doc2.Range(ref start, ref start); int ioo = Doc2.Sections.Count; Section sec = Doc2.Sections[1]; sec.Range.InsertBreak(Type.Missing);//插入换行符 try { //sec.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault); sec.Range.PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting); meetingItem.Save(); ThisAddIn.g_log.Info(string.Format("meetingItem doc length is {0}.", Doc2.Content.Text.Length)); if (meetingItem.Body == null || meetingItem.Body.Length < 100) { Doc2.Activate(); ((_Inspector)(meetingItem.GetInspector)).Activate(); ThisAddIn.g_log.Info("meetingItems's body is null Or body length is short,Activate over"); } } catch (System.Exception ex) { ThisAddIn.g_log.Info("CopyBodyToMeeting comes Exception " + ex.ToString()); } } else { ThisAddIn.g_log.Info("Doc is null"); } } if (Doc != null) { Marshal.ReleaseComObject(Doc); Doc = null; } if (Doc2 != null) { Marshal.ReleaseComObject(Doc2); Doc2 = null; } //Doc = null; //Doc2 = null; ////App1 = null; ////Sel = null; //// App2 = null; //// Sel2 = null; ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem exit"); }
/// <summary> /// 避免与SMC交互两次 /// </summary> /// <param name="meetingItem"></param> /// <param name="ai"></param> /// <param name="bak_appointment"></param> /// <returns> True与SMC操作,false仅发送邮件不操作</returns> private bool EditConferenceCompare(MeetingItem meetingItem, AppointmentItem ai, BackUpAppointment bak_appointment) { if (meetingItem.Class == OlObjectClass.olMeetingCancellation) { if (bak_appointment != null) { return true; } else { ThisAddIn.g_log.Info("Cancel Recepients just send Mail not to SMC"); sendMailNotifications(ai, OperatorType.Cancel, meetingItem.Recipients); return false; } } else if (meetingItem.Class == OlObjectClass.olMeetingRequest) //发送的是会议增加人员 { if (bak_appointment != null) { if (bak_appointment.editEnd) { if (bak_appointment.editException) { ThisAddIn.g_log.Info("Cancel Recepients Comes Exception,Request Recepients stop"); //AppSubjectDic[ai].editEnd = false; //AppSubjectDic[ai].editException = false; //Cancel = true; return false; } else { ThisAddIn.g_log.Info("Request Recepients just send Mail not to SMC"); sendMailNotifications(ai, OperatorType.Modify, meetingItem.Recipients); AppSubjectDic[ai].editEnd = false; return false; } } else { return true; } } else { return true; } } else { ThisAddIn.g_log.Info("Edit Conference Enter into other state " + meetingItem.Class.ToString()); return false; } }
/// <summary> /// 比较用户,判断是修改还是删除 /// </summary> /// <param name="appItem"></param> /// <param name="mItem"></param> /// <returns>true 是删除会议,false 是修改会议</returns> private bool CompareRecipient(AppointmentItem appItem, MeetingItem mItem) { List<string> meetRecps = new List<string>(); foreach (Recipient recp in mItem.Recipients) { meetRecps.Add(recp.Name); } foreach (Recipient recp in appItem.Recipients) { if (!meetRecps.Contains(recp.Name)) { if (recp.Index == 1 && loginRecipient != null && recp.Name == loginRecipient.Name) { continue; } else { return false; } } } return true; }
private void Items_ItemAdd(object item) { MeetingItem meetingItem = item as MeetingItem; if (meetingItem != null) { var apptItem = meetingItem.GetAssociatedAppointment(false); if (apptItem != null) { var organizerAddressEntry = apptItem.GetOrganizer(); var currentUserAddressEntry = apptItem.Session?.CurrentUser?.AddressEntry; CreateEmailItem( subjectEmail: $"Oofer debug: {meetingItem.Subject}", toEmail: currentUserAddressEntry.Address, bodyEmail: $"This meeting item was received:\n\n{meetingItem.Subject}"); var alias = string.Empty; if (organizerAddressEntry.Type == "EX") { var exchangeUser = organizerAddressEntry.GetExchangeUser(); alias = exchangeUser.Alias; } var organizerFirstName = organizerAddressEntry.Name.Split(' ').FirstOrDefault(); if (_matches.Any(x => apptItem.Subject.ToUpperInvariant().Contains(x)) && organizerAddressEntry != currentUserAddressEntry) { var needsAlias = !string.IsNullOrWhiteSpace(alias) && !apptItem.Subject.Contains(organizerFirstName) && !apptItem.Subject.Contains(alias); if (apptItem.ReminderSet || apptItem.BusyStatus != OlBusyStatus.olFree || apptItem.ResponseRequested == true || needsAlias) { var subjectText = apptItem.Subject; var busyStatusText = GetBusyStatusString(apptItem.BusyStatus); var reminderSetText = apptItem.ReminderSet ? "Reminder was set" : "Reminder was not set"; var responseRequestedText = apptItem.ResponseRequested ? "Response was requested" : "Response was not requested"; apptItem.BusyStatus = OlBusyStatus.olFree; apptItem.ReminderSet = false; apptItem.ResponseRequested = false; if (needsAlias) { apptItem.Subject = $"{alias}: {subjectText}"; } // We will not send the response, but want to accept the appointment on our side. See linked // docs to send the response, if desired. apptItem.Respond(OlMeetingResponse.olMeetingAccepted, true, Type.Missing); apptItem.UnRead = false; apptItem.Save(); meetingItem.UnRead = false; meetingItem.Save(); CreateEmailItem( subjectEmail: $"Cleaned OOF/WFH: {subjectText}", toEmail: currentUserAddressEntry.Address, bodyEmail: $"This appointment was cleaned:\n\n{apptItem.Subject}\n{busyStatusText}\n{reminderSetText}\n{responseRequestedText}"); } } } } }
private void CopyBodyToMeeting(AppointmentItem ai, ref MeetingItem meetingItem) { ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem enter"); Word.Document Doc = new Word.Document(); Word.Document Doc2 = new Word.Document(); Word.Application App1; Word.Selection Sel; Doc = ai.GetInspector.WordEditor as Word.Document; if (Doc != null) { ThisAddIn.g_log.Info(string.Format("appointmentItem doc length is {0}.", Doc.Content.Text.Length)); Doc.Activate(); Doc.Select(); App1 = Doc.Windows.Application; Sel = App1.Selection; Sel.WholeStory(); Sel.Copy(); Doc2 = meetingItem.GetInspector.WordEditor as Word.Document; if (Doc2 != null) { Doc2.Activate(); object start = 0; Range newRang = Doc2.Range(ref start, ref start); int ioo = Doc2.Sections.Count; Section sec = Doc2.Sections[1]; sec.Range.InsertBreak(Type.Missing);//插入换行符 sec.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault); meetingItem.Save(); ThisAddIn.g_log.Info(string.Format("meetingItem doc length is {0}.", Doc2.Content.Text.Length)); //ThisAddIn.g_log.Info(string.Format("mailItem body length is {0}.", meetingItem.Body.Length)); if (meetingItem.Body == null || meetingItem.Body.Length < 100) { Doc2.Activate(); ((_Inspector)(meetingItem.GetInspector)).Activate(); } } } Doc = null; Doc2 = null; App1 = null; Sel = null; ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem exit"); }
public JoinClassControlViewModel(JoinClassView view, JoinClassControl jccView, MeetingItem item) { _view = view; _meetingId = item.MeetingId; _meetingService = DependencyResolver.Current.GetService <IMeetingSdkAgent>(); Load(item); WindowKeyDownCommand = new DelegateCommand <object>(WindowKeyDownHandler); _localDataManager = DependencyResolver.Current.GetService <ILocalDataManager>(); }
public void Init() { // テスト対象のクラス内で使われる変数のモック testRec = Substitute.For <Recipient>(); //testAdd = Substitute.For<AddressEntry>(); testExchUser = Substitute.For <ExchangeUser>(); // テスト用のXXXItemを、モックで作成 testMail = Substitute.For <MailItem>(); testMeeting = Substitute.For <MeetingItem>(); testAppointment = Substitute.For <AppointmentItem>(); testSharing = Substitute.For <SharingItem>(); testReport = Substitute.For <TestReportItem>(); testDocument = Substitute.For <DocumentItem>(); // ------------------------------------------------------------------------------------------------ // VSで実行する場合 // ------------------------------------------------------------------------------------------------ //// Factoryクラスは、自作のTestFactoryクラス&その中で使うTestAddInクラスがないとうまくいかない //// ThisAddInクラスのタイプを取得 //TestFactory testFactory = new TestFactory(); //IServiceProvider testService = Substitute.For<IServiceProvider>(); //ThisAddIn testAddIn = new ThisAddIn(testFactory, testService); //// リフレクション //// アセンブリを読み込み、モジュールを取得 //Assembly asm = Assembly.LoadFrom(@".\ORCAUnitTest\bin\Debug\OutlookRecipientConfirmationAddin.dll"); // ------------------------------------------------------------------------------------------------ // batで、このプロジェクトのテストをまとめて実行する場合 // ------------------------------------------------------------------------------------------------ // 共通で使うThisAddInクラスを取得 ThisAddIn testAddIn = GetContactItemUnitTest.testAddIn; // リフレクション // アセンブリを読み込み、モジュールを取得 Assembly asm = Assembly.LoadFrom(@".\OutlookRecipientConfirmationAddin.dll"); // ------------------------------------------------------------------------------------------------ Module mod = asm.GetModule("OutlookRecipientConfirmationAddin.dll"); Type typeThisAddIn = testAddIn.GetType(); // Applicaitionのモック作成 FieldInfo fieldApp = typeThisAddIn.GetField("Application", BindingFlags.NonPublic | BindingFlags.Instance); testApp = Substitute.For <TestApplication>(); fieldApp.SetValue(testAddIn, testApp); // Sessionのモック作成 testNs = Substitute.For <NameSpace>(); testNs.CreateRecipient(Arg.Any <string>()).Returns(testRec); testApp.Session.Returns(testNs); // ------------------------------------------------------------------------------------------------ // このクラスを単独で実行する場合 // ------------------------------------------------------------------------------------------------ //// Globalsのタイプと、ThisAddInプロパティを取得 //Type typeGlobal = mod.GetType("OutlookRecipientConfirmationAddin.Globals"); //PropertyInfo testProp = typeGlobal.GetProperty("ThisAddIn", BindingFlags.NonPublic | BindingFlags.Static); //// ThisAddinプロパティに、モックなどを使って作った値をセットする //testProp.SetValue(null, testAddIn); // ------------------------------------------------------------------------------------------------ // テスト対象のクラス(Utility)のタイプを取得 Type type = mod.GetType("OutlookRecipientConfirmationAddin.Utility"); // インスタンスを生成し、メソッドにアクセスできるようにする obj = Activator.CreateInstance(type); mi = type.GetMethod("GetSenderInfomation"); }
/// <summary> /// 获取周期性会议信息 /// </summary> /// <param name="ConfInfo">周期性会议信息</param> private void setRecurrenceConferenceInfo(ref RecurrenceConfInfo recurrenceConfInfo, AppointmentItem ai, bool bSingle, MeetingItem meeting) { //获取智真会议参数 recurrenceConfInfo.name = ai.Subject; recurrenceConfInfo.beginTime = ai.Start.ToUniversalTime(); TimeSpan span = ai.End - ai.Start; string duration = String.Format("P0Y0M{0}DT{1}H{2}M{3}S", span.Days, span.Hours, span.Minutes, span.Seconds); recurrenceConfInfo.duration = duration; recurrenceConfInfo.mediaEncryptType = ThisAddIn.g_SystemSettings.nMediaEncryptType; recurrenceConfInfo.rate = ThisAddIn.g_SystemSettings.strSiteRate; recurrenceConfInfo.isLiveBroadcast = ThisAddIn.g_SystemSettings.nLiving; recurrenceConfInfo.isRecording = ThisAddIn.g_SystemSettings.nRecording; recurrenceConfInfo.timeZone = transSysTimezone2SMC(ai.StartTimeZone); recurrenceConfInfo.billCode = ThisAddIn.g_SystemSettings.strBillCode; recurrenceConfInfo.password = ThisAddIn.g_SystemSettings.strConfPWD; recurrenceConfInfo.chairmanPassword = ThisAddIn.g_SystemSettings.strConfPWD; recurrenceConfInfo.cpResouce = ThisAddIn.g_SystemSettings.nCPResource; #region UserProperty up = ai.UserProperties.Find(PROPERTY_NAME_CONF_INFO, Type.Missing); if (up != null) { recurrenceConfInfo.confId = up.Value; } else { UserProperty upConfoID = ai.UserProperties.Add(ThisAddIn.PROPERTY_NAME_CONF_INFO, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing); } up = ai.UserProperties.Find(PROPERTY_CONFERENCE_PASSWORD, Type.Missing); if (up != null) { recurrenceConfInfo.password = up.Value; recurrenceConfInfo.chairmanPassword = up.Value; } else { UserProperty upConfoPassword = ai.UserProperties.Add(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing); upConfoPassword.Value = ThisAddIn.g_SystemSettings.strConfPWD; } up = ai.UserProperties.Find(PROPERTY_IS_RECORDING, Type.Missing); if (up != null) { recurrenceConfInfo.isRecording = Convert.ToInt32(up.Value); } else { UserProperty upRecording = ai.UserProperties.Add(ThisAddIn.PROPERTY_IS_RECORDING, Outlook.OlUserPropertyType.olYesNo, Type.Missing, Type.Missing); upRecording.Value = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nRecording); } up = ai.UserProperties.Find(PROPERTY_IS_LIVING, Type.Missing); if (up != null) { recurrenceConfInfo.isLiveBroadcast = Convert.ToInt32(up.Value); } else { UserProperty upLiving = ai.UserProperties.Add(ThisAddIn.PROPERTY_IS_LIVING, Outlook.OlUserPropertyType.olYesNo, Type.Missing, Type.Missing); upLiving.Value = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nLiving); } up = ai.UserProperties.Find(PROPERTY_SITE_RATE, Type.Missing); if (up != null) { recurrenceConfInfo.rate = up.Value; } else { UserProperty upSiteRate = ai.UserProperties.Add(ThisAddIn.PROPERTY_SITE_RATE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing); upSiteRate.Value = ThisAddIn.g_SystemSettings.strSiteRate; } up = ai.UserProperties.Find(PROPERTY_SECURITY_LEVEL, Type.Missing); if (up != null) { recurrenceConfInfo.mediaEncryptType = up.Value; } else { UserProperty upSecurityLevel = ai.UserProperties.Add(ThisAddIn.PROPERTY_SECURITY_LEVEL, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing); upSecurityLevel.Value = ThisAddIn.g_SystemSettings.nMediaEncryptType; } up = ai.UserProperties.Find(PROPERTY_BILL_CODE, Type.Missing); if (up != null) { recurrenceConfInfo.billCode = up.Value; } else { UserProperty upBillCode = ai.UserProperties.Add(ThisAddIn.PROPERTY_BILL_CODE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing); upBillCode.Value = ThisAddIn.g_SystemSettings.strBillCode; } up = ai.UserProperties.Find(PROPERTY_CPRESOURCE, Type.Missing); if (up != null) { if (false == ThisAddIn.g_SystemSettings.bShowCPResource) { recurrenceConfInfo.cpResouce = 0; } else { recurrenceConfInfo.cpResouce = up.Value; } } else//非智真会场入口 { UserProperty upCPResource = ai.UserProperties.Add(ThisAddIn.PROPERTY_CPRESOURCE, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing); if (false == ThisAddIn.g_SystemSettings.bShowCPResource) { upCPResource.Value = 0; recurrenceConfInfo.cpResouce = 0; } else { upCPResource.Value = ThisAddIn.g_SystemSettings.nCPResource; } } #endregion ThisAddIn.g_log.Info(string.Format("recurrence conf id is: {0}", recurrenceConfInfo.confId)); ThisAddIn.g_log.Info(string.Format("recurrence conf name is: {0}", recurrenceConfInfo.name)); ThisAddIn.g_log.Info(string.Format("recurrence conf begin at utc: {0}", recurrenceConfInfo.beginTime.ToString())); ThisAddIn.g_log.Info(string.Format("appointment item begin at local: {0}", ai.Start.ToString())); ThisAddIn.g_log.Info(string.Format("recurrence conf duration: {0}", recurrenceConfInfo.duration)); ThisAddIn.g_log.Info(string.Format("recurrence conf rate is: {0}", recurrenceConfInfo.rate)); ThisAddIn.g_log.Info(string.Format("recurrence conf media encrypt type is: {0}", recurrenceConfInfo.mediaEncryptType)); ThisAddIn.g_log.Info(string.Format("recurrence conf recording is: {0}", recurrenceConfInfo.isRecording)); ThisAddIn.g_log.Info(string.Format("recurrence conf living is: {0}", recurrenceConfInfo.isLiveBroadcast)); ThisAddIn.g_log.Info(string.Format("recurrence conf bill code is: {0}", recurrenceConfInfo.billCode)); ThisAddIn.g_log.Info(string.Format("recurrence conf password is: ******")); ThisAddIn.g_log.Info(string.Format("recurrence conf chairman password is: ******")); ThisAddIn.g_log.Info(string.Format("recurrence conf CPResource is: {0}", recurrenceConfInfo.cpResouce)); ThisAddIn.g_log.Info(string.Format("recurrence conf timezone is: {0}", recurrenceConfInfo.timeZone)); //视频会场 ArrayList list = new ArrayList(); SiteInfo tempSite = null; int nVideoCount = 0; up = ai.UserProperties.Find(PROPERTY_VIDEO_SITES_COUNT, Type.Missing); if (up != null) { nVideoCount = up.Value; } else { UserProperty upVideoSiteCounts = ai.UserProperties.Add(ThisAddIn.PROPERTY_VIDEO_SITES_COUNT, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing); upVideoSiteCounts.Value = ThisAddIn.g_SystemSettings.nVideoSitesCount; nVideoCount = ThisAddIn.g_SystemSettings.nVideoSitesCount; } if (nVideoCount > 0) { for (int i = 0; i < nVideoCount; i++) { tempSite = new SiteInfo(); tempSite.type = 4; list.Add(tempSite); } } //语音会场 int nVoiceCount = 0; up = ai.UserProperties.Find(PROPERTY_VOICE_SITES_COUNT, Type.Missing); if (up != null) { nVoiceCount = up.Value; } else { UserProperty upVoiceSiteCounts = ai.UserProperties.Add(ThisAddIn.PROPERTY_VOICE_SITES_COUNT, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing); upVoiceSiteCounts.Value = ThisAddIn.g_SystemSettings.nVoiceSitesCount; nVoiceCount = ThisAddIn.g_SystemSettings.nVoiceSitesCount; } if (nVoiceCount > 0) { for (int i = 0; i < nVoiceCount; i++) { tempSite = new SiteInfo(); tempSite.type = 9; list.Add(tempSite); } } //2015-7-14 w00322557 临时会场 up = ai.UserProperties.Find(PROPERTY_TEMP_SITES, Type.Missing); if (up != null) { List<SiteInfo> listTempSites = XmlHelper.Desrialize<List<SiteInfo>>(up.Value); foreach (SiteInfo site in listTempSites) { list.Add(site); ThisAddIn.g_log.Info(string.Format("Temp site name: {0}", site.name)); ThisAddIn.g_log.Info(string.Format("Temp site uri: {0}", site.uri)); ThisAddIn.g_log.Info(string.Format("Temp site type: {0}", site.type)); } } else { ThisAddIn.g_log.Debug("Temp site is null or empty!"); } //获取会场邮件地址 List<string> listSites = GetTPSitesFromLocation(ai); if (listSites != null) { SiteInfo[] sites = new SiteInfo[listSites.Count]; for (int i = 0; i < listSites.Count; i++) { sites[i] = new SiteInfo(); sites[i].uri = listSites[i]; sites[i].type = -1;//2015-7-15 w00322557 smc会场类型修改为-1 list.Add(sites[i]); ThisAddIn.g_log.Info(string.Format("TP site uri is: {0}", sites[i].uri)); } } if (list.Count > 0) { recurrenceConfInfo.sites = (SiteInfo[])list.ToArray(typeof(SiteInfo)); ThisAddIn.g_log.Info(string.Format("RecurrenceConfInfo sites length is: {0}", recurrenceConfInfo.sites.Length)); ThisAddIn.g_log.Info(string.Format("Total TP sites count is: {0}", list.Count)); } else { ThisAddIn.g_log.Error(string.Format("There is no TP sites!")); } // //2007版本,缺少sendable属性,不用AppointMentItem的收件人,用MeetingItem的收件人 // if (bSingle && meeting.Class == OlObjectClass.olMeetingRequest) // { // listSites = GetTPSitesFromLocation(meeting.GetAssociatedAppointment(false)); // } // else // { // listSites = GetTPSitesFromLocation(ai); // } // // //2014/12/25 修改周期会议的子会议,将删除的会场从总会场地址中去除 // if (bSingle && meeting.Class == OlObjectClass.olMeetingCancellation) // { // foreach (Recipient recp in meeting.Recipients) // { // Outlook.ExchangeUser exchangeUser = recp.AddressEntry.GetExchangeUser(); // // string smtpAddress; // if (exchangeUser != null) // { // smtpAddress = exchangeUser.PrimarySmtpAddress; // } // else // { // smtpAddress = recp.Address; // } // // if (listSites.Contains(smtpAddress)) // { // listSites.Remove(smtpAddress); // } // } // } // // SiteInfo[] sites = new SiteInfo[listSites.Count]; // for (int i = 0; i < listSites.Count; i++) // { // sites[i] = new SiteInfo(); // sites[i].uri = listSites[i]; // sites[i].type = 7; // list.Add(sites[i]); // ThisAddIn.g_log.Info(string.Format("Total TP sites uri is: {0}", sites[i].uri)); // } // // recurrenceConfInfo.sites = (SiteInfo[])list.ToArray(typeof(SiteInfo)); if (bSingle == false) { ThisAddIn.g_log.Info("setRecurrenceConferenceInfo recurrence"); //周期信息 RecurrencePattern recurrencePattern = ai.GetRecurrencePattern(); OlDaysOfWeek daysOfWeek = recurrencePattern.DayOfWeekMask;//一周中的天数 //recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数 //recurrencePattern.GetOccurrence()//根据指定日期,返回AppointmentItem if (recurrencePattern.NoEndDate == true) { recurrencePattern.NoEndDate = false; } //周期类型(天=0、周=1、月=2) if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursDaily)//天 { recurrenceConfInfo.frequency = 0; recurrenceConfInfo.interval = recurrencePattern.Interval;//周期间隔 if (true == recurrenceConfInfo.endDateSpecified) { recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期 } else { recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数 } } else if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursWeekly)//周 { recurrenceConfInfo.frequency = 1; // Int32[] weekDays = this.getWeekDays(daysOfWeek); if (weekDays != null) { recurrenceConfInfo.weekDays = weekDays; } if (0 == recurrencePattern.Interval) { recurrenceConfInfo.interval = 1;//周期间隔 } else { recurrenceConfInfo.interval = recurrencePattern.Interval; } if (true == recurrenceConfInfo.endDateSpecified) { recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期 } else { recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数 } } else if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursMonthly)//月 { recurrenceConfInfo.frequency = 2; int nDay = recurrencePattern.PatternStartDate.Day; recurrenceConfInfo.monthDay = nDay; recurrenceConfInfo.interval = recurrencePattern.Interval;//周期间隔 if (true == recurrenceConfInfo.endDateSpecified) { recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期 } else { recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数 } } else if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursMonthNth) { recurrenceConfInfo.frequency = 2; recurrenceConfInfo.weekDay = recurrencePattern.Instance; recurrenceConfInfo.weekDays = this.getWeekDays(daysOfWeek); recurrenceConfInfo.interval = recurrencePattern.Interval;//周期间隔 if (true == recurrenceConfInfo.endDateSpecified) { recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期 } else { recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数 } } else { ThisAddIn.g_log.Error("RecurrenceType is year!"); } } else { //recurrenceConfInfo.timeZone = null; recurrenceConfInfo.frequency = null; recurrenceConfInfo.interval = null; ThisAddIn.g_log.Info("setRecurrenceConferenceInfo single"); } ThisAddIn.g_log.Info("setRecurrenceConferenceInfo success"); }
/// <summary> /// 修改预约会议 /// </summary> /// <param name="tempAppt">相应的AppointmentItem</param> /// <param name="tempAppt">相应的MeetingItem,主要用于获取MeetingItem的人员</param> private int EditConference(ref AppointmentItem tempAppt, MeetingItem tempMeet) { ThisAddIn.g_log.Info("EditConference enter"); int nResult = PARAM_ERROR; UserProperty upConfInfo = tempAppt.UserProperties.Find(PROPERTY_NAME_CONF_INFO, Type.Missing); string strContent = upConfInfo.Value; if (string.IsNullOrEmpty(strContent)) { ThisAddIn.g_log.Error("ConfInfo UserProperty is empty!"); return nResult; } //修改会议 if (true == tempAppt.IsRecurring) { //获取ConferenceInfo属性 RecurrenceConfInfo recurrenceConfInfo = new RecurrenceConfInfo(); recurrenceConfInfo.confId = strContent; nResult = this.editRecurrenceTPConf(tempAppt, ref recurrenceConfInfo, tempMeet); } else { ConferenceInfo confInfo = this.GetConfInfoUserProperty(tempAppt); nResult = this.editTPConf(tempAppt, ref confInfo, tempMeet); } //2015-3-20 w00322557 智真或lync会场个数小于2,直接透传产品错误码信息 ThisAddIn.g_log.Info(string.Format("EditConference exit with {0}", nResult)); return nResult; }
/// <summary> /// 创建预约会议 /// </summary> /// <param name="tempAppt">相应的AppointmentItem</param> private int CreateConference(AppointmentItem tempAppt, MeetingItem meetingItem) { int nResult = PARAM_ERROR; //2014-8-21 wangpai 预约智真会议的 Outlook.UserProperty property = tempAppt.UserProperties.Find(ThisAddIn.PROPERTY_ENTER_FROM_SELF, Type.Missing); if (property != null) { property.Value = true; } else { property = tempAppt.UserProperties.Add(ThisAddIn.PROPERTY_ENTER_FROM_SELF, OlUserPropertyType.olYesNo, Type.Missing, Type.Missing); property.Value = true; } if (true == tempAppt.IsRecurring) { nResult = this.scheduleRecurrenceTPConf(ref tempAppt); } else { nResult = this.scheduleTPConf(tempAppt); } return nResult; }
public JoinClassControl(JoinClassView view, MeetingItem item) { InitializeComponent(); DataContext = new JoinClassControlViewModel(view, this, item); }
/// <summary> /// 修改周期性智真会议 /// </summary> /// <returns>native接口返回值</returns> private int editRecurrenceTPConf(AppointmentItem ai, ref RecurrenceConfInfo ConfInfo, MeetingItem meetingItem) { ThisAddIn.g_log.Info("editRecurrenceTPConf enter"); Inspector ins = ai.GetInspector; string accessCode = null; List<SiteInfo> siteInfos = new List<SiteInfo>(); //编辑周期会议中单个子会议 DateTime? date = null; if (OlRecurrenceState.olApptException == ai.RecurrenceState || OlRecurrenceState.olApptOccurrence == ai.RecurrenceState) { UserProperty upRightBeginTime = ai.UserProperties.Find(PROPERTY_RIGHT_BEGIN_TIME, Type.Missing); string val = upRightBeginTime.Value; List<RecurrenceAppoint> appointList = XmlHelper.Desrialize<List<RecurrenceAppoint>>(val); foreach (RecurrenceAppoint Rappoint in appointList) { if (Rappoint.AppointDate.Equals(ai.Start.ToShortDateString())) { string s = string.Format("{0} {1}", Rappoint.AppointDate, Rappoint.AppointTime); date = DateTime.Parse(s).ToUniversalTime(); break; } } if (date == null)//证明修改了时间 { return ERROR_CODE_CHANGE_DATE; } setRecurrenceConferenceInfo(ref ConfInfo, ai, true); } else { setRecurrenceConferenceInfo(ref ConfInfo, ai, false); } TPOASDKResponse<RecurrenceConfInfo> responseRecurrence = null; int resultCode = -1; //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号” //string strAccountName = ThisAddIn.g_AccountInfo.strUserName; Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser(); string strOutlookAccount = string.Empty; if (mainUser != null) { strOutlookAccount = mainUser.PrimarySmtpAddress; } string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount); string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD; string strServerAddress = ThisAddIn.g_AccountInfo.strServer; ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName)); ThisAddIn.g_log.Debug("PWD is: ******"); ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress)); try { //密码不存在,返回 if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD)) { ThisAddIn.g_log.Info("pwd is null"); MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD")); } ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress); responseRecurrence = conferenceServiceEx.editRecurrenceConference(ConfInfo, date); //已关联 resultCode = responseRecurrence.resultCode; } catch (System.Exception ex) { ThisAddIn.g_log.Error(string.Format("editRecurrenceTPConf exception with: {0}", ex.Message)); return PARAM_ERROR; } if (0 == resultCode) { //预约成功,将返回的会议信息作为属性保存 if (string.IsNullOrEmpty(ai.Subject)) { ai.Subject = ConfInfo.name; } ConferenceInfo confInfo = null; if (responseRecurrence != null) { //预约成功,将返回的confId作为属性保存 RecurrenceConfInfo retConfInfo = responseRecurrence.result; //2014/10/21 测试 confInfo = (ConferenceInfo)retConfInfo; //2014/10/14 新增测试 List<RecurrenceAppoint> retConfInfoArray = new List<RecurrenceAppoint>(); ArrayList tempCon = new ArrayList(); try { RecurrenceAppoint appo = null; for (int i = 0; i < retConfInfo.siteAccessInfos.Length; i++) { DateTime time = retConfInfo.siteAccessInfos[i].beginTime.ToLocalTime(); if (!tempCon.Contains(time)) { tempCon.Add(time); appo = new RecurrenceAppoint(); appo.AppointDate = time.ToShortDateString(); appo.AppointTime = time.ToLongTimeString(); appo.AccessCode = retConfInfo.siteAccessInfos[i].confAccessCode; //2015-6-17 w00322557 保存会场 appo.AppointSites = retConfInfo.sites[i].name + ","; retConfInfoArray.Add(appo); } else { appo.AppointSites += retConfInfo.sites[i].name + ","; } ThisAddIn.g_log.Info(string.Format("Edit RecurrenceAppoint sites name: {0}", retConfInfo.sites[i].name)); //保存当天会议的接入码 if (time.ToString("yyyy-MM-dd HH:mm") == ai.Start.ToString("yyyy-MM-dd HH:mm")) { accessCode = retConfInfo.siteAccessInfos[i].confAccessCode; SiteInfo info = new SiteInfo(); //info.name = retConfInfo.siteAccessInfos[i].uri; //siteInfos.Add(info); //2014/10/21 测试 info.name = confInfo.sites[i].name; siteInfos.Add(info); } } } catch (System.Exception ex) { ThisAddIn.g_log.Error(string.Format("editRecurrenceTPConf exception: {0}", ex.Message)); } //SaveRecurrenceReturnUserProperties(retConfInfo, ai,retConfInfoArray); //HTML模板 Microsoft.Office.Interop.Word.Document objDoc = ins.WordEditor as Microsoft.Office.Interop.Word.Document; if (null != objDoc) { string strFilePath = string.Empty; strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage)); if (!File.Exists(strFilePath)) { ThisAddIn.g_log.Error("notification file path not exist."); return PARAM_ERROR; } //读取会议邮件通知模板内容 string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8")); //2014/10/16 测试 string strNotify; if (OlRecurrenceState.olApptException == ai.RecurrenceState)//证明修改的是周期会议的子会议 { //传接入码 confInfo.accessCode = accessCode; //传会场 SiteInfo[] infos = siteInfos.ToArray(); confInfo.sites = infos; strNotify = this.replaceContentsInTemplate(ai, textTemplate, ref confInfo); SaveRecuConfReturnUserProperties(retConfInfo, ai, retConfInfoArray); } else { SaveRecurrenceReturnUserProperties(retConfInfo, ai, retConfInfoArray); strNotify = this.replaceContentsInTemplateRecurrence(ai, textTemplate, ref retConfInfo); } //将会议通知模板数据拷贝/粘贴到文档中 Clipboard.Clear(); VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify); object html = Clipboard.GetData(DataFormats.Html); ThisAddIn.g_log.Info("edit recurrence paste enter"); objDoc.Range().WholeStory(); try { objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault); } catch (System.Exception ex) { ThisAddIn.g_log.Error(ex.Message); } ThisAddIn.g_log.Info("edit recurrence paste end"); } } SendRecipientsInfo(ai, meetingItem); MessageBoxTimeOut mes = new MessageBoxTimeOut(); string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_MODIFY")); mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000); } else { //返回错误码,计入日志 ThisAddIn.g_log.Error(string.Format("editRecurrenceTPConf return: {0}", responseRecurrence.resultCode.ToString())); } ThisAddIn.g_log.Info("editRecurrenceTPConf exit"); return resultCode; }
private SyncResult synchronize() { Console console = Forms.Main.Instance.Console; console.Update("Finding Calendar Entries", Console.Markup.mag_right, newLine: false); List <AppointmentItem> outlookEntries = null; List <Event> googleEntries = null; try { #region Read Outlook items console.Update("Scanning Outlook calendar..."); outlookEntries = OutlookOgcs.Calendar.Instance.GetCalendarEntriesInRange(false); console.Update(outlookEntries.Count + " Outlook calendar entries found.", Console.Markup.sectionEnd, newLine: false); if (CancellationPending) { return(SyncResult.UserCancelled); } #endregion #region Read Google items console.Update("Scanning Google calendar..."); try { googleEntries = GoogleOgcs.Calendar.Instance.GetCalendarEntriesInRange(); } catch (AggregateException agex) { OGCSexception.AnalyseAggregate(agex); } catch (Google.Apis.Auth.OAuth2.Responses.TokenResponseException ex) { OGCSexception.AnalyseTokenResponse(ex, false); return(SyncResult.Fail); } catch (System.Net.Http.HttpRequestException ex) { OGCSexception.Analyse(ex); ex.Data.Add("OGCS", "ERROR: Unable to connect to the Google calendar. Please try again."); throw ex; } catch (System.Exception ex) { OGCSexception.Analyse(ex); ex.Data.Add("OGCS", "ERROR: Unable to connect to the Google calendar."); if (OGCSexception.GetErrorCode(ex) == "0x8013153B") //ex.Message == "A task was canceled." - likely timed out. { ex.Data["OGCS"] += " Please try again."; } throw ex; } Recurrence.Instance.SeparateGoogleExceptions(googleEntries); if (Recurrence.Instance.GoogleExceptions != null && Recurrence.Instance.GoogleExceptions.Count > 0) { console.Update(googleEntries.Count + " Google calendar entries found."); console.Update(Recurrence.Instance.GoogleExceptions.Count + " are exceptions to recurring events.", Console.Markup.sectionEnd, newLine: false); } else { console.Update(googleEntries.Count + " Google calendar entries found.", Console.Markup.sectionEnd, newLine: false); } if (CancellationPending) { return(SyncResult.UserCancelled); } #endregion #region Normalise recurring items in sync window console.Update("Total inc. recurring items spanning sync date range..."); //Outlook returns recurring items that span the sync date range, Google doesn't //So check for master Outlook items occurring before sync date range, and retrieve Google equivalent for (int o = outlookEntries.Count - 1; o >= 0; o--) { log.Fine("Processing " + (o + 1) + "/" + outlookEntries.Count); AppointmentItem ai = null; try { if (outlookEntries[o] is AppointmentItem) { ai = outlookEntries[o]; } else if (outlookEntries[o] is MeetingItem) { log.Info("Calendar object appears to be a MeetingItem, so retrieving associated AppointmentItem."); MeetingItem mi = outlookEntries[o] as MeetingItem; outlookEntries[o] = mi.GetAssociatedAppointment(false); ai = outlookEntries[o]; } else { log.Warn("Unknown calendar object type - cannot sync it."); skipCorruptedItem(ref outlookEntries, outlookEntries[o], "Unknown object type."); outlookEntries[o] = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(outlookEntries[o]); continue; } } catch (System.Exception ex) { log.Warn("Encountered error casting calendar object to AppointmentItem - cannot sync it."); log.Debug(ex.Message); skipCorruptedItem(ref outlookEntries, outlookEntries[o], ex.Message); outlookEntries[o] = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(outlookEntries[o]); ai = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(ai); continue; } //Now let's check there's a start/end date - sometimes it can be missing, even though this shouldn't be possible!! String entryID; try { entryID = outlookEntries[o].EntryID; DateTime checkDates = ai.Start; checkDates = ai.End; } catch (System.Exception ex) { log.Warn("Calendar item does not have a proper date range - cannot sync it."); log.Debug(ex.Message); skipCorruptedItem(ref outlookEntries, outlookEntries[o], ex.Message); outlookEntries[o] = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(outlookEntries[o]); ai = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(ai); continue; } if (ai.IsRecurring && ai.Start.Date < Settings.Instance.SyncStart && ai.End.Date < Settings.Instance.SyncStart) { //We won't bother getting Google master event if appointment is yearly reoccurring in a month outside of sync range //Otherwise, every sync, the master event will have to be retrieved, compared, concluded nothing's changed (probably) = waste of API calls RecurrencePattern oPattern = ai.GetRecurrencePattern(); try { if (oPattern.RecurrenceType.ToString().Contains("Year")) { log.Fine("It's an annual event."); Boolean monthInSyncRange = false; DateTime monthMarker = Settings.Instance.SyncStart; while (Convert.ToInt32(monthMarker.ToString("yyyyMM")) <= Convert.ToInt32(Settings.Instance.SyncEnd.ToString("yyyyMM")) && !monthInSyncRange) { if (monthMarker.Month == ai.Start.Month) { monthInSyncRange = true; } monthMarker = monthMarker.AddMonths(1); } log.Fine("Found it to be " + (monthInSyncRange ? "inside" : "outside") + " sync range."); if (!monthInSyncRange) { outlookEntries.Remove(ai); log.Fine("Removed."); continue; } } Event masterEv = Recurrence.Instance.GetGoogleMasterEvent(ai); if (masterEv != null && masterEv.Status != "cancelled") { Event cachedEv = googleEntries.Find(x => x.Id == masterEv.Id); if (cachedEv == null) { googleEntries.Add(masterEv); } else { if (masterEv.Updated > cachedEv.Updated) { log.Debug("Refreshing cache for this Event."); googleEntries.Remove(cachedEv); googleEntries.Add(masterEv); } } } } catch (System.Exception ex) { console.Update("Failed to retrieve master for Google recurring event outside of sync range.", Console.Markup.error); throw ex; } finally { oPattern = (RecurrencePattern)OutlookOgcs.Calendar.ReleaseObject(oPattern); } } //Completely dereference object and retrieve afresh (due to GetRecurrencePattern earlier) ai = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(ai); OutlookOgcs.Calendar.Instance.IOutlook.GetAppointmentByID(entryID, out ai); outlookEntries[o] = ai; } console.Update("Outlook " + outlookEntries.Count + ", Google " + googleEntries.Count); GoogleOgcs.Calendar.ExportToCSV("Outputting all Events.", "google_events.csv", googleEntries); OutlookOgcs.Calendar.ExportToCSV("Outputting all Appointments.", "outlook_appointments.csv", outlookEntries); if (CancellationPending) { return(SyncResult.UserCancelled); } #endregion Boolean success = true; String bubbleText = ""; if (Settings.Instance.SyncDirection != Direction.GoogleToOutlook) { success = outlookToGoogle(outlookEntries, googleEntries, ref bubbleText); if (CancellationPending) { return(SyncResult.UserCancelled); } } if (!success) { return(SyncResult.Fail); } if (Settings.Instance.SyncDirection != Direction.OutlookToGoogle) { if (bubbleText != "") { bubbleText += "\r\n"; } success = googleToOutlook(googleEntries, outlookEntries, ref bubbleText); if (CancellationPending) { return(SyncResult.UserCancelled); } } if (bubbleText != "") { Forms.Main.Instance.NotificationTray.ShowBubbleInfo(bubbleText); } return(SyncResult.OK); } finally { for (int o = outlookEntries.Count() - 1; o >= 0; o--) { outlookEntries[o] = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(outlookEntries[o]); outlookEntries.RemoveAt(o); } } }
/// <summary> /// 修改非周期性智真会议 /// </summary> /// <returns>native接口返回值</returns> private int editTPConf(AppointmentItem ai, ref ConferenceInfo ConfInfo, MeetingItem meetingItem) { ThisAddIn.g_log.Info("editTPConf enter"); Inspector ins = ai.GetInspector; setConferenceInfo(ref ConfInfo, ai); ConfInfo.accessCode = string.Empty; TPOASDKResponse<ConferenceInfo> response = null; int resultCode = -1; //非周期性会议 //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号” //string strAccountName = ThisAddIn.g_AccountInfo.strUserName; Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser(); string strOutlookAccount = string.Empty; if (mainUser != null) { strOutlookAccount = mainUser.PrimarySmtpAddress; } string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount); string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD; string strServerAddress = ThisAddIn.g_AccountInfo.strServer; ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName)); ThisAddIn.g_log.Debug("PWD is: ******"); ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress)); try { //密码不存在,返回 if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD)) { ThisAddIn.g_log.Info("pwd is null"); MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD")); } ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress); response = conferenceServiceEx.editScheduledConf(ConfInfo); resultCode = response.resultCode; } catch (System.Exception ex) { ThisAddIn.g_log.Error(string.Format("editScheduledConf exception because :{0} ", ex.Message)); return PARAM_ERROR; } if (0 == resultCode) { if (string.IsNullOrEmpty(ai.Subject)) { ai.Subject = ConfInfo.name; } //修改成功,将返回的confId作为属性保存 if (response != null)//第一次执行的 { ConferenceInfo retConfInfo = response.result; SaveReturnUserProperties(retConfInfo, ai); //HTML模板 Microsoft.Office.Interop.Word.Document objDoc = ins.WordEditor as Microsoft.Office.Interop.Word.Document; if (null != objDoc) { //读入会议通知模板数据 string strFilePath = string.Empty; strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage)); if (!File.Exists(strFilePath)) { ThisAddIn.g_log.Error("notification file path not exist."); return PARAM_ERROR; } string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8")); string strNotify = this.replaceContentsInTemplate(ai, textTemplate, ref retConfInfo); //将会议通知模板数据拷贝/粘贴到文档中 Clipboard.Clear(); VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify); object html = Clipboard.GetData(DataFormats.Html); ThisAddIn.g_log.Info("edit TP paste enter"); objDoc.Range().WholeStory(); try { objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault); } catch (System.Exception ex) { ThisAddIn.g_log.Error(ex.Message); } ThisAddIn.g_log.Info("edit TP paste end"); } } SendRecipientsInfo(ai, meetingItem); MessageBoxTimeOut mes = new MessageBoxTimeOut(); string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_MODIFY")); mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000); } else { //2014-5-13 返回码映射 ThisAddIn.g_log.Error(string.Format("editTPConf failed with error code: {0}", response.resultCode.ToString())); } ThisAddIn.g_log.Info("editTPConf exit"); return resultCode; }
/// <summary> /// 选择发送人员信息 /// </summary> /// <param name="ai"></param> /// <param name="meetingItem"></param> private void SendRecipientsInfo(AppointmentItem ai, MeetingItem meetingItem) { if (meetingItem != null) { //获取人员 Outlook.Recipients recipents = meetingItem.Recipients; //发送的是会议取消人员 if (meetingItem.Class.ToString().Equals("olMeetingCancellation")) { sendMailNotifications(ai, OperatorType.Cancel, recipents); } else if (meetingItem.Class.ToString().Equals("olMeetingRequest")) //发送的是会议增加人员 { sendMailNotifications(ai, OperatorType.Modify, recipents); } } }
/// <summary> /// テスト対象メソッドで使われる値のReturnsを設定するメソッド /// </summary> /// <param name="testRecNames">Recipientのアドレス</param> /// <param name="testRecSendable">RecipientのSendableプロパティ</param> /// <param name="testRecType">RecipientのType</param> /// <param name="item">選択されたitem</param> private void SubstituteRecProps(string[] testRecNames, bool[] testRecSendable, int[] testRecType, object item) { int i = 0; if (item is MailItem) { MailItem testItem = (MailItem)item; foreach (string testRec in testRecNames) { // テスト用Recipientのプロパティに値を設定 testItem.Recipients[i + 1].Address.Returns(testRecNames[i]); testItem.Recipients[i + 1].Sendable.Returns(testRecSendable[i]); testItem.Recipients[i + 1].Type.Returns(testRecType[i]); i++; } } else if (item is MeetingItem) { MeetingItem testItem = (MeetingItem)item; foreach (string testRec in testRecNames) { // テスト用Recipientのプロパティに値を設定 testItem.Recipients[i + 1].Address.Returns(testRecNames[i]); testItem.Recipients[i + 1].Sendable.Returns(testRecSendable[i]); testItem.Recipients[i + 1].Type.Returns(testRecType[i]); i++; } } else if (item is AppointmentItem) { AppointmentItem testItem = (AppointmentItem)item; foreach (string testRec in testRecNames) { // テスト用Recipientのプロパティに値を設定 testItem.Recipients[i + 1].Address.Returns(testRecNames[i]); testItem.Recipients[i + 1].Sendable.Returns(testRecSendable[i]); testItem.Recipients[i + 1].Type.Returns(testRecType[i]); i++; } } else if (item is SharingItem) { SharingItem testItem = (SharingItem)item; foreach (string testRec in testRecNames) { // テスト用Recipientのプロパティに値を設定 testItem.Recipients[i + 1].Address.Returns(testRecNames[i]); testItem.Recipients[i + 1].Sendable.Returns(testRecSendable[i]); testItem.Recipients[i + 1].Type.Returns(testRecType[i]); i++; } } }