public ActionResult Index()
        {
            //Check so the user is logged in
            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                loggedInUser user = Session["user"] as loggedInUser;
                if (user.errorText != "")
                {
                    ViewBag.errorText = user.errorText;
                    user.errorText    = "";
                    return(View("ErrorView"));
                }
                user.lastView = "_5S";

                /* Send in the current user to update 5S tasks
                 * send that info to the view */

                s5Func.update5S(user);
                if (s5Func._5sDone.Count() != 0)
                {
                    ViewData["5sDone"] = s5Func._5sDone;
                }
                ViewBag.submitClass = s5Func.submitClass;
                ViewBag.canSubmit   = s5Func.canSubmit;
                return(View(s5Func._5sTodo));
            }
        }
Example #2
0
        /* PartialView on the top of the webpage, displays
         * information about the user. */
        public ActionResult MachinePartialView()
        {
            //If user is null, you are not logged in, return empty view.
            if (Session["user"] != null)
            {
                //Get logged in user, check what shift is on and getShift(x) x days back.
                loggedInUser user = Session["user"] as loggedInUser;
                ViewBag.selectedShiftNo = user.selShift.shiftno.ToString();
                ViewBag.allShift        = user.getShiftBack(3);

                //Is the user locked to a machine
                if (!user.locked)
                {
                    ViewBag.allMachines = user.allMachines();
                }
                //Are the machine a producing machine?
                if (user.prodMachine())
                {
                    var MachTarFun = new MachineTargetFunctions(context, user);
                    if (MachTarFun.prodShift == null)
                    {
                        user.errorText = "Could not fetch shift production data!";
                        return(new EmptyResult());
                    }
                    ViewBag.tarRes = MachTarFun.calcTargetResult();
                }
                return(PartialView(user));
            }

            return(new EmptyResult());
        }
Example #3
0
        public ActionResult getAllSettingValues(int index)
        {
            loggedInUser user       = Session["user"] as loggedInUser;
            var          descValues = user.selectSetting.getAllSettingValues(index);

            return(Json(descValues, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public ActionResult Index()
        {
            loggedInUser user = Session["user"] as loggedInUser;

            user.lastView = "History";

            /*var fetchSetting = from d in context.MachSettHistory where d.machSettID == 1 select d;
             * string settName = fetchSetting.First().MachineSettings.machineSetting;
             * var chart = new Chart(width: 600, height: 400, theme: ChartTheme.Green)
             *  .AddTitle(settName).AddSeries("Default", chartType: "line",
             *  xValue: fetchSetting, xField: "date",
             *  yValues: fetchSetting, yFields: "paramInput"
             *  ).Save(path: "~/content/chart.png");
             *
             * IEnumerable<SelectListItem> items = context.MachineSettings.Select(c => new SelectListItem
             * {
             *  Value = c.machSettID.ToString(),
             *  Text = c.machineSetting
             * });
             *
             * ViewBag.machSettID = items;
             *
             * if (Session["user"] == null)
             * {
             *  return RedirectToAction("Index");
             * }
             * return View(fetchSetting.ToList());*/
            return(View());
        }
Example #5
0
        public ActionResult getDescriptions(string index)
        {
            loggedInUser  user         = Session["user"] as loggedInUser;
            List <string> descriptions = user.selectSetting.getAllthemSetting(int.Parse(index), user.Machno);

            return(Json(descriptions, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public ActionResult addValues(FormCollection form)
        {
            loggedInUser user = Session["user"] as loggedInUser;

            user.selectSetting.addValues(form, user);
            return(RedirectToAction("Index", user.lastView));
        }
Example #7
0
        //Called when the user changes machine
        public ActionResult changeMachine()
        {
            loggedInUser user = Session["user"] as loggedInUser;

            user.changeMachine(Request["selectedMachine"]);
            return(RedirectToAction("Index", user.lastView));
        }
Example #8
0
        void GetMainPage()
        {
            L10n.SetLocale();

            var netLanguage = DependencyService.Get <ILocale>().GetCurrent();

            AppResources.Culture = new CultureInfo(netLanguage);

            loggedInUser user = new loggedInUser();

            try
            {
                if (App.Database.GetLoginUser(out user))
                {
                    LoginDetails.userId    = user.userId;
                    LoginDetails.mobile    = user.mobile;
                    LoginDetails.sessionId = user.sessionId;

                    App.Current.MainPage.Navigation.PushAsync(new Views.BottomPageView());
                }
                else
                {
                    App.Current.MainPage.Navigation.PushAsync(new Views.LogInPage());
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }
Example #9
0
        public ActionResult MenuPartialView()
        {
            //If user is null, you are not logged in, return empty view.
            if (Session["user"] != null)
            {
                loggedInUser user = Session["user"] as loggedInUser;
                ViewBag.lastView = user.lastView;
                if (user.userlevel == "rst")
                {
                    ViewBag.admin = 1;
                }
                else
                {
                    ViewBag.admin = 0;
                }
                s5Func.update5S(user);
                ViewBag._5sTodo = s5Func.numTodo;

                dds.updateDDS(user.Machno, user.selShift.shiftno);
                ViewBag.DDSTodo = dds.numDDSTodo;

                return(PartialView());
            }
            else
            {
                return(new EmptyResult());
            }
        }
Example #10
0
        public loggedInUser PostDataForLoggedInUser(User user, MyUsersDBEntities db, LoggedInUserDBEntities loggedInUserDb)
        {
            var loggedInUserToReturn = new loggedInUser();

            List <loggedInUser> loggedInUsersList = new List <loggedInUser>();

            loggedInUsersList = loggedInUserDb.loggedInUsers.ToList();

            if (loggedInUsersList.Count <= 0)
            {
                loggedInUserToReturn = new loggedInUser();

                loggedInUserToReturn.loggedInUserId = user.Id;
                loggedInUserToReturn.UserName       = user.Username;
                loggedInUserToReturn.Hash           = DateTime.Now.ToString();
                loggedInUserToReturn.IsLoggedIn     = user.isLoggedIn;
            }
            else
            {
                foreach (var loggedInUser in loggedInUserDb.loggedInUsers)
                {
                    loggedInUser.UserName     = user.Username;
                    loggedInUser.IsLoggedIn   = user.isLoggedIn;
                    loggedInUserToReturn.Hash = DateTime.Now.ToString();
                    loggedInUserToReturn      = loggedInUser;
                }
            }

            loggedInUserDb.Set <loggedInUser>().AddOrUpdate(loggedInUserToReturn);

            loggedInUserDb.SaveChanges();
            return(loggedInUserToReturn);
        }
        protected void gvPosts_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = gvPosts.SelectedRow;

            Session["Post"] = allePosts[row.RowIndex];
            Post selectedPost = (Post)Session["Post"];

            if (Session["loggedInUser"] != null)
            {
                loggedInUser lu = (loggedInUser)Session["loggedInUser"];
                if (selectedPost.getUser().userName.Equals(lu.userName))
                {
                    Session["WayToPost"] = "edit";
                    Response.Redirect("Beitrag.aspx");
                }
                else
                {
                    lblError.Text = "Sie können nicht Beiträge anderer User bearbeiten.";
                    return;
                }
            }


            Session["WayToLogin"] = "******";
            Response.Redirect("Login.aspx");
        }
        public ActionResult Index()
        {
            /* Check so that you are logged in
             * and not trying to reach this the wrong way */

            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                loggedInUser user = Session["user"] as loggedInUser;

                //If there is an Errortext return the ErrorView
                if (user.errorText != "")
                {
                    ViewBag.errorText = user.errorText;
                    user.errorText    = "";
                    return(View("ErrorView"));
                }

                user.lastView = "DDS";
                user.updateShift();
                dds.updateDDS(user.Machno, user.selShift.shiftno);
                if (dds.DDSDone.Count() != 0)
                {
                    ViewData["DDSDone"] = dds.DDSDone;
                }
                return(View(dds.DDSTodo));
            }
        }
        public ActionResult submitDDS()
        {
            loggedInUser user = Session["user"] as loggedInUser;

            dds.submitDDS(Request["hiddenId"], Request["hiddenReadValue"], Request["hiddenComment"]);
            return(RedirectToAction("index", user.lastView));
        }
Example #14
0
        public ActionResult DDSFreq()
        {
            /* Check so that you are logged in
             * and not trying to reach this the wrong way */

            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                loggedInUser user = Session["user"] as loggedInUser;

                //Check so the user is the correct userlevel to access admin
                if (user.userlevel != "rst")
                {
                    return(RedirectToAction("Index", user.lastView));
                }

                //If there is an Errortext return the ErrorView
                if (user.errorText != "")
                {
                    ViewBag.errorText = user.errorText;
                    user.errorText    = "";
                    return(View("ErrorView"));
                }

                user.lastView = "Admin";
                user.updateShift();
                var allActiveMachineSettings = new SettingFrequensFunctions();
                return(View(allActiveMachineSettings.getAllConnections(user.Machno)));
            }
        }
Example #15
0
        public IHttpActionResult PutloggedInUser(int id, loggedInUser loggedInUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != loggedInUser.loggedInUserId)
            {
                return(BadRequest());
            }

            db.Entry(loggedInUser).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!loggedInUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #16
0
        public ActionResult Index()
        {
            /* Check so that you are logged in
             * and not trying to reach this the wrong way */

            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                loggedInUser user = Session["user"] as loggedInUser;

                //Check so the user is the correct userlevel to access admin
                if (user.userlevel != "rst")
                {
                    return(RedirectToAction("Index", user.lastView));
                }

                //If there is an Errortext return the ErrorView
                if (user.errorText != "")
                {
                    ViewBag.errorText = user.errorText;
                    user.errorText    = "";
                    return(View("ErrorView"));
                }

                user.lastView = "Admin";
                user.updateShift();
                user.selectSetting.Machno = user.Machno;
                ViewBag.procFunc          = user.selectSetting.makeDistinctProcFunc();
                return(View(user.selectSetting));
            }
        }
Example #17
0
        public SettingsPage(string pageName)
        {
            InitializeComponent();

            PageName = pageName;

            Title = "Settings";



            //Notification toggle setting

            notificationSwich.IsToggled = false;
            CrossFirebasePushNotification.Current.UnsubscribeAll();


            FirstTimeBindData();



            if (PageName == "LoginPage" || PageName == "SignUpPage" || PageName == "LoginPage")
            {
                LogoutLabel.IsVisible = false;

                notificationLabel.IsVisible = false;

                notificationSwich.IsVisible = false;
            }
            else
            {
                loggedInUser userData = new loggedInUser();

                var settingData = App.Database.GetLoginUser(out userData);


                if (userData.notficationEnabled == "false")
                {
                    notificationSwich.IsToggled = false;
                    CrossFirebasePushNotification.Current.UnsubscribeAll();
                }
                else if (userData.notficationEnabled == null)
                {
                    notificationSwich.IsToggled = false;
                    CrossFirebasePushNotification.Current.UnsubscribeAll();
                }
                else
                {
                    notificationSwich.IsToggled = true;
                    CrossFirebasePushNotification.Current.Subscribe("general");
                }



                LogoutLabel.IsVisible = true;

                notificationLabel.IsVisible = true;

                notificationSwich.IsVisible = true;
            }
        }
Example #18
0
        public IHttpActionResult PostloggedInUser(loggedInUser loggedInUser)
        {
            LoggedInUserService loggedInUserService = new LoggedInUserService();

            loggedInUserService.PostDataForCurrentUserOnLogin(loggedInUser, db, userDb);

            return(CreatedAtRoute("DefaultApi", new { id = loggedInUser.loggedInUserId }, loggedInUser));
        }
        public ActionResult submitPicture()
        {
            loggedInUser user = Session["user"] as loggedInUser;
            var          id   = Request["id"];
            var          uri  = Request["uri"];

            s5Func.saveImage(id, uri, user);
            return(RedirectToAction("Index", user.lastView));
        }
Example #20
0
        public ActionResult addSetting()
        {
            loggedInUser user              = Session["user"] as loggedInUser;
            var          startDate         = DateTime.ParseExact(Request["startDate"], "yyyy-MM-dd", null);
            var          week              = Request["weekpicker"];
            int          indexSelectedDesc = int.Parse(Request["indexSelectedDesc"]);

            user.selectSetting.addSettings(startDate, indexSelectedDesc, user.winuser, user.Machno);
            return(RedirectToAction("Index", user.lastView));
        }
Example #21
0
        //Called when changing shifts
        public ActionResult changeShift()
        {
            //Get the selection and set as selected shift
            int          selectedShift = int.Parse(Request["selectedShiftNo"]);
            loggedInUser user          = Session["user"] as loggedInUser;

            user.selShift = (from d in context.MachineShift where d.shiftno == selectedShift && d.DESCRIPTION == user.maskin select d).First();

            //When shiftchange is complete redirect to last view
            return(RedirectToAction("Index", user.lastView));
        }
Example #22
0
        public IHttpActionResult GetloggedInUser(int id)
        {
            loggedInUser loggedInUser = db.loggedInUsers.Find(id);

            if (loggedInUser == null)
            {
                return(NotFound());
            }

            return(Ok(loggedInUser));
        }
Example #23
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string oldPassword = tbOldPassword.Text;
            string newPassword = tbNewPassword.Text;

            loggedInUser currentUser = (loggedInUser)Session["loggedInUser"];

            if (currentUser.changePassword(oldPassword, newPassword))
            {
                Response.Redirect("Profil.aspx");
            }

            lblErrorLogin.Text = "Das Ändern des Passwortes hat leider nicht funktioniert. \n Bitte überprüfen Sie Ihr altes Passwort!";
        }
Example #24
0
        public IHttpActionResult DeleteloggedInUser(int id)
        {
            loggedInUser loggedInUser = db.loggedInUsers.Find(id);

            if (loggedInUser == null)
            {
                return(NotFound());
            }

            db.loggedInUsers.Remove(loggedInUser);
            db.SaveChanges();

            return(Ok(loggedInUser));
        }
Example #25
0
        public int UpdateLoggedUser(loggedInUser objLoggedUser)
        {
            int status = 0;

            try
            {
                status = database.Update(objLoggedUser);
            }
            catch (Exception ex)
            {
                status = 0;
            }
            return(status);
        }
Example #26
0
        public int SaveLoggedUser(loggedInUser objLoggedUser)
        {
            int status = 0;

            try
            {
                database.DeleteAll <loggedInUser>();
                status = database.Insert(objLoggedUser);
            }
            catch (Exception ex)
            {
                status = 0;
            }
            return(status);
        }
Example #27
0
        public ActionResult addDescription()
        {
            loggedInUser user     = Session["user"] as loggedInUser;
            var          procUnit = Request["hiddUnit"];
            int          index    = procUnit.IndexOf(" ");

            //procUnit request contains XPOS/YPOS so we remove everything behind the first space
            if (index > 0)
            {
                procUnit = procUnit.Substring(0, index);
            }
            var descGB = Request["descGB"];
            var descSV = Request["descSV"];

            user.selectSetting.addDescription(user.Machno, procUnit, descSV, descGB);
            return(RedirectToAction("Index", user.lastView));
        }
Example #28
0
        void GetMainPage()
        {
            L10n.SetLocale();

            var netLanguage = DependencyService.Get <ILocale>().GetCurrent();

            AppResources.Culture = new CultureInfo(netLanguage);

            loggedInUser user = new loggedInUser();

            try
            {
                if (App.Database.GetLoginUser(out user))
                {
                    LoginDetails.userId    = user.userId;
                    LoginDetails.mobile    = user.mobile;
                    LoginDetails.sessionId = user.sessionId;

                    LoginDetails.userType = user.userType;
                    LoginDetails.lifeLine = user.lifeLine;

                    UpdateDeviceId();
                    UpdateProfile();


                    Application.Current.MainPage.Navigation.PushAsync(new Views.BottomPageView());
                }
                else
                {
                    if (Device.RuntimePlatform == Device.iOS)
                    {
                        App.Current.MainPage = new NavigationPage(new LogInPage());
                    }
                    else
                    {
                        Application.Current.MainPage.Navigation.PushAsync(new Views.LogInPage());
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }
Example #29
0
        //First page
        public ActionResult Index()
        {
            //Already logged in, show View
            if (Session["user"] != null)
            {
                loggedInUser user = (Session["user"]) as loggedInUser;
                if (user.errorText != "")
                {
                    ViewBag.errorText = user.errorText;
                    user.errorText    = "";
                    return(View("ErrorView"));
                }
                user.updateShift();
                s5Func.update5S(user);
                user.lastView = "Home";
                ViewBag.tot   = s5Func.numTodo + s5Func.numDone;
                ViewBag.done  = s5Func.numDone;
                return(View(user));
            }

            //Get windows user and check database if that user is allowed to login
            string winuser = System.Environment.UserName;
            var    myUser  = (from u in context.myuser where u.winuser == winuser select u).FirstOrDefault();

            //Setup the user
            if (myUser != null)
            {
                loggedInUser user = new loggedInUser(myUser);
                Session["user"] = user;
                MachinePartialView();
                s5Func.update5S(user);
                if (user.errorText != "")
                {
                    ViewBag.errorText = user.errorText;
                    return(View("ErrorView"));
                }
                ViewBag.tot  = s5Func.numTodo + s5Func.numDone;
                ViewBag.done = s5Func.numDone;
                return(View(user));
            }

            //If you where not authurized to login on that computer, send error View.
            ViewBag.errorText = "You are not authorized to login in and/or the user database is inaccessable";
            return(View("ErrorView"));
        }
Example #30
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string enteredUsername = tbUsername.Text;
            string enteredPassword = tbPassword.Text;

            loggedInUser result = Starter.login(enteredUsername, enteredPassword);

            if (result != null)
            {
                if (result.GetType() == typeof(AdminUser))
                {
                    Session["AdminUser"] = result;
                }
                Session["loggedInUser"] = result;

                if (Session["WayToLogin"].ToString().Equals("plus"))
                {
                    if (Session["Post"] != null)
                    {
                        Post selectedPost = (Post)Session["Post"];

                        loggedInUser lu = result;
                        if (selectedPost.getUser().userName.Equals(lu.userName))
                        {
                            Response.Redirect("Beitrag.aspx");
                        }
                        else
                        {
                            Response.Redirect("index.aspx");
                        }
                    }
                    Response.Redirect("Beitrag.aspx");
                }
                if (Session["WayToLogin"].ToString().Equals("index"))
                {
                    Response.Redirect("index.aspx");
                }
                Session["User"]     = result;
                Session["UserName"] = result.userName;
                Response.Redirect("Profil.aspx");
            }

            lblErrorLogin.Text = "Login hat nicht funktioniert.";
        }