Beispiel #1
0
            public Data(ClaimsPrincipal User, int id, string excuse, int request, int response, string date)
            {
                JObject lang = LangResource.GetLanguageJson("excuseStates", User.FindFirst("Language").Value);

                Id     = id;
                Excuse = excuse;
                Date   = date;
                if (request == 0)
                {
                    Request = "Change Status";
                }
                else if (request == 1)
                {
                    Request = "Use Day off";
                }
                if (response == 0)
                {
                    Response = "No";
                }
                else if (response == 1)
                {
                    Response = "Yes";
                }
                else if (response == 2)
                {
                    Response = "Waiting User";
                }
                else if (response == 3)
                {
                    Response = "Waiting Admin";
                }
            }
Beispiel #2
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource,
        ///passes the selected day to client,
        ///fills the "days" list and finally provides the page
        ///</summary>
        public void OnGet(string day = "")
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.excuse);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
            }
            Int32.TryParse(HttpContext.User.Identity.Name, out Id);
            lang = LangResource.GetLanguageJson("excuse", User.FindFirst("Language").Value);
            var query =
                from u in _context.UserWorkedSet
                where u.UserId == Id &&
                u.ReqApproved == 2 &&
                u.WorkedTime < 8
                select u;

            days = new List <string>();
            foreach (UserWorked u in query)
            {
                days.Add(u.date.ToString("yyyy.MM.dd") + " / " + u.date.DayOfWeek);
                try
                {
                    if (DateTime.Equals(u.date, DateTime.Parse(day)))
                    {
                        clickedIndex = days.Count - 1;
                    }
                }
                catch (Exception)
                {
                    System.Console.WriteLine("No day input");
                }
            }
        }
Beispiel #3
0
        ///<summary>
        ///Handles get requests from "authTable".
        ///authenticates the user, gets the language resource
        ///and finally provides the page. Optionally gets an Id for client to preselect
        ///</summary>
        public void OnGetFromTable(string id = "1")
        {
            initSelect = id;
            var obj = _context.AdminAuthorizationSet.ToList();

            auths = obj as List <AdminAuthorization>;
            lang  = LangResource.GetLanguageJson("authorize", User.FindFirst("Language").Value);
        }
Beispiel #4
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource
        ///and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.admin);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
                return;
            }
            Name = User.FindFirst("FullName").Value;
            lang = LangResource.GetLanguageJson("admin", User.FindFirst("Language").Value);
        }
Beispiel #5
0
        ///<summary>
        ///Provides the json data for the permits popup table
        ///but gets only a 10 row page.
        ///can feed page number through "getPage" parameter
        ///</summary>
        public ActionResult OnPostPermits()
        {
            lang = LangResource.GetLanguageJson("admin", User.FindFirst("Language").Value);
            int reqPageOffset = 1;

            Int32.TryParse(HttpContext.Request.Form["getPage"], out reqPageOffset);
            reqPageOffset = (reqPageOffset * 10) - 10;
            string IzinDbPath = Configuration.GetSection("Connections:IzinMsSqlDB").Value;

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = IzinDbPath;
                SqlCommand    cmd = new SqlCommand();
                SqlDataReader reader;
                cmd.CommandText = "SELECT * FROM SMP_BORAX_IZIN order by \"İzin Tarihi\" OFFSET " + reqPageOffset + " ROWS FETCH NEXT 10 ROWS ONLY;";
                cmd.Connection  = conn;
                raporlar        = new List <Rapor>();
                conn.Open();
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Rapor rapor = new Rapor
                    {
                        Id = (string)reader.GetValue(0)
                        ,
                        IzinTip = (string)reader.GetValue(1)
                        ,
                        IzinTarih = ((DateTime)reader.GetValue(2)).ToString()
                        ,
                        BasSaat = MinsToTime((Int32)reader.GetValue(3))
                        ,
                        BitSaat = MinsToTime((Int32)reader.GetValue(4))
                        ,
                        Saat = (Decimal)reader.GetValue(5)
                        ,
                        Durum = (string)reader.GetValue(6)
                    };
                    rapor.IzinTarih = rapor.IzinTarih.Substring(0, 10);

                    raporlar.Add(rapor);
                    //System.Console.WriteLine(rapor.Id + "-" + rapor.IzinTip + "-" + rapor.IzinTarih + "-" + rapor.BasSaat + "-" + rapor.BitSaat + "-" + rapor.Saat + "-" + rapor.Durum);
                }
                return(new JsonResult(JsonConvert.SerializeObject(raporlar)));
            }
        }
Beispiel #6
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource
        ///, fills the "reqs" list and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.authTable);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
            }
            lang = LangResource.GetLanguageJson("requestsTable", User.FindFirst("Language").Value);
            var obj = (from w in _context.UserWorkedSet
                       join u in _context.UserSet
                       on w.UserId equals u.Id
                       where w.ReqApproved == 3
                       select new
            {
                UserId = u.Id
                ,
                Id = w.Id
                ,
                Name = u.Name
                ,
                Excuse = w.Excuse
                ,
                Request = w.Request
                ,
                Day = w.date
            }).ToList();

            if (obj.Count == 0)
            {
                State = "No users found.";
            }
            reqs = new List <Data>();
            for (int i = 0; i < obj.Count; i++)
            {
                reqs.Add(new Data(obj[i].Id,
                                  obj[i].UserId,
                                  obj[i].Name,
                                  obj[i].Excuse,
                                  obj[i].Request,
                                  obj[i].Day.ToString().Substring(0, obj[i].Day.ToString().Length - 9)
                                  ));
            }
            ViewData["Table"] = reqs;
        }
Beispiel #7
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource
        ///and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.login);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
            }
            lang = LangResource.GetLanguageJson("login", "EN");


            try
            {
                if (HttpContext.User.FindFirst("Role").Value == "3")
                {
                    State = "Your account is inactive";
                }
            }
            catch (Exception) { }
        }
Beispiel #8
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource
        ///, fills the "users" list and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.authTable);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
            }
            lang = LangResource.GetLanguageJson("hoursTable", User.FindFirst("Language").Value);
            var obj = (from s in _context.StandartWorkhoursSet
                       join u in _context.UserSet
                       on s.Id equals u.StandartWorkHoursId
                       select new
            {
                Id = u.Id
                ,
                Name = u.Name
                ,
                StartHr = s.StartHr
                ,
                EndHr = s.EndHr
                ,
                BreakTime = s.BreakTime
            }).ToList();

            if (obj.Count == 0)
            {
                State = "No users found.";
            }
            users = new List <Data>();
            for (int i = 0; i < obj.Count; i++)
            {
                users.Add(new Data(obj[i].Id,
                                   obj[i].Name,
                                   obj[i].StartHr.ToString().Substring(10, obj[i].StartHr.ToString().Length - 10),
                                   obj[i].EndHr.ToString().Substring(10, obj[i].EndHr.ToString().Length - 10),
                                   obj[i].BreakTime
                                   ));
            }
            ViewData["Table"] = users;
        }
Beispiel #9
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource
        ///, fills the "users" list and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.hoursChange);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
                return;
            }
            lang = LangResource.GetLanguageJson("hoursChange", User.FindFirst("Language").Value);
            var query =
                from u in _context.UserSet
                where u.Id != Int32.Parse(HttpContext.User.Identity.Name)
                select u;

            users = new Dictionary <int, string>();
            foreach (User u in query)
            {
                users[u.Id] = u.Name;
            }
        }
Beispiel #10
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource,
        ///fills the "reqs" list and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.excuseStates);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
                return;
            }
            string name = User.FindFirst("FullName").Value;

            lang = LangResource.GetLanguageJson("excuseStates", User.FindFirst("Language").Value);
            var obj = (from w in _context.UserWorkedSet
                       where w.UserId == Int32.Parse(User.FindFirst(ClaimTypes.Name).Value) && w.WorkedTime < 8 && w.ReqApproved != 2
                       select new
            {
                Id = w.Id
                ,
                Excuse = w.Excuse
                ,
                Request = w.Request
                ,
                Response = w.ReqApproved
                ,
                Date = w.date
            }).ToList();

            reqs = new List <Data>();
            for (int i = 0; i < obj.Count; i++)
            {
                reqs.Add(new Data(User,
                                  obj[i].Id,
                                  obj[i].Excuse,
                                  obj[i].Request,
                                  obj[i].Response,
                                  obj[i].Date.ToString().Substring(0, obj[i].Date.ToString().Length - 9)
                                  ));
            }
            ViewData["Table"] = reqs;
        }
Beispiel #11
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource,
        ///fills the "auths" list and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.authTable);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
            }
            lang = LangResource.GetLanguageJson("authTable", User.FindFirst("Language").Value);

            var obj = (from a in _context.AdminAuthorizationSet
                       join u in _context.UserSet
                       on a.UserId equals u.Id
                       select new
            {
                Id = a.Id
                ,
                Name = u.Name
                ,
                Customize = a.Customize
                ,
                Requests = a.Requests
                ,
                Authority = a.Authority
            }).ToList();

            if (obj.Count == 0)
            {
                Response.Redirect("/admin", false);
            }
            auths = new List <Data>();
            for (int i = 0; i < obj.Count; i++)
            {
                auths.Add(new Data(obj[i].Id, obj[i].Name, obj[i].Customize, obj[i].Requests, obj[i].Authority));
            }
            ViewData["Table"] = auths;
        }
Beispiel #12
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource
        ///, fills the "users" list and finally provides the page
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.requestRespond);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
                return;
            }
            lang = LangResource.GetLanguageJson("requestRespond", User.FindFirst("Language").Value);
            var obj = (from u in _context.UserSet
                       join w in _context.UserWorkedSet
                       on u.Id equals w.UserId
                       where u.Id != Int32.Parse(HttpContext.User.Identity.Name) &&
                       w.ReqApproved == 3
                       select new
            {
                UserId = u.Id
                ,
                Name = u.Name
                ,
                Id = w.Id
            }).ToList();

            users = new List <Data>();
            if (obj.Count == 0)
            {
                State = "No requests found.";
                return;
            }
            for (int i = 0; i < obj.Count; i++)
            {
                users.Add(new Data(obj[i].UserId, obj[i].Name, obj[i].Id));
            }
            ViewData["Table"] = users;
        }
Beispiel #13
0
 ///<summary>
 ///Calls the interconnector to change the
 /// password of the user accordingly
 ///Requires: prevPwInput, newPwInput, newPwInput2
 /// through request
 ///</summary>
 public ActionResult OnPostPWChange()
 {
     lang = LangResource.GetLanguageJson("admin", User.FindFirst("Language").Value);
     return(new JsonResult(lang[Interconnector.PasswordChange(_context, HttpContext)]));
 }
Beispiel #14
0
        ///<summary>
        ///Default get handler:
        ///Authenticates the user, gets the language resource,
        ///fills the "weeks" list and finally provides the page.
        ///weeks are filled by fetching and grouping the days
        ///by week of a year
        ///</summary>
        public void OnGet()
        {
            string redirectionPath = Interconnector.Authenticator(HttpContext.User, EPage.worked);

            if (redirectionPath != "")
            {
                Response.Redirect(redirectionPath, false);
                return;
            }
            if (HttpContext.User.FindFirst("Role").Value == "1")
            {
                UserIsAdmin = true;
            }
            int uId = 0;

            Int32.TryParse(HttpContext.User.Identity.Name, out uId);

            Name = User.FindFirst("FullName").Value;
            lang = LangResource.GetLanguageJson("worked", User.FindFirst("Language").Value);
            List <UserWorked> worked = null;

            try
            {
                worked = _context.UserWorkedSet.Where(b => (b.UserId == uId)).ToList() as List <UserWorked>;
                worked.Sort((x, y) => DateTime.Compare(x.date, y.date));
                var d1             = worked.First().date;
                var d2             = worked.Last().date;
                var currentCulture = CultureInfo.CurrentCulture;
                weeks = new Dictionary <int, Week>();
                for (var dt = d1; dt <= d2; dt = dt.AddDays(1))
                {
                    var weekNo = currentCulture.Calendar.GetWeekOfYear(
                        dt,
                        currentCulture.DateTimeFormat.CalendarWeekRule,
                        currentCulture.DateTimeFormat.FirstDayOfWeek);
                    if (dt.DayOfWeek == DayOfWeek.Saturday || dt.DayOfWeek == DayOfWeek.Sunday)
                    {
                        continue;
                    }
                    if (!weeks.Keys.Contains(weekNo))
                    {
                        weeks[weekNo]         = new Week();
                        weeks[weekNo].dates   = new Dictionary <DayOfWeek, DateTime>();
                        weeks[weekNo].days    = new Dictionary <DayOfWeek, int>();
                        weeks[weekNo].dayReqs = new Dictionary <DayOfWeek, EDayStates>();
                    }
                    if (null == worked.Find(x => x.date == dt))
                    {
                        var newWorked = new UserWorked {
                            WorkedTime = 0, date = dt, UserId = uId
                        };
                        _context.UserWorkedSet.Add(newWorked);
                        _context.SaveChanges();
                        weeks[weekNo].days[dt.DayOfWeek]    = 0;
                        weeks[weekNo].dayReqs[dt.DayOfWeek] = EDayStates.UserPending;
                    }
                    else
                    {
                        weeks[weekNo].days[dt.DayOfWeek]    = worked.Find(x => x.date == dt).WorkedTime;
                        weeks[weekNo].dayReqs[dt.DayOfWeek] = (EDayStates)worked.Find(x => x.date == dt).ReqApproved;
                    }
                    weeks[weekNo].dates[dt.DayOfWeek] = dt;
                    Console.WriteLine(weekNo + " : " + dt.DayOfWeek + " : " + dt + " : " + weeks[weekNo].days[dt.DayOfWeek] + " : " + weeks[weekNo].dayReqs[dt.DayOfWeek]);
                }
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.Message);
                worked = new List <UserWorked>();
                worked.Add(new UserWorked());
            }
        }