Ejemplo n.º 1
0
        public static string DriveToUNC(string RoutingPath, string RoutingDrive, out DriveMapping unc, User user)
        {
            hapConfig config = hapConfig.Current;

            unc = config.MyFiles.Mappings.FilteredMappings[RoutingDrive.ToCharArray()[0]];
            return((Converter.FormatMapping(unc.UNC, user) + HttpUtility.UrlDecode(RoutingPath.Replace('|', '%'), System.Text.Encoding.Default)).TrimEnd(new char[] { '\\' }).Replace('^', '&').Replace('/', '\\'));
        }
Ejemplo n.º 2
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            if (!UrlAuthorizationModule.CheckUrlAccessForPrincipal("~/Download/", requestContext.HttpContext.User, requestContext.HttpContext.Request.HttpMethod))
            {
                requestContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                requestContext.HttpContext.Response.End();
            }

            hapConfig    config = hapConfig.Current;
            string       path   = HttpUtility.UrlDecode(((string)requestContext.RouteData.Values["path"]).Replace('^', '&').Replace("|", "%"));
            DriveMapping unc    = config.MyFiles.Mappings.FilteredMappings[((string)requestContext.RouteData.Values["drive"]).ToUpper().ToCharArray()[0]];

            path = Converter.FormatMapping(unc.UNC, ADUser) + '\\' + path.Replace('/', '\\');
            HAP.Data.SQL.WebEvents.Log(DateTime.Now, "MyFiles.Download", requestContext.HttpContext.User.Identity.Name, HttpContext.Current.Request.UserHostAddress, HttpContext.Current.Request.Browser.Platform, HttpContext.Current.Request.Browser.Browser + " " + HttpContext.Current.Request.Browser.Version, HttpContext.Current.Request.UserHostName, "Downloading: " + path);

            Downloader downloader = new Downloader();

            if (requestContext.RouteData.Values.ContainsKey("path"))
            {
                downloader.RoutingPath = requestContext.RouteData.Values["path"] as string;
            }
            else
            {
                downloader.RoutingPath = string.Empty;
            }
            downloader.RoutingDrive = requestContext.RouteData.Values["drive"] as string;
            downloader.RoutingDrive = downloader.RoutingDrive.ToUpper();
            return(downloader);
        }
Ejemplo n.º 3
0
        public int RemoveLesson(string name)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.BookingSystem.Lessons.Remove(name);
            return(0);
        }
Ejemplo n.º 4
0
        public Properties Properties(string teacher, string name, string start, string end, string Drive, string Path)
        {
            Properties ret = new Properties();

            Path = "/" + Path;
            hapConfig   config = hapConfig.Current;
            List <File> Items  = new List <File>();

            Homework.Homework i = Item(teacher, name, start, end);
            User user           = new User();

            if (config.AD.AuthenticationMode == Web.Configuration.AuthMode.Forms)
            {
                user.Authenticate(i.Teacher, TokenGenerator.ConvertToPlain(i.Token));
            }
            DriveMapping mapping;
            string       path = Converter.DriveToUNC(Path, Drive, out mapping, user);

            HAP.Data.SQL.WebEvents.Log(DateTime.Now, "MyFiles.Properties", user.UserName, HttpContext.Current.Request.UserHostAddress, HttpContext.Current.Request.Browser.Platform, HttpContext.Current.Request.Browser.Browser + " " + HttpContext.Current.Request.Browser.Version, HttpContext.Current.Request.UserHostName, "Requesting properties of: " + path);
            user.ImpersonateContained();
            try
            {
                FileAttributes attr = System.IO.File.GetAttributes(path);
                //detect whether its a directory or file
                ret = ((attr & FileAttributes.Directory) == FileAttributes.Directory) ? new Properties(new DirectoryInfo(path), mapping, user) : new Properties(new FileInfo(path), mapping, user);
            }
            finally { user.EndContainedImpersonate(); }

            return(ret);
        }
Ejemplo n.º 5
0
        public int RemoveMapping(string drive, string unc)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.MyFiles.Mappings.Remove(new MappingKey(drive.ToCharArray()[0], unc.Replace('/', '\\')));
            return(0);
        }
Ejemplo n.º 6
0
        public int RemoveFilter(string name, string expression)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.MyFiles.Filters.Delete(name, expression.Replace("/", "\\"));
            return(0);
        }
Ejemplo n.º 7
0
        public int AddLesson(string name, string type, string start, string end)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            int       h      = int.Parse(start.Substring(0, 2)) + (start.Contains("PM") ? 12 : 0);

            if (h == 12)
            {
                h = 0;
            }
            else if (h == 24)
            {
                h = 12;
            }
            int h2 = int.Parse(end.Substring(0, 2)) + (end.Contains("PM") ? 12 : 0);

            if (h2 == 12)
            {
                h2 = 0;
            }
            else if (h2 == 24)
            {
                h2 = 12;
            }
            Config.BookingSystem.Lessons.Add(name,
                                             (LessonType)Enum.Parse(typeof(LessonType), type),
                                             new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, h, int.Parse(start.Substring(3, 2)), 00),
                                             new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, h2, int.Parse(end.Substring(3, 2)), 00));
            return(0);
        }
Ejemplo n.º 8
0
        public int AddOU(string path, string name, string visibility)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.AD.OUs.Add(name, HttpUtility.UrlDecode(path, System.Text.Encoding.Default), (OUVisibility)Enum.Parse(typeof(OUVisibility), visibility));
            return(0);
        }
Ejemplo n.º 9
0
        public int UpdateSubject(string origsubject, string subject)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.BookingSystem.Subjects.Update(origsubject, subject);
            return(0);
        }
Ejemplo n.º 10
0
        public int AddLinkGroup(string name, string showto, string subtitle, string hidehomepage, string hidetopmenu, string hidehomepagelink)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.Homepage.Groups.Add(name, showto, subtitle, bool.Parse(hidehomepage), bool.Parse(hidetopmenu), bool.Parse(hidehomepagelink));
            return(0);
        }
Ejemplo n.º 11
0
        public int RemoveLinkGroup(string name)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.Homepage.Groups.Remove(name);
            return(0);
        }
Ejemplo n.º 12
0
        public int AddFilter(string name, string expression, string enablefor)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.MyFiles.Filters.Add(name, expression.Replace("/", "\\"), enablefor);
            return(0);
        }
Ejemplo n.º 13
0
        public int RemoveOU(string name)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.AD.OUs.Remove(name);
            return(0);
        }
Ejemplo n.º 14
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            hapConfig config = hapConfig.Current;

            if (context.Request.QueryString["op"] == "getBookings")
            {
                DateTime date = DateTime.Parse(context.Request.QueryString["d"]);
                HAP.BookingSystem.BookingSystem bs = new HAP.BookingSystem.BookingSystem(date);
                string format = "{0}:{1}:{2}:{3}";

                List <string> bookings = new List <string>();
                foreach (Resource br in config.BookingSystem.Resources.Values)
                {
                    foreach (Lesson l in config.BookingSystem.Lessons)
                    {
                        foreach (Booking b in bs.getBooking(br.Name, l.Name))
                        {
                            bookings.Add(string.Format(format, b.Lesson, b.Name, b.Room, b.Username == "Not Booked" ? "" : b.User.Notes));
                        }
                    }
                }
                context.Response.Write(string.Join("\n", bookings.ToArray()));
            }
            else if (context.Request.QueryString["op"] == "getTimes")
            {
                foreach (Lesson l in config.BookingSystem.Lessons)
                {
                    context.Response.Write(string.Format("{0},{1},{2}\n", l.Name, l.StartTime, l.EndTime));
                }
            }
        }
Ejemplo n.º 15
0
        public int RemoveSubject(string subject)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.BookingSystem.Subjects.Delete(subject);
            return(0);
        }
Ejemplo n.º 16
0
        public int UpdateLink(string group, string origname, string name, string desc, string icon, string url, string target, string showto, string width, string height)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            bool      temp   = true;

            if (Config == null)
            {
                Config = hapConfig.Current; temp = false;
            }
            Link l = Config.Homepage.Groups[group].Single(a => a.Name == origname);

            l.ShowTo      = showto;
            l.Description = desc;
            l.Url         = url;
            l.Target      = target;
            l.Icon        = icon;
            l.Name        = name;
            l.Width       = width;
            l.Height      = height;
            Config.Homepage.Groups[group].UpdateLink(origname, l);
            if (!temp)
            {
                Config.Save();
            }
            return(0);
        }
Ejemplo n.º 17
0
        public int EditLesson(string origname, string name, string type, string start, string end)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            Lesson    l      = Config.BookingSystem.Lessons.Get(origname);

            l.Name = name;
            l.Type = (LessonType)Enum.Parse(typeof(LessonType), type.Replace(" ", ""));
            int h = int.Parse(start.Substring(0, 2)) + (start.Contains("PM") ? 12 : 0);

            if (h == 12)
            {
                h = 0;
            }
            else if (h == 24)
            {
                h = 12;
            }
            int h2 = int.Parse(end.Substring(0, 2)) + (end.Contains("PM") ? 12 : 0);

            if (h2 == 12)
            {
                h2 = 0;
            }
            else if (h2 == 24)
            {
                h2 = 12;
            }
            l.StartTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, h, int.Parse(start.Substring(3, 2)), 00);
            l.EndTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, h2, int.Parse(end.Substring(3, 2)), 00);
            Config.BookingSystem.Lessons.Update(origname, l);
            return(0);
        }
Ejemplo n.º 18
0
        public int RemoveResource(string name)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.BookingSystem.Resources.Delete(name);
            return(0);
        }
Ejemplo n.º 19
0
        public int AddResource(string name, string type, bool enabled, bool charging, string admins, bool emailadmins, string showto, string hidefrom, string quantities, string years, string readonlyto, string readwriteto, string disclaimer, bool canshare)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.BookingSystem.Resources.Add(name, (ResourceType)Enum.Parse(typeof(ResourceType), type), admins, enabled, emailadmins, charging, showto, hidefrom, years, quantities, readonlyto, readwriteto, disclaimer, canshare);
            return(0);
        }
Ejemplo n.º 20
0
        public int AddMapping(string drive, string name, string unc, string enablereadto, string enablewriteto, string usagemode)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            unc = unc.Replace('/', '\\');
            Config.MyFiles.Mappings.Add(drive.ToCharArray()[0], name, unc, enablereadto, enablewriteto, (MappingUsageMode)Enum.Parse(typeof(MappingUsageMode), usagemode));
            return(0);
        }
Ejemplo n.º 21
0
        public int RemoveQServer(string server, string expression)
        {
            expression = expression.Replace('/', '\\');
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.MyFiles.QuotaServers.Delete(server, expression);
            return(0);
        }
Ejemplo n.º 22
0
        public int AddQServer(string server, string expression, string drive)
        {
            expression = expression.Replace('/', '\\');
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            Config.MyFiles.QuotaServers.Add(server, expression, drive.ToCharArray()[0]);
            return(0);
        }
Ejemplo n.º 23
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            hapConfig config = hapConfig.Current;

            HAP.BookingSystem.BookingSystem bs = new HAP.BookingSystem.BookingSystem(Date);
            writer.WriteLine("<div class=\"lessoncol\" style=\"border-left-width: 1px;\">");
            writer.Write("<h2>");
            writer.Write("Lesson");
            writer.WriteLine("</h2>");
            bool alt = false;

            foreach (Lesson les in config.BookingSystem.Lessons)
            {
                writer.Write("<div{0}>", alt ? " class=\"alt\"" : "");
                writer.Write(les.Name);
                writer.WriteLine("</div>");
                alt = !alt;
            }
            writer.WriteLine("</div>");
            alt = false;
            foreach (Resource res in config.BookingSystem.Resources.Values)
            {
                string Room = res.Name;
                writer.WriteLine("<div class=\"lessoncol\">");
                writer.Write("<h2>");
                writer.Write(res.Name);
                writer.WriteLine("</h2>");
                foreach (Lesson lesson in config.BookingSystem.Lessons)
                {
                    foreach (Booking b in bs.getBooking(Room, lesson.Name))
                    {
                        string lessonname = b.Name;
                        if (lessonname.Length > 17)
                        {
                            lessonname = lessonname.Remove(17) + "...";
                        }
                        if (lessonname.Length > 16 && b.Static)
                        {
                            lessonname = lessonname.Remove(14) + "...";
                        }
                        if (b.Name == "FREE")
                        {
                            writer.Write("<div{0}>FREE</div>", alt ? " class=\"alt\"" : "");
                        }
                        else
                        {
                            writer.Write("<div{2}><span>{0}<i>with {1}</i></span></div>", lessonname, b.User.Notes, alt ? " class=\"alt\"" : "");
                        }
                        alt = !alt;
                    }
                }
                alt = false;
                writer.Write("</div>");
            }
        }
Ejemplo n.º 24
0
        public int UpdateFilter(string origname, string origexpression, string name, string expression, string enablefor)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            Filter    f      = Config.MyFiles.Filters.Find(origname, origexpression.Replace("/", "\\"));

            f.Name       = name;
            f.Expression = expression.Replace("/", "\\");
            f.EnableFor  = enablefor;
            Config.MyFiles.Filters.Update(origname, origexpression.Replace("/", "\\"), f);
            return(0);
        }
Ejemplo n.º 25
0
        public int UpdateLinkGroupOrder(string groups)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;

            if (Config == null)
            {
                Config = hapConfig.Current;
            }
            Config.Homepage.Groups.ReOrder(groups.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
            return(0);
        }
Ejemplo n.º 26
0
        public int UpdateQServer(string origserver, string origexpression, string server, string expression, string drive)
        {
            origexpression = origexpression.Replace('/', '\\');
            expression     = expression.Replace('/', '\\');
            hapConfig   Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            QuotaServer q      = Config.MyFiles.QuotaServers.Find(origserver, origexpression);

            q.Server     = server;
            q.Drive      = drive.ToCharArray()[0];
            q.Expression = expression;
            Config.MyFiles.QuotaServers.Update(origserver, origexpression, q);
            return(0);
        }
Ejemplo n.º 27
0
        public int UpdateMapping(string origdrive, string origunc, string drive, string name, string unc, string enablereadto, string enablewriteto, string usagemode)
        {
            hapConfig    Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            DriveMapping m      = Config.MyFiles.Mappings.Single(ma => ma.Key.Drive == origdrive.ToCharArray()[0] && ma.Key.UNC == origunc.Replace('/', '\\')).Value;

            m.Drive         = drive.ToCharArray()[0];
            m.UsageMode     = (MappingUsageMode)Enum.Parse(typeof(MappingUsageMode), usagemode);
            m.Name          = name;
            m.UNC           = unc.Replace('/', '\\');
            m.EnableReadTo  = enablereadto;
            m.EnableWriteTo = enablewriteto;
            Config.MyFiles.Mappings.Update(origdrive.ToCharArray()[0], origunc, m);
            return(0);
        }
Ejemplo n.º 28
0
        public int UpdateLinkGroup(string origname, string name, string showto, string subtitle, string hidehomepage, string hidetopmenu, string hidehomepagelink)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            LinkGroup g      = Config.Homepage.Groups[origname];

            g.ShowTo           = showto;
            g.Name             = name;
            g.SubTitle         = subtitle;
            g.HideHomePage     = bool.Parse(hidehomepage);
            g.HideTopMenu      = bool.Parse(hidetopmenu);
            g.HideHomePageLink = bool.Parse(hidehomepagelink);
            Config.Homepage.Groups.UpdateGroup(origname, g);
            return(0);
        }
Ejemplo n.º 29
0
        public int UpdateLinkOrder(string group, string links)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            bool      temp   = true;

            if (Config == null)
            {
                Config = hapConfig.Current; temp = false;
            }
            Config.Homepage.Groups[group.Remove(0, 9).Replace('_', ' ')].ReOrder(links.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
            if (!temp)
            {
                Config.Save();
            }
            return(0);
        }
Ejemplo n.º 30
0
        public int RemoveLink(string group, string name)
        {
            hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig;
            bool      temp   = true;

            if (Config == null)
            {
                Config = hapConfig.Current; temp = false;
            }
            Config.Homepage.Groups[group].Remove(name);
            if (!temp)
            {
                Config.Save();
            }
            return(0);
        }