Exemple #1
0
        private void FunctionsSetting()
        {
            FunctionsTabs = new ObservableCollection <TabItem>();

            foreach (Functions functions in TableFunctions.QueryFunctions())
            {
                TabItem fTabItem = new TabItem
                {
                    Header = functions.Function_Title,
                    Uid    = functions.Function_ID.ToString()
                };

                switch (fTabItem.Uid)
                {
                case "1":
                    functionList = new FunctionList(Agencys, Patients, DisplayImageInfo);
                    functionList.ReturnValueCallback += new FunctionList.ReturnValueDelegate(RegistrationSetting);
                    functionList.ReturnRenewCallback += new FunctionList.ReturnRenewDelegate(RenewImageSource);
                    break;

                case "2":
                    functionTemplate = new FunctionTemplate(Agencys, Patients, DisplayImageInfo);
                    functionTemplate.ReturnValueCallback += new FunctionTemplate.ReturnValueDelegate(RenewUsercontrol);
                    break;
                }

                FunctionsTabs.Add(fTabItem);

                if (functions.Function_ID == Agencys.Function_ID)
                {
                    SelectedTabItem = fTabItem;
                }
            }
        }
        private void RunMultilayer()
        {
            PrintHeader();

            string selection = EncryptOrDecrypt();
            string message   = GetMessage(selection);
            string key       = GetKey();
            string altKey    = TableFunctions.AltKeyGen(key);
            string output    = "";

            if (selection == "2")
            {
                PrintHeader();
                output = multilayer.Decipher(message, altKey);
                output = railroad.Decipher(output);
                output = multilayer.Decipher(output, key);
                Console.WriteLine(output);
            }
            else
            {
                PrintHeader();
                output = multilayer.Encipher(message, key);
                output = railroad.Encipher(output);
                output = multilayer.Encipher(output, altKey);
                Console.WriteLine(output);
            }
            RetToCon();
        }
Exemple #3
0
        public JsonResult SetStudentGrade(long studentId, long columnId, byte first, byte second)
        {
            byte   resultCode = 1;
            string resultText = "Ошибка добавления оценки";

            resultCode = new TableFunctions().saveValue(studentId, columnId, first, second, out resultText);

            return(Json(new
            {
                resultCode = resultCode,
                resultText = resultText
            }));
        }
Exemple #4
0
        public JsonResult saveStudent(string fio)
        {
            byte   resultCode = 1;
            string resultText = "Ошибка добавления ученика";


            resultCode = new TableFunctions().saveStudent(fio, out resultText);

            return(Json(new {
                resultCode = resultCode,
                resultText = resultText
            }));
        }
Exemple #5
0
        public JsonResult saveColumn(DateTime date, byte type)
        {
            byte   resultCode = 1;
            string resultText = "Ошибка добавления столбца";

            resultCode = new TableFunctions().saveColumn(date, type, out resultText);


            return(Json(new
            {
                resultCode = resultCode,
                resultText = resultText
            }));
        }
Exemple #6
0
        public bool Decipher(string fullPath, string key)
        {
            bool   fileCreated = false;
            string altKey      = TableFunctions.AltKeyGen(key);

            try
            {
                string fileName      = Path.GetFileName(fullPath);
                string fileNameNoExt = Path.GetFileNameWithoutExtension(fileName);
                string fileExt       = Path.GetExtension(fileName);

                string fileDir    = fullPath.Substring(0, fullPath.Length - fileName.Length);
                string createFile = fileNameNoExt + "MLC" + fileExt;
                string createFull = Path.Combine(fileDir, createFile);

                using (StreamReader sr = new StreamReader(fullPath))
                {
                    while (!sr.EndOfStream)
                    {
                        using (StreamWriter sw = new StreamWriter(createFull, true))
                        {
                            string output = "";
                            output = mlc.Decipher(sr.ReadLine(), altKey);
                            output = rrc.Decipher(output);
                            sw.WriteLine(mlc.Decipher(output, key));
                        }
                    }
                }
                if (Path.IsPathFullyQualified(createFull))
                {
                    fileCreated = true;
                }
                File.Move(createFull, fullPath, true);
            }
            catch (Exception e)
            {
                Console.WriteLine("Invalid input for file path...");
            }
            return(fileCreated);
        }
        private void RunDocument()
        {
            PrintHeader();

            string selection = EncryptOrDecrypt();
            string fullPath  = GetFilePath();
            string key       = GetKey();
            string altKey    = TableFunctions.AltKeyGen(key);

            if (selection == "2")
            {
                PrintHeader();
                bool decipherSuccessful = documentIO.Decipher(fullPath, key);
                if (decipherSuccessful)
                {
                    Console.WriteLine("File decipher successful!");
                }
                else
                {
                    Console.WriteLine("File decipher was not successful, please try again!");
                }
            }
            else
            {
                PrintHeader();
                bool encipherSuccessful = documentIO.Encipher(fullPath, key);
                if (encipherSuccessful)
                {
                    Console.WriteLine("File encipher successful!");
                }
                else
                {
                    Console.WriteLine("File encipher was not successful, please try again!");
                }
            }
            RetToCon();
        }
        public void Add(DbSchemaObject schemaObject)
        {
            switch (schemaObject.SchemaObjectType)
            {
            case ESchemaObjectType.Table:
                Tables.Add((DbTable)schemaObject);
                break;

            case ESchemaObjectType.View:
                Views.Add((DbView)schemaObject);
                break;

            case ESchemaObjectType.StoredProcedure:
                StoredProcs.Add((DbStoredProc)schemaObject);
                break;

            case ESchemaObjectType.ScalarFunction:
                ScalarFunctions.Add((DbScalarFunction)schemaObject);
                break;

            case ESchemaObjectType.TableFunction:
                TableFunctions.Add((DbTableFunction)schemaObject);
                break;

            case ESchemaObjectType.Trigger:
                Triggers.Add((DbTrigger)schemaObject);
                break;

            case ESchemaObjectType.ForeignKey:
                ForeignKeys.Add((DbForeignKey)schemaObject);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #9
0
        public HomeModule()
        {
            if (Context != null)
            {
                this.RequiresAuthentication();
            }


            Get["test2"] = parameters =>
            {
                try
                {
                    this.RequiresClaims(new[] { "Admin" });

                    string s = "a";


                    return(s);
                }
                catch (Exception e)
                {
                    return(e.Message);
                }
            };

            Get["/"] = parameters =>
            {
                //var currentUser = "******";
                //try
                //{
                // currentUser = Context.CurrentUser.UserName;

                //}
                //catch(Exception e)
                //{

                //}
                var currentUser = Context.CurrentUser != null ? Context.CurrentUser.UserName : string.Empty;
                var guid        = UserFunctions.getGuidByName(currentUser);
                if (guid != null)
                {
                    Objects.User u = new Objects.User();
                    u.userUrlList = TableFunctions.getUserList("all", guid);
                    return(View["Index", u]);
                }
                else
                {
                    return("error");
                }
            };

            #region table index

            Get["/table/{date}"] = parameters =>
            {
                var currentUser = Context.CurrentUser.UserName;
                var guid        = UserFunctions.getGuidByName(currentUser);
                if (guid != null)
                {
                    UserUrlList list = TableFunctions.getUserList(parameters.date, guid);
                    return(View["_TableUrl", list]);
                }
                else
                {
                    return("error");
                }
            };


            Get["/tableDetails/{urlObjectId}"] = parameters =>
            {
                int       urlObjId = parameters.urlObjectId;
                UrlObject urlObj   = TableFunctions.getUrlTableDetails(urlObjId);

                if (urlObj != null)
                {
                    return(View["_ShortedUrlInfo", urlObj]);
                }
                else
                {
                    return("error");
                }
            };

            #endregion

            #region user

            #region logIN
            Get["/login"] = parameter =>
            {
                dynamic model = new ExpandoObject();
                model.Errored = Request.Query.error.HasValue;
                return(View["logIn", model]);
            };

            Post["/login"] = parameter =>
            {
                string name     = Request.Form["userName"];
                string pass     = Request.Form["userPass"];
                string remember = Request.Form["rememberMe"];

                Objects.User user = UserFunctions.logInUser(name, pass);

                if (user != null)
                {
                    DateTime?expiry = null;
                    if (!string.IsNullOrEmpty(remember))
                    {
                        expiry = DateTime.Now.AddDays(7);
                    }

                    return(this.LoginAndRedirect(user.id, expiry));
                }
                else
                {
                    return(Context.GetRedirect("~/login?error=true&username="******"/logout"] = parameter =>
            {
                return(this.LoginAndRedirect(UserFunctions.getDummyCurrentUser().guid));
            };

            #endregion

            #region register

            Get["/register"] = parameter =>
            {
                dynamic model = new ExpandoObject();
                model.Errored = Request.Query.error.HasValue;
                return(View["register", model]);
            };

            Post["/register"] = parameter =>
            {
                string name     = Request.Form["userName"];
                string pass     = Request.Form["userPass"];
                string pass2    = Request.Form["userPass"];
                string remember = Request.Form["rememberMe"];

                Objects.User user = UserFunctions.registerUser(name, pass, pass2);

                if (user != null)
                {
                    DateTime?expiry = null;
                    if (!string.IsNullOrEmpty(remember))
                    {
                        expiry = DateTime.Now.AddDays(7);
                    }

                    return(this.LoginAndRedirect(user.id, expiry));
                }
                else
                {
                    return(Context.GetRedirect("~/register?error=true&username="******"profile"] = parameters =>
            {
                var currentUser = Context.CurrentUser.UserName;
                var guid        = UserFunctions.getGuidByName(currentUser);
                if (guid != null)
                {
                    Objects.User u = UserFunctions.getFullUserByGuid(guid);
                    u.userUrlList = TableFunctions.getUserList("all", guid);
                    return(View["profile", u]);
                }
                else
                {
                    return("error");
                }
            };

            Post["/profile"] = parameter =>
            {
                Objects.User user        = this.Bind();
                var          changePass  = Request.Form["changePass"];
                var          currentUser = Context.CurrentUser.UserName;
                var          guid        = UserFunctions.getGuidByName(currentUser);
                user.id   = guid;
                user.name = currentUser;

                if (changePass == "1")
                {
                    if (!string.IsNullOrEmpty(user.newPass1) && user.newPass1 == user.newPass2)
                    {
                        if (UserFunctions.verifyOldPass(user))
                        {
                            if (UserFunctions.updateProfile(user, true) > 0)
                            {
                                return(View["profile", user]);
                            }
                            else
                            {
                                user.error = "Error Ocurred while updating profile";
                                return(View["profile", user]);
                            }
                        }
                        else
                        {
                            user.error = "Old password was incorrect";
                            return(View["profile", user]);
                        }
                    }
                    else
                    {
                        user.error = "Password does not match";
                        return(View["profile", user]);
                    }
                }
                else
                {
                    if (UserFunctions.updateProfile(user, false) > 0)
                    {
                        return(View["profile", user]);
                    }
                    else
                    {
                        user.error = "Error Ocurred while updating profile";
                        return(View["profile", user]);
                    }
                }
            };

            #endregion
            #endregion

            #region short
            Get["/goTo/{toShort}"] = parameters =>
            {
                string    toShort   = parameters.toShort;
                UrlObject urlObject = ShortFunctions.getUrlObjectIdByShorted(toShort);

                if (urlObject != null && urlObject.status.ToString() == "200")
                {
                    if (ShortFunctions.insertNewClick(urlObject.idShortedUrl) > 0)
                    {
                        return(Response.AsRedirect(urlObject.longUrl));
                    }
                    return(View["error", new errorObj {
                                    errorMsg = "No se ha podido acceder a la url " + urlObject.shortedUrl + "error desconocdio"
                                }]);
                }
                else
                {
                    return(View["error", new errorObj {
                                    errorMsg = "Url Caida desde " + urlObject.lastStatusCHanged
                                }]);
                }
            };


            Post["/addUrl"] = parameters =>
            {
                string urlToAdd    = Request.Form["urlToShort"];
                var    currentUser = Context.CurrentUser.UserName;
                if (!string.IsNullOrEmpty(currentUser))
                {
                    var        guid   = UserFunctions.getGuidByName(currentUser);
                    ShortedUrl newUrl = ShortFunctions.urlAlreadyShorted(urlToAdd, guid);
                    if (newUrl == null)
                    {
                        int result = ShortFunctions.addNewUrl(urlToAdd, guid);
                        if (result != 0)
                        {
                            return(Response.AsRedirect("/"));
                        }
                        else
                        {
                            return(View["error", new errorObj {
                                            errorMsg = "No se ha podido crear la url " + urlToAdd
                                        }]);
                        }
                    }

                    return(Response.AsRedirect("/tableDetails/" + newUrl.idShortedUrl));
                }
                return("error");
            };
            #endregion

            #region csv

            Get["/csv"] = parameters =>
            {
                return(View["csv", null]);
            };

            Post["/csv"] = parameters =>
            {
                string   urlsToAdd   = Request.Form["urlList"];
                string[] urlsArr     = urlsToAdd.Split(',');
                var      currentUser = Context.CurrentUser.UserName;
                var      guid        = UserFunctions.getGuidByName(currentUser);
                if (guid != null)
                {
                    csvResponse result = ShortFunctions.addArrUrls(urlsArr, guid);
                    return(View["csv", result]);
                }

                return(0);
            };

            #endregion


            Get["/details/{url}"] = parameters =>
            {
                return(View["register"]);
            };
        }