protected void bAjaxPostback_Click(object sender, EventArgs e)
        {
            string status = string.Empty;

            try
            {
                Affine.WebService.StreamService   ss          = new Affine.WebService.StreamService();
                Affine.Data.Managers.IDataManager dataManager = Affine.Data.Managers.LINQ.DataManager.Instance;

                switch (hiddenAjaxAction.Value)
                {
                case "delStream":
                    long sid = Convert.ToInt64(hiddenAjaxValue.Value);
                    Affine.Data.Managers.LINQ.DataManager.Instance.deleteStream(UserSettings, sid);
                    status = "Your stream item has been deleted.";
                    RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
                    break;

                case "delComment":
                    long cid = Convert.ToInt64(hiddenAjaxValue.Value);
                    Affine.Data.Managers.LINQ.DataManager.Instance.deleteComment(UserSettings, cid);
                    status = "Your commnet has been deleted.";
                    RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
                    break;

                case "AddComment":
                    try
                    {
                        JavaScriptSerializer jserializer = new JavaScriptSerializer();
                        Shout shoutRet = dataManager.SaveShout(-1, this.UserId, -1, this.PortalId, hiddenAjaxValue.Value);
                        // get the json serializable version of the object.
                        Affine.Data.json.StreamData sd = Affine.Data.Managers.LINQ.StreamManager.Instance.UserStreamEntityToStreamData(shoutRet, null);
                        // RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.Controls.atiStreamPanel.prependJson(" + _jserializer.Serialize(sd) + "); })();");
                        string json = jserializer.Serialize(sd);
                        RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.atiStreamScript.prependJson('" + json + "'); Aqufit.Page.atiComment.clear(); })();");
                        //Affine.WebService.StreamService service = new WebService.StreamService();
                        //RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.atiStreamScript.prependJson('" + service.SaveStreamShout(-1, this.UserId, this.PortalId, hiddenAjaxValue.Value) + "'); Aqufit.Page.atiComment.clear(); })();");
                    }
                    catch (Exception ex)
                    {
                        RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + "');");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                //status = "ERROR: There was a problem with the action (" + ex.Message + ")";
                RadAjaxManager1.ResponseScripts.Add(" alert('" + ex.Message + "'); ");
            }
        }
        protected void bAjaxPostback_Click(object sender, EventArgs e)
        {
            string status = string.Empty;
            try
            {
                Affine.WebService.StreamService ss = new Affine.WebService.StreamService();
                Affine.Data.Managers.IDataManager dataManager = Affine.Data.Managers.LINQ.DataManager.Instance;

                switch (hiddenAjaxAction.Value)
                {
                     case "delStream":
                        long sid = Convert.ToInt64(hiddenAjaxValue.Value);
                        Affine.Data.Managers.LINQ.DataManager.Instance.deleteStream(UserSettings, sid);
                        status = "Your stream item has been deleted.";
                        RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
                        break;
                    case "delComment":
                        long cid = Convert.ToInt64(hiddenAjaxValue.Value);
                        Affine.Data.Managers.LINQ.DataManager.Instance.deleteComment(UserSettings, cid);
                        status = "Your commnet has been deleted.";
                        RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
                        break;
                    case "AddComment":
                        try
                        {
                            JavaScriptSerializer jserializer = new JavaScriptSerializer();
                            Shout shoutRet = dataManager.SaveShout(-1, this.UserId, -1, this.PortalId, hiddenAjaxValue.Value);
                            // get the json serializable version of the object.
                            Affine.Data.json.StreamData sd = Affine.Data.Managers.LINQ.StreamManager.Instance.UserStreamEntityToStreamData(shoutRet, null);
                            // RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.Controls.atiStreamPanel.prependJson(" + _jserializer.Serialize(sd) + "); })();");
                            string json = jserializer.Serialize(sd);
                            RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.atiStreamScript.prependJson('" + json + "'); Aqufit.Page.atiComment.clear(); })();");
                            //Affine.WebService.StreamService service = new WebService.StreamService();
                            //RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.atiStreamScript.prependJson('" + service.SaveStreamShout(-1, this.UserId, this.PortalId, hiddenAjaxValue.Value) + "'); Aqufit.Page.atiComment.clear(); })();");
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                //status = "ERROR: There was a problem with the action (" + ex.Message + ")";
                RadAjaxManager1.ResponseScripts.Add(" alert('" + ex.Message + "'); ");
            }
        }
Esempio n. 3
0
        protected void bAjaxPostback_Click(object sender, EventArgs e)
        {
            string status = string.Empty;

            try
            {
                Affine.Data.Managers.IDataManager dataMan = Affine.Data.Managers.LINQ.DataManager.Instance;
                switch (hiddenAjaxAction.Value)
                {
                case "AddFriend":
                    try
                    {
                        status = dataMan.sendFriendRequest(UserSettings.Id, this.ProfileSettings.Id);
                        RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowOk('A Friend request has been sent to " + ProfileSettings.UserName + "');");
                    }
                    catch (Exception ex)
                    {
                        RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowFail('Error: " + ex.Message + "');");
                    }
                    break;

                case "AddFollow":
                    try
                    {
                        Affine.WebService.StreamService ss = new Affine.WebService.StreamService();
                        status = ss.FollowUser(UserSettings.Id, ProfileSettings.Id);
                        RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowOk('You are now following " + ProfileSettings.UserName + "');");
                    }
                    catch (Exception ex)
                    {
                        RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowFail('Error: " + ex.Message + "');");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                //status = "ERROR: There was a problem with the action (" + ex.Message + ")";
                RadAjaxManager1.ResponseScripts.Add(" alert('" + ex.Message + "'); ");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack && !Page.IsCallback && this.ProfileSettings != null)
     {
         _IsOwner = (this.ProfileSettings.UserKey == (long)PortalSettings.UserId);
         urlBase  = ResolveUrl("~/");
         if (!_IsOwner)
         {
             this.Visible = false;
         }
         if (this.ProfileSettings.MainGroupKey != null && this.Visible)
         {
             Affine.WebService.StreamService ss = new Affine.WebService.StreamService();
             string json = ss.getFriendSuggestions(ProfileSettings.Id, this.ProfileSettings.MainGroupKey.Value, null, 2);
             ScriptManager.RegisterStartupScript(this, Page.GetType(), "SugestedFriends", "$(function(){ Aqufit.Page." + this.ID + ".geneateListDom('" + json + "') });", true);
         }
         else
         {
             this.Visible = false;
         }
     }
 }
Esempio n. 5
0
        protected void bAjaxPostback_Click(object sender, EventArgs e)
        {
            string status = string.Empty;
            try
            {
                Affine.WebService.StreamService ss = new Affine.WebService.StreamService();
                Affine.Data.Managers.IDataManager dataManager = Affine.Data.Managers.LINQ.DataManager.Instance;
                switch (hiddenAjaxAction.Value)
                {
                    case "AddFriend":
                        try
                        {
                            status = dataManager.sendFriendRequest(UserSettings.Id, this.ProfileSettings.Id);
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.atiProfile.ShowOk('A Friend request has been sent to " + ProfileSettings.UserName + " ');");
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                    case "AddSuggestFriend":
                        try
                        {
                            long usid = Convert.ToInt64(hiddenAjaxValue.Value);
                            status = dataManager.sendFriendRequest(UserSettings.Id, usid);
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.atiProfile.ShowOk('A Friend request has been sent');");
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                    case "AddFollow":
                        try
                        {
                            status = ss.FollowUser(UserSettings.Id, ProfileSettings.Id);
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.atiProfile.ShowOk('You are now following " + ProfileSettings.UserName + "');");
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                    case "delStream":
                        long sid = Convert.ToInt64(hiddenAjaxValue.Value);
                        Affine.Data.Managers.LINQ.DataManager.Instance.deleteStream(UserSettings, sid);
                        status = "Your stream item has been deleted.";
                        RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
                        break;
                    case "delComment":
                        long cid = Convert.ToInt64(hiddenAjaxValue.Value);
                        Affine.Data.Managers.LINQ.DataManager.Instance.deleteComment(UserSettings, cid);
                        status = "Your commnet has been deleted.";
                        RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); ");
                        break;
                    case "StreamPost":
                    case "AddComment":
                        try
                        {
                            long toUserSettingsKey = -1;
                            long photoKey = 0;
                            Affine.Data.json.PageMetaData linkJson = null;
                            if (hiddenAjaxAction.Value == "StreamPost")
                            {
                                toUserSettingsKey = ProfileSettings.Id;
                                photoKey = atiStreamPostAttachment.PhotoKey;
                                linkJson = atiStreamPostAttachment.LinkJson;
                            }
                            else
                            {
                                photoKey = atiCommentAttachment.PhotoKey;
                                linkJson = atiCommentAttachment.LinkJson;
                            }
                            Shout shoutRet = dataManager.SaveShout(-1, this.UserId, this.PortalId, toUserSettingsKey, hiddenAjaxValue.Value);
                            bool dirty = false;
                            if (photoKey  > 0)
                            {
                                dataManager.AddAttachmentToStream(shoutRet.Id, photoKey);
                                dirty = true;
                            }
                            else if (linkJson != null)
                            {
                                dirty = true;
                                dataManager.SaveLinkAttachment(UserSettings.Id, shoutRet.Id, linkJson);
                            }
                            if (dirty)
                            {
                                aqufitEntities entities = new aqufitEntities();
                                shoutRet = entities.UserStreamSet.OfType<Shout>().Include("UserSetting").Include("UserAttachments").FirstOrDefault(s => s.Id == shoutRet.Id);
                            }
                            // get the json serializable version of the object.
                            Affine.Data.json.StreamData sd = _IStreamManager.UserStreamEntityToStreamData(shoutRet, null);
                            // RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.Controls.atiStreamPanel.prependJson(" + _jserializer.Serialize(sd) + "); })();");
                            string json = _jserializer.Serialize(sd);
                            RadAjaxManager1.ResponseScripts.Add(" (function(){ if(Aqufit.Page.atiStreamPostAttachment)Aqufit.Page.atiStreamPostAttachment.clear(); if(Aqufit.Page.atiCommentAttachment)Aqufit.Page.atiCommentAttachment.clear(); Aqufit.Page.atiStreamScript.prependJson('" + json + "'); Aqufit.Page.atiComment.clear(); })();");
                            //Affine.WebService.StreamService service = new WebService.StreamService();
                            //RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.atiStreamScript.prependJson('" + service.SaveStreamShout(-1, this.UserId, this.PortalId, hiddenAjaxValue.Value) + "'); Aqufit.Page.atiComment.clear(); })();");
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + ex.InnerException.Message + ex.InnerException.StackTrace.Replace("\r", "").Replace("\n", "").Replace("'", "") + "');");
                        }
                        break;
                    case "remStepByStep":
                        try
                        {
                            aqufitEntities entities = new aqufitEntities();
                            SiteSetting introSettings = ProfileSettings.SiteSettings.FirstOrDefault(s => s.Name == "SiteIntro");
                            if (introSettings != null)
                            {
                                entities.DeleteObject(entities.SiteSettings.FirstOrDefault(s => s.Id == introSettings.Id));
                                entities.SaveChanges();
                            }
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                    case "remStreamTutorial":
                        try
                        {
                            aqufitEntities entities = new aqufitEntities();
                            SiteSetting StreamTutorial = ProfileSettings.SiteSettings.FirstOrDefault(s => s.Name == "StreamTutorial");
                            if (StreamTutorial != null)
                            {
                                entities.DeleteObject(entities.SiteSettings.FirstOrDefault(s => s.Id == StreamTutorial.Id));
                                entities.SaveChanges();
                            }
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                    case "test":
                        try
                        {
                            aqufitEntities entities = new aqufitEntities();
                            Workout newWorkout = entities.UserStreamSet.OfType<Workout>().Include("WOD").Include("UserSetting").Where(w => w.UserSetting.Id == UserSettings.Id).OrderByDescending(w => w.Id).First();
                            DisplayWorkoutStatistics(newWorkout);
                        }
                        catch (Exception ex) { RadAjaxManager1.ResponseScripts.Add("alert(\"" + ex.StackTrace.Replace("\n","").Replace("'","") + "\");"); }

                        break;
                    case "SaveWorkout":
                        try
                        {

                            aqufitEntities entities = new aqufitEntities();
                            UserSettings settings = entities.UserSettings.FirstOrDefault(us => us.UserKey == this.UserId && us.PortalKey == this.PortalId);
                            // Check if we have a map record accociated with the workout.

                            if (atiWorkout.WorkoutType.Id == (int)Affine.Utils.WorkoutUtil.WorkoutType.CROSSFIT)
                            {
                                dataManager.SaveWorkout(UserSettings, atiWorkout.WorkoutType.Id, (int)WorkoutUtil.DataSrc.MANUAL_NO_MAP, atiWorkout.Date, atiWorkout.Time, atiWorkout.Notes, atiWorkout.IsRxD, atiWorkout.WODId, atiWorkout.Score, (int)atiWorkout.MaxWeightUnit);
                            }
                            else
                            {
                                dataManager.SaveWorkout(UserSettings, atiWorkout.WorkoutType.Id, (int)WorkoutUtil.DataSrc.MANUAL_NO_MAP, atiWorkout.Date, atiWorkout.Time, atiWorkout.Distance, atiWorkout.SelectedMapRouteId, (short)atiWorkout.Feeling, (short)atiWorkout.Weather, (short)atiWorkout.Terrain, atiWorkout.Title, atiWorkout.Notes);
                            }
                            // get the workout we just saved
                            Workout newWorkout = entities.UserStreamSet.OfType<Workout>().Include("WOD").Where(w => w.UserSetting.Id == UserSettings.Id).OrderByDescending(w => w.Id).First();
                            bool dirty = false;
                            if (atiWorkoutAttachment.PhotoKey > 0)
                            {
                                dataManager.AddAttachmentToStream(newWorkout.Id, atiWorkoutAttachment.PhotoKey);
                                dirty = true;
                            }
                            else if (atiWorkoutAttachment.LinkJson != null)
                            {
                                dirty = true;
                                dataManager.SaveLinkAttachment(UserSettings.Id, newWorkout.Id, atiWorkoutAttachment.LinkJson);
                            }
                            if (dirty)
                            {
                                newWorkout = entities.UserStreamSet.OfType<Workout>().Include("UserSetting").Include("UserAttachments").FirstOrDefault(s => s.Id == newWorkout.Id);
                            }
                            // get the json serializable version of the object.
                            Affine.Data.json.StreamData sd = _IStreamManager.UserStreamEntityToStreamData(newWorkout, null);
                            // TOOD: "Aqufit.Page.atiWorkout.clear();" was in the response script but it messes up the Ajaax after the first postback..
                            RadAjaxManager1.ResponseScripts.Add(" (function(){ Aqufit.Page.atiStreamScript.prependJson('" + _jserializer.Serialize(sd) + "'); Aqufit.Page.atiWorkout.clear(); })();");
                            status = "Workout has been saved.";
                            // display the stats...
                            DisplayWorkoutStatistics(newWorkout);
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.ShowFail('Error: " + ex.Message + ex.StackTrace.Replace("\n","").Replace("'","") +  "');");
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                //status = "ERROR: There was a problem with the action (" + ex.Message + ")";
                RadAjaxManager1.ResponseScripts.Add(" alert('"+ex.Message+"'); ");
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);
            try
            {
                if (!Page.IsPostBack && !Page.IsCallback)
                {
                    atiRadDatePicker.SelectedDate = DateTime.Today;
                    ServiceReference service = new ServiceReference("~/DesktopModules/ATI_Base/resources/services/StreamService.asmx");
                    service.InlineScript = true;
                    ScriptManager.GetCurrent(Page).Services.Add(service);

                    atiProfileImg.Settings = GroupSettings != null ? (Affine.Data.UserSettings)GroupSettings : UserSettings;
                    Affine.WebService.StreamService streamService = new Affine.WebService.StreamService();
                    aqufitEntities entities = new aqufitEntities();
                    WODType[]      wodTypes = entities.WODTypes.ToArray();
                    ddlWODType.Items.AddRange(wodTypes.Select(t => new ListItem()
                    {
                        Text = t.Name, Value = "" + t.Id
                    }).ToArray());

                    // CA - new ...
                    ddlWODType2.Items.AddRange(wodTypes.Select(t => new ListItem()
                    {
                        Text = t.Name, Value = "" + t.Id
                    }).ToArray());
                    RadListBoxExcerciseSource.DataValueField = "Value";
                    RadListBoxExcerciseSource.DataTextField  = "Text";
                    RadListBoxExcerciseSource.DataSource     = entities.Exercises.OrderBy(ex => ex.Name).Select(ex => new { Text = ex.Name, Value = ex.Id }).ToList();
                    RadListBoxExcerciseSource.DataBind();

                    string js = string.Empty;
                    if (UserSettings.MainGroupKey.HasValue && GroupSettings == null)   // Remember that "g" is when a group admin is scheduling a wod..
                    {
                        long[] groupIds = entities.UserFriends.Where(f => f.SrcUserSettingKey == UserSettings.Id && f.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(f => f.DestUserSettingKey).ToArray();
                        lbGroups.DataTextField  = "Text";
                        lbGroups.DataValueField = "Value";
                        lbGroups.DataSource     = entities.UserSettings.OfType <Group>().Where(Affine.Utils.Linq.LinqUtils.BuildContainsExpression <UserSettings, long>(us => us.Id, groupIds)).Select(g => new { Text = g.UserFirstName, Value = g.Id }).ToList();
                        lbGroups.DataBind();
                        ListItem li = lbGroups.Items.FindByValue("" + UserSettings.MainGroupKey);
                        if (li != null)
                        {
                            li.Selected = true;
                        }
                    }
                    else
                    {   // we skip the first 2 steps of the workout creator.. since they have no group
                        js += "Aqufit.Page.Actions.HaveNoGroup(); ";
                    }

                    ScriptManager.RegisterStartupScript(this, Page.GetType(), "ExerciseList",
                                                        "$(function(){ " +
                                                        js +
                                                        //   "Aqufit.Page.atiExerciseListScript.generateStreamDom('" + streamService.GetAllExercises() + "'); " +
                                                        "Aqufit.Page.Events.OnLoad();" +
                                                        "});", true);

                    string baseUrl = ResolveUrl("~");
                    aReturn.HRef     = baseUrl + UserSettings.UserName;
                    aMyWorkouts.HRef = baseUrl + "Profile/MyWorkouts";
                    //Profile/MyWorkouts


                    atiTemp.Visible = false;
                    atiNew.Visible  = true;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 7
0
        protected void bAjaxPostback_Click(object sender, EventArgs e)
        {
            string status = string.Empty;
            try
            {

                Affine.Data.Managers.IDataManager dataMan = Affine.Data.Managers.LINQ.DataManager.Instance;
                switch (hiddenAjaxAction.Value)
                {
                    case "AddFriend":
                        try
                        {
                            status = dataMan.sendFriendRequest(UserSettings.Id, this.ProfileSettings.Id);
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowOk('A Friend request has been sent to " + ProfileSettings.UserName + "');");
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                    case "AddFollow":
                        try
                        {
                            Affine.WebService.StreamService ss = new Affine.WebService.StreamService();
                            status = ss.FollowUser(UserSettings.Id, ProfileSettings.Id);
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowOk('You are now following " + ProfileSettings.UserName + "');");
                        }
                        catch (Exception ex)
                        {
                            RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Action.ShowFail('Error: " + ex.Message + "');");
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                //status = "ERROR: There was a problem with the action (" + ex.Message + ")";
                RadAjaxManager1.ResponseScripts.Add(" alert('"+ex.Message+"'); ");
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);
            try
            {
                if (!Page.IsPostBack && !Page.IsCallback)
                {
                    atiRadDatePicker.SelectedDate = DateTime.Today;
                    ServiceReference service = new ServiceReference("~/DesktopModules/ATI_Base/resources/services/StreamService.asmx");
                    service.InlineScript = true;
                    ScriptManager.GetCurrent(Page).Services.Add(service);

                    atiProfileImg.Settings = GroupSettings != null ? (Affine.Data.UserSettings)GroupSettings : UserSettings;
                    Affine.WebService.StreamService streamService = new Affine.WebService.StreamService();
                    aqufitEntities entities = new aqufitEntities();
                    WODType[] wodTypes =  entities.WODTypes.ToArray();
                    ddlWODType.Items.AddRange(wodTypes.Select(t => new ListItem() { Text = t.Name, Value = "" + t.Id }).ToArray());

                    // CA - new ...
                    ddlWODType2.Items.AddRange(wodTypes.Select(t => new ListItem() { Text = t.Name, Value = "" + t.Id }).ToArray());
                    RadListBoxExcerciseSource.DataValueField = "Value";
                    RadListBoxExcerciseSource.DataTextField = "Text";
                    RadListBoxExcerciseSource.DataSource = entities.Exercises.OrderBy(ex => ex.Name).Select(ex => new { Text = ex.Name, Value = ex.Id }).ToList();
                    RadListBoxExcerciseSource.DataBind();

                    string js = string.Empty;
                    if (UserSettings.MainGroupKey.HasValue && GroupSettings == null)   // Remember that "g" is when a group admin is scheduling a wod..
                    {
                        long[] groupIds = entities.UserFriends.Where(f => f.SrcUserSettingKey == UserSettings.Id && f.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(f => f.DestUserSettingKey).ToArray();
                        lbGroups.DataTextField = "Text";
                        lbGroups.DataValueField = "Value";
                        lbGroups.DataSource = entities.UserSettings.OfType<Group>().Where(Affine.Utils.Linq.LinqUtils.BuildContainsExpression<UserSettings, long>(us => us.Id, groupIds)).Select(g => new { Text = g.UserFirstName, Value = g.Id }).ToList();
                        lbGroups.DataBind();
                        ListItem li = lbGroups.Items.FindByValue("" + UserSettings.MainGroupKey);
                        if (li != null)
                        {
                            li.Selected = true;
                        }
                    }
                    else
                    {   // we skip the first 2 steps of the workout creator.. since they have no group
                        js += "Aqufit.Page.Actions.HaveNoGroup(); ";
                    }

                    ScriptManager.RegisterStartupScript(this, Page.GetType(), "ExerciseList",
                        "$(function(){ " +
                            js +
                         //   "Aqufit.Page.atiExerciseListScript.generateStreamDom('" + streamService.GetAllExercises() + "'); " +
                            "Aqufit.Page.Events.OnLoad();" +
                        "});", true);

                    string baseUrl = ResolveUrl("~");
                    aReturn.HRef = baseUrl + UserSettings.UserName;
                    aMyWorkouts.HRef = baseUrl + "Profile/MyWorkouts";
                    //Profile/MyWorkouts

                    atiTemp.Visible = false;
                    atiNew.Visible = true;

                }

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }