private void HandleChannelSubscriber_NotifyLeave(RPCContext context) { LeaveNotification leaveNotification = LeaveNotification.ParseFrom(context.Payload); base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyLeave: " + leaveNotification); ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId); if (channelReferenceObject == null) { base.ApiLog.LogError("HandleChannelSubscriber_NotifyLeave had unexpected traffic for objectId : " + context.Header.ObjectId); return; } switch (channelReferenceObject.m_channelData.m_channelType) { case ChannelAPI.ChannelType.CHAT_CHANNEL: case ChannelAPI.ChannelType.GAME_CHANNEL: break; case ChannelAPI.ChannelType.PARTY_CHANNEL: this.m_battleNet.Party.PartyMemberLeft(channelReferenceObject, leaveNotification); break; default: return; } ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData; if (channelData != null) { channelData.m_members.Remove(leaveNotification.MemberId); if (!this.m_battleNet.GameAccountId.Equals(leaveNotification.MemberId)) { this.m_battleNet.Presence.PresenceUnsubscribe(leaveNotification.MemberId); } } }
public static LeaveNotification CreateRequestHandled(LeaveRequest request, IStringLocalizer localizer) { LeaveNotification notification = new LeaveNotification() { EventArgs = new { Controller = "LeaveRequests", Action = "EmployeeRequests" }, EventDate = request.RequestedDate }; string status = String.Empty; if (request.RequestCancelled) { status = localizer["Cancelled"]; } else { if (request.Approuved == true) { status = localizer["Approuved"]; } else if (request.Approuved == false) { status = localizer["Rejected"]; } } notification.EventMessage = localizer["Your request for {0} was {1}", request.LeaveType.LeaveTypeName, status]; return(notification); }
public static LeaveNotification CreateRequestAdded(LeaveRequest request, IStringLocalizer localizer) { LeaveNotification notification = new LeaveNotification() { EventArgs = new { requestId = request.Id, Controller = "LeaveRequests", Action = "Review" }, EventDate = request.RequestedDate }; notification.EventMessage = localizer["You have new pending request for {0} from {1}", request.LeaveType.LeaveTypeName, request.RequestingEmployee.FormatEmployeeSNT()]; return(notification); }
public ActionResult Review(long id, LeaveStatus status, string reason) { var taken = db.leaves_takens.Single(x => x.id == id); taken.status = (byte)status; taken.reason = reason; if (status == LeaveStatus.APPROVED) { // check that staff still has enough leave var alloc = taken.leaves_allocated; if (alloc.remaining.HasValue && taken.days > alloc.remaining) { return(Json("Staff does not have enough leave remaining".ToJsonFail())); } if (alloc.remaining.HasValue) { alloc.remaining -= taken.days; Debug.Assert(alloc.remaining >= 0); } } repository.Save(); // notify applicant var emailmodel = new LeaveNotification(); emailmodel.receiver = taken.user.ToName(false); emailmodel.leavetakenID = taken.id; emailmodel.status = status.ToString(); emailmodel.reason = reason; this.SendEmailNow( EmailViewType.LEAVE_UPDATED, emailmodel, string.Format("Leave #{0} {1}", emailmodel.leavetakenID, emailmodel.status), taken.user.email, emailmodel.receiver); var viewmodel = "Leave application reviewed successfully".ToJsonOKMessage(); viewmodel.data = this.RenderViewToString("IndexRows", new[] { taken }.ToModel(auth.perms.HasFlag(Permission.LEAVE_REVIEW), sessionid.Value, auth.perms)); return(Json(viewmodel)); }
public override void NotifyLeave(Google.ProtocolBuffers.IRpcController controller, LeaveNotification request, Action<bnet.protocol.NO_RESPONSE> done) { throw new NotImplementedException(); }
BattlenetRpcErrorCode HandleOnLeave(LeaveNotification request) { Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnLeave: {1}", GetCallerInfo(), request.ToString()); return(BattlenetRpcErrorCode.RpcNotImplemented); }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream) { switch (methodId) { case 1: { JoinNotification request = new JoinNotification(); request.MergeFrom(stream); BattlenetRpcErrorCode status = HandleOnJoin(request); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnJoin(bgs.protocol.channel.v1.JoinNotification: {1}) status: {2}.", GetCallerInfo(), request.ToString(), status); if (status != 0) { SendResponse(token, status); } break; } case 2: { MemberAddedNotification request = new MemberAddedNotification(); request.MergeFrom(stream); BattlenetRpcErrorCode status = HandleOnMemberAdded(request); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnMemberAdded(bgs.protocol.channel.v1.MemberAddedNotification: {1}) status: {2}.", GetCallerInfo(), request.ToString(), status); if (status != 0) { SendResponse(token, status); } break; } case 3: { LeaveNotification request = new LeaveNotification(); request.MergeFrom(stream); BattlenetRpcErrorCode status = HandleOnLeave(request); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnLeave(bgs.protocol.channel.v1.LeaveNotification: {1}) status: {2}.", GetCallerInfo(), request.ToString(), status); if (status != 0) { SendResponse(token, status); } break; } case 4: { MemberRemovedNotification request = new MemberRemovedNotification(); request.MergeFrom(stream); BattlenetRpcErrorCode status = HandleOnMemberRemoved(request); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnMemberRemoved(bgs.protocol.channel.v1.MemberRemovedNotification: {1}) status: {2}.", GetCallerInfo(), request.ToString(), status); if (status != 0) { SendResponse(token, status); } break; } case 5: { SendMessageNotification request = new SendMessageNotification(); request.MergeFrom(stream); BattlenetRpcErrorCode status = HandleOnSendMessage(request); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnSendMessage(bgs.protocol.channel.v1.SendMessageNotification: {1}) status: {2}.", GetCallerInfo(), request.ToString(), status); if (status != 0) { SendResponse(token, status); } break; } case 6: { UpdateChannelStateNotification request = new UpdateChannelStateNotification(); request.MergeFrom(stream); BattlenetRpcErrorCode status = HandleOnUpdateChannelState(request); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnUpdateChannelState(bgs.protocol.channel.v1.UpdateChannelStateNotification: {1}) status: {2}.", GetCallerInfo(), request.ToString(), status); if (status != 0) { SendResponse(token, status); } break; } case 7: { UpdateMemberStateNotification request = new UpdateMemberStateNotification(); request.MergeFrom(stream); BattlenetRpcErrorCode status = HandleOnUpdateMemberState(request); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnUpdateMemberState(bgs.protocol.channel.v1.UpdateMemberStateNotification: {1}) status: {2}.", GetCallerInfo(), request.ToString(), status); if (status != 0) { SendResponse(token, status); } break; } default: Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId); SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod); break; } }
public override void NotifyLeave(Google.ProtocolBuffers.IRpcController controller, LeaveNotification request, Action <bnet.protocol.NO_RESPONSE> done) { throw new NotImplementedException(); }