Exemplo n.º 1
0
        public async Task <Result <int> > AddUser([FromBody] UserEnt ent)
        {
            Result <int> r = null;
            await Task.Run(() =>
            {
                r = ResultRunner <int> .Run(delegate() { UserBus.AddUser(ent, LoggededInUserID); });
            });

            return(r);
        }
Exemplo n.º 2
0
        private void OnTaoMatKhau(DataRow row)
        {
            string fileNum = row["FileNum"].ToString();
            Result result  = UserBus.GetUser(fileNum);

            if (result.Error.Code != ErrorCode.EXIST && result.Error.Code != ErrorCode.NOT_EXIST)
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("UserBus.GetUser"), IconType.Information);
                Utility.WriteToTraceLog(result.GetErrorAsString("UserBus.GetUser"));
                return;
            }

            if (result.Error.Code == ErrorCode.NOT_EXIST)
            {
                string password = Utility.GeneratePassword(5);
                result = UserBus.AddUser(fileNum, password);
                if (!result.IsOK)
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("UserBus.AddUser"), IconType.Information);
                    Utility.WriteToTraceLog(result.GetErrorAsString("UserBus.AddUser"));
                    return;
                }
            }
        }
Exemplo n.º 3
0
        private void OnUploadHoSo(DataRow row)
        {
            string maBenhNhan   = row["FileNum"].ToString();
            string tenBenhNhan  = Utility.ConvertToUnSign(row["FullName"].ToString());
            string tenBenhNhan2 = Utility.ConvertToUnSign2(row["FullName"].ToString());
            string password     = Utility.GeneratePassword(5);
            string path         = string.Format("{0}\\{1}@{2}", Global.HoSoPath, maBenhNhan, tenBenhNhan);

            if (!Directory.Exists(path))
            {
                return;
            }
            string[] files = Directory.GetFiles(path);
            if (files == null || files.Length <= 0)
            {
                return;
            }

            Result result = UserBus.GetUser(maBenhNhan);

            if (result.Error.Code != ErrorCode.EXIST && result.Error.Code != ErrorCode.NOT_EXIST)
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("UserBus.GetUser"), IconType.Information);
                Utility.WriteToTraceLog(result.GetErrorAsString("UserBus.GetUser"));
                return;
            }

            if (result.Error.Code == ErrorCode.NOT_EXIST)
            {
                result = UserBus.AddUser(maBenhNhan, password);
                if (!result.IsOK)
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("UserBus.AddUser"), IconType.Information);
                    Utility.WriteToTraceLog(result.GetErrorAsString("UserBus.AddUser"));
                    return;
                }
            }
            else
            {
                password = (result.QueryResult as User).Password;
            }

            result = MySQLHelper.InsertUser(maBenhNhan, password, tenBenhNhan2);
            if (!result.IsOK)
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("MySQLHelper.InsertUser"), IconType.Information);
                Utility.WriteToTraceLog(result.GetErrorAsString("MySQLHelper.InsertUser"));
                return;
            }

            foreach (string file in files)
            {
                string remoteFileName = string.Format("{0}/{1}/{2}", Global.FTPFolder, maBenhNhan, Path.GetFileName(file));
                result = FTP.UploadFile(Global.FTPConnectionInfo, file, remoteFileName);
                if (!result.IsOK)
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("FTP.UploadFile"), IconType.Information);
                    Utility.WriteToTraceLog(result.GetErrorAsString("FTP.UploadFile"));
                }
            }
        }