Exemplo n.º 1
0
        /// <summary>
        /// 预约非周期性智真会议
        /// </summary>
        /// <returns>native接口返回值</returns>
        private int scheduleTPConf(AppointmentItem ai)
        {
            ThisAddIn.g_log.Info("scheduleTPConf enter");
            //2014-4-29
            Inspector ins = ai.GetInspector;

            ConferenceInfo ConfInfo = new ConferenceInfo();
            setConferenceInfo(ref ConfInfo, ai);

            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            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<ConferenceInfo> response = 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);
                response = conferenceServiceEx.scheduleConf(ConfInfo);
                ThisAddIn.g_log.Info(string.Format("scheduleConf return: {0}", response.resultCode));
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("scheduleConf exception:{0}", ex.Message));
                return PARAM_ERROR;
            }

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

                SaveReturnUserProperties(retConfInfo, ai);

                if (string.IsNullOrEmpty(ai.Subject))
                {
                    ai.Subject = ConfInfo.name;
                }

                //HTML模板
                Microsoft.Office.Interop.Word.Document objDoc = ins.WordEditor as Microsoft.Office.Interop.Word.Document;
                if (null != objDoc)
                {
                    try
                    {
                        //获取当前语言通知模板的路径
                        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);

                        //paste notification to body
                        ThisAddIn.g_log.Info("schedule paste enter");

                        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 paste end");

                        //send email
                        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("email notification error,because: {0},{1},{2}.", ex.Source, ex.Message, ex.StackTrace));
                    }
                }
            }
            else
            {
                //2014-5-13 返回码映射
                ThisAddIn.g_log.Error(string.Format("scheduleConf failed with return code:{0}", response.resultCode.ToString()));
            }
            ThisAddIn.g_log.Info("scheduleTPConf exit");
            return response.resultCode;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除周期会议的子会议
        /// </summary>
        /// <param name="tempAppt"></param>
        /// <param name="recipients"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        private int DeleteConferenceWithTime(AppointmentItem tempAppt, Recipients recipients, DateTime date)
        {
            ThisAddIn.g_log.Info(string.Format("Delete Conference ,Time is {0}", date.ToString()));

            int resultCode = PARAM_ERROR;
            object confInfo = null;
            string confId = "";

            confInfo = this.GetConfInfoUserProperty(tempAppt);
            if (null == confInfo)
            {
                return PARAM_ERROR;
            }
            confId = ((ConferenceInfo)confInfo).confId;

            //获取已预约的会议信息
            //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);
                resultCode = conferenceServiceEx.delScheduledConf(confId, date.ToUniversalTime());
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("DeleteConferenceWithTime exception: {0}", ex.Message));
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                ThisAddIn.g_log.Info(String.Format("delScheduledConf date: {0}", date.ToString()));
                ThisAddIn.g_log.Info(String.Format("delScheduledConf result code:{0:D}", resultCode));

                //2014/10/18 测试
                if (date != null)//删除单个子会议,修改模板
                {
                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = tempAppt.GetInspector.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"));

                        ConferenceInfo cInfo = new ConferenceInfo();
                        string strNotify = replaceContentsInTemplate(tempAppt, textTemplate, ref cInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("delete single 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("delete single recurrence paste end");
                    }
                }
                if (recipients == null)
                {
                    recipients = tempAppt.Recipients;
                }

                sendMailNotifications(tempAppt, OperatorType.Cancel, recipients);

                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_CANCEL"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                return 0;
            }
            else
            {
                ThisAddIn.g_log.Error(String.Format("delScheduledConf failed:{0:D}", resultCode));
                return resultCode;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 删除预约会议
        /// </summary>
        /// <param name="tempAppt">相应的AppointmentItem</param>
        private int DeleteConference(AppointmentItem tempAppt, Recipients recipients)
        {
            int resultCode = PARAM_ERROR;
            object confInfo = null;
            string confId = "";
            DateTime? date = null;

            confInfo = this.GetConfInfoUserProperty(tempAppt);
            if (null == confInfo)
            {
                return PARAM_ERROR;
            }
            confId = ((ConferenceInfo)confInfo).confId;

            //获取已预约的会议信息
            //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));

            if (OlRecurrenceState.olApptException == tempAppt.RecurrenceState)//删除单个
            {
                date = tempAppt.Start.ToUniversalTime();
            }

            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);
                resultCode = conferenceServiceEx.delScheduledConf(confId, date);
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(ex.Message);
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                ThisAddIn.g_log.Info(String.Format("delScheduledConf date: {0}", date.ToString()));
                ThisAddIn.g_log.Info(String.Format("delScheduledConf success:{0:D}", resultCode));

                //2014/10/18 测试
                if (date != null)//删除单个子会议,修改模板
                {
                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = tempAppt.GetInspector.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"));

                        ConferenceInfo cInfo = new ConferenceInfo();

                        //2015-6-17 w00322557 增加解析会场
                        try
                        {
                            UserProperty upRightBeginTime = tempAppt.UserProperties.Find(PROPERTY_RIGHT_BEGIN_TIME, Type.Missing);
                            if (upRightBeginTime != null)
                            {
                                string val = upRightBeginTime.Value;

                                List<RecurrenceAppoint> appointList = XmlHelper.Desrialize<List<RecurrenceAppoint>>(val);
                                foreach (RecurrenceAppoint Rappoint in appointList)
                                {

                                    if (Rappoint.AppointDate.Equals(date.Value.ToLocalTime().ToShortDateString()) &&
                                        Rappoint.AppointTime.Equals(date.Value.ToLocalTime().ToLongTimeString()))
                                    {
                                        string sSites = Rappoint.AppointSites.TrimEnd(',');
                                        string[] varSites = sSites.Split(',');
                                        cInfo.sites = new SiteInfo[varSites.Length];
                                        int iCount = 0;
                                        foreach (string sSite in varSites)
                                        {
                                            SiteInfo site = new SiteInfo();
                                            site.name = sSite;
                                            cInfo.sites[iCount] = site;
                                            iCount++;
                                        }
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(string.Format("Parse site error with: {0}", ex.Message));
                        }

                        string strNotify = replaceContentsInTemplate(tempAppt, textTemplate, ref cInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("delete single 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("delete single recurrence paste end");
                    }
                }
                if (recipients == null)
                {
                    recipients = tempAppt.Recipients;
                }

                sendMailNotifications(tempAppt, OperatorType.Cancel, recipients);

                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_CANCEL"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                return 0;
            }
            else
            {
                ThisAddIn.g_log.Error(String.Format("delScheduledConf failed:{0:D}", resultCode));
                return resultCode;
            }
        }