Esempio n. 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);
 }
Esempio n. 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));
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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());
            }
        }
Esempio n. 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()));
            }
        }
Esempio n. 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
                }
            }
        }
Esempio n. 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
                }
            }
        }