internal string buildAddRecordStatement(AbstractCredentials creds, string encryptionKey) { string phoneNum = "No phone"; if (!String.IsNullOrEmpty(creds.SubjectPhone)) { phoneNum = creds.SubjectPhone; } string result = "INSERT INTO " + _tableName + " (SessionID,SSN,Name,DUZ,SiteId,SiteName,Phone) VALUES ("; if (_encrypt) { result += "'" + escapeString(SSTCryptographer.Encrypt(creds.AuthenticationToken, encryptionKey)) + "'," + "'" + escapeString(SSTCryptographer.Encrypt(creds.FederatedUid, encryptionKey)) + "'," + "'" + escapeString(SSTCryptographer.Encrypt(creds.SubjectName, encryptionKey)) + "'," + "'" + escapeString(SSTCryptographer.Encrypt(creds.LocalUid, encryptionKey)) + "'," + "'" + escapeString(SSTCryptographer.Encrypt(creds.AuthenticationSource.SiteId.Id, encryptionKey)) + "'," + "'" + escapeString(SSTCryptographer.Encrypt(creds.AuthenticationSource.SiteId.Name, encryptionKey)) + "'," + "'" + escapeString(SSTCryptographer.Encrypt(phoneNum, encryptionKey)); } else { result += "'" + escapeString(creds.AuthenticationToken) + "'," + "'" + escapeString(creds.FederatedUid) + "'," + "'" + escapeString(creds.SubjectName) + "'," + "'" + escapeString(creds.LocalUid) + "'," + "'" + escapeString(creds.AuthenticationSource.SiteId.Id) + "'," + "'" + escapeString(creds.AuthenticationSource.SiteId.Name) + "'," + "'" + escapeString(phoneNum); } result += "');"; return(result); }
public static string strLogPath; // Log file path #endregion /// <summary> /// Static function to write log /// </summary> /// <param name="inText">String to log in the file</param> /// <param name="strKID">Kiosk ID of the machine from which message received</param> /// <param name="strMSN">Serial number of the machine from which message received</param> public static void Write(string inText, string strFoldername) { try { string strPath = ""; //if (strClient != "") // strPath = strLogPath + "\\" + "Client- " + strClient + "\\" + DateTime.Now.ToString("MMM yy"); //else strPath = strLogPath + "\\" + DateTime.Now.ToString("MMM yy"); // Create directory if not exist if (!Directory.Exists(strPath)) { Directory.CreateDirectory(strPath); } if (!File.Exists(strPath + "\\khaoPiyoLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt")) { if (bEncryptLog) { File.WriteAllText(strPath + "\\khaoPiyoLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt", SSTCryptographer.Encrypt(DateTime.Now.ToString("HH:mm:ss.fff") + "\t***** Service started V" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " *****\n")); } else { File.WriteAllText(strPath + "\\khaoPiyoLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt", DateTime.Now.ToString("HH:mm:ss.fff") + "\t***** Service started V" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " *****\n"); } } // Create or map file objct with append mode StreamWriter swFile = new StreamWriter(strPath + "\\khaoPiyoLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt", true); // If created or mapped if (swFile != null) { if (bEncryptLog) // If write encrypted log { swFile.WriteLine(SSTCryptographer.Encrypt(DateTime.Now.ToString("HH:mm:ss.fff") + "\t" + inText)); } else // Normla log write { if (strFoldername == "nt") { swFile.WriteLine("\t\t\n" + inText + "\n"); } else { swFile.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + "\t" + inText); } } // Close the file swFile.Close(); } } catch { } }
public static string strLogPath; // Log file path #endregion /// <summary> /// Static function to write log /// </summary> /// <param name="inText">String to log in the file</param> /// <param name="strKID">Kiosk ID of the machine from which message received</param> /// <param name="strMSN">Serial number of the machine from which message received</param> public static void Write(string inText, string strKioskIP) { try { strLogPath = ConfigurationManager.AppSettings["LogDirectory"].ToString(); string strPath = ""; if (strKioskIP != "") { strPath = strLogPath + "\\" + "KioskIP- " + strKioskIP + "\\" + DateTime.Now.ToString("MMM yy"); } else { strPath = strLogPath + "\\Server\\" + DateTime.Now.ToString("MMM yy"); } // Create directory if not exist if (!Directory.Exists(strPath)) { Directory.CreateDirectory(strPath); } if (!File.Exists(strPath + "\\LipiRMSLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt")) { if (bEncryptLog) { File.WriteAllText(strPath + "\\LipiRMSLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt", SSTCryptographer.Encrypt(DateTime.Now.ToString("HH:mm:ss.fff") + "\t***** Service started V" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " *****\n")); } else { File.WriteAllText(strPath + "\\LipiRMSLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt", DateTime.Now.ToString("HH:mm:ss.fff") + "\t***** Service started V" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " *****\n"); } } // Create or map file objct with append mode StreamWriter swFile = new StreamWriter(strPath + "\\LipiRMSLog_" + DateTime.Today.ToString("dd_MM_yyyy") + ".txt", true); // If created or mapped if (swFile != null) { if (bEncryptLog) // If write encrypted log { swFile.WriteLine(SSTCryptographer.Encrypt(DateTime.Now.ToString("HH:mm:ss.fff") + "\t" + inText)); } else // Normla log write { swFile.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + "\t" + inText); } // Close the file swFile.Close(); } } catch { } }
public override MdoQuery buildVisitRequest() { VistaQuery vq = new VistaQuery("XUS SIGNON SETUP"); string token = SSTCryptographer.Encrypt(creds.AuthenticationToken, VistaConstants.ENCRYPTION_KEY); token = UserValidationDao.escapeString(token); string arg = "-35^" + VistaUtils.encrypt(creds.SecurityPhrase + '^' + token); vq.addParameter(vq.LITERAL, arg); return(vq); }
internal string buildDeleteRecordStatement(string securityToken, string encryptionKey) { if (_encrypt) { return("DELETE FROM " + _tableName + " WHERE SessionId ='" + escapeString(SSTCryptographer.Encrypt(securityToken, encryptionKey)) + "';"); } else { return("DELETE FROM " + _tableName + " WHERE SessionId ='" + escapeString(securityToken) + "';"); } }
public void ProcessRequest(HttpContext Context) { if (Context.Session["profileFriendID"] != null) { string memberId = Context.Request.QueryString["id"]; //get the querystring value that was pass on the ImageURL (see GridView MarkUp in Page1.aspx) memberId = SSTCryptographer.Encrypt(memberId); Member aMember = new Member(memberId); if (memberId != null) { MemberInfoDAL dal = new MemberInfoDAL(); aMember = dal.GetAllMemberInfo(aMember); MemoryStream ms = new MemoryStream(); aMember.ProfilePicture.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] file = ms.ToArray(); ms.Write(file, 0, file.Length); Context.Response.Buffer = true; Context.Response.BinaryWrite(file); ms.Dispose(); } Context.Session["profileFriendID"] = Context.Session["memberID"].ToString(); } else { string memberId = Context.Request.QueryString["id"]; //get the querystring value that was pass on the ImageURL (see GridView MarkUp in Page1.aspx) memberId = SSTCryptographer.Encrypt(memberId); Member aMember = new Member(memberId); if (memberId != null) { MemberInfoDAL dal = new MemberInfoDAL(); aMember = dal.GetAllMemberInfo(aMember); MemoryStream ms = new MemoryStream(); aMember.ProfilePicture.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] file = ms.ToArray(); ms.Write(file, 0, file.Length); Context.Response.Buffer = true; Context.Response.BinaryWrite(file); ms.Dispose(); } } }
private void button1_Click(object sender, EventArgs e) { Properties.Settings.Default.serverAddress = textBox[0].Text; Properties.Settings.Default.serverPort = textBox[1].Text; Properties.Settings.Default.databaseName = textBox[2].Text; Properties.Settings.Default.databaseUsername = textBox[3].Text; Properties.Settings.Default.databasePassword = SSTCryptographer.Encrypt(textBox[4].Text, Properties.Settings.Default.databaseUsername + "as56afs65qer3g654afg"); Properties.Settings.Default.reportUNC = textBox[5].Text; Properties.Settings.Default.useWildcard = checkBox1.Checked; Properties.Settings.Default.limitResults = checkBox2.Checked; Properties.Settings.Default.limitResultsTo = (int)numericUpDown1.Value; Properties.Settings.Default.Save(); Application.Restart(); }
public void RememberMe(string username, string password) { try { if (Request.Cookies["login"] != null) { HttpCookie getCookie = Request.Cookies.Get("login"); } else { HttpCookie cookie = new HttpCookie("login"); Response.Cookies.Add(cookie); cookie.Values.Add("username", username); cookie.Values.Add("password", SSTCryptographer.Encrypt(password)); cookie.Expires = DateTime.Now.AddMonths(1); } } catch (Exception e) { e.ToString(); } }
public IHttpActionResult ExternalAuthRegister(RegisterModel model) { ResponseModel obj = new ResponseModel(); string errorMessage = string.Empty; HttpResponseMessage response = new HttpResponseMessage(); try { if (!ModelState.IsValid) { errorMessage = String.Join(",", ErrorHelper.GetErrorListFromModelState(ModelState)); return(BadRequest(errorMessage)); } if (string.IsNullOrEmpty(model.ExternalAuthType)) { return(BadRequest("External Auth Type is required.")); } if (string.IsNullOrEmpty(model.ExternalAuthUserId)) { return(BadRequest("External Auth User Id is required.")); } bool isEmail = ValidateEmail(model.Email); if (isEmail == false) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Please give a valid email id."))); } var userDetailsByEmail = _userService.GetUserDetailsByEmail(model.Email); if (userDetailsByEmail == null) { } else { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "This email is already taken."))); } var trevoId = PasswordAndTrevoHelper.GenerateTrevoId(model.Name); TrevoUsers user = new TrevoUsers(); user.Address = model.Address == null ? string.Empty : model.Address; user.Country_Id = model.CountryId; user.DeviceId = model.DeviceId; user.Dob = model.Dob; user.Email_Id = model.Email; user.Gender = model.Gender; //user.UsersLanguageId = model.Id; user.Interests = model.Interests == null ? string.Empty : model.Interests; user.LagLevel_ID = model.LanguageLevelId; user.Name = model.Name; user.Password = string.Empty; user.PasswordHash = string.Empty; user.QR_Code = string.Empty; user.Self_Introduction = model.SelfIntroduction == null ? string.Empty : model.SelfIntroduction; user.TravelDestination_CId = model.TravelDestination == null ? string.Empty : model.TravelDestination; user.TrevoId = trevoId; user.IsVerified = 0; user.ImagePath = string.Empty; user.CreatedTime = DateTime.UtcNow; user.ExternalAuthType = model.ExternalAuthType; user.ExternalAuthUserId = model.ExternalAuthUserId; //_userService.InsertUserDetails(user); //insert the user language first var isSuccess = _userService.InsertUserDetails(user); if (isSuccess.IsSuccess) { UsersLanguage userLanguage = new UsersLanguage(); userLanguage.User_Id = Convert.ToInt64(isSuccess.Message); obj.UserID = userLanguage.User_Id; userLanguage.Learning_LanguageId = model.LearningLanguageId; userLanguage.Native_LanguageId = model.NativeLanguageId; _userLanguageService.InsertUserLanguageDetails(userLanguage); } else { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "There is some error."))); } //send mail after successfull registration StreamReader reader = new StreamReader(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/EmailTemplate/RegistrationActivation.html")); string readFile = reader.ReadToEnd(); string mailBody = ""; mailBody = readFile; mailBody = mailBody.Replace("$$UserName$$", model.Name); string otpCode = PasswordAndTrevoHelper.CreateRandomNumber(5); string encryptedUserName = SSTCryptographer.Encrypt(model.Name, SSTCryptographer.Key = "Activation"); mailBody = mailBody.Replace(" $$OTPCode$$", otpCode); ReturnMsg mailResult = SendMail.SendEmail(InfoMail, model.Email, "Account Activation", mailBody); obj.Email = model.Email; obj.Name = model.Name; } catch (System.Exception e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message))); } return(Ok(obj)); }
public void testEncrypt() { Assert.AreEqual(ENCRYPTED, SSTCryptographer.Encrypt(SECRET)); }
protected void LoginButton_Click(object sender, EventArgs e) { Member_Status member_Status; dal = new LoginDAL(); string username = LoginUser.UserName; string password = LoginUser.Password; //Validate the Credentials against the active directory userInformation = new ActiveDirectoryDAL(username, password); username = SSTCryptographer.Encrypt(username); bool isValid = userInformation.ValidateCredentials(); if (!isValid) //Invalid Credentials { failureText = "Incorrect username or password."; ErrorInfo.Visible = true; } else if (dal.GetMemberStatus(member_Status = new Member_Status(username))) { failureText = "Your account has been suspended."; ErrorInfo.Visible = true; } else //Valid Credentials { userInformation.GetUserInformation(); if (IsSchoolOfICTMember()) { //treat the case where we set the remember me check box if (LoginUser.RememberMeSet) { RememberMe(username, password); } dal = new LoginDAL(); //save data into db if first time login Member member; if (!dal.MemberExists(member = new Member(username))) { //add member to database member = new Member(username, userInformation.GetFirstName(), userInformation.GetLastName(), userInformation.GetDisplayName(), userInformation.GetEmail(), userInformation.GetThumbnailPhoto(), userInformation.GetDescription(), userInformation.GetCompany(), ValidateMemberType()); dal.InsertMember(member); //assign member to groups AssignMemberToGroups(username); } Session["memberID"] = username; // Server.Transfer("~/Home.aspx"); Response.Redirect("~/Home.aspx"); //Redirect to home page if the user is a memeber of the faculty of ICT } else { //Display error message if the user is not a memeber of the faculty of ICT failureText = "Sorry. You need to be a registered school of ICT member in order to gain access to this site"; ErrorInfo.Visible = true; } } }
public void GeneratePendingManualdata() { string FileExtension = "EXCEL"; string server = f.IniReadValue("PendingRecords", "Path"); directoryname = server.ToString(); if (!Directory.Exists(directoryname)) { Directory.CreateDirectory(directoryname); } try { bool mailsendflag = false; int count = 0; int day = 0; string monthnumber = string.Empty; int year = 0; DBConnection db_connection = new DBConnection(); DataTable filtered_data = new DataTable(); DataTable manual_entry_pending_data = new DataTable(); DataTable overtime_pending_data = new DataTable(); DataTable out_of_office = new DataTable(); string from_date, to_date, final_date, first_date, initial_date, managerorhrcode, managerorhrname, managerorhremail, ismanager, ishr, where_clause, current_user_id, companyname, managernHRfetchquery, dayname, currentdayname = string.Empty; DateTime last_date = new DateTime(); Hashtable filter_conditions = new Hashtable(); monthnumber = DateTime.Now.ToString("MMM"); year = DateTime.Now.Year; //day = Convert.ToInt32(f.IniReadValue("Daynumber", "number")); dayname = f.IniReadValue("Dayname", "name"); currentdayname = DateTime.Now.DayOfWeek.ToString(); final_date = DateTime.Now.ToString("dd-MMM-yyyy"); to_date = DateTime.ParseExact(final_date, "dd-MMM-yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd"); string firstDay = string.Empty; last_date = Convert.ToDateTime(to_date); initial_date = last_date.AddDays(-6).ToString("dd-MMM-yyyy"); from_date = DateTime.ParseExact(initial_date, "dd-MMM-yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd"); managernHRfetchquery = "select emp_code,Emp_Name , emp_email , ismanager , ishr from employeemaster where emp_status = 1 and ( ismanager = 1 or ishr = 1 )"; DataTable managerHRlist = new DataTable(); managerHRlist = db_connection.ReturnDataTable(managernHRfetchquery); if (dayname.ToUpper() == currentdayname.ToUpper()) { foreach (DataRow row in managerHRlist.Rows) { managerorhrcode = row["emp_code"].ToString(); managerorhrname = row["Emp_Name"].ToString(); managerorhremail = row["emp_email"].ToString(); ismanager = row["ismanager"].ToString(); ishr = row["ishr"].ToString(); if (!string.IsNullOrEmpty(managerorhremail)) { string query, file_name, company_name, exportPath = string.Empty; string messageBody = string.Empty; company_name = db_connection.ExecuteQuery_WithReturnValueString("select companyname from companymaster where companycode in ( select emp_company from employeemaster where emp_code ='" + managerorhrcode + "')"); #region Manual Punch query = "select p.empcode as EmpCode , p.workdate as WorkDate , p.inpunch as InPunch , p.outpunch as OutPunch , md.status as Status from punchforapproval p join MASTERPROCESSDAILYDATA md on p.WorkDate = md.PDate and p.EmpCode = md.emp_id where p.approve = 1 and p.empcode in (select EmpID from [FetchEmployees] ('" + managerorhrcode + "',''))"; manual_entry_pending_data = db_connection.ReturnDataTable(query); if (manual_entry_pending_data.Rows.Count > 0) { messageBody += "Dear " + managerorhrname + ",<br/>" + "<br/>"; messageBody += "Please find pending approval records for your reportee employee. " + "<br/>" + "<br/>"; OpenFileForWriting("Your Pending Manual Entry Approval : " + DateTime.Now.ToString("dd-MMM-yyyy")); OpenFileForWriting("Employee ID" + " " + "Date" + " " + "In Punch" + " " + "Out Punch" + " " + "Status" + " " + "Access Link"); messageBody += "Pending Manual Entry Approval List as on : " + DateTime.Now.ToString("dd-MMM-yyyy"); messageBody += "<br><br>"; messageBody += "<table border=1>"; messageBody += "<tr><td>Employee ID</td>"; messageBody += "<td>Date</td>"; messageBody += "<td>In Punch</td>"; messageBody += "<td>Out Punch</td>"; messageBody += "<td>Status</td>"; // messageBody += "<td>Access Link</td>"; messageBody += "</tr>"; foreach (DataRow pendingmanualrow in manual_entry_pending_data.Rows) { Location = f.IniReadValue("Location", "value"); encrypt = SSTCryptographer.Encrypt(managerorhrcode, "SampleKey"); managerurl = "?MP=" + encrypt + ""; Location = Location + managerurl; Location = ConvertUrlsToLinks(Location); messageBody += "<tr>"; messageBody += "<td>" + pendingmanualrow["EmpCode"].ToString() + "</td>"; messageBody += "<td>" + pendingmanualrow["WorkDate"].ToString() + "</td>"; messageBody += "<td>" + pendingmanualrow["InPunch"].ToString() + "</td>"; messageBody += "<td>" + pendingmanualrow["OutPunch"].ToString() + "</td>"; messageBody += "<td>" + pendingmanualrow["Status"].ToString() + "</td>"; // messageBody += "<td>" + Location + "</td>"; messageBody += "</tr>"; OpenFileForWriting(pendingmanualrow["EmpCode"].ToString() + " " + pendingmanualrow["WorkDate"].ToString() + " " + pendingmanualrow["InPunch"].ToString() + " " + pendingmanualrow["OutPunch"].ToString() + " " + pendingmanualrow["Status"].ToString() + " '" + Location + "'"); } messageBody += "</table></br>"; messageBody += "<br><br>"; messageBody += Environment.NewLine + " " + Environment.NewLine; messageBody += Environment.NewLine + " " + Environment.NewLine; } else { ErrorLog.ErrorLogfile(@"" + directoryname + " ", "No pending manual entry record found for employee under Manager/HR ID :'" + managerorhrcode + "' and name '" + managerorhrname + "'", ""); } #endregion #region Overtime query = "select ot.EMPID as EmpCode , ot.OTDate as WorkDate , ot.OTHrs as OTHours , md.status as Status from overtime ot join MASTERPROCESSDAILYDATA md on ot.otdate = md.PDate and ot.EMPID = md.emp_id where ot.Flag = 1 and ot.EMPID in (select EmpID from [FetchEmployees] ('" + managerorhrcode + "',''))"; overtime_pending_data = db_connection.ReturnDataTable(query); if (overtime_pending_data.Rows.Count > 0) { OpenFileForWriting("Your pending OT approval : " + DateTime.Now.ToString("dd-MMM-yyyy")); OpenFileForWriting("Employee ID" + " " + "Date" + " " + "OTHours" + " " + "Status" + "Access Link"); messageBody += "Pending OT Entry Approval List as on : " + DateTime.Now.ToString("dd-MMM-yyyy"); messageBody += "<br><br>"; messageBody += "<tr>"; messageBody += "<table border=1>"; messageBody += "<tr><td>Employee ID</td>"; messageBody += "<td>Date</td>"; messageBody += "<td>OTHours</td>"; messageBody += "<td>Status</td>"; // messageBody += "<td>Access Link</td>"; messageBody += "</tr>"; foreach (DataRow pendingotrow in overtime_pending_data.Rows) { Location = f.IniReadValue("Location", "value"); encrypt = SSTCryptographer.Encrypt(managerorhrcode, "SampleKey"); managerurl = "?MP=" + encrypt + ""; Location = Location + managerurl; Location = ConvertUrlsToLinks(Location); messageBody += "<tr>"; messageBody += "<td>" + pendingotrow["EmpCode"].ToString() + "</td>"; messageBody += "<td>" + pendingotrow["WorkDate"].ToString() + "</td>"; messageBody += "<td>" + pendingotrow["OTHours"].ToString() + "</td>"; messageBody += "<td>" + pendingotrow["Status"].ToString() + "</td>"; // messageBody += "<td>" + Location + "</td>"; messageBody += "</tr>"; messageBody += "</tr>"; OpenFileForWriting(pendingotrow["EmpCode"].ToString() + " " + pendingotrow["WorkDate"].ToString() + " " + pendingotrow["OTHours"].ToString() + " " + pendingotrow["Status"].ToString() + " '" + Location + "'"); } messageBody += "</table></br>"; messageBody += "<br><br>"; messageBody += Environment.NewLine + " " + Environment.NewLine; messageBody += Environment.NewLine + " " + Environment.NewLine; } else { ErrorLog.ErrorLogfile(@"" + directoryname + " ", "No pending OT record found for employee under Manager/HR ID :'" + managerorhrcode + "' and name '" + managerorhrname + "'", ""); } #endregion #region OUTOFFOFFICE*/ query = string.Empty; if (ismanager == "1") { query = @" select Emp_ID, Emp_Name,OOO_type_name,FromDateTime,ToDateTime from outoffoffice O join OOOType OT on O.OOO_type=OT.OOO_type_id where Manager_Status=1 and Emp_ID in (select EmpID from [FetchEmployees] ('" + managerorhrcode + "',''))"; } if (ishr == "1") { query = @" select Emp_ID,Emp_Name,OOO_type_name,FromDateTime,ToDateTime from outoffoffice O join OOOType OT on O.OOO_type=OT.OOO_type_id where HR_Status=1 and Emp_ID in (select EmpID from [FetchEmployees] ('" + managerorhrcode + "',''))"; } query += " and Emp_ID!='" + managerorhrcode + "'"; out_of_office = db_connection.ReturnDataTable(query); if (out_of_office.Rows.Count > 0) { messageBody += "Dear " + managerorhrname + ",<br/>" + "<br/>"; messageBody += "Please find pending approval records for your reportee employee. " + "<br/>" + "<br/>"; OpenFileForWriting("Your Pending OUT OF OFFICE Approval : " + DateTime.Now.ToString("dd-MMM-yyyy")); OpenFileForWriting("Employee ID" + " " + "Employee Name" + " " + "OUT OF OFFICE Type" + " " + "From DateTime" + " " + "To DateTime"); messageBody += "Pending OUT OF OFFICE Approval List as on : " + DateTime.Now.ToString("dd-MMM-yyyy"); messageBody += "<br><br>"; messageBody += "<table border=1>"; messageBody += "<tr><td>Employee ID</td>"; messageBody += "<td>Employee Name</td>"; messageBody += "<td>OUT OF OFFICE Type</td>"; messageBody += "<td>From DateTime</td>"; messageBody += "<td>To DateTime</td>"; messageBody += "</tr>"; foreach (DataRow pendingooorow in out_of_office.Rows) { Location = f.IniReadValue("Location", "value"); encrypt = SSTCryptographer.Encrypt(managerorhrcode, "SampleKey"); managerurl = "?MP=" + encrypt + ""; Location = Location + managerurl; Location = ConvertUrlsToLinks(Location); messageBody += "<tr>"; messageBody += "<td>" + pendingooorow["Emp_ID"].ToString() + "</td>"; messageBody += "<td>" + pendingooorow["Emp_Name"].ToString() + "</td>"; messageBody += "<td>" + pendingooorow["OOO_type_name"].ToString() + "</td>"; messageBody += "<td>" + pendingooorow["FromDateTime"].ToString() + "</td>"; messageBody += "<td>" + pendingooorow["ToDateTime"].ToString() + "</td>"; messageBody += "</tr>"; OpenFileForWriting(pendingooorow["Emp_ID"].ToString() + " " + pendingooorow["Emp_Name"].ToString() + " " + pendingooorow["OOO_type_name"].ToString() + " " + pendingooorow["FromDateTime"].ToString() + " " + pendingooorow["ToDateTime"].ToString()); } messageBody += "</table></br>"; messageBody += "<br><br>"; messageBody += Environment.NewLine + " " + Environment.NewLine; messageBody += Environment.NewLine + " " + Environment.NewLine; } else { ErrorLog.ErrorLogfile(@"" + directoryname + " ", "No pending OUT OF OFFICE record found for employee under Manager/HR ID :'" + managerorhrcode + "' and name '" + managerorhrname + "'", ""); } #endregion if (overtime_pending_data.Rows.Count > 0 || manual_entry_pending_data.Rows.Count > 0 || out_of_office.Rows.Count > 0) { messageBody += "<br /><br /> Thanks and Regards.<br /> <b>"; messageBody += "<br /><br /> Please do not reply on this mail, because it is system generated mail!<br /> <b>"; mailsendflag = MailSender.SendEmail(managerorhremail, "", messageBody, "", managerorhrname, directoryname); if (mailsendflag) { ErrorLog.ErrorLogfile(@"" + directoryname + " ", "Mail Sending done successfull for Manager email ID :'" + managerorhrcode + "' and name '" + managerorhrname + "'", ""); } else { ErrorLog.ErrorLogfile(@"" + directoryname + " ", "Mail Sending failed for Manager email ID :'" + managerorhrcode + "' and name '" + managerorhrname + "'", ""); } } } else { ErrorLog.ErrorLogfile(@"" + directoryname + " ", "EmailID is blank for Manager/HR ID " + managerorhrcode + " and name " + managerorhrname + " ", ""); } } } else { } } catch (Exception ex) { ErrorLog.ErrorLogfile(@"" + directoryname + " ", ex.Message, ex.StackTrace); } }
private void Login(Hashtable namedate, Hashtable dochash, Hashtable rephash, Hashtable slipshash) { try { FileStream fs = null; moConnection.WaitTimeout = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "TimeOut", 1)); string serverip = Static.ToStr(Static.RegisterGet(mstrRegPath, "Login", "Server", "")); int portno = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "PortNo", "")); int userno = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "UserNo", "")); string[] tfilename = Directory.GetDirectories(Terminaldir); if (serverip != "" || portno != 0) { moConnection.Connect(serverip, portno); if (moConnection.Connected) { string cas = ""; Result res = moConnection.Call(userno, 224, 100003, 100003, new object[] { namedate, dochash, rephash, slipshash }); if (res.ResultNo == 0) { Hashtable hash = (Hashtable)res.Param[0]; if (hash.Count != 0) { if (!Directory.Exists(@Terminaldir + @"\temp")) { Directory.CreateDirectory(@Terminaldir + @".\temp"); } for (int j = 0; j < hash.Count; j++) { ArrayList array = (ArrayList)hash[j]; byte[] bytes = (byte[])array[1]; fs = File.Create(Terminaldir + "\\temp\\" + Static.ToStr(array[0])); fs.Write(bytes, 0, Static.ToInt(bytes.Length)); fs.Flush(); fs.Close(); fs.Dispose(); cas = cas + SSTCryptographer.Encrypt(Static.ToStr(array[0]), "SampleKey") + " " + array[2] + " " + Static.ToStr(array[3]) + " "; Program.updatefiles = cas.TrimEnd(); Program.selfupdate = 1; selfupdate = true; } } } else { if (res.ResultNo == 9110135) { Program.updatefiles = res.ResultDesc; string[] name = res.ResultDesc.Split(' '); Hashtable hash = (Hashtable)res.Param[0]; if (hash.Count != 0) { if (!Directory.Exists(@".\temp")) { Directory.CreateDirectory(@".\temp"); } for (int j = 0; j < hash.Count; j++) { ArrayList array = (ArrayList)hash[j]; byte[] bytes = (byte[])array[1]; fs = File.Create(Terminaldir + "\\temp\\" + Static.ToStr(array[0])); fs.Write(bytes, 0, Static.ToInt(bytes.Length)); fs.Flush(); fs.Close(); fs.Dispose(); cas = cas + SSTCryptographer.Encrypt(Static.ToStr(array[0]), "SampleKey") + " " + array[2] + " " + Static.ToStr(array[3]) + " "; } } Program.selfupdate = 1; Program.updatefiles = cas; MessageBox.Show(this, "Шинэчлэгч өөрийгөө шинэчлэсэн тул хуулах үйлдэл дууссаны дараа дахин шинэчлэх үйлдлээ хийнэ үү.", "Мэдээлэл", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(res.ResultNo + " " + res.ResultDesc); } } this.Close(); } else { MessageBox.Show("Серверт холбогдож чадсангүй"); } } else { MessageBox.Show("Тохиргоо буруу байна."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }