/// <summary> /// Adaptive approximation of the definite integral in the provided interval by the trapezium rule. /// </summary> public double IntegrateAdaptive( CustomFunction f, double intervalBegin, double intervalEnd, double targetRelativeError) { int numberOfPartitions = 1; double step = intervalEnd - intervalBegin; double sum = 0.5 * step * (f(intervalBegin) + f(intervalEnd)); for(int k = 0; k < 20; k++) { double midpointsum = 0; for(int i = 0; i < numberOfPartitions; i++) { midpointsum += f(intervalBegin + ((i + 0.5) * step)); } midpointsum *= step; sum = 0.5 * (sum + midpointsum); step *= 0.5; numberOfPartitions *= 2; if(Number.AlmostEqual(sum, midpointsum, targetRelativeError)) { break; } } return sum; }
/// <summary> /// Composite N-point approximation of the definite integral in the provided interval by Simpson's rule. /// </summary> public double IntegrateComposite( CustomFunction f, double intervalBegin, double intervalEnd, int numberOfPartitions) { if(numberOfPartitions <= 0) { throw new ArgumentOutOfRangeException("numberOfPartitions", Properties.LocalStrings.ArgumentPositive); } if(IntegerTheory.IsOdd(numberOfPartitions)) { throw new ArgumentException(Properties.LocalStrings.ArgumentEven, "numberOfPartitions"); } double step = (intervalEnd - intervalBegin) / numberOfPartitions; double factor = step / 3; double offset = step; int m = 4; double sum = f(intervalBegin) + f(intervalEnd); for(int i = 0; i < numberOfPartitions - 1; i++) { // NOTE (ruegg, 2009-01-07): Do not combine intervalBegin and offset (numerical stability!) sum += m * f(intervalBegin + offset); m = 6 - m; offset += step; } return factor * sum; }
public void AddCustomFunction(string name, FunctionDelegate2 function) { string lowername = name.ToLower(); if (m_Functions.ContainsKey(lowername)) throw new FunctionAlreadyDefinedException("Function " + name + " already defined!"); m_Functions[lowername] = new CustomFunction(lowername, function); }
/// <summary> /// Approximation of the definite interval of an analytic smooth function on a closed interval. /// </summary> /// <param name="f">The analytic smooth function to integrate.</param> /// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param> /// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param> public static double OnClosedInterval( CustomFunction f, double intervalBegin, double intervalEnd) { return Det.Integrate( f, intervalBegin, intervalEnd, 1e-8); }
/// <summary> /// Approximation of the definite interval of an analytic smooth function on a closed interval. /// </summary> /// <param name="f">The analytic smooth function to integrate.</param> /// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param> /// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param> /// <param name="targetAbsoluteError">The expected relative accuracy of the approximation.</param> public static double OnClosedInterval( CustomFunction f, double intervalBegin, double intervalEnd, double targetAbsoluteError) { return Det.Integrate( f, intervalBegin, intervalEnd, targetAbsoluteError); }
void slyceGridEntities_CellValueChanged(int row, int cell, int column, string columnHeader, ref object tag, object newValue) { if (slyceGridEntities.Columns[column].Tag is CustomNamespace) { CustomNamespace ns = (CustomNamespace)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { ns.Entities.Add(entity); } else { ns.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomImplement) { CustomImplement ci = (CustomImplement)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { ci.Entities.Add(entity); } else { ci.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomAttribute) { CustomAttribute ca = (CustomAttribute)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { ca.Entities.Add(entity); } else { ca.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomProperty) { CustomProperty cp = (CustomProperty)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { cp.Entities.Add(entity); } else { cp.Entities.Remove(entity); } } else if (slyceGridEntities.Columns[column].Tag is CustomFunction) { CustomFunction cm = (CustomFunction)slyceGridEntities.Columns[column].Tag; Entity entity = (Entity)slyceGridEntities.Items[row].Tag; bool isChecked = (bool)newValue; if (isChecked) { cm.Entities.Add(entity); } else { cm.Entities.Remove(entity); } } }
public ActionResult AdjustLeaves(FormCollection collection) { float AL = float.Parse(Request.Form["ALeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float CL = float.Parse(Request.Form["CLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float SL = float.Parse(Request.Form["SLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float CPL = float.Parse(Request.Form["CPLLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); int EmpID = Convert.ToInt32(Request.Form["EmpID"].ToString()); string year = Request.Form["LvYear"].ToString(); string EmpLvTypeYearCL = EmpID.ToString() + "A" + year; string EmpLvTypeYearAL = EmpID.ToString() + "B" + year; string EmpLvTypeYearSL = EmpID.ToString() + "C" + year; string EmpLvTypeYearCPL = EmpID.ToString() + "E" + year; var lvTypeAL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearAL).ToList(); var lvTypeCL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearCL).ToList(); var lvTypeSL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearSL).ToList(); var lvTypeCPL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearCPL).ToList(); //Anual if (lvTypeAL.Count > 0) { foreach (var item in lvTypeAL) { item.YearRemaining = (float)AL; item.GrandTotalRemaining = (float)AL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = AL; lvConsumed.YearRemaining = AL; lvConsumed.GrandTotal = AL; lvConsumed.GrandTotalRemaining = AL; lvConsumed.EmpLvType = EmpID.ToString() + "B"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearAL; lvConsumed.LeaveType = "B"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } //Casual if (lvTypeCL.Count > 0) { foreach (var item in lvTypeCL) { item.YearRemaining = (float)CL; item.GrandTotalRemaining = (float)CL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = CL; lvConsumed.YearRemaining = CL; lvConsumed.GrandTotal = CL; lvConsumed.GrandTotalRemaining = CL; lvConsumed.EmpLvType = EmpID.ToString() + "A"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearCL; lvConsumed.LeaveType = "A"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } //Sick if (lvTypeSL.Count > 0) { foreach (var item in lvTypeSL) { item.YearRemaining = (float)SL; item.GrandTotalRemaining = (float)SL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = SL; lvConsumed.YearRemaining = SL; lvConsumed.GrandTotal = SL; lvConsumed.GrandTotalRemaining = SL; lvConsumed.EmpLvType = EmpID.ToString() + "C"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearSL; lvConsumed.LeaveType = "C"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } //CPL if (lvTypeCPL.Count > 0) { foreach (var item in lvTypeCPL) { item.YearRemaining = (float)CPL; item.GrandTotalRemaining = (float)CPL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = CPL; lvConsumed.YearRemaining = CPL; lvConsumed.GrandTotal = CPL; lvConsumed.GrandTotalRemaining = CPL; lvConsumed.EmpLvType = EmpID.ToString() + "E"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearCPL; lvConsumed.LeaveType = "E"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View("Index")); }
/// <summary> /// Composite N-point approximation of the definite integral in the provided interval by the trapezium rule. /// </summary> public double IntegrateComposite( CustomFunction f, double intervalBegin, double intervalEnd, int numberOfPartitions) { if(numberOfPartitions <= 0) { throw new ArgumentOutOfRangeException("numberOfPartitions", Properties.LocalStrings.ArgumentPositive); } double step = (intervalEnd - intervalBegin) / numberOfPartitions; double offset = step; double sum = 0.5 * (f(intervalBegin) + f(intervalEnd)); for(int i = 0; i < numberOfPartitions - 1; i++) { // NOTE (ruegg, 2009-01-07): Do not combine intervalBegin and offset (numerical stability!) sum += f(intervalBegin + offset); offset += step; } return step * sum; }
public ActionResult EditorOT(FormCollection form) { TAS2013Entities db = new TAS2013Entities(); try { User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewData["datef"] = Convert.ToDateTime(Request.Form["DateFrom"].ToString()).ToString("yyyy-MM-dd"); //ViewData["datef"] = Request.Form["DateFrom"].ToString(); if (Request.Form["EmpNo"].ToString() != "" && Request.Form["DateFrom"].ToString() != "") { string _EmpNo = Request.Form["EmpNo"].ToString(); DateTime _AttDataFrom = Convert.ToDateTime(Request.Form["DateFrom"].ToString()); Session["EditAttendanceDate"] = Request.Form["DateFrom"].ToString(); var _CompId = Request.Form["CompanyID"]; int compID = Convert.ToInt32(_CompId); ViewAttDataOT _attData = new ViewAttDataOT(); List <EmpView> _Emp = new List <EmpView>(); int EmpID = 0; _Emp = db.EmpViews.Where(aa => aa.EmpNo == _EmpNo && aa.CompanyID == compID && aa.Status == true).ToList(); if (_Emp.Count > 0) { EmpID = _Emp.FirstOrDefault().EmpID; if (db.AttDataOTs.Where(aa => aa.EmpID == EmpID && aa.AttDate == _AttDataFrom).Count() > 0) { _attData = db.ViewAttDataOTs.First(aa => aa.EmpID == EmpID && aa.AttDate == _AttDataFrom); } } _attData.EmpID = EmpID; _attData.EmpNo = _Emp.FirstOrDefault().EmpNo; _attData.AttDate = _AttDataFrom; _attData.EmpName = _Emp.FirstOrDefault().EmpName; _attData.FatherName = _Emp.FirstOrDefault().FatherName; _attData.SectionName = _Emp.FirstOrDefault().SectionName; _attData.DeptName = _Emp.FirstOrDefault().DeptName; _attData.DesignationName = _Emp.FirstOrDefault().DesignationName; if (_attData.EmpNo != null) { List <PollData> _Polls = new List <PollData>(); string _EmpDate = _attData.EmpID.ToString() + _AttDataFrom.Date.ToString("yyMMdd"); _Polls = db.PollDatas.Where(aa => aa.EntDate == _AttDataFrom && aa.EmpID == _attData.EmpID).OrderBy(a => a.EntTime).ToList(); ViewBag.PollsDataIn = _Polls.Where(aa => aa.Reader.OnlyOT == true && aa.RdrDuty == 1); ViewBag.PollsDataOut = _Polls.Where(aa => aa.Reader.OnlyOT == true && aa.RdrDuty == 1); ViewBag.EmpID = new SelectList(db.Emps.OrderBy(s => s.EmpName), "EmpID", "EmpNo", _attData.EmpID); Session["NEmpNo"] = _attData.EmpID; ViewBag.SucessMessage = ""; return(View(_attData)); } else { return(View(_attData)); } } else { return(View("Index")); } } catch (Exception ex) { if (ex.Message.Contains("Sequence")) { ViewBag.Message = "No Entry found on this particular date"; } return(View("Index")); } }
public ActionResult Create(AttProcessorScheduler attprocessor) { string d = Request.Form["CriteriaID"].ToString(); switch (d) { case "C": attprocessor.Criteria = "C"; break; case "L": attprocessor.Criteria = "L"; break; case "A": attprocessor.Criteria = "A"; break; case "E": { attprocessor.Criteria = "E"; attprocessor.ProcessCat = false; string ee = Request.Form["EmpNo"].ToString(); int cc = Convert.ToInt16(Request.Form["CompanyIDForEmp"].ToString()); List <Emp> empss = new List <Emp>(); empss = context.Emps.Where(aa => aa.EmpNo == ee && aa.CompanyID == cc).ToList(); if (empss.Count() > 0) { attprocessor.EmpID = empss.First().EmpID; attprocessor.EmpNo = empss.First().EmpNo; } } break; } int a = Convert.ToInt16(Request.Form["ProcessCats"].ToString()); if (a == 1) { attprocessor.ProcessCat = true; } else { attprocessor.ProcessCat = false; } attprocessor.ProcessingDone = false; attprocessor.WhenToProcess = DateTime.Today; attprocessor.CreatedDate = DateTime.Now; int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); if ((attprocessor.DateTo - attprocessor.DateFrom).Days > 3 & attprocessor.PeriodTag == "D") { ModelState.AddModelError("DateTo", "Date Difference must be between 3 days!"); } if (ModelState.IsValid) { attprocessor.UserID = _userID; context.AttProcessorSchedulers.Add(attprocessor); context.SaveChanges(); return(RedirectToAction("Index")); } TAS2013Entities db = new TAS2013Entities(); User LoggedInUser = Session["LoggedUser"] as User; QueryBuilder qb = new QueryBuilder(); String query = qb.QueryForCompanyViewLinq(LoggedInUser); ViewBag.PeriodTag = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = false, Text = "Monthly", Value = "M" }, new SelectListItem { Selected = true, Text = "Daily", Value = "D" }, new SelectListItem { Selected = false, Text = "Summary", Value = "S" }, }, "Value", "Text", 1); ViewBag.CriteriaID = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = true, Text = "Company", Value = "C" }, new SelectListItem { Selected = false, Text = "Location", Value = "L" }, new SelectListItem { Selected = false, Text = "Employee", Value = "E" }, }, "Value", "Text", 1); ViewBag.ProcessCats = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = true, Text = "Yes", Value = "1" }, new SelectListItem { Selected = false, Text = "No", Value = "0" }, }, "Value", "Text", 1); if (LoggedInUser.RoleID == 1) { ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDForEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); query = qb.QueryForLocationTableSegerationForLinq(LoggedInUser); ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); } else { ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDForEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); query = qb.QueryForLocationTableSegerationForLinq(LoggedInUser); ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); } ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View(attprocessor)); }
public Complex CustomOperation(Complex number, CustomFunction function) { return(function(this, number)); }
public ActionResult Create([Bind(Include = "ShiftID,ShiftName,StartTime,DayOff1,DayOff2,Holiday,RosterType,MonMin,TueMin,WedMin,ThuMin,FriMin,SatMin,SunMin,LateIn,EarlyIn,EarlyOut,LateOut,OverTimeMin,MinHrs,HasBreak,BreakMin,GZDays,LocationID,OpenShift")] Shift shift, FormCollection form) { if (string.IsNullOrEmpty(shift.ShiftName)) { ModelState.AddModelError("ShiftName", "Required"); } if (shift.ShiftName != null) { if (shift.ShiftName.Length > 50) { ModelState.AddModelError("ShiftName", "String length exceeds!"); } if (db.Shifts.Where(aa => aa.ShiftName == shift.ShiftName).Count() > 0) { ModelState.AddModelError("ShiftName", "Shift Name must be unique"); } } if (shift.HasBreak == true) { if (shift.BreakMin == null) { ModelState.AddModelError("BreakMin", "Required"); } if (shift.LateIn == null) { ModelState.AddModelError("LateIn", "Required"); } if (shift.EarlyIn == null) { ModelState.AddModelError("EarlyIn", "Required"); } if (shift.EarlyOut == null) { ModelState.AddModelError("EarlyOut", "Required"); } if (shift.LateOut == null) { ModelState.AddModelError("LateOut", "Required"); } if (shift.OverTimeMin == null) { ModelState.AddModelError("OverTimeMin", "Required"); } if (shift.MinHrs == null) { ModelState.AddModelError("MinHrs", "Required"); } } User LoggedInUser = Session["LoggedUser"] as User; if (ModelState.IsValid) { var aaa = form["HasBreak"]; if (shift.OpenShift == true) { shift.StartTime = TimeSpan.Zero; } //shift.OpenShift = false; //shift.HasBreak = false; shift.CompanyID = LoggedInUser.CompanyID; shift.GZDays = shift.Holiday; db.Shifts.Add(shift); db.SaveChanges(); int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Shift, (byte)MyEnums.Operation.Add, DateTime.Now); return(RedirectToAction("Index")); } ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); ViewBag.DayOff1 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name", shift.DayOff1); ViewBag.DayOff2 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name", shift.DayOff2); ViewBag.RosterType = new SelectList(db.RosterTypes.OrderBy(s => s.Name), "ID", "Name", shift.RosterType); return(View(shift)); }
public ActionResult Edit([Bind(Include = "EmpID,EmpNo,EmpName,DesigID,JobID,Gender,ShiftID,LocID,TypeID,GradeID,SecID,CardNo,FpID,PinCode,NicNo,FatherName,BloodGroup,BirthDate,MarStatus,JoinDate,ValidDate,IssueDate,ResignDate,HomeAdd,ProcessAtt,ProcessIn,Status,PhoneNo,Remarks,Email,CellNo,CrewID,FlagFP,FlagFace,FlagCard,EmpImageID,CompanyID,HasOT,IsSafe,LastEntryDateTime,ReaderID")] Emp emp) { try { ViewBag.Message = ""; TAS2013Entities ctx = new TAS2013Entities(); HttpPostedFileBase file = Request.Files["ImageData"]; if (file != null) { if (file.FileName != "") { ImageConversion _Image = new ImageConversion(); int imageid = _Image.UploadImageInDataBase(file, emp); if (imageid != 0) { emp.EmpImageID = imageid; } else { } } } if (string.IsNullOrEmpty(emp.EmpNo)) { ModelState.AddModelError("EmpNo", "Emp No field is required!"); } if (string.IsNullOrEmpty(emp.EmpName)) { ModelState.AddModelError("EmpName", "Namefield is required!"); } if (emp.EmpNo != null) { if (emp.EmpNo.Length > 15) { ModelState.AddModelError("EmpNo", "String length exceeds!"); } } if (emp.EmpName != null) { if (emp.EmpName.Length > 40) { ModelState.AddModelError("EmpName", "String length exceeds!"); } } if (emp.SecID == null) { ModelState.AddModelError("SecID", "Please Specify section!"); } if (emp.TypeID == null) { ModelState.AddModelError("TypeID", "Please Specify Type!"); } if (emp.GradeID == null) { ModelState.AddModelError("GradeID", "Please Specify Grade!"); } if (ModelState.IsValid) { emp.EmpNo = emp.EmpNo.ToUpper(); db.Entry(emp).State = EntityState.Modified; ViewBag.JS = "toastr.success('" + emp.EmpName + " data Successfully edited');"; db.SaveChanges(); int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Employee, (byte)MyEnums.Operation.Edit, DateTime.Now); return(RedirectToAction("Index")); } User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", emp.CompanyID); ViewBag.LocID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName", emp.CompanyID); ViewBag.CrewID = new SelectList(db.Crews.OrderBy(s => s.CrewName), "CrewID", "CrewName"); ViewBag.DesigID = new SelectList(db.Designations.OrderBy(s => s.DesignationName), "DesignationID", "DesignationName"); ViewBag.GradeID = new SelectList(db.Grades.OrderBy(s => s.GradeName), "GradeID", "GradeName"); ViewBag.JobID = new SelectList(db.JobTitles.OrderBy(s => s.JobTitle1), "JobID", "JobTitle1"); ViewBag.SecID = new SelectList(db.Sections.OrderBy(s => s.SectionName), "SectionID", "SectionName"); ViewBag.ShiftID = new SelectList(db.Shifts.OrderBy(s => s.ShiftName), "ShiftID", "ShiftName"); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName"); ViewBag.EmpID = new SelectList(db.EmpFaces.OrderBy(s => s.Face1), "EmpID", "Face1"); ViewBag.EmpID = new SelectList(db.EmpFps.OrderBy(s => s.Fp1), "EmpID", "Fp1"); ViewBag.EmpID = new SelectList(db.LvQuotas.OrderBy(s => s.CompanyID), "EmpID", "EmpID"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); ViewBag.DeptID = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName"); return(View(emp)); } catch (Exception ex) { ViewBag.Message = ex.InnerException.ToString(); User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(db.Companies.OrderBy(s => s.CompName), "CompID", "CompName"); ViewBag.CrewID = new SelectList(db.Crews.OrderBy(s => s.CrewName), "CrewID", "CrewName"); ViewBag.DesigID = new SelectList(db.Designations.OrderBy(s => s.DesignationName), "DesignationID", "DesignationName"); ViewBag.GradeID = new SelectList(db.Grades.OrderBy(s => s.GradeName), "GradeID", "GradeName"); ViewBag.JobID = new SelectList(db.JobTitles.OrderBy(s => s.JobTitle1), "JobID", "JobTitle1"); ViewBag.LocID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.SecID = new SelectList(db.Sections.OrderBy(s => s.SectionName), "SectionID", "SectionName"); ViewBag.ShiftID = new SelectList(db.Shifts.OrderBy(s => s.ShiftName), "ShiftID", "ShiftName"); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName"); ViewBag.EmpID = new SelectList(db.EmpFaces.OrderBy(s => s.Face1), "EmpID", "Face1"); ViewBag.EmpID = new SelectList(db.EmpFps.OrderBy(s => s.Fp1), "EmpID", "Fp1"); ViewBag.EmpID = new SelectList(db.LvQuotas.OrderBy(s => s.CompanyID), "EmpID", "EmpID"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); ViewBag.DeptID = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName"); return(View(emp)); } }
private void buttonOk_Click(object sender, EventArgs e) { string name; switch (EditType) { case EditTypes.CustomMethod: ArchAngel.Providers.CodeProvider.DotNet.Function codeMethod; try { if (!CustomFunction.CodeMethodIsValid(syntaxEditor1.Text, out name, out codeMethod)) { MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (CustomMethod == null) { CustomMethod = new CustomFunction(name, syntaxEditor1.Text); } else { CustomMethod.Name = name; CustomMethod.UserString = syntaxEditor1.Text; } CustomMethod.CodeFunction = codeMethod; CustomMethod.AutoAddToEntities = checkBoxAutoAddToEntities.Checked; break; case EditTypes.CustomProperty: ArchAngel.Providers.CodeProvider.DotNet.Property codeProperty; try { if (!CustomProperty.CodePropertyIsValid(syntaxEditor1.Text, out name, out codeProperty)) { MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (CustomProperty == null) { CustomProperty = new CustomProperty(name, syntaxEditor1.Text); } else { CustomProperty.Name = name; CustomProperty.UserString = syntaxEditor1.Text; } CustomProperty.CodeProperty = codeProperty; CustomProperty.AutoAddToEntities = checkBoxAutoAddToEntities.Checked; break; default: throw new NotImplementedException("EditType not handled yet in buttonOk_Click(): " + EditType.ToString()); } this.DialogResult = DialogResult.OK; this.Close(); }
public ActionResult AdjustLeaveQuotaStepOne() { string EmpNo = Request.Form["AdjustEmpNo"].ToString(); DateTime dt = DateTime.Today; if (Request.Form["ALQDate"].ToString() != "") { string date = Request.Form["ALQDate"].ToString(); dt = Convert.ToDateTime(date); } int CompanyID = Convert.ToInt32(Request.Form["CompanyID"].ToString()); User LoggedInUser = Session["LoggedUser"] as User; var emp = db.Emps.Where(aa => aa.CompanyID == CompanyID && aa.EmpNo == EmpNo && aa.Status == true).ToList(); if (emp.Count > 0) { //Check for Employee lies under user permission if (CheckEmpValidation(emp)) { int EmpID = emp.FirstOrDefault().EmpID; string year = dt.Year.ToString(); var lvType = db.LvConsumeds.Where(aa => aa.EmpID == EmpID && aa.Year == year).ToList(); if (lvType.Count > 0) { //go to next page LeaveQuotaModel lvModel = new LeaveQuotaModel(); lvModel.EmpID = emp.FirstOrDefault().EmpID; lvModel.EmpNo = emp.FirstOrDefault().EmpNo; lvModel.EmpName = emp.FirstOrDefault().EmpName; lvModel.Year = year; lvModel.SectionName = emp.FirstOrDefault().Section.SectionName; foreach (var lv in lvType) { switch (lv.LeaveType) { case "A": //CL if (lv.YearRemaining != null) { lvModel.CL = (float)lv.YearRemaining; } break; case "B": //AL if (lv.YearRemaining != null) { lvModel.AL = (float)lv.YearRemaining; } break; case "C": //SL if (lv.YearRemaining != null) { lvModel.SL = (float)lv.YearRemaining; } break; case "E": //CPL if (lv.YearRemaining != null) { lvModel.CPL = (float)lv.YearRemaining; } break; } } return(View("AdjustLeaves", lvModel)); } } else { ViewBag.CMessage = "Employee No " + Request.Form["AdjustEmpNo"].ToString() + ": Create Leave Quota for this employee"; } } else { ViewBag.CMessage = "Employee No " + Request.Form["EmpNo"].ToString() + " not found"; } ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View("Index")); }
private void mnuEditNamespace_Click(object sender, EventArgs e) { switch (SelectedType) { case SelectedTypes.Namespace: CustomNamespace ns = EntitySet.CustomNamespaces.First(n => n.Value == SelectedNamespace); Input.Text = ns.Value; Input.AutoAddToEntities = ns.AutoAddToEntities; if (Input.ShowDialog(this) == DialogResult.OK) { if (SelectedNamespace != Input.Text) { ns.Value = Input.Text; ns.AutoAddToEntities = Input.AutoAddToEntities; PopulateEntitiesGrid(); } } break; case SelectedTypes.Implement: CustomImplement ci = EntitySet.CustomImplements.First(n => n.Value == SelectedImplement); Input.Text = ci.Value; Input.AutoAddToEntities = ci.AutoAddToEntities; if (Input.ShowDialog(this) == DialogResult.OK) { if (SelectedImplement != Input.Text) { ci.Value = Input.Text; ci.AutoAddToEntities = Input.AutoAddToEntities; PopulateEntitiesGrid(); } } break; case SelectedTypes.Attribute: CustomAttribute ca = EntitySet.CustomAttributes.First(n => n.RawName == SelectedAttribute); FormAttributeEditor form = new FormAttributeEditor(ca.RawName, ca.RawArgumentString, ca.AutoAddToEntities); if (form.ShowDialog(this) == DialogResult.OK) { if (ca.RawName != form.RawName || ca.RawArgumentString != form.RawArgumentString || ca.AutoAddToEntities != form.AutoAddToEntities) { ca.RawName = form.RawName; ca.RawArgumentString = form.RawArgumentString; ca.AutoAddToEntities = form.AutoAddToEntities; PopulateEntitiesGrid(); } } break; case SelectedTypes.Property: CustomProperty cp = EntitySet.CustomProperties.First(n => n.Name == SelectedProperty); FormCodeInput.FillData(cp); if (FormCodeInput.ShowDialog(this) == DialogResult.OK) { PopulateEntitiesGrid(); } break; case SelectedTypes.Function: CustomFunction cm = EntitySet.CustomFunctions.First(n => n.Name == SelectedFunction); FormCodeInput.FillData(cm); if (FormCodeInput.ShowDialog(this) == DialogResult.OK) { PopulateEntitiesGrid(); } break; default: throw new NotImplementedException("Type not handled yet: " + SelectedType.ToString()); } }
/// <summary> /// Approximate the integral by the double exponential transformation /// </summary> public double Integrate( CustomFunction f, double intervalBegin, double intervalEnd, double targetRelativeError) { if(_levelAbcissas == null) { _levelAbcissas = ProvideLevelAbcissas(); _levelWeights = ProvideLevelWeights(); } return _trapezium.IntegrateAdaptiveTransformedOdd( f, intervalBegin, intervalEnd, _levelAbcissas, _levelWeights, 1, targetRelativeError); }
public async Task Can_Use_Custom_Function_Variables() { // Arrange LambdaTestServer.ClearLambdaEnvironmentVariables(); var options = new LambdaTestServerOptions() { FunctionArn = "my-custom-arn", FunctionHandler = "my-custom-handler", FunctionMemorySize = 1024, FunctionName = "my-function-name", FunctionTimeout = TimeSpan.FromSeconds(119), FunctionVersion = 42, LogGroupName = "my-log-group", LogStreamName = "my-log-stream", }; using var server = new LambdaTestServer(options); using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); await server.StartAsync(cts.Token); var request = new LambdaTestRequest(Array.Empty <byte>(), "my-request-id") { ClientContext = @"{""client"":{""app_title"":""my-app""}}", CognitoIdentity = @"{""cognitoIdentityId"":""my-identity""}", }; var context = await server.EnqueueAsync(request); _ = Task.Run(async() => { await context.Response.WaitToReadAsync(cts.Token); if (!cts.IsCancellationRequested) { cts.Cancel(); } }); using var httpClient = server.CreateClient(); // Act await CustomFunction.RunAsync(httpClient, cts.Token); // Assert context.Response.TryRead(out var response).ShouldBeTrue(); response.ShouldNotBeNull(); response !.IsSuccessful.ShouldBeTrue(); response.Content.ShouldNotBeNull(); var lambdaContext = response.ReadAs <IDictionary <string, string> >(); lambdaContext.ShouldContainKeyAndValue("AwsRequestId", request.AwsRequestId); lambdaContext.ShouldContainKeyAndValue("ClientContext", "my-app"); lambdaContext.ShouldContainKeyAndValue("FunctionName", options.FunctionName); lambdaContext.ShouldContainKeyAndValue("FunctionVersion", "42"); lambdaContext.ShouldContainKeyAndValue("IdentityId", "my-identity"); lambdaContext.ShouldContainKeyAndValue("InvokedFunctionArn", options.FunctionArn); lambdaContext.ShouldContainKeyAndValue("LogGroupName", options.LogGroupName); lambdaContext.ShouldContainKeyAndValue("LogStreamName", options.LogStreamName); lambdaContext.ShouldContainKeyAndValue("MemoryLimitInMB", "1024"); lambdaContext.ShouldContainKey("RemainingTime"); string remainingTimeString = lambdaContext["RemainingTime"]; TimeSpan.TryParse(remainingTimeString, out var remainingTime).ShouldBeTrue(); remainingTime.Minutes.ShouldBe(options.FunctionTimeout.Minutes); }
/// <summary> /// Direct 3-point approximation of the definite integral in the provided interval by Simpson's rule. /// </summary> public double IntegrateThreePoint( CustomFunction f, double intervalBegin, double intervalEnd) { double midpoint = (intervalEnd + intervalBegin) / 2; return (intervalEnd - intervalBegin) / 6 * (f(intervalBegin) + f(intervalEnd) + (4 * f(midpoint))); }
public IList <IList <int> > FindSolution1(CustomFunction customfunction, int z) { throw new NotImplementedException(); }
/// <summary> /// Direct 2-point approximation of the definite integral in the provided interval by the trapezium rule. /// </summary> public double IntegrateTwoPoint( CustomFunction f, double intervalBegin, double intervalEnd) { return (intervalEnd - intervalBegin) / 2 * (f(intervalBegin) + f(intervalEnd)); }
/// <summary> /// Adaptive approximation of the definite integral by the trapezium rule. /// </summary> public double IntegrateAdaptiveTransformedOdd( CustomFunction f, double intervalBegin, double intervalEnd, IEnumerable <double[]> levelAbscissas, IEnumerable <double[]> levelWeights, double levelOneStep, double targetRelativeError) { double linearSlope = 0.5 * (intervalEnd - intervalBegin); double linearOffset = 0.5 * (intervalEnd + intervalBegin); targetRelativeError /= (5 * linearSlope); IEnumerator <double[]> abcissasIterator = levelAbscissas.GetEnumerator(); IEnumerator <double[]> weightsIterator = levelWeights.GetEnumerator(); double step = levelOneStep; // First Level abcissasIterator.MoveNext(); weightsIterator.MoveNext(); double[] abcissasL1 = abcissasIterator.Current; double[] weightsL1 = weightsIterator.Current; double sum = f(linearOffset) * weightsL1[0]; for (int i = 1; i < abcissasL1.Length; i++) { sum += weightsL1[i] * (f((linearSlope * abcissasL1[i]) + linearOffset) + f(-(linearSlope * abcissasL1[i]) + linearOffset)); } sum *= step; // Additional Levels double previousDelta = double.MaxValue; for (int level = 1; abcissasIterator.MoveNext() && weightsIterator.MoveNext(); level++) { double[] abcissas = abcissasIterator.Current; double[] weights = weightsIterator.Current; double midpointsum = 0; for (int i = 0; i < abcissas.Length; i++) { midpointsum += weights[i] * (f((linearSlope * abcissas[i]) + linearOffset) + f(-(linearSlope * abcissas[i]) + linearOffset)); } midpointsum *= step; sum = 0.5 * (sum + midpointsum); step *= 0.5; double delta = Math.Abs(sum - midpointsum); if (level == 1) { previousDelta = delta; continue; } double r = Math.Log(delta) / Math.Log(previousDelta); previousDelta = delta; if (r > 1.9 && r < 2.1) { // convergence region delta = Math.Sqrt(delta); } if (Number.AlmostEqualNorm(sum, midpointsum, delta, targetRelativeError)) { break; } } return(sum * linearSlope); }
/// <summary> /// Adaptive approximation of the definite integral by the trapezium rule. /// </summary> public double IntegrateAdaptiveTransformedOdd( CustomFunction f, double intervalBegin, double intervalEnd, IEnumerable<double[]> levelAbscissas, IEnumerable<double[]> levelWeights, double levelOneStep, double targetRelativeError) { double linearSlope = 0.5 * (intervalEnd - intervalBegin); double linearOffset = 0.5 * (intervalEnd + intervalBegin); targetRelativeError /= (5 * linearSlope); IEnumerator<double[]> abcissasIterator = levelAbscissas.GetEnumerator(); IEnumerator<double[]> weightsIterator = levelWeights.GetEnumerator(); double step = levelOneStep; // First Level abcissasIterator.MoveNext(); weightsIterator.MoveNext(); double[] abcissasL1 = abcissasIterator.Current; double[] weightsL1 = weightsIterator.Current; double sum = f(linearOffset) * weightsL1[0]; for(int i = 1; i < abcissasL1.Length; i++) { sum += weightsL1[i] * (f((linearSlope * abcissasL1[i]) + linearOffset) + f(-(linearSlope * abcissasL1[i]) + linearOffset)); } sum *= step; // Additional Levels double previousDelta = double.MaxValue; for(int level = 1; abcissasIterator.MoveNext() && weightsIterator.MoveNext(); level++) { double[] abcissas = abcissasIterator.Current; double[] weights = weightsIterator.Current; double midpointsum = 0; for(int i = 0; i < abcissas.Length; i++) { midpointsum += weights[i] * (f((linearSlope * abcissas[i]) + linearOffset) + f(-(linearSlope * abcissas[i]) + linearOffset)); } midpointsum *= step; sum = 0.5 * (sum + midpointsum); step *= 0.5; double delta = Math.Abs(sum - midpointsum); if(level == 1) { previousDelta = delta; continue; } double r = Math.Log(delta) / Math.Log(previousDelta); previousDelta = delta; if(r > 1.9 && r < 2.1) { // convergence region delta = Math.Sqrt(delta); } if(Number.AlmostEqualNorm(sum, midpointsum, delta, targetRelativeError)) { break; } } return sum * linearSlope; }
public static void SmartClick(this IWebElement element, IWebDriver driver = null, CustomFunction precondition = null, CustomFunction postcondition = null, int iterations = 1, int delay = 1, params ClickAction[] clicks) { int i = iterations; //if you do not specify what actions to use for clicking the following default actions will be used ClickAction[] clickActions = clicks != null ? clicks : new ClickAction[] { ClickAction.Click, ClickAction.LeftMBClick, ClickAction.JSClick }; string elementName = element.Text; if (precondition == null) { precondition = x => true; //if you did not specify the method let's assume it has passed (return true) } if (postcondition == null) { if (driver == null) { //"SmartClick: IWebDriver is null, no postcondition verification provided" message to log file postcondition = x => true; //assume if you do not pass IWebDriver to the mathod you do not need any post-click conditions verification. Therefore, this method always returns true } else { //"SmartClick: No click verification conditions are specified. Default verification wil be used." message to log file var numOfWindows = driver.WindowHandles.Count; var pageHashCode = PageHashCode(driver); var pageTitle = driver.Title; var pageUrl = driver.Url; //the method returns true if any of the following conditions are met, otherwise it returns false postcondition = delegate { //page title is changed if (pageTitle != driver.Title) { //log message "SmartClick: Click validation - Title of the page has changed" //screenshot return(true); } //page url address is changed if (pageUrl != driver.Url) { //log message "SmartClick: Click validation - Url address of the page has changed" //screenshot return(true); } //alert pop-up is displayed try { driver.SwitchTo().Alert(); //log message "SmartClick: "Element_ClickWhile: Click validation - Alert pop-up is displayed" //screenshot return(true); } catch (Exception e) { Console.WriteLine(e.Message); } //number of opened windows or tabs is changed if (numOfWindows != driver.WindowHandles.Count) { //log message "SmartClick: "Element_ClickWhile: Click validation - Number of opened windows (tabs) has changed" //screenshot return(true); } //page hash code is changed. It indicates that some changes has occurred on the page if (pageHashCode != PageHashCode(driver)) { //log message "SmartClick: "Element_ClickWhile: Click validation - Hash code of the page has changed" //screenshot return(true); } return(false); }; } } while (i > 0) { i--; if (!precondition.Invoke()) { //add string.Format("Preconditions for clicking '{0}' web element are not met", elementName) error message into your log file //screenshot continue; //there is no sense to do clicking action if precondition method has failed. Return back to the beginning of the loop and start again from the very beginning } if (element == null) { //add 'Element is null' error message into your log file or throw NoSuchElement or NullReference exception } if (!element.Displayed) { //add 'Element is not displayed and cannot be clicked' error message into your log file //you may add a screenshot here } if (!element.Enabled) { //add 'Element is not displayed and cannot be clicked' error message into your log file //plus a screenshot } foreach (var action in clickActions) { //here you may add string.Format("Clicking '{0}' web element with {1} click action", elementName, action) message into your log file switch (action) { case ClickAction.Click: try { element.Click(); } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.Submit: try { } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.DoubleClick: try { var builder = new Actions(driver); builder.DoubleClick().Build().Perform(); } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.RightMBClick: if (driver == null) { //"SmartClick clicking error: IWebDriver instance must be passed as a parameter and connot be null if you use clicking with right mouse button action" error message break; } try { var builder = new Actions(driver); builder.MoveToElement(element).ContextClick(element).Build().Perform(); } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.JSClick: if (driver == null) { //"SmartClick clicking error: IWebDriver instance must be passed as a parameter and connot be null if you use clicking with JavaScript action" error message break; } try { ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click()", element); } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.CursorClick: try { var X = element.Location.X; var Y = element.Location.Y; SetCursorPos(X, Y); mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.SendKeyEnter: try { element.SendKeys(Keys.Enter); } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.SendKeyReturn: try { element.SendKeys(Keys.Return); } catch (Exception e) { Console.WriteLine(e.Message); } break; case ClickAction.SendKeySpacebar: try { element.SendKeys(Keys.Space); } catch (Exception e) { Console.WriteLine(e.Message); } break; } Thread.Sleep(delay * 1000); if (postcondition()) { return; } //add string.Format("Post-conditions for clicking '{0}' web element are not met", elementName) error message into your log file //screenshot } } }