Beispiel #1
0
        public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj)
        {
            ShareSocialContent content = new ShareSocialContent();

            content.Caption = BlogEntryStrings.BlogModule_ShareToSocial_Caption;
            content.Name    = BlogEntryStrings.BlogModule_ShareToSocial_Name;
            StringBuilder descriptionBuilder = new StringBuilder();

            descriptionBuilder.AppendFormat(BlogEntryStrings.BlogModule_ShareToSocial_Description, entryObj.TrainingDay.TrainingDate.ToShortDateString());
            content.Description = descriptionBuilder.ToString();
            return(content);
        }
Beispiel #2
0
        public void PostNote(ShareSocialContent content)
        {
            bool tryAgain = true;

            while (tryAgain)
            {
                try
                {
                    var fbApp = new FacebookClient(Settings1.Default.FacebookToken);

                    var args = new Dictionary <string, object>();
                    //args["name"] = content.Name;
                    //args["link"] = string.IsNullOrEmpty(content.Url) ? "http://bodyarchitectonline.com" : content.Url;
                    args["subject"] = content.Name;
                    args["message"] = content.Description;
                    args["icon"]    = "http://www.bodyarchitectonline.com/images/bodyarchitect1.jpg";
                    if (!string.IsNullOrEmpty(content.Message))
                    {
                        args["message"] = content.Message;
                    }

                    args["message"] += "<br/><br/><a href='http://bodyarchitectonline.com'><img  src='http://bodyarchitectonline.com/images/bodyarchitect1.jpg'></img></a><br/><a href='http://bodyarchitectonline.com'>BodyArchitect</a> - " + Strings.SocialNetworkShare_Footer;


                    //args["actions"] = "";
                    fbApp.Post("/me/notes", args);
                    tryAgain = false;
                }
                catch (FacebookOAuthException ex)
                {
                    tryAgain = false;
                    try
                    {
                        Settings1.Default.FacebookToken = RenewToken(Settings1.Default.FacebookToken);
                        tryAgain = true;
                    }
                    catch (Exception)
                    {
                        ExceptionHandler.Default.Process(ex);
                        FacebookLoginWindow dlg = new FacebookLoginWindow();
                        if (dlg.ShowDialog() == true)
                        {
                            tryAgain = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Default.Process(ex, Strings.Exception_SocialNetworkShare_CannotPublishToFacebook, ErrorWindow.EMailReport);
                }
            }
        }
Beispiel #3
0
        public void PostOnWall(ShareSocialContent content)
        {
            bool tryAgain = true;

            while (tryAgain)
            {
                try
                {
                    var fbApp = new FacebookClient(Settings1.Default.FacebookToken);
                    var args  = new Dictionary <string, object>();
                    args["name"]        = content.Name;
                    args["link"]        = string.IsNullOrEmpty(content.Url) ? "http://bodyarchitectonline.com" : content.Url;
                    args["caption"]     = content.Caption;
                    args["description"] = content.Description;
                    //args["picture"] = "http://www.bodyarchitectonline.com/images/stories/blue-09_thumb.png";
                    if (!string.IsNullOrEmpty(content.Message))
                    {
                        args["message"] = content.Message;
                    }
                    args["actions"] = "";
                    fbApp.Post("/571048516255177/feed", args);
                    tryAgain = false;
                }
                catch (FacebookOAuthException ex)
                {
                    tryAgain = false;
                    try
                    {
                        Settings1.Default.FacebookToken = RenewToken(Settings1.Default.FacebookToken);
                        tryAgain = true;
                    }
                    catch (Exception)
                    {
                        ExceptionHandler.Default.Process(ex);
                        FacebookLoginWindow dlg = new FacebookLoginWindow();
                        if (dlg.ShowDialog() == true)
                        {
                            tryAgain = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Default.Process(ex, Strings.Exception_SocialNetworkShare_CannotPublishToFacebook, ErrorWindow.EMailReport);
                }
            }
        }
Beispiel #4
0
        public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj)
        {
            A6WEntryDTO        a6W     = (A6WEntryDTO)entryObj;
            ShareSocialContent content = new ShareSocialContent();

            content.Caption = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_Caption");
            content.Name    = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_Name");
            var daysToFinish = A6WManager.Days.Count - a6W.Day.DayNumber;

            if (daysToFinish == 0)
            {
                content.Description = string.Format(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_Finished_Description"), a6W.Day.DayNumber, a6W.TrainingDay.TrainingDate.ToShortDateString());
            }
            else
            {
                content.Description = string.Format(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_NotFinished_Description"), a6W.Day.DayNumber, a6W.TrainingDay.TrainingDate.ToShortDateString(), daysToFinish);
            }

            return(content);
        }
Beispiel #5
0
        public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj)
        {
            var supple = (SuplementsEntryDTO)entryObj;
            ShareSocialContent content = new ShareSocialContent();

            content.Caption = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Caption");
            content.Name    = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Name");
            StringBuilder descriptionBuilder = new StringBuilder();

            descriptionBuilder.AppendFormat(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Date"), entryObj.TrainingDay.TrainingDate.ToShortDateString());
            descriptionBuilder.AppendFormat("<br/>");
            foreach (var item in supple.Items)
            {
                if (item.Suplement != null)
                {
                    descriptionBuilder.AppendFormat(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Dosage"), item.Suplement.Name, item.Name.Trim(), item.Dosage, EnumLocalizer.Default.Translate(item.DosageType));
                }
            }
            content.Description = descriptionBuilder.ToString();
            return(content);
        }
Beispiel #6
0
        public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj)
        {
            ShareSocialContent content = new ShareSocialContent();

            content.Caption = "StrengthTrainingModule_ShareSocialContent_Caption_BodyArchitect".TranslateStrength();
            content.Name    = "StrengthTrainingModule_ShareSocialContent_Name_NewEntry".TranslateStrength();
            StringBuilder            descriptionBuilder = new StringBuilder();
            StrengthTrainingEntryDTO strengthEntry      = (StrengthTrainingEntryDTO)entryObj;

            descriptionBuilder.AppendFormat("StrengthTrainingModule_ShareSocialContent_Date".TranslateStrength(), strengthEntry.TrainingDay.TrainingDate.ToShortDateString());

            foreach (var exerciseType in strengthEntry.Entries.Where(x => x.Exercise != null).Select(x => x.Exercise.ExerciseType).Distinct())
            {
                var exercises = strengthEntry.Entries.Where(x => x.Exercise != null && x.Exercise.ExerciseType == exerciseType);
                descriptionBuilder.AppendFormat(@"<br/><b>{0}</b>", EnumLocalizer.Default.Translate(exerciseType));
                foreach (var item in exercises)
                {
                    descriptionBuilder.AppendFormat(@"<br/>{0}: <i>", item.Exercise.Name);
                    foreach (var set in item.Series)
                    {
                        if (set.IsRecord)
                        {
                            descriptionBuilder.AppendFormat(" <b>{0}</b>", set.GetDisplayText(WorkoutPlanOperationHelper.SetDisplayMode.Medium));
                        }
                        else
                        {
                            descriptionBuilder.AppendFormat(" {0}", set.GetDisplayText(WorkoutPlanOperationHelper.SetDisplayMode.Medium));
                        }
                    }
                    descriptionBuilder.Append("</i>");
                }
                descriptionBuilder.Append(@"<br/>");
            }

            content.Description = descriptionBuilder.ToString();
            return(content);
        }
Beispiel #7
0
        public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj)
        {
            var sizeEntry = (SizeEntryDTO)entryObj;
            ShareSocialContent content = new ShareSocialContent();

            content.Caption = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Measurements:SizeEntryStrings:SizeModule_ShareToSocial_Caption");
            content.Name    = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Measurements:SizeEntryStrings:SizeModule_ShareToSocial_Name");
            StringBuilder descriptionBuilder = new StringBuilder();

            descriptionBuilder.AppendFormat(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Measurements:SizeEntryStrings:SizeModule_ShareToSocial_Date"), sizeEntry.TrainingDay.TrainingDate.ToShortDateString());
            string weightType = "WeightType_Kg".TranslateStrings();
            string lengthType = "LengthType_Cm".TranslateStrings();

            if (UserContext.Current.ProfileInformation.Settings.WeightType == WeightType.Pounds)
            {
                weightType = "WeightType_Pound".TranslateStrings();
            }
            if (UserContext.Current.ProfileInformation.Settings.LengthType == LengthType.Inchs)
            {
                lengthType = "LengthType_Inch".TranslateStrings();
            }

            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.Klatka.ToDisplayLength(), "usrWymiaryEditor_KlatkaLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.RightBiceps.ToDisplayLength(), "usrWymiaryEditor_RightBicepsLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.LeftBiceps.ToDisplayLength(), "usrWymiaryEditor_LeftBicepsLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.RightForearm.ToDisplayLength(), "usrWymiaryEditor_RightForearmLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.LeftForearm.ToDisplayLength(), "usrWymiaryEditor_LeftForearmsLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.RightUdo.ToDisplayLength(), "usrWymiaryEditor_RightUdoLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.LeftUdo.ToDisplayLength(), "usrWymiaryEditor_LeftUdoLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.Pas.ToDisplayLength(), "usrWymiaryEditor_PasLabel".TranslateGUI(), lengthType);
            addMeasurement(descriptionBuilder, sizeEntry.Wymiary.Weight.ToDisplayWeight(), "usrWymiaryEditor_WeightLabel".TranslateGUI(), weightType);

            content.Description = descriptionBuilder.ToString();

            return(content);
        }