Example #1
0
        private void AppendFreeBusyEntry(
            DateTime startUtc,
            DateTime endUtc,
            string subject,
            string location,
            string organizer,
            BusyStatus busyStatus,
            StringBuilder result)
        {
            DateTime startLocal = OlsonUtil.ConvertFromUTC(startUtc, Request.TimeZone);
            DateTime endLocal   = OlsonUtil.ConvertFromUTC(endUtc, Request.TimeZone);
            int      status     = ConversionsUtil.ConvertBusyStatusToGoogleResponse(busyStatus);

            ConversionsUtil.EscapeNonAlphaNumeric(subject, escapedSubject);
            ConversionsUtil.EscapeNonAlphaNumeric(location, escapedLocation);
            ConversionsUtil.EscapeNonAlphaNumeric(organizer, escapedOrganizer);

            result.AppendFormat("['{0}','{1}','{2}','{3}','{4}',{5}]",
                                escapedSubject,
                                DateUtil.FormatDateTimeForGoogle(startLocal),
                                DateUtil.FormatDateTimeForGoogle(endLocal),
                                escapedLocation,
                                escapedOrganizer,
                                status);
        }
        /// <summary>
        /// Convert an Exchange Event Busy Status to a Google Calendar response
        /// </summary>
        /// <param name="busyStatus">The Exchange event status</param>
        /// <returns>The Google Calendar response</returns>
        public static int ConvertBusyStatusToGoogleResponse(BusyStatus busyStatus)
        {
            GCalResponseStatus googleStatus = GCalResponseStatus.Uninvited;

            switch (busyStatus)
            {
            case BusyStatus.OutOfOffice:
            case BusyStatus.Busy:
                googleStatus = GCalResponseStatus.Accepted;
                break;

            case BusyStatus.Free:
                googleStatus = GCalResponseStatus.Declined;
                break;

            case BusyStatus.Tentative:
                googleStatus = GCalResponseStatus.Tentative;
                break;

            default:
                googleStatus = GCalResponseStatus.Uninvited;
                break;
            }

            return((int)googleStatus);
        }
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomSetEVSEBusyStatusRequestSerializer">A delegate to serialize custom set EVSE busy status request XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <SetEVSEBusyStatusRequest> CustomSetEVSEBusyStatusRequestSerializer = null)
        {
            var XML = new XElement(eMIPNS.EVCIDynamic + "eMIP_ToIOP_SetEVSEBusyStatusRequest",

                                   TransactionId.HasValue
                              ? new XElement("transactionId", TransactionId.ToString())
                              : null,

                                   new XElement("partnerIdType", PartnerId.Format.AsText()),
                                   new XElement("partnerId", PartnerId.ToString()),

                                   new XElement("operatorIdType", OperatorId.Format.AsText()),
                                   new XElement("operatorId", OperatorId.ToString()),

                                   new XElement("EVSEIdType", EVSEId.Format.AsText()),
                                   new XElement("EVSEId", EVSEId.ToString()),

                                   new XElement("statusEventDate", StatusEventDate.ToIso8601(false).Replace("Z", "")),
                                   new XElement("busyStatus", BusyStatus.AsNumber()),

                                   BusyStatusUntil.HasValue
                              ? new XElement("busyStatusUntil", BusyStatusUntil.Value.ToIso8601(false).Replace("Z", ""))
                              : null,

                                   BusyStatusComment.IsNeitherNullNorEmpty()
                              ? new XElement("busyStatusComment", BusyStatusComment)
                              : null

                                   );


            return(CustomSetEVSEBusyStatusRequestSerializer != null
                       ? CustomSetEVSEBusyStatusRequestSerializer(this, XML)
                       : XML);
        }
Example #4
0
        /// 客服置忙状态
        /// <summary>
        /// 客服置忙状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AgentSetStateNotReady_Click(object sender, EventArgs e)
        {
            //预防代码进入
            if (sender != null && !Common.IsOldVersionContinue())
            {
                return;
            }
            ToolStripItem model = (ToolStripItem)sender;
            string        name  = model.Tag.ToString();

            Loger.Log4Net.Info("[Main] 点击按钮==置忙==" + name);
            BusyStatus busy = (BusyStatus)Enum.Parse(typeof(BusyStatus), name);

            //定义回调事件
            Action <object> callback = new Action <object>((x) =>
            {
                if (!HollyContactHelper.Instance.RestStart(busy))
                {
                    MessageBox.Show("置忙失败!");
                }
                else
                {
                    //窗口变量赋值
                    Main_BusyStatus = busy;
                }
            });

            //置闲成功后调用
            AfterToReadyCallBack(callback, "置闲后置忙");
        }
Example #5
0
        public ExceptionInfoStructure(byte[] buffer, int offset)
        {
            int position = offset;

            NewStartDT      = DateTimeHelper.ReadDateTimeFromMinutes(buffer, ref position);
            NewEndDT        = DateTimeHelper.ReadDateTimeFromMinutes(buffer, ref position);
            OriginalStartDT = DateTimeHelper.ReadDateTimeFromMinutes(buffer, ref position);
            Flags           = (OverrideFlags)LittleEndianReader.ReadUInt16(buffer, ref position);

            if (HasModifiedSubject)
            {
                ushort fieldLength        = LittleEndianReader.ReadUInt16(buffer, ref position);
                ushort numberOfCharacters = LittleEndianReader.ReadUInt16(buffer, ref position);
                Subject   = Encoding.Default.GetString(buffer, position, numberOfCharacters);
                position += numberOfCharacters;
            }

            if (HasModifiedStateFlags)
            {
                AppointmentStateFlags = LittleEndianReader.ReadUInt32(buffer, ref position);
            }

            if (HasModifiedReminderTime)
            {
                ReminderTime = LittleEndianReader.ReadUInt32(buffer, ref position);
            }

            if (HasModifiedIsReminderSet)
            {
                IsReminderSet = LittleEndianReader.ReadUInt32(buffer, ref position) == 0;
            }

            if (HasModifiedLocation)
            {
                ushort fieldLength        = LittleEndianReader.ReadUInt16(buffer, ref position);
                ushort numberOfCharacters = LittleEndianReader.ReadUInt16(buffer, ref position);
                Location  = Encoding.Default.GetString(buffer, position, numberOfCharacters);
                position += numberOfCharacters;
            }

            if (HasModifiedBusyStatus)
            {
                BusyStatus = (BusyStatus)LittleEndianReader.ReadUInt32(buffer, ref position);
            }

            if (HasModifiedHasAttachment)
            {
                HasAttachment = LittleEndianReader.ReadUInt32(buffer, ref position) == 0;
            }

            if (HasModifiedIsAllDayEvent)
            {
                IsAllDayEvent = LittleEndianReader.ReadUInt32(buffer, ref position) == 0;
            }

            if (HasModifiedColor)
            {
                Color = LittleEndianReader.ReadUInt32(buffer, ref position);
            }
        }
Example #6
0
 public Event(string title, DateTime start, DateTime end, BusyStatus status = BusyStatus.Busy)
 {
     StartTime = start;
     EndTime   = end;
     Title     = title;
     Status    = status;
     Details   = string.Empty;
     Tags      = new List <string>();
 }
Example #7
0
        /// 更新临时记录
        /// <summary>
        /// 更新临时记录
        /// </summary>
        /// <param name="state"></param>
        /// <param name="agentAuxState"></param>
        /// <param name="callType"></param>
        /// <param name="agTime"></param>
        /// <param name="startTime"></param>
        /// <returns></returns>
        public void UpdateAgentState2DBAsync(AgentState state, BusyStatus agentAuxState, Calltype callType, int agTime, DateTime startTime)
        {
            int busystate = (int)agentAuxState;

            if (state != AgentState.AS4_置忙)
            {
                busystate = -1;
            }
            agentService.UpdateAgentState2DBAsync(CallRecordAuthorizeCode, (int)state, busystate, (int)callType, agTime, startTime, LoginUser.UserID.ToString());
        }
Example #8
0
        /// 插入临时记录
        /// <summary>
        /// 插入临时记录
        /// </summary>
        /// <param name="state"></param>
        /// <param name="agentAuxState"></param>
        /// <param name="callType"></param>
        /// <param name="agTime"></param>
        /// <param name="startTime"></param>
        /// <returns></returns>
        public void InsertAgentState2DBAsync(AgentState state, BusyStatus agentAuxState, Calltype callType, int agTime, DateTime startTime)
        {
            int busystate = (int)agentAuxState;

            if (state != AgentState.AS4_置忙)
            {
                busystate = -1;
            }
            agentService.InsertAgentState2DBAsync(CallRecordAuthorizeCode, (int)state, busystate, (int)callType, agTime, startTime, LoginUser.UserID.ToString(), LoginUser.TrueName, LoginUser.BGID, LoginUser.ExtensionNum);
        }
Example #9
0
        /// 插入明细记录
        /// <summary>
        /// 插入明细记录
        /// </summary>
        /// <param name="state"></param>
        /// <param name="agentAuxState"></param>
        /// <param name="callType"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public int InsertAgentStateDetail2DB(AgentState state, BusyStatus agentAuxState, Calltype callType, DateTime startTime, DateTime endTime)
        {
            int busystate = (int)agentAuxState;

            if (state != AgentState.AS4_置忙)
            {
                busystate = -1;
            }
            return(agentService.InsertAgentStateDetail2DB(CallRecordAuthorizeCode, (int)state, busystate, (int)callType, startTime, endTime, LoginUser.TrueName, LoginUser.UserID.ToString(), LoginUser.ExtensionNum, Convert.ToInt32(LoginUser.BGID)));
        }
        /// 休息
        /// <summary>
        /// 休息
        /// </summary>
        /// <param name="busystatus"></param>
        /// <returns></returns>
        public bool RestStart(BusyStatus busystatus)
        {
            string name = Util.GetEnumOptText(typeof(BusyStatus), (int)busystatus);

            axUniSoftPhone.SetOneBusiParamData("RestCode", name);
            bool flag = axUniSoftPhone.actRest();

            Loger.Log4Net.Info("[HollyContactHelper]用户操作==休息(" + busystatus + ")->" + flag);
            return(flag);
        }
        private static void ConvertEventToFreeBusy(
            ExchangeUser user,
            EventEntry googleAppsEvent,
            DateTimeRange coveredRange,
            List <DateTimeRange> busyTimes,
            List <DateTimeRange> tentativeTimes)
        {
            DateTime   startDate    = DateTime.MinValue;
            DateTime   endDate      = DateTime.MinValue;
            DateTime   utcStartDate = DateTime.MinValue;
            DateTime   utcEndDate   = DateTime.MinValue;
            BusyStatus userStatus   = BusyStatus.Free;

            userStatus = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent);

            // If the user is free, do not put this meeting in the free busy
            if (userStatus == BusyStatus.Free)
            {
                return;
            }

            startDate    = googleAppsEvent.Times[0].StartTime;
            utcStartDate = DateTime.SpecifyKind(startDate.ToUniversalTime(),
                                                DateTimeKind.Unspecified);
            endDate    = googleAppsEvent.Times[0].EndTime;
            utcEndDate = DateTime.SpecifyKind(endDate.ToUniversalTime(),
                                              DateTimeKind.Unspecified);

            if (utcStartDate < coveredRange.Start)
            {
                coveredRange.Start = utcStartDate;
            }

            if (utcEndDate > coveredRange.End)
            {
                coveredRange.End = utcEndDate;
            }

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Read GData FB event {0} - {1}", startDate, endDate);
                _log.DebugFormat("Write FB event {0} - {1} in UTC", utcStartDate, utcEndDate);
                _log.DebugFormat("The FB status is {0}", userStatus.ToString());
            }

            if (userStatus == BusyStatus.Tentative)
            {
                tentativeTimes.Add(new DateTimeRange(utcStartDate, utcEndDate));
            }
            else
            {
                Debug.Assert(userStatus == BusyStatus.Busy);
                busyTimes.Add(new DateTimeRange(utcStartDate, utcEndDate));
            }
        }
Example #12
0
        private void GenerateResponseForTimeBlock(
            ExchangeUser user,
            FreeBusyTimeBlock timeBlock,
            BusyStatus busyStatus,
            bool firstAppointment,
            StringBuilder result)
        {
            if (timeBlock.Appointments == null || timeBlock.Appointments.Count == 0)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                AppendPrivateFreeBusyEntry(timeBlock.StartDate,
                                           timeBlock.EndDate,
                                           user.CommonName,
                                           busyStatus,
                                           result);
                return;
            }

            foreach (Appointment appt in timeBlock.Appointments)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                if (!appt.IsPrivate)
                {
                    AppendFreeBusyEntry(appt.StartDate,
                                        appt.EndDate,
                                        appt.Subject,
                                        appt.Location,
                                        appt.Organizer,
                                        appt.BusyStatus,
                                        result);
                }
                else
                {
                    AppendPrivateFreeBusyEntry(appt.StartDate,
                                               appt.EndDate,
                                               user.CommonName,
                                               appt.BusyStatus,
                                               result);
                }

                firstAppointment = false;
            }
        }
        public void TestConvertParticipantStatus()
        {
            EventEntry   googleAppsEvent = new EventEntry("title", "description", "location");
            BusyStatus   status          = BusyStatus.Busy;
            ExchangeUser user            = new ExchangeUser();

            user.Email = "*****@*****.**";

            // The user status with no participants should be busy, since this is how the data
            // comes from the free busy projection
            status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent);
            Assert.AreEqual(status, BusyStatus.Busy);

            Who john = new Who();

            googleAppsEvent.Participants.Add(john);
            john.Email = user.Email;

            // Attendee with no status should be converted to busy.
            status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent);
            Assert.AreEqual(status, BusyStatus.Busy);

            john.Attendee_Status = new Who.AttendeeStatus();

            // Accepted attendee should be converted to busy.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED;
            status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent);
            Assert.AreEqual(status, BusyStatus.Busy);

            // Declined attendee should be converted to free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED;
            status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent);
            Assert.AreEqual(status, BusyStatus.Free);

            // Tentative attendee should be converted to tentative.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE;
            status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent);
            Assert.AreEqual(status, BusyStatus.Tentative);

            // Attendee who hasn't responded yet should be converted to free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED;
            status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent);
            Assert.AreEqual(status, BusyStatus.Tentative);

            // Attendee with bogus status should be converted to buys.
            john.Attendee_Status.Value = "Abrakadabra";
            status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent);
            Assert.AreEqual(status, BusyStatus.Busy);
        }
Example #14
0
 private void AppendPrivateFreeBusyEntry(
     DateTime startUtc,
     DateTime endUtc,
     string commonName,
     BusyStatus busyStatus,
     StringBuilder result)
 {
     AppendFreeBusyEntry(startUtc,
                         endUtc,
                         "",
                         "",
                         commonName,
                         busyStatus,
                         result);
 }
        /// <summary>
        /// Converst Exchange raster free busy string to FreeBusy
        /// </summary>
        /// <param name="baseTime">The start date of the free busy</param>
        /// <param name="freeBusyInterval">The granularity of the free busy in minutes</param>
        /// <param name="freeBusyRaster">The raster to parse</param>
        /// <param name="freeBusy">The free busy result</param>
        /// <returns>void</returns>
        public static void ParseRasterFreeBusy(
            DateTime baseTime,
            int freeBusyInterval,
            string freeBusyRaster,
            FreeBusy freeBusy)
        {
            BusyStatus oldState = BusyStatus.Free;
            int        startRun = 0;
            int        idx      = 0;

            if (string.IsNullOrEmpty(freeBusyRaster))
            {
                return;
            }

            log.DebugFormat("Parsing the raster {0}", freeBusyRaster);

            foreach (char current in freeBusyRaster)
            {
                BusyStatus newState = ConvertRasterToFreeBusy(current);

                if (newState != oldState)
                {
                    RecordFreeBusyInterval(baseTime,
                                           oldState,
                                           freeBusyInterval,
                                           startRun,
                                           idx,
                                           freeBusy);

                    oldState = newState;
                    startRun = idx;
                }

                idx++;
            }

            RecordFreeBusyInterval(baseTime,
                                   oldState,
                                   freeBusyInterval,
                                   startRun,
                                   idx,
                                   freeBusy);

            log.DebugFormat("Parsed the raster into {0} busy and {1} tentative ranges",
                            freeBusy.Busy.Count,
                            freeBusy.Tentative.Count);
        }
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return((TransactionId.HasValue
                            ? TransactionId.GetHashCode() * 31
                            : 0) ^

                       PartnerId.GetHashCode() * 29 ^
                       OperatorId.GetHashCode() * 23 ^
                       EVSEId.GetHashCode() * 21 ^


                       (AvailabilityStatusEventDate.HasValue
                            ? AvailabilityStatusEventDate.GetHashCode() * 19
                            : 0) ^

                       (AvailabilityStatus.HasValue
                            ? AvailabilityStatus.GetHashCode() * 17
                            : 0) ^

                       (AvailabilityStatusUntil.HasValue
                            ? AvailabilityStatusUntil.GetHashCode() * 13
                            : 0) ^

                       (AvailabilityStatusComment.IsNeitherNullNorEmpty()
                            ? AvailabilityStatusComment.GetHashCode() * 11
                            : 0) ^


                       (BusyStatusEventDate.HasValue
                            ? BusyStatusEventDate.GetHashCode() * 7
                            : 0) ^

                       (BusyStatus.HasValue
                            ? BusyStatus.GetHashCode() * 3
                            : 0) ^

                       (BusyStatusUntil.HasValue
                            ? BusyStatusUntil.GetHashCode() * 3
                            : 0) ^

                       (BusyStatusComment.IsNeitherNullNorEmpty()
                            ? BusyStatusComment.GetHashCode()
                            : 0));
            }
        }
Example #17
0
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return(EVSEId.GetHashCode() * 11 ^
                       StatusEventDate.GetHashCode() * 7 ^
                       BusyStatus.GetHashCode() * 5 ^

                       (BusyStatusUntil.HasValue
                            ? BusyStatusUntil.GetHashCode() * 3
                            : 0) ^

                       (BusyStatusComment.IsNeitherNullNorEmpty()
                            ? BusyStatusComment.GetHashCode()
                            : 0));
            }
        }
Example #18
0
        /// <summary>
        /// Compares two EVSEBusyStatus for equality.
        /// </summary>
        /// <param name="EVSEBusyStatus">An EVSEBusyStatus to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(EVSEBusyStatus EVSEBusyStatus)
        {
            if ((Object)EVSEBusyStatus == null)
            {
                return(false);
            }

            return(EVSEId.Equals(EVSEBusyStatus.EVSEId) &&
                   StatusEventDate.Equals(EVSEBusyStatus.StatusEventDate) &&
                   BusyStatus.Equals(EVSEBusyStatus.BusyStatus) &&

                   ((!BusyStatusUntil.HasValue && !EVSEBusyStatus.BusyStatusUntil.HasValue) ||
                    (BusyStatusUntil.HasValue && EVSEBusyStatus.BusyStatusUntil.HasValue && BusyStatusUntil.Value.Equals(EVSEBusyStatus.BusyStatusUntil.Value))) &&

                   ((!BusyStatusComment.IsNeitherNullNorEmpty() && !EVSEBusyStatus.BusyStatusComment.IsNeitherNullNorEmpty()) ||
                    (BusyStatusComment.IsNeitherNullNorEmpty() && EVSEBusyStatus.BusyStatusComment.IsNeitherNullNorEmpty() && BusyStatusComment.Equals(EVSEBusyStatus.BusyStatusComment))));
        }
Example #19
0
        /// <summary>
        /// The to outlook.
        /// </summary>
        /// <param name="status">
        /// The status.
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// </exception>
        public static OlBusyStatus ToOutlook(this BusyStatus status)
        {
            switch (status)
            {
            case BusyStatus.Free:
                return(OlBusyStatus.olFree);

            case BusyStatus.Busy:
                return(OlBusyStatus.olBusy);

            case BusyStatus.OutOfOffice:
                return(OlBusyStatus.olOutOfOffice);

            case BusyStatus.Tentative:
                return(OlBusyStatus.olTentative);

            default:
                throw new ArgumentOutOfRangeException("status", status, Resources.NoValueTranslationMessage);
            }
        }
        /// <summary>
        /// Convert a Google Calender attendee status to an Exchange status
        /// </summary>
        /// <param name="googleAppsEvent">The Google Calendar event</param>
        /// <param name="user">The user to get the status for</param>
        /// <returns>The Exchange status for the given user</returns>
        public static BusyStatus ConvertParticipantStatus(
            ExchangeUser user,
            EventEntry googleAppsEvent)
        {
            BusyStatus result = BusyStatus.Busy;
            // Default is busy, because in order to make free-buys projections work correctly,
            // since in that case the participants are not set at all.

            string externalEmail = ConfigCache.MapToExternalDomain(user.Email);

            foreach (Who participant in googleAppsEvent.Participants)
            {
                if (!string.IsNullOrEmpty(participant.Email) &&
                    (participant.Email.Equals(user.Email) ||
                     participant.Email.Equals(externalEmail)))
                {
                    switch (SafeGetValue(participant.Attendee_Status))
                    {
                    case Who.AttendeeStatus.EVENT_ACCEPTED:
                        result = BusyStatus.Busy;
                        break;

                    case Who.AttendeeStatus.EVENT_DECLINED:
                        result = BusyStatus.Free;
                        break;

                    case Who.AttendeeStatus.EVENT_INVITED:
                        result = BusyStatus.Tentative;
                        break;

                    case Who.AttendeeStatus.EVENT_TENTATIVE:
                        result = BusyStatus.Tentative;
                        break;
                    }

                    break;
                }
            }

            return(result);
        }
Example #21
0
        /// <summary>
        /// Create a new appointment
        /// </summary>
        public Appointment()
        {
            Created = DateUtil.NowUtc;
            range   = new DateTimeRange(Created, Created);

            Body      = string.Empty;
            Subject   = string.Empty;
            Location  = string.Empty;
            Comment   = string.Empty;
            Organizer = string.Empty;

            BusyStatus     = BusyStatus.Free;
            ResponseStatus = ResponseStatus.None;
            InstanceType   = InstanceType.Single;
            MeetingStatus  = MeetingStatus.Tentative;

            IsPrivate   = false;
            AllDayEvent = false;

            HRef = string.Empty;
        }
        /// <summary>
        /// Compares two SetEVSEBusyStatus requests for equality.
        /// </summary>
        /// <param name="SetEVSEBusyStatusRequest">A SetEVSEBusyStatus request to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(SetEVSEBusyStatusRequest SetEVSEBusyStatusRequest)
        {
            if ((Object)SetEVSEBusyStatusRequest == null)
            {
                return(false);
            }

            return(((!TransactionId.HasValue && !SetEVSEBusyStatusRequest.TransactionId.HasValue) ||
                    (TransactionId.HasValue && SetEVSEBusyStatusRequest.TransactionId.HasValue && TransactionId.Value.Equals(SetEVSEBusyStatusRequest.TransactionId.Value))) &&

                   PartnerId.Equals(SetEVSEBusyStatusRequest.PartnerId) &&
                   OperatorId.Equals(SetEVSEBusyStatusRequest.OperatorId) &&
                   EVSEId.Equals(SetEVSEBusyStatusRequest.EVSEId) &&
                   StatusEventDate.Equals(SetEVSEBusyStatusRequest.StatusEventDate) &&
                   BusyStatus.Equals(SetEVSEBusyStatusRequest.BusyStatus) &&

                   ((!BusyStatusUntil.HasValue && !SetEVSEBusyStatusRequest.BusyStatusUntil.HasValue) ||
                    (BusyStatusUntil.HasValue && SetEVSEBusyStatusRequest.BusyStatusUntil.HasValue && BusyStatusUntil.Value.Equals(SetEVSEBusyStatusRequest.BusyStatusUntil.Value))) &&

                   ((!BusyStatusComment.IsNeitherNullNorEmpty() && !SetEVSEBusyStatusRequest.BusyStatusComment.IsNeitherNullNorEmpty()) ||
                    (BusyStatusComment.IsNeitherNullNorEmpty() && SetEVSEBusyStatusRequest.BusyStatusComment.IsNeitherNullNorEmpty() && BusyStatusComment.Equals(SetEVSEBusyStatusRequest.BusyStatusComment))));
        }
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return((TransactionId.HasValue
                            ? TransactionId.GetHashCode() * 23
                            : 0) ^

                       PartnerId.GetHashCode() * 21 ^
                       OperatorId.GetHashCode() * 17 ^
                       EVSEId.GetHashCode() * 13 ^
                       StatusEventDate.GetHashCode() * 11 ^
                       BusyStatus.GetHashCode() * 7 ^

                       (BusyStatusUntil.HasValue
                            ? BusyStatusUntil.GetHashCode() * 5
                            : 0) ^

                       (BusyStatusComment.IsNeitherNullNorEmpty()
                            ? BusyStatusComment.GetHashCode() * 3
                            : 0));
            }
        }
Example #24
0
 internal static uint ParseBusyStatus(BusyStatus status)
 {
     if (status == BusyStatus.Free)
     {
         return(0);
     }
     else if (status == BusyStatus.Tentative)
     {
         return(1);
     }
     else if (status == BusyStatus.Busy)
     {
         return(2);
     }
     else if (status == BusyStatus.OutOfOffice)
     {
         return(3);
     }
     else
     {
         return(0);
     }
 }
        private static void RecordFreeBusyInterval(
            DateTime baseTime,
            BusyStatus state,
            int freeBusyInterval,
            int start,
            int end,
            FreeBusy freeBusy)
        {
            DateTime      eventStart = baseTime.AddMinutes(start * freeBusyInterval);
            DateTime      eventEnd   = baseTime.AddMinutes(end * freeBusyInterval);
            DateTimeRange range      = new DateTimeRange(eventStart, eventEnd);

            // Handle the state
            switch (state)
            {
            default:
            case BusyStatus.Free:
                // We don't record these
                break;

            case BusyStatus.Busy:
                // Busy is recorded in busy and all
                freeBusy.All.Add(range);
                freeBusy.Busy.Add(range);
                break;

            case BusyStatus.Tentative:
                freeBusy.Tentative.Add(range);
                break;

            case BusyStatus.OutOfOffice:
                // OOO is recorded in out of office and all
                freeBusy.All.Add(range);
                freeBusy.OutOfOffice.Add(range);
                break;
            }
        }
        private void AppendFreeBusyEntry(
            DateTime startUtc,
            DateTime endUtc,
            string subject,
            string location,
            string organizer,
            BusyStatus busyStatus,
            StringBuilder result)
        {
            DateTime startLocal = OlsonUtil.ConvertFromUTC(startUtc, Request.TimeZone);
            DateTime endLocal = OlsonUtil.ConvertFromUTC(endUtc, Request.TimeZone);
            int status = ConversionsUtil.ConvertBusyStatusToGoogleResponse(busyStatus);

            ConversionsUtil.EscapeNonAlphaNumeric(subject, escapedSubject);
            ConversionsUtil.EscapeNonAlphaNumeric(location, escapedLocation);
            ConversionsUtil.EscapeNonAlphaNumeric(organizer, escapedOrganizer);

            result.AppendFormat("['{0}','{1}','{2}','{3}','{4}',{5}]",
                                escapedSubject,
                                DateUtil.FormatDateTimeForGoogle(startLocal),
                                DateUtil.FormatDateTimeForGoogle(endLocal),
                                escapedLocation,
                                escapedOrganizer,
                                status);
        }
        /// <summary>
        /// Return the user status, with support for tentative, if the event has the needed details.
        /// </summary>
        /// <param name="googleAppsEvent">The Google Calendar event</param>
        /// <param name="user">The user to get the status for</param>
        /// <returns>The Exchange status for the given user</returns>
        public static BusyStatus GetUserStatusForEvent(
            ExchangeUser user,
            EventEntry googleAppsEvent)
        {
            MeetingStatus meetingStatus = MeetingStatus.Confirmed;
            BusyStatus    userStatus    = BusyStatus.Free;

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Looking the status of {0} in {1}",
                                 user.Email,
                                 googleAppsEvent.Title.Text);
            }

            // Treat events w/o proper times as free. There isn't much we can do.
            if (googleAppsEvent.Times == null || googleAppsEvent.Times.Count == 0)
            {
                return(BusyStatus.Free);
            }

            meetingStatus = ConvertGoogleEventStatus(googleAppsEvent.Status);

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("The event status is {0}", meetingStatus.ToString());
            }

            // If the meeting is cancelled, treat it as free time.
            if (meetingStatus == MeetingStatus.Cancelled)
            {
                return(BusyStatus.Free);
            }

            // And if it's transparent, also treat it as free.
            if (GoogleEventIsTransparent(googleAppsEvent))
            {
                return(BusyStatus.Free);
            }

            userStatus = ConvertParticipantStatus(user, googleAppsEvent);
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("The user status is {0}", userStatus.ToString());
            }

            if (userStatus == BusyStatus.Free)
            {
                return(BusyStatus.Free);
            }

            // There is no mapping from GCal to OOF right now. If/when it is added, it should
            // be handled in a manner similar to busy and tentative.
            Debug.Assert(userStatus != BusyStatus.OutOfOffice);

            // If the meeting is set to show as tentative, set the time as tentative, not busy
            // if the user accepted the meeting.
            if (meetingStatus == MeetingStatus.Tentative && userStatus == BusyStatus.Busy)
            {
                userStatus = BusyStatus.Tentative;
            }

            return(userStatus);
        }
Example #28
0
        /// <summary>
        /// Return a text representation of this object.
        /// </summary>
        public override String ToString()

        => String.Concat(EVSEId, " -> ", BusyStatus.AsText());
        /// <summary>
        /// Create a new appointment
        /// </summary>
        public Appointment()
        {
            Created = DateUtil.NowUtc;
            range = new DateTimeRange(Created, Created);

            Body = string.Empty;
            Subject = string.Empty;
            Location = string.Empty;
            Comment = string.Empty;
            Organizer = string.Empty;

            BusyStatus = BusyStatus.Free;
            ResponseStatus = ResponseStatus.None;
            InstanceType = InstanceType.Single;
            MeetingStatus = MeetingStatus.Tentative;

            IsPrivate = false;
            AllDayEvent = false;

            HRef = string.Empty;
        }
        public void AddModifiedInstanceAttachment(DateTime originalStartDTUtc, int originalDuration, DateTime newStartDTUtc, int duration, string subject, string location, BusyStatus busyStatus, int color, MessagePriority priority, TimeZoneInfo timezone)
        {
            AttachmentObject            attachment       = AttachmentObject.CreateNewExceptionAttachmentObject(this.File, this.SubnodeBTree);
            ModifiedAppointmentInstance modifiedInstance = ModifiedAppointmentInstance.CreateNewModifiedInstance(attachment.File, attachment.SubnodeBTree);

            modifiedInstance.SetStartAndDuration(newStartDTUtc, duration);
            modifiedInstance.AlternateRecipientAllowed = true;
            modifiedInstance.Subject  = subject;
            modifiedInstance.Location = location;
            //modifiedInstance.Sensitivity = 0;
            modifiedInstance.Priority             = priority;
            modifiedInstance.BusyStatus           = busyStatus;
            modifiedInstance.Color                = color;
            modifiedInstance.MessageFlags         = MessageFlags.MSGFLAG_READ;
            modifiedInstance.ExceptionReplaceTime = originalStartDTUtc;
            modifiedInstance.StartDate            = originalStartDTUtc;
            modifiedInstance.EndDate              = originalStartDTUtc.AddMinutes(originalDuration);

            modifiedInstance.SaveChanges(attachment.SubnodeBTree);
            attachment.StoreModifiedInstance(modifiedInstance, timezone);
            attachment.SaveChanges(this.SubnodeBTree);
            this.AddAttachment(attachment);
        }
        private static void RecordFreeBusyInterval(
            DateTime baseTime,
            BusyStatus state,
            int freeBusyInterval,
            int start,
            int end,
            FreeBusy freeBusy)
        {
            DateTime eventStart = baseTime.AddMinutes(start * freeBusyInterval);
            DateTime eventEnd = baseTime.AddMinutes(end * freeBusyInterval);
            DateTimeRange range = new DateTimeRange(eventStart, eventEnd);

            // Handle the state
            switch (state)
            {
                default:
                case BusyStatus.Free:
                    // We don't record these
                    break;

                case BusyStatus.Busy:
                    // Busy is recorded in busy and all
                    freeBusy.All.Add(range);
                    freeBusy.Busy.Add(range);
                    break;

                case BusyStatus.Tentative:
                    freeBusy.Tentative.Add(range);
                    break;

                case BusyStatus.OutOfOffice:
                    // OOO is recorded in out of office and all
                    freeBusy.All.Add(range);
                    freeBusy.OutOfOffice.Add(range);
                    break;
            }
        }
        /// <summary>
        /// Convert an Exchange Event Busy Status to a Google Calendar response
        /// </summary>
        /// <param name="busyStatus">The Exchange event status</param>
        /// <returns>The Google Calendar response</returns>
        public static int ConvertBusyStatusToGoogleResponse(BusyStatus busyStatus)
        {
            GCalResponseStatus googleStatus = GCalResponseStatus.Uninvited;

            switch (busyStatus)
            {
                case BusyStatus.OutOfOffice:
                case BusyStatus.Busy:
                    googleStatus = GCalResponseStatus.Accepted;
                    break;

                case BusyStatus.Free:
                    googleStatus = GCalResponseStatus.Declined;
                    break;

                case BusyStatus.Tentative:
                    googleStatus = GCalResponseStatus.Tentative;
                    break;

                default:
                    googleStatus = GCalResponseStatus.Uninvited;
                    break;
            }

            return (int)googleStatus;
        }
 public static void SetStatus(UIElement control, BusyStatus value)
 {
     control.SetValue(StatusProperty, value);
 }
 private void AppendPrivateFreeBusyEntry(
     DateTime startUtc,
     DateTime endUtc,
     string commonName,
     BusyStatus busyStatus,
     StringBuilder result)
 {
     AppendFreeBusyEntry(startUtc,
                         endUtc,
                         "",
                         "",
                         commonName,
                         busyStatus,
                         result);
 }
        /// <summary>
        /// Return a text representation of this object.
        /// </summary>
        public override String ToString()

        => String.Concat(PartnerId, " / ",
                         OperatorId, ": ",
                         EVSEId, " -> ", BusyStatus.AsText());
        private void GenerateResponseForTimeBlock(
            ExchangeUser user,
            FreeBusyTimeBlock timeBlock,
            BusyStatus busyStatus,
            bool firstAppointment,
            StringBuilder result)
        {
            if (timeBlock.Appointments == null || timeBlock.Appointments.Count == 0)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                AppendPrivateFreeBusyEntry(timeBlock.StartDate,
                                           timeBlock.EndDate,
                                           user.CommonName,
                                           busyStatus,
                                           result);
                return;
            }

            foreach (Appointment appt in timeBlock.Appointments)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                if (!appt.IsPrivate)
                {
                    AppendFreeBusyEntry(appt.StartDate,
                                        appt.EndDate,
                                        appt.Subject,
                                        appt.Location,
                                        appt.Organizer,
                                        appt.BusyStatus,
                                        result);
                }
                else
                {
                    AppendPrivateFreeBusyEntry(appt.StartDate,
                                               appt.EndDate,
                                               user.CommonName,
                                               appt.BusyStatus,
                                               result);
                }

                firstAppointment = false;
            }
        }
		public static void SetStatus( UIElement control, BusyStatus value )
		{
			control.SetValue( StatusProperty, value );
		}