예제 #1
0
 public static AutoMail Create (AutoMailType type, Organization org, Geography geo,
                                Person author, string title, string body)
 {
     SwarmDb.GetDatabaseForWriting().SetAutoMail (type, org.Identity, geo.Identity,
                                         author == null ? 0 : author.Identity, title, body);
     return FromTypeOrganizationAndGeography (type, org, geo);
 }
예제 #2
0
 public static AutoMail Create(AutoMailType type, Organization org, Geography geo,
                               Person author, string title, string body)
 {
     SwarmDb.GetDatabaseForWriting().SetAutoMail(type, org.Identity, geo.Identity,
                                                 author == null ? 0 : author.Identity, title, body);
     return(FromTypeOrganizationAndGeography(type, org, geo));
 }
예제 #3
0
 /// <summary>
 /// Basic constructor.
 /// </summary>
 public BasicAutoMail (int autoMailId, AutoMailType type, int organizationId, int geographyId,
                       int authorPersonId, string title, string body)
 {
     this.autoMailId = autoMailId;
     this.type = type;
     this.organizationId = organizationId;
     this.geographyId = geographyId;
     this.authorPersonId = authorPersonId;
     this.title = title;
     this.body = body;
 }
예제 #4
0
 /// <summary>
 /// Basic constructor.
 /// </summary>
 public BasicAutoMail(int autoMailId, AutoMailType type, int organizationId, int geographyId,
                      int authorPersonId, string title, string body)
 {
     this.autoMailId     = autoMailId;
     this.type           = type;
     this.organizationId = organizationId;
     this.geographyId    = geographyId;
     this.authorPersonId = authorPersonId;
     this.title          = title;
     this.body           = body;
 }
예제 #5
0
        private static BasicAutoMail ReadAutoMailFromDataReader(DbDataReader reader)
        {
            int          autoMailId     = reader.GetInt32(0);
            AutoMailType type           = (AutoMailType)Enum.Parse(typeof(AutoMailType), reader.GetString(1));
            int          geographyId    = reader.GetInt32(3);
            int          organizationId = reader.GetInt32(2);
            int          authorPersonId = reader.GetInt32(4); // appear to be unused?
            string       title          = reader.GetString(5);
            string       body           = reader.GetString(6);

            return(new BasicAutoMail(autoMailId, type, organizationId, geographyId, authorPersonId,
                                     title, body));
        }
예제 #6
0
        public static AutoMail FromTypeOrganizationAndGeography(AutoMailType type, Organization org, Geography geo)
        {
            BasicAutoMail basic = SwarmDb.GetDatabaseForReading().GetAutoMail(type, org.Identity, geo.Identity);

            if (basic == null)
            {
                return(null);
            }

            if (basic.Body.Trim().Length < 3)
            {
                return(null); // If there is no body, there is no mail
            }

            return(FromBasic(basic));
        }
예제 #7
0
        public static AutoMail FromTypeOrganizationAndGeography (AutoMailType type, Organization org, Geography geo)
        {
            BasicAutoMail basic = SwarmDb.GetDatabaseForReading().GetAutoMail (type, org.Identity, geo.Identity);

            if (basic == null)
            {
                return null;
            }

            if (basic.Body.Trim().Length < 3)
            {
                return null; // If there is no body, there is no mail
            }

            return FromBasic (basic);
        }
예제 #8
0
        public int SetAutoMail (AutoMailType type, int organizationId, int geographyId,
                                int authorPersonId, string title, string body)
        {
            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

                DbCommand command = GetDbCommand("SetAutoMail", connection);
                command.CommandType = CommandType.StoredProcedure;

                AddParameterWithName(command, "autoMailType", type.ToString());
                AddParameterWithName(command, "organizationId", organizationId);
                AddParameterWithName(command, "geographyId", geographyId);
                AddParameterWithName(command, "authorPersonId", authorPersonId);
                AddParameterWithName(command, "title", title);
                AddParameterWithName(command, "body", body);

                return Convert.ToInt32(command.ExecuteScalar());
            }
        }
예제 #9
0
        public int SetAutoMail(AutoMailType type, int organizationId, int geographyId,
                               int authorPersonId, string title, string body)
        {
            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

                DbCommand command = GetDbCommand("SetAutoMail", connection);
                command.CommandType = CommandType.StoredProcedure;

                AddParameterWithName(command, "autoMailType", type.ToString());
                AddParameterWithName(command, "organizationId", organizationId);
                AddParameterWithName(command, "geographyId", geographyId);
                AddParameterWithName(command, "authorPersonId", authorPersonId);
                AddParameterWithName(command, "title", title);
                AddParameterWithName(command, "body", body);

                return(Convert.ToInt32(command.ExecuteScalar()));
            }
        }
예제 #10
0
        public BasicAutoMail GetAutoMail (AutoMailType type, int organizationId, int geographyId)
        {
            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

                DbCommand command =
                    GetDbCommand(
                        "select AutoMails.AutoMailId,AutoMailTypes.Name,AutoMails.OrganizationId,AutoMails.GeographyId,AutoMails.AuthorPersonId,Title,Body " + 
                        "FROM AutoMails JOIN AutoMailTypes USING (AutoMailTypeId) " +
                        "WHERE AutoMailTypes.Name='" + type.ToString() + "' AND AutoMails.OrganizationId=" + organizationId.ToString() + " AND AutoMails.GeographyId=" + geographyId.ToString(), connection);

                using (DbDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        return ReadAutoMailFromDataReader(reader);
                    }

                    return null; // NULL returned - unusual; usually exception is thrown if not found
                }
            }
        }
예제 #11
0
        public BasicAutoMail GetAutoMail(AutoMailType type, int organizationId, int geographyId)
        {
            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

                DbCommand command =
                    GetDbCommand(
                        "select AutoMails.AutoMailId,AutoMailTypes.Name,AutoMails.OrganizationId,AutoMails.GeographyId,AutoMails.AuthorPersonId,Title,Body " +
                        "FROM AutoMails JOIN AutoMailTypes USING (AutoMailTypeId) " +
                        "WHERE AutoMailTypes.Name='" + type.ToString() + "' AND AutoMails.OrganizationId=" + organizationId.ToString() + " AND AutoMails.GeographyId=" + geographyId.ToString(), connection);

                using (DbDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        return(ReadAutoMailFromDataReader(reader));
                    }

                    return(null); // NULL returned - unusual; usually exception is thrown if not found
                }
            }
        }