Exemple #1
0
        private void LoginLocal(AdUser user)
        {
            EditText userid = FindViewById <EditText> (Resource.Id.login_userName);
            EditText passw  = FindViewById <EditText> (Resource.Id.login_password);
            EditText code   = FindViewById <EditText> (Resource.Id.login_code);

            if (user.UserID.ToUpper() == userid.Text.ToUpper())
            {
                if (user.Password == passw.Text)
                {
                    if (isLastConnectExpire(user))
                    {
                        user.Islogon = false;
                        RemoveUser(user);
                        DownloadCOmpleted(Resources.GetString(Resource.String.msg_faillogin));
                    }
                    else
                    {
                        user.Islogon = true;
                        UpdateLogin(user);
                        ShowMainActivity(user.CompCode, user.BranchCode);
                    }
                }
                else
                {
                    DownloadCOmpleted(Resources.GetString(Resource.String.msg_faillogin));
                }
            }
            else
            {
                DownloadCOmpleted(Resources.GetString(Resource.String.msg_faillogin));
            }
        }
Exemple #2
0
        private void InsertItemIntoDb(string result)
        {
            string pathToDatabase = ((GlobalvarsApp)CallingActivity.Application).DATABASE_PATH;

            string[] para = result.Split(new char[] { '|' });
            if (para [0] != "OK")
            {
                Downloadhandle.Invoke(CallingActivity, 0, CallingActivity.Resources.GetString(Resource.String.msg_faillogin));
                return;
            }
            EditText passw = CallingActivity.FindViewById <EditText> (Resource.Id.login_password);

            using (var db = new SQLite.SQLiteConnection(pathToDatabase))
            {
                var list2 = db.Table <AdUser>().ToList <AdUser>();
                list2.RemoveAll(x => x.UserID == para[1]);
                AdUser user = new AdUser();
                user.BranchCode  = para [3];
                user.CompCode    = para [2];
                user.Islogon     = true;
                user.Password    = passw.Text;
                user.UserID      = para [1];
                user.LastConnect = DateTime.Now;
                db.Insert(user);
            }
            ((GlobalvarsApp)CallingActivity.Application).USERID_CODE  = para [1];
            ((GlobalvarsApp)CallingActivity.Application).COMPANY_CODE = para [2];
            ((GlobalvarsApp)CallingActivity.Application).BRANCH_CODE  = para [3];
            //DownloadCOmpleted ("Successfully Logon.");
            //Downloadhandle.Invoke(CallingActivity,0,"Successfully Logon.");
            FireEvent(EventID.LOGIN_SUCCESS);
        }
Exemple #3
0
        private void UploadlocsToServer()
        {
            string pathToDatabase = ((GlobalvarsApp)CallingActivity).DATABASE_PATH;
            AdUser user           = new AdUser();

            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                user = db.Table <AdUser> ().FirstOrDefault();
            }
            if (user == null)
            {
                return;
            }

            string comp   = user.CompCode;
            string brn    = user.BranchCode;
            string userid = user.UserID;

            locs = Getlocs();

            invcount += locs.Count;
            if (locs.Count > 0)
            {
                _client.UpdateLocationAsync(locs.ToArray(), comp, brn, userid);
            }
//			else {
//				RunOnUiThread (() => Uploadhandle.Invoke(CallingActivity,invcount,_errmsg));
//			}
        }
Exemple #4
0
        private void BeforeReLoginToCloud(AdUser user)
        {
            EditText userid = FindViewById <EditText> (Resource.Id.login_userName);
            EditText passw  = FindViewById <EditText> (Resource.Id.login_password);
            EditText code   = FindViewById <EditText> (Resource.Id.login_code);

            userid.Text    = user.UserID;
            passw.Text     = user.Password;
            code.Text      = user.CompCode;
            userid.Enabled = false;
            code.Enabled   = false;
        }
Exemple #5
0
        public static void UpdateLastConnect(string pathToDatabase)
        {
            AdUser user = null;

            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                var list2 = db.Table <AdUser> ().ToList <AdUser> ();
                if (list2.Count > 0)
                {
                    user             = list2 [0];
                    user.LastConnect = DateTime.Now;
                    db.Update(user);
                }
            }
        }
Exemple #6
0
        public static AdUser GetUser(string pathToDatabase)
        {
            AdUser user = null;

            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                var list2 = db.Table <AdUser> ().ToList <AdUser> ();
                if (list2.Count > 0)
                {
                    user = list2 [0];
                }
            }

            return(user);
        }
Exemple #7
0
        private bool isLastConnectExpire(AdUser user)
        {
            bool isExpiry = false;

            rights = Utility.GetAccessRights(pathToDatabase);
            int Expiry = DataHelper.GetExpiryDay(pathToDatabase);

            if (rights.IsLoginControl)
            {
                if (user.LastConnect.Year < 2000)
                {
                    user.LastConnect = DateTime.Now;
                }
                double day = (DateTime.Now - user.LastConnect).TotalDays;
                isExpiry = (day > Expiry);
            }

            return(isExpiry);
        }
Exemple #8
0
        private void InsertItemIntoDb(string result)
        {
            string pathToDatabase = ((GlobalvarsApp)CallingActivity.Application).DATABASE_PATH;
            string userid = ((GlobalvarsApp)CallingActivity.Application).USERID_CODE;

            string[] para = result.Split (new char[]{ '|' });
            if (para [0] != "OK") {
                Downloadhandle.Invoke(CallingActivity,0,"Fail to Login.");
                return;
            }
            EditText passw =  CallingActivity.FindViewById<EditText> (Resource.Id.login_password);
            using (var db = new SQLite.SQLiteConnection(pathToDatabase))
            {
                var list2 = db.Table<AdUser>().ToList<AdUser>();
                list2.RemoveAll (x => x.UserID == para[1]&&x.CompCode== para [2].ToUpper()&&x.BranchCode == para [3].ToUpper());
                AdUser user = new AdUser ();
                user.BranchCode = para [3].ToUpper();
                user.CompCode = para [2].ToUpper();
                user.Islogon = true;
                user.Password = passw.Text;
                user.UserID = para [1].ToUpper();

                db.Insert (user);
            }
            ((GlobalvarsApp)CallingActivity.Application).USERID_CODE = para [1].ToUpper();
            ((GlobalvarsApp)CallingActivity.Application).COMPANY_CODE = para [2].ToUpper();
            ((GlobalvarsApp)CallingActivity.Application).BRANCH_CODE = para [3].ToUpper();
            //DownloadCOmpleted ("Successfully Logon.");
            //Downloadhandle.Invoke(CallingActivity,0,"Successfully Logon.");
            FireEvent (EventID.LOGIN_SUCCESS);
        }
Exemple #9
0
        private void UploadlocsToServer()
        {
            string pathToDatabase = ((GlobalvarsApp)CallingActivity).DATABASE_PATH;
            AdUser user = new AdUser ();
            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
                user = db.Table<AdUser> ().FirstOrDefault ();
            }
            if (user == null)
                return;

            string comp =user.CompCode;
            string brn = user.BranchCode;
            string userid = user.UserID;

            locs = Getlocs();

            invcount += locs.Count;
            if (locs.Count > 0) {
                _client.UpdateLocationAsync (locs.ToArray (), comp, brn, userid);
            }
            //			else {
            //				RunOnUiThread (() => Uploadhandle.Invoke(CallingActivity,invcount,_errmsg));
            //			}
        }
Exemple #10
0
 void RemoveUser(AdUser user)
 {
     using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
         db.Delete (user);
     }
 }
Exemple #11
0
        private void LoginLocal(AdUser user)
        {
            EditText userid = FindViewById<EditText> (Resource.Id.login_userName);
            EditText passw = FindViewById<EditText> (Resource.Id.login_password);
            EditText code = FindViewById<EditText> (Resource.Id.login_code);
            user = DataHelper.GetUser (pathToDatabase,userid.Text.ToUpper(),code.Text.ToUpper());

            if (userid.Text == "") {
                DownloadCOmpleted ("User ID is blank...."); return;
            }
            if (passw.Text == "") {
                DownloadCOmpleted ("Password is blank...."); return;
            }
            if (code.Text == "") {
                DownloadCOmpleted ("Security code is blank...."); return;
            }

            if (user == null) {
                LoginIntoCloud ();
                return;
            }

            if (user.UserID.ToUpper () == userid.Text.ToUpper ()) {
                if (user.Password == passw.Text) {
                    ((GlobalvarsApp)this.Application).USERID_CODE = user.UserID.ToUpper();
                    ((GlobalvarsApp)this.Application).COMPANY_CODE = user.CompCode.ToUpper();
                    ((GlobalvarsApp)this.Application).BRANCH_CODE = user.BranchCode.ToUpper();
                    user.Islogon = true;
                    UpdateLogin (user);
                    ShowMainActivity (user.CompCode, user.BranchCode);
                } else {
                    DownloadCOmpleted ("Login fail....");
                }
            }else DownloadCOmpleted ("Login fail....");
        }
        private void LoginLocal(AdUser user)
        {
            EditText userid = FindViewById<EditText> (Resource.Id.login_userName);
            EditText passw = FindViewById<EditText> (Resource.Id.login_password);
            EditText code = FindViewById<EditText> (Resource.Id.login_code);

            if (user.UserID.ToUpper () == userid.Text.ToUpper ()) {
                if (user.Password == passw.Text) {
                    user.Islogon = true;
                    UpdateLogin (user);
                    ShowMainActivity (user.CompCode, user.BranchCode);
                } else {
                    DownloadCOmpleted ("Login fail....");
                }
            }else DownloadCOmpleted ("Login fail....");
        }
Exemple #13
0
 void RemoveUser(AdUser user)
 {
     using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
         db.Delete(user);
     }
 }
Exemple #14
0
 void UpdateLogin(AdUser user)
 {
     using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
         db.Update(user);
     }
 }
Exemple #15
0
        private bool isLastConnectExpire(AdUser user)
        {
            bool isExpiry = false;
            rights = Utility.GetAccessRights (pathToDatabase);
            int Expiry = DataHelper.GetExpiryDay (pathToDatabase);
            if (rights.IsLoginControl) {
                if (user.LastConnect.Year < 2000)
                    user.LastConnect = DateTime.Now;
                double day = (DateTime.Now - user.LastConnect).TotalDays;
                isExpiry = (day > Expiry);
            }

            return isExpiry;
        }
Exemple #16
0
 private void BeforeReLoginToCloud(AdUser user)
 {
     EditText userid = FindViewById<EditText> (Resource.Id.login_userName);
     EditText passw = FindViewById<EditText> (Resource.Id.login_password);
     EditText code = FindViewById<EditText> (Resource.Id.login_code);
     userid.Text = user.UserID;
     passw.Text = user.Password;
     code.Text = user.CompCode;
     userid.Enabled = false;
     code.Enabled = false;
 }
Exemple #17
0
        private void LoginLocal(AdUser user)
        {
            EditText userid = FindViewById<EditText> (Resource.Id.login_userName);
            EditText passw = FindViewById<EditText> (Resource.Id.login_password);
            EditText code = FindViewById<EditText> (Resource.Id.login_code);

            if (user.UserID.ToUpper () == userid.Text.ToUpper ()) {
                if (user.Password == passw.Text) {
                    if (isLastConnectExpire (user)) {
                        user.Islogon = false;
                        RemoveUser (user);
                        DownloadCOmpleted (Resources.GetString (Resource.String.msg_faillogin));
                    } else {
                        user.Islogon = true;
                        UpdateLogin (user);
                        ShowMainActivity (user.CompCode, user.BranchCode);
                    }
                } else {
                    DownloadCOmpleted (Resources.GetString (Resource.String.msg_faillogin));
                }
            }else DownloadCOmpleted (Resources.GetString (Resource.String.msg_faillogin));
        }
Exemple #18
0
 void UpdateLogin(AdUser user)
 {
     using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
         db.Update (user);
     }
 }
Exemple #19
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SignIn);
            // Create your application here
            EventManagerFacade.Instance.GetEventManager().AddListener(this);
            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
            PackageInfo pInfo = PackageManager.GetPackageInfo(PackageName, 0);
//			Button import = FindViewById<Button>(Resource.Id.logimport);
//
//			import.Click+= (object sender, EventArgs e) => {
//				ImportDatabase();
//			};
            Button   login   = FindViewById <Button>(Resource.Id.login);
            Button   bexit   = FindViewById <Button>(Resource.Id.exit);
            TextView txtver  = FindViewById <TextView> (Resource.Id.textVer);
            EditText txtcode = FindViewById <EditText> (Resource.Id.login_code);

            bexit.Click += (object sender, EventArgs e) => {
                Finish();
                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
            };
            //InitializeServiceClient();
            txtver.Text = "VERSION " + pInfo.VersionName;
            ((GlobalvarsApp)this.Application).VERSION = pInfo.VersionName;

            AdUser user = null;

            //SQLiteConnection...CreateFile(pathToDatabase);
            if (!File.Exists(pathToDatabase))
            {
                createTable(pathToDatabase);
            }
            else
            {
                if (pInfo.VersionCode >= 57)
                {
                    if (!CheckIfColumnExists())
                    {
                        UpdateItem();
                    }
                    if (!CheckIfColumnExists2())
                    {
                        UpdateItem2();
                    }
                }
            }
            //else {
//				user = DataHelper.GetUser (pathToDatabase);
//				UpdateDatbase ();
//				if (user !=null)
//					BeforeReLoginToCloud (user);
//			}

            user = DataHelper.GetUser(pathToDatabase);
//			using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
//				var list2 = db.Table<AdUser> ().ToList<AdUser> ();
//				if (list2.Count > 0) {
//					user = list2 [0];
//				}
//			}


            if (user != null)
            {
                ((GlobalvarsApp)this.Application).USERID_CODE = user.UserID;
                if (user.Islogon)
                {
                    ShowMainActivity(user.CompCode, user.BranchCode);
                    return;
                }
                else
                {
                    //txtcode.Enabled = false;
                    //txtcode.SetBackgroundColor (Android.Graphics.Color.Gray);
                    txtcode.Visibility = ViewStates.Gone;
                    login.Click       += (object sender, EventArgs e) => {
                        LoginLocal(user);
                    };
                }
            }
            else
            {
                login.Click += (object sender, EventArgs e) => {
                    LoginIntoCloud();
                };
            }

            CheckSystemUpdate();
        }