예제 #1
0
        static Task BroadcastTimeJob(WebSocketServer ws)
        {
            var contacts = DB_Functions.GetUsers();

            var job = Task.Run(() =>
            {
                while (true)
                {
                    List <ContactItemModel> users = new List <ContactItemModel>();
                    foreach (var item in contacts)
                    {
                        users.Add(new ContactItemModel()
                        {
                            ContactNickname = item.ContactNickname, IsOnline = SocketConnectionHandler.idList.Any(w => w.Key == item.ContactNickname), ApplicationUserId = item.Id
                        });
                    }
                    SocketConnectionHandler.GroupList = DB_Functions.GetGroups();

                    BroadcastContactStatuses(ws, users);

                    Thread.Sleep(TimeSpan.FromSeconds(2));
                }
            });

            return(job);
        }
예제 #2
0
        public override void Process(
            HttpListenerRequest request,
            HttpListenerResponse response)
        {
            var ms = new MemoryStream();

            request.InputStream.CopyTo(ms);

            var bodyAsBytes = ms.ToArray();

            var bodyParsed = JsonConvert.DeserializeObject <Local_Group>(
                Encoding.UTF8.GetString(bodyAsBytes));

            //response.OutputStream.Write(DB_Functions.Find_User(bodyParsed.ContactNickname, bodyParsed.Password).ToByteArray(ByteOrder.Big), 0, DB_Functions.Find_User(bodyParsed.ContactNickname, bodyParsed.Password).ToByteArray(ByteOrder.Big).Length);



            var responseMessage = new { Id = DB_Functions.Create_Group(bodyParsed.Users, bodyParsed.Title, bodyParsed.GroupType) };



            var responseBytes = Encoding.UTF8.GetBytes(
                JsonConvert.SerializeObject(responseMessage));

            response.StatusCode = 200;

            response.OutputStream.Write(responseBytes, 0, responseBytes.Length);


            response.Close();
        }
예제 #3
0
        public ActionResult ReceivedFrd(string Id, string error = null)
        {
            ViewBag.message = error;
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }

            Frd File = DB_Functions.CheckReceived(ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(Id)));

            if (File == null)
            {
                //Error page
                return(RedirectToAction("Received"));
            }
            Frd viewModel = ActiveFrdProcessor.Process(File);

            //viewModel.Type = Frd.TypesEnum.ReceivedManager;



            if (viewModel.Type == Frd.TypesEnum.ReceivedManagerPending || viewModel.Type == Frd.TypesEnum.ReceivedManagerActive)
            {
                ViewBag.helpMessage = "This FRD is waiting for your approval. \n" +
                                      "You can approve or reject this FRD.";

                return(View("View_NoEdit", viewModel));//Manager Approval
            }
            viewModel.Upload_Token = DB_Functions.NewUploadToken(DB_Functions.UploadTokenType.Received);
            ViewBag.helpMessage    = "This FRD is sent to you by the owner and is waiting for your feedback. \n" +
                                     "You can submit your feedback in the form of an approval, rejection, or by commenting and adding files and then submitting updates";
            return(View(viewModel));
        }
        public FileStreamResult TestDownload(string frdID, string FID)
        {
            Attatchment file = DB_Functions.GetFile(frdID, FID);

            if (file == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }


            //HttpResponseMessage gg = new HttpResponseMessage();
            string File_Name = "/" + file.Id + file.Owner.Replace("application/", ".");

            try
            {
                stream = new FileStream(Server.MapPath("~/Files") + File_Name, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            FileStreamResult fileStream = new FileStreamResult(stream, file.Owner);

            fileStream.FileDownloadName = file.Name;
            return(fileStream);
        }
예제 #5
0
        private List <string> LoadLinks(string floorString)
        {
            List <string> result = new List <string>();

            //this.result += "begin LoadLinks ";
            log.Debug("begin LoadLinks");

            string link = string.Empty;

            if (floorString != null)
            {
                string    getFloors = "Select SecAlph,Floor from SectionFloorNames where IDSecFl=" + floorString;
                DataTable dt        = DB_Functions.GetData(getFloors);
                if (dt.Rows.Count > 0)
                {
                    link = "корпус " + dt.Rows[0][0] + " ет." + dt.Rows[0][1] + "; ";
                    link = "корпус " + dt.Rows[0][0] + " ет." + dt.Rows[0][1] + "; ";

                    result.Add(link);
                }
            }
            this.result += "end LoadLinks ";
            log.Debug("end LoadLinks");

            return(result);
        }
예제 #6
0
        public ActionResult ViewFrd(string Id, int V)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            Frd File = DB_Functions.CheckForFrd(ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(Id)));

            if (File == null)
            {
                //Error page
                return(new HttpNotFoundResult());
            }
            if (V != 0)
            {
                File.LatestVersion        = V;
                File.Panel0.LatestVersion = V;
            }


            Frd s = ActiveFrdProcessor.Process(File, V);

            s.Type = Frd.TypesEnum.Closed;
            ViewBag.helpMessage = "This FRD can not be edited and can only be viewed from the archive of versions. \n";

            return(View("View_NoEdit", s));
        }
 public List <SmsCode> GetCodes(string sender)
 {
     if (Functions.NoSession())
     {
         return(new List <SmsCode>());
     }
     return(DB_Functions.DefaultSmsCodes(sender));
 }
예제 #8
0
 public bool GetFrdId(string id)
 {
     if (Functions.NoSession())
     {
         return(false);
     }
     return(DB_Functions.CheckFrdId(id));
 }
예제 #9
0
        private RouteModel GetRoute(string floor, string fromRoom, string toRoom, string searchID)
        {
            this.result += "begin GetRoute ";

            log.Debug("begin GetRoute");

            RouteModel result = new RouteModel();

            string    getFloors = "Select SecAlph,Floor from SectionFloorNames where IDSecFl=" + floor;
            DataTable dt1       = DB_Functions.GetData(getFloors);

            if (dt1.Rows.Count > 0)
            {
                result.FloorSection = dt1.Rows[0][0].ToString();
                result.Floor        = Convert.ToInt32(dt1.Rows[0][1]);
            }


            string sel = "Select Pic,SecPic,Rotation,MarkerPath from SecFlPics where IDSecFl=" + floor;

            result.FloorSectionID = floor;
            result.RoomFromID     = int.Parse(fromRoom);
            result.RoomToID       = int.Parse(toRoom);

            DataTable dt = DB_Functions.GetData(sel);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0][2].ToString().Equals("1") || dt.Rows[0][2].ToString().Equals("2"))
                {
                    result.PictureFileName = dt.Rows[0][0].ToString().Replace("/", "/r");
                    //Session["pic"] = dt.Rows[0][0].ToString().Replace("/", "/r");
                }
                else
                {
                    result.PictureFileName = dt.Rows[0][0].ToString();
                    //Session["pic"] = dt.Rows[0][0].ToString();
                }

                //result.SecPic = dt.Rows[0][1].ToString();
                //Session["secpic"] = dt.Rows[0][1].ToString();
                result.Rotation = dt.Rows[0][2].ToString();
                //Session["rotation"] = dt.Rows[0][2].ToString();
                result.ArrCoords = dt.Rows[0][3].ToString();
                //Session["arrcoords"] = dt.Rows[0][3].ToString();


                List <Point> pathCoords = Calculate(fromRoom, toRoom, floor, searchID);
                result.PathPoints = pathCoords;
            }

            this.result += "end GetRoute ";
            log.Debug("end GetRoute");

            return(result);
        }
예제 #10
0
        public ActionResult ActiveFrd(Frd submittedForm)
        {
            SuccessData viewModel;

            switch (submittedForm.SubmitType)
            {
            case Frd.ButtonsEnum.Submit:
                if (DB_Functions.SubmitOwnerUpdate(submittedForm))
                {
                    viewModel = new SuccessData()
                    {
                        Heading            = "FRD updates have been submitted successfully",
                        PrimaryParagraph   = "Your active FRD has been updated successfully!",
                        SecondaryParagraph = "The selected employees have now received your updated version",
                        LastParagraph      = "The updated FRD can be found in the 'Active Requests' page.",
                        ButtonText         = "GO TO ACTIVE REQUESTS",
                        ButtonLink         = "Request/Active"
                    };
                    ViewBag.helpMessage = "No Information. \n";

                    return(View("Success", viewModel));
                }
                else
                {
                    return(RedirectToAction("ActiveFrd", new { id = submittedForm.Panel0.Hashed_Id, error = "Changes have to be made in order to submit an updated version of the FRD" }));
                }

            case Frd.ButtonsEnum.Reject:
                if (DB_Functions.OwnerClose(submittedForm.Panel0.Id))
                {
                    viewModel = new SuccessData()
                    {
                        Heading            = "FRD has been closed successfully",
                        PrimaryParagraph   = "Your active FRD has been closed successfully!",
                        SecondaryParagraph = "",
                        LastParagraph      = "The closed FRD can be found in the 'Closed Requests' page.",
                        ButtonText         = "GO TO Closed REQUESTS",
                        ButtonLink         = "Request/Closed"
                    };
                    ViewBag.helpMessage = "No Information. \n";

                    return(View("Success", viewModel));
                }
                else
                {
                }


                break;
            }

            ViewBag.helpMessage = "This FRD has been approved by your manager and is now awaiting the recepients' feedback and approval/rejection. \n" +
                                  "FRDs that you have created and are still awaiting approval can be found in the 'pending requests' page.";

            return(View());
        }
예제 #11
0
        public override void Process(
            HttpListenerRequest request,
            HttpListenerResponse response)
        {
            var ms = new MemoryStream();

            request.InputStream.CopyTo(ms);

            var bodyAsBytes = ms.ToArray();

            var bodyParsed = JsonConvert.DeserializeObject <User>(
                Encoding.UTF8.GetString(bodyAsBytes));

            if (DB_Functions.Find_User(bodyParsed.ContactNickname, bodyParsed.Password))
            {
                //response.OutputStream.Write(DB_Functions.Find_User(bodyParsed.ContactNickname, bodyParsed.Password).ToByteArray(ByteOrder.Big), 0, DB_Functions.Find_User(bodyParsed.ContactNickname, bodyParsed.Password).ToByteArray(ByteOrder.Big).Length);



                Repository.ApplicationAccounts.Add(new ApplicationAccount()
                {
                    Email    = bodyParsed.ContactNickname,
                    Password = bodyParsed.Password
                });
                var cookie = Guid.NewGuid().ToString("N");
                Repository.ActiveSessions[cookie] = new ApplicationAccount()
                {
                    Email    = bodyParsed.ContactNickname,
                    Password = bodyParsed.Password
                };


                webSocket.Connect();
                webSocket.Send(JsonConvert.SerializeObject(new MessageContainer <KeyValuePair <string, string> >()
                {
                    MessageType = MessageTypes.FromHttpToWeb, Body = new KeyValuePair <string, string>(bodyParsed.ContactNickname, cookie)
                }));


                var responseMessage = new
                {
                    Cookie = cookie
                };


                var responseBytes = Encoding.UTF8.GetBytes(
                    JsonConvert.SerializeObject(responseMessage));
                response.StatusCode = 200;

                response.OutputStream.Write(responseBytes, 0, responseBytes.Length);


                response.Close();
            }
        }
예제 #12
0
        public Content GetContent(string sender, string code)
        {
            if (Functions.NoSession())
            {
                return(new Content());
            }
            //get from database the list of codes based on the selected sender using its id and assign them to codesList
            return(DB_Functions.DefaultSmsContent(sender, code));

            //send back to react the list of codes
        }
예제 #13
0
        public static void Process_Panel2_3(ref Frd file)
        {
            string FRD_ID = file.Panel0.Id;

            file.Panel2 = new Panels.Panel_2 {
                Targets = DB_Functions.ReadTargetsOnly(FRD_ID, file.LatestVersion)
            };

            file.Panel3 = new Panels.Panel_3 {
                Channels = DB_Functions.ReadChannelsOnly(FRD_ID, file.LatestVersion)
            };
        }
예제 #14
0
        public ActionResult SearchedFrd(string FrdId, int Version = 0)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            Frd frd = DB_Functions.CheckForFrd(FrdId);

            if (frd == null)
            {
                return(new HttpNotFoundResult());
            }

            if (Version == 0 || frd.LatestVersion == Version)
            {
                switch (frd.Type)
                {
                case Frd.TypesEnum.Active:
                    return(RedirectToAction("ActiveFrd", "Request", new { Id = G_Functions.GetHash(FrdId) }));

                case Frd.TypesEnum.Closed:
                    return(RedirectToAction("ClosedFrd", "Request", new { Id = G_Functions.GetHash(FrdId) }));

                    break;

                case Frd.TypesEnum.Pending:
                    return(RedirectToAction("PendingFrd", "Request", new { Id = G_Functions.GetHash(FrdId) }));

                    break;

                case Frd.TypesEnum.ReceivedManagerActive:


                case Frd.TypesEnum.ReceivedManagerPending:


                case Frd.TypesEnum.ReceivedUser:
                    return(RedirectToAction("ReceivedFrd", "Request", new { Id = G_Functions.GetHash(FrdId) }));


                    break;
                }
            }
            else
            {
                return(RedirectToAction("ViewFrd", "Request", new { Id = G_Functions.GetHash(FrdId), V = Version }));
            }
            return(new HttpNotFoundResult());
        }
        public ActionResult Check(string noti_id)
        {
            if (Models.Session.Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            Notification N = DB_Functions.GetNotiInfo(noti_id);

            if (N == null)
            {
                return(new HttpNotFoundResult());
            }

            DB_Functions.NotiSeen(noti_id);
            Frd frd = DB_Functions.CheckForFrd(N.FrdId);

            if (frd == null)
            {
                return(new HttpNotFoundResult());
            }


            if (frd.LatestVersion == N.Version)
            {
                switch (frd.Type)
                {
                case Frd.TypesEnum.Active:
                    return(RedirectToAction("ActiveFrd", "Request", new { Id = G_Functions.GetHash(N.FrdId) }));

                case Frd.TypesEnum.Closed:
                    return(RedirectToAction("ClosedFrd", "Request", new { Id = G_Functions.GetHash(N.FrdId) }));

                case Frd.TypesEnum.Pending:
                    return(RedirectToAction("PendingFrd", "Request", new { Id = G_Functions.GetHash(N.FrdId) }));

                case Frd.TypesEnum.ReceivedManagerActive:
                case Frd.TypesEnum.ReceivedManagerPending:
                case Frd.TypesEnum.ReceivedUser:
                    return(RedirectToAction("ReceivedFrd", "Request", new { Id = G_Functions.GetHash(N.FrdId) }));
                }
            }
            else
            {
                return(RedirectToAction("ViewFrd", "Request", new { Id = G_Functions.GetHash(N.FrdId), V = N.Version }));
            }

            return(View());
        }
예제 #16
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                using (DB_Model db = new DB_Model())
                {
                    DB_Functions.Add_User(collection["Password"], collection["ContactNickname"]);
                }

                return(RedirectToAction("Success"));
            }
            catch
            {
                return(View());
            }
        }
예제 #17
0
        public ActionResult Search(string input)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            SearchResult viewModel = new SearchResult
            {
                Searched = input,
                List     = DB_Functions.Search(input)
            };

            ViewBag.helpMessage = "Results of your search are displayed as a list of items. \n" +
                                  "inside each result item will be the relevant versions which match the search keyword";

            return(View(viewModel));
        }
예제 #18
0
        public ActionResult New(Frd submittedFrd)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            switch (submittedFrd.SubmitType)
            {
            case Frd.ButtonsEnum.Reset:    //reset
                DB_Functions.DeleteSavedDraft();
                return(RedirectToAction("New", new { message = "The FRD data has been reset successfully!" }));

            case Frd.ButtonsEnum.Submit:    //submit
                if (DB_Functions.SubmitNewFrd(submittedFrd))
                {
                    SuccessData viewModel = new SuccessData()
                    {
                        Heading            = "FRD has been submitted successfully",
                        PrimaryParagraph   = "Your FRD has been submitted successfully!",
                        SecondaryParagraph = "Please wait for your manager's approval.",
                        LastParagraph      = "The submitted FRD can be found in the 'Pending Requests' page.",
                        ButtonText         = "GO TO PENDING REQUESTS",
                        ButtonLink         = "Request/Pending"
                    };
                    return(View("Success", viewModel));
                }
                else
                {
                    submittedFrd.Type = Frd.TypesEnum.Saved;
                    return(RedirectToAction("New", SavedFrdHandling.ProcessInfo(submittedFrd)));
                }

            case Frd.ButtonsEnum.Save:    //save
                DB_Functions.SaveToDraft(G_Functions.ToByteArray(submittedFrd));
                return(RedirectToAction("New", new { message = "The FRD data has been saved successfully!" }));
            }



            var a = FRD_Submit.Save(submittedFrd);

            return(RedirectToAction("New"));
        }
예제 #19
0
        public ActionResult ClosedFrd(string Id)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }

            Frd File = DB_Functions.CheckClosed(ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(Id)));

            if (File == null)
            {
                //Error page
                return(RedirectToAction("Closed"));
            }
            Frd s = ActiveFrdProcessor.Process(File);

            ViewBag.helpMessage = "This FRD can not be edited and can only be viewed from the archive of versions. \n";
            return(View("View_NoEdit", s));
        }
예제 #20
0
        public ActionResult Active(string UserID = null)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }

            if (UserID != null && !DB_Functions.CheckUserManager(UserID))
            {
                return(new HttpNotFoundResult());
            }
            var a = DB_Functions.ActiveList(UserID);

            ViewBag.helpMessage = "This page contains a list of the FRDs that have been created by you and then approved. \n" +
                                  "FRDs created by you and not approved yet can be found in the 'Pending Requests' page.\n";


            FrdsList viewModel = new FrdsList()
            {
                List      = a,
                PageTitle = "Active Requets"
            };

            if (viewModel.List.Count > 0)
            {
                return(View(viewModel));
            }
            else
            {
                NoFRD viewModel1 = new NoFRD()
                {
                    Heading            = "You currently have no active FRDS available",
                    PrimaryParagraph   = "To create and submit a new FRD, go to 'New Request' page",
                    SecondaryParagraph = "",
                    LastParagraph      = "",
                    ButtonText         = "GO TO NEW REQUEST",
                    ButtonLink         = "Request/New",
                    Page = NoFRD.menuitem.Active
                };

                return(View("noFRD", viewModel1));
            }
        }
        public async Task <JsonResult> Upload(string Token)
        {
            if (Functions.NoSession())
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json("Upload failed"));
            }
            if (!DB_Functions.CheckToken(Token))
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json("Upload failed"));
            }
            string User_ID = Functions.GetID();

            try
            {
                foreach (string x in Request.Files)
                {
                    var thefile = Request.Files[x];
                    if (thefile != null && thefile.ContentLength > 0)
                    {
                        string FileId = Guid.NewGuid().ToString();
                        // get a stream
                        string extension = Path.GetExtension(thefile.FileName);
                        var    stream    = thefile.InputStream;
                        var    fileName  = FileId + extension;
                        var    path      = Path.Combine(Server.MapPath("~/Files"), fileName);
                        using (var fileStream = new FileStream(path, FileMode.Create))
                        {
                            stream.CopyTo(fileStream);
                        }
                        DB_Functions.InsertTempFile(FileId, "application/" + extension.Replace(".", ""), Token, thefile.FileName, (new FileInfo(path)).Length);
                    }
                }

                //here send to db
                return(Json("File uploaded successfully"));
            }catch (Exception e)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json("Upload failed"));
            }
        }
예제 #22
0
        public ActionResult ManagerDashBoard()
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            if (!Functions.IsManager())
            {
                return(new HttpNotFoundResult());
            }

            var       data      = DB_Functions.GetManagerData();
            DashBoard viewModel = new DashBoard
            {
                List = data
            };

            ViewBag.helpMessage = "This page contains a list of the employees that you manage. \n" +
                                  "Under each employee, number of the various FRDs lists of that employee are shown";

            return(View(viewModel));
        }
        // GET: NotificationPage

        public ActionResult NotificationPage(string op = "all", string frd = null)
        {
            if (Models.Session.Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }

            NotificationPage viewModel = new NotificationPage();

            switch (op)
            {
            case "all":
                viewModel.Notifications = DB_Functions.ReadNotifications(Functions.GetID());
                break;

            case "R":
                viewModel.Notifications = DB_Functions.ReadNotifications(Functions.GetID(), DB_Functions.NotificationsType.Received);
                break;

            case "C":
                viewModel.Notifications = DB_Functions.ReadNotifications(Functions.GetID(), DB_Functions.NotificationsType.Closed);
                break;

            case "P":
                viewModel.Notifications = DB_Functions.ReadNotifications(Functions.GetID(), DB_Functions.NotificationsType.Pending);
                break;

            case "A":
                viewModel.Notifications = DB_Functions.ReadNotifications(Functions.GetID(), DB_Functions.NotificationsType.Active);
                break;

            case "FRD":
                viewModel.Notifications = DB_Functions.ReadNotifications(Functions.GetID(), DB_Functions.NotificationsType.FRD, G_Functions.GetIdFromHash(frd));
                break;
            }


            return(View("NotificationPage", viewModel));
        }
예제 #24
0
        public ActionResult ReceivedM()
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            if (!Functions.IsManager())
            {
                return(new HttpNotFoundResult());
            }

            FrdsList viewModel = new FrdsList {
                List = DB_Functions.ReceivedListAsManager()
            };

            ViewBag.helpMessage = "This page contains a list of the FRDs that you have received from other users. \n" +
                                  "The FRDs listed here are the ones you received because you are the manager of employees who submitted and FRD. \n" +
                                  "These FRDs are awaiting your approval or rejection in order to continue their process to the next phase";


            if (viewModel.List.Count > 0)
            {
                return(View(viewModel));
            }
            else
            {
                NoFRD viewModel1 = new NoFRD()
                {
                    Heading            = "There are currently no received FRDS available",
                    PrimaryParagraph   = "Received FRDs are listed here if you are a manager of an employee who submitted an FRD",
                    SecondaryParagraph = "",
                    LastParagraph      = "",
                    ButtonText         = "GO TO HOME PAGE",
                    ButtonLink         = "Home/Index",
                    Page = NoFRD.menuitem.ReceivedM
                };
                return(View("noFRD", viewModel1));
            }
        }
예제 #25
0
        public ActionResult PendingFrd(string Id)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }

            Frd File = DB_Functions.CheckPending(ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(Id)));

            if (File == null)
            {
                //Error page
                return(RedirectToAction("Active"));
            }
            Frd viewModel = ActiveFrdProcessor.Process(File);

            ViewBag.helpMessage = "This FRD you submitted is still awaiting approval by your manager. \n" +
                                  "Once approved, you will receive a notification and the FRD will be moved to the 'Active FRDs' page.";


            return(View("View_NoEdit", viewModel));
        }
예제 #26
0
        public ActionResult Login(Credentials input)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Session.Clear();
                }
                catch (System.Exception)
                {
                }
                Login R = DB_Functions.LogIn(input.Email, input.Pass);

                var identity = new ClaimsIdentity(new[] {
                    new Claim(ClaimTypes.Name, input.Email),
                },
                                                  DefaultAuthenticationTypes.ApplicationCookie,
                                                  ClaimTypes.Name, ClaimTypes.Role);

                // if you want roles, just add as many as you want here (for loop maybe?)
                identity.AddClaim(new Claim(ClaimTypes.Role, "guest"));
                // tell OWIN the identity provider, optional
                // identity.AddClaim(new Claim(IdentityProvider, "Simplest Auth"));

                Authentication.SignIn(new AuthenticationProperties
                {
                    IsPersistent = true
                                   // input.RememberMe
                }, identity);

                if (Functions.NoSession())
                {
                    return(RedirectToAction("Login", "Authentication", new { error = "E-mail address or password incorrect" }));
                }

                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Login", "Authentication", new { error = "Error" }));
        }
예제 #27
0
        public ActionResult ReceivedU(string UserID = null)
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            if (UserID != null && !DB_Functions.CheckUserManager(UserID))
            {
                return(new HttpNotFoundResult());
            }
            FrdsList viewModel = new FrdsList
            {
                List = DB_Functions.ReceivedListAsUser(UserID)
            };


            ViewBag.helpMessage = "This page contains a list of the FRDs that you have received from other users. \n" +
                                  "The FRDs listed here are the ones you received because you were selected as a recepient of the FRD during its creation.";

            if (viewModel.List.Count > 0)
            {
                return(View(viewModel));
            }
            else
            {
                NoFRD viewModel1 = new NoFRD()
                {
                    Heading            = "There are currently no received FRDS available",
                    PrimaryParagraph   = "Received FRDs are listed here if you were selected as a recepient of the FRD during its creation by an employee",
                    SecondaryParagraph = "",
                    LastParagraph      = "",
                    ButtonText         = "GO TO HOME PAGE",
                    ButtonLink         = "Home/Index",
                    Page = NoFRD.menuitem.ReceivedU
                };
                return(View("noFRD", viewModel1));
            }
        }
예제 #28
0
        public ActionResult Pending()
        {
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            var a = DB_Functions.PendingList();

            ViewBag.helpMessage = "This page contains a list of the FRDs that have been created by you and have not been approved yet. \n" +
                                  "FRDs created by you and that have been approved can be found in the 'Active Requests' page.\n";


            FrdsList viewModel = new FrdsList()
            {
                List = a
            };

            if (viewModel.List.Count > 0)
            {
                return(View(viewModel));
            }
            else
            {
                NoFRD viewModel1 = new NoFRD()
                {
                    Heading            = "There are currently no pending FRDS available",
                    PrimaryParagraph   = "FRDs appear as pending if you submitted an FRD and you are waiting for a manager's approval",
                    SecondaryParagraph = "To create and submit a new FRD, go to 'New Request' page",
                    LastParagraph      = "",
                    ButtonText         = "GO TO NEW REQUEST",
                    ButtonLink         = "Request/New",
                    Page = NoFRD.menuitem.Pending
                };
                return(View("noFRD", viewModel1));
            }
        }
예제 #29
0
        public ActionResult ActiveFrd(string Id, string error = null)
        {
            ViewBag.message = error;
            if (Functions.NoSession())
            {
                return(RedirectToAction("Login", "Authentication"));
            }

            Frd File = DB_Functions.CheckActive(ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(Id)));

            if (File == null)
            {
                //Error page
                return(RedirectToAction("Active"));
            }
            Frd viewModel = ActiveFrdProcessor.Process(File);

            ViewBag.helpMessage = "This FRD has been approved by your manager and is now awaiting the recepients' feedback and approval/rejection. \n" +
                                  "FRDs that you have created and are still awaiting approval can be found in the 'pending requests' page.";


            viewModel.Upload_Token = DB_Functions.NewUploadToken(DB_Functions.UploadTokenType.Active);
            return(View(viewModel));
        }
 public void DeleteFile(string U_Token, string FileName)
 {
     DB_Functions.DeleteTempFile(U_Token, FileName);
 }