Ejemplo n.º 1
0
        public EmailDataSet GetEventAlertEmailsByDate(DateTime sendDate)
        {
            var retDataset = new EmailDataSet();


            try
            {
                if (igniteConn.State != System.Data.ConnectionState.Open)
                {
                    igniteConn.Open();
                }
                SqlCommand cmd = igniteConn.CreateCommand();
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = "spGetEventAlertEmailByDate";


                var p = new SqlParameter("sendDate", sendDate);


                cmd.Parameters.Add(p);

                SqlDataReader reader = cmd.ExecuteReader();
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        var sysParam = retDataset.Email.NewEmailRow();

                        sysParam.Id           = int.Parse(reader["Id"].ToString());
                        sysParam.Body         = reader["Body"].ToString();
                        sysParam.Subject      = reader["Subject"].ToString();
                        sysParam.isUser       = bool.Parse(reader["isUser"].ToString());
                        sysParam.Location     = reader["Location"].ToString();
                        sysParam.EventId      = int.Parse(reader["EventId"].ToString());
                        sysParam.Event        = reader["Event"].ToString();
                        sysParam.BeginDate    = DateTime.Parse(reader["BeginDate"].ToString());
                        sysParam.EndDate      = DateTime.Parse(reader["EndDate"].ToString());
                        sysParam.BeginTime    = TimeSpan.Parse(reader["BeginTime"].ToString());
                        sysParam.EndTime      = TimeSpan.Parse(reader["EndTime"].ToString());
                        sysParam.Organisation = reader["Organisation"].ToString();

                        retDataset.Email.AddEmailRow(sysParam);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (igniteConn.State != System.Data.ConnectionState.Closed)
                {
                    igniteConn.Close();
                }
            }

            return(retDataset);
        }
Ejemplo n.º 2
0
        public override global::System.Data.DataSet Clone()
        {
            EmailDataSet cln = ((EmailDataSet)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Ejemplo n.º 3
0
        public EmailDataSet GetEventAlertEmailsByDate(DateTime sendDate)
        {
            var retDataset = new EmailDataSet();

            
                try
                {
                    if (igniteConn.State != System.Data.ConnectionState.Open) { igniteConn.Open(); }
                    SqlCommand cmd = igniteConn.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "spGetEventAlertEmailByDate";

                   
                        var p = new SqlParameter("sendDate",sendDate);
                    
                    
                    cmd.Parameters.Add(p);

                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            var sysParam = retDataset.Email.NewEmailRow();

                            sysParam.Id = int.Parse(reader["Id"].ToString());
                            sysParam.Body = reader["Body"].ToString();
                            sysParam.Subject = reader["Subject"].ToString();
                            sysParam.isUser = bool.Parse(reader["isUser"].ToString());
                            sysParam.Location  = reader["Location"].ToString();
                            sysParam.EventId = int.Parse(reader["EventId"].ToString());
                            sysParam.Event = reader["Event"].ToString();
                            sysParam.BeginDate = DateTime.Parse(reader["BeginDate"].ToString());
                            sysParam.EndDate = DateTime.Parse(reader["EndDate"].ToString());
                            sysParam.BeginTime = TimeSpan.Parse(reader["BeginTime"].ToString());
                            sysParam.EndTime = TimeSpan.Parse(reader["EndTime"].ToString());
                            sysParam.Organisation = reader["Organisation"].ToString();

                            retDataset.Email.AddEmailRow(sysParam);
                        }
                        reader.Close();
                    }

                }
                catch (Exception ex)
                {
                    throw;
                }
                finally
                {
                    if (igniteConn.State != System.Data.ConnectionState.Closed)
                    {
                        igniteConn.Close();
                    }
                }
            
            return retDataset;
        }
Ejemplo n.º 4
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            EmailDataSet ds = new EmailDataSet();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Ejemplo n.º 5
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                EmailDataSet ds = new EmailDataSet();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "EmailDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
Ejemplo n.º 6
0
        protected void btnSaveAlertEmail_OnClick(object sender, EventArgs e)
        {
            DateTime _sendDate;
            int      _msgType;

            if (txtDaysBeforeAfterEmail.Text == "")
            {
                txtDaysBeforeAfterEmail.Text = "0";
            }

            if (emailId.Value == "")
            {
                emailId.Value = "0";
            }

            if (smsId.Value == "")
            {
                smsId.Value = "0";
            }

            if (messagetypes.SelectedValue == "1")
            {
                TimeSpan sub = new TimeSpan(int.Parse(txtDaysBeforeAfterEmail.Text), 0, 0, 0);
                _sendDate = DateTime.Parse(Session["beginDate"].ToString()).Subtract(sub);
                _msgType  = 1;
            }
            else if (messagetypes.SelectedValue == "2")
            {
                _sendDate = DateTime.Parse(Session["beginDate"].ToString());
                _msgType  = 2;
            }
            else if (messagetypes.SelectedValue == "3")
            {
                TimeSpan add = new TimeSpan(int.Parse(txtDaysBeforeAfterEmail.Text), 0, 0, 0);
                _sendDate = DateTime.Parse(Session["endDate"].ToString()).Add(add);
                _msgType  = 3;
            }
            else
            {
                SetToast("error", "Select a message type!");
                return;
            }

            bool _isUser;

            if (recipients.SelectedValue == "True")
            {
                _isUser = true;
            }
            else if (recipients.SelectedValue == "False")
            {
                _isUser = false;
            }
            else
            {
                SetToast("error", "Select a recipient!");
                return;
            }


            var emDS = new EmailDataSet();

            emDS.Email.AddEmailRow(int.Parse(emailId.Value), eventId, _sendDate, txtSubject.Text, txtBody.Text, _isUser,
                                   false, _msgType, eventNameParam);


            if (Utilities.editId == 3 || Utilities.editId == 4)
            {
                int result = dataProvider.UpdateEventAlertEmail(userToken, emDS);

                if (result != -1)
                {
                    SetToast("success", "Alert Email updated.");
                }
                else
                {
                    SetToast("errror", "An error occured, this type of email exists already.");
                }
            }
            else
            {
                int result = dataProvider.AddEventAlertEmail(userToken, emDS);

                if (result != -1)
                {
                    SetToast("success", "Alert Email added.");
                }
                else
                {
                    SetToast("errror", "An error occured, this type of email exists already.");
                }
            }

            initFields();
        }
Ejemplo n.º 7
0
        public EmailDataSet GetEventAlertEmail(string userToken, int eventId, int msgType, bool isUser)
        {

            var retDataset = new EmailDataSet();

            if (IsUserTokenValid(userToken))
            {
                try
                {
                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "spGetEventAlertEmail";

                    var p = new SqlParameter[3];
                    for (int i = 0; i < 3; i++)
                    {
                        p[i] = new SqlParameter();
                    }

                    p[0] = new SqlParameter("eventId", eventId);
                    p[1] = new SqlParameter("msgType", msgType);
                    p[2] = new SqlParameter("isUser", isUser);

                    cmd.Parameters.AddRange(p);

                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            var sysParam = retDataset.Email.NewEmailRow();

                            sysParam.Id = int.Parse(reader["Id"].ToString());
                            sysParam.Body = reader["Body"].ToString();
                            sysParam.Subject = reader["Subject"].ToString();
                            sysParam.isUser = bool.Parse(reader["isUser"].ToString());
                            sysParam.Processed = bool.Parse(reader["Processed"].ToString());
                            sysParam.EventId = int.Parse(reader["EventId"].ToString());
                            sysParam.Event = reader["Event"].ToString();
                            sysParam.SendDate = DateTime.Parse(reader["SendDate"].ToString());
                            sysParam.MessageType = int.Parse(reader["MessageType"].ToString());


                            retDataset.Email.AddEmailRow(sysParam);
                        }
                        reader.Close();
                    }

                }
                catch (Exception ex)
                {
                    throw new OperationFailedException(ex.Message, ex);
                }
                finally
                {
                    if (conn.State != System.Data.ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            }
            return retDataset;
        }
Ejemplo n.º 8
0
        public int UpdateEventAlertEmail(string userToken, EmailDataSet sysParameter)
        {
            int newId = -1;
            if (IsUserTokenValid(userToken))
            {
                try
                {
                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "spUpdateEventAlertEmail";

                    var p2 = new SqlParameter[9];
                    for (int i = 0; i < 9; i++)
                        p2[i] = new SqlParameter();

                    p2[1] = new SqlParameter("subject", sysParameter.Email[0].Subject);
                    p2[2] = new SqlParameter("body", sysParameter.Email[0].Body);
                    p2[3] = new SqlParameter("sendDate", sysParameter.Email[0].SendDate);
                    p2[4] = new SqlParameter("processed", sysParameter.Email[0].Processed);
                    p2[5] = new SqlParameter("updateUser", _userId);
                    p2[6] = new SqlParameter("eventId", sysParameter.Email[0].EventId);
                    p2[7] = new SqlParameter("isUser", sysParameter.Email[0].isUser);
                    p2[8] = new SqlParameter("msgType", sysParameter.Email[0].MessageType);
                    p2[0] = new SqlParameter("id", sysParameter.Email[0].Id);

                    cmd.Parameters.AddRange(p2);

                    newId = int.Parse(cmd.ExecuteScalar().ToString());

                }
                catch (Exception ex)
                {
                    throw new OperationFailedException(ex.Message, ex);
                }
                finally
                {
                    if (conn.State != System.Data.ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            }
            return newId;
        }
Ejemplo n.º 9
0
        protected void btnSaveAlertEmail_OnClick(object sender, EventArgs e)
        {
            DateTime _sendDate;
            int _msgType;

            if (txtDaysBeforeAfterEmail.Text == "")
                txtDaysBeforeAfterEmail.Text = "0";

            if (emailId.Value == "")
                emailId.Value = "0";

            if (smsId.Value == "")
                smsId.Value = "0";

            if (messagetypes.SelectedValue == "1")
            {

                TimeSpan sub = new TimeSpan(int.Parse(txtDaysBeforeAfterEmail.Text),0,0,0);
                _sendDate = DateTime.Parse(Session["beginDate"].ToString()).Subtract(sub);
                _msgType = 1;
            }
            else if (messagetypes.SelectedValue == "2")
            {
                _sendDate = DateTime.Parse(Session["beginDate"].ToString());
                _msgType = 2;
            }
            else if (messagetypes.SelectedValue == "3")
            {
                TimeSpan add = new TimeSpan(int.Parse(txtDaysBeforeAfterEmail.Text), 0, 0, 0);
                _sendDate = DateTime.Parse(Session["endDate"].ToString()).Add(add);
                _msgType = 3;
            }
            else
            {
                SetToast("error","Select a message type!");
                return;
            }

            bool _isUser;

            if (recipients.SelectedValue == "True")
            {
                _isUser = true;
            }
            else if (recipients.SelectedValue == "False")
            {
                _isUser = false;
            }
            else
            {
                SetToast("error","Select a recipient!");
                return;
            }


            var emDS = new EmailDataSet();
            emDS.Email.AddEmailRow(int.Parse(emailId.Value), eventId, _sendDate, txtSubject.Text, txtBody.Text, _isUser,
                false, _msgType, eventNameParam);
            
           
            if (Utilities.editId == 3 || Utilities.editId == 4)
            {
                int result = dataProvider.UpdateEventAlertEmail(userToken, emDS);
                
                if (result != -1)
                {
                    SetToast("success", "Alert Email updated.");

                }
                else
                {
                    SetToast("errror", "An error occured, this type of email exists already.");
                }
            }
            else
            {
                int result = dataProvider.AddEventAlertEmail(userToken,emDS);
                
                if (result != -1)
                {
                    SetToast("success", "Alert Email added.");

                }
                else
                {
                    SetToast("errror", "An error occured, this type of email exists already.");
                }
            }

            initFields();
        }