Пример #1
0
        //public LogInData Data { get; set; }

        public bool LogInProcess(LogInData data)
        {
            byte[] _data = data.Serialize();
            //Data = data;

            return(LogInClient.Instance.LogIn(_data));
        }
Пример #2
0
        public ActionResult Edit(UserInfo usr)
        {
            bool IsSaved = db_usrinfo.UpdateUserInfo(usr);

            LogInData LID = (LogInData)Session["LogInData"];

            LID.UserName = usr.UserName;
            LID.Password = usr.Password;

            Session["LogInData"] = LID;

            if (LID.AdminEqual1 != 1)
            {
                if (LID.UserTypeCode == 1)
                {
                    return(RedirectToAction("Index", "StdHome"));
                }
                else
                {
                    return(RedirectToAction("Index", "EmpHome"));
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public void WhenTheUserEntersIncorrectLoginInformation(Table table)
        {
            var loginPage = new LoginPage(driver);

            userLogInData = table.CreateInstance <LogInData>();
            loginPage.LogInUser(userLogInData.UserName, userLogInData.Password);
        }
        public void GivenTheUserIsLoggedInHisAccount(Table table)
        {
            var loginPage = new LoginPage(driver);
            var homePage  = new HomePage(driver);

            userLogInData = table.CreateInstance <LogInData>();
            loginPage.LogInUser(userLogInData.UserName, userLogInData.Password);
            Assert.That(homePage.LogoutBtn.Displayed, Is.True);
        }
        public List <LogInData> GetEmployee(UserInfo obj = null)
        {
            con.Open();
            SqlCommand _command = new SqlCommand();

            string query = "SELECT A.*,B.*,C.* " +
                           "FROM UserInfo A " +
                           "LEFT JOIN Employee B " +
                           "ON A.EmpOrStdId=B.EmployeeId " +
                           "LEFT JOIN Department C " +
                           "ON B.DepartmentId=C.DepartmentId " +
                           "WHERE A.UserName='******' AND A.Password='******' AND A.UserTypeCode='" + obj.UserTypeCode + "'";

            _command.CommandText = query;
            _command.Connection  = con;

            SqlDataAdapter _adapter = new SqlDataAdapter();

            _adapter.SelectCommand = _command;

            DataTable dt = new DataTable();

            _adapter.Fill(dt);
            List <LogInData> LogInEmp_list = new List <LogInData>();

            foreach (DataRow dr in dt.Rows)
            {
                LogInData logdata = new LogInData();
                logdata.UserName     = dr["UserName"].ToString();
                logdata.Password     = dr["Password"].ToString();
                logdata.UserTypeCode = Convert.ToInt16(dr["UserTypeCode"].ToString());
                logdata.UserId       = Convert.ToInt64(dr["UserId"].ToString());
                logdata.EmpOrStdId   = Convert.ToInt16(dr["EmpOrStdId"].ToString());


                logdata.EmployeeCode   = dr["EmployeeCode"].ToString();
                logdata.EmployeeName   = dr["EmployeeName"].ToString();
                logdata.Address        = dr["Address"].ToString();
                logdata.ContactNo      = dr["ContactNo"].ToString();
                logdata.Email          = dr["Email"].ToString();
                logdata.BloodGroup     = dr["BloodGroup"].ToString();
                logdata.Sex            = dr["Sex"].ToString();
                logdata.DepartmentName = dr["DepartmentName"].ToString();
                logdata.JoiningDate    = Convert.ToDateTime(dr["JoiningDate"].ToString());

                logdata.BioPhoto = (byte[])dr["BioPhoto"];

                string imageBase64 = Convert.ToBase64String((byte[])dr["BioPhoto"]);
                string imageSrc    = string.Format("data:image/jpeg;base64,{0}", imageBase64);

                logdata.PhotoByteString = imageSrc;

                LogInEmp_list.Add(logdata);
            }
            return(LogInEmp_list);
        }
        // GET: /Home/
        public ActionResult Index()
        {
            LogInData LID = (LogInData)Session["LogInData"];

            List <LogInData> logemp_list = new List <LogInData>();

            logemp_list.Add(LID);
            return(View("Index", logemp_list));
        }
Пример #7
0
        private void HandleRegisterSuccess(GuestControllerResult <LogInResponse> result, IEnumerable <Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem> marketing, Action <IRegisterResult> callback)
        {
            IList <IInvalidProfileItemError> profileItemErrors = null;

            try
            {
                if (!result.Success)
                {
                    callback(new RegisterResult(success: false, null, null));
                    return;
                }
                IRegisterResult registerResult = GuestControllerErrorParser.GetRegisterResult(result.Response.error);
                if (registerResult != null)
                {
                    callback(registerResult);
                    return;
                }
                profileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
                if (result.Response.data == null)
                {
                    if (result.Response.error != null && profileItemErrors == null)
                    {
                        logger.Critical("Received unhandled error exception" + JsonParser.ToJson(result.Response.error));
                    }
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                    return;
                }
                LogInData loginData = result.Response.data;
                if (loginData.displayName == null || loginData.etag == null || loginData.profile == null || loginData.token == null || loginData.token.access_token == null)
                {
                    logger.Critical("Invalid login data:" + JsonParser.ToJson(loginData));
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                    return;
                }
                loginData.profile.status = GuestControllerErrorParser.GetAccountStatusCode(result.Response.error, loginData.profile.status);
                string countryCode = GuestControllerUtils.GetCountryCode(loginData.profile);
                database.StoreSession(loginData.token.swid, loginData.token.access_token, loginData.token.refresh_token, loginData.displayName.displayName, loginData.profile.firstName, loginData.etag, loginData.profile.ageBand, loginData.displayName.proposedDisplayName, loginData.displayName.proposedStatus, loginData.profile.status, updateLastProfileRefreshTime: true, countryCode);
                mixSessionStarter.Start(loginData.token.swid, loginData.token.access_token, delegate
                {
                    HandleMixSessionStartSuccess(profileItemErrors, loginData.token.swid, loginData.profile, loginData.displayName, marketing, callback);
                }, delegate
                {
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                });
            }
            catch (CorruptionException ex)
            {
                logger.Fatal("Corruption detected during registration: " + ex);
                callback(new RegisterCorruptionDetectedResult());
            }
            catch (Exception ex2)
            {
                logger.Critical("Unhandled exception: " + ex2);
                callback(new RegisterResult(success: false, null, profileItemErrors));
            }
        }
Пример #8
0
        public IHttpActionResult PostCheckinDetail(UserAttendanceViewModel login)
        {
            LogInData    logR         = new LogInData();
            var          userdetails  = generic.GetUserDetail(login.UserId);
            var          Ipdata       = db.IpMasters.Where(c => c.UserId == userdetails.SubscriberId).ToList();
            var          finalipMatch = Ipdata.Where(c => c.LatitudeFrom <= login.Latitude && c.LatitudeTo >= login.Latitude && c.LongitudeFrom <= login.Longitude && c.LongitudeTo >= login.Longitude).FirstOrDefault();
            TimeZoneInfo INDIAN_ZONE  = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            DateTime     indianTime   = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);

            var getcheckindetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == login.UserId && c.CheckInDate == indianTime.Date).FirstOrDefault();

            if (finalipMatch != null)
            {
                if (getcheckindetails != null)
                {
                    var getcheckoutdetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == login.UserId && c.CheckOutDate == indianTime.Date).FirstOrDefault();
                    if (getcheckoutdetails != null)
                    {
                        logR.CheckedStatus  = 2;                             // checkin / checkout done
                        logR.CheckOutTime   = getcheckindetails.CheckOutTime;
                        logR.CheckInTime    = getcheckindetails.CheckInTime; //mj
                        logR.CurrentDate    = indianTime.Date;
                        logR.ServerTime     = indianTime.TimeOfDay;
                        logR.LocationStatus = 1; //Inside of premises
                    }

                    else
                    {
                        logR.CheckedStatus  = 1; // Only checked in
                        logR.CheckInTime    = getcheckindetails.CheckInTime;
                        logR.CurrentDate    = indianTime.Date;
                        logR.ServerTime     = indianTime.TimeOfDay;
                        logR.LocationStatus = 1;//Inside of premises
                    }
                }
                else
                {
                    logR.CheckedStatus  = 0; //No checkin /checkout found
                    logR.CurrentDate    = indianTime.Date;
                    logR.ServerTime     = indianTime.TimeOfDay;
                    logR.LocationStatus = 1;//Inside of premises
                }
            }
            else
            {
                logR.LocationStatus = 0;//outside of premises
                logR.CurrentDate    = indianTime.Date;
                logR.ServerTime     = indianTime.TimeOfDay;
            }
            return(new LogInResult(logR, Request));
        }
Пример #9
0
 public async Task <IActionResult> Index(LogInData data)
 {
     if (ModelState.IsValid)
     {
         var account = db.Accounts
                       .Where(q => q.Phone == data.Phone && q.Password == data.Password)
                       .FirstOrDefault();
         if (account != null)
         {
             await Authenticate(account.Id); // аутентификация
         }
         return(RedirectToAction("Index", "Main"));
     }
     return(View(data));
 }
Пример #10
0
        public void Send()
        {
            logInData = new LogInData()
            {
                user = userField.text,
                pass = passwordField.text
            };

            if (!logInData.Validate)
            {
                Debug.Log($"Uncorrect username:[{logInData.user}] or password:[{logInData.pass}]");
                return;
            }

            Scripts.Network.DBManager.Upload(UrlKeywords.LogIn, logInData.GetForm(), AuthorizeCallback);
        }
Пример #11
0
        private void createAccountButton_Click(object sender, EventArgs e)
        {
            RegisterModel register = new RegisterModel();

            register.RegisterProcess(_data);

            LogInModel login     = new LogInModel();
            LogInData  loginData = new LogInData();

            LogInData.ViaAction = "REGISTER";

            loginData.Username = _data.Username;
            loginData.Password = _data.Password;

            bool isConnected = login.LogInProcess(loginData);

            if (isConnected)
            {
                notificationLabel.ForeColor = Color.Green;
                notificationLabel.Text      = "Connected";
                notificationLabel.Visible   = true;
            }
            else
            {
                notificationLabel.ForeColor = Color.Red;
                notificationLabel.Text      = "Account does NOT Exist!";
                notificationLabel.Visible   = true;
            }


            var loadingBar = new LoadingBar();

            loadingBar.Activate(131, 383, this);
            Refresh();
            notificationLabel.Visible = false;
            if (isConnected)
            {
                Close();
                Dispose();

                AppProjForm appProjForm = new AppProjForm();
                appProjForm.ShowDialog();
            }
        }
Пример #12
0
        public ActionResult Edit(long EmpOrStdId = 0)
        {
            LogInData       LID         = (LogInData)Session["LogInData"];
            List <UserInfo> usrinf_list = new List <UserInfo>();

            if (LID.AdminEqual1 != 1)
            {
                UserInfo usr = new UserInfo();
                usr.UserName     = LID.UserName;
                usr.UserTypeCode = LID.UserTypeCode;
                usr.UserId       = LID.UserId;
                usr.EmpOrStdId   = LID.EmpOrStdId;
                usr.Password     = LID.Password;
                usrinf_list.Add(usr);
            }
            else
            {
                usrinf_list = db_usrinfo.SelectUserInfo(new UserInfo {
                    EmpOrStdId = EmpOrStdId
                });
            }

            return(View(usrinf_list[0]));
        }
Пример #13
0
    private void HandleLoginSuccess(GuestControllerResult <LogInResponse> result, Action <ILoginResult> callback)
    {
        try
        {
            LogInResponse           response          = result.Response;
            LogInData               data              = response.data;
            GuestApiErrorCollection gcErrorCollection = response.error;
            ILoginResult            loginResult       = GuestControllerErrorParser.GetLoginResult(gcErrorCollection);
            bool   flag          = false;
            string hallPassToken = string.Empty;
            string swid          = string.Empty;
            if (data != null || loginResult == null)
            {
                goto IL_015d;
            }
            if (loginResult is ILoginFailedParentalConsentResult)
            {
                foreach (GuestApiError error in gcErrorCollection.errors)
                {
                    TemporaryToken data2 = error.data;
                    if (data2 != null)
                    {
                        flag          = true;
                        hallPassToken = data2.accessToken;
                        swid          = data2.swid;
                        break;
                    }
                }
                if (flag)
                {
                    goto IL_015d;
                }
                callback(loginResult);
            }
            else
            {
                callback(loginResult);
            }
            goto end_IL_0018;
IL_015d:
            if (data == null && !flag)
            {
                if (gcErrorCollection != null)
                {
                    logger.Critical("Received unhandled error exception: " + JsonParser.ToJson(gcErrorCollection));
                }
                callback(new LoginResult(success: false, null));
            }
            else if (flag)
            {
                database.StoreSession(swid, hallPassToken, null, null, null, null, null, null, null, null, updateLastProfileRefreshTime: false, null);
                IGuestControllerClient guestControllerClient = guestControllerClientFactory.Create(swid);
                ProfileGetter.GetProfile(logger, guestControllerClient, delegate(ProfileData profileData)
                {
                    if (profileData == null)
                    {
                        database.DeleteSession(swid);
                        callback(new LoginFailedParentalConsentResult());
                    }
                    else
                    {
                        StoreSession(swid, hallPassToken, null, profileData.etag, profileData.displayName, profileData.profile);
                        HandleRefreshProfileSuccess(callback, loginResult, gcErrorCollection, profileData.profile, profileData.displayName, profileData.marketing, swid, hallPassToken);
                    }
                });
            }
            else if (!ValidateLogInData(data))
            {
                logger.Critical("Error parsing the login data:" + JsonParser.ToJson(data));
                callback(new LoginResult(success: false, null));
            }
            else
            {
                Token token = data.token;
                StoreSession(token.swid, token.access_token, token.refresh_token, data.etag, data.displayName, data.profile);
                HandleRefreshProfileSuccess(callback, loginResult, gcErrorCollection, data.profile, data.displayName, data.marketing, token.swid, token.access_token);
            }
            end_IL_0018 :;
        }
        catch (CorruptionException arg)
        {
            logger.Fatal("Corruption detected during login: "******"Unhandled exception: " + arg2);
            callback(new LoginResult(success: false, null));
        }
    }
Пример #14
0
 public void receiveLogin(LogInData data)
 {
 }
Пример #15
0
 public TestGuest(LogInData logInData, string password)
 {
     LogInData = logInData;
     Password  = password;
 }
Пример #16
0
 private static bool ValidateLogInData(LogInData data)
 {
     return(data.displayName != null && data.etag != null && data.profile != null && data.token != null && data.token.access_token != null);
 }
Пример #17
0
        public ActionResult LogIn(UserInfo usrInfo)
        {
            /*UserInfo_DBAccess usr_dbAccess = new UserInfo_DBAccess();
             * List<UserInfo> list = usr_dbAccess.SelectUserInfo(usrInfo);
             * LogInData LID = new LogInData();
             * if (list != null && list.Count > 0)
             * {
             *
             *  LID.EmpOrStdId = list[0].EmpOrStdId;
             *  LID.UserId = list[0].UserId;
             *  LID.UserName = list[0].UserName;
             *  LID.UserTypeCode = list[0].UserTypeCode;
             *  LID.Password = list[0].Password;
             * }*/
            List <LogInData> list = new List <LogInData>();

            if (usrInfo.UserTypeCode == 1)
            {
                LogInStudent_DBAccess std_dbAccess = new LogInStudent_DBAccess();
                list = std_dbAccess.GetStudent(usrInfo);
            }
            else
            {
                LogInEmployee_DBAccess emp_dbAccess = new LogInEmployee_DBAccess();
                list = emp_dbAccess.GetEmployee(usrInfo);
            }
            if (list[0].EmpOrStdId != 0)
            {
                if (list != null && list.Count > 0)
                {
                    LogInData LID = new LogInData();
                    LID.EmpOrStdId      = list[0].EmpOrStdId;
                    LID.UserId          = list[0].UserId;
                    LID.UserName        = list[0].UserName;
                    LID.UserTypeCode    = list[0].UserTypeCode;
                    LID.Password        = list[0].Password;
                    LID.Address         = list[0].Address;
                    LID.ContactNo       = list[0].ContactNo;
                    LID.Email           = list[0].Email;
                    LID.BloodGroup      = list[0].BloodGroup;
                    LID.Sex             = list[0].Sex;
                    LID.DepartmentName  = list[0].DepartmentName;
                    LID.BioPhoto        = list[0].BioPhoto;
                    LID.PhotoByteString = list[0].PhotoByteString;

                    if (LID.UserTypeCode == 1)
                    {
                        LID.StudentCode   = list[0].StudentCode;
                        LID.StudentName   = list[0].StudentName;
                        LID.FatherName    = list[0].FatherName;
                        LID.MotherName    = list[0].MotherName;
                        LID.Hall          = list[0].Hall;
                        LID.AdmissionYear = list[0].AdmissionYear;
                        LID.DateOfBirth   = list[0].DateOfBirth;

                        Session["LogInData"] = LID;

                        return(RedirectToAction("Index", "StdHome"));
                    }
                    else
                    {
                        LID.EmployeeCode = list[0].EmployeeCode;
                        LID.EmployeeName = list[0].EmployeeName;
                        LID.JoiningDate  = list[0].JoiningDate;

                        Session["LogInData"] = LID;

                        return(RedirectToAction("Index", "EmpHome"));
                    }
                }
            }
            return(View("Index"));
        }
Пример #18
0
        private void LogInProcess(TcpClient client)
        {
            NetworkStream stream        = client.GetStream();
            Assembly      encript       = Assembly.LoadFrom("AsymmetricEncriptionAssembly.dll");
            Type          type          = encript.GetType("AsymmetricEncriptionAssembly.AsymmetricEncription");
            MethodInfo    getPublicKey  = type.GetMethod("getPublicKey");
            MethodInfo    getPrivateKey = type.GetMethod("getPrivateKey");
            MethodInfo    Decription    = type.GetMethod("Decription");
            object        instance      = Activator.CreateInstance(type);

            Database db = Database.Instance;

            db.ConnectToDb();

            bool justConnected = true;

            LogInData logInData = null;

            while (client.Connected)
            {
                //TcpClient client = server.AcceptTcpClient();
                //Console.WriteLine("Connected!");
                //if (justConnected)
                //{
                //    //Thread tmsg = new Thread(() => Output.Instance.AppendMsg("Connected!"));
                //    //tmsg.Start();
                //    Output.Instance.AppendMsg("Connected!");
                //}
                //Output.Instance.AppendMsg("Connected!");

                /// Encription client sided
                if (justConnected)
                {
                    string publicKey = (string)getPublicKey.Invoke(instance, null);
                    byte[] token     = System.Text.Encoding.ASCII.GetBytes(publicKey);

                    Console.WriteLine(token.Length);
                    stream.Write(token, 0, token.Length);
                    justConnected = false;
                }


                //data = null;

                //NetworkStream stream = client.GetStream();

                //int i
                string responseMsg = null;
                byte[] _data       = new byte[128];
                try
                {
                    stream.Read(_data, 0, _data.Length);

                    if (_data == null)
                    {
                        break;
                    }
                    /// Decription
                    //Console.WriteLine(_data.Length);
                    string privateKey = (string)getPrivateKey.Invoke(instance, null);

                    byte[] decriptedData = (byte[])Decription.Invoke(instance, new object[] { (string)getPrivateKey.Invoke(instance, null),
                                                                                              _data });

                    /// Deserialization of Object
                    logInData = LogInData.Deserialize(decriptedData);


                    if (db.AuthenticateUser(logInData.Username,
                                            logInData.Password))
                    {
                        responseMsg = "OK";
                        //Console.WriteLine(DateTime.Now + $" -> {logInData.Username} Logged In\n");
                        //Output.Instance.AppendMsg(DateTime.Now + $" -> {logInData.Username} Logged In\n");

                        //onlineConnexions.UserConnected(new User
                        //{
                        //    Username = logInData.Username,
                        //    conn = client
                        //});
                    }
                    else
                    {
                        responseMsg = "NOT";
                    }


                    byte[] response = System.Text.Encoding.ASCII.GetBytes(responseMsg);
                    stream.Write(response, 0, response.Length);

                    if (responseMsg.Contains("OK"))
                    {
                        client.Close();
                    }
                    //client.Close();
                    //Console.WriteLine("Disconnected!");
                    //Output.Instance.AppendMsg("Disconnected!");
                }
                catch (Exception ex)
                {
                    ;
                }

                //while((i = stream.Read(bytes, 0, bytes.Length)) != 0)
                //{
                //    data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
                //    Console.WriteLine("Received: {0}", data);

                //    data = data.ToUpper();

                //    byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);

                //    stream.Write(msg, 0, msg.Length);
                //    Console.WriteLine("Sent: {0}", data);
                //}



                //client.Close();
            }
            Console.WriteLine(DateTime.Now + $" -> {logInData.Username} Disconnected\n");
            Output.Instance.AppendMsg(DateTime.Now + $" -> {logInData.Username} Disconnected\n");
        }
Пример #19
0
        public IHttpActionResult Post(UserAttendanceViewModel login)
        {
            LogInData logR = new LogInData();

            TimeZoneInfo    INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            DateTime        indianTime  = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            DateTime        date        = DateTime.Now.Date;
            ApplicationUser userExists  = UserManager.FindByEmail(login.Email);

            if (userExists != null)
            {
                var user       = UserManager.Find(userExists.UserName, login.Password);
                var userDetail = generic.GetUserDetail(user.Id);
                if (user != null)
                {
                    string name = null;
                    if (userDetail.Role == "Admin")
                    {
                        name = db.CorporateProfile.Where(c => c.CorporateId == user.Id).FirstOrDefault().Name;
                    }
                    else
                    {
                        name = db.EmployeeBasicDetails.Where(e => e.UserId == user.Id).FirstOrDefault().Name;
                    }
                    var deviceinfo = db.DeviceDetail.Where(c => c.UserId == user.Id).FirstOrDefault();
                    if (deviceinfo == null)
                    {
                        pms.AddDeviceInfromation(user.Id, login.AndroidId, login.AndroidDeviceName);
                        var getcheckindetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == user.Id && c.CheckInDate == date).FirstOrDefault();

                        if (getcheckindetails != null)
                        {
                            var getcheckoutdetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == user.Id && c.CheckOutDate == date).FirstOrDefault();
                            if (getcheckoutdetails != null)
                            {
                                logR.CheckedStatus = 2;
                                logR.CheckOutTime  = getcheckindetails.CheckOutTime;
                                logR.CurrentDate   = indianTime.Date;
                                logR.ServerTime    = indianTime.TimeOfDay;
                                logR.Status        = 2;
                                logR.Message       = "LogIn Successful";
                                logR.BearerCode    = logintoken(login.Email, login.Password);
                                logR.UserName      = name;
                                logR.Phonenumber   = user.PhoneNumber;
                                logR.UserId        = user.Id;
                            }

                            else
                            {
                                logR.CheckedStatus = 1;
                                logR.CheckInTime   = getcheckindetails.CheckInTime;
                                logR.CurrentDate   = indianTime.Date;
                                logR.ServerTime    = indianTime.TimeOfDay;
                                logR.Status        = 2;
                                logR.Message       = "LogIn Successful";
                                logR.BearerCode    = logintoken(login.Email, login.Password);
                                logR.UserName      = name;
                                logR.Phonenumber   = user.PhoneNumber;
                                logR.UserId        = user.Id;
                            }
                        }
                        else
                        {
                            logR.CheckedStatus = 0;
                            logR.CheckInTime   = getcheckindetails.CheckInTime;
                            logR.CurrentDate   = indianTime.Date;
                            logR.ServerTime    = indianTime.TimeOfDay;
                            logR.Status        = 2;
                            logR.Message       = "LogIn Successful";
                            logR.BearerCode    = logintoken(login.Email, login.Password);
                            logR.UserName      = name; // user.UserName;
                            logR.Phonenumber   = user.PhoneNumber;
                            logR.UserId        = user.Id;
                        }
                    }
                    else
                    {
                        if (deviceinfo.DeviceId == login.AndroidId)
                        {
                            var getcheckindetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == user.Id && c.CheckInDate == date).FirstOrDefault();
                            if (getcheckindetails != null)
                            {
                                var getcheckoutdetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == user.Id && c.CheckOutDate == date).FirstOrDefault();
                                if (getcheckoutdetails != null)
                                {
                                    logR.CheckedStatus = 2;
                                    logR.CheckOutTime  = getcheckindetails.CheckOutTime;
                                    logR.CurrentDate   = indianTime.Date;
                                    logR.ServerTime    = indianTime.TimeOfDay;
                                    logR.Status        = 2;
                                    logR.Message       = "LogIn Successful";
                                    logR.BearerCode    = logintoken(login.Email, login.Password);
                                    logR.UserName      = name;
                                    logR.Phonenumber   = user.PhoneNumber;
                                    logR.UserId        = user.Id;
                                }

                                else
                                {
                                    logR.CheckedStatus = 1;
                                    logR.CheckInTime   = getcheckindetails.CheckInTime;
                                    logR.CurrentDate   = indianTime.Date;
                                    logR.ServerTime    = indianTime.TimeOfDay;
                                    logR.Status        = 2;
                                    logR.Message       = "LogIn Successful";
                                    logR.BearerCode    = logintoken(login.Email, login.Password);
                                    logR.UserName      = name;
                                    logR.Phonenumber   = user.PhoneNumber;
                                    logR.UserId        = user.Id;
                                }
                            }
                            else
                            {
                                logR.CheckedStatus = 0;
                                //logR.CheckInTime = getcheckindetails.CheckInTime;
                                logR.CurrentDate = indianTime.Date;
                                logR.ServerTime  = indianTime.TimeOfDay;
                                logR.Status      = 2;
                                logR.Message     = "LogIn Successful";
                                logR.BearerCode  = logintoken(login.Email, login.Password);
                                logR.UserName    = name;
                                logR.Phonenumber = user.PhoneNumber;
                                logR.UserId      = user.Id;
                            }
                        }

                        else
                        {
                            logR.Status     = 3;
                            logR.Message    = "Device is not registered";
                            logR.DeviceName = deviceinfo.DeviceName;
                            logR.UserId     = user.Id;
                        }
                    }
                    //for valid login
                }
                else
                {
                    // for invalid password
                    logR.Status  = 1;
                    logR.Message = "Invalid Password";
                }
            }
            else
            {
                logR.Status  = 0; //Invalid Email or User doesn't exists
                logR.Message = "Invalid Email";
            }
            return(new LogInResult(logR, Request));
        }
Пример #20
0
        public IHttpActionResult PostCheckInCheckOut(UserAttendanceViewModel login)
        {
            LogInData logR = new LogInData();

            string status = "NoMatch";


            var userdetails = generic.GetUserDetail(login.UserId);

            Int64 branchId = db.EmpJoiningDetail.Where(e => e.UserId == userdetails.UserId).FirstOrDefault().BranchId;

            var Ipdata = db.IpMasters.Where(c => c.UserId == userdetails.SubscriberId && c.BranchId == branchId).ToList();

            TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            DateTime     indianTime  = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);

            DateTime currentDate = indianTime.Date;
            TimeSpan CurrentTime = indianTime.TimeOfDay;

            if (Ipdata != null)
            {
                var branchlocation = Ipdata.FirstOrDefault();

                if (branchlocation.Authenticate == 1)
                {
                    if (login.LoggedInIp == branchlocation.IPAddressFrom || login.LoggedInIp == branchlocation.IPAddressTo)
                    {
                        status = submitAttendance(login.UserId, userdetails.SubscriberId, login.LoggedInIp, login.Latitude, login.Longitude, currentDate, CurrentTime);
                    }
                }
                else if (branchlocation.Authenticate == 2)
                {
                    if (login.Latitude >= branchlocation.LatitudeFrom && login.Latitude <= branchlocation.LatitudeTo && login.Longitude >= branchlocation.LongitudeFrom && login.Longitude <= branchlocation.LongitudeTo)
                    {
                        status = submitAttendance(login.UserId, userdetails.SubscriberId, login.LoggedInIp, login.Latitude, login.Longitude, currentDate, CurrentTime);
                    }
                }
                else if (branchlocation.Authenticate == 3)
                {
                    if ((login.LoggedInIp == branchlocation.IPAddressFrom || login.LoggedInIp == branchlocation.IPAddressTo) && (login.Latitude >= branchlocation.LatitudeFrom && login.Latitude <= branchlocation.LatitudeTo && login.Longitude >= branchlocation.LongitudeFrom && login.Longitude <= branchlocation.LongitudeTo))
                    {
                        status = submitAttendance(login.UserId, userdetails.SubscriberId, login.LoggedInIp, login.Latitude, login.Longitude, currentDate, CurrentTime);
                    }
                }

                if (status == "CheckedIn")
                {
                    logR.CheckedStatus  = 1;//checked in
                    logR.CheckInTime    = CurrentTime;
                    logR.CurrentDate    = indianTime.Date;
                    logR.ServerTime     = CurrentTime;
                    logR.LocationStatus = 1;
                }
                else
                {
                    logR.CheckedStatus  = 2; //checked Out
                    logR.CheckInTime    = db.BiometricCheckInCheckOut.Where(c => c.UserId == login.UserId && c.CheckInDate == indianTime.Date).FirstOrDefault().CheckInTime;
                    logR.CheckOutTime   = CurrentTime;
                    logR.CurrentDate    = indianTime.Date;
                    logR.ServerTime     = CurrentTime;
                    logR.LocationStatus = 1;
                }
            }
            else
            {
                logR.LocationStatus = 0;
                logR.CurrentDate    = indianTime.Date;
                logR.ServerTime     = indianTime.TimeOfDay;
            }

            //var userdetails = generic.GetUserDetail(login.UserId);
            //var Ipdata = db.IpMasters.Where(c => c.UserId == userdetails.SubscriberId).ToList();

            //TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            //DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            //if (Ipdata != null)
            //{
            //    var finalipMatch = Ipdata.Where(c => c.LatitudeFrom <= login.Latitude && c.LatitudeTo >= login.Latitude && c.LongitudeFrom <= login.Longitude && c.LongitudeTo >= login.Longitude).FirstOrDefault();
            //    //var finalipMatch = Ipdata.Where(c => c.IPAddressFrom == IpRangeofUser || c.IPAddressTo == IpRangeofUser).FirstOrDefault();
            //    if (finalipMatch != null)
            //    {

            //        var getcheckindetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == login.UserId && c.CheckInDate == indianTime.Date).FirstOrDefault();
            //        if (getcheckindetails == null)
            //        {
            //            //Default 0 fro adding new record
            //            Int64 BiometricId = 0;


            //            DateTime checkindate = indianTime.Date;
            //            TimeSpan CheckInTime = indianTime.TimeOfDay;

            //            Int64 ShiftId = 1;
            //            bool result = admin.AddEmployeeCheckinCheckout(BiometricId, login.UserId, checkindate, CheckInTime, null, null, login.LoggedInIp, userdetails.SubscriberId, ShiftId);
            //            logR.CheckedStatus = 1;//checked in
            //            logR.CheckInTime = CheckInTime;
            //            logR.CurrentDate = checkindate;
            //            logR.ServerTime = indianTime.TimeOfDay;
            //            logR.LocationStatus = 1;
            //        }
            //        else
            //        {
            //            var BiometricDetails = db.BiometricCheckInCheckOut.Where(c => c.UserId == login.UserId).ToList().OrderByDescending(d => d.CheckInDate).FirstOrDefault();
            //            //DateTime? checkoutdate = DateTime.Now.Date;
            //            //TimeSpan? CheckoutTime = DateTime.Now.TimeOfDay;
            //            DateTime checkoutdate = indianTime.Date;
            //            TimeSpan CheckoutTime = indianTime.TimeOfDay;


            //            Int64 ShiftId = 1;
            //            bool res = admin.AddEmployeeCheckinCheckout(BiometricDetails.BiometricId, login.UserId, BiometricDetails.CheckInDate, BiometricDetails.CheckInTime, checkoutdate, CheckoutTime, login.LoggedInIp, BiometricDetails.SubscriberId, ShiftId);
            //            logR.CheckedStatus = 2; //checked Out
            //            logR.CheckInTime = getcheckindetails.CheckInTime;
            //            logR.CheckOutTime = CheckoutTime;
            //            logR.CurrentDate = checkoutdate;
            //            logR.ServerTime = indianTime.TimeOfDay;
            //            logR.LocationStatus = 1;
            //        }

            //    }
            //    else
            //    {
            //        logR.LocationStatus = 0;
            //        logR.CurrentDate = indianTime.Date;
            //        logR.ServerTime = indianTime.TimeOfDay;
            //    }
            //}
            return(new LogInResult(logR, Request));
        }