/// <summary> /// /// </summary> /// <param name="attrib"></param> /// <returns></returns> public TestTemplateAttributeDto Addattribute(TestTemplateAttribute attrib) { TestTemplateAttributeRepository repo = new TestTemplateAttributeRepository(); MapperConfig.ConfigAutoMapper(); if (this.IsValidAttribute(attrib)) { if (repo.GetAttribute(attrib.Attribute) == null) { attrib.CreatedDate = DateTime.Now; attrib.CreatedBy = "MLT"; attrib.ModifiedBy = null; attrib.ModifiedDate = null; var saveattrib = repo.Insert(Mapper.Map <TestTemplateAttribute>(attrib)); return(Mapper.Map <TestTemplateAttributeDto>(attrib)); } else { throw new InvalidOperationException("Template is not acceptable.Already saved template"); } } else { throw new ArgumentNullException("Provided information is not valid."); } }
/// <summary> /// /// </summary> /// <param name="updateAttribute"></param> /// <param name="user"></param> /// <returns></returns> public TestTemplateAttributeDto UpdateAttribute(TestResultDto updateAttribute, UserDto user) { MapperConfig.ConfigAutoMapper(); if ((updateAttribute != null) && (user != null)) { PatientTestResultHelper Resulthelp = new PatientTestResultHelper(); // Attribute set according to the visit ID IList <TestResultDto> ResultAttributes = Resulthelp.GetTestResults(updateAttribute.VisitID); //updateAttribute.AttrID = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).AttrID; updateAttribute.ModifiedDate = DateTime.Now; updateAttribute.VisitID = Resulthelp.GetResultByID(updateAttribute.ID).VisitID; updateAttribute.AttrID = Resulthelp.GetResultByID(updateAttribute.ID).AttrID; updateAttribute.CreatedBy = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).CreatedBy; updateAttribute.CreatedDate = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).CreatedDate; updateAttribute.ModifiedBy = user.Username; ResultRepo.Update(Mapper.Map <TestResult>(updateAttribute)); } else { System.Diagnostics.Debug.WriteLine("Null Attribute ! / Null User "); } return(null); }
/// <summary> /// /// </summary> /// <param name="visitid"></param> /// <param name="template"></param> /// <returns></returns> public PatientTestDto AddNewPatientTest(int visitid, TestTemplate template) { MapperConfig.ConfigAutoMapper(); PatientTest Test = new PatientTest(); int testTemplateID = TestTemplateRepository.GetTestTemplate(template.TemplateName).TestTemplateId; Test.TemplateID = testTemplateID; Test.VisitID = visitid; /*This will update by MLT After he Approved the test */ Test.ApprovedBy = 0; Test.CreatedBy = "EMP"; Test.Price = TestTemplateRepository.GetTestTemplate(template.TemplateName).Price; Test.CreatedDate = DateTime.Now; Test.ApprovedDate = DateTime.Now; Test.ModifiedBy = string.Empty; Test.ModifiedDate = null; var patientTest = PatientTestRepository.Insert(Mapper.Map <PatientTest>(Test)); return(Mapper.Map <PatientTestDto>(patientTest)); }
/// <summary> /// /// </summary> /// <param name="attribute"></param> /// <returns></returns> /// public TestResultDto DeleteAttribute(TestResultDto attribute) { PatientTestResultHelper visitHelper = new PatientTestResultHelper(); MapperConfig.ConfigAutoMapper(); if (attribute != null) { attribute.ModifiedDate = DateTime.Now; attribute.CreatedDate = new DateTime(2017, 7, 6); attribute.CreatedBy = "EMP01"; attribute.ModifiedBy = null; IList <TestResultDto> TestRes = visitHelper.GetTestResults(attribute.VisitID); TestResult Del = context.TestResults.SingleOrDefault(item => item.ID == attribute.ID); context.TestResults.Remove(Mapper.Map <TestResult>(Del)); context.SaveChanges(); return(null); } else { throw new NullReferenceException("null attrib"); } }
/// <summary> /// /// </summary> /// <param name="role"></param> /// <returns></returns> public RoleDto DeleteRole(Role role) { MapperConfig.ConfigAutoMapper(); if (role.RoleID.ToString() != null) { int Role = RoleRepo.GetRole(role.RoleID).RoleID; if (Role.ToString() != null) { role.CreatedBy = RoleRepo.GetRole(role.RoleID).CreatedBy; role.CreatedDate = RoleRepo.GetRole(role.RoleID).CreatedDate; role.ModifiedBy = RoleRepo.GetRole(role.RoleID).ModifiedBy; role.ModifiedDate = RoleRepo.GetRole(role.RoleID).ModifiedDate; Role DelRole = context.Roles.SingleOrDefault(item => item.RoleID == role.RoleID); context.Roles.Remove(DelRole); context.SaveChanges(); } else { System.Diagnostics.Debug.WriteLine("Role not Exists"); } } else { System.Diagnostics.Debug.WriteLine("Null Role"); } return(null); }
/// <summary> /// /// </summary> /// <param name="doctor"></param> /// <returns></returns> public DoctorDto AddNewDoctor(Doctor doctor) { MapperConfig.ConfigAutoMapper(); if (this.IsValidDoctor(doctor)) { if ((DoctorHelp.GetDoctorByName(doctor.DoctorName) == null) || (DoctorHelp.GetDoctorBySpeciality(doctor.DoctorSpeciality) == null))// Check is Doctor Exisits { doctor.CreatedDate = DateTime.Now; doctor.CreatedBy = "Reciptionist"; doctor.ModifiedBy = string.Empty; doctor.ModifiedDate = null; var saveDoctor = DocRepo.Insert(Mapper.Map <Doctor>(doctor)); return(Mapper.Map <DoctorDto>(saveDoctor)); } else { throw new InvalidOperationException("Doctor is not acceptable to insert.Already exists"); } } else { throw new ArgumentNullException("Provided information is not valid."); } }
/// <summary> /// /// </summary> /// <param name="newtemplate"></param> /// <returns></returns> public TestTemplateDto AddNewTemplate(TestTemplate newtemplate) { TestTemplateRepository repo = new TestTemplateRepository(); MapperConfig.ConfigAutoMapper(); if (this.IsValidTest(newtemplate)) { if (repo.GetTestTemplate(newtemplate.TemplateName) == null) { newtemplate.CreatedDate = DateTime.Now; newtemplate.CreatedBy = "Test"; newtemplate.ModifiedBy = string.Empty; newtemplate.ModifiedDate = null; var savetemp = repo.Insert(Mapper.Map <TestTemplate>(newtemplate)); return(Mapper.Map <TestTemplateDto>(savetemp)); } else { throw new InvalidOperationException("Template is not acceptable.Already saved template"); } } else { throw new ArgumentNullException("Provided information is not valid."); } }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <returns></returns> public UserDto UpdateUser(UserDto user) { MapperConfig.ConfigAutoMapper(); if (user == null) { throw new NullReferenceException("null user"); } else { RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buffer = new byte[50]; byte[] salt = new byte[25]; rng.GetBytes(salt); string saltString = Encoding.Default.GetString(salt); string hashedPassString = this.GenerateSaltedHash(user.Password, saltString); user.Password = hashedPassString; user.PasswordSalt = saltString; user.CreatedBy = UserHelp.GetUser(user.UserId).CreatedBy; user.CreatedDate = UserHelp.GetUser(user.UserId).CreatedDate; user.ModifiedDate = DateTime.Now; user.NumOfInvalidLogins = 0; userRepo.Update(Mapper.Map <User>(user)); } return(null); }
/// <summary> /// /// </summary> /// <param name="patient"></param> /// <returns></returns> public PatientDto AddNewPatient(Patient patient) { MapperConfig.ConfigAutoMapper(); patient.CreatedDate = DateTime.Now; patient.CreatedBy = "EMP_RECIPTION"; patient.ModifiedBy = string.Empty; patient.ModifiedDate = null; var savePatient = PatientRepository.Insert(Mapper.Map <Patient>(patient)); return(Mapper.Map <PatientDto>(savePatient)); }
/// <summary> /// /// </summary> /// <param name="Result"></param> /// <returns></returns> public TestResultDto AddNewTestResult(TestResult Result) { MapperConfig.ConfigAutoMapper(); Result.CreatedDate = DateTime.Now; Result.CreatedBy = "EMP"; Result.ModifiedDate = null; Result.ModifiedBy = string.Empty; var NewResult = TestResultRepository.Insert(Mapper.Map <TestResult>(Result)); return(Mapper.Map <TestResultDto>(NewResult)); }
/// <summary> /// /// </summary> /// <param name="doctor"></param> /// <returns></returns> public DoctorDto AddNewDoctor(Doctor doctor) { MapperConfig.ConfigAutoMapper(); doctor.CreatedDate = DateTime.Now; doctor.CreatedBy = "EMP_RECIPTION"; doctor.ModifiedBy = string.Empty; doctor.ModifiedDate = null; var saveDoctor = DoctorRepository.Insert(Mapper.Map <Doctor>(doctor)); return(Mapper.Map <DoctorDto>(saveDoctor)); }
/// <summary> /// /// </summary> /// <param name="doctor"></param> /// <returns></returns> public object DeleteDoctor(Doctor doctor) { MapperConfig.ConfigAutoMapper(); { Doctor DelDoctor = context.Doctors.SingleOrDefault(item => item.DoctorId == doctor.DoctorId); context.Doctors.Remove(DelDoctor); context.SaveChanges(); //patientRepo.Delete(Mapper.Map<Patient>(DelPatietnt)); } return(null); }
/// <summary> /// /// </summary> /// <param name="chk"></param> /// <returns></returns> public DoctorDto GetDoctor(Doctor chk) { MapperConfig.ConfigAutoMapper(); if (DoctorHelp.GetDoctorByName(chk.DoctorName) == null || DoctorHelp.GetDoctorBySpeciality(chk.DoctorSpeciality) == null) { System.Diagnostics.Debug.WriteLine("Doctor not found"); return(null); } else { System.Diagnostics.Debug.WriteLine("Doctor Found!"); return(null); } }
/// <summary> /// /// </summary> /// <param name="patient"></param> /// <returns></returns> public PatientDto DeletePatient(Patient patient) { MapperConfig.ConfigAutoMapper(); if (patient.ContactNo.Length <= 10) { Patient DelPatietnt = context.Patients.FirstOrDefault(item => item.ContactNo == patient.ContactNo); context.Patients.Remove(DelPatietnt); context.SaveChanges(); } else { System.Diagnostics.Debug.WriteLine("Invalid Contact Number"); throw new ArgumentNullException(); } return(null); }
/// <summary> /// /// </summary> /// <param name="role"></param> /// <returns></returns> public RoleDto UpdateRole(Role role) { MapperConfig.ConfigAutoMapper(); if (role != null) { role.CreatedDate = RoleRepo.GetRole(role.RoleID).CreatedDate; role.CreatedBy = RoleRepo.GetRole(role.RoleID).CreatedBy; role.ModifiedBy = "Administrator"; role.ModifiedDate = DateTime.Now; RoleRepo.Update(Mapper.Map <Role>(role)); } else { System.Diagnostics.Debug.WriteLine("Null Role"); } return(null); }
/// <summary> /// Adds the new user. /// </summary> /// <param name="user">The user.</param> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> /// public UserDto AddNewUser(UserDto user) { MapperConfig.ConfigAutoMapper(); if (this.IsUserValid(user)) { if (userRepo.GetUser(user.Username) == null) { RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buffer = new byte[50]; byte[] salt = new byte[25]; rng.GetBytes(salt); string saltString = Encoding.Default.GetString(salt); string hashedPassString = this.GenerateSaltedHash(user.Password, saltString); user.Password = hashedPassString; user.PasswordSalt = saltString; user.IsLoked = false; user.LastLogin = null; user.NumOfInvalidLogins = 0; user.CreatedBy = "Test User"; user.CreatedDate = DateTime.Now; user.ModifiedBy = string.Empty; user.ModifiedDate = null; var savedUser = userRepo.Insert(Mapper.Map <User>(user)); return(Mapper.Map <UserDto>(savedUser)); } else { throw new InvalidOperationException("Username is not available."); } } else { throw new ArgumentNullException("Provided information is not valid."); } }
/// <summary> /// /// </summary> /// <param name="patientTest"></param> /// <param name="user"></param> /// <returns></returns> /// public PatientTestDto ApproveTest(PatientTest patientTest, User user) { MapperConfig.ConfigAutoMapper(); patientTest.TemplateID = TestRepo.GetTest(patientTest.VisitID).TemplateID; patientTest.PatientTestID = TestRepo.GetTest(patientTest.VisitID).PatientTestID; patientTest.CreatedBy = TestRepo.GetTest(patientTest.VisitID).CreatedBy; patientTest.ModifiedBy = user.Username; patientTest.ApprovedBy = user.UserId; patientTest.CreatedDate = new DateTime(2016, 5, 5); patientTest.ModifiedDate = DateTime.Now; patientTest.ApprovedDate = DateTime.Now; System.Diagnostics.Debug.WriteLine("Test Approved by : " + user.Username + " "); TestRepo.Update(Mapper.Map <PatientTest>(patientTest)); return(null); }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <returns></returns> public UserDto DeleteUser(UserDto user) { MapperConfig.ConfigAutoMapper(); { if (user == null) { throw new NullReferenceException("null user"); } else { User DelUser = context.Users.SingleOrDefault(item => item.UserId == user.UserId); context.Users.Remove(DelUser); context.SaveChanges(); } //patientRepo.Delete(Mapper.Map<Patient>(DelPatietnt)); } return(null); }
/// <summary> /// /// </summary> /// <param name="attrib"></param> /// <returns></returns> public TestTemplateAttributeDto Updateattribute(TestTemplateAttribute attrib) { TestTemplateAttributeRepository repo = new TestTemplateAttributeRepository(); attrib.CreatedDate = repo.GetAttribute(attrib.Attribute).CreatedDate; attrib.AttrID = repo.GetAttribute(attrib.Attribute).AttrID; attrib.TemplateID = repo.GetAttribute(attrib.Attribute).TemplateID; attrib.CreatedBy = repo.GetAttribute(attrib.Attribute).CreatedBy; MapperConfig.ConfigAutoMapper(); { repo.Update(Mapper.Map <TestTemplateAttribute>(attrib)); } return(null); }
/// <summary> /// /// </summary> /// <param name="role"></param> /// <returns></returns> public RoleDto createRole(Role role) { MapperConfig.ConfigAutoMapper(); if (this.IsRoleValid(role)) { role.CreatedDate = DateTime.Now; role.CreatedBy = "Administrator"; role.ModifiedDate = null; role.ModifiedBy = string.Empty; var saveRole = RoleRepo.Insert(Mapper.Map <Role>(role)); return(Mapper.Map <RoleDto>(saveRole)); } else { System.Diagnostics.Debug.WriteLine("Role not Created ! Validation Failed !"); } return(null); }
/// <summary> /// /// </summary> /// <param name="Patient"></param> /// <returns></returns> /// public Patient Getresults(PatientDto Patient) { MapperConfig.ConfigAutoMapper(); if (patient.GetPatient(Patient.ContactNo) != null) { int PatientID = patient.GetPatient(Patient.ContactNo).PatientId; int visitID = visitHelper.GetVisitByPatientID(PatientID).PatientVisitId; IList <TestResultDto> TestAttribute = helper.GetTestResults(visitID); System.Diagnostics.Debug.WriteLine("Result set Found !"); System.Diagnostics.Debug.WriteLine(TestAttribute); } else { System.Diagnostics.Debug.WriteLine("Patient Not Found !"); } return(null); }
/// <summary> /// /// </summary> /// <param name="patient"></param> /// <returns></returns> public PatientDto PatientUpdate(Patient patient) { MapperConfig.ConfigAutoMapper(); if (patient.ContactNo.Length <= 10) { patient.CreatedBy = patientRepo.GetPatient(patient.ContactNo).CreatedBy; patient.CreatedDate = patientRepo.GetPatient(patient.ContactNo).CreatedDate; patient.ModifiedBy = patientRepo.GetPatient(patient.ContactNo).ModifiedBy; patient.ModifiedDate = DateTime.Now; } else { System.Diagnostics.Debug.WriteLine("Invalid Contact Number"); throw new ArgumentNullException(); } { patientRepo.Update(Mapper.Map <Patient>(patient)); } return(null); }
/// <summary> /// /// </summary> /// <param name="doctor"></param> /// <returns></returns> public DoctorDto DoctorUpdate(Doctor doctor) { MapperConfig.ConfigAutoMapper(); if (DocRepo.GetDoctor(doctor.DoctorId) != null) { doctor.CreatedDate = DocRepo.GetDoctor(doctor.DoctorId).CreatedDate; doctor.ModifiedBy = DocRepo.GetDoctor(doctor.DoctorId).ModifiedBy; doctor.CreatedBy = DocRepo.GetDoctor(doctor.DoctorId).CreatedBy; doctor.ModifiedDate = DateTime.Now; { DocRepo.Update(Mapper.Map <Doctor>(doctor)); } } else { throw new ArgumentNullException("Doctor not found!"); } return(null); }
/// <summary> /// /// </summary> /// <param name="patientVisit"></param> /// <param name="Template"></param> /// <returns></returns> public PatientVisitDto AddNewPatientVisit(PatientVisit patientVisit, TestTemplate Template) { PatientVisitHelper visithelp = new PatientVisitHelper(); MapperConfig.ConfigAutoMapper(); if (this.ValidateVisit(patientVisit)) { patientVisit.CreatedDate = DateTime.Now; patientVisit.CreatedBy = "EMP"; patientVisit.ModifiedDate = new DateTime(2017, 12, 2); patientVisit.ModifiedBy = string.Empty; // if (DoctorRepository.GetDoctor(patientVisit.Doctor.DoctorId) == null) if (DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName) == null || DoctorHelp.GetDoctorBySpeciality(patientVisit.Doctor.DoctorSpeciality) == null) { this.AddNewDoctor(patientVisit.Doctor); System.Diagnostics.Debug.WriteLine("Doctor Added"); patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName); } else { patientVisit.DoctorID = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName).DoctorId; patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName); System.Diagnostics.Debug.WriteLine("Doctor Exists"); } if (PatientRepository.GetPatient(patientVisit.Patient.ContactNo) == null) { this.AddNewPatient(patientVisit.Patient); patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo); System.Diagnostics.Debug.WriteLine("Patient Added"); } else { patientVisit.PatientID = PatientRepository.GetPatient(patientVisit.Patient.ContactNo).PatientId; patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo); System.Diagnostics.Debug.WriteLine("Patient Exists"); } patientVisit.UserId = UserRepository.GetUser(patientVisit.User.Username).UserId; patientVisit.User.RoleId = 1; patientVisit.User = UserRepository.GetUser(patientVisit.User.Username); var NewVisit = PatientVisitRepo.Insert(Mapper.Map <PatientVisit>(patientVisit)); Mapper.Map <PatientVisitDto>(NewVisit); System.Diagnostics.Debug.WriteLine("Visit Added"); int VisitId = NewVisit.PatientVisitId; this.AddNewPatientTest(VisitId, Template); System.Diagnostics.Debug.WriteLine("Patient Test Added"); int testTemplateID = TestTemplateRepository.GetTestTemplate(Template.TemplateName).TestTemplateId; IList <TestTemplateAttributeDto> TestAttribute = visithelp.GetTestTemplateAttributes(testTemplateID); TestResult results = new TestResult(); foreach (var x in TestAttribute) { results.AttrID = x.AttrID; results.VisitID = VisitId; results.Status = "NO STATUS YET"; results.Value = "NO VALUE YET"; this.AddNewTestResult(results); } System.Diagnostics.Debug.WriteLine("Result Added"); } else { throw new ArgumentNullException("Provided information is not valid."); } return(null); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public UserDto Login(string username, string password) { /// ToDo: Remove this code after testing MapperConfig.ConfigAutoMapper(); if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { var user = userRepo.GetUser(username); if (user != null) { if (!user.IsLoked) { var hashedPass = this.GenerateSaltedHash(password, user.PasswordSalt); if (hashedPass.Equals(user.Password)) { user.NumOfInvalidLogins = 0; user.IsLoked = false; user.LastLogin = DateTime.Now; userRepo.Update(user); user.Password = string.Empty; user.PasswordSalt = string.Empty; System.Diagnostics.Debug.WriteLine("Login success!"); return(Mapper.Map <UserDto>(user)); } else { if (user.NumOfInvalidLogins < 2) { user.NumOfInvalidLogins++; userRepo.Update(user); throw new InvalidOperationException("Login not succesful."); } else { user.NumOfInvalidLogins++; user.IsLoked = true; userRepo.Update(user); throw new InvalidOperationException("Login not succesful. Account Locked!."); } } } else { throw new InvalidOperationException("User has been locked."); } } else { throw new InvalidOperationException("User not found."); } } else { throw new ArgumentNullException("Username or password cannot be null or empty."); } }
/// <summary> /// /// </summary> /// <param name="printreport"></param> /// <returns></returns> public TestResultDto PrintReport(TestResultDto printreport) { MapperConfig.ConfigAutoMapper(); if (printreport != null) { int patientid = visit.GetVisit(printreport.VisitID).PatientID; var patient = base.context.Patients.AsNoTracking().FirstOrDefault(p => p.PatientId.Equals(patientid)); String name = patient.Name; int age = patient.Age; string sex = patient.Gender; string address = patient.Address; string number = patient.ContactNo; DateTime arrivedate = visit.GetVisit(printreport.VisitID).ArriveDate; DateTime ExpDelDate = visit.GetVisit(printreport.VisitID).ExpectedDeliveryDate; int TesTID = test.GetTest(printreport.VisitID).TemplateID; var testTemplate = base.context.TestTemplates.FirstOrDefault(p => p.TestTemplateId.Equals(TesTID)); string templatename = testTemplate.TemplateName; int temID = testTemplate.TestTemplateId; decimal price = testTemplate.Price; IList <TestResultDto> results = resultSet.GetTestResults(printreport.VisitID); IList <TestTemplateAttributeDto> Attribs = VisitHelper.GetTestTemplateAttributes(temID); string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments); string fileName = "" + path + "\\Report.docx"; var doc = DocX.Create(fileName); doc.InsertParagraph(" __________________________________________________________________________________________________ "); doc.InsertParagraph(""); doc.InsertParagraph(" MEDICAL LAB REPORT MANAGEMENT SYSTEM | FINAL TEST REPORT "); doc.InsertParagraph(""); doc.InsertParagraph(" __________________________________________________________________________________________________ "); doc.InsertParagraph(" "); doc.InsertParagraph(" "); doc.InsertParagraph(" Patient Name : " + name + " Gender : " + sex + " "); doc.InsertParagraph(" "); doc.InsertParagraph(" "); doc.InsertParagraph(" Patient Age : " + age + " Address:" + address + " Payment : RS: " + price + ""); doc.InsertParagraph(" "); doc.InsertParagraph(" "); doc.InsertParagraph(" Contact Number : " + number + " Test : " + templatename + " "); doc.InsertParagraph(" "); doc.InsertParagraph(""); doc.InsertParagraph(" Arrived Date: " + arrivedate + " Deliver Date:" + ExpDelDate + " "); doc.InsertParagraph(" "); doc.InsertParagraph(" __________________________________________________________________________________________________ "); doc.InsertParagraph(""); doc.InsertParagraph(" Patients Results "); doc.InsertParagraph(""); doc.InsertParagraph(""); int seq = 1; foreach (var x in results) { doc.InsertParagraph(" " + seq + " Value: " + x.Value + " Status : " + x.Status + ""); doc.InsertParagraph(""); seq++; if (seq > Attribs.Count) { break; } } doc.InsertParagraph(""); doc.InsertParagraph(""); doc.InsertParagraph(" Reffer below Information. "); doc.InsertParagraph(""); doc.InsertParagraph(""); int NextSeq = 1; foreach (var x in Attribs) { doc.InsertParagraph(" " + NextSeq + " . " + x.Attribute + " --> " + x.PrefferedLimit + ""); doc.InsertParagraph(""); doc.InsertParagraph(""); NextSeq++; } doc.Save(); /*Open as html format*/ SautinSoft.RtfToHtml z = new SautinSoft.RtfToHtml(); string docxFile = Path.GetFullPath(fileName); string htmlFile = Path.ChangeExtension(docxFile, ".html"); z.OpenDocx(docxFile); z.ToHtml(htmlFile); System.Diagnostics.Process.Start(htmlFile); return(null); } else { throw new ArgumentNullException("Provided information is not valid."); } }