Ejemplo n.º 1
0
 private static bool isChangedByEWS(SchedulingInfo schedulingInfo)
 {
     String lastInfo = schedulingInfo.lastHashInfo;
     String lastRecurrenceHashInfo = schedulingInfo.lastRecurrenceHashInfo;
     using (HashAlgorithm hashAlg = HashAlgorithm.Create())
     {
         // Compare the hashes.
         if (lastInfo.Equals(GetHashString(schedulingInfo, schedulingInfo.subject))
             && lastRecurrenceHashInfo.Equals(schedulingInfo.recurrenceHashInfo))
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
        void RvScopiaMeeting_OnResolvedMessage(ResolvedMessageEventSource source, QueuedMessageEventArgs args){
            this.emailMessage = args.MailItem.Message;

            if (this.emailMessage == null || this.emailMessage.TnefPart == null) {
                return;
            }

            long now = DateTime.UtcNow.Ticks;
            SchedulingInfo schedulingInfo = new SchedulingInfo();
            schedulingInfo.subject = args.MailItem.Message.Subject;
            schedulingInfo.delegatorEmailAddr = args.MailItem.Message.From.NativeAddress;
            RvLogger.DebugWrite("Enter transport agent, from: " + schedulingInfo.delegatorEmailAddr + ", subject: " + schedulingInfo.subject);

            try
            {
                this.agentAsyncContext = this.GetAgentAsyncContext();
                schedulingInfo.requestType = this.getRequestType(this.emailMessage.MapiMessageClass);
                //Reject all meeting type except request and cancel.
                if (RequestType.Other == schedulingInfo.requestType)
                {
                    RvLogger.DebugWrite("Reject other request type: " + this.emailMessage.MapiMessageClass);
                    return;
                }
                RvMailParser parser = new RvMailParser(this);
                try
                {
                    parser.parseTnefSimple(args.MailItem, schedulingInfo);
                }
                catch (Exception exceptionParseMail)
                {
                    RvLogger.DebugWrite("Fail to parse mail.");
                    RvLogger.DebugWrite(exceptionParseMail.Message);
                    RvLogger.DebugWrite(exceptionParseMail.StackTrace);
                    return;
                }
                
                //Reject forwarded appointment
                if (!string.IsNullOrEmpty(schedulingInfo.subjectPrefix) && "FW:".Equals(schedulingInfo.subjectPrefix))
                {
                    RvLogger.DebugWrite("Reject forward request type");
                    return;
                }

                if (schedulingInfo.recurrencePattern != null){
                    schedulingInfo.recurrenceHashInfo = RvScopiaMeeting.getHashString4Str(schedulingInfo.recurrencePattern.getStringForHash());
                    schedulingInfo.recurrencePattern.startDate = schedulingInfo.startDate;
                    schedulingInfo.recurrencePattern.endDate = schedulingInfo.endDate;
                }

                if (null == schedulingInfo.emailMessage) {
                    RvLogger.DebugWrite("null == schedulingInfo.emailMessage================================================");
                    return; 
                }

                if (!isScopia(schedulingInfo))
                {
                    RvLogger.DebugWrite("This is not a SCOPIA meeting");
                    return;
                }

                parseRecipentsChanged(schedulingInfo);
                if (schedulingInfo.isRecipentsChanged)
                    if (schedulingInfo.requestType == RequestType.CancelMeeting)
                    {
                        schedulingInfo.requestType = RequestType.CreateMeeting;
                        schedulingInfo.isAddRecipents = false;
                        schedulingInfo.subject = schedulingInfo.subject.Substring(schedulingInfo.subjectPrefix.Length + 1);
                        Thread.Sleep(HOW_MANY_SECONDS_WAIT_FOR_FOLLOWING_REQUEST * 1000);
                    }else
                        schedulingInfo.isAddRecipents = true;

                if (RvScopiaMeeting.SERVER_ACCOUNT.Equals(schedulingInfo.senderEmailAddr))
                {
                    RvLogger.DebugWrite("Send a email back to notify the sender this mail is failed to send out.");
                    return;
                }

                //when modify a recurrence, to make sure the modified ocurrence request is later than the recurrence request.
                if (schedulingInfo.meetingType == MeetingType.Ocurrence)
                    Thread.Sleep(HOW_MANY_SECONDS_WAIT_FOR_FOLLOWING_REQUEST * 1000);

                icm.XmlApi.scheduleReportType result = changeMail(source, args, schedulingInfo, now);
                if (null != result && result.Success && isCreateMeetingRequest(schedulingInfo))
                {
                    Dictionary<string, byte[]> attachmentsdata = null;
                    if (this.emailMessage.Attachments.Count > 0)
                    {
                        attachmentsdata = new Dictionary<string, byte[]>(this.emailMessage.Attachments.Count);
                        for (int i = 0; i < this.emailMessage.Attachments.Count; i++)
                        {
                            Attachment attachment = this.emailMessage.Attachments[i];
                            Stream readStream = attachment.GetContentReadStream();
                            byte[] bytes = null;
                            if (readStream.Length > 0) {
                                bytes = new byte[readStream.Length];
                                readStream.Read(bytes, 0, bytes.Length);
                            } else
                                bytes = Encoding.ASCII.GetBytes(" ");
                            attachmentsdata.Add(attachment.FileName, bytes);
                        }
                    }
                    
                    parser.changeBodyOfTnef(args.MailItem.Message.TnefPart, schedulingInfo);

                    if (attachmentsdata != null)
                    {
                        foreach (KeyValuePair<string, byte[]> attachmentdata in attachmentsdata)
                        {
                            Attachment attachment = this.emailMessage.Attachments.Add(attachmentdata.Key);
                            Stream attachmentStream = attachment.GetContentWriteStream();
                            attachmentStream.Write(attachmentdata.Value, 0, attachmentdata.Value.Length);
                            attachmentStream.Flush();
                            attachmentStream.Close();
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                RvLogger.DebugWrite(ex.Message);
                RvLogger.DebugWrite(ex.StackTrace);
                string baseFailCode = ex.Message;
                sendBackAMail(source, schedulingInfo, baseFailCode);
            }
            finally
            {
                RvLogger.DebugWrite("Start to agentAsyncContext.Complete()================================================");
                agentAsyncContext.Complete();
                RvLogger.DebugWrite("Complete agentAsyncContext.Complete()================================================");
                RvLogger.DebugWrite("Leave transport agent, from: " + schedulingInfo.delegatorEmailAddr + ", subject: " + schedulingInfo.subject);
            }
        }
Ejemplo n.º 3
0
        private void AddRecurrenceInfo(icm.XmlApi.conferenceType conference, SchedulingInfo schedulingInfo)
        {
            if (conference == null)
                throw new ArgumentNullException("conference");

            RecurrencePattern recurrencePattern = schedulingInfo.recurrencePattern;
            //StringBuilder patternString = new StringBuilder("");
            //patternString.Append(appointment.Start.ToUniversalTime()).Append(appointment.End.ToUniversalTime());
            if (recurrencePattern.hasEnd)
            {
                conference.RecurrenceEnd = new icm.XmlApi.conferenceTypeRecurrenceEnd();
                conference.RecurrenceEnd.Item = recurrencePattern.numberOfOccurrences;
                //patternString.Append(recurrence.NumberOfOccurrences).Append(recurrence.StartDate.ToUniversalTime());
                RvLogger.InfoWrite("Recurrence will be scheduled with end date " + recurrencePattern.endDate + " - Occurrences [" + recurrencePattern.numberOfOccurrences + "].");
            }
            else
                RvLogger.InfoWrite("Recurrence will be scheduled without end date.");

            if (recurrencePattern.patternType == PatternType.DAILY)
            {
                icm.XmlApi.recurrenceDailyType recurrenceDailyType = new icm.XmlApi.recurrenceDailyType();
                if (recurrencePattern.dailyInterval != -1)
                    recurrenceDailyType.Item = recurrencePattern.dailyInterval;
                conference.Item = recurrenceDailyType;
                //patternString.Append("daily").Append(dailyPattern.Interval);
            }
            else if (recurrencePattern.patternType == PatternType.WEEKLY)
            {
                //patternString.Append("weekly").Append(weeklyPattern.Interval);
                if (recurrencePattern.weeklyInterval == 0)
                {
                    icm.XmlApi.recurrenceDailyType
                        recurrenceDailyType = new icm.XmlApi.recurrenceDailyType();
                    recurrenceDailyType.Item = true;

                    conference.Item = recurrenceDailyType;
                }
                else
                {
                    icm.XmlApi.recurrenceWeeklyType
                        recurrenceWeeklyType = new icm.XmlApi.recurrenceWeeklyType();
                    recurrenceWeeklyType.NumberOfEveryWeek = recurrencePattern.weeklyInterval;
                    recurrenceWeeklyType.DayOfWeek = recurrencePattern.daysOfWeek;
                    conference.Item = recurrenceWeeklyType;
                }

            }
            else if (recurrencePattern.patternType == PatternType.MONTHLY)
            {
                icm.XmlApi.recurrenceMonthlyType recurrenceMonthlyType = new icm.XmlApi.recurrenceMonthlyType();
                recurrenceMonthlyType.NumberOfEveryMonth = recurrencePattern.monthlyInterval;
                recurrenceMonthlyType.Item = recurrencePattern.dayOfMonth;
                conference.Item = recurrenceMonthlyType;

                    //patternString.Append("monthly").Append(monthlyPattern.Interval).Append(monthlyPattern.DayOfMonth);
            }
            else if (recurrencePattern.patternType == PatternType.RELATIVE_MONTHLY)
            {                  
                icm.XmlApi.recurrenceMonthlyType
                    recurrenceMonthlyType = new icm.XmlApi.recurrenceMonthlyType();

                icm.XmlApi.recurrenceMonthlyTypeDayOfNumberOfEveryMonth
                    dayOfNumberOfEveryMonth = new icm.XmlApi.recurrenceMonthlyTypeDayOfNumberOfEveryMonth();

                dayOfNumberOfEveryMonth.WeekOfMonth = recurrencePattern.weekOfMonth;

                dayOfNumberOfEveryMonth.DayOfWeek = recurrencePattern.dayOfWeekOfMonthly;


                recurrenceMonthlyType.NumberOfEveryMonth = recurrencePattern.monthlyInterval;
                recurrenceMonthlyType.Item = dayOfNumberOfEveryMonth;

                conference.Item = recurrenceMonthlyType;

                //patternString.Append("relativeMonthly").Append(monthlyPattern.DayOfTheWeekIndex)
                //    .Append(monthlyPattern.DayOfTheWeek)
                //    .Append(monthlyPattern.Interval);
            }
            else if (recurrencePattern.patternType == PatternType.YEARLY ||
                recurrencePattern.patternType == PatternType.RELATIVE_YEARLY)
            {
                RvLogger.FatalWrite("Trying to add NOT SUPPORTED yearly recurrence.");
            }else
                RvLogger.FatalWrite("Trying to add NOT SUPPORTED UNKNOWN recurrence.");

            //return patternString.ToString();
        }
Ejemplo n.º 4
0
 private static string GetHashString(SchedulingInfo schedulingInfo, string subject)
 {
     string startDate = schedulingInfo.startDate.ToUniversalTime().ToString();
     string endDate = schedulingInfo.endDate.ToUniversalTime().ToString();
     string location = schedulingInfo.location;
     string resources = schedulingInfo.outlookResources;
     string recipients = schedulingInfo.recipents;
     string str = subject + startDate + endDate + location + resources + recipients;
     return RvScopiaMeeting.getHashString4Str(str);
 }
Ejemplo n.º 5
0
        private icm.XmlApi.scheduleReportType changeMail(QueuedMessageEventSource source, QueuedMessageEventArgs args, SchedulingInfo schedulingInfo, long now)
        {
            icm.XmlApi.scheduleReportType result = null;
            icm.XmlApi.userType userInfo = null;
            string dialingInfoStr = null;
            bool isCreate = isCreateMeetingRequest(schedulingInfo);
            webServiceData.ExchangeService service = null;

            try
            {
                userInfo = getUserInfo(schedulingInfo.delegatorEmailAddr);
                if (null == userInfo)
                    throw new ScopiaMeetingAddInException(ScopiaMeetingAddInException.ERROR_MESSAGE_USER_NOT_FOUND);
                else if (!userInfo.Schedulable)
                    throw new ScopiaMeetingAddInException(ScopiaMeetingAddInException.ERROR_MESSAGE_HAVE_NO_PERMISSION);
                else if (isCreate)
                {
                    service = getWebService(schedulingInfo);
                    if(null == service)
                        throw new ScopiaMeetingAddInException(ScopiaMeetingAddInException.ERROR_MESSAGE_INCORRECT_EWS_CONFIGURATION);
                }
            }
            catch (Exception ex) {
                sendBackAMail(source, schedulingInfo, ex.Message);
                if (IS_DELETE_ERROR) {
                    if (null == service)
                        service = getWebService(schedulingInfo);
                    if (null == service)
                        return result;
                    result = new icm.XmlApi.scheduleReportType();
                    result.Success = false;
                    result.Detail = "";
                    //Do not add a cancel request into the task list,
                    if (schedulingInfo.requestType == RequestType.CreateMeeting)
                    {
                        object[] parameters = new object[5];
                        parameters[0] = schedulingInfo;
                        parameters[1] = null;
                        parameters[2] = result;
                        parameters[3] = now;
                        parameters[4] = service;
                        lock (ewsTasks)
                        {
                            RvLogger.DebugWrite("add the task in=============" + schedulingInfo.subject);
                            ewsTasks.AddLast(parameters);
                        }
                    }
                }
                return result;
            }

            bool successfullyRescheduled = false;
            if (schedulingInfo.requestType == RequestType.CreateMeeting)
            {
                try {
                    icm.XmlApi.virtualRoomType[] virtualRooms = this.getVirtualRoom(userInfo);
                    if (null == virtualRooms && isCreate)
                        throw new ScopiaMeetingAddInException(ScopiaMeetingAddInException.ERROR_MESSAGE_NO_VIRTUALROOM);
                    if (isCreate) {
                        icm.XmlApi.virtualRoomType defaultVirtualRoom = null;
                        foreach (icm.XmlApi.virtualRoomType virtualRoom in virtualRooms) {
                            if (virtualRoom.Default) {
                                defaultVirtualRoom = virtualRoom;
                                break;
                            }
                        }
                        if (null == defaultVirtualRoom)
                            defaultVirtualRoom = virtualRooms[0];

                        if (defaultVirtualRoom.OneTimePINRequired) {
                            if (string.IsNullOrEmpty(schedulingInfo.meetingPin))
                                schedulingInfo.meetingPin = CreateRandomPWD(6);
                        }

                        icm.XmlApi.dialingInfoType dialingInfo = this.getDialingInfo(schedulingInfo, userInfo, defaultVirtualRoom);
                        if (USE_HTML)
                            dialingInfoStr = dialingInfo.DescriptionOfHTML;
                        else
                            dialingInfoStr = dialingInfo.Description;

                        if (!USE_HTML && null != dialingInfoStr)
                        {
                            dialingInfoStr = dialingInfoStr.Replace("\n", "<br>");
                            dialingInfoStr = dialingInfoStr.Replace("\r", "");
                            dialingInfoStr = dialingInfoStr.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
                        }
                        schedulingInfo.dialingInfo = dialingInfoStr;
                    }
                    result = this.scheduleMeeting(schedulingInfo, schedulingInfo.subject, false);
                    if (!result.Success && IS_RESCHEDULE && !notResourceProblem(string.IsNullOrEmpty(result.ErrorCode) ? (result.Detail == null ? "" : result.Detail) : result.ErrorCode))
                    {
                        result = this.scheduleMeeting(schedulingInfo, schedulingInfo.subject, true);
                        if (result.Success)
                        {
                            successfullyRescheduled = true;
                        } 
                    }
                } catch (Exception ex) {
                    result = new icm.XmlApi.scheduleReportType();
                    result.Success = false;
                    result.ErrorCode = ex.Message;
                    result.Detail = ex.Message;
                }

                result.Detail = result.Detail == null ? "" : result.Detail;

                if ((isCreate && result.Success) || (!result.Success && IS_DELETE_ERROR))
                {
                    if (null == service)
                        service = getWebService(schedulingInfo);
                    if (null == service)
                        return result;

                    object[] parameters = new object[5];
                    parameters[0] = schedulingInfo;
                    parameters[1] = dialingInfoStr;
                    parameters[2] = result;
                    parameters[3] = now;
                    parameters[4] = service;
                    lock (ewsTasks)
                    {
                        RvLogger.DebugWrite("add the task in=============" + schedulingInfo.subject);
                        ewsTasks.AddLast(parameters);
                    }
                }
            }
            else
            {
                result = this.deleteMeeting(schedulingInfo, true);
                result.Detail = result.Detail == null ? "" : result.Detail;
            }

            if (false == result.Success && ("CONF_NOT_FOUND".Equals(result.Detail) || "CANCELLED".Equals(result.Detail)))
                result.Success = true;

            if (false == result.Success)
            {
                sendBackAMail(source, schedulingInfo, string.IsNullOrEmpty(result.ErrorCode) ? result.Detail : result.ErrorCode);
            }
            else if (successfullyRescheduled)
                sendBackAMail(source, schedulingInfo, "RESOURCE_SHORTAGE");
            else if (IS_SEND_SUCCESS_MAIL)
            {
                sendBackAMail(source, schedulingInfo, "SUCCESS_NOTIFICATION");
            }

            return result;
        }
Ejemplo n.º 6
0
        public void changeBodyOfTnef(MimePart tnefPart, SchedulingInfo schedulingInfo)
        {
            TnefReader tnefreader = new TnefReader(tnefPart.GetContentReadStream(), 0, TnefComplianceMode.Loose);
            while (tnefreader.ReadNextAttribute())
            {
                if (tnefreader.AttributeTag != TnefAttributeTag.MapiProperties)
                    continue;
                string dialingInfo = schedulingInfo.dialingInfo;
                TnefWriter writer = new TnefWriter(
                tnefPart.GetContentWriteStream(tnefPart.ContentTransferEncoding), tnefreader.AttachmentKey, 0, TnefWriterFlags.NoStandardAttributes);

                writer.StartAttribute(TnefAttributeTag.MapiProperties, TnefAttributeLevel.Message);
                writer.WriteAllProperties(tnefreader.PropertyReader);
                writer.StartProperty(TnefPropertyTag.RtfCompressed);
                if (null != dialingInfo)
                {
                    dialingInfo = convertToUnicode(dialingInfo);
                }
                string body = null == dialingInfo ? schedulingInfo.emailMessage : schedulingInfo.emailMessage + "<br><br>" + dialingInfo;
                Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
                HtmlToRtf htmlToRtf = new HtmlToRtf();
                RtfToRtfCompressed rtfToRtfCompressed = new RtfToRtfCompressed();
                htmlToRtf.InputEncoding = System.Text.Encoding.UTF8;//GetEncoding("ISO-8859-1");
                stream = new ConverterStream(stream, htmlToRtf, ConverterStreamAccess.Read);
                stream = new ConverterStream(stream, rtfToRtfCompressed, ConverterStreamAccess.Read);
                writer.WritePropertyValue(stream);

                if (null != writer)
                {
                    writer.Close();
                }
            }
            tnefreader.Close();
            RvLogger.DebugWrite("ok**************************************");
        }
Ejemplo n.º 7
0
        private icm.XmlApi.scheduleReportType scheduleMeeting(SchedulingInfo schedulingInfo, string subject, bool removeResource)
        {
            icm.XmlApi.conferenceType conferenceType = new icm.XmlApi.conferenceType();
            conferenceType.Subject = subject; 
            conferenceType.Duration = "PT" + schedulingInfo.endDate.Subtract(schedulingInfo.startDate).TotalMinutes + "M";
            conferenceType.UserEmail = schedulingInfo.delegatorEmailAddr;
            conferenceType.ConferenceId = schedulingInfo.conferenceID;
            if (!removeResource)
                conferenceType.OutlookResources = schedulingInfo.outlookResources;
            conferenceType.StartTime = schedulingInfo.startDate;
            conferenceType.StartTimeSpecified = true;
            conferenceType.TimeZoneId = schedulingInfo.timeZoneID;
            conferenceType.RecipentsChanged = schedulingInfo.isRecipentsChanged;
            conferenceType.AddRecipents = schedulingInfo.isAddRecipents;
            conferenceType.RemovePersonalTerminals = removeResource;
            if (!string.IsNullOrEmpty(schedulingInfo.meetingPin))
                conferenceType.AccessPIN = Encoding.UTF8.GetBytes(schedulingInfo.meetingPin);

            if (schedulingInfo.meetingType == MeetingType.Reccurence)
            {
                this.AddRecurrenceInfo(conferenceType, schedulingInfo);
            }
            else if (schedulingInfo.meetingType == MeetingType.Ocurrence)
            {
                if (schedulingInfo.hasPreStartDate)
                    conferenceType.OccurrenceOldStartTime = schedulingInfo.preStartDate;
                else
                    conferenceType.OccurrenceOldStartTime = schedulingInfo.startDate;
                conferenceType.OccurrenceOldStartTimeSpecified = true;
            }

            if (!string.IsNullOrEmpty(schedulingInfo.recipents))
                conferenceType.OutlookRecipents = schedulingInfo.recipents;
            if (!string.IsNullOrEmpty(schedulingInfo.outlookResources))
                conferenceType.OutlookResources = schedulingInfo.outlookResources;

            RvLogger.DebugWrite("conferenceType.outlookResources=====================" + conferenceType.OutlookResources);
            RvLogger.DebugWrite("Start scheduling this SCOPIA meeting, the subject is : " + subject);

            icm.XmlApi.scheduleReportType report = null;
            if (isCreateMeetingRequest(schedulingInfo)) {
                conferenceType.Description = "";
                report = adapter.ScheduleConference(conferenceType);
            } else {
                if (schedulingInfo.meetingType == MeetingType.Reccurence)
                {
                    report = adapter.ModifyConference(conferenceType);
                    report.Detail = report.Detail == null ? "" : report.Detail;
                    if (!report.Success && "PATTERN_CHANGED".Equals(report.Detail)) {
                        this.deleteMeeting(schedulingInfo, false);
                        conferenceType.ReccurencePatternChanged = true;
                        report = adapter.ScheduleConference(conferenceType);
                    } else if (!report.Success && !"PATTERN_CHANGED".Equals(report.Detail)) {
                        if (notResourceProblem(report.ErrorCode) || !IS_RESCHEDULE)
                        {
                            this.deleteMeeting(schedulingInfo, true);
                            //throw new ScopiaMeetingAddInException(string.IsNullOrEmpty(report.ErrorCode) ? report.Detail : report.ErrorCode);
                        }
                    }
                }
                else
                { 
                    report = adapter.ModifyConference(conferenceType);
                    report.Detail = report.Detail == null ? "" : report.Detail;
                    if (!report.Success && schedulingInfo.meetingType == MeetingType.Ocurrence && schedulingInfo.isRecipentsChanged
                        && !schedulingInfo.isAddRecipents && "CONF_NOT_FOUND".Equals(report.Detail))
                        report.Success = true;
                    if (!report.Success && (notResourceProblem(report.ErrorCode) || !IS_RESCHEDULE))
                    {
                        this.deleteMeeting(schedulingInfo, false);
                        //throw new ScopiaMeetingAddInException(string.IsNullOrEmpty(report.ErrorCode) ? report.Detail : report.ErrorCode);
                    }
                }
            }
            return report;
        }
Ejemplo n.º 8
0
        private void sendBackAMail(QueuedMessageEventSource source, SchedulingInfo schedulingInfo, string baseFailCode)
        {
            try
            {
                RvLogger.DebugWrite("Send back a mail to the sender.");
                RvLogger.DebugWrite("Notification mail code: " + baseFailCode);
                DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
                string PickupPath = directoryInfo.Parent.Parent.FullName + @"\Pickup\";
                if (settingsInfo["ExchangeServer.PickupDirectoryPath"] != null)
                {
                    PickupPath = settingsInfo["ExchangeServer.PickupDirectoryPath"];
                    if(!PickupPath.EndsWith(@"\"))
                         PickupPath = PickupPath + @"\";
                }
                

                if (!Directory.Exists(PickupPath))
                {
                    Directory.CreateDirectory(PickupPath);
                }
                EmailMessage origMsg = this.emailMessage;

                EmailMessage newMsg = EmailMessage.Create();
                //newMsg.MessageId = "11111111112222222222";
 
                string subjectFailCode = getFailCode(schedulingInfo, "subject.fail");

                if ("SUCCESS_NOTIFICATION".Equals(baseFailCode))
                    subjectFailCode = getFailCode(schedulingInfo, "subject.success");
                else if ("RESOURCE_SHORTAGE".Equals(baseFailCode))
                    subjectFailCode = getFailCode(schedulingInfo, "subject.resource.shortage");
                else if (!notResourceProblem(baseFailCode))
                    baseFailCode = "ERROR_RESOURCE_SHORTAGE";

                string failCode = getFailCode(schedulingInfo, baseFailCode);

                newMsg.Subject = messages[subjectFailCode];
                newMsg.To.Clear();
                newMsg.To.Add(new EmailRecipient(
                    origMsg.Sender.DisplayName,
                    origMsg.Sender.SmtpAddress));

                newMsg.From = new EmailRecipient("Service Account",
                    SERVER_ACCOUNT);
                Stream writer = newMsg.Body.GetContentWriteStream();
                StreamWriter sw = new StreamWriter(writer, Encoding.Unicode);
                if (schedulingInfo != null)
                {
                    sw.WriteLine("Subject : " + schedulingInfo.subject);
                    sw.WriteLine();
                }
                string message = messages.ContainsKey(failCode) ? messages[failCode] : null;
                if (string.IsNullOrEmpty(message))
                    message = messages["common.message"];

                RvLogger.DebugWrite("Notification mail message: " + message);
                sw.WriteLine(message);
                sw.Close();
                writer.Close();
                SaveMessage(newMsg, String.Concat(PickupPath, schedulingInfo.delegatorEmailAddr + "-" + DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss-ms") + ".eml"));
                RvLogger.DebugWrite("Notification mail is sent.");
                // Cancel the original message
                if (!"SUCCESS_NOTIFICATION".Equals(baseFailCode) && !"RESOURCE_SHORTAGE".Equals(baseFailCode)) 
                    source.Delete();
            }
            catch (Exception ex)
            {
                RvLogger.DebugWrite(ex.StackTrace);
                RvLogger.DebugWrite(ex.Message);
            }
            RvLogger.DebugWrite("Send back a mail to the sender completed.");
        }
Ejemplo n.º 9
0
        private static void saveConferenceInfoIntoAppointment(icm.XmlApi.scheduleReportType result, webServiceData.Appointment appointment, SchedulingInfo schedulingInfo, webServiceData.ExchangeService service, string dialingInfoStr, string uniqueId)
        {
                string hashString = RvScopiaMeeting.GetHashString(schedulingInfo, schedulingInfo.subject);
                if (schedulingInfo.requestType != RequestType.CancelMeeting)
                {
                    string conferenceID = null == result || !result.Success ? "empty" : result.ConferenceId;
                    if (isCreateMeetingRequest(schedulingInfo))
                    {
                        if (!result.Success && IS_DELETE_ERROR) {
                            appointment.Delete(webServiceData.DeleteMode.HardDelete, webServiceData.SendCancellationsMode.SendToNone);
                            RvLogger.DebugWrite("delete appointment: " + schedulingInfo.subject);
                            return;
                        }
                        appointment.MeetingWorkspaceUrl = CONFERENCE_ID + ":" + conferenceID + ":" + hashString + "$" + schedulingInfo.recurrenceHashInfo;
                        if (USE_HTML)
                            appointment.Body.BodyType = webServiceData.BodyType.HTML;

                        List<webServiceData.Attachment> attachments = new List<webServiceData.Attachment>(appointment.Attachments.Count);
                        foreach (webServiceData.Attachment attachment in appointment.Attachments)
                            appointment.Body.Text = appointment.Body.Text.Replace(attachment.Name, "");
                        appointment.Body.Text = appointment.Body + Environment.NewLine + "<br>" + dialingInfoStr;
                        if (schedulingInfo.meetingType == MeetingType.Reccurence)
                            appointment.MeetingWorkspaceUrl = "#" + appointment.MeetingWorkspaceUrl;
                    }
                    else
                    {
                        if (!result.Success && IS_DELETE_ERROR) {
                            appointment.Delete(webServiceData.DeleteMode.HardDelete, webServiceData.SendCancellationsMode.SendToNone);
                            RvLogger.DebugWrite("delete appointment: " + schedulingInfo.subject);
                            return;
                        }
                    }                    
                }

                updateAppointment(appointment);
        }
Ejemplo n.º 10
0
 private icm.XmlApi.dialingInfoType getDialingInfo(SchedulingInfo schedulingInfo, icm.XmlApi.userType userInfo, icm.XmlApi.virtualRoomType defaultVirtualRoom)
 {
     bool isCreate = isCreateMeetingRequest(schedulingInfo);
     return adapter.GetDialingInfo(userInfo, schedulingInfo, defaultVirtualRoom, isCreate, schedulingInfo.requestType == RequestType.CancelMeeting);
 }
Ejemplo n.º 11
0
        private static void updateAppointment(webServiceData.Appointment appointment, SchedulingInfo schedulingInfo, webServiceData.ExchangeService service, string dialingInfoStr, icm.XmlApi.scheduleReportType result)
        {
                if (null == appointment) 
                    return;

                string uniqueId = null;
                if (schedulingInfo.meetingType == MeetingType.Ocurrence)
                {
                    appointment = webServiceData.Appointment.Bind(service, appointment.Id, new webServiceData.PropertySet(webServiceData.BasePropertySet.FirstClassProperties) { RequestedBodyType = webServiceData.BodyType.HTML });
                }
                else if (appointment.AppointmentType == webServiceData.AppointmentType.RecurringMaster)
                {
                    uniqueId = appointment.Id.UniqueId;
                    appointment = webServiceData.Appointment.Bind(service, appointment.Id);
                }
                else
                    appointment = webServiceData.Appointment.Bind(service, appointment.Id);

                saveConferenceInfoIntoAppointment(result, appointment, schedulingInfo, service, dialingInfoStr, uniqueId);
        }
Ejemplo n.º 12
0
        private static webServiceData.Appointment searchAppointmentByFilter(SchedulingInfo schedulingInfo, webServiceData.ExchangeService service, string appointmentID)
        {
            RvLogger.DebugWrite("enter searchAppointmentByFilter==============");
            List<webServiceData.SearchFilter> searchORFilterCollection = new List<webServiceData.SearchFilter>();
            if (null != appointmentID)
                searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.Id, new webServiceData.ItemId(appointmentID)));
            else {
                searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.Subject, schedulingInfo.subject));
                searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.From, schedulingInfo.delegatorEmailAddr));
                searchORFilterCollection.Add(new webServiceData.SearchFilter.IsGreaterThan(webServiceData.EmailMessageSchema.LastModifiedTime, DateTime.UtcNow.AddHours(-25)));
                if (!string.IsNullOrEmpty(schedulingInfo.storeEntryId))
                    searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.StoreEntryId, schedulingInfo.storeEntryId));
                if (!string.IsNullOrEmpty(schedulingInfo.conversationKey))
                    searchORFilterCollection.Add(new webServiceData.SearchFilter.IsEqualTo(webServiceData.EmailMessageSchema.ConversationId, schedulingInfo.conversationKey));
            }
            RvLogger.DebugWrite("enter searchAppointmentByFilter==============1");
            webServiceData.SearchFilter searchFilter = new webServiceData.SearchFilter.SearchFilterCollection(webServiceData.LogicalOperator.And, searchORFilterCollection.ToArray());
            RvLogger.DebugWrite("enter searchAppointmentByFilter==============2 " + schedulingInfo.delegatorEmailAddr);
            webServiceData.Mailbox mailBox = new webServiceData.Mailbox(schedulingInfo.delegatorEmailAddr);
            RvLogger.DebugWrite("enter searchAppointmentByFilter==============3");
            webServiceData.FolderId folderID = new webServiceData.FolderId(webServiceData.WellKnownFolderName.Calendar, mailBox); //No need to set mail since the service already know it.
            //webServiceData.FolderId folderID = new webServiceData.FolderId(webServiceData.WellKnownFolderName.Calendar);
            RvLogger.DebugWrite("enter searchAppointmentByFilter==============4");
            webServiceData.FindItemsResults<webServiceData.Item> results = service.FindItems(
                                    folderID,
                                    searchFilter,
                                    new webServiceData.ItemView(100));
            RvLogger.DebugWrite("enter searchAppointmentByFilter==============5");
            RvLogger.DebugWrite("results searchAppointmentByFilter==============" + (null == results.Items ? "0" : "" + results.Items.Count));

            foreach (webServiceData.Item item in results) {
                try {
                    webServiceData.Appointment appointment = (webServiceData.Appointment)item;
                    if (string.IsNullOrEmpty(schedulingInfo.location)) schedulingInfo.location = "";
                    if (string.IsNullOrEmpty(appointment.Location)) appointment.Location = "";
                    if (schedulingInfo.location == appointment.Location
                        && schedulingInfo.startDate.ToUniversalTime().Equals(appointment.Start.ToUniversalTime())
                        && schedulingInfo.endDate.ToUniversalTime().Equals(appointment.End.ToUniversalTime()))
                    {
                        RvLogger.DebugWrite("lastModifiedTime1===================" + appointment.LastModifiedTime);
                        return appointment;
                    }
                }
                catch (ScopiaMeetingAddInException ex) {
                    throw ex;
                }
            }

            return null;
        }
Ejemplo n.º 13
0
        private static webServiceData.Appointment searchAppointment(SchedulingInfo schedulingInfo, webServiceData.ExchangeService service)
        {
            RvLogger.DebugWrite("enter searchAppointment==============");
            webServiceData.Mailbox mailBox = new webServiceData.Mailbox(schedulingInfo.delegatorEmailAddr);
            webServiceData.FolderId folderID = new webServiceData.FolderId(webServiceData.WellKnownFolderName.Calendar, mailBox);
            webServiceData.CalendarFolder folder = webServiceData.CalendarFolder.Bind(service, folderID);
            webServiceData.CalendarView view = new webServiceData.CalendarView(schedulingInfo.startDate, schedulingInfo.endDate);
            webServiceData.PropertySet propertySet = new webServiceData.PropertySet(webServiceData.BasePropertySet.FirstClassProperties);
            view.PropertySet = propertySet;
            webServiceData.FindItemsResults<webServiceData.Appointment> results = folder.FindAppointments(view);

            RvLogger.DebugWrite("results==============" + (null == results.Items ? "0" : "" + results.Items.Count));

            foreach (webServiceData.Item item in results)
            {
                try
                {
                    webServiceData.Appointment appointment = (webServiceData.Appointment)item;
                    if (string.IsNullOrEmpty(schedulingInfo.location)) schedulingInfo.location = "";
                    if (string.IsNullOrEmpty(appointment.Location)) appointment.Location = "";
                    if (string.IsNullOrEmpty(schedulingInfo.subject)) schedulingInfo.subject = "";
                    if (string.IsNullOrEmpty(appointment.Subject)) appointment.Subject = "";
                    if (schedulingInfo.location == appointment.Location 
                        && appointment.Subject == schedulingInfo.subject
                        && 0 == appointment.Start.ToUniversalTime().CompareTo(schedulingInfo.startDate.ToUniversalTime())
                        && 0 == appointment.End.ToUniversalTime().CompareTo(schedulingInfo.endDate.ToUniversalTime()))
                    {
                        return appointment;
                    }
                }
                catch (ScopiaMeetingAddInException ex)
                {
                    throw ex;
                }
            }

            return null;
        }
Ejemplo n.º 14
0
        private bool isScopia(SchedulingInfo schedulingInfo)
        {
            if (!string.IsNullOrEmpty(schedulingInfo.location))
                foreach(string mark in MARK_OF_SCOPIA_LOCATION) {
                    if (schedulingInfo.location.ToLower().IndexOf(mark) != -1)
                        return true;
                }

            if (!string.IsNullOrEmpty(schedulingInfo.subject))
                foreach (string mark in MARK_OF_SCOPIA_SUBJECT)
                {
                    if (schedulingInfo.subject.ToLower().IndexOf(mark) != -1)
                        return true;
                }

            if (!string.IsNullOrEmpty(schedulingInfo.recipents))
                foreach (string mark in MARK_OF_SCOPIA_RECEIPENT)
                {
                    if (schedulingInfo.recipents.ToLower().IndexOf(mark) != -1)
                        return true;
                }

            if (!string.IsNullOrEmpty(schedulingInfo.conferenceID))
                return true;

            return false;
        }
Ejemplo n.º 15
0
 private icm.XmlApi.scheduleReportType deleteMeeting(SchedulingInfo schedulingInfo, bool deleteClientlessMapping) 
 {
     return adapter.CancelConference(schedulingInfo, deleteClientlessMapping);
 }
Ejemplo n.º 16
0
        private void parseRecipentsChanged(SchedulingInfo schedulingInfo)
        {
            RvLogger.DebugWrite("parseRecipentsChanged schedulingInfo.displayNamesFromTnef=============" + schedulingInfo.displayNamesFromTnef);
            if (string.IsNullOrEmpty(schedulingInfo.displayNamesFromTnef.Trim()))
                return;

            string[] names = schedulingInfo.displayNamesFromTnef.Split(new string[] { "; " }, StringSplitOptions.RemoveEmptyEntries);
            List<string> list = names.ToList<string>();
            list.Sort();
            StringBuilder displayNamesStrb = new StringBuilder("");
            foreach (string name in list)
            {
                displayNamesStrb.Append(name).Append("; ");
            }
            string displayNamesStr = displayNamesStrb.ToString().Trim();
            RvLogger.DebugWrite("parseRecipentsChanged displayNamesStr=============" + displayNamesStr);
            if (displayNamesStr.Length < 2)
                return;
            schedulingInfo.displayNamesFromTnef = displayNamesStr.Substring(0, displayNamesStr.Length - 1);
            RvLogger.DebugWrite("DisplayNames emails are displayNamesFromTnef: " + schedulingInfo.displayNamesFromTnef);
            if (!schedulingInfo.displayNames.Equals(schedulingInfo.displayNamesFromTnef))
                schedulingInfo.isRecipentsChanged = true;
        }
Ejemplo n.º 17
0
 private static bool isCreateMeetingRequest(SchedulingInfo schedulingInfo)
 {
     if (schedulingInfo.requestType == RequestType.CreateMeeting)
         return string.IsNullOrEmpty(schedulingInfo.conferenceID) || schedulingInfo.conferenceID.Equals("empty");
     return false;
 }
Ejemplo n.º 18
0
        private static webServiceData.ExchangeService getWebService(SchedulingInfo schedulingInfo){

            long now = DateTime.UtcNow.Ticks;
            RvLogger.DebugWrite("start to create webservice======================================");
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

            webServiceData.ExchangeService service = new webServiceData.ExchangeService(webServiceData.ExchangeVersion.Exchange2010_SP2);

            String userAccount = null;
            if (settingsInfo.ContainsKey("ExchangeServer.email.account"))
                userAccount = settingsInfo["ExchangeServer.email.account"];

            if(settingsInfo.ContainsKey("ExchangeServer.user.account"))
                userAccount = settingsInfo["ExchangeServer.user.account"];
            String userPassword = null;
            if (settingsInfo.ContainsKey("ExchangeServer.email.password"))
                userPassword = settingsInfo["ExchangeServer.email.password"];
            if (settingsInfo.ContainsKey("ExchangeServer.user.password"))
                userPassword = settingsInfo["ExchangeServer.user.password"];

            String userEmail = null;
            if (settingsInfo.ContainsKey("ExchangeServer.email.account"))
                userEmail = settingsInfo["ExchangeServer.email.account"];
            if (settingsInfo.ContainsKey("ExchangeServer.user.email"))
                userEmail = settingsInfo["ExchangeServer.user.email"];

            RvLogger.DebugWrite("EXCHANGE_USER: "******"EXCHANGE_EMAIL: " + userEmail);
            RvLogger.DebugWrite("EXCHANGE_password: "******"AutodiscoverUrl Error: " + e.Message);
                RvLogger.InfoWrite(e.StackTrace);
                service.TraceEnabled = true;
                service.TraceListener = new TraceListener();
                service.TraceFlags = webServiceData.TraceFlags.All;
                try
                {
                    service.AutodiscoverUrl(userEmail, RedirectionUrlValidationCallback);
                }
                catch (Exception e1)
                {
                    RvLogger.InfoWrite("AutodiscoverUrl Error1: " + e1.Message);
                    RvLogger.InfoWrite(e1.StackTrace);
                    if (settingsInfo.ContainsKey("ExchangeServer.ewsurl"))
                    {
                        String ewsurl = settingsInfo["ExchangeServer.ewsurl"];
                        service.Url = new Uri(ewsurl);
                    }
                    if (settingsInfo.ContainsKey("ExchangeServer.trace.all"))
                    {
                        String traceAll = settingsInfo["ExchangeServer.trace.all"];
                        if (traceAll != null && !traceAll.Equals("true"))
                        {
                            service.TraceEnabled = false;
                            service.TraceListener = null;
                        }
                    }

                }
            }
            RvLogger.DebugWrite("Discovered service URL:"+service.Url);
            if (null != schedulingInfo)
                service.ImpersonatedUserId = new webServiceData.ImpersonatedUserId(webServiceData.ConnectingIdType.SmtpAddress, schedulingInfo.delegatorEmailAddr);

            RvLogger.DebugWrite("Finished to create webservice======================================time:" + (DateTime.UtcNow.Ticks - now));

            return service;
        }
Ejemplo n.º 19
0
        private string getFailCode(SchedulingInfo schedulingInfo, string baseFailCode)
        {
            string code = "";
            if (null != schedulingInfo)
                if (schedulingInfo.requestType == RequestType.CreateMeeting) {
                    if(isCreateMeetingRequest(schedulingInfo))
                        code = baseFailCode + ".create";
                    else
                        code = baseFailCode + ".update";
                }else
                    code = baseFailCode + ".delete";

            return code;
        }
Ejemplo n.º 20
0
        private static webServiceData.Appointment getCurrentAppointment(SchedulingInfo schedulingInfo, webServiceData.ExchangeService service)
        {
            webServiceData.Appointment theCurrentAppointment = null;
            //service.ImpersonatedUserId = new webServiceData.ImpersonatedUserId(webServiceData.ConnectingIdType.SmtpAddress, schedulingInfo.senderEmailAddr);

            //long startSearchTime = DateTime.UtcNow.Ticks;
            //do
            //{
                if (schedulingInfo.meetingType == MeetingType.Ocurrence)
                {
                    webServiceData.Appointment appointment = searchAppointment(schedulingInfo, service);
                    if (null != appointment)
                    {
                        theCurrentAppointment = appointment;
                    }
                }
                else
                {
                    webServiceData.Appointment appointment = searchAppointmentByFilter(schedulingInfo, service, null);
                    if (null != appointment)
                    {
                        theCurrentAppointment = appointment;
                    }
                }

            //    if (null == theCurrentAppointment) Thread.Sleep(5000);
            //} while (null == theCurrentAppointment && (DateTime.UtcNow.Ticks - startSearchTime) / 10000000 <= 60);

            if (null == theCurrentAppointment)
            {
                //do
                //{
                    webServiceData.Appointment appointment = searchAppointment(schedulingInfo, service);
                    //if (null != appointment)
                    //{
                        theCurrentAppointment = appointment;
                    //}
                    //else
                    //{
                    //    Thread.Sleep(5000);
                    //}
                //} while (null == theCurrentAppointment && (DateTime.UtcNow.Ticks - startSearchTime) / 10000000 <= 10);
            }

            return theCurrentAppointment;
        }
Ejemplo n.º 21
0
        public void parseTnefSimple(MailItem mailItem, SchedulingInfo schedulingInfo)
        {
            try
            {

                TnefReader tnefreader = new TnefReader(mailItem.Message.TnefPart.GetContentReadStream(), 0, TnefComplianceMode.Loose);
                EnvelopeRecipientCollection.Enumerator enumerator = mailItem.Recipients.GetEnumerator();
                StringBuilder recipents = new StringBuilder("");
                StringBuilder resources = new StringBuilder("");
                ArrayList displayNames = new ArrayList();
                while (enumerator.MoveNext())
                {
                    string emailAddress = enumerator.Current.Address.ToString();
                    int recipientP2Type = (int)enumerator.Current.Properties["Microsoft.Exchange.Transport.RecipientP2Type"];
                    String displayName = emailAddress;
                    try
                    {
                        displayName = (string)enumerator.Current.Properties["Microsoft.Exchange.MapiDisplayName"];
                    }
                    catch (Exception ex1)
                    {
                        RvLogger.DebugWrite("Error: " + ex1.Message);
                        if(emailAddress != null )
                        {
                               int lastIndex = emailAddress.LastIndexOf("@");
                                if (lastIndex != -1)
                                {
                                        displayName = emailAddress.Substring(0, lastIndex);
                                }
                        }
                    }
                    displayNames.Add(displayName);
                    if (recipientP2Type == 3)
                    {
                        resources.Append(emailAddress).Append(" ");
                    }
                    else if (recipientP2Type == 1 || recipientP2Type == 2)
                    {
                        recipents.Append(emailAddress).Append(" ");
                    }
                }
                schedulingInfo.outlookResources = resources.ToString();
                schedulingInfo.recipents = recipents.ToString();
                displayNames.Sort();
                StringBuilder displayNamesStrb = new StringBuilder("");
                foreach (object displayName in displayNames)
                {
                    displayNamesStrb.Append((string)displayName).Append("; ");
                }
                string displayNamesStr = displayNamesStrb.ToString().Trim();
                schedulingInfo.displayNames = displayNamesStr.Substring(0, displayNamesStr.Length - 1);
                RvLogger.DebugWrite("Recipents emails are :" + schedulingInfo.recipents);
                RvLogger.DebugWrite("Resources emails are :" + schedulingInfo.outlookResources);
                RvLogger.DebugWrite("DisplayNames emails are :" + displayNamesStr);

                bool isRecurrence = false;
                bool isOcurrence = false;
                while (tnefreader.ReadNextAttribute())
                {
                    if (tnefreader.AttributeTag != TnefAttributeTag.MapiProperties)
                        continue;

                    while (tnefreader.PropertyReader.ReadNextProperty())
                    {
                        try
                        {
                            TnefPropertyTag tag = tnefreader.PropertyReader.PropertyTag;
                            //RvLogger.DebugWrite("PropertyTagID:" + tag.Id);
                            //RvLogger.DebugWrite("PropertyTagToString:" + tag.ToString());
                            //RvLogger.DebugWrite("ValueType==:" + tnefreader.PropertyReader.ValueType);
                            /*try
                            {
                                RvLogger.DebugWrite("PropertyID:" + tnefreader.PropertyReader.PropertyNameId.Id);
                                RvLogger.DebugWrite("PropertyName:" + tnefreader.PropertyReader.PropertyNameId.Name);
                                RvLogger.DebugWrite("PropertySetGUID:" + tnefreader.PropertyReader.PropertyNameId.PropertySetGuid);
                            }
                            catch (Exception) {
                                RvLogger.DebugWrite("***********************************************0");
                            }
                            */
                            if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 33302)
                            {
                                byte[] recurrencePatternByte = tnefreader.PropertyReader.ReadValueAsBytes();
                                RecurrencePattern recurrencePattern = RvMailParser.parseRecurrenceMeeting(recurrencePatternByte);
                                schedulingInfo.recurrencePattern = recurrencePattern;
                            }
                            else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 33374)
                            {
                                byte[] timezonebytes = tnefreader.PropertyReader.ReadValueAsBytes();
                                byte[] lengthOfZone = { timezonebytes[6], timezonebytes[7] };
                                int length = BitConverter.ToInt16(lengthOfZone, 0);
                                byte[] timezonekeyNameBytes = new byte[length * 2];
                                Array.Copy(timezonebytes, 8, timezonekeyNameBytes, 0, length * 2 - 1);
                                String timezonekeyName = Encoding.Unicode.GetString(timezonekeyNameBytes);
                                schedulingInfo.timeZoneID = timezonekeyName;
                                //RvLogger.DebugWrite("timezonekeyName:" + timezonekeyName);
                            }
                            if (!tnefreader.PropertyReader.ValueType.IsArray)
                            {
                                object propValue = tnefreader.PropertyReader.ReadValue();

                                //RvLogger.DebugWrite("PropertyValue:" + propValue);

                                if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 33315)
                                {
                                    if ((Boolean)propValue)
                                        isRecurrence = (Boolean)propValue;
                                    isOcurrence = !(Boolean)propValue;
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 33330)
                                {
                                    schedulingInfo.recurrenceInfo = (string)propValue;
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 33332)
                                {
                                    schedulingInfo.timeZoneDisplayName = (string)propValue;
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 33336)
                                {
                                    schedulingInfo.displayNamesFromTnef = ((string)propValue).Trim();
                                }

                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 41)
                                {
                                    schedulingInfo.preStartDate = (DateTime)propValue;
                                    RvLogger.DebugWrite("schedulingInfo.preStartDate===================" + ((DateTime)propValue));
                                    schedulingInfo.hasPreStartDate = true;
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 4115)
                                {
                                    RvLogger.DebugWrite("Parsed html body===================" + ((string)propValue));
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 4118)
                                {
                                    RvLogger.DebugWrite("Parsed native body===================" + ((string)propValue));
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 4096)
                                {
                                    RvLogger.DebugWrite("Parsed text body===================" + ((string)propValue));
                                }
                                else if (tag.Id == TnefPropertyId.StartDate)
                                {
                                    schedulingInfo.startDate = ((DateTime)propValue);
                                    RvLogger.DebugWrite("schedulingInfo.startDate===================" + ((DateTime)propValue));

                                }
                                else if (tag.Id == TnefPropertyId.EndDate)
                                {
                                    schedulingInfo.endDate = ((DateTime)propValue);
                                }
                                else if (tag.Id == TnefPropertyId.LastModificationTime)
                                {
                                    RvLogger.DebugWrite("lastModifiedTime===================" + ((DateTime)propValue));
                                }
                                else if (tag.Id == TnefPropertyId.CreationTime)
                                {
                                    RvLogger.DebugWrite("CreationTime===================" + ((DateTime)propValue));
                                }
                                else if (tag.Id == TnefPropertyId.SenderEmailAddress)
                                {
                                    schedulingInfo.senderEmailAddr = (string)propValue;
                                }
                                else if (tag.Id == TnefPropertyId.SubjectPrefix)
                                {
                                    if (null != propValue)
                                        schedulingInfo.subjectPrefix = ((string)propValue).Trim();
                                }
                                else if (tag.Id == TnefPropertyId.StoreEntryId)
                                {
                                    schedulingInfo.storeEntryId = (string)propValue;
                                }
                                else if (tag.Id == TnefPropertyId.INetMailOverrideCharset)
                                {
                                    object a = propValue;
                                }
                                else if (tag.Id == TnefPropertyId.ConversationKey)
                                {
                                    schedulingInfo.conversationKey = (string)propValue;
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 2)
                                {
                                    schedulingInfo.location = (string)propValue;
                                    string meetingPin = RvScopiaMeeting.parseMeetingPin(schedulingInfo.location);
                                    if (!string.IsNullOrEmpty(meetingPin))
                                        schedulingInfo.meetingPin = meetingPin;
                                }
                                else if (tnefreader.PropertyReader.IsNamedProperty && tnefreader.PropertyReader.PropertyNameId.Id == 33289)
                                {
                                    string value = (string)propValue;
                                    RvLogger.DebugWrite("infomation======================================" + value);
                                    int firstIndex = value.IndexOf(":");
                                    int lastIndex = value.LastIndexOf(":");
                                    if (firstIndex != -1)
                                    {
                                        schedulingInfo.conferenceID = value.Substring(firstIndex + 1, lastIndex - firstIndex - 1);
                                        string hashString = value.Substring(lastIndex + 1);
                                        int indexHashSplit = hashString.IndexOf("$");
                                        schedulingInfo.lastHashInfo = hashString.Substring(0, indexHashSplit);
                                        schedulingInfo.lastRecurrenceHashInfo = hashString.Substring(indexHashSplit + 1);
                                        if (value.StartsWith("#"))
                                        {
                                            isRecurrence = true;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (tag == TnefPropertyTag.RtfCompressed)
                                {
                                    schedulingInfo.emailMessage = "";
                                    Stream stream = tnefreader.PropertyReader.GetRawValueReadStream();
                                    Stream decompressedRtfStream = new ConverterStream(stream, new RtfCompressedToRtf(), ConverterStreamAccess.Read);
                                    RtfToHtml rtfToHtml = new RtfToHtml();
                                    rtfToHtml.OutputEncoding = System.Text.Encoding.UTF8;
                                    rtfToHtml.EnableHtmlDeencapsulation = true;
                                    Stream text = new ConverterStream(decompressedRtfStream, rtfToHtml, ConverterStreamAccess.Read);
                                    StreamReader sr = new StreamReader(text);
                                    schedulingInfo.emailMessage = sr.ReadToEnd();
                                    //RvLogger.DebugWrite("schedulingInfo.emailMessage: " + schedulingInfo.emailMessage);
                                    int indexOfSystemInfoSign = schedulingInfo.emailMessage.IndexOf("*~*~*~*~*~*~*~*~*~*");
                                    int startIndex = -1;
                                    int endIndex = -1;
                                    if (indexOfSystemInfoSign > -1)
                                    {
                                        startIndex = schedulingInfo.emailMessage.Substring(0, indexOfSystemInfoSign).LastIndexOf("<div>");
                                        endIndex = schedulingInfo.emailMessage.IndexOf("</div>", indexOfSystemInfoSign) + 6;
                                        if (startIndex > -1 && endIndex > -1)
                                            schedulingInfo.emailMessage = schedulingInfo.emailMessage.Substring(0, startIndex) + schedulingInfo.emailMessage.Substring(endIndex);
                                    }

                                    schedulingInfo.emailMessage = schedulingInfo.emailMessage.Replace("<img src=\"objattph://\">", "");
                                    sr.Close();
                                    text.Close();
                                    decompressedRtfStream.Close();
                                    stream.Close();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            RvLogger.DebugWrite("ex.Message======================" + ex.Message);
                            RvLogger.DebugWrite(ex.StackTrace);
                        }
                    }
                }

                if (isRecurrence && !isOcurrence)
                    schedulingInfo.meetingType = MeetingType.Reccurence;
                else if (isRecurrence && isOcurrence)
                    schedulingInfo.meetingType = MeetingType.Ocurrence;
                else
                    schedulingInfo.meetingType = MeetingType.Normal;

                tnefreader.Close();
            }
            catch (Exception e)
            {
                RvLogger.DebugWrite("Fail to parse mail-- " + e.Message);
                RvLogger.DebugWrite(e.StackTrace);
            }
        }