static void Main(string[] args) { Console.WriteLine("..........File Bytes........."); string file = @"D:\Atbash.exe"; //File Will Be Encrypted <--------------- string key = "abcde"; byte[] fileBytes = File.ReadAllBytes(file); for (int i = 0; i <= fileBytes.Length - 1; i++) { Console.Write(fileBytes[i] + " "); } Console.WriteLine("\n \n"); Console.WriteLine("..........File Encrypted Bytes........."); byte[] fileEncryptedBytes = EncryptionClass.Encryption(file, key); File.WriteAllBytes(@"D:\AtbashEncrypt.exe", fileEncryptedBytes); string fileE = @"D:\AtbashEncrypt.exe"; //You want this file name in Excute programe for (int i = 0; i <= fileEncryptedBytes.Length - 1; i++) { //File Encrypted Byte Copy output To paste in Excute Programe Console.Write(fileEncryptedBytes[i] + " "); } Console.WriteLine("\n \n"); Console.WriteLine("..........File Decrypted Bytes........."); byte[] fileDecryptedBytes = EncryptionClass.Decryption(fileE, key); for (int i = 0; i <= fileDecryptedBytes.Length - 1; i++) { Console.Write(fileDecryptedBytes[i] + " "); } Console.ReadKey(); }
private void Load_MRP(string docnumber) { string query = "SELECT TOP (100) PERCENT tbl_MRP_List.*, vw_AXEntityTable.NAME AS EntityCodeDesc, vw_AXOperatingUnitTable.NAME AS BUCodeDesc, tbl_MRP_Status.StatusName, tbl_Users.Lastname, tbl_Users.Firstname FROM tbl_MRP_List LEFT OUTER JOIN tbl_Users ON tbl_MRP_List.CreatorKey = tbl_Users.PK LEFT OUTER JOIN vw_AXOperatingUnitTable ON tbl_MRP_List.BUCode = vw_AXOperatingUnitTable.OMOPERATINGUNITNUMBER LEFT OUTER JOIN tbl_MRP_Status ON tbl_MRP_List.StatusKey = tbl_MRP_Status.PK LEFT OUTER JOIN vw_AXEntityTable ON tbl_MRP_List.EntityCode = vw_AXEntityTable.ID WHERE dbo.tbl_MRP_List.DocNumber = '" + docnumber + "' ORDER BY dbo.tbl_MRP_List.DocNumber DESC"; SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { mrp_key = Convert.ToInt32(reader["PK"].ToString()); entitycode = reader["EntityCode"].ToString(); DocNum.Text = reader["DocNumber"].ToString(); DateCreated.Text = reader["DateCreated"].ToString(); EntityCode.Text = reader["EntityCodeDesc"].ToString(); BUCode.Text = reader["BUCodeDesc"].ToString(); buCode = reader["BUCode"].ToString(); Month.Text = MRPClass.Month_Name(Int32.Parse(reader["MRPMonth"].ToString())); Year.Text = reader["MRPYear"].ToString(); Status.Text = reader["StatusName"].ToString(); firstname = reader["Firstname"].ToString(); lastname = reader["Lastname"].ToString(); } reader.Close(); conn.Close(); Creator.Text = EncryptionClass.Decrypt(firstname) + " " + EncryptionClass.Decrypt(lastname); iStatusKey = MRPClass.MRP_Line_Status(mrp_key, wrkflwln); }
public static void Main(string[] args) { WorkWithConsoleClass workWithConsoleClass = new WorkWithConsoleClass(); WorkWithFileClass workWithFileClass = new WorkWithFileClass(); EncryptionClass encryptionClass = new EncryptionClass(); CongruentialGeneratorClass congruentialGeneratorClass = new CongruentialGeneratorClass(); int a = workWithConsoleClass.InputA(); int c = workWithConsoleClass.InputC(); int startValue = workWithConsoleClass.InputStartValue(); int m = workWithConsoleClass.InputM(); var inputFile = workWithFileClass.ReadFile(); var keyWord = congruentialGeneratorClass.CongruentialGenerator(a, c, m, startValue, inputFile.Length); var binaryCodeOfAlphabet = workWithFileClass.GetBinaryCodeOfAlphabet(); var decimalCodeAndLetterOfAlphabet = workWithFileClass.GetDecimalCodeAndLetterOfAlphabet(); var encryptedMessage = encryptionClass.Encryption(inputFile, keyWord, binaryCodeOfAlphabet, decimalCodeAndLetterOfAlphabet); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, keyWord, binaryCodeOfAlphabet, decimalCodeAndLetterOfAlphabet); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }
public static void Main(string[] args) { WorkWithFileClass workWithFileClass = new WorkWithFileClass(); WorkWithConsoleClass workWithConsoleClass = new WorkWithConsoleClass(); EncryptionClass encryptionClass = new EncryptionClass(); var inputMessage = workWithFileClass.ReadFile(); int m = workWithFileClass.GetAlphabetLength(); int n = workWithConsoleClass.ReadNFromConsole(); while (encryptionClass.GCD(n, m) != 1) { n = workWithConsoleClass.ReadAnotherNFromConsole(); } int k = workWithConsoleClass.ReadKFromConsole(); var numCodeOfAlphabet = workWithFileClass.GetNumCodeOfAlphabet(); var encryptedMessage = encryptionClass.Encryption(inputMessage, numCodeOfAlphabet, n, k, m); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, numCodeOfAlphabet, k, n, m); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }
public bool VerifyHash(string plainText, string hashAlgorithm, string hashValue, string saltValue) { bool isMatch; EncryptionClass _Encrypton = new EncryptionClass(); try { // Make sure that hashing algorithm name is specified. if ((hashAlgorithm == null)) { hashAlgorithm = ""; } // Compute a new hash string. var expectedHashString = _Encrypton.ComputeHash(plainText, hashAlgorithm, saltValue); // If the computed hash matches the specified hash, // the plain text value must be correct. isMatch = (hashValue == expectedHashString); } catch (Exception ex) { return(false); } return(isMatch); }
public static List <String> GetSelectCols(Model mode) { List <String> result = new List <string>(); foreach (var property in mode.Properties.Where(p => p.IsArray == false && p.AutoGenerationType != Data.Discription.ORM.GenerationType.OnInSert)) { if (property.PropertyType == PropertyType.RadomDECS) { result.AddRange(EncryptionClass.GetPropertyCols(property)); } else { if (String.IsNullOrEmpty(property.DBName) == false) { result.Add(property.DBName); } result.AddRange(property.DBMaps.Where(p => String.IsNullOrEmpty(p.DBColName) == false).Select(q => q.DBColName)); } } var keyCol = GetKeyCol(mode); if (result.Contains(keyCol) == false) { result.Add(keyCol); } return(result); }
protected void btnExamLMS_ServerClick(object sender, EventArgs e) { //rwm_message.RadAlert("سامانه در حال آماده سازی میباشد.", null, 100, "پیام", ""); //return; bool linkIsActive; if (ConfigurationManager.AppSettings["ExamLinkActive"] == null || string.IsNullOrEmpty(ConfigurationManager.AppSettings["ExamLinkActive"].ToString()) || !bool.TryParse(ConfigurationManager.AppSettings["ExamLinkActive"].ToString(), out linkIsActive) || !linkIsActive) { rwm_message.RadAlert("لطفا در زمان مقرر مراجعه فرمایید", null, 100, "پیام", ""); } else { ExamBusiness ExamBusiness = new ExamBusiness(); SHA256 mySHA256 = SHA256Managed.Create(); var profInfo = ExamBusiness.GetProfessorInfoByProfessorCode(Session[sessionNames.userID_StudentOstad].ToString()); if (profInfo.Rows.Count > 0) { var key = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(ConfigurationManager.AppSettings["ExamLinkKey"].ToString())); var IV = string.IsNullOrEmpty(ConfigurationManager.AppSettings["ExamLinkIV"].ToString()) ? new byte[16] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } : Encoding.ASCII.GetBytes(ConfigurationManager.AppSettings["ExamLinkIV"].ToString()); var url = ConfigurationManager.AppSettings["ExamLink"].ToString(); var token = EncryptionClass.EncryptAES256(Session[sessionNames.userID_StudentOstad].ToString() + ";" + profInfo.Rows[0]["idd_meli"].ToString() + ";" + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"), key, IV); var script = "var form = document.createElement('form'); form.setAttribute('style', 'display: none;'); var tokenField = document.createElement('input'); form.method = 'POST'; form.action = '" + url + "';"; script += "tokenField.value='" + token + "'; tokenField.name='token'; form.appendChild(tokenField); document.body.appendChild(form); form.submit();"; ScriptManager.RegisterStartupScript(this, GetType(), "submitform", script, true); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ScriptManager.RegisterStartupScript(this.Page, typeof(string), "Resize", "changeWidth.resizeWidth();", true); //Session["mrp_docNum"] = docnumber.ToString(); //Session["mrp_wrkLine"] = wrkflwln.ToString(); //string docnumber = Request.Params["DocNum"].ToString(); string docnumber = Session["mrp_docNum"].ToString(); int source = Convert.ToInt32(Session["mrp_source"]); string query = "SELECT dbo.tbl_MRP_List.DocNumber, dbo.tbl_MRP_List.MRPMonth, dbo.tbl_MRP_List.MRPYear, dbo.tbl_MRP_List.DateCreated, dbo.vw_AXEntityTable.NAME AS EntityName, dbo.vw_AXOperatingUnitTable.NAME AS BU, dbo.tbl_Users.Firstname, dbo.tbl_Users.Lastname, dbo.tbl_MRP_Status.StatusName FROM dbo.tbl_MRP_List LEFT OUTER JOIN dbo.vw_AXEntityTable ON dbo.tbl_MRP_List.EntityCode = dbo.vw_AXEntityTable.ID LEFT OUTER JOIN dbo.vw_AXOperatingUnitTable ON dbo.tbl_MRP_List.BUCode = dbo.vw_AXOperatingUnitTable.OMOPERATINGUNITNUMBER LEFT OUTER JOIN dbo.tbl_Users ON dbo.tbl_MRP_List.CreatorKey = dbo.tbl_Users.PK LEFT OUTER JOIN dbo.tbl_MRP_Status ON dbo.tbl_MRP_List.StatusKey = dbo.tbl_MRP_Status.PK WHERE DocNumber = '" + docnumber + "'"; SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { DocNum.Text = reader["DocNumber"].ToString(); Month.Text = Convertion.INDEX_TO_MONTH(Convert.ToInt32(reader["MRPMonth"].ToString())); Year.Text = reader["MRPYear"].ToString(); Entity.Text = reader["EntityName"].ToString(); Department.Text = reader["BU"].ToString(); Status.Text = reader["StatusName"].ToString(); Creator.Text = EncryptionClass.Decrypt(reader["Firstname"].ToString()) + " " + EncryptionClass.Decrypt(reader["Lastname"].ToString()); DateCreated.Text = reader["DateCreated"].ToString(); } BindGrid(docnumber); } }
protected void Button1_Click(object sender, EventArgs e) { byte[] strPath = Convert.FromBase64String(TextBox1.Text); string pass = EncryptionClass.DecryptRJ256(strPath); Response.Write(pass); }
protected void btnChangePW_Click(object sender, EventArgs e) { if (captcha.IsValid && ASPxEdit.ValidateEditorsInContainer(this)) { //PopupChangePW.HeaderText = "Confirm"; //PopupChangePW.ShowOnPageLoad = true; string qry = "", _sPassword = ""; SqlCommand cmd = null; _sPassword = EncryptionClass.Encrypt(newPasswordCH.Text.ToString().Trim()); SqlConnection con = new SqlConnection(GlobalClass.SQLConnString()); con.Open(); qry = "UPDATE tbl_Users " + " SET Password = '******' " + " WHERE (PK = " + Session["CreatorKey"] + ")"; cmd = new SqlCommand(qry); cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); ModalPopupExtenderLoading.Hide(); Response.Redirect("home.aspx"); } }
private void Load_MRP(string docnum) { //string query = "SELECT TOP (100) PERCENT dbo.tbl_MRP_List.PK, dbo.tbl_MRP_List.DocNumber, " + // " dbo.tbl_MRP_List.DateCreated, dbo.tbl_MRP_List.EntityCode, dbo.vw_AXEntityTable.NAME AS EntityCodeDesc, " + // " dbo.tbl_MRP_List.BUCode, dbo.vw_AXOperatingUnitTable.NAME AS BUCodeDesc, dbo.tbl_MRP_List.MRPMonth, " + // " dbo.tbl_MRP_List.MRPYear, dbo.tbl_MRP_List.StatusKey, dbo.tbl_MRP_Status.StatusName, " + // " dbo.tbl_MRP_List.CreatorKey, dbo.tbl_MRP_List.LastModified " + // " FROM dbo.tbl_MRP_List LEFT OUTER JOIN " + // " dbo.vw_AXOperatingUnitTable ON dbo.tbl_MRP_List.BUCode = dbo.vw_AXOperatingUnitTable.OMOPERATINGUNITNUMBER LEFT OUTER JOIN " + // " dbo.tbl_MRP_Status ON dbo.tbl_MRP_List.StatusKey = dbo.tbl_MRP_Status.PK LEFT OUTER JOIN " + // " dbo.vw_AXEntityTable ON dbo.tbl_MRP_List.EntityCode = dbo.vw_AXEntityTable.ID " + // " WHERE(dbo.tbl_MRP_List.DocNumber = '" + DocNum.Text.ToString().Trim() + "') " + // " ORDER BY dbo.tbl_MRP_List.DocNumber DESC"; string query = "SELECT tbl_MRP_List.*, " + " vw_AXEntityTable.NAME AS EntityCodeDesc, " + " vw_AXOperatingUnitTable.NAME AS BUCodeDesc, " + " tbl_MRP_Status.StatusName, tbl_Users.Lastname, " + " tbl_Users.Firstname, tbl_MRP_List.EntityCode, " + " tbl_MRP_List.BUCode " + " FROM tbl_MRP_List LEFT OUTER JOIN tbl_Users ON tbl_MRP_List.CreatorKey = tbl_Users.PK " + " LEFT OUTER JOIN vw_AXOperatingUnitTable ON tbl_MRP_List.BUCode = vw_AXOperatingUnitTable.OMOPERATINGUNITNUMBER " + " LEFT OUTER JOIN tbl_MRP_Status ON tbl_MRP_List.StatusKey = tbl_MRP_Status.PK " + " LEFT OUTER JOIN vw_AXEntityTable ON tbl_MRP_List.EntityCode = vw_AXEntityTable.ID " + " WHERE dbo.tbl_MRP_List.DocNumber = '" + docnum + "' " + " ORDER BY dbo.tbl_MRP_List.DocNumber DESC"; SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { DocNum.Text = reader["DocNumber"].ToString(); //DateCreated.Text = reader["DateCreated"].ToString(); dateCreated = Convert.ToDateTime(reader["DateCreated"]); mrp_key = Convert.ToInt32(reader["PK"]); entitycode = reader["EntityCode"].ToString(); EntityCode.Text = reader["EntityCodeDesc"].ToString(); buCode = reader["BUCode"].ToString(); BUCode.Text = reader["BUCodeDesc"].ToString(); Month.Text = MRPClass.Month_Name(Int32.Parse(reader["MRPMonth"].ToString())); Year.Text = reader["MRPYear"].ToString(); //Status.Text = reader["StatusName"].ToString(); Creator.Text = EncryptionClass.Decrypt(reader["Firstname"].ToString()) + " " + EncryptionClass.Decrypt(reader["Lastname"].ToString()); Status.Text = reader["StatusName"].ToString(); } reader.Close(); conn.Close(); iStatusKey = MRPClass.MRP_ApprvLine_Status(mrp_key, appflwln); StatusHidden["hidden_preview_iStatusKey"] = iStatusKey; WorkLineHidden["hidden_preview_wrkflwln"] = appflwln; BindAll(); }
protected void UserList_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { ASPxGridView grid = sender as ASPxGridView; ASPxPageControl pageControl = grid.FindEditFormTemplateControl("UserPageControl") as ASPxPageControl; //ASPxTextBox entCode = pageControl.FindControl("EntityValue") as ASPxTextBox; ASPxComboBox entCode = pageControl.FindControl("EntityCode") as ASPxComboBox; ASPxTextBox buCode = pageControl.FindControl("BUValue") as ASPxTextBox; ASPxTextBox domainAcc = pageControl.FindControl("DomainAccount") as ASPxTextBox; ASPxTextBox userLevel = pageControl.FindControl("UserLevelValue") as ASPxTextBox; ASPxTextBox userStatus = pageControl.FindControl("UserStatusValue") as ASPxTextBox; SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); string PK = e.Keys[0].ToString(); string sEntCode = entCode.Value.ToString(); string sBUCode = buCode.Value.ToString(); string sDomainAcc = ""; if (domainAcc.Value != null) { sDomainAcc = EncryptionClass.Encrypt(domainAcc.Value.ToString()); } int sUserLevel = Convert.ToInt32(userLevel.Value.ToString()); int sUserStatus = Convert.ToInt32(userStatus.Value.ToString()); string update_User = "******" + " SET [EntityCode] = @EntCode, " + " [BUCode] = @BUCode, " + " [DomainAccount] = @DomainAccount, " + " [UserLevelKey] = @UserLevelKey, " + " [Active] = @Active " + " WHERE [PK] = @PK"; SqlCommand cmd = new SqlCommand(update_User, conn); cmd.Parameters.AddWithValue("@PK", PK); cmd.Parameters.AddWithValue("@EntCode", sEntCode); cmd.Parameters.AddWithValue("@BUCode", sBUCode); cmd.Parameters.AddWithValue("@DomainAccount", sDomainAcc); cmd.Parameters.AddWithValue("@UserLevelKey", sUserLevel); cmd.Parameters.AddWithValue("@Active", sUserStatus); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); conn.Close(); BindUserList(); e.Cancel = true; grid.CancelEdit(); }
public static void Main(string[] args) { WorkWithFileClass workWithFileClass = new WorkWithFileClass(); EncryptionClass encryptionClass = new EncryptionClass(); var keyPairs = encryptionClass.CreateKeyPairs(workWithFileClass.ReadAlphabetFile()); var encryptedMessage = encryptionClass.Encryption(workWithFileClass.ReadFile(), keyPairs); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, keyPairs); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }
public static void Main(string[] args) { WorkWithFileClass workWithFileClass = new WorkWithFileClass(); WorkWithConsole workWithConsole = new WorkWithConsole(); EncryptionClass encryptionClass = new EncryptionClass(); var keyWord = workWithConsole.InputKeyWordFromConsole(); var encryptedMessage = encryptionClass.Encryption(workWithFileClass.ReadFile(), keyWord, workWithFileClass.CreateVigenereTableFromFile()); var decryptedMessage = encryptionClass.Decryption(encryptedMessage, keyWord, workWithFileClass.CreateVigenereTableFromFile()); workWithFileClass.OutputResultToFile(encryptedMessage, decryptedMessage); }
public ActionResult Index() { var h = "EsSWxhhkcqfIvh4n1K83DOQynZmnoH3XvZo1APFl6/w="; var user = "******"; var hash = EncryptionClass.EncryptPass(user); var decrypt = EncryptionClass.DecryptPass(h); //JOPsUBHAck9T8bb96DGtLg == byte[] base64HashesPassword = Convert.FromBase64String(h); string pass = EncryptionClass.DecryptRJ256(base64HashesPassword); var decrypt256 = EncryptionClass.EncryptRJ(h); //DecryptRJ256 return(View()); }
private void Form1_Load(object sender, EventArgs e) { EncryptionClass encryption = new EncryptionClass(); for (int i = 0; i < c.Length; i++) { for (int j = 1; j < 6; j++) { s = encryption.RandomString(5, true); dictCoord.Add(c[i] + j.ToString(), s); } } foreach (KeyValuePair <string, string> item in dictCoord) { textBox1.Text += item.Key + " = " + item.Value + "\r\n"; } }
protected void OK_ChangePW_Click(object sender, EventArgs e) { string qry = "", _sPassword = ""; SqlCommand cmd = null; _sPassword = EncryptionClass.Encrypt(newPasswordCH.Text.ToString().Trim()); SqlConnection con = new SqlConnection(GlobalClass.SQLConnString()); con.Open(); qry = "UPDATE tbl_Users " + " SET Password = '******' " + " WHERE (PK = " + Session["CreatorKey"] + ")"; cmd = new SqlCommand(qry); cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); ModalPopupExtenderLoading.Hide(); Response.Redirect("home.aspx"); }
protected void POGrid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { ASPxGridView grid = sender as ASPxGridView; ASPxPageControl pageControl = grid.FindEditFormTemplateControl("GridPageControl") as ASPxPageControl; ASPxComboBox entity = pageControl.FindControl("EntityCode") as ASPxComboBox; ASPxTextBox entityname = pageControl.FindControl("EntityName") as ASPxTextBox; ASPxTextBox header = pageControl.FindControl("HeaderPath") as ASPxTextBox; ASPxTextBox line = pageControl.FindControl("LinePath") as ASPxTextBox; ASPxTextBox domain = pageControl.FindControl("Domain") as ASPxTextBox; ASPxTextBox uname = pageControl.FindControl("Uname") as ASPxTextBox; ASPxTextBox Pword = pageControl.FindControl("Pword") as ASPxTextBox; SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); string encrypted_password = EncryptionClass.Encrypt(Pword.Text); string insert = "INSERT INTO [dbo].[tbl_AXPOUploadingPath] ([Entity], [Entity Name], [POHeaderPath], [POLinePath], [Domain], [UserName], [Password]) VALUES (@Entity, @EntityName, @POHeaderPath, @POLinePath, @Domain, @UserName, @Password)"; SqlCommand cmd = new SqlCommand(insert, conn); cmd.Parameters.AddWithValue("@Entity", entity.Text); cmd.Parameters.AddWithValue("@EntityName", entityname.Text); cmd.Parameters.AddWithValue("@POHeaderPath", header.Text); cmd.Parameters.AddWithValue("@POLinePath", line.Text); cmd.Parameters.AddWithValue("@Domain", domain.Text); cmd.Parameters.AddWithValue("@UserName", uname.Text); cmd.Parameters.AddWithValue("@Password", encrypted_password); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); conn.Close(); grid.CancelEdit(); e.Cancel = true; BindGrid(); }
public LoginResponse Login(string userName, string passwrod, string returnUrl, string keepMeSignedIn) { var userData = new LoginResponse(); if (_db.Users.Any(x => x.Username == userName && x.Password == passwrod)) { var user = _db.Users.SingleOrDefault(x => x.Username == userName && x.isActive == "true"); if (user != null) { string Authkey = ConfigurationManager.AppSettings["AuthKey"]; userData.UTMZK = EncryptionClass.GetEncryptionKey(user.Username, Authkey); userData.UTMZV = EncryptionClass.GetEncryptionKey(user.Password, Authkey); userData.TimeStamp = DateTime.Now.ToString(CultureInfo.InvariantCulture); userData.Code = "200"; try { user.KeepMeSignedIn = keepMeSignedIn.Equals("true", StringComparison.OrdinalIgnoreCase)? "true" : "false"; _db.SaveChanges(); } catch (DbEntityValidationException e) { DbContextException.LogDbContextException(e); userData.Code = "500"; return(userData); } } else { userData.Code = "403"; } } else { userData.Code = "401"; } return(userData); }
public ResponseModel <String> ResetPasswordService(ResetPasswordRequest req) { var response = new ResponseModel <string>(); //EncryptionClass.GetDecryptionValue(req.Username, ConfigurationManager.AppSettings["AuthKey"]); if (_db.ForgetPasswords.Any(x => x.guid == req.Guid)) { var removeForgetPasswordData = _db.ForgetPasswords.SingleOrDefault(x => x.guid == req.Guid); _db.ForgetPasswords.Remove(removeForgetPasswordData); var userData = _db.Users.SingleOrDefault(x => x.Username == removeForgetPasswordData.Username); if (userData != null) { var password = EncryptionClass.Md5Hash(req.Password); userData.Password = password; userData.Locked = "false"; } try { _db.SaveChanges(); } catch (DbEntityValidationException e) { DbContextException.LogDbContextException(e); response.Status = 500; response.Message = "Internal Server Error."; Logger.Info("Save new Reseted Password : "******"Success"; return(response); } response.Status = 402; response.Message = "link expired"; return(response); }
public JsonResult Login(LoginRequest req) { var returnUrl = "/"; var referral = Request.QueryString["ref"]; var responseData = new LoginResponse(); if (req.Type == "web") { var loginService = new LoginService(); responseData = loginService.WebLogin(req.UserName, EncryptionClass.Md5Hash(req.Password), returnUrl, req.KeepMeSignedInCheckBox); } if (responseData.Code == "200") { var session = new M2ESession(req.UserName); TokenManager.CreateSession(session); responseData.UTMZT = session.SessionId; } var response = new ResponseModel <LoginResponse> { Status = Convert.ToInt32(responseData.Code), Message = "success", Payload = responseData }; return(Json(response)); }
protected void FloatCallbackPanel_Callback(object sender, CallbackEventArgsBase e) { //string type = e.Parameter.Substring(0, e.Parameter.IndexOf("-")); //int PK = Convert.ToInt32(e.Parameter.Substring(e.Parameter.IndexOf("-") + 1, e.Parameter.Length - (e.Parameter.IndexOf("-") + 1))); dvMOPSidePanel.Visible = false; dvItemSidePanel.Visible = false; string param = e.Parameter; string[] arrParam = param.Split('^'); string type = arrParam[0].ToString(); //MRPClass.PrintString(type + " - " + PK.ToString() + " - " + sEntCode + " - " + sBuCode + " - " + arrParam[4].ToString()) ; string description = "Description"; string descdata = "", sItemCode = ""; //SqlCommand cmd = new SqlCommand(); string query_1 = ""; string query_2 = ""; SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); DataTable dt = new DataTable(); SqlCommand cmd = null; SqlDataAdapter adp; if (type == "MOPList") { dvMOPSidePanel.Visible = true; int mopKey = Convert.ToInt32(arrParam[1].ToString()); string mopNum = ""; query_1 = "SELECT tbl_MRP_List.* FROM tbl_MRP_List WHERE (PK = " + mopKey + ")"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { mopNum = row["DocNumber"].ToString(); MOPDucNumber.Text = row["DocNumber"].ToString(); DataTable dtRecord = MRPClass.POListDetails(mopNum); grdMOPPOList.DataSource = dtRecord; grdMOPPOList.DataBind(); } } dt.Clear(); } else { dvItemSidePanel.Visible = true; int PK = Convert.ToInt32(arrParam[1]); string sEntCode = arrParam[2].ToString(); string sBuCode = arrParam[3].ToString(); List <object> fieldValues = new List <object>(); //this is for comment section ArrayList loggersFirstName = new ArrayList(); ArrayList loggersLastName = new ArrayList(); ArrayList logsArr = new ArrayList(); switch (type) { case materialsIdentifier: //ASPxGridView grid = DirectMaterialsGrid as ASPxGridView; //ASPxTextBox txtid = (ASPxTextBox)ContentPlaceHolder1.FindControl("txtTest"); //ASPxGridView grid = (ASPxGridView)ContentPlaceHolder1.FindControl("DirectMaterialsGrid"); if (PK == 0) { sItemCode = arrParam[4].ToString(); query_1 = "SELECT ITEMID, NAMEALIAS " + " FROM dbo.vw_AXInventTable " + " WHERE(DATAAREAID = '" + sEntCode + "') " + " AND(ITEMID = '" + sItemCode + "')"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { lblItemCode.Text = row["ITEMID"].ToString(); lblDescription.Text = row["NAMEALIAS"].ToString(); DataTable dtRecord = ItemInfoClass.Item_Invent_OnHand(sEntCode, lblItemCode.Text); grdOnHand.DataSource = dtRecord; grdOnHand.DataBind(); DataTable dtRecord1 = ItemInfoClass.Item_Pending_PO(sEntCode, sBuCode, lblItemCode.Text); grdPendingPO.DataSource = dtRecord1; grdPendingPO.DataBind(); DataTable dtRecord2 = ItemInfoClass.Item_Inventory_Movement(sEntCode, sBuCode, lblItemCode.Text); grdInventMovement.DataSource = dtRecord2; grdInventMovement.DataBind(); } } dt.Clear(); } else { query_1 = "SELECT [ItemDescription], [ItemCode] FROM [dbo].[tbl_MRP_List_DirectMaterials] where [PK] = '" + PK + "'"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { descdata = row["ItemDescription"].ToString(); lblItemCode.Text = row["ItemCode"].ToString(); lblDescription.Text = row["ItemDescription"].ToString(); DataTable dtRecord = ItemInfoClass.Item_Invent_OnHand(sEntCode, lblItemCode.Text); grdOnHand.DataSource = dtRecord; grdOnHand.DataBind(); DataTable dtRecord1 = ItemInfoClass.Item_Pending_PO(sEntCode, sBuCode, lblItemCode.Text); grdPendingPO.DataSource = dtRecord1; grdPendingPO.DataBind(); DataTable dtRecord2 = ItemInfoClass.Item_Inventory_Movement(sEntCode, sBuCode, lblItemCode.Text); grdInventMovement.DataSource = dtRecord2; grdInventMovement.DataBind(); } } dt.Clear(); //cmd = new SqlCommand(query_1, conn); //SqlDataReader reader = cmd.ExecuteReader(); //while (reader.Read()) //{ // descdata = reader[0].ToString(); // lblItemCode.Text = reader[1].ToString(); // lblDescription.Text = reader[0].ToString(); // DataTable dtRecord = ItemInfoClass.Item_Invent_OnHand(sEntCode, lblItemCode.Text); // grdOnHand.DataSource = dtRecord; // grdOnHand.DataBind(); //} //reader.Close(); } query_2 = "SELECT tbl_MRP_List_DirectMaterials_Logs.Remarks, tbl_Users.Firstname, tbl_Users.Lastname FROM tbl_MRP_List_DirectMaterials_Logs LEFT OUTER JOIN tbl_Users ON tbl_MRP_List_DirectMaterials_Logs.UserKey = tbl_Users.PK WHERE MasterKey = '" + PK + "'"; cmd = new SqlCommand(query_2); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { logsArr.Add(row["Remarks"].ToString()); loggersFirstName.Add(row["Firstname"].ToString()); loggersLastName.Add(row["Lastname"].ToString()); } } dt.Clear(); //cmd = new SqlCommand(query_2, conn); //SqlDataReader reader = cmd.ExecuteReader(); //reader = cmd.ExecuteReader(); //while (reader.Read()) //{ // logsArr.Add(reader[0].ToString()); // loggersFirstName.Add(reader[1].ToString()); // loggersLastName.Add(reader[2].ToString()); //} //reader.Close(); break; case opexIdentifier: //ASPxGridView grid1 = (ASPxGridView)ContentPlaceHolder1.FindControl("DirectMaterialsGrid"); if (PK == 0) { sItemCode = arrParam[4].ToString(); query_1 = "SELECT ITEMID, NAMEALIAS " + " FROM dbo.vw_AXInventTable " + " WHERE(DATAAREAID = '" + sEntCode + "') " + " AND(ITEMID = '" + sItemCode + "')"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { lblItemCode.Text = row["ITEMID"].ToString(); lblDescription.Text = row["NAMEALIAS"].ToString(); DataTable dtRecord = ItemInfoClass.Item_Invent_OnHand(sEntCode, lblItemCode.Text); grdOnHand.DataSource = dtRecord; grdOnHand.DataBind(); DataTable dtRecord1 = ItemInfoClass.Item_Pending_PO(sEntCode, sBuCode, lblItemCode.Text); grdPendingPO.DataSource = dtRecord1; grdPendingPO.DataBind(); DataTable dtRecord2 = ItemInfoClass.Item_Inventory_Movement(sEntCode, sBuCode, lblItemCode.Text); grdInventMovement.DataSource = dtRecord2; grdInventMovement.DataBind(); } } dt.Clear(); } else { query_1 = "SELECT [Description], [ItemCode] FROM [dbo].[tbl_MRP_List_OPEX] where [PK] = '" + PK + "'"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { descdata = row["Description"].ToString(); lblItemCode.Text = row["ItemCode"].ToString(); lblDescription.Text = row["Description"].ToString(); DataTable dtRecord = ItemInfoClass.Item_Invent_OnHand(sEntCode, lblItemCode.Text); grdOnHand.DataSource = dtRecord; grdOnHand.DataBind(); DataTable dtRecord1 = ItemInfoClass.Item_Pending_PO(sEntCode, sBuCode, lblItemCode.Text); grdPendingPO.DataSource = dtRecord1; grdPendingPO.DataBind(); DataTable dtRecord2 = ItemInfoClass.Item_Inventory_Movement(sEntCode, sBuCode, lblItemCode.Text); grdInventMovement.DataSource = dtRecord2; grdInventMovement.DataBind(); } } dt.Clear(); } query_2 = "SELECT tbl_MRP_List_OPEX_Logs.Remarks, tbl_Users.Firstname, tbl_Users.Lastname FROM tbl_MRP_List_OPEX_Logs LEFT OUTER JOIN tbl_Users ON tbl_MRP_List_OPEX_Logs.UserKey = tbl_Users.PK WHERE MasterKey = '" + PK + "'"; cmd = new SqlCommand(query_2); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { logsArr.Add(row["Remarks"].ToString()); loggersFirstName.Add(row["Firstname"].ToString()); loggersLastName.Add(row["Lastname"].ToString()); } } dt.Clear(); break; case manpowerIdentifier: query_1 = "SELECT [Description] FROM [dbo].[tbl_MRP_List_ManPower] where [PK] = '" + PK + "'"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { descdata = row["Description"].ToString(); lblItemCode.Text = ""; //reader[1].ToString(); lblDescription.Text = row["Description"].ToString(); } } dt.Clear(); query_2 = "SELECT tbl_MRP_List_ManPower_Logs.Remarks, tbl_Users.Firstname, tbl_Users.Lastname FROM tbl_MRP_List_ManPower_Logs LEFT OUTER JOIN tbl_Users ON tbl_MRP_List_ManPower_Logs.UserKey = tbl_Users.PK WHERE MasterKey = '" + PK + "'"; cmd = new SqlCommand(query_2); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { logsArr.Add(row["Remarks"].ToString()); loggersFirstName.Add(row["Firstname"].ToString()); loggersLastName.Add(row["Lastname"].ToString()); } } dt.Clear(); break; case capexIdentifier: query_1 = "SELECT [Description] FROM [dbo].[tbl_MRP_List_CAPEX] where [PK] = '" + PK + "'"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { descdata = row["Description"].ToString(); lblItemCode.Text = ""; //reader[1].ToString(); lblDescription.Text = row["Description"].ToString(); } } dt.Clear(); query_2 = "SELECT tbl_MRP_List_CAPEX_Logs.Remarks, tbl_Users.Firstname, tbl_Users.Lastname FROM tbl_MRP_List_CAPEX_Logs LEFT OUTER JOIN tbl_Users ON tbl_MRP_List_CAPEX_Logs.UserKey = tbl_Users.PK WHERE MasterKey = '" + PK + "'"; cmd = new SqlCommand(query_2); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { logsArr.Add(row["Remarks"].ToString()); loggersFirstName.Add(row["Firstname"].ToString()); loggersLastName.Add(row["Lastname"].ToString()); } } dt.Clear(); break; case revenueIdentifier: query_1 = "SELECT [FarmName] FROM [dbo].[tbl_MRP_List_RevenueAssumptions] where [PK] = '" + PK + "'"; cmd = new SqlCommand(query_1); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { descdata = row["FarmName"].ToString(); lblItemCode.Text = ""; //reader[1].ToString(); lblDescription.Text = row["FarmName"].ToString(); } } dt.Clear(); query_2 = "SELECT tbl_MRP_List_RevenueAssumptions_Logs.Remarks, tbl_Users.Firstname, tbl_Users.Lastname FROM tbl_Users LEFT OUTER JOIN tbl_MRP_List_RevenueAssumptions_Logs ON tbl_Users.PK = tbl_MRP_List_RevenueAssumptions_Logs.UserKey WHERE MasterKey = '" + PK + "'"; cmd = new SqlCommand(query_2); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { logsArr.Add(row["Remarks"].ToString()); loggersFirstName.Add(row["Firstname"].ToString()); loggersLastName.Add(row["Lastname"].ToString()); } } dt.Clear(); break; } for (int i = 0; i < loggersFirstName.Count; i++) { string fname = EncryptionClass.Decrypt(loggersFirstName[i].ToString()); loggersFirstName[i] = fname; string lname = EncryptionClass.Decrypt(loggersLastName[i].ToString()); loggersLastName[i] = lname; } } conn.Close(); }
byte[] GeneratPdf(DataRow row) { string did = "-1"; string QuesId = "-1"; int? cityId = null; int q2Status = -1; int q1Status = -1; string fullPathZipFile; //=================================== did = row["coursecode"].ToString(); QuesId = row["QuestionId"].ToString(); cityId = int.Parse(row["cityId"].ToString()); q2Status = int.Parse(row["q2Status"].ToString()); q1Status = int.Parse(row["Status"].ToString()); int?cityIDQ2 = null; if (q2Status != -1 && q1Status == 3) { cityIDQ2 = cityId; } var quizPapere = EBusiness.ShowQueizPaperByDid(did, cityIDQ2); var dynamicPath = "~/QueizPapers/" + quizPapere.Rows[0]["tterm"].ToString() + "/" + quizPapere.Rows[0]["code_ostad"].ToString() + "/pdffiles/" + quizPapere.Rows[0]["coursecode"].ToString(); string path = Server.MapPath(dynamicPath); if (cityIDQ2 == -1) { fullPathZipFile = $"{path}/{did.ToString()}_canceled_1.zip"; } else if (cityIDQ2 > 0) { fullPathZipFile = $"{path}/{did.ToString()}_canceled_2.zip"; } else { fullPathZipFile = $"{path}/{did.ToString()}.zip"; } byte[] base64HashesPassword = Convert.FromBase64String(quizPapere.Rows[0]["Password"].ToString()); string pass = EncryptionClass.DecryptRJ256(base64HashesPassword); var item = EBusiness.GetExamQuestionsbyDid(did, null, cityIDQ2); var whiteTape = Server.MapPath("~/University/Theme/images/whitePaper.jpg"); var questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg"); var examQ_Detail = EBusiness.Get_ExamdetailbyDid(did, null, cityIDQ2); var constQuestionFileInfo = new ExamStudentDTO(); constQuestionFileInfo.TypeNimsal = examQ_Detail.Rows[0]["typeNimsal"].ToString(); constQuestionFileInfo.CourseTitle = examQ_Detail.Rows[0]["namedars"].ToString(); constQuestionFileInfo.ProfossorFullName = examQ_Detail.Rows[0]["osname"].ToString(); constQuestionFileInfo.ExamDate = examQ_Detail.Rows[0]["dateexam"].ToString(); constQuestionFileInfo.ExamTime = examQ_Detail.Rows[0]["saatexam"].ToString(); constQuestionFileInfo.KeyCode = examQ_Detail.Rows[0]["keyCode"].ToString(); constQuestionFileInfo.ExamDuration = examQ_Detail.Rows[0]["examTime"].ToString(); constQuestionFileInfo.Calculator = examQ_Detail.Rows[0]["calculator"].ToString(); constQuestionFileInfo.Note = examQ_Detail.Rows[0]["note"].ToString(); constQuestionFileInfo.LowBook = examQ_Detail.Rows[0]["LowBook"].ToString(); constQuestionFileInfo.ClassCode = examQ_Detail.Rows[0]["ClassCode"].ToString(); constQuestionFileInfo.Grade = examQ_Detail.Rows[0]["magh"].ToString(); constQuestionFileInfo.Major = examQ_Detail.Rows[0]["nameresh"].ToString(); var userID = Session[sessionNames.userID_Karbar].ToString(); EBusiness.ChangeTemplateOfQuestion(path, did.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID, cityIDQ2); var generatedPdfPath = (Server.MapPath($"{dynamicPath}/{userID}/{did}_Momtahen_{userID}_1.pdf")); fileByteArray = System.IO.File.ReadAllBytes(generatedPdfPath); //Directory.GetDirectories(path).ToList().ForEach(dir => Directory.Delete(dir, true)); //File.Delete(generatedPdfPath); return(fileByteArray); }
protected void signUp_Click(object sender, EventArgs e) { int iEmployeeKey = 0; //MRPClass.PrintString("pass clicked signup"); if (captcha.IsValid && ASPxEdit.ValidateEditorsInContainer(this)) { ModalPopupExtenderLoading.Show(); //MRPClass.PrintString("pass inside validation"); DataTable dt = new DataTable(); SqlCommand cmd = null; SqlDataAdapter adp; string qry = ""; using (SqlConnection conHRIS = new SqlConnection(GlobalClass.SQLConnStringHRIS())) { //MRPClass.PrintString("pass inside hris"); qry = "SELECT PK, IDNumber FROM dbo.tbl_EmployeeIDNumber WHERE(IDNumber = '" + IDNumTextBox.Text.ToString() + "')"; cmd = new SqlCommand(qry); cmd.Connection = conHRIS; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { //MRPClass.PrintString("pass inside hris with id"); foreach (DataRow row in dt.Rows) { iEmployeeKey = Convert.ToInt32(row["PK"]); } } else { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('ID Number not found in Employee MasterList!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "ID Number not found in Employee MasterList!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } dt.Clear(); conHRIS.Close(); } DataTable dtUser = AccountClass.UserList(); //dtUser.CaseSensitive = true; string expressionID = "EmployeeKey = '" + iEmployeeKey.ToString().Trim() + "'"; string sortOrderID = "PK ASC"; DataRow[] foundRowsID; foundRowsID = dtUser.Select(expressionID, sortOrderID); if (foundRowsID.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate ID Number!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate ID Number!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } dtUser.CaseSensitive = true; string expressionName = "Lastname = '" + lastNameTextBox.Text.ToString().Trim() + "' AND Firstname = '" + firstNameTextBox.Text.ToString().Trim() + "'"; string sortOrderName = "PK ASC"; DataRow[] foundRowsName; foundRowsName = dtUser.Select(expressionName, sortOrderName); if (foundRowsName.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate Lastname and Firstname!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate Lastname and Firstname!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } string expressionEmail = "Email = '" + eMailTextBox.Text.ToString().Trim() + "'"; string sortOrderEmail = "PK ASC"; DataRow[] foundRowsEmail; foundRowsEmail = dtUser.Select(expressionEmail, sortOrderEmail); if (foundRowsEmail.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate Email!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate Email!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } string expressionUName = "Username = '******'"; string sortOrderUName = "PK ASC"; DataRow[] foundRowsUName; foundRowsUName = dtUser.Select(expressionUName, sortOrderUName); if (foundRowsUName.Length > 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('Found Duplicate Username!')},0);</script>"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = "Found Duplicate Username!"; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; return; } using (SqlConnection con = new SqlConnection(GlobalClass.SQLConnString())) { string _sLastName, _sFirstName, _sEmail, _sUserName, _sPassword, _sIDNum; int _Gender = 0; _sLastName = EncryptionClass.Encrypt(GlobalClass.UpperCaseFirstLetter(lastNameTextBox.Text.ToString().Trim())); _sFirstName = EncryptionClass.Encrypt(GlobalClass.UpperCaseFirstLetter(firstNameTextBox.Text.ToString().Trim())); _Gender = gender_int; _sEmail = EncryptionClass.Encrypt(eMailTextBox.Text.ToString().Trim()); _sUserName = EncryptionClass.Encrypt(userNameTextBox.Text.ToString().Trim()); _sPassword = EncryptionClass.Encrypt(passwordTextBox.Text.ToString().Trim()); _sIDNum = EncryptionClass.Encrypt(IDNumTextBox.Text.ToString().Trim()); con.Open(); qry = "INSERT INTO tbl_Users " + " (Lastname, Firstname, Username, Password, Email, EmployeeKey, Gender) " + " VALUES ('" + _sLastName + "', '" + _sFirstName + "', '" + _sUserName + "', " + " '" + _sPassword + "', '" + _sEmail + "', " + iEmployeeKey + ", " + _Gender + ")";; try { cmd = new SqlCommand(qry); cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('You have successfully registered')},0);</script>"); //MRPClass.PrintString("pass saved"); ModalPopupExtenderLoading.Hide(); CreateAccntNotify.HeaderText = "Info"; CreateAccntNotifyLbl.Text = "You is successfully registered."; CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Black; CreateAccntNotify.ShowOnPageLoad = true; Response.Redirect("default.aspx"); } catch (SqlException ex) { //MRPClass.PrintString(ex.ToString()); con.Close(); //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", // @"<script type=""text/javascript"">setTimeout(()=>{alert('" + ex.ToString() + "')},0);</script>"); CreateAccntNotify.HeaderText = "Error..."; CreateAccntNotifyLbl.Text = ex.ToString(); CreateAccntNotifyLbl.ForeColor = System.Drawing.Color.Red; CreateAccntNotify.ShowOnPageLoad = true; } } } }
protected void Page_Load(object sender, EventArgs e) { CheckCreatorKey(); if (!Page.IsPostBack) { //Rsize ScriptManager.RegisterStartupScript(this.Page, typeof(string), "Resize", "changeWidth.resizeWidth();", true); docnumber = Request.Params["DocNum"].ToString(); string query = "SELECT TOP (100) PERCENT tbl_MRP_List.*, vw_AXEntityTable.NAME AS EntityCodeDesc, vw_AXOperatingUnitTable.NAME AS BUCodeDesc, tbl_MRP_Status.StatusName, tbl_Users.Lastname, tbl_Users.Firstname FROM tbl_MRP_List LEFT OUTER JOIN tbl_Users ON tbl_MRP_List.CreatorKey = tbl_Users.PK LEFT OUTER JOIN vw_AXOperatingUnitTable ON tbl_MRP_List.BUCode = vw_AXOperatingUnitTable.OMOPERATINGUNITNUMBER LEFT OUTER JOIN tbl_MRP_Status ON tbl_MRP_List.StatusKey = tbl_MRP_Status.PK LEFT OUTER JOIN vw_AXEntityTable ON tbl_MRP_List.EntityCode = vw_AXEntityTable.ID WHERE dbo.tbl_MRP_List.DocNumber = '" + docnumber + "' ORDER BY dbo.tbl_MRP_List.DocNumber DESC"; SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); string firstname = "", lastname = ""; SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { mrp_key = Convert.ToInt32(reader["PK"].ToString()); entitycode = reader["EntityCode"].ToString(); DocNum.Text = reader["DocNumber"].ToString(); DateCreated.Text = reader["DateCreated"].ToString(); EntityCode.Text = reader["EntityCodeDesc"].ToString(); BUCode.Text = reader["BUCodeDesc"].ToString(); Month.Text = MRPClass.Month_Name(Int32.Parse(reader["MRPMonth"].ToString())); Year.Text = reader["MRPYear"].ToString(); Status.Text = reader["StatusName"].ToString(); firstname = reader["Firstname"].ToString(); lastname = reader["Lastname"].ToString(); } reader.Close(); conn.Close(); Creator.Text = EncryptionClass.Decrypt(firstname) + " " + EncryptionClass.Decrypt(lastname); DirectMaterialsRoundPanel.HeaderText = "[" + DocNum.Text.ToString().Trim() + "] Direct Materials"; OpexRoundPanel.HeaderText = "[" + DocNum.Text.ToString().Trim() + "] Operational Expense"; ManpowerRoundPanel.HeaderText = "[" + DocNum.Text.ToString().Trim() + "] Man Power"; CapexRoundPanel.HeaderText = "[" + DocNum.Text.ToString().Trim() + "] Capital Expenditure"; DirectMaterialsRoundPanel.Font.Bold = true; OpexRoundPanel.Font.Bold = true; ManpowerRoundPanel.Font.Bold = true; CapexRoundPanel.Font.Bold = true; DirectMaterialsRoundPanel.Collapsed = true; OpexRoundPanel.Collapsed = true; ManpowerRoundPanel.Collapsed = true; CapexRoundPanel.Collapsed = true; ASPxPageControl1.Font.Bold = true; ASPxPageControl1.Font.Size = 12; } BindDirectMaterials(docnumber); BindOpex(docnumber); BindManPower(docnumber); BindCapex(docnumber); }
protected void grd_CourseList_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridDataItem) { //GridDataItem dataItem = e.Item as GridDataItem; //GridDataItem item = (GridDataItem)e.Item; Button btnDlQuestionSinglePage = e.Item.FindControl("btnDlQuestionSinglePage") as Button; Button btnDlQuestionMergedFiles = e.Item.FindControl("btnDlQuestionMergedFiles") as Button; Button btnDlQuestionMainFormat = e.Item.FindControl("btnDlQuestionMainFormat") as Button; TextBox lbl_Password = e.Item.FindControl("lbl_Password") as TextBox; HiddenField hdn_Pass = e.Item.FindControl("hdn_Pass") as HiddenField; HiddenField hdn_IsActive = e.Item.FindControl("hdn_IsActive") as HiddenField; HiddenField hdn_ApproveNewHeader = e.Item.FindControl("hdn_ApproveNewHeader") as HiddenField; var dtUserRoles = getCurrentUserRoles(Session[sessionNames.userID_Karbar].ToString()); if (dtUserRoles != null && dtUserRoles.Rows.Count > 0) { //var isRole_1_32_33 = false; //for (int i = 0; i < dtUserRoles.Rows.Count; i++) //{ // if (dtUserRoles.Rows[i]["RoleId"].ToString() == "1" // || dtUserRoles.Rows[i]["RoleId"].ToString() == "32" // || dtUserRoles.Rows[i]["RoleId"].ToString() == "33") // { // isRole_1_32_33 = true; // break; // } //} //if (isRole_1_32_33) //{ // if (!string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) && hdn_ApproveNewHeader.Value == "False") // { // btnDlQuestionMainFormat.Visible = true; // } // else // { // btnDlQuestionSinglePage.Visible = true; // } //} //else { //TODO if ApproveNewHeader value is false then just show old header if (!string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) && hdn_ApproveNewHeader.Value == "False") { btnDlQuestionMainFormat.Visible = true; } else if (string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) || hdn_ApproveNewHeader.Value == "True") //TODO else ApproveNewHeader is true or Null then { //TODO if permision is true show new header and total new header if (!string.IsNullOrEmpty(hdn_IsActive.Value) && hdn_IsActive.Value == "1") { btnDlQuestionSinglePage.Visible = true; btnDlQuestionMergedFiles.Visible = true; } else if (string.IsNullOrEmpty(hdn_IsActive.Value) || hdn_IsActive.Value == "0")//TODO else permision is false or null total new header { btnDlQuestionMergedFiles.Visible = true; } } } } else { //TODO if ApproveNewHeader value is false then just show old header if (!string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) && hdn_ApproveNewHeader.Value == "False") { btnDlQuestionMainFormat.Visible = true; } else if (string.IsNullOrEmpty(hdn_ApproveNewHeader.Value) || hdn_ApproveNewHeader.Value == "True") //TODO else ApproveNewHeader is true or Null then { //TODO if permision is true show new header and total new header if (!string.IsNullOrEmpty(hdn_IsActive.Value) && hdn_IsActive.Value == "1") { btnDlQuestionSinglePage.Visible = true; btnDlQuestionMergedFiles.Visible = true; } else if (string.IsNullOrEmpty(hdn_IsActive.Value) || hdn_IsActive.Value == "0")//TODO else permision is false or null total new header { btnDlQuestionMergedFiles.Visible = true; } } } var answerSheetType = string.Empty; var rrr = (DataRowView)e.Item.DataItem; if (Convert.ToBoolean(rrr["AnswerSheet1"])) { answerSheetType += "پاسخگویی در برگه سوالات"; } if (Convert.ToBoolean(rrr["AnswerSheet2"])) { if (answerSheetType.Length > 0) { answerSheetType += " | "; } answerSheetType += " تشریحی "; } if (Convert.ToBoolean(rrr["AnswerSheet3"])) { if (answerSheetType.Length > 0) { answerSheetType += " | "; } answerSheetType += " تستی "; } e.Item.Cells[9].Text = answerSheetType; //TableCell cell = dataItem["did"]; string tt = (hdn_Pass.Value.ToString()); byte[] str = Convert.FromBase64String(tt); string pass = EncryptionClass.DecryptRJ256(str); lbl_Password.Text = pass; } }
protected void Page_Load(object sender, EventArgs e) { form1.Action = System.Configuration.ConfigurationManager.AppSettings["LMS_link"].ToString(); if (Session["LogStatus"].ToString() == "0-0") { LogStatus.Value = Session["LogStatus"].ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "submitform", "submitform();", true); } else { LogStatus.Value = Session["LogStatus"].ToString(); string key = "b3afc5fd20e3637160da4f9cab6c8072"; string IV = "a214ee38a470c5974c10498b7152ca39"; // string key = "b2afc5fd22e3637260da4f9cab6c8272"; // string IV = "a224ee38a470c5974c20498b7252ca39"; string userName = "", pass = ""; //یک کارمندو مدیرگروه 2- استاد 3- دانشجو 4- ممتحن switch (Session["UserType_lms"].ToString()) { case "1": if (Session[sessionNames.roleID].ToString() == "33") { userName = "******"; pass = Session["p"].ToString(); } else if (Session[sessionNames.roleID].ToString() == "32") { userName = "******"; pass = Session["p"].ToString(); } else { userName = Session[sessionNames.user_Karbar].ToString(); pass = Session["p"].ToString(); } break; case "2": userName = "******" + Session[sessionNames.userID_StudentOstad].ToString(); pass = Session["Password"].ToString(); break; case "3": userName = Session[sessionNames.userID_StudentOstad].ToString(); pass = Session["Password"].ToString(); break; case "4": userName = "******" + Session[sessionNames.user_Karbar].ToString(); pass = Session["p"].ToString(); break; } // var ddd = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); // string message = "970225966;1990079997;"+ddd; // //string message = "99900999;0012244511;2020-05-12 15:20:01"; // string password = "******"; // // Create sha256 hash // SHA256 mySHA256 = SHA256Managed.Create(); // byte[] key123 = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(password)); // string author = "zxcvbnmasdfghjkl"; // // Convert a C# string to a byte array // //byte[] bytes = Encoding.ASCII.GetBytes(author); // // Create secret IV // byte[] iv = new byte[16] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; //// iv = bytes; // string encrypted = this.EncryptString(message, key123, iv); // string decrypted = this.DecryptString(encrypted, key123, iv); // var u = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); // var d = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // Console.WriteLine(encrypted); // Console.WriteLine(decrypted); UserName.Value = EncryptionClass.EncryptRJ(userName, key, IV); Password.Value = EncryptionClass.EncryptRJ(pass, key, IV); ScriptManager.RegisterStartupScript(this, GetType(), "submitform", "submitform();", true); } }
public static IObjectProxy LoadSqlDataQuery(Soway.Model.View.View view, System.Data.DataRow row, SqlCon con, Context.ICurrentContextFactory conFac) { IObjectProxy proxy = new SqlDataProxy(view.Model, conFac, LoadType.Null, con); foreach (var viewItem in view.Items) { if (viewItem.Property.PropertyType == PropertyType.RadomDECS) { proxy [viewItem.Property] = EncryptionClass.GetDecrptyString( viewItem.Property, row, string.Format("{0}_", proxy.Model.DataTableName)); } else if (viewItem.Property.PropertyType != PropertyType.BusinessObject) { if (string.IsNullOrEmpty(viewItem.Property.DBName) == false) { proxy[viewItem.Property] = row[string.Format("{0}_{1}", proxy.Model.DataTableName, viewItem.Property.DBName)]; } } else { var propertyProxy = new SqlDataProxy(viewItem.Property.Model, conFac, LoadType.Null, con); if (viewItem.Property.IsMultiMap == false) { if (viewItem.Property.Model.ShowProperty != null && row[string.Format("{0}_{1}", viewItem.Property.Name, viewItem.Property.Model.ShowProperty.DBName)] != DBNull.Value) { if (viewItem.Property.Model.IdProperty != null) { propertyProxy[viewItem.Property.Model.IdProperty] = row[string.Format("{0}_{1}", viewItem.Property.Name, viewItem.Property.Model.IdProperty.DBName)]; } if (viewItem.Property.Model.ShowProperty != null) { propertyProxy[viewItem.Property.Model.ShowProperty] = row[string.Format("{0}_{1}", viewItem.Property.Name, viewItem.Property.Model.ShowProperty.DBName)]; } } else { propertyProxy = null; } } else { foreach (var map in viewItem.Property.DBMaps) { propertyProxy[viewItem.Property.Model.Properties.First(p => p.Name == map.PropertyName || p.PropertyName == map.PropertyName)] = row[string.Format("{0}_{1}", viewItem.Property.Name, map.PropertyName)]; } } proxy[viewItem.Property] = propertyProxy; } } if (proxy.Model.AutoSysId == true) { proxy.ID = row[string.Format("{0}_{1}", proxy.Model.DataTableName, "SYSID")]; } else { proxy.ID = row[string.Format("{0}_{1}", proxy.Model.DataTableName, proxy.Model.IdProperty.DBName)]; } return(proxy); }
public static void LoadSqlData(IObjectProxy proxy, System.Data.DataRow row, SqlCon con, Context.ICurrentContextFactory conFac) { if (proxy != null && proxy.Model.ModelType != ModelType.Enum) { foreach (var property in proxy.Model.Properties.Where(p => p.IsArray == false && (string.IsNullOrEmpty(p.DBName) == false || p.IsMultiMap == true))) { dynamic propertyOb = null; if (property.PropertyType == PropertyType.RadomDECS) { propertyOb = EncryptionClass.GetDecrptyString(property, row); } else if (property.PropertyType != PropertyType.BusinessObject) { if (String.IsNullOrEmpty((property.DBName ?? "").Trim()) == false && row.Table.Columns.Contains(property.DBName) == true && row[property.DBName] != DBNull.Value) { propertyOb = row[property.DBName]; } else { propertyOb = GetDefaultValue(property); } } else { IObjectProxy tempProxy = null;/// new SqlDataProxy(property.Model,conFac, LoadType.Null,con); if (property.IsMultiMap == false) { if (String.IsNullOrEmpty(property.DBName) == false && row[property.DBName] != DBNull.Value) { tempProxy = getProxy(property.Model, row[property.DBName], con, conFac); } else { tempProxy = null; } } else { var modelKeyProperty = property.Model.IdProperty; if (modelKeyProperty != null) { var itemKeyProperrty = property.DBMaps.FirstOrDefault(p => p.PropertyName == modelKeyProperty.PropertyName); if (itemKeyProperrty != null) { var rowOb = row[itemKeyProperrty.DBColName]; if (rowOb != DBNull.Value) { tempProxy = getProxy(property.Model, rowOb, con, conFac); tempProxy.IsLoad = LoadType.Null; } } } bool IsSet = false; foreach (var map in property.DBMaps) { var rowOb = row[map.DBColName]; if (rowOb != DBNull.Value) { tempProxy[tempProxy.Model.Properties.First(p => p.Name == map.PropertyName || p.PropertyName == map.PropertyName)] = rowOb; IsSet = true; } } if (IsSet == false) { tempProxy = null; } else { tempProxy.IsLoad = LoadType.Partial; } } propertyOb = tempProxy; } proxy[property] = propertyOb; proxy.UpdateToNew(property); } } if (proxy.ID == null || (proxy.ID is long && System.Convert.ToInt64(proxy.ID) == 0)) { if (proxy.Model.AutoSysId == false && proxy.Model.IdProperty != null) { proxy.ID = proxy[proxy.Model.IdProperty]; } else { proxy.ID = row["SysId"]; } } MemoryCache.StoreDbCache.UpdateOrAddDbMemoryCache(con, proxy.Model, proxy.ID, proxy); // System.Diagnostics.Trace.WriteLine( "Id:" + proxy.ID); }
protected void grd_Class_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "Filter") { return; } string did = "0"; var dtdet = new DataTable(); var path = string.Empty; var absPath = string.Empty; var pass = string.Empty; var hdnPassword = (HiddenField)e.Item.FindControl("hdnPassword"); if (e.CommandName == "ShowNewHeaderForAll" || e.CommandName == "ShowNewHeader" || e.CommandName == "ShowOldHeader") { did = e.CommandArgument.ToString(); dtdet = examBusiness.Get_ExamdetailbyDid(did); path = $"QueizPapers/{dtdet.Rows[0]["tterm"].ToString()}/{dtdet.Rows[0]["code_ostad"].ToString()}/pdffiles/{e.CommandArgument.ToString()}"; absPath = Server.MapPath($"~/{path}"); var base64HashesPassword = Convert.FromBase64String(hdnPassword.Value); pass = EncryptionClass.DecryptRJ256(base64HashesPassword); } var QuestionId = Convert.ToInt32(e.CommandArgument.ToString()); var constQuestionFileInfo = new ExamStudentDTO(); var whiteTape = Server.MapPath("~/University/Theme/images/whitePaper.jpg"); var questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg"); var userID = Session[sessionNames.userID_Karbar].ToString(); switch (e.CommandName) { case "ShowNewHeaderForAll": constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO() { TypeNimsal = x.Field <string>("typeNimsal"), CourseTitle = x.Field <string>("namedars"), ProfossorFullName = x.Field <string>("osname"), ExamDate = x.Field <string>("dateexam"), ExamTime = x.Field <string>("saatexam"), KeyCode = x.Field <string>("keyCode"), ExamDuration = x.Field <string>("examTime"), Calculator = x.Field <string>("calculator"), Note = x.Field <string>("note"), LowBook = x.Field <string>("LowBook"), ClassCode = x.Field <string>("ClassCode").ToString() }).FirstOrDefault(); var dt = examBusiness.ExamAnswerSheetbyDid(did, int.Parse(Session[sessionNames.userID_Karbar].ToString())); var studentList = dt.AsEnumerable().Select(x => new ExamStudentDTO() { FirstName = x.Field <string>("stFirstName"), LastName = x.Field <string>("stLastName"), StudentCode = x.Field <string>("stcode"), Grade = x.Field <string>("magh"), Major = x.Field <string>("nameresh"), SeatHeader = x.Field <string>("SeatHeader"), SeatNumber = x.Field <int?>("SeatNumber") }).ToList(); examBusiness.GeneratePdfQuestionForStudents(absPath, did.ToString(), pass, questioHeaderTemplate, whiteTape, userID, constQuestionFileInfo, studentList); Session["BigFile"] = true; ShowFiles($"{path}/{userID}/{did}_Momtahen_{userID}_2.zip", pass); break; case "ShowNewHeader": constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO() { TypeNimsal = x.Field <string>("typeNimsal"), CourseTitle = x.Field <string>("namedars"), ProfossorFullName = x.Field <string>("osname"), ExamDate = x.Field <string>("dateexam"), ExamTime = x.Field <string>("saatexam"), KeyCode = x.Field <string>("keyCode"), ExamDuration = x.Field <string>("examTime"), Calculator = x.Field <string>("calculator"), Note = x.Field <string>("note"), LowBook = x.Field <string>("LowBook"), ClassCode = x.Field <string>("ClassCode").ToString() }).FirstOrDefault(); examBusiness.ChangeTemplateOfQuestion(absPath, e.CommandArgument.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID); ShowFiles($"{path}/{userID}/{did}_Momtahen_{userID}_1.zip", pass); break; case "ShowOldHeader": constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO() { TypeNimsal = x.Field <string>("typeNimsal"), CourseTitle = x.Field <string>("namedars"), ProfossorFullName = x.Field <string>("osname"), ExamDate = x.Field <string>("dateexam"), ExamTime = x.Field <string>("saatexam"), KeyCode = x.Field <string>("keyCode"), ExamDuration = x.Field <string>("examTime"), Calculator = x.Field <string>("calculator"), Note = x.Field <string>("note"), LowBook = x.Field <string>("LowBook"), ClassCode = x.Field <string>("ClassCode").ToString() }).FirstOrDefault(); examBusiness.ChangeTemplateOfQuestion(absPath, e.CommandArgument.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID); ShowFiles($"{path}/{did}.zip", pass); break; case "ApproveNewHeader": examBusiness.SetApproveNewHeader(QuestionId, true); BindGrid = true; grd_Class.Rebind(); break; case "RejectNewHeader": examBusiness.SetApproveNewHeader(QuestionId, false); BindGrid = true; grd_Class.Rebind(); break; } }