Inheritance: gov.va.medora.mdo.domain.sm.BaseModel
Ejemplo n.º 1
0
        public Addressee moveMessage(Message message, domain.sm.User user, Folder folder)
        {
            Addressee addressee = getAddressee(message.Id, user.Id);

            checkValidMove(addressee.Folder, folder);

            addressee.Folder = folder;
            addressee.FolderId = folder.Id;
            if (!addressee.Folder.SystemFolder)
            {
                FolderDao folderDao = new FolderDao(_cxn);
                addressee.Folder = folderDao.getUserFolder(user.Id, folder.Id);
            }
            return moveMessage(addressee);
        }
Ejemplo n.º 2
0
        internal static Folder getFolderFromReader(System.Data.IDataReader rdr, Dictionary<string, bool> columnTable)
        {
            Folder folder = new Folder();

            if (columnTable["FOLDER_ID"])
            {
                int idIndex = rdr.GetOrdinal("FOLDER_ID");
                if (!rdr.IsDBNull(idIndex))
                {
                    folder.Id = Convert.ToInt32(rdr.GetDecimal(idIndex));
                }
            }
            if (columnTable["USER_ID"])
            {
                int userIdIndex = rdr.GetOrdinal("USER_ID");
                if (!rdr.IsDBNull(userIdIndex))
                {
                    folder.Owner = new User() { Id = Convert.ToInt32(rdr.GetDecimal(userIdIndex)) };
                }
            }
            if (columnTable["FOLDER_NAME"])
            {
                int nameIndex = rdr.GetOrdinal("FOLDER_NAME");
                if (!rdr.IsDBNull(nameIndex))
                {
                    folder.Name = rdr.GetString(nameIndex);
                }
            }
            if (columnTable["FOLDOPLOCK"])
            {
                int oplockIndex = rdr.GetOrdinal("FOLDOPLOCK");
                if (!rdr.IsDBNull(oplockIndex))
                {
                    folder.Oplock = Convert.ToInt32(rdr.GetDecimal(oplockIndex));
                }
            }

            // set up other folder properties
            if (folder.Id <= 0)
            {
                folder.SystemFolder = true;
                folder.Name = Enum.GetName(typeof(domain.sm.enums.SystemFolderEnum), folder.Id);
            }
            else if (folder.Id > 0) // all system folders have ID < 0
            {
                if (columnTable["FOLDACTIVE"])
                {
                    folder.Active = rdr.GetDecimal(rdr.GetOrdinal("FOLDACTIVE")) == 1;
                }
            }

            return folder;
        }
Ejemplo n.º 3
0
 internal void checkValidMove(Folder oldFolder, Folder newFolder)
 {
     if (oldFolder.Id <= 0 && oldFolder.Id != (Int32)domain.sm.enums.SystemFolderEnum.Deleted && oldFolder.Id != (Int32)domain.sm.enums.SystemFolderEnum.Inbox)
     {
         throw new MdoException("Messages can only be moved out of user folders and inbox/deleted");
     }
     if (newFolder.Id <= 0 && newFolder.Id != (Int32)domain.sm.enums.SystemFolderEnum.Deleted && newFolder.Id != (Int32)domain.sm.enums.SystemFolderEnum.Inbox)
     {
         throw new MdoException("Messages can only be moved to user folders and inbox/deleted");
     }
 }
Ejemplo n.º 4
0
        internal static Addressee getAddresseeFromReader(System.Data.IDataReader rdr, Dictionary <string, bool> columnTable)
        {
            Addressee addr = new Addressee();

            if (columnTable["ADDRESSEE_ID"])
            {
                int idIndex = rdr.GetOrdinal("ADDRESSEE_ID");
                if (!rdr.IsDBNull(idIndex))
                {
                    addr.Id = Convert.ToInt32(rdr.GetDecimal(idIndex));
                }
            }
            if (columnTable["ADDRESSEE_ROLE"])
            {
                int roleIndex = rdr.GetOrdinal("ADDRESSEE_ROLE");
                if (!rdr.IsDBNull(roleIndex))
                {
                    addr.Role = (AddresseeRoleEnum)Convert.ToInt32(rdr.GetDecimal(roleIndex));
                }
            }
            if (columnTable["SECURE_MESSAGE_ID"])
            {
                int smIdIndex = rdr.GetOrdinal("SECURE_MESSAGE_ID");
                if (!rdr.IsDBNull(smIdIndex))
                {
                    addr.Message = new Message()
                    {
                        Id = Convert.ToInt32(rdr.GetDecimal(smIdIndex))
                    };
                }
            }
            if (columnTable["USER_ID"])
            {
                int userIdIndex = rdr.GetOrdinal("USER_ID");
                if (!rdr.IsDBNull(userIdIndex))
                {
                    addr.Owner = new User()
                    {
                        Id = Convert.ToInt32(rdr.GetDecimal(userIdIndex))
                    };
                }
            }
            if (columnTable["ADDROPLOCK"])
            {
                int oplockIndex = rdr.GetOrdinal("ADDROPLOCK");
                if (!rdr.IsDBNull(oplockIndex))
                {
                    addr.Oplock = Convert.ToInt32(rdr.GetDecimal(oplockIndex));
                }
            }
            if (columnTable["FOLDER_ID"])
            {
                int folderIdIndex = rdr.GetOrdinal("FOLDER_ID");
                if (!rdr.IsDBNull(folderIdIndex))
                {
                    addr.FolderId = Convert.ToInt32(rdr.GetDecimal(folderIdIndex));
                }
                addr.Folder = Folder.getFolderFromReader(rdr);
            }
            if (columnTable["READ_DATE"])
            {
                int readDateIndex = rdr.GetOrdinal("READ_DATE");
                if (!rdr.IsDBNull(readDateIndex))
                {
                    addr.ReadDate = rdr.GetDateTime(readDateIndex);
                }
            }
            if (columnTable["REMINDER_DATE"])
            {
                int reminderDateIndex = rdr.GetOrdinal("REMINDER_DATE");
                if (!rdr.IsDBNull(reminderDateIndex))
                {
                    addr.ReminderDate = rdr.GetDateTime(reminderDateIndex);
                }
            }

            return(addr);
        }