Exemplo n.º 1
0
        public void login(string username, string pwd, string clientID)
        {
            try
            {
                int storeID = GetStoreIDbyPhone(username);
                string folderName = System.Configuration.ConfigurationManager.AppSettings.GetValues("RootPath").FirstOrDefault().ToString();

                bool exists = System.IO.Directory.Exists(folderName + storeID);
                string pathString = "";
                if (!exists)
                {
                    pathString = System.IO.Path.Combine(folderName, storeID.ToString());
                    System.IO.Directory.CreateDirectory(pathString);
                    pathString += "\\";
                }
                MySQLBusinessLogic bl = new MySQLBusinessLogic();
                int result = bl.LoginUser(username, Encrypt(pwd));
                //string email = res.Split('_')[0];
                //int result = Convert.ToInt32(res.Split('_')[1]);
                if (result == 1)
                {
                    //If success

                    Clients.Client(clientID).loginResult(username, "1");
                    bl.AddtoRetailerLoginHistory(storeID, DateTime.Now);
                }
                else if (result == 2)
                {
                    //if  username or pwd doent exist
                    Clients.Client(clientID).loginResult(username, "2");
                }
                else
                {
                    //if something gone wrong(exception)
                    Clients.Client(clientID).loginResult(username, "0");
                }
            }

            catch (Exception ex)
            {
                Clients.Client(clientID).loginResult(username, "0");
            }
        }