Example #1
0
        public void OnPostAppearanceSave()
        {
            StreamingLiveLib.Site site = AppUser.CurrentSite;
            site.HomePageUrl   = HomePageUrl;
            site.PrimaryColor  = PrimaryColor;
            site.ContrastColor = ContrastColor;
            site.HeaderColor   = HeaderColor;

            if (Logo != null && Logo.FormFile != null)
            {
                //string tempFile = Path.Combine(CachedData.Environment.WebRootPath, "/temp/" + AppUser.Current.UserData.Id.ToString() + ".png");

                byte[] photoBytes;
                using (var stream = new MemoryStream())
                {
                    Logo.FormFile.CopyToAsync(stream).Wait();
                    stream.Position = 0;
                    photoBytes      = new byte[stream.Length];
                    stream.Read(photoBytes, 0, photoBytes.Length);
                }

                using (MemoryStream outStream = new MemoryStream())
                {
                    MagickImage image = new MagickImage(photoBytes);
                    int         ratio = Convert.ToInt32(150.0 / Convert.ToDouble(image.Height));
                    image.Resize(image.Width * ratio, 150);
                    image.Write(outStream);
                    outStream.Position = 0;


                    S3Client.PutObjectAsync(new Amazon.S3.Model.PutObjectRequest()
                    {
                        BucketName  = CachedData.S3ContentBucket,
                        InputStream = outStream,
                        ContentType = "image/png",
                        Key         = $"data/{AppUser.CurrentSite.KeyName}/logo.png",
                        CannedACL   = S3CannedACL.PublicRead
                    }).Wait();
                }
            }
            site.LogoUrl = $"/data/{site.KeyName}/logo.png?dt=" + DateTime.UtcNow.Ticks.ToString();

            site.Save();


            AppUser au = AppUser.Current;

            au.Sites        = StreamingLiveLib.Sites.LoadByUserId(AppUser.Current.UserData.Id);
            AppUser.Current = au; //*** This really shouldn't be necessary.  Updated session variables should automatically store in dynamodb.

            UpdateData();
            Populate();
        }
Example #2
0
 private void PopulateAppearance()
 {
     StreamingLiveLib.Site site = AppUser.Current.Site;
     if (site.LogoUrl == "" || site.LogoUrl == null)
     {
         LogoHtml = "none";
     }
     else
     {
         LogoHtml = $"<img src=\"{CachedData.ContentUrl}{site.LogoUrl}\" class=\"img-fluid\" />";
     }
     HomePageUrl   = site.HomePageUrl;
     PrimaryColor  = site.PrimaryColor;
     ContrastColor = site.ContrastColor;
     HeaderColor   = site.HeaderColor;
 }
Example #3
0
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            string[] errors = Validate();
            if (errors.Length == 0)
            {
                StreamingLiveLib.Site s = new StreamingLiveLib.Site()
                {
                    KeyName = KeyNameText.Text.ToLower().Trim(), PrimaryColor = "#24b9ff", ContrastColor = "#ffffff", HeaderColor = "#24b9ff", HomePageUrl = "/", LogoUrl = "/data/master/logo.png", RegistrationDate = DateTime.UtcNow
                };
                s.Save();

                StreamingLiveLib.User u = new StreamingLiveLib.User()
                {
                    Email = EmailText.Text.ToLower().Trim(), Password = StreamingLiveLib.User.HashPassword(PasswordText.Text.Trim()), DisplayName = "Admin"
                };
                u.ResetGuid = Guid.NewGuid().ToString();
                u.Save();

                StreamingLiveLib.Role r = new StreamingLiveLib.Role()
                {
                    Name = "admin", SiteId = s.Id, UserId = u.Id
                };
                r.Save();


                new StreamingLiveLib.Button()
                {
                    SiteId = s.Id, Sort = 1, Text = "Resources", Url = "about:blank"
                }.Save();
                new StreamingLiveLib.Button()
                {
                    SiteId = s.Id, Sort = 2, Text = "Give", Url = "about:blank"
                }.Save();

                new StreamingLiveLib.Tab()
                {
                    SiteId = s.Id, Sort = 1, TabType = "chat", TabData = "", Icon = "far fa-comment", Text = "Chat", Url = ""
                }.Save();
                new StreamingLiveLib.Tab()
                {
                    SiteId = s.Id, Sort = 2, TabType = "url", TabData = "", Icon = "fas fa-bible", Text = "Bible", Url = "https://www.bible.com/en-GB/bible/111/GEN.1.NIV"
                }.Save();
                new StreamingLiveLib.Tab()
                {
                    SiteId = s.Id, Sort = 3, TabType = "prayer", TabData = "", Icon = "fas fa-praying-hands", Text = "Prayer", Url = ""
                }.Save();

                DateTime serviceTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9 + 5, 0, 0).AddDays(1);
                while (serviceTime.DayOfWeek != DayOfWeek.Sunday)
                {
                    serviceTime = serviceTime.AddDays(1);
                }
                new StreamingLiveLib.Service()
                {
                    SiteId = s.Id, ChatAfter = 15 * 60, ChatBefore = 15 * 60, Duration = 60 * 60, EarlyStart = 5 * 60, Provider = "youtube_watchparty", ProviderKey = "zFOfmAHFKNw", VideoUrl = "https://www.youtube.com/embed/zFOfmAHFKNw?autoplay=1&controls=0&showinfo=0&rel=0&modestbranding=1&disablekb=1", ServiceTime = serviceTime, TimezoneOffset = 300, Recurring = false
                }.Save();

                System.IO.Directory.CreateDirectory(Server.MapPath("/data/" + s.KeyName));
                System.IO.File.Copy(Server.MapPath("/data/master/data.json"), Server.MapPath("/data/" + s.KeyName + "/data.json"));
                System.IO.File.Copy(Server.MapPath("/data/master/data.css"), Server.MapPath("/data/" + s.KeyName + "/data.css"));

                try
                {
                    string body = "<a href=\"https://" + s.KeyName + ".streaminglive.church/\">https://" + s.KeyName + ".streaminglive.church/</a> - " + u.Email;
                    StreamingLiveLib.Aws.EmailHelper.SendEmail(CachedData.SupportEmail, CachedData.SupportEmail, "New StreamingLive.church Registration", body);
                } catch { }



                AppUser.Login(u);
                FormsAuthentication.SetAuthCookie(u.ResetGuid.ToString(), true);
                Response.Redirect("/cp/welcome.aspx");
            }
            else
            {
                OutputMessage("<b>Error:</b><ul><li>" + String.Join("</li><li>", errors) + "</li></ul>", true, OutputLit);
            }
        }