Exemple #1
0
        /// <summary>
        /// 预约周期性智真会议
        /// </summary>
        /// <returns>native接口返回值</returns>
        private int scheduleRecurrenceTPConf(ref AppointmentItem ai)
        {
            ThisAddIn.g_log.Info("scheduleRecurrenceTPConf enter");
            Inspector ins = ai.GetInspector;

            RecurrenceConfInfo ConfInfo = new RecurrenceConfInfo();
            setRecurrenceConferenceInfo(ref ConfInfo, ai, false);

            //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));

            TPOASDKResponse<RecurrenceConfInfo> responseRecurrence = null;
            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.scheduleRecurrenceConference(ConfInfo);
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("scheduleRecurrenceTPConf exception,because {0}", ex.Message));
                return PARAM_ERROR;
            }

            if (0 == responseRecurrence.resultCode)
            {
                try
                {
                    //预约成功,将返回的confId作为属性保存
                    RecurrenceConfInfo retConfInfo = responseRecurrence.result;

                    //2014/10/14 新增测试
                    List<RecurrenceAppoint> retConfInfoArray = new List<RecurrenceAppoint>();
                    ArrayList tempCon = new ArrayList();
                    if (retConfInfo.siteAccessInfos != null)
                    {
                        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("RecurrenceAppoint sites name: {0}", retConfInfo.sites[i].name));
                        }
                    }

                    SaveRecurrenceReturnUserProperties(retConfInfo, ai, retConfInfoArray);

                    DateTime tmpBeginTime = retConfInfo.siteAccessInfos[0].beginTime.ToLocalTime();
                    if (ai.Start != tmpBeginTime)
                    {
                        RecurrencePattern recurrencePattern = ai.GetRecurrencePattern();
                        recurrencePattern.StartTime = DateTime.Parse(tmpBeginTime.ToShortTimeString());
                    }

                    if (string.IsNullOrEmpty(ai.Subject))
                    {
                        ai.Subject = retConfInfo.name;
                        ThisAddIn.g_log.Info(string.Format("outlook subject is empty. return subject is: {0}", retConfInfo.name));
                    }

                    //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.replaceContentsInTemplateRecurrence(ai, textTemplate, ref retConfInfo);

                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("schedule recurrence paste enter.");

                        object start = 0;
                        Range newRang = objDoc.Range(ref start, ref start);

                        int ioo = objDoc.Sections.Count;
                        Section sec = objDoc.Sections.Add(Type.Missing, Type.Missing);

                        sec.Range.InsertBreak(Type.Missing);//插入换行符

                        //2014/11/13 测试,防止异常,邮件体出现空白
                        for (int i = 0; i < 5; i++)
                        {
                            try
                            {
                                sec.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault);
                                break;
                            }
                            catch (System.Exception ex)
                            {
                                ThisAddIn.g_log.Error(ex.Message);
                                Thread.Sleep(500);
                            }
                        }

                        ThisAddIn.g_log.Info("schedule recurrence paste end");

                        #region 2014/11/3 注销,合并入SendMailNotification()
                        ThisAddIn.g_log.Info("schedule send mail enter.");

                        //MailItem email = this.Application.CreateItem(OlItemType.olMailItem);
                        //string smtpAddress = "";

                        //Outlook.Recipients recipients = ai.Recipients;
                        //foreach (Outlook.Recipient recipient in recipients)
                        //{
                        //    Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();

                        //    if (exchangeUser != null)
                        //    {
                        //        smtpAddress += exchangeUser.PrimarySmtpAddress + ";";//获取账户信息,作为默认第一个收件人
                        //    }
                        //    else
                        //    {
                        //        smtpAddress += recipient.Address + ";";//添加收件人地址
                        //    }
                        //}

                        //email.To = smtpAddress;  //收件人地址
                        //email.Subject = "[Successfully Scheduled]" + ai.Subject;
                        //email.BodyFormat = OlBodyFormat.olFormatHTML;//body格式
                        //email.HTMLBody = strNotify;

                        //((Outlook._MailItem)email).Send();//发送邮件

                        //ThisAddIn.g_log.Info("sendMailNotifications exit");
                        //ThisAddIn.g_log.Info("schedule send mail exit.");
                        #endregion

                        Outlook.Recipients recipients = ai.Recipients;
                        sendMailNotifications(ai, OperatorType.Schedule, recipients);

                        //3's
                        MessageBoxTimeOut mes = new MessageBoxTimeOut();
                        string strFormat = GlobalResourceClass.getMsg("OPERATOR_MESSAGE");
                        string messageBody = string.Format(strFormat, GlobalResourceClass.getMsg("OPERATOR_TYPE_SCHEDULE"));
                        mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                    }
                }
                catch (System.Exception ex)
                {
                    ThisAddIn.g_log.Error(string.Format("recurrence email notification error,because {0}.", ex.Message));
                }
            }
            else
            {
                //
                ThisAddIn.g_log.Info(string.Format("scheduleRecurrenceTPConf failed with: {0}", responseRecurrence.resultCode.ToString()));
            }

            ThisAddIn.g_log.Info("scheduleRecurrenceTPConf exit");
            return responseRecurrence.resultCode;
        }
Exemple #2
0
        /// <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;
        }