Пример #1
0
func (this *Counter) ReadNotificationItem(input *ReadNotificationInput, reply *CountNotification) (err error) {

	defer func() {
		if x := recover(); x != nil {
			utils.PrintfStackAndError("Error: %+v \n For:", x.(error), input)
		}
	}()

	var myCount *qortexapi.MyCount
	serv, err := MakeWsService(input.OrganizationId, input.ReaderId)
	if err != nil {
		utils.PrintStackAndError(err)
		return
	}
	if myCount, err = serv.ReadNotificationItem(input.NotificationItemId, input.GroupId); err != nil {
		utils.PrintStackAndError(err)
		return
	}

	if serv.OnlineUser == nil {
		return
	}

	newReply := CountNotification{
		Method:           COUNTER_READ_NOTIFICATION,
		MyCount:          myCount,
		NewMessageNumber: len(serv.OnlineUser.NewMessageIds),
	}
	serv.OnlineUser.SendReply(newReply)

	return
}
Пример #2
0
func (this *Counter) ReadEntry(input *ReadEntryInput, reply *CountNotification) (err error) {

	defer func() {
		if x := recover(); x != nil {
			utils.PrintfStackAndError("Error: %+v \n For:", x.(error), input)
		}
	}()

	if !input.isValid() {
		return
	}

	var myCount *qortexapi.MyCount
	serv, err := MakeWsService(input.OrganizationId, input.ReaderId)
	if err != nil {
		utils.PrintStackAndError(err)
		return
	}

	var method string
	switch {
	case input.isReadEntry():
		method = COUNTER_READ_ENTRY
		myCount, err = serv.ReadEntry(input.EntryId, input.GroupId)
	case input.isReadMyMessage():
		method = COUNTER_READ_MESSAGE
		myCount, err = serv.ReadMyMessage(input.ConversationId)
	default:
		return
	}
	if err != nil {
		utils.PrintStackAndError(err)
		return
	}

	if serv.OnlineUser == nil {
		return
	}

	newReply := CountNotification{
		Method:           method,
		EntryId:          input.EntryId,
		GroupId:          input.GroupId,
		MyCount:          myCount,
		NewMessageNumber: serv.OnlineUser.ClearNewMessageId(),
	}
	serv.OnlineUser.SendReply(newReply)

	return
}
Пример #3
0
func (this *Counter) Refresh(input *RefreshInput, reply *CountNotification) (err error) {

	defer func() {
		if x := recover(); x != nil {
			utils.PrintfStackAndError("Error: %+v \n For:", x.(error), input)
		}
	}()

	reply.Method = COUNTER_REFRESH
	serv, err := MakeWsService(input.OrganizationId, input.LoggedInUserId)
	if err != nil {
		utils.PrintStackAndError(err)
		return
	}

	reply.MyCount, err = serv.GetMyCount()
	if err != nil {
		utils.PrintStackAndError(err)
		return
	}
	return
}