예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            WebText webtext = db.WebTexts.Find(id);

            db.WebTexts.Remove(webtext);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public void UpdatePage(WebComponent source, WebSubmission values)
        {
            WebPage page = (WebPage)source;

            try {
                WebForm  proc_form  = (WebForm)page.Children.Where(o => o.ID.Equals("proc_form")).First();
                WebTable proc_table = (WebTable)proc_form.Children.Where(o => o.ID.Equals("processes")).First();
                proc_table.ClearRows();
                foreach (ProcObject proc in this._pm.Processes)
                {
                    WebComponent icon_img = null;
                    if (null == proc.JpegB64)
                    {
                        proc.JpegB64 = "";
                        try {
                            Bitmap pico = Icon.ExtractAssociatedIcon(proc.Filename).ToBitmap();
                            icon_img     = new WebImage(pico);
                            proc.JpegB64 = ((WebImage)icon_img).Src;
                        } catch (Exception) {
                            // XXX
                        }
                    }
                    else
                    {
                        icon_img = new WebImage(proc.JpegB64);
                    }

                    if (null != icon_img)
                    {
                        ((WebImage)icon_img).WidthPx  = 16;
                        ((WebImage)icon_img).HeightPx = 16;
                    }
                    else
                    {
                        icon_img = new WebText("");
                    }

                    proc_table.AddBodyRow(
                        "proc-row-" + proc.ProcId,
                        icon_img,
                        new WebText(proc.ProcName),
                        new WebText(proc.ProcId.ToString()),
                        new WebText(proc.ProcUser),
                        new WebText(proc.CPUPercent.ToString("n2")),
                        new WebText(WebComponent.FormatDataSize(proc.ReadBytesSec)),
                        new WebText(WebComponent.FormatDataSize(proc.WriteBytesSec)),
                        new WebText(WebComponent.FormatDataSize(proc.WorkingSet)),
                        new WebCheckbox("Kill", "proc_guid", proc.GUID.ToString())
                        );
                }
            } catch (InvalidOperationException ex) {
                Trace.TraceError(ex.Message);
            } catch (NullReferenceException ex) {
                Trace.TraceError(ex.Message);
            }
        }
예제 #3
0
        public ActionResult Edit([Bind(Include = "WebTextID,Section,Page,Body,LastChangedOn,LastChangeBy")] WebText webtext)
        {
            webtext.LastChangedOn = DateTime.Today;
            webtext.LastChangeBy  = User.Identity.Name;

            if (ModelState.IsValid)
            {
                db.Entry(webtext).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("TextEditorIndex", new { pageName = webtext.Page }));
            }
            return(View(webtext));
        }
예제 #4
0
        // GET: /Default1/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WebText webtext = db.WebTexts.Find(id);

            if (webtext == null)
            {
                return(HttpNotFound());
            }
            return(View(webtext));
        }
예제 #5
0
        void HandleSelectionChanged(object sender, SelectionChangedEventArgs args)
        {
            if (sender == null)
            {
                return;
            }

            Details.DataContext = (sender as ListBox).DataContext;
            ListBox lbi = sender as ListBox;

            //  Uri uri = new Uri(@"pack://*****:*****@src";*/
            //string url ="d:\\22.rtf";*/

            /* //string url2 = bind.XPath ("@src");
             * XmlDocument document = new XmlDocument();
             * document.Load("Samples.xml");
             * XPathNavigator navigator = document.CreateNavigator();
             *
             * navigator.MoveToChild("Samples", "");
             * navigator.MoveToChild("Category", "Approximate");
             * navigator.MoveToChild("Sample ", "");
             *
             * string Sample = (string)navigator.ValueAs(typeof(string));*/

            //TextBox1.Text = Sample;

            /* using (FileStream fs = File.Open(url, FileMode.Open))
             * {
             *    documentTextRange.Load(fs, DataFormats.Rtf);
             * }*/
        }
예제 #6
0
        protected override void Seed(SARDT.Models.SARDTContext context)
        {
            UserManager <Member> userManager = new UserManager <Member>(
                new UserStore <Member>(context));

            WebText homeText = new WebText {
                WebTextID = 0, Page = "Home", Section = "Welcome", Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText homeText1 = new WebText {
                WebTextID = 1, Page = "Home", Section = "News", Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText homeText2 = new WebText {
                WebTextID = 2, Page = "Home", Section = "Announcements", Body = "Announcements, Announcements, Announcements...please?", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };

            context.WebTexts.AddOrUpdate(homeText);
            context.WebTexts.AddOrUpdate(homeText1);
            context.WebTexts.AddOrUpdate(homeText2);

            WebText aboutText = new WebText {
                WebTextID = 6, Page = "Team", Section = "About", Body = "Info about the dive team", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };

            context.WebTexts.AddOrUpdate(aboutText);

            WebText historyText = new WebText {
                WebTextID = 7, Page = "History", Section = "History of the Dive Team", Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText historyText1 = new WebText {
                WebTextID = 20, Page = "History", Section = "Where it started...", Body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };

            context.WebTexts.AddOrUpdate(historyText);
            context.WebTexts.AddOrUpdate(historyText1);


            WebText contactText1 = new WebText {
                WebTextID = 8, Page = "Contact", Section = "Expected Response", Body = "This can be a generic message...once contacted you can expect a response within a certian amount of time...", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText2 = new WebText {
                WebTextID = 9, Page = "Contact", Section = "Name", Body = "Jessica Watson", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText3 = new WebText {
                WebTextID = 10, Page = "Contact", Section = "Email", Body = "*****@*****.**", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText4 = new WebText {
                WebTextID = 11, Page = "Contact", Section = "Phone", Body = "541-682-6411", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText5 = new WebText {
                WebTextID = 12, Page = "Contact", Section = "Fax", Body = "541-682-3309", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText6 = new WebText {
                WebTextID = 13, Page = "Contact", Section = "Address", Body = "125 E 8th Ave", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText7 = new WebText {
                WebTextID = 14, Page = "Contact", Section = "City", Body = "Eugene", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText8 = new WebText {
                WebTextID = 15, Page = "Contact", Section = "State", Body = "OR", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText9 = new WebText {
                WebTextID = 16, Page = "Contact", Section = "Zip", Body = "97401", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText contactText10 = new WebText {
                WebTextID = 17, Page = "Contact", Section = "Map URL", Body = "https://www.google.com/maps/d/embed?mid=1eeqA5dx0Qtw9GB6zqbfBlOk8hCI", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };

            context.WebTexts.AddOrUpdate(contactText1);
            context.WebTexts.AddOrUpdate(contactText2);
            context.WebTexts.AddOrUpdate(contactText3);
            context.WebTexts.AddOrUpdate(contactText4);
            context.WebTexts.AddOrUpdate(contactText5);
            context.WebTexts.AddOrUpdate(contactText6);
            context.WebTexts.AddOrUpdate(contactText7);
            context.WebTexts.AddOrUpdate(contactText8);
            context.WebTexts.AddOrUpdate(contactText9);
            context.WebTexts.AddOrUpdate(contactText10);


            WebText applicationText0 = new WebText {
                WebTextID = 3, Page = "Application", Section = "Requirements", Body = "A summary of steps and requirements. Such as background check, fingerprint, rescue cert, probationary period, current fa/cpr...", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText applicationText1 = new WebText {
                WebTextID = 4, Page = "Application", Section = "1", Body = "Fill out and return the application form.", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText applicationText2 = new WebText {
                WebTextID = 5, Page = "Application", Section = "2", Body = "App part 2", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText applicationText3 = new WebText {
                WebTextID = 18, Page = "Application", Section = "3", Body = "App part 3", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };
            WebText applicationText4 = new WebText {
                WebTextID = 19, Page = "Application", Section = "4", Body = "App part 4", LastChangedOn = new DateTime(2016, 4, 2), LastChangeBy = "Kyle"
            };

            context.WebTexts.AddOrUpdate(applicationText0);
            context.WebTexts.AddOrUpdate(applicationText1);
            context.WebTexts.AddOrUpdate(applicationText2);
            context.WebTexts.AddOrUpdate(applicationText3);
            context.WebTexts.AddOrUpdate(applicationText4);

            Application app = new Application {
                ApplicationID = 0, FileName = "Application.pdf"
            };

            context.Applications.AddOrUpdate(app);

            WebImage image1 = new WebImage {
                WebImageID = 0, FileName = "pic1.jpg", Caption = "Image Caption1", InUse = true, Page = "Home", Location = 1
            };
            WebImage image2 = new WebImage {
                WebImageID = 1, FileName = "pic2.jpg", Caption = "Image Caption2", InUse = true, Page = "Home", Location = 2
            };
            WebImage image3 = new WebImage {
                WebImageID = 2, FileName = "pic3.jpg", Caption = "Image Caption3", InUse = true, Page = "History", Location = 1
            };
            WebImage image4 = new WebImage {
                WebImageID = 3, FileName = "pic4.jpg", Caption = "Image Caption4", InUse = true, Page = "History", Location = 2
            };
            WebImage image5 = new WebImage {
                WebImageID = 4, FileName = "pic5.jpg", Caption = "Image Caption5", InUse = false, Page = "", Location = null
            };

            context.WebImages.AddOrUpdate(image1);
            context.WebImages.AddOrUpdate(image2);
            context.WebImages.AddOrUpdate(image3);
            context.WebImages.AddOrUpdate(image4);
            context.WebImages.AddOrUpdate(image5);

            Video seedVid = new Video {
                ID = 2, Title = "Insert Title", URL = "https://www.youtube.com/embed/6OHmn4Tcfd4?rel=0"
            };

            context.Videos.AddOrUpdate(seedVid);
            CurrentVideos video = new CurrentVideos {
                CurrentVideo = seedVid, ID = 2
            };

            context.CurrentVideo.AddOrUpdate(video);


            // create various users
            var userMember = new Member {
                UserName = "******", Email = "*****@*****.**", Name = "Member Test"
            };
            var adminCreateResult = userManager.Create(userMember, "password");

            var userMod = new Member {
                UserName = "******", Email = "*****@*****.**", Name = "Moderator Stevens"
            };
            var modCreateResult = userManager.Create(userMod, "password");

            var userBob = new Member {
                UserName = "******", Email = "*****@*****.**", Name = "Bob Dylan"
            };
            var bobCreateResult = userManager.Create(userBob, "password");

            var userGuy = new Member {
                UserName = "******", Email = "*****@*****.**", Name = "Guy Pierce"
            };
            var guyCreateResult = userManager.Create(userGuy, "password");



            //##### START OF CHANGES TO FIX ISSUE WITH DATABASE SEEDING #####
            //###############################################################

            // --- CHECK TO SEE IF THERE IS ALREADY AN ADMIN ROLE IN THE DATABASE
            var memberRole = (from role in context.Roles
                              where role.Name == "member"
                              select role).FirstOrDefault();


            // --- CHECK TO SEE IF THERE IS ALREADY A MODERATOR ROLE IN THE DATABASE
            var moderatorRole = (from role in context.Roles
                                 where role.Name == "Moderator"
                                 select role).FirstOrDefault();

            // --- IF QUERY DID NOT FIND AN ADMIN ROLE IN DATABASE, ADD IT.
            if (memberRole == null)
            {
                context.Roles.AddOrUpdate(new IdentityRole()
                {
                    Name = "Member"
                });
            }

            // --- IF QUERY DID NOT FIND A MODERATOR ROLE IN DATABASE, ADD IT.
            if (moderatorRole == null)
            {
                context.Roles.AddOrUpdate(new IdentityRole()
                {
                    Name = "Moderator"
                });
            }
            context.SaveChanges();

            // --- GET THE USER FROM THE DATABASE. THIS IS TO RESOLVE ISSUES WITH
            // --- AddToRole FUNCTION.
            userMember = (from user in context.Users
                          where user.UserName == "member"
                          select user).FirstOrDefault();


            // --- GET THE USER FROM THE DATABASE. THIS IS TO RESOLVE ISSUES WITH
            // --- AddToRole FUNCTION.
            userMod = (from user in context.Users
                       where user.UserName == "moderator"
                       select user).FirstOrDefault();

            // ########################################################
            // ##### END OF CHANGES TO FIX DATABASE SEEDING ERROR #####


            // Add role to user
            userManager.AddToRole(userMember.Id, "Member");
            userManager.AddToRole(userMod.Id, "Moderator");

            Event firstEvent = new Event {
                Description = "This is the first event!", StartTime = "1200", EndTime = "1400", EventDate = Convert.ToDateTime("04/30/2016"), EventTitle = "First Event", LastChangeBy = "guy", LastChangedOn = Convert.ToDateTime("04/30/2016"), Type = "public"
            };

            Event secondEvent = new Event {
                Description = "Second event here!", StartTime = "0800", EndTime = "1000", EventDate = Convert.ToDateTime("04/21/2016"), EventTitle = "Second Event", LastChangeBy = "dude", LastChangedOn = Convert.ToDateTime("04/21/2016"), Type = "public"
            };

            Event thirdEvent = new Event {
                Description = "WOOOHOOO!", StartTime = "1700", EndTime = "2000", EventDate = Convert.ToDateTime("05/10/2016"), EventTitle = "Last Event", LastChangeBy = "person", LastChangedOn = Convert.ToDateTime("05/10/2016"), Type = "team"
            };

            context.Events.AddOrUpdate(firstEvent);
            context.Events.AddOrUpdate(secondEvent);
            context.Events.AddOrUpdate(thirdEvent);

            context.SaveChanges();
            base.Seed(context);
        }
예제 #7
0
 public string Get(string title)
 {
     return(WebText.Html(title));
 }