Ejemplo n.º 1
0
        // =============================
        //   CONSTRUCTION AND CREATION
        // =============================


        /// <summary>
        /// Basic constructor. This is for database use and NOT for public construction.
        /// </summary>
        public BasicOutboundMail (int outboundMailId, MailAuthorType authorType, int authorPersonId, string title,
                                  string body, int mailPriority, int mailTypeId, int organizationId,
                                  int geographyId,
                                  DateTime createdDateTime, DateTime releaseDateTime, bool readyForPickup, bool resolved,
                                  bool processed,
                                  DateTime resolvedDateTime, DateTime startProcessDateTime, DateTime endProcessDateTime,
                                  int recipientCount, int recipientsSuccess, int recipientsFail)
        {
            this.outboundMailId = outboundMailId;
            this.authorType = authorType;
            this.authorPersonId = authorPersonId;
            this.title = title;
            this.body = body;
            this.mailPriority = mailPriority;
            this.mailType = mailTypeId;
            this.geographyId = geographyId;
            this.organizationId = organizationId;
            this.createdDateTime = createdDateTime;
            this.releaseDateTime = releaseDateTime;
            this.readyForPickup = readyForPickup;
            this.resolved = resolved;
            this.processed = processed;
            this.resolvedDateTime = resolvedDateTime;
            this.startProcessDateTime = startProcessDateTime;
            this.endProcessDateTime = endProcessDateTime;
            this.recipientCount = recipientCount;
            this.recipientsSuccess = recipientsSuccess;
            this.recipientsFail = recipientsFail;

            // phew.
        }
Ejemplo n.º 2
0
        // =============================
        //   CONSTRUCTION AND CREATION
        // =============================


        /// <summary>
        /// Basic constructor. This is for database use and NOT for public construction.
        /// </summary>
        public BasicOutboundMail(int outboundMailId, MailAuthorType authorType, int authorPersonId, string title,
                                 string body, int mailPriority, int mailTypeId, int organizationId,
                                 int geographyId,
                                 DateTime createdDateTime, DateTime releaseDateTime, bool readyForPickup, bool resolved,
                                 bool processed,
                                 DateTime resolvedDateTime, DateTime startProcessDateTime, DateTime endProcessDateTime,
                                 int recipientCount, int recipientsSuccess, int recipientsFail)
        {
            this.outboundMailId       = outboundMailId;
            this.authorType           = authorType;
            this.authorPersonId       = authorPersonId;
            this.title                = title;
            this.body                 = body;
            this.mailPriority         = mailPriority;
            this.mailType             = mailTypeId;
            this.geographyId          = geographyId;
            this.organizationId       = organizationId;
            this.createdDateTime      = createdDateTime;
            this.releaseDateTime      = releaseDateTime;
            this.readyForPickup       = readyForPickup;
            this.resolved             = resolved;
            this.processed            = processed;
            this.resolvedDateTime     = resolvedDateTime;
            this.startProcessDateTime = startProcessDateTime;
            this.endProcessDateTime   = endProcessDateTime;
            this.recipientCount       = recipientCount;
            this.recipientsSuccess    = recipientsSuccess;
            this.recipientsFail       = recipientsFail;

            // phew.
        }
Ejemplo n.º 3
0
        public int CreateOutboundMail(MailAuthorType authorType, int authorPersonId, string title,
                                      string body, int mailPriority, int mailType, int geographyId,
                                      int organizationId, DateTime releaseDateTime)
        {
            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

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

                AddParameterWithName(command, "authorType", (int)authorType);
                AddParameterWithName(command, "authorPersonId", authorPersonId);
                AddParameterWithName(command, "title", title);
                AddParameterWithName(command, "body", body);
                AddParameterWithName(command, "mailPriority", mailPriority);
                AddParameterWithName(command, "mailType", mailType);
                AddParameterWithName(command, "geographyId", geographyId);
                AddParameterWithName(command, "organizationId", organizationId);
                AddParameterWithName(command, "createdDateTime", DateTime.Now);
                AddParameterWithName(command, "releaseDateTime", releaseDateTime);

                int result = Convert.ToInt32(command.ExecuteScalar());

                if (result == 0)
                {
                    throw new Exception("Unable to create outbound mail");
                }

                return(result);
            }
        }
Ejemplo n.º 4
0
        private void LoadFunctionalMailAddress()
        {
            if (this.functionalMailDict == null)
            {
                this.functionalMailDict = new Dictionary <MailAuthorType, FunctionalMail.AddressItem>();
                string   funcMails = OptionalData.GetOptionalDataString(ObjectOptionalDataType.OrgFunctionalMail);
                string[] rows      = funcMails.Replace("\r", "\n")
                                     .Replace("\n\n", "\n")
                                     .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

                Regex reSplitAddress = new Regex(@"^(?<Type>.+?):(?<Name>.+)[,;:]\s*(?<Address>\S+?@\S+?)$",
                                                 RegexOptions.IgnoreCase);
                foreach (string row in rows)
                {
                    Match match = reSplitAddress.Match(row);
                    try
                    {
                        MailAuthorType maType =
                            (MailAuthorType)Enum.Parse(typeof(MailAuthorType), match.Groups["Type"].Value);
                        string name    = match.Groups["Name"].Value;
                        string address = match.Groups["Address"].Value;
                        this.functionalMailDict[maType] = new FunctionalMail.AddressItem(address, name);
                    }
                    catch
                    {
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public FunctionalMail.AddressItem GetFunctionalMailAddress(MailAuthorType authorType)
        {
            LoadFunctionalMailAddress();

            if (this.functionalMailDict.ContainsKey(authorType))
            {
                return(this.functionalMailDict[authorType]);
            }
            return(null);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor used by OutboundMail after creating record in db. NOT for other use
 /// </summary>
 public BasicOutboundMail(int outboundMailId, MailAuthorType authorType, int authorPersonId, string title,
                          string body, int mailPriority, int mailType, int organizationId,
                          int geographyId, DateTime createdDateTime, DateTime releaseDateTime)
     : this(outboundMailId, authorType, authorPersonId, title, body,
            mailPriority, mailType, organizationId, geographyId,
            createdDateTime, releaseDateTime,
            false, false, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, 0, 0)
 {
     // nothing more to do
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor used by OutboundMail after creating record in db. NOT for other use
 /// </summary>
 public BasicOutboundMail (int outboundMailId, MailAuthorType authorType, int authorPersonId, string title,
                           string body, int mailPriority, int mailType, int organizationId,
                           int geographyId, DateTime createdDateTime, DateTime releaseDateTime)
     : this(outboundMailId, authorType, authorPersonId, title, body,
             mailPriority, mailType, organizationId, geographyId,
             createdDateTime, releaseDateTime,
             false, false, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, 0, 0)
 {
     // nothing more to do
 }
Ejemplo n.º 8
0
 public void SetFunctionalMailAddress(MailAuthorType authorType, string name, string email)
 {
     if (string.IsNullOrEmpty(email.Trim()))
     {
         functionalMailDict.Remove(authorType);
     }
     else
     {
         functionalMailDict[authorType] = new FunctionalMail.AddressItem(email, name);
     }
     SaveFunctionalMailDict();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates an OutboundMail with a "functional" author.
        /// </summary>
        public static OutboundMail CreateFunctional(MailAuthorType authorType, string title,
                                                    string body, int mailPriority, int mailType,
                                                    int organizationId, int geographyId, DateTime releaseDateTime)
        {
            int mailID = SwarmDb.GetDatabaseForWriting().CreateOutboundMail(authorType, 0, title,
                                                                            body, mailPriority, mailType, geographyId,
                                                                            organizationId, releaseDateTime);

            //Constructing instead of reading back from DB, saves time but..., Don't know if it is a good idea./JL
            return(FromBasic(new BasicOutboundMail(mailID, authorType, 0, title,
                                                   body, mailPriority, mailType, organizationId,
                                                   geographyId, DateTime.Now,
                                                   releaseDateTime)));
        }
Ejemplo n.º 10
0
        public FunctionalMail.AddressItem GetFunctionalMailAddressInh(MailAuthorType authorType)
        {
            LoadFunctionalMailAddress();

            if (this.functionalMailDict.ContainsKey(authorType))
            {
                return(this.functionalMailDict[authorType]);
            }
            if (ParentIdentity != 0)
            {
                return(Parent.GetFunctionalMailAddressInh(authorType));
            }
            if (FunctionalMail.Address.ContainsKey(authorType))
            {
                return(FunctionalMail.Address[authorType]); // Default.
            }
            return(null);
        }
Ejemplo n.º 11
0
        public BasicOutboundMail[] GetDuplicateOutboundMail(MailAuthorType authorType, int authorPersonId, string title,
                                                            string body, int mailPriority, int mailType, int geographyId,
                                                            int organizationId, DateTime createDateTime, int recieverId)
        {
            List <BasicOutboundMail> result = new List <BasicOutboundMail>();

            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();
                DbCommand command =
                    GetDbCommand(
                        "SELECT " + outboundMailFieldSequence +
                        @" INNER JOIN OutboundMailRecipients ON OutboundMailRecipients.OutboundMailId = OutboundMails.OutboundMailId
                            WHERE (OutboundMailRecipients.PersonId = " + recieverId + @") 
                            AND (OutboundMails.AuthorType = " + (int)authorType + @") 
                            AND (OutboundMails.AuthorPersonId = " + authorPersonId + @") 
                            AND (OutboundMails.Title = '" + title + @"') 
                            AND (OutboundMails.Body = '" + body + @"') 
                            AND (OutboundMails.MailPriority = " + mailPriority + @") 
                            AND (OutboundMails.MailType = " + mailType + @") 
                            AND (OutboundMails.OrganizationId = " + organizationId + @") 
                            AND (OutboundMails.GeographyId = " + geographyId + @") 
                            AND (OutboundMails.CreatedDateTime > TO_DATE('" +
                        createDateTime.ToString("yyyy-MM-dd HH:mm:ss") + @"'))", connection);

                command.CommandType = CommandType.Text;

                using (DbDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        result.Add(ReadOutboundMailFromDataReader(reader));
                    }

                    return(result.ToArray());
                }
            }
        }
Ejemplo n.º 12
0
 public OutboundMail CreateFunctionalOutboundMail(MailAuthorType authorType, int mailPriority,
                                                  Organization organization, Geography geography, DateTime releaseDateTime)
 {
     return(OutboundMail.CreateFunctional(authorType, BaseName, SerializePlaceHolders(),
                                          mailPriority, MailType, organization.Identity, geography.Identity, releaseDateTime));
 }
Ejemplo n.º 13
0
 /// <summary>
 ///     Create OutboundMail mail with "functional" sender
 /// </summary>
 public OutboundMail CreateFunctionalOutboundMail(MailAuthorType authorType, int mailPriority,
                                                  Organization organization, Geography geography)
 {
     return(CreateFunctionalOutboundMail(authorType, mailPriority, organization, geography, DateTime.Now));
 }
Ejemplo n.º 14
0
        public BasicOutboundMail[] GetDuplicateOutboundMail (MailAuthorType authorType, int authorPersonId, string title,
                                       string body, int mailPriority, int mailType, int geographyId,
                                       int organizationId, DateTime createDateTime, int recieverId)
        {
            List<BasicOutboundMail> result = new List<BasicOutboundMail>();

            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();
                DbCommand command =
                    GetDbCommand(
                        "SELECT " + outboundMailFieldSequence + @" INNER JOIN OutboundMailRecipients ON OutboundMailRecipients.OutboundMailId = OutboundMails.OutboundMailId
                            WHERE (OutboundMailRecipients.PersonId = " + recieverId + @") 
                            AND (OutboundMails.AuthorType = " + (int)authorType + @") 
                            AND (OutboundMails.AuthorPersonId = " + authorPersonId + @") 
                            AND (OutboundMails.Title = '" + title + @"') 
                            AND (OutboundMails.Body = '" + body + @"') 
                            AND (OutboundMails.MailPriority = " + mailPriority + @") 
                            AND (OutboundMails.MailType = " + mailType + @") 
                            AND (OutboundMails.OrganizationId = " + organizationId + @") 
                            AND (OutboundMails.GeographyId = " + geographyId + @") 
                            AND (OutboundMails.CreatedDateTime > TO_DATE('" + createDateTime.ToString("yyyy-MM-dd HH:mm:ss") + @"'))", connection);

                command.CommandType = CommandType.Text;

                using (DbDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        result.Add(ReadOutboundMailFromDataReader(reader));
                    }

                    return result.ToArray();
                }

            }
        }
Ejemplo n.º 15
0
        public int CreateOutboundMail (MailAuthorType authorType, int authorPersonId, string title,
                                       string body, int mailPriority, int mailType, int geographyId,
                                       int organizationId, DateTime releaseDateTime)
        {
            using (DbConnection connection = GetMySqlDbConnection())
            {
                connection.Open();

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

                AddParameterWithName(command, "authorType", (int)authorType);
                AddParameterWithName(command, "authorPersonId", authorPersonId);
                AddParameterWithName(command, "title", title);
                AddParameterWithName(command, "body", body);
                AddParameterWithName(command, "mailPriority", mailPriority);
                AddParameterWithName(command, "mailType", mailType);
                AddParameterWithName(command, "geographyId", geographyId);
                AddParameterWithName(command, "organizationId", organizationId);
                AddParameterWithName(command, "createdDateTime", DateTime.Now);
                AddParameterWithName(command, "releaseDateTime", releaseDateTime);

                int result = Convert.ToInt32(command.ExecuteScalar());

                if (result == 0)
                {
                    throw new Exception("Unable to create outbound mail");
                }

                return result;
            }
        }
Ejemplo n.º 16
0
 public void SetFunctionalMailAddress (MailAuthorType authorType, string name, string email)
 {
     if (string.IsNullOrEmpty(email.Trim()))
     {
         functionalMailDict.Remove(authorType);
     }
     else
     {
         functionalMailDict[authorType] = new FunctionalMail.AddressItem(email, name);
     }
     SaveFunctionalMailDict();
 }
Ejemplo n.º 17
0
        public FunctionalMail.AddressItem GetFunctionalMailAddress (MailAuthorType authorType)
        {
            LoadFunctionalMailAddress();

            if (functionalMailDict.ContainsKey(authorType))
                return functionalMailDict[authorType];
            else
            {
                return null;
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Create OutboundMail mail with "functional" sender
 /// </summary>
 public OutboundMail CreateFunctionalOutboundMail (MailAuthorType authorType, int mailPriority, Organization organization, Geography geography)
 {
     return CreateFunctionalOutboundMail(authorType, mailPriority, organization, geography, DateTime.Now);
 }
Ejemplo n.º 19
0
 public OutboundMail CreateFunctionalOutboundMail (MailAuthorType authorType, int mailPriority,
                                    Organization organization, Geography geography, DateTime releaseDateTime)
 {
     return OutboundMail.CreateFunctional(authorType, this.BaseName, this.SerializePlaceHolders(),
                                 mailPriority, this.MailType, organization.Identity, geography.Identity, releaseDateTime);
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates an OutboundMail with a "functional" author. 
        /// </summary>
        public static OutboundMail CreateFunctional (MailAuthorType authorType, string title,
                                           string body, int mailPriority, int mailType,
                                           int organizationId, int geographyId, DateTime releaseDateTime)
        {

            int mailID = SwarmDb.GetDatabaseForWriting().CreateOutboundMail(authorType, 0, title,
                                           body, mailPriority, mailType, geographyId,
                                           organizationId, releaseDateTime);

            //Constructing instead of reading back from DB, saves time but..., Don't know if it is a good idea./JL
            return FromBasic(new BasicOutboundMail(mailID, authorType, 0, title,
                                                    body, mailPriority, mailType, organizationId,
                                                    geographyId, DateTime.Now,
                                                    releaseDateTime));
        }
Ejemplo n.º 21
0
        public FunctionalMail.AddressItem GetFunctionalMailAddressInh (MailAuthorType authorType)
        {
            LoadFunctionalMailAddress();

            if (functionalMailDict.ContainsKey(authorType))
                return functionalMailDict[authorType];
            else
            {
                if (this.ParentIdentity != 0)
                    return this.Parent.GetFunctionalMailAddressInh(authorType);
                else if (FunctionalMail.Address.ContainsKey(authorType))
                    return FunctionalMail.Address[authorType];// Default.
                else
                    return null;
            }
        }
Ejemplo n.º 22
0
    private void SaveOptionalFields()
    {
        int orgid = 0;

        int.TryParse(HiddenSelectedOrgID.Value, out orgid);
        if (orgid != 0)
        {
            Organization org = Organization.FromIdentity(orgid);
            DropDownList ddl = null;

            //ShowNamesInNotifications
            ddl = FindControlRecursive(FormView1, "DropDownShowNamesInNotifications") as DropDownList;

            if (ddl.SelectedValue.ToLower() == "true")
            {
                org.ShowNamesInNotifications = true;
            }
            else if (ddl.SelectedValue.ToLower() == "false")
            {
                org.ShowNamesInNotifications = false;
            }
            else
            {
                org.ShowNamesInNotifications = null;
            }

            //UsePaymentStatus
            ddl = FindControlRecursive(FormView1, "DropDownUsePaymentStatus") as DropDownList;

            if (ddl.SelectedValue.ToLower() == "true")
            {
                org.UsePaymentStatus = true;
            }
            else if (ddl.SelectedValue.ToLower() == "false")
            {
                org.UsePaymentStatus = false;
            }
            else
            {
                org.UsePaymentStatus = null;
            }

            //Functional Mail addresses
            GridView gv = FindControlRecursive(FormView1, "GridViewMailEdit") as GridView;
            if (gv != null)
            {
                foreach (GridViewRow gRow in gv.Rows)
                {
                    Label                      LabelType    = FindControlRecursive(gRow, "LabelType") as Label;
                    TextBox                    TextBoxName  = FindControlRecursive(gRow, "TextBoxName") as TextBox;
                    TextBox                    TextBoxEmail = FindControlRecursive(gRow, "TextBoxEmail") as TextBox;
                    MailAuthorType             maType       = (MailAuthorType)Enum.Parse(typeof(MailAuthorType), LabelType.Text);
                    FunctionalMail.AddressItem directItem   = org.GetFunctionalMailAddress(maType);
                    if (directItem == null ||
                        TextBoxName.Text != directItem.Name ||
                        TextBoxEmail.Text != directItem.Email)
                    {
                        FunctionalMail.AddressItem inhItem = org.GetFunctionalMailAddressInh(maType);
                        if (inhItem != null &&
                            TextBoxName.Text == inhItem.Name &&
                            TextBoxEmail.Text == inhItem.Email)
                        {
                            TextBoxName.Text  = "";
                            TextBoxEmail.Text = "";
                        }
                        org.SetFunctionalMailAddress(maType, TextBoxName.Text, TextBoxEmail.Text);
                    }
                }
            }
        }
    }