コード例 #1
0
        public ActionResult List(int pageNum = 0)
        {
            if (Request.IsAuthenticated)
            {
                CUser  clUser = new CUser(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());
                STUser stUser;
                string msg;
                clUser.GetRecordByUserId(LocalData.UserId(), out stUser, out msg);
                if (!stUser.oldpass)
                {
                    STTransactVP param;
                    if (Session["TRANSACTPARAM"] != null)
                    {
                        param = (STTransactVP)Session["TRANSACTPARAM"];
                    }
                    else
                    {
                        param = new STTransactVP();
                    }

                    if (!SharedModel.IsConnect(LocalData.CSDbTransacts1(), out msg) &&
                        !SharedModel.IsConnect(LocalData.CSDbTransacts2(), out msg))
                    {
                        ViewData["ERROR"] = "No connection to DB";
                        ViewData["MSG"]   = msg;

                        //return RedirectToAction("Index", "Error");
                        return(View("Index"));
                    }
                    else
                    {
                        string[] arr = new[] { "'", "\"", "--" };
                        if (CheckerField.CheckField(arr, param.maskedpan, param.maskedpos))
                        {
                            ViewData["MSG"] = "One or more fields contain invalid characters.";
                            return(View("Errors"));
                        }
                        else
                        {
                            List <TransactModels> lst = TransactModelsRepository.Instance.GetListTransact(param);
                            ViewData["PageNum"]    = pageNum;
                            ViewData["ItemsCount"] = lst.Count;
                            ViewData["PageSize"]   = pageSize;
                            ViewData["STRPARAM"]   = param.strdata;

                            return(View(TransactModelsRepository.Instance.GetListTransact(pageSize, pageNum, param)));
                        }
                    }
                }
                else
                {
                    return(RedirectToAction("ChangePassword", "Account"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     _bfs = new Bfs();
     _bfs.Run();
     StartField = _bfs.StartField;
     CheckerGrid.DataContext = StartField;
     FinalField = _bfs.FinalField;
 }
コード例 #3
0
ファイル: UserModels.cs プロジェクト: Pavlo7/AEVIProject
        public int UpdateUser(UserModels model, out string msg)
        {
            int ret = 0;

            msg = null;
            STUser      data         = new STUser();
            CCondition  clCondition  = new CCondition();
            CPermission clPermission = new CPermission();

            try
            {
                CUser clUser = new CUser(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());

                data.comments     = model.Comments;
                data.condition    = clCondition.GetId(model.Condition);
                data.email        = model.Email;
                data.login        = model.Login;
                data.modifieddate = DateTime.Now;
                data.passwordsalt = CreateSalt();
                //      data.password = CreatePasswordHash(model.Password, data.passwordsalt);
                data.permission = clPermission.GetId(model.Permission);
                data.username   = model.UserName;

                string[] arr = new[] { "'", "\"", "--" };
                if (CheckerField.CheckField(arr, data.comments, data.email, data.login, data.username))
                {
                    msg = "One or more fields contain invalid characters.";
                    return(2);
                }

                ret = clUser.Update(model.UserId, data, out msg);

                if (ret == 0)
                {
                    CAction clAction = new CAction(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());
                    clAction.AddAction(ActionType.EditUser, string.Format("Edit user {0}, {1}", data.username,
                                                                          data.login), out msg);
                }
            }
            catch (Exception ex) { msg = ex.Message; ret = -1; }

            return(ret);
        }
コード例 #4
0
ファイル: UserController.cs プロジェクト: Pavlo7/AEVIProject
        public ActionResult List(int pageNum = 0)
        {
            if (Request.IsAuthenticated)
            {
                STUserVP param;
                if (Session["USERPARAM"] != null)
                {
                    param = (STUserVP)Session["USERPARAM"];
                }
                else
                {
                    param = new STUserVP();
                }

                string[] arr = new[] { "'", "\"", "--" };
                if (CheckerField.CheckField(arr, param.masklogin, param.maskusername, param.maskemail))
                {
                    ViewData["MSG"] = "One or more fields contain invalid characters.";
                    return(View("Errors"));
                }
                else
                {
                    List <UserModels> lst = UserModelsRepository.Instance.GetListUser(param);

                    ViewData["PageNum"]    = pageNum;
                    ViewData["ItemsCount"] = lst.Count;
                    ViewData["PageSize"]   = pageSize;
                    ViewData["STRPARAM"]   = param.strdata;

                    return(View(UserModelsRepository.Instance.GetListUser(pageSize, pageNum, param)));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #5
0
ファイル: UserModels.cs プロジェクト: Pavlo7/AEVIProject
        public int AddUser(UserModels model, out string msg)
        {
            int    ret  = 0;
            STUser data = new STUser();

            msg = null;
            CCondition  clCondition  = new CCondition();
            CPermission clPermission = new CPermission();

            try
            {
                CUser clUser =
                    new CUser(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());

                ret = clUser.GetRecordByUserLogin(model.Login, out data, out msg);
                if (ret != 0)
                {
                    return(ret);
                }
                else
                {
                    if (data.login != null)
                    {
                        msg = "The login already exists in the database for the application.";
                        return(1);
                    }
                }

                data.comments      = model.Comments;
                data.activateddate = null;
                data.condition     = 0;
                data.creationdate  = DateTime.Now;
                data.email         = model.Email;
                data.isactivated   = false;
                data.login         = model.Login;
                data.modifieddate  = data.creationdate;
                data.owneruserid   = LocalData.UserId();
                //      data.passwordsalt = CreateSalt();
                //      data.password = CreatePasswordHash(model.Password, data.passwordsalt);
                data.permission    = clPermission.GetId(model.Permission);
                data.username      = model.UserName;
                data.passvaliddate = DateTime.Now.AddDays(-1);
                data.newemailkey   = GenerateKey();

                string[] arr = new[] { "'", "\"", "--" };
                if (CheckerField.CheckField(arr, data.comments, data.email, data.login, data.username))
                {
                    msg = "One or more fields contain invalid characters.";
                    return(2);
                }

                ret = clUser.Insert(data, out msg);

                if (ret == 0)
                {
                    CAction clAction = new CAction(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());
                    clAction.AddAction(ActionType.AddUser, string.Format("Add user {0}, {1}", data.username,
                                                                         data.login), out msg);

                    CMail clMail = new CMail(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());

                    STMail maildata = new STMail();
                    maildata.to         = data.email;
                    maildata.tamplate   = "MailToUserActivateAccount.txt";
                    maildata.linkkey    = data.newemailkey;
                    maildata.fleetpwd   = null;
                    maildata.pan        = null;
                    maildata.dtcreate   = DateTime.Now.ToString("yyyyMMddHHmmss");
                    maildata.dtmistsent = null;
                    maildata.login      = data.login;
                    clMail.Insert(maildata, out msg);

                    SMTPNotice smtp = new SMTPNotice(LocalData.SmtpHost(), LocalData.SmtpPort(), LocalData.SmtpUseSSL(),
                                                     LocalData.SmtpUserName(), LocalData.SmtpPassword(), LocalData.SmtpFrom(), LocalData.CSDbUsers(),
                                                     LocalData.LogPath(), LocalData.GetTemplatePath(), LocalData.Images());
                    smtp.SendNotice(out msg);
                }
            }
            catch (Exception ex) { msg = ex.Message; ret = -1; }
            return(ret);
        }