public static string ReadReg(string Title, string keyName)//ReadLocal  value to Reg
        {
            //Title = EncryptionDecryption.Encrypt(Title, "9946");
            //keyName = EncryptionDecryption.Encrypt(keyName, "9946");

            string      t;
            RegistryKey Test = Registry.CurrentUser.OpenSubKey(Title);

            try
            {
                if (Test != null)
                {
                    Test.OpenSubKey(keyName);
                    t = Test.GetValue(keyName).ToString();
                }
                else
                {
                    t = null;
                }
                return(EncryptionDecryption.Decrypt(t, MyShopConfigration.EncyKey));
            }
            catch (NullReferenceException)
            {
                return(null);
            }
        }
Example #2
0
        public async Task <ActionResult> ChangePassword(PasswordChange std)
        {
            await Task.Delay(0);

            Response res = new Response();
            var      Id  = EncryptionDecryption.Decrypt(std.id);

            DataTable table = SQLDatabase.GetDataTable("SELECT * FROM users WHERE Id='" + Id + "' AND Password='******'");

            if (table.Rows.Count > 0)
            {
                if (SQLDatabase.ExecNonQuery("update users set Password='******' where Id='" + Id + "'") > 0)
                {
                    res.Status = "Password Update Successfully";
                }
                else
                {
                    res.Status = "Password Updation Failed";
                }
            }
            else
            {
                res.Status = "Old Password is Incorrect";
            }

            return(Ok(res));
        }
Example #3
0
        public async Task <ActionResult> DeleteUser(Students std)
        {
            await Task.Delay(0);

            Response res = new Response();

            var Deactivebyid = std.Deactivebyid;

            if (Deactivebyid == "" || Deactivebyid == null)
            {
                Deactivebyid = std.Deactivebyid;
            }
            else
            {
                Deactivebyid = EncryptionDecryption.Decrypt(std.Deactivebyid);
            }
            res.id = std.Id;
            if (SQLDatabase.ExecNonQuery("update users set Status=0, DeactiveDateTime='" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "', Deactivebyid='" + Deactivebyid + "' where Id=" + std.Id) > 0)
            {
                res.Status = "Delete Successfully";
            }
            else
            {
                res.Status = "Deletion Failed";
            }

            return(Ok(res));
        }
Example #4
0
        public async Task <ActionResult> GetAllUser(Students std)
        {
            await Task.Delay(0);

            string    Uid   = EncryptionDecryption.Decrypt(std.str1);
            DataTable table = SQLDatabase.GetDataTable("select Id,Name,FatherName,Email,PhoneNumber,Gender,Address,Image from users where Status='1' ");

            return(Ok(table));
        }
        public async Task <IActionResult> GetBindStudent(Students std)
        {
            await Task.Delay(0);

            string    Uid   = EncryptionDecryption.Decrypt(std.str1);
            DataTable table = SQLDatabase.GetDataTable("SELECT (bindstudent.Id) AS bsid,(users.Name) AS StudentName, (courses.Coursetitle) AS CourseTitle, (bindstudent.InsertedDateTime) AS bsdatetime FROM users INNER JOIN bindstudent on bindstudent.StudentId=users.Id and bindstudent.Status=1 INNER JOIN courses ON bindstudent.CourseId=courses.Courseid");

            return(Ok(table));
        }
        public async Task <ActionResult> GetAllCourses(Students std)
        {
            await Task.Delay(0);

            string    Uid   = EncryptionDecryption.Decrypt(std.str1);
            DataTable table = SQLDatabase.GetDataTable("select Courseid, Coursetitle, Description, Fee from courses where Status='1' ");

            return(Ok(table));
        }
Example #7
0
        public async Task <ActionResult> UserProfile(Students std)
        {
            await Task.Delay(0);

            Response  res   = new Response();
            var       Id    = EncryptionDecryption.Decrypt(std.str1);
            DataTable table = SQLDatabase.GetDataTable("select Name,FatherName,Email,PhoneNumber,Gender,Address,Username from users where Id=" + Id + "");

            return(Ok(table));
        }
Example #8
0
        public async Task <ActionResult> GetUserData(Students std)
        {
            await Task.Delay(0);

            var Uid    = std.str1;
            var userId = EncryptionDecryption.Decrypt(Uid);

            DataTable table = SQLDatabase.GetDataTable("SELECT Name,Image FROM users where Id='" + userId + "'");

            return(Ok(table));
        }
Example #9
0
        private static void AppEventsManager_OnUpdateConnectionString()
        {
            // 获取连接字符串
            string baseXPath  = "/Application/ConnectionString/";
            string dataSource = XmlUtil.XmlGetElementText(XmlUtil.AppConfig, baseXPath + "DataSource");
            string catalog    = XmlUtil.XmlGetElementText(XmlUtil.AppConfig, baseXPath + "InitialCatalog");
            string userId     = XmlUtil.XmlGetElementText(XmlUtil.AppConfig, baseXPath + "UserId");
            string password   = XmlUtil.XmlGetElementText(XmlUtil.AppConfig, baseXPath + "Password");

            password   = EncryptionDecryption.Decrypt(password);
            connString = "Data Source=" + dataSource + ";Initial Catalog=" + catalog + ";User Id=" + userId + ";Password="******";";
        }
 protected void btn_Submit_Click(object sender, EventArgs e)
 {
     try
     {
         Config  config = new Config();
         DataSet ds     = new DataSet();
         ds = config.UserEmailExist(txtemail.Text);
         if (ds.Tables.Count > 0)
         {
             if (ds.Tables[0].Rows.Count > 0)
             {
                 if (Convert.ToInt32(ds.Tables[0].Rows[0]["user_status"]) == 1)
                 {
                     string password           = ds.Tables[0].Rows[0]["Password"].ToString();
                     string getpasswordfromkey = EncryptionDecryption.Decrypt(password);
                     string pwd = EncryptionDecryption.Decrypt(txtpassword.Text);
                     if (getpasswordfromkey == pwd)
                     {
                         Session["username"] = ds.Tables[0].Rows[0]["FirstName"].ToString();
                         Session["userID"]   = ds.Tables[0].Rows[0]["UserID"].ToString();
                         Session["Role"]     = ds.Tables[0].Rows[0]["Role"].ToString();
                         Response.Redirect("Default.aspx");
                     }
                     else
                     {
                         txtemail.BackColor = System.Drawing.ColorTranslator.FromHtml("#fff");
                         //txtemail.BackColor = System.Drawing.ColorTranslator.FromHtml("#8BE7FF");
                         lblmessage.Text = "Wrong Password,Please Enter right password.";
                     }
                 }
                 else
                 {
                     lblmessage.Text = "User is inActive.";
                 }
             }
             else
             {
                 //txtemail.Focus();
                 //txtemail.Text.Length
                 txtemail.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFE0");
                 lblmessage.Text    = "UserName does not exist";
                 //return;
                 //lblmessage.Text = "User Not Exist.";
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #11
0
        public async Task <ActionResult> InsertData(Students std)
        {
            await Task.Delay(0);

            Response res = new Response();

            DataTable table = SQLDatabase.GetDataTable("select* from users where Email='" + std.Email + "'");

            if (table.Rows.Count > 0)
            {
                res.Status = "Email Matched";
            }
            else
            {
                DataTable table1 = SQLDatabase.GetDataTable("select* from users where Username='******'");

                if (table1.Rows.Count > 0)
                {
                    res.Status = "Username Matched";
                }
                else
                {
                    var UserImage = "/assets/img/faces/card-profile1-square.jpg";

                    var Insertedbyid = std.Insertedbyid;

                    if (Insertedbyid == "" || Insertedbyid == null)
                    {
                        Insertedbyid = std.Insertedbyid;
                    }
                    else
                    {
                        Insertedbyid = EncryptionDecryption.Decrypt(std.Insertedbyid);
                    }

                    if (SQLDatabase.ExecNonQuery("insert into users (Name,FatherName,PhoneNumber,Email,Gender,Address,Username,Password,Image,Status,InsertedDateTime,Insertedbyid) values ('" + std.Name + "','" + std.FatherName + "','" + std.PhoneNumber + "','" + std.Email + "','" + std.Gender + "','" + std.Address + "','" + std.Username + "','" + EncryptionDecryption.Encrypt(std.Password) + "','" + UserImage + "',1,'" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','" + Insertedbyid + "')") > 0)
                    {
                        res.Status = "Inserted Successfully";
                    }
                    else
                    {
                        res.Status = "Insertion failed";
                    }
                }
            }
            return(Ok(res));
        }
Example #12
0
        public async Task <ActionResult> ChangeProfileImage()
        {
            await Task.Delay(0);

            _environment.WebRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot");

            string StudentId = Request.Form["StudentId"].ToString();

            if (Request.Form.Files.Count > 0)
            {
                string FileCompletePath = "";
                string FileExtention    = "";
                string UniqueId         = "";
                string BAsePath         = "";
                for (int i = 0; i < Request.Form.Files.Count; i++)
                {
                    BAsePath         = _environment.WebRootPath + "/uploads/";
                    UniqueId         = Guid.NewGuid().ToString();
                    FileExtention    = Path.GetExtension(Request.Form.Files[i].FileName);
                    FileCompletePath = BAsePath + UniqueId + FileExtention;


                    using (var FileUploadingStream = new FileStream(FileCompletePath, FileMode.Create))
                    {
                        Request.Form.Files[i].CopyTo(FileUploadingStream);
                    }
                    var userId = EncryptionDecryption.Decrypt(StudentId);

                    var filespath = "/uploads/" + UniqueId + FileExtention;

                    if (SQLDatabase.ExecNonQuery("UPDATE users SET Image = '" + filespath + "' WHERE Id =" + userId + "") == 0)
                    {
                        return(Ok("File Uploaded But File Address Not Save Database"));
                    }
                }

                return(Ok("File Uploaded successfully"));
            }
            else
            {
                return(Ok("No File Uploaded"));
            }
        }
        public async Task <ActionResult> InsertCourses(Courses std)
        {
            await Task.Delay(0);

            Response res          = new Response();
            var      Insertedbyid = EncryptionDecryption.Decrypt(std.Insertedbyid);


            if (SQLDatabase.ExecNonQuery("insert into courses (Coursetitle,Description,Fee,Status,InsertedDateTime,Insertedbyid) values ('" + std.Coursetitle + "','" + std.Description + "','" + std.Fee + "',1,'" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','" + Insertedbyid + "')") > 0)
            {
                res.Status = "Inserted Successfully";
            }
            else
            {
                res.Status = "Insertion failed";
            }


            return(Ok(res));
        }
 public void EncryptTest()
 {
     Console.WriteLine(EncryptionDecryption.Encrypt("PY-123456"));
     Console.WriteLine(EncryptionDecryption.Decrypt("Jb0JxAiP41QAKVPMlagmtQ=="));
 }
Example #15
0
        /// <summary>
        /// Sets constants response from resource file and stores the refresh token in the cookie.
        /// </summary>
        /// <param name="request">Request Object</param>
        /// <param name="response">Response Object</param>
        /// <param name="queryStringCookieName">Cookie Name</param>
        /// <param name="redirectURL">Redirect URL</param>
        /// <param name="constantFileObject">Object to fetch constants from resource file</param>
        /// <param name="constantFile">Name of the app specific resource file</param>
        internal static void SetConstantsResponse(HttpRequest request, HttpResponse response, string redirectURL, string constantFileObject, string constantFile)
        {
            string refreshToken = string.Empty;

            try
            {
                bool environment = Convert.ToBoolean(UIConstantStrings.IsDeployedOnAzure, CultureInfo.InvariantCulture);
                if (environment)
                {
                    //// Check if page loaded due to Token Request failure issue (Query string will contain IsInvalidToken parameter)
                    if (request.Url.Query.ToString().ToUpperInvariant().Contains(UIConstantStrings.TokenRequestFailedQueryString.ToUpperInvariant()))
                    {
                        refreshToken = SetMatterCenterCookie(request, response, redirectURL, constantFileObject, constantFile, true);
                    }
                    else
                    {
                        refreshToken = (null != request.Cookies[UIConstantStrings.refreshToken]) ? request.Cookies[UIConstantStrings.refreshToken].Value : string.Empty;
                    }
                    if (string.IsNullOrWhiteSpace(refreshToken))
                    {
                        refreshToken = SetMatterCenterCookie(request, response, redirectURL, constantFileObject, constantFile, false);
                    }
                    else
                    {
                        string DecryptedrefreshToken = string.Empty;
                        string key = ConfigurationManager.AppSettings["Encryption_Key"];
                        if (!string.IsNullOrWhiteSpace(key))
                        {
                            DecryptedrefreshToken = EncryptionDecryption.Decrypt(refreshToken, key);
                            if (!string.IsNullOrWhiteSpace(DecryptedrefreshToken))
                            {
                                SetResponse(request, response, constantFileObject, constantFile, refreshToken);
                                response.Write(UIUtility.SetSharePointResponse(refreshToken));
                            }
                            else
                            {
                                key = ConfigurationManager.AppSettings["Old_Encryption_Key"];
                                if (!string.IsNullOrWhiteSpace(key))
                                {
                                    DecryptedrefreshToken = EncryptionDecryption.Decrypt(refreshToken, key);
                                    if (!string.IsNullOrWhiteSpace(DecryptedrefreshToken))
                                    {
                                        request.Cookies[UIConstantStrings.refreshToken].Value = refreshToken = EncryptionDecryption.Encrypt(DecryptedrefreshToken);
                                        SetResponse(request, response, constantFileObject, constantFile, refreshToken);
                                        response.Write(UIUtility.SetSharePointResponse(refreshToken));
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    SetResponse(request, response, constantFileObject, constantFile, refreshToken);
                    response.Write(UIUtility.SetSharePointResponse(refreshToken));
                }
            }
            catch (Exception exception)
            {
                string result = Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, UIConstantStrings.LogTableName);
                response.Write(GenericFunctions.SetErrorResponse(ConstantStrings.TRUE, result));
            }
        }