Ejemplo n.º 1
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        int id = Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.Category));

        UmbracoCustom.DataTypeValue(id);
    }
Ejemplo n.º 2
0
    private void LoadData()
    {
        int                documentId   = int.Parse(HttpContext.Current.Request.QueryString["id"]);
        Document           Workout      = new Document(documentId);
        int                objectType   = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(o => o.Value.ToLower() == "workout").Id;
        List <PushMessage> pushMessages = new List <PushMessage>();
        string             cn           = UmbracoCustom.GetParameterValue(UmbracoType.Connection);
        SqlDataReader      reader       = SqlHelper.ExecuteReader(cn, CommandType.StoredProcedure, "SelectPushMessage",
                                                                  new SqlParameter {
            ParameterName = "@ObjectId", Value = Workout.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                                                  new SqlParameter {
            ParameterName = "@ObjectType", Value = objectType, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        }
                                                                  );

        while (reader.Read())
        {
            pushMessages.Add(new PushMessage
            {
                Id             = Convert.ToInt32(reader.GetValue(0)),
                Token          = reader.GetValue(1).ToString(),
                NotificationId = Convert.ToInt32(reader.GetValue(2)),
                UserId         = Convert.ToInt32(reader.GetValue(3)),
                UserType       = Convert.ToInt32(reader.GetValue(4)),
                ObjectId       = Convert.ToInt32(reader.GetValue(5)),
                ObjectType     = Convert.ToInt32(reader.GetValue(6)),
                Message        = reader.GetValue(7).ToString(),
                SendDate       = Convert.ToDateTime(reader.GetValue(8))
            });
        }
        GridView.DataSource = pushMessages;
        GridView.DataBind();
    }
Ejemplo n.º 3
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        grid = new Table {
            ID = "grid4", ClientIDMode = ClientIDMode.Static
        };
        pager = new Panel {
            ID = "pager4", ClientIDMode = ClientIDMode.Static
        };

        IEnumerable <PreValue> platforms = UmbracoCustom.DataTypeValue(int.Parse(UmbracoCustom.GetParameterValue(UmbracoType.Platform)));

        platformSelected = new HiddenField {
            ID = "platformSelected", Value = platforms.First().Id.ToString(), ClientIDMode = ClientIDMode.Static
        };

        Panel pnlForm = new Panel {
            ID = "pnlForm4", CssClass = "form-horizontal", ClientIDMode = ClientIDMode.Static
        };

        pnlForm.Controls.Add(grid);
        pnlForm.Controls.Add(pager);
        pnlForm.Controls.Add(platformSelected);

        Controls.Add(pnlForm);
    }
Ejemplo n.º 4
0
    private void HtmlButtonOnServerClick(object sender, EventArgs eventArgs)
    {
        int      documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]);
        Document Gymnast    = new Document(documentId);

        int userType = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "trainer").Id;

        string cn = UmbracoCustom.GetParameterValue(UmbracoType.Connection);

        SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertChat",
                                  new SqlParameter {
            ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@GymnastId", Value = Gymnast.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@Message", Value = HtmlTextArea.Value, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
        },
                                  new SqlParameter {
            ParameterName = "@UserId", Value = User.GetCurrent().Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@UserType", Value = userType, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        }
                                  );
        HtmlTextArea.Value = string.Empty;
        LoadData();
        NotificationMessage();
    }
    private void ButtonOnClick(object sender, EventArgs eventArgs)
    {
        int      documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]);
        Document Workout    = new Document(documentId);
        Document Gymnast    = new Document(Workout.ParentId);
        int      trainerId  = Convert.ToInt32(Gymnast.getProperty("trainer").Value);
        int      memberId   = Convert.ToInt32(Gymnast.getProperty("member").Value);
        Member   member     = new Member(memberId);
        //Label.Text = string.Format("WorkoutId: {0} / TrainerId: {1} ", documentId, Gymnast.getProperty("trainer").Value);

        SmtpClient  client  = new SmtpClient();
        MailMessage message = new MailMessage();

        message.IsBodyHtml = true;
        message.From       = new MailAddress("*****@*****.**");
        message.To.Add(member.Email);
        message.Subject = "MetaFitness";
        message.Body    = "A new workout is available on your account.";
        client.Send(message);

        int userType   = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "trainer").Id;
        int objectType = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(o => o.Value.ToLower() == "workout").Id;

        string cn = UmbracoCustom.GetParameterValue(UmbracoType.Connection);

        SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertEmailMessage",
                                  new SqlParameter {
            ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@UserId", Value = trainerId, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@UserType", Value = userType, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@ObjectId", Value = Workout.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@ObjectType", Value = objectType, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@Email", Value = member.Email, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar
        },
                                  new SqlParameter {
            ParameterName = "@Message", Value = "A new workout is available on your account. Check your MetaFitness App now.", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
        }
                                  );

        LoadData();
    }
Ejemplo n.º 6
0
    public string GetPrevalue(int id)
    {
        StringBuilder result = new StringBuilder();

        result.Append("<select>");
        IEnumerable <PreValue> values = UmbracoCustom.DataTypeValue(id);

        foreach (PreValue preValue in values)
        {
            result.Append(string.Format("<option value='{0}'>{1}</option>", preValue.Id, preValue.Value));
        }
        result.Append("</select>");
        return(result.ToString());
    }
Ejemplo n.º 7
0
    private void SetPostUser(Post post)
    {
        User   user   = umbraco.BusinessLogic.User.GetCurrent();
        Member member = Member.GetCurrentMember();

        if (user != null)
        {
            post.UserId   = user.Id;
            post.UserType = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "trainer").Id;
        }
        else
        {
            post.UserId   = member.Id;
            post.UserType = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "client").Id;
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.Panel"/> class.
    /// </summary>
    public ExerciseControl()
    {
        Category = new DropDownList {
            ID = "category", ClientIDMode = ClientIDMode.Static, AutoPostBack = true, DataTextField = "Value", DataValueField = "Id", EnableViewState = false, ViewStateMode = ViewStateMode.Disabled
        };
        int id = Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.Category));

        Category.DataSource = UmbracoCustom.DataTypeValue(id);
        Category.DataBind();
        Category.SelectedIndexChanged += new EventHandler(Category_SelectedIndexChanged);
        Exercise = new DropDownList {
            ID = "exercise", ClientIDMode = ClientIDMode.Static, AutoPostBack = false, DataTextField = "exercise", DataValueField = "id", EnableViewState = false, ViewStateMode = ViewStateMode.Disabled
        };
        Exercise.TextChanged          += new EventHandler(Exercise_TextChanged);
        Exercise.SelectedIndexChanged += new EventHandler(Exercise_SelectedIndexChanged);
    }
Ejemplo n.º 9
0
    private void ButtonOnClick(object sender, EventArgs eventArgs)
    {
        int      documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]);
        Document Workout    = new Document(documentId);
        Document Gymnast    = new Document(Workout.ParentId);
        int      trainerId  = Convert.ToInt32(Gymnast.getProperty("trainer").Value);
        int      memberId   = Convert.ToInt32(Gymnast.getProperty("member").Value);
        //Label.Text = string.Format("WorkoutId: {0} / TrainerId: {1} ", documentId, Gymnast.getProperty("trainer").Value);

        int userType   = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "trainer").Id;
        int objectType = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(o => o.Value.ToLower() == "workout").Id;

        List <PushNotification> notifications = new List <PushNotification>();
        string        cn     = UmbracoCustom.GetParameterValue(UmbracoType.Connection);
        SqlDataReader reader = SqlHelper.ExecuteReader(cn, CommandType.StoredProcedure, "SelectNotificationByMember",
                                                       new SqlParameter
        {
            ParameterName = "@MemberId",
            Value         = memberId,
            Direction     = ParameterDirection.Input,
            SqlDbType     = SqlDbType.Int
        });

        while (reader.Read())
        {
            notifications.Add(new PushNotification
            {
                Id         = int.Parse(reader.GetValue(0).ToString()),
                MemberId   = int.Parse(reader.GetValue(1).ToString()),
                Token      = reader.GetValue(2).ToString(),
                DeviceId   = int.Parse(reader.GetValue(3).ToString()),
                IsActive   = bool.Parse(reader.GetValue(4).ToString()),
                Device     = reader.GetValue(5).ToString(),
                PlatformId = int.Parse(reader.GetValue(6).ToString()),
                Platform   = UmbracoCustom.PropertyValue(UmbracoType.Platform, reader.GetValue(6))
            });
        }

        foreach (PushNotification notification in notifications)
        {
            //pushService.QueueNotification(NotificationFactory.Apple().ForDeviceToken(notification.Token).WithAlert("A new workout is available on your account.").WithBadge(7));
            pushService.StopAllServices();

            SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertPushMessage",
                                      new SqlParameter {
                ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@Token", Value = notification.Token, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 50
            },
                                      new SqlParameter {
                ParameterName = "@NotificationId", Value = notification.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserId", Value = trainerId, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserType", Value = userType, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectId", Value = Workout.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectType", Value = objectType, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@Message", Value = "A new workout is available on your account.", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
            }
                                      );
        }
        LoadData();
    }
Ejemplo n.º 10
0
    public void NotificationTask()
    {
        foreach (Member member in Member.GetAllAsList().Where(m => m.getProperty("isActive").Value.ToString() == "1"))
        {
            SmtpClient  client  = new SmtpClient();
            MailMessage message = new MailMessage();
            message.IsBodyHtml = true;
            message.From       = new MailAddress("*****@*****.**");
            message.To.Add(member.Email);
            message.Subject = "MetaFitness";
            message.Body    = "It's time. Let's check in on those results. Submit yours now through your MetaFitness App.";
            client.Send(message);

            string cn = UmbracoCustom.GetParameterValue(UmbracoType.Connection);
            SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertEmailMessage",
                                      new SqlParameter {
                ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserId", Value = new User("system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectId", Value = Convert.ToInt32(member.getProperty("gymnast").Value), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(u => u.Value.ToLower() == "gymnast").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@Email", Value = member.Email, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar
            },
                                      new SqlParameter {
                ParameterName = "@Message", Value = "It's time. Let's check in on those results. Submit yours now through your MetaFitness App.", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
            }
                                      );

            foreach (PushNotification notification in SelectNotificationByMember(member.Id))
            {
                pushService.QueueNotification(new AppleNotification().ForDeviceToken(notification.Token).WithAlert("It's time. Let's check in on those results. Submit yours now.").WithBadge(7));
                pushService.StopAllServices();

                SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertPushMessage",
                                          new SqlParameter {
                    ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@Token", Value = notification.Token, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 50
                },
                                          new SqlParameter {
                    ParameterName = "@NotificationId", Value = notification.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@UserId", Value = new User("system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@UserType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@ObjectId", Value = Convert.ToInt32(member.getProperty("gymnast").Value), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@ObjectType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(u => u.Value.ToLower() == "gymnast").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@Message", Value = "It's time. Let's check in on those results. Submit yours now.", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
                }
                                          );
            }
        }
    }
Ejemplo n.º 11
0
    public void NotificationMessasge(int topicId, int postId)
    {
        foreach (Post post in SelectTopicNotification(topicId))
        {
            SmtpClient  client  = new SmtpClient();
            MailMessage message = new MailMessage();
            message.IsBodyHtml = true;
            message.From       = new MailAddress("*****@*****.**");
            message.To.Add(new Member(post.UserId).Email);
            message.Subject = "MetaFitness";
            message.Body    = (post.IsOwner ? "A message you created has a new response. Check your MetaFitness App now." : "A message you commented on has a new response. Check your MetaFitness App now.");
            client.Send(message);

            string cn = UmbracoCustom.GetParameterValue(UmbracoType.Connection);
            SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertEmailMessage",
                                      new SqlParameter {
                ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserId", Value = new User("system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectId", Value = (post.IsOwner ? topicId : postId), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(u => u.Value.ToLower() == (post.IsOwner ? "topic" : "post")).Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@Email", Value = new Member(post.UserId).Email, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar
            },
                                      new SqlParameter {
                ParameterName = "@Message", Value = (post.IsOwner ? "A message you created has a new response. Check your MetaFitness App now." : "A message you commented on has a new response. Check your MetaFitness App now."), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
            }
                                      );


            foreach (PushNotification notification in SelectNotificationByMember(post.UserId))
            {
                pushService.QueueNotification(new AppleNotification().ForDeviceToken(notification.Token).WithAlert((post.IsOwner ? "A message you created has a new response." : "A message you commented on has a new response.")).WithBadge(7));
                pushService.StopAllServices();

                SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertPushMessage",
                                          new SqlParameter {
                    ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@Token", Value = notification.Token, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 50
                },
                                          new SqlParameter {
                    ParameterName = "@NotificationId", Value = notification.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@UserId", Value = new User("system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@UserType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@ObjectId", Value = (post.IsOwner ? topicId : postId), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@ObjectType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(u => u.Value.ToLower() == (post.IsOwner ? "topic" : "post")).Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
                },
                                          new SqlParameter {
                    ParameterName = "@Message", Value = (post.IsOwner ? "A message you created has a new response." : "A message you commented on has a new response."), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
                }
                                          );
            }
        }
    }
Ejemplo n.º 12
0
    //void Category_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    Exercise.Items.Clear();
    //    Exercise.DataSource = GetExerciseByCategory();
    //    Exercise.DataBind();
    //}

    //void Add_Click(object sender, EventArgs e)
    //{
    //    int documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]);
    //    Document document = new Document(documentId);
    //    Document parentDocument = new Document(document.ParentId);

    //    int id = 0;
    //    string cn = ConfigurationManager.AppSettings["umbracoDbDSN"];
    //    string cmd = "InsertRoutine";
    //    SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, cmd,
    //        new SqlParameter { ParameterName = "@Id", Value = id, Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int },
    //        new SqlParameter { ParameterName = "@DocumentId", Value = parentDocument.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int },
    //        new SqlParameter { ParameterName = "@ExerciseId", Value = Exercise.SelectedValue, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int },
    //        new SqlParameter { ParameterName = "@MemberId", Value = Convert.ToInt32(parentDocument.getProperty("member").Value), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int },
    //        new SqlParameter { ParameterName = "@TrainerId", Value = Convert.ToInt32(parentDocument.getProperty("trainer").Value), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int },
    //        new SqlParameter { ParameterName = "@WorkoutId", Value = document.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int },
    //        new SqlParameter { ParameterName = "@Value", Value = Value.Text, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal }
    //        );

    //    GetRoutineByWorkout();
    //}

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        //this.Controls.Add(Category);
        //this.Controls.Add(Exercise);
        //this.Controls.Add(Value);
        //this.Controls.Add(State);
        //this.Controls.Add(Add);
        //this.Controls.Add(Result);
        grid = new Table {
            ID = "grid1", ClientIDMode = ClientIDMode.Static
        };
        pager = new Panel {
            ID = "pager1", ClientIDMode = ClientIDMode.Static
        };

        Panel pnlTemplate = new Panel();

        inputText = new HtmlInputText {
            ID = "templateName", ClientIDMode = ClientIDMode.Static
        };
        button = new HtmlButton {
            ID = "addWorkout", InnerText = "Add Workout to your repository ", ClientIDMode = ClientIDMode.Static
        };
        pnlTemplate.Controls.Add(new Label {
            Text = "Template Name"
        });
        pnlTemplate.Controls.Add(inputText);
        pnlTemplate.Controls.Add(button);

        //Panel pnlApplyTemplate = new Panel();
        //select = new HtmlSelect{ID = "ddlTemplate", DataSource = SelectTemplate()};
        //select.DataBind();
        //buttonApply = new HtmlButton { ID = "applyTemplate", InnerText = "Apply Template", ClientIDMode = ClientIDMode.Static };

        //pnlApplyTemplate.Controls.Add(new Label { Text = "Templates" });
        //pnlApplyTemplate.Controls.Add(select);
        //pnlApplyTemplate.Controls.Add(buttonApply);


        IEnumerable <PreValue> categories = UmbracoCustom.DataTypeValue(int.Parse(UmbracoCustom.GetParameterValue(UmbracoType.Category)));

        categorySelected = new HiddenField {
            ID = "categorySelected", Value = categories.First().Id.ToString(), ClientIDMode = ClientIDMode.Static
        };



        Panel pnlForm = new Panel {
            ID = "pnlForm1", CssClass = "form-horizontal", ClientIDMode = ClientIDMode.Static
        };

        //pnlForm.Controls.Add(pnlCategory);
        //pnlForm.Controls.Add(pnlExercise);
        //pnlForm.Controls.Add(pnlValue);
        //pnlForm.Controls.Add(pnlState);
        //pnlForm.Controls.Add(pnlAdd);
        //pnlForm.Controls.Add(pnlResult);
        //pnlForm.Controls.Add(Message);

        pnlForm.Controls.Add(pnlTemplate);
        //pnlForm.Controls.Add(pnlApplyTemplate);
        pnlForm.Controls.Add(grid);
        pnlForm.Controls.Add(pager);
        pnlForm.Controls.Add(categorySelected);

        Controls.Add(pnlForm);
    }
Ejemplo n.º 13
0
    private void NotificationMessage()
    {
        int      documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]);
        Document Gymnast    = new Document(documentId);
        int      memberId   = Convert.ToInt32(Gymnast.getProperty("member").Value);

        SmtpClient  client  = new SmtpClient();
        MailMessage message = new MailMessage();

        message.IsBodyHtml = true;
        message.From       = new MailAddress("*****@*****.**");
        message.To.Add(new Member(memberId).Email);
        message.Subject = "MetaFitness";
        message.Body    = "Your Trainer has sent you a new message. Check your MetaFitness App now.";
        client.Send(message);

        string cn = UmbracoCustom.GetParameterValue(UmbracoType.Connection);

        SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertEmailMessage",
                                  new SqlParameter {
            ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@UserId", Value = new User("system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@UserType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@ObjectId", Value = Gymnast.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@ObjectType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(u => u.Value.ToLower() == "chat").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
        },
                                  new SqlParameter {
            ParameterName = "@Email", Value = new Member(memberId).Email, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar
        },
                                  new SqlParameter {
            ParameterName = "@Message", Value = "Your Trainer has sent you a new message. Check your MetaFitness App now.", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
        }
                                  );


        foreach (PushNotification notification in SelectNotificationByMember(memberId))
        {
            pushService.QueueNotification(new AppleNotification().ForDeviceToken(notification.Token).WithAlert("Your Trainer has sent you a new message.").WithBadge(7));
            pushService.StopAllServices();

            SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertPushMessage",
                                      new SqlParameter {
                ParameterName = "@Id", Value = new int(), Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@Token", Value = notification.Token, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 50
            },
                                      new SqlParameter {
                ParameterName = "@NotificationId", Value = notification.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserId", Value = new User("system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@UserType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.UserType))).Single(u => u.Value.ToLower() == "system").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectId", Value = Gymnast.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@ObjectType", Value = UmbracoCustom.DataTypeValue(Convert.ToInt32(UmbracoCustom.GetParameterValue(UmbracoType.ObjectType))).Single(u => u.Value.ToLower() == "chat").Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int
            },
                                      new SqlParameter {
                ParameterName = "@Message", Value = "Your Trainer has sent you a new message.", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 500
            }
                                      );
        }
    }