Beispiel #1
0
        protected void set_messages_as_seen(Guid?threadId, ref string responseText)
        {
            //Privacy Check: OK
            if (!paramsContainer.GBEdit)
            {
                return;
            }

            if (!threadId.HasValue || !MSGController.has_message(paramsContainer.Tenant.Id,
                                                                 null, paramsContainer.CurrentUserID.Value, threadId, null))
            {
                responseText = "{\"ErrorText\":\"" + Messages.AccessDenied + "\"}";
                return;
            }

            int msgCount = 0, sentCount = 0, notSeenCount = 0;

            bool result = MSGController.set_messages_as_seen(paramsContainer.Tenant.Id,
                                                             paramsContainer.CurrentUserID.Value, threadId.Value);

            if (result)
            {
                MSGController.get_thread_info(paramsContainer.Tenant.Id,
                                              threadId.Value, paramsContainer.CurrentUserID.Value, ref msgCount, ref sentCount, ref notSeenCount);
            }

            responseText = !result ? "{\"ErrorText\":\"" + Messages.OperationFailed + "\"}" :
                           "{\"Succeed\":\"" + Messages.OperationCompletedSuccessfully + "\"" +
                           ",\"ThreadInfo\":" + _get_thread_info_json(msgCount, sentCount, notSeenCount) + "}";
        }
Beispiel #2
0
        protected void get_thread_users(Guid?threadId, int?count, int?lastId, ref string responseText)
        {
            //Privacy Check: OK
            if (!paramsContainer.GBEdit)
            {
                return;
            }

            if (!lastId.HasValue)
            {
                lastId = -1;
            }

            if (!threadId.HasValue || !MSGController.has_message(paramsContainer.Tenant.Id,
                                                                 null, paramsContainer.CurrentUserID.Value, threadId, null))
            {
                responseText = "{\"ErrorText\":\"" + Messages.AccessDenied + "\"}";
                return;
            }

            List <User> users = MSGController.get_thread_users(paramsContainer.Tenant.Id,
                                                               threadId.Value, paramsContainer.CurrentUserID.Value, count, lastId);

            responseText = "{\"Users\":[" +
                           ProviderUtil.list_to_string <string>(users.Select(
                                                                    u => "{\"UserID\":\"" + u.UserID.ToString() + "\"" +
                                                                    ",\"UserName\":\"" + Base64.encode(u.UserName) + "\"" +
                                                                    ",\"FirstName\":\"" + Base64.encode(u.FirstName) + "\"" +
                                                                    ",\"LastName\":\"" + Base64.encode(u.LastName) + "\"" +
                                                                    ",\"ProfileImageURL\":\"" + DocumentUtilities.get_personal_image_address(paramsContainer.Tenant.Id,
                                                                                                                                             u.UserID.Value) + "\"}").ToList()) +
                           "]}";
        }
Beispiel #3
0
        protected void remove_message(long?id, ref string responseText)
        {
            //Privacy Check: OK
            if (!paramsContainer.GBEdit)
            {
                return;
            }

            if (!id.HasValue ||
                !MSGController.has_message(paramsContainer.Tenant.Id, id, paramsContainer.CurrentUserID.Value, null, null))
            {
                responseText = "{\"ErrorText\":\"" + Messages.AccessDenied + "\"}";
                return;
            }

            bool result = id.HasValue && MSGController.remove_message(paramsContainer.Tenant.Id, id.Value);

            responseText = result ? "{\"Succeed\":\"" + Messages.OperationCompletedSuccessfully + "\"}" :
                           "{\"ErrorText\":\"" + Messages.OperationFailed + "\"}";
        }
Beispiel #4
0
        protected void get_forwarded_messages(Guid?messageId, int?count, int?lastId, ref string responseText)
        {
            //Privacy Check: OK
            if (!paramsContainer.GBEdit)
            {
                return;
            }

            if (!messageId.HasValue || !MSGController.has_message(paramsContainer.Tenant.Id,
                                                                  null, paramsContainer.CurrentUserID.Value, null, messageId))
            {
                responseText = "{\"ErrorText\":\"" + Messages.AccessDenied + "\"}";
                return;
            }

            List <Message> fwdMessages = MSGController.get_forwarded_messages(paramsContainer.Tenant.Id, messageId.Value);

            responseText = "{\"ForwardedMessages\": [";
            bool isFirst = true;

            List <DocFileInfo> attachments = DocumentsController.get_owner_files(paramsContainer.Tenant.Id,
                                                                                 fwdMessages.Where(u => u.HasAttachment.HasValue && u.HasAttachment.Value).Select(v => v.MessageID.Value).ToList());

            List <Message> messageUsers = MSGController.get_message_receivers(paramsContainer.Tenant.Id,
                                                                              fwdMessages.Select(m => m.MessageID.Value).ToList(), count);

            foreach (Message msg in messageUsers)
            {
                Message ms = fwdMessages.Where(m => m.MessageID == msg.MessageID).FirstOrDefault();

                ms.ReceiverUsers  = msg.ReceiverUsers;
                ms.ReceiversCount = msg.ReceiversCount;
            }

            foreach (Message msg in fwdMessages)
            {
                responseText += (isFirst ? string.Empty : ",") +
                                "{\"ID\":\"" + msg.ID.ToString() + "\"" +
                                ",\"MessageID\":\"" + msg.MessageID.Value.ToString() + "\"" +
                                ",\"IsGroup\":" + (msg.IsGroup.HasValue && msg.IsGroup.Value).ToString().ToLower() +
                                ",\"SenderUserID\":\"" + msg.SenderUserID.ToString() + "\"" +
                                ",\"SenderUserName\":\"" + Base64.encode(msg.SenderUserName) + "\"" +
                                ",\"SenderFirstName\":\"" + Base64.encode(msg.SenderFirstName) + "\"" +
                                ",\"SenderLastName\":\"" + Base64.encode(msg.SenderLastName) + "\"" +
                                ",\"SenderProfileImageURL\":\"" + DocumentUtilities.get_personal_image_address(
                    paramsContainer.Tenant.Id, msg.SenderUserID.Value) + "\"" +
                                ",\"Title\":\"" + Base64.encode(msg.Title) + "\"" +
                                ",\"MessageText\":\"" + Base64.encode(msg.MessageText) + "\"" +
                                ",\"SendDate\":\"" + PublicMethods.get_local_date(msg.SendDate.Value, true) + "\"" +
                                ",\"ForwardedFrom\":\"" + (msg.ForwardedFrom.HasValue ? msg.ForwardedFrom.Value.ToString() : "") + "\"" +
                                ",\"AttachedFiles\":" + DocumentUtilities.get_files_json(paramsContainer.Tenant.Id, attachments.Where(u => u.OwnerID == msg.MessageID).ToList(), true) +
                                ",\"Level\":" + msg.Level.ToString().ToLower() +
                                ",\"ReceiversCount\":" + (msg.ReceiversCount.HasValue ? msg.ReceiversCount.Value : 0).ToString() +
                                ",\"ReceiverUsers\":[" +
                                ProviderUtil.list_to_string <string>(msg.ReceiverUsers.Select(
                                                                         u => "{\"UserID\":\"" + u.UserID.ToString() + "\"" +
                                                                         ",\"UserName\":\"" + Base64.encode(u.UserName) + "\"" +
                                                                         ",\"FirstName\":\"" + Base64.encode(u.FirstName) + "\"" +
                                                                         ",\"LastName\":\"" + Base64.encode(u.LastName) + "\"" +
                                                                         ",\"ProfileImageURL\":\"" + DocumentUtilities.get_personal_image_address(
                                                                             paramsContainer.Tenant.Id, u.UserID.Value) + "\"}").ToList()) +
                                "]}";
                isFirst = false;
            }

            responseText += "]}";
        }