//User Login public LoginCL User_Login(User_LoginIN user_Login) { //Initialize Logger log4net.Config.XmlConfigurator.Configure(); //Initialize Logger LoginCL results_final = new LoginCL(); try { string objUSER_AGENT = Common.USER_AGENT(); if (objUSER_AGENT != ConfigurationManager.AppSettings["User-Agent"].ToString()) { ctx.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode) 401; goto Finish; } //get IPAddress OperationContext context = OperationContext.Current; MessageProperties messageProperties = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; //get IPAddress string encPWD = Common.Password_Encrypt(user_Login.password); Hashtable parameters = new Hashtable(); parameters.Clear(); parameters.Add("@EMAIL", user_Login.email); parameters.Add("@PASSWORD", encPWD); parameters.Add("@IPADDRESS", endpointProperty.Address + ":" + endpointProperty.Port); parameters.Add("@MODE", "LOGIN"); DataSet dsrec = objDb.senddataset_SP("GC_REGISTRATION_PRC", parameters); if (dsrec.Tables[0].Rows.Count > 0) { if (dsrec.Tables[0].Rows[0]["RSTATUS"].ToString().ToLower() == "invalid") { //ctx.OutgoingResponse.StatusCode = HttpStatusCode.NoContent; ctx.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode) 211; goto Finish; } if (dsrec.Tables[0].Rows[0]["RSTATUS"].ToString().ToLower() == "email not verified") { //Send email verification mail here.. //ctx.OutgoingResponse.StatusCode = HttpStatusCode.NoContent; ctx.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode) 415; goto Finish; } if (dsrec.Tables[0].Rows[0]["RSTATUS"].ToString().ToLower() == "user blocked") { ctx.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode) 419; goto Finish; } //string objResponse = string.Empty; //Int32 objRegistrationId = Convert.ToInt32(dsrec.Tables[0].Rows[0]["REGISTRATIONID"].ToString()); //if (objRegistrationId == 0) //{ // ctx.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode)211; // goto Finish; //} results_final.RegistrationId = objDb.ENC_REGID(Convert.ToInt32(dsrec.Tables[0].Rows[0]["REGISTRATIONID"].ToString())); results_final.name = dsrec.Tables[0].Rows[0]["NAME"].ToString(); results_final.email = dsrec.Tables[0].Rows[0]["EMAIL"].ToString(); results_final.mobile = dsrec.Tables[0].Rows[0]["MOBILE"].ToString(); results_final.SERVER_DATETIME = Common.GetUTCdatetime_epoch(); } else { ctx.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode) 211; } Finish: return(results_final); } catch (Exception ex) { ctx.OutgoingResponse.StatusCode = HttpStatusCode.InternalServerError; logger.Error("User.svc/User_Login: "******"::" + ex.StackTrace.ToString()); return(results_final); } }
private void btnLogin_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtUserName.Text.Trim())) { this.rectangleShape1.BorderColor = Color.FromArgb(251, 51, 51); this.txtUserName.Focus(); } else if (String.IsNullOrEmpty(txtPassword.Text.Trim())) { this.rectangleShape2.BorderColor = Color.FromArgb(251, 51, 51); this.txtPassword.Focus(); } else { this.rectangleShape1.BorderColor = Color.FromArgb(225, 225, 225); this.rectangleShape2.BorderColor = Color.FromArgb(225, 225, 225); try { //var rowCount = 0; //using (OleDbConnection OConn = new OleDbConnection(Program.ConnectionStr)) //{ // OConn.Open(); // OleDbCommand cmd = new OleDbCommand("SELECT COUNT(*) FROM employees", OConn); // int.TryParse(cmd.ExecuteScalar()+"", out rowCount); // //OleDbCommand cmd = new OleDbCommand("SELECT password FROM employees WHERE user = '******'", OConn); //} //if(rowCount > 0) //{ // //try Login //} //else //{ // //Show Message for Sync. // //Sync all api altogether. //} string URL = Program.BaseUrl; string LoginUrl = URL + "/login?username="******"&password="******""); JavaScriptSerializer serializer = new JavaScriptSerializer(); LoginCL result = serializer.Deserialize <LoginCL>(GetLoginDetails); if (result.message == "success") { this.Hide(); Program.IsLogined = true; Program.SessionId = result.sessionid; Program.OutletType = result.outlet_Type; Program.Token = result.data; } else { Program.IsLogined = false; MessageBox.Show("Login Failed For User ?", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Program.IsLogined = false; var err = ex.Message; MessageBox.Show(ex.Message, "Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }