public void MethodUnderTest_TestedBehavior_ExpectedResult() { const string errorConnectingToDatabase = "Error connecting to database"; var exceptionArgs = new DatabaseErrorExceptionArgs(errorConnectingToDatabase); var customException = new CustomException<DatabaseErrorExceptionArgs>(exceptionArgs); Assert.That(customException.Args.ErrorMessage, Is.EqualTo(errorConnectingToDatabase)); }
public void NotHasFlag_WithCustomException_CustomTypeException() { FlagsEnum value = FlagsEnum.Value0; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .NotHasFlag(value)); Assert.Equal($"Argument '{nameof(value)}' must not have the nexts flag(s): {value}. Current value: {value}", exc.Message); }
public void CountMoreThan_WithCustomException_CustomTypeException() { int[] arr = { 1 }; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(arr, nameof(arr)) .With <CustomException>() .CountMoreThan(1)); Assert.Equal($"Argument '{nameof(arr)}' must contains more than 1 elements. Current count elements: {arr.Length}", exc.Message); }
public void DeveloperCanChooseWhichStackFrameItemsToExclude() { CustomException ex = Assert.Throws <CustomException>(() => { throw new CustomException(); }); string stackTrace = ex.StackTrace; Assert.Empty(stackTrace); // Everything was filtered out in our exception Assert.Equal(2, ex.StackFrames.Count); Assert.Contains("at Xunit1.AssertExceptionTests", ex.StackFrames[0]); Assert.Contains("at Xunit.Record.Exception", ex.StackFrames[1]); }
public void Empty_WithCustomException_CustomTypeException() { int[] arr = { 1 }; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(arr, nameof(arr)) .With <CustomException>() .Empty()); Assert.Equal($"Argument '{nameof(arr)}' must be empty. Current value: ['1']", exc.Message); }
public void NotNull_WithCustomException_CustomTypeException() { object nullObj = null; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(nullObj, nameof(nullObj)) .With <CustomException>() .NotNull()); Assert.Equal($"Argument '{nameof(nullObj)}' is null", exc.Message); }
public async Task <IHttpActionResult> GetMyClient(string id) { var userName = User.Identity.Name; if (!await ClientService.CheckUserClient(userName, id)) { CustomException.ThrowBadRequestException($"There is no client with id = {id} associated with user: {userName}."); } return(Ok(await ClientService.GetMyClientAsync(userName, id))); }
public void NullOrWhitespace_WithCustomException_CustomTypeException() { string value = "value"; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .NullOrWhitespace()); Assert.Equal($"Argument '{nameof(value)}' must be empty or whitespace. Current value: '{value}'", exc.Message); }
public override async Task <ErrorLogDto> GetByIdAsync(object id) { if (!await ExistsAsync(id)) { CustomException.ThrowNotFoundException($"There is no log with id = {id}."); } var log = await UnitOfWork.ErrorLogRepository.FindAsync((long)id); return(ModelFactory.GetModel <ErrorLogDto>(log)); }
public override async Task RemoveAsync(object id) { if (!await ExistsAsync(id)) { CustomException.ThrowNotFoundException($"There is no client with clientId = {id}."); } var clientDomain = await UnitOfWork.ClientRepository.FindAsync(id); await UnitOfWork.ClientRepository.RemoveAsync(clientDomain); }
public async Task <ClientByUserNameDto> GetMyClientAsync(string userName, string clientId) { if (!await ExistsAsync(clientId)) { CustomException.ThrowNotFoundException($"There is no client with id = {clientId}."); } var client = await UnitOfWork.ClientRepository.SingleOrDefaultAsync(x => x.Username.Equals(userName) && x.Id.Equals(clientId)); return(ModelFactory.GetModel <ClientByUserNameDto>(client)); }
public void Ctor_CopyFrom_NeverThrown() { var template = new CustomException(5, "msg"); var errorData = new CommonErrorData(template); Assert.Equal("msg", template.Message); Assert.Equal(template.HResult, errorData.HResult); Assert.Null(errorData.Inner); Assert.Equal(typeof(CustomException).FullName, errorData.TypeName); Assert.Null(errorData.StackTrace); }
public void LengthInRange_WithCustomException_CustomTypeException() { string value = "123"; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .LengthInRange(10, 20)); Assert.Equal($"Argument '{nameof(value)}' must be length in range 10 - 20. Current length: {value.Length}", exc.Message); }
public override async Task <IdentityRoleDto> GetByIdAsync(object id) { if (!await ExistsAsync(id)) { CustomException.ThrowNotFoundException($"There is no role with id = {id}."); } var role = await _roleManager.FindByIdAsync((string)id); return(_roleModelFactory.GetModel(role)); }
public void LengthMoreThan_WithCustomException_CustomTypeException() { string value = "123"; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .LengthMoreThan(10)); Assert.Equal($"Argument '{nameof(value)}' must be length more than 10. Current length: {value.Length}", exc.Message); }
public async Task <IHttpActionResult> GetUserClients(string userName, [FromUri] Pagination paginationModel) { var user = await UserManager.FindByEmailAsync(userName); if (user == null) { CustomException.ThrowNotFoundException($"User {userName} doesn't exists."); } return(Ok(await ClientService.GetUserClients(userName, paginationModel.Page, paginationModel.PageSize))); }
public void Null_WithCustomException_CustomTypeException() { object notNull = new object(); CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(notNull, nameof(notNull)) .With <CustomException>() .Null()); Assert.Equal($"Argument '{nameof(notNull)}' must be null. Current value: '{notNull}'", exc.Message); }
public void CustomExceptionConstructorCustomMessageTest() { string message = string.Empty; Exception innerException = null; bool hasCustomMessage = true; ErrorCodes errorCode = ErrorCodes.Code100004; CustomException target = new CustomException(message, innerException, hasCustomMessage, errorCode); bool actual = target.HasCustomMessage; Assert.AreEqual(hasCustomMessage, actual); }
public ICollection <Order> GetDeliveryRouteLoad() { try { return(_context.Set <Order>().Include(x => x.User).Include(x => x.Route).ToList()); } catch (Exception ex) { throw CustomException.Create <DeliveryRepository>("Unexpected error fetching get deliveries", nameof(this.GetDeliveryRouteLoad), ex); } }
public void GetObjectDataTest() { CustomException target = new CustomException(); SerializationInfo info = new SerializationInfo(typeof(CustomException), new FormatterConverter()); StreamingContext context = new StreamingContext(); target.GetObjectData(info, context); Assert.IsNotNull(info); Assert.IsNotNull(context); }
public void MinLength_WithCustomException_CustomTypeException() { string value = "123"; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .MinLength(10)); Assert.Equal($"Argument '{nameof(value)}' has a minimum length of 10. Current length: {value.Length}", exc.Message); }
public void StartsWith_WithCustomException_CustomTypeException() { string value = "123"; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .StartsWith("2")); Assert.Equal($"Argument '{nameof(value)}' must starts with '2'. Current value: '{value}'", exc.Message); }
public override async Task <ClientDto> GetByIdAsync(object id) { if (!await ExistsAsync(id)) { CustomException.ThrowNotFoundException($"There is no client with clientId = {id}."); } var client = await UnitOfWork.ClientRepository.FindAsync(id); return(ModelFactory.GetModel <ClientDto>(client)); }
public override async Task RemoveAsync(object id) { if (!await ExistsAsync(id)) { CustomException.ThrowNotFoundException($"There is no log with id = {id}."); } var logDomain = await UnitOfWork.ErrorLogRepository.FindAsync(id); await UnitOfWork.ErrorLogRepository.RemoveAsync(logDomain); }
private void btnSave_Click(object sender, EventArgs e) { Int16 Flag = 0; try { if (Validation()) { if (OperationFlag == 1) { Flag = IDataProvider.InsertModifyBranch(Convert.ToInt32(cmbBankName.SelectedValue), txtBranchCode.Text.Trim(), txtBranchName.Text.Trim(), txtBranchAddress.Text.Trim(), txtPhone.Text.Trim(), 'I', LoginInfo.UserId, 0); if (Flag == 0) { MessageBox.Show("Record Added successfully", "Patpedhi", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record already exist", "Patpedhi", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (OperationFlag == 2) { Flag = IDataProvider.InsertModifyBranch(Convert.ToInt32(cmbBankName.SelectedValue), txtBranchCode.Text.Trim(), txtBranchName.Text.Trim(), txtBranchAddress.Text.Trim(), txtPhone.Text.Trim(), 'M', LoginInfo.UserId, BranchId); if (Flag == 0) { MessageBox.Show("Record modified successfully", "Patpedhi", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record already exist", "Patpedhi", MessageBoxButtons.OK, MessageBoxIcon.Information); } } BranchId = 0; //cmbBankName.SelectedValue = 0; txtBranchCode.Text = ""; txtBranchName.Text = ""; txtBranchAddress.Text = ""; txtPhone.Text = ""; cmbBankName.Enabled = false; txtBranchName.Enabled = false; txtBranchAddress.Enabled = false; txtPhone.Enabled = false; btnAdd.Enabled = true; btnModify.Enabled = false; btnSave.Enabled = false; OperationFlag = 4; btnAdd.Focus(); } } catch (Exception ex) { CustomException.CustomExceptionLog(ex); } }
public ICollection <DeliveryDetail> GetDeliveryProductsLoad(Guid deliveryID) { try { return(_context.Set <DeliveryDetail>().Include(x => x.Order).Include(x => x.Product).Where(x => x.OrderID == deliveryID).ToList()); } catch (Exception ex) { throw CustomException.Create <DeliveryRepository>("Unexpected error fetching get deliveries", nameof(this.GetDeliveryProductsLoad), ex); } }
public void NotContains_WithCustomException_CustomTypeException() { string value = "123"; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .NotContains("1")); Assert.Equal($"Argument '{nameof(value)}' must not contains '1'. Current value: '{value}'", exc.Message); }
public void OnExceptionThrownEvent(ExceptionThrownEvent exceptionThrownEvent) { var customException = new CustomException() { ExceptionType = exceptionThrownEvent.ExceptionType.ToString(), Message = exceptionThrownEvent.Message, StackTrace = exceptionThrownEvent.StackTrace }; _repo.Insert(customException); }
public override async Task RemoveAsync(object id) { if (!await ExistsAsync(id)) { CustomException.ThrowNotFoundException($"There is no role with id = {id}."); } var role = await _roleManager.FindByIdAsync((string)id); await _roleManager.DeleteAsync(role); }
public void DefinedInEnum_WithCustomException_CustomTypeException() { NotFlagsEnum value = (NotFlagsEnum)111; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .DefinedInEnum()); Assert.Equal($"Argument '{nameof(value)}' must be defined in enum type {typeof(NotFlagsEnum).FullName}. Current value: {value}", exc.Message); }
public async Task <IdentityRoleDto> GetByName(string name) { if (!await RoleExistsAsync(name)) { CustomException.ThrowNotFoundException($"There is no role: {name}."); } var role = await _roleManager.FindByNameAsync(name); return(_roleModelFactory.GetModel(role)); }
public DataSetData GetDataSetData(string ConnStr,string SQL, out CustomException ServiceError) { try { DataSet ds = GetDataSet(ConnStr,SQL); ServiceError = null; return DataSetData.FromDataSet(ds); } catch(Exception ex) { ServiceError = new CustomException(ex); } return null; }
public DataSetData GetDataSetData(string SQL, int PageNumber, int PageSize, out CustomException ServiceError) { try { DataSet ds = GetDataSet(SQL, PageNumber, PageSize); ServiceError = null; return DataSetData.FromDataSet(ds); } catch(Exception ex) { ServiceError = new CustomException(ex); } return null; }
public void fill() { try { gv_events.DataSource=sedb.getall(); gv_events.DataBind(); } catch { CustomException ex = new CustomException("Error !!!", "Data can not be loaded to page"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
//fill the drivview with table data public void fill() { try { //invoke the methode to retrive the record from the table gv_warning.DataSource = swdb.databind(); gv_warning.DataBind(); } catch (Exception dd) { //popout custom message if any error happans CustomException ex = new CustomException("Error !!!", "warning details can not be retrived"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
public DataSetData GetEventTypes(out CustomException ServiceError) { try { string SQL = "select EVENT_TYPE_ID, EVENT_TYPE_NAME from EVENT_TYPES;"; int PageNumber = 1; int PageSize = 10000; DataSet ds = GetDataSet(SQL, PageNumber, PageSize); ServiceError = null; return DataSetData.FromDataSet(ds); } catch (Exception ex) { ServiceError = new CustomException(ex); } return null; }
public DataSetData GetSchools(out CustomException ServiceError) { try { string SQL = "select SCHOOL_ID, SCHOOL_NAME from SCHOOLS;"; int PageNumber = 1; int PageSize = 10000; DataSet ds = GetDataSet(SQL, PageNumber, PageSize); ServiceError = null; return DataSetData.FromDataSet(ds); } catch (Exception ex) { ServiceError = new CustomException(ex); } return null; }
public DataSetData GetSchoolBuildings(int school_id, out CustomException ServiceError) { try { string SQL = String.Format("select SCHOOL_BUILDINGS_ID, BUILDING_NAME from SCHOOL_BUILDINGS where (SCHOOL_ID = {0});", school_id); int PageNumber = 1; int PageSize = 10000; DataSet ds = GetDataSet(SQL, PageNumber, PageSize); ServiceError = null; return DataSetData.FromDataSet(ds); } catch (Exception ex) { ServiceError = new CustomException(ex); } return null; }
//invoke the methode to get all table records public void fill() { try { //invoke the get all methde gv_events.DataSource = sedb.getall(); gv_events.DataBind(); } catch { //promt error meesage is any exception happens CustomException ex = new CustomException("Error !!!", "Data can not be loaded to page"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
//fill the dropdown list with all sub events public void fill_ddl_subevents(string master) { try { //invoe get all grade methode ddl_sub.DataSource = sedc.get_subevents(master); ddl_sub.DataMember = "EVENT_TYPE_SUB"; ddl_sub.DataValueField = "EVENT_TYPE_SUB"; ddl_sub.DataBind(); } catch { //Response.Write("<script>alert('sub event details can not be loaded')</script>"); CustomException ex = new CustomException("Error !!!", "event sub details can not be loaded"); MessageBox messages = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messages.Show(this); } }
//fill the drop down list with activty codes public void fill_ddl_activtycode() { try { //invoke get all activityes methode ddl_type.DataSource = ialdc.getall_activity_type(); ddl_type.DataMember = "ACTIVITY_CODE"; ddl_type.DataValueField = "ACTIVITY_CODE"; ddl_type.DataBind(); } catch { //Response.Write("<script>alert('activty code details can not be loaded')</script>"); ////popout custom message if any error happans CustomException ex = new CustomException("Error!!!", "activty code details can not be loaded"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
//fill the ddl_class with selected grade public void fillclass(decimal grade) { try { //invoke the methode to retrive the class details according to the selected grade ddl_class.DataSource = swdb.get_class_relevaent_grade(grade); ddl_class.DataMember = "CLASS_CODE"; ddl_class.DataValueField = "CLASS_CODE"; ddl_class.DataBind(); } catch (Exception ss) { //popout custom message if any error happans CustomException ex = new CustomException("Error !!!", "class detals can not retrived"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
//validate the selected date public bool validate_date(string date) { int selected_date = 0; try { //hold the current date and month string format = date.Substring(3, 1); int this_month = Convert.ToInt32(DateTime.Today.Month.ToString()); int today = Convert.ToInt32(DateTime.Today.Day.ToString()); //hold the selected date and month int selected_month = Convert.ToInt32(date.Substring(0, 1)); if (format == "/") { selected_date = Convert.ToInt32(date.Substring(2, 1)); } else { selected_date = Convert.ToInt32(date.Substring(2, 2)); } //check whether the selected date is beyond the current date if (selected_date <= today && this_month <= selected_month) { return false; } else { return true; } } catch { //promt error meesage is any exception happens CustomException ex = new CustomException("Error !!!", "Selected Date is in incorrect format"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); return true; } }
protected void btnSubmit_Click(object sender, EventArgs e) { lblError.ForeColor = Color.Red; lblError.Text = ""; if (txtAdNo.Text == null || txtAdNo.Text.ToString().Length <= 0) { lblError.Text = "Please fill Admission Number."; CustomException ex = new CustomException("Success !!!", "Record Inserted Successfully."); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } else if (ddlExamination.SelectedIndex <= 0 || ddlYear.SelectedIndex <= 0) { lblError.Text = "Please select an Examination and Year."; } else if (txtSubCode.Text == null || txtSubCode.Text.ToString().Length <= 0) { lblError.Text = "Please fill Subject Code."; } else if (MedDateCal.SelectedDate == null || MedDateCal.SelectedDate.ToString().Length <= 0) { lblError.Text = "Please select the Medical Date."; } else if (ddlDuration.SelectedIndex <= 0) { lblError.Text = "Please select the Medical Duration."; } else { lblError.Text = ""; addMedical(); } }
private void PreParse() { try { Parser.Output.Parse_Begin(Main.ParsePath, Main.pvStr(Parser.XH.FileVer, "."), Parser.SkipCompare, Main.PCMD); } catch (SQLiteException expr_32) { ProjectData.SetProjectError(expr_32); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_47) { ProjectData.SetProjectError(expr_47); Exception ex = expr_47; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } }
private static void Abort(string Msg) { try { Parser.myAbortMsg = Msg; Parser.Output.Parse_End(true); } catch (SQLiteException expr_16) { ProjectData.SetProjectError(expr_16); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_2B) { ProjectData.SetProjectError(expr_2B); Exception ex = expr_2B; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } Parser.ReturnCode = Parser.ParserReturns.Aborted; bool flag = Parser.pThread != null; if (flag) { Parser.pThread.Abort(); } }
private void ParseAtkDefSet(ref bool R) { List<Plugin.ItemNanoKeyVal> list = new List<Plugin.ItemNanoKeyVal>(); List<Plugin.ItemNanoKeyVal> list2 = new List<Plugin.ItemNanoKeyVal>(); br.SkipBytes(4, "AtkDefSkip"); int num = br.ReadCNum("MaxSet"); int arg_34_0 = 1; int num2 = num; int num3 = arg_34_0; checked { while (true) { int arg_163_0 = num3; int num4 = num2; if (arg_163_0 > num4) { break; } int value = br.ReadInt32("Key"); int num5 = br.ReadCNum("Sets"); int arg_63_0 = 1; int num6 = num5; int num7 = arg_63_0; while (true) { int arg_152_0 = num7; num4 = num6; if (arg_152_0 > num4) { break; } Plugin.ItemNanoKeyVal item = default(Plugin.ItemNanoKeyVal); item.AttrKey = br.ReadInt32("AttrKey"); item.AttrVal = br.ReadInt32("AttrVal"); while (true) { switch (value) { case 3: { bool flag = Parser.XH.FileVer == 15000100 && this.AOID == 213413; if (flag) { value = 13; continue; } goto IL_10D; } case 12: goto IL_110; case 13: goto IL_11C; } goto Block_1; } IL_142: num7++; continue; IL_10D: goto IL_142; IL_110: list.Add(item); goto IL_142; IL_11C: list2.Add(item); goto IL_142; IL_128: R = this.CritError("Unhandled AtkDef Set: " + Conversions.ToString(value)); goto IL_142; Block_1: goto IL_128; } num3++; } try { Parser.Output.ItemNanoAttackAndDefense(list.ToArray(), list2.ToArray()); } catch (SQLiteException expr_182) { ProjectData.SetProjectError(expr_182); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_198) { ProjectData.SetProjectError(expr_198); Exception ex = expr_198; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } } }
private void ParseFunctionSet(ref bool R) { int eventNum = br.ReadInt32("EventNum"); int num = br.ReadCNum("NumFuncs"); List<Plugin.ItemNanoFunction> list = new List<Plugin.ItemNanoFunction>(); int arg_2F_0 = 0; checked { int num2 = num - 1; int num3 = arg_2F_0; while (true) { int arg_1C3_0 = num3; int num4 = num2; if (arg_1C3_0 > num4) { goto Block_4; } Plugin.ItemNanoFunction item = default(Plugin.ItemNanoFunction); item.FunctionReqs = new Plugin.ItemNanoRequirement[0]; item.FunctionArgs = new string[0]; item.FunctionNum = br.ReadInt32("FuncNum"); br.SkipBytes(8, "FuncHeaderPreSkip"); int num5 = br.ReadInt32("NumReqs"); bool flag = num5 > 0; if (flag) { List<Parser.ReqsStruc> list2 = new List<Parser.ReqsStruc>(); int arg_AE_0 = 0; int num6 = num5 - 1; int num7 = arg_AE_0; while (true) { int arg_118_0 = num7; num4 = num6; if (arg_118_0 > num4) { break; } list2.Add(new Parser.ReqsStruc { AttrNum = br.ReadInt32("RawReqsNum"), AttrVal = br.ReadInt32("RawReqsVal"), AttrOp = br.ReadInt32("RawReqsOp") }); num7++; } item.FunctionReqs = this.ParseReqs(list2.ToArray()); } item.TickCount = br.ReadInt32("TickCount"); item.TickInterval = br.ReadInt32("TickInterval"); item.Target = br.ReadInt32("Target"); br.SkipBytes(4, "FuncHeaderPostSkip"); item.FunctionArgs = this.ParseArgs(Conversions.ToString(item.FunctionNum), ref R); flag = (R == 0); if (flag) { break; } list.Add(item); num3++; } return; Block_4: try { Parser.Output.ItemNanoEventAndFunctions(eventNum, list.ToArray()); } catch (SQLiteException expr_1DD) { ProjectData.SetProjectError(expr_1DD); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_1F3) { ProjectData.SetProjectError(expr_1F3); Exception ex = expr_1F3; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } } }
private void ParseAnimSoundSet(int TypeN, ref bool R) { int num = br.ReadInt32("SetType"); int num2 = br.ReadCNum("NumFunc"); int arg_27_0 = 1; int num3 = num2; int num4 = arg_27_0; checked { while (true) { int arg_13B_0 = num4; int num5 = num3; if (arg_13B_0 > num5) { break; } List<int> list = new List<int>(); int actionNum = br.ReadInt32("actionNum"); int num6 = br.ReadCNum("maxSets"); int arg_5C_0 = 1; int num7 = num6; int num8 = arg_5C_0; while (true) { int arg_96_0 = num8; num5 = num7; if (arg_96_0 > num5) { break; } int item = br.ReadInt32("animNum" + Conversions.ToString(num8)); list.Add(item); num8++; } try { switch (TypeN) { case 1: Parser.Output.ItemNanoAnimSets(actionNum, list.ToArray()); break; case 2: Parser.Output.ItemNanoSoundSets(actionNum, list.ToArray()); break; default: throw new Exception("Xyphos, you're an idiot!"); } } catch (SQLiteException expr_E9) { ProjectData.SetProjectError(expr_E9); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_FF) { ProjectData.SetProjectError(expr_FF); Exception ex = expr_FF; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } num4++; } } }
private void ParseActionSet(ref bool R) { bool flag = br.ReadInt32("&H24 Check") != 36; if (flag) { throw new Exception("Why am I here?"); } int arg_3D_0 = 1; int num = br.ReadCNum("MaxSets"); int num2 = arg_3D_0; checked { while (true) { int arg_160_0 = num2; int num3 = num; if (arg_160_0 > num3) { break; } int actionNum = br.ReadInt32("actionNum"); int num4 = br.ReadCNum("NumReqs"); Plugin.ItemNanoRequirement[] requirements = new Plugin.ItemNanoRequirement[0]; flag = (num4 > 0); if (flag) { List<Parser.ReqsStruc> list = new List<Parser.ReqsStruc>(); int arg_86_0 = 0; int num5 = num4 - 1; int num6 = arg_86_0; while (true) { int arg_F0_0 = num6; num3 = num5; if (arg_F0_0 > num3) { break; } list.Add(new Parser.ReqsStruc { AttrNum = br.ReadInt32("RawReqsNum"), AttrVal = br.ReadInt32("RawReqsVal"), AttrOp = br.ReadInt32("RawReqsOp") }); num6++; } requirements = this.ParseReqs(list.ToArray()); } try { Parser.Output.ItemNanoAction(actionNum, requirements); } catch (SQLiteException expr_111) { ProjectData.SetProjectError(expr_111); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_127) { ProjectData.SetProjectError(expr_127); Exception ex = expr_127; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } num2++; } } }
private void DoParse() { checked { while (Parser.ReturnCode == Parser.ParserReturns.Parsing) { gzbFile.FileXRDB4Record xR = Parser.GZB.ReadRecord(); bool flag = xR.MarkerTag != -559038242; if (flag) { CustomException ex = new CustomException(string.Format("{0}{1}{0}{2}is corrupt!", '"', Parser.GZB.FileStream.Name, "\r\n"), "Corrupted data file detected"); Parser.Abort("Corrupt Datafile"); Parser.ReturnCode = Parser.ParserReturns.Failed; break; } string key = Conversions.ToString(xR.RecordType) + ":" + Conversions.ToString(xR.RecordNum); flag = this.Blacklist.ContainsKey(key); if (!flag) { Plugin.ChangeStates changeStates = Plugin.ChangeStates.NewRecord; flag = this.Checksums.ContainsKey(key); bool flag2; if (flag) { flag2 = Operators.ConditionalCompareObjectNotEqual(this.Checksums[key], xR.RecordCRC, false); if (flag2) { changeStates = Plugin.ChangeStates.ModifiedRecord; } else { changeStates = Plugin.ChangeStates.NoChange; } } Application.DoEvents(); this.AOID = xR.RecordNum; int recordType = xR.RecordType; flag2 = (recordType == 0); if (flag2) { Parser.ReturnCode = Parser.ParserReturns.Success; break; } flag2 = (recordType == 1000020 || recordType == 1040005); if (flag2) { this.ParseItemNano(xR, changeStates); } else { try { flag2 = !Parser.Output.OtherData_Begin(xR.RecordNum, xR.RecordType, changeStates); if (flag2) { continue; } Parser.Output.OtherData(xR.RecordData); Parser.Output.OtherData_End(); } catch (SQLiteException expr_197) { ProjectData.SetProjectError(expr_197); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_1AD) { ProjectData.SetProjectError(expr_1AD); Exception ex2 = expr_1AD; CustomException ex3 = new CustomException(ex2.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } } Main.TotalParsed++; } } } }
private void PostParse() { try { Parser.Output.Parse_End(false); } catch (SQLiteException expr_10) { ProjectData.SetProjectError(expr_10); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_25) { ProjectData.SetProjectError(expr_25); Exception ex = expr_25; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { //fill all the records fill(); } } catch { //promt error meesage is any exception happens CustomException ex = new CustomException("Error !!!", "Error in Page loading"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
/// <summary> /// when update link clicked the record will be updated. first it read the values from the /// edited grid view. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gv_UD_hostel_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { //create data table to hold the list values after validation DataTable dt = new DataTable(); //add cloumn dt.Columns.Add("values"); //clear all the fields lbl_status.Text = string.Empty; txt_search.Text = string.Empty; //identfy the selected record GridViewRow row = gv_UD_hostel.Rows[Convert.ToInt32(e.RowIndex)]; //select the student id string id = gv_UD_hostel.DataKeys[e.RowIndex].Value.ToString(); //select the students regsiterd date string nfrom = gv_UD_hostel.Rows[Convert.ToInt32(e.RowIndex)].Cells[2].Text; //select the to date TextBox todate = (TextBox)row.FindControl("txtto"); string ntodate = todate.Text; //select the prefect date TextBox prefect = (TextBox)row.FindControl("txt_prefect"); string nprefect = prefect.Text; //select the deputy head prefect year TextBox dhprefect = (TextBox)row.FindControl("txt_dh"); string ndhprefect = dhprefect.Text; //select the head prefect year TextBox hprefect = (TextBox)row.FindControl("txt_hp"); string nhprefect = hprefect.Text; //select the registerd year int year_sep = nfrom.LastIndexOf('/'); int from_date = Convert.ToInt16(nfrom.Substring(year_sep + 1, 4)); //invoke date checking validation methodes if ((checkdate(ntodate) == 1) && (verify_years(from_date, nprefect, ndhprefect, nhprefect) == 1)) { //create the generic list to hold values List<string> list = new List<string>(); //add records in to list list.Add(ntodate); list.Add(nprefect); list.Add(ndhprefect); list.Add(nhprefect); //access the each list value and check whether they are null or not //if null then set the value as 0; foreach (string s in list) { if (s == string.Empty || s == null) { dt.Rows.Add("0"); } else { dt.Rows.Add(s); } } //invoke the methide to update methode if (hd.update_hostel(id, dt.Rows[0]["values"].ToString(), Convert.ToDecimal(dt.Rows[1]["values"].ToString()), Convert.ToDecimal(dt.Rows[2]["values"].ToString()), Convert.ToDecimal(dt.Rows[3]["values"].ToString()))) { //display the suucess message if the operation is succussfull CustomException ex = new CustomException("Success", "Record Successfully Updated"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); gv_UD_hostel.EditIndex = -1; fill(); //lbl_status.Text = "record updated successfully"; // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Record Successfully Updated')", true); } } else { //create alert if any exception happens ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Error!! Please Insert Proper Values As Inputs Or Keep The Default Value As It Is.')", true); } } catch (Exception ss) { string s = ss.Message; //lbl_status.Text = "Can not update the record"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Error!! Record Can not be Updated')", true); } }
protected void gv_events_RowEditing(object sender, GridViewEditEventArgs e) { try { //move the selected record in to modify mode gv_events.EditIndex = e.NewEditIndex; //invoke the fill method fill(); } catch { //promt error meesage is any exception happens CustomException ex = new CustomException("Error !!!", "Selected Record can not be move to modify"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
protected void gv_events_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { //check if is in edit mode if ((e.Row.RowState & DataControlRowState.Edit) > 0) { DropDownList main = (DropDownList)e.Row.FindControl("ddl_master"); //Bind subcategories data to dropdownlist main.DataMember = "EVENT_TYPE_MAST"; main.DataValueField = "EVENT_TYPE_MAST"; main.DataSource = sedb.get_event_master(); main.DataBind(); DataRowView dr = e.Row.DataItem as DataRowView; main.SelectedValue = dr["EVENT_TYPE_MAST"].ToString(); DropDownList sub = (DropDownList)e.Row.FindControl("ddl_sub"); //Bind subcategories data to dropdownlist sub.DataTextField = "EVENT_TYPE_SUB"; sub.DataValueField = "EVENT_TYPE_SUB"; sub.DataSource = sedb.get_subevents(); sub.DataBind(); DataRowView dr2 = e.Row.DataItem as DataRowView; main.SelectedValue = dr["EVENT_TYPE_SUB"].ToString(); } } } catch { //promt error meesage is any exception happens CustomException ex = new CustomException("Error !!!", "Selected row's values are not available"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } }
private void GetCRCs() { this.lblStat.Text = "Reading Checksums..."; Parser.GZB = new gzbFile(this.OldDF, FileMode.Open, CompressionMode.Decompress); Parser.GZB.ReadHeader(); while (Parser.ReturnCode == Parser.ParserReturns.Parsing) { gzbFile.FileXRDB4Record fileXRDB4Record = Parser.GZB.ReadRecord(); bool flag = fileXRDB4Record.MarkerTag != -559038242; if (flag) { CustomException ex = new CustomException(string.Format("{0}{1}{0}{2}is corrupt!", '"', Parser.GZB.FileStream.Name, "\r\n"), "Corrupted data file detected"); Parser.ReturnCode = Parser.ParserReturns.Failed; return; } flag = (fileXRDB4Record.RecordType == 0); if (flag) { break; } string key = Conversions.ToString(fileXRDB4Record.RecordType) + ":" + Conversions.ToString(fileXRDB4Record.RecordNum); this.Checksums.Add(key, fileXRDB4Record.RecordCRC); this.pbProg.Value = checked((int)Math.Round(unchecked((double)Parser.GZB.FileStream.Position / (double)Parser.GZB.FileStream.Length * 100.0))); Main.DoEvents(); } Parser.GZB.Close(); Parser.GZB = null; }
protected void btn_search_Click(object sender, EventArgs e) { //check whether the search search word is empty if (txt_search.Text == string.Empty) { Response.Write("<script>alert('Plaese insert search key')</script>"); //CustomException ex = new CustomException("Warning !!!", "Please insert a key for search"); //MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); //messageBox.Show(this); } else { try { //invoke the methode to get search result gv_events.DataSource = sedb.search(txt_search.Text); gv_events.DataBind(); } catch { //promt error meesage is any exception happens CustomException ex = new CustomException("Error !!!", "Search results are not avalible"); MessageBox messageBox = new MessageBox(ex, MessageBoxDefaultButtonEnum.OK); messageBox.Show(this); } } }
private void ParseItemNano(int rectype, int recnum, byte[] data) { this.BR = new Parser.BufferedReader(rectype,recnum,data, this.Tracing); bool flag; flag = !Parser.Output.ItemNano_Begin(XR.RecordNum, XR.RecordType == 1040005, CS); if (flag) { return; } br.SkipBytes(16, "Pre-Attr"); int num = br.ReadCNum("AttrCount"); Plugin.ItemNanoInfo info = default(Plugin.ItemNanoInfo); List<Plugin.ItemNanoKeyVal> list = new List<Plugin.ItemNanoKeyVal>(); bool flag2 = false; int arg_C0_0 = 0; short num5; short num6; checked { int num2 = num - 1; int num3 = arg_C0_0; while (true) { int arg_1C2_0 = num3; int num4 = num2; if (arg_1C2_0 > num4) { break; } Plugin.ItemNanoKeyVal item = default(Plugin.ItemNanoKeyVal); item.AttrKey = br.ReadInt32("AttrKey" + Conversions.ToString(num3)); item.AttrVal = br.ReadInt32("AttrVal" + Conversions.ToString(num3)); list.Add(item); int attrKey = item.AttrKey; flag = (attrKey == 54); if (flag) { info.QL = item.AttrVal; } else { flag = (attrKey == 76); if (flag) { info.EquipPage = item.AttrVal; } else { flag = (attrKey == 88); if (flag) { info.DefaultSlot = item.AttrVal; } else { flag = (attrKey == 298); if (flag) { info.EquipSlots = item.AttrVal; } else { flag = (attrKey == 388); if (flag) { flag2 = true; } } } } } num3++; } br.SkipBytes(8, "Post-Attr"); num5 = br.ReadInt16("NameLen"); num6 = br.ReadInt16("DescLen"); } bool arg_222_0; if (num5 >= 0 && num6 >= 0) { if ((long)num5 <= 4095L) { if ((long)num6 <= 4095L) { arg_222_0 = false; goto IL_222; } } } arg_222_0 = true; IL_222: flag = arg_222_0; if (flag) { br.DebugDump("NameLen or DescLen is invalid", Parser.ParserReturns.Failed); } flag = (num5 > 0); if (flag) { info.Name = br.ReadString((int)num5, "Name"); } else { info.Name = ""; } flag = (num6 > 0); if (flag) { info.Description = br.ReadString((int)num6, "Description"); } else { info.Description = ""; } BitManipulation bitManipulation = new BitManipulation(); info.Type = info.EquipPage; flag = (Strings.InStr(info.Name, "_", CompareMethod.Binary) != 0 || Strings.InStr(Strings.UCase(info.Name), "BOSS", CompareMethod.Binary) != 0); if (flag) { info.Type = 4; } else { flag = flag2; if (flag) { info.Type = 7; } else { flag = (info.EquipPage == 1); if (flag) { bool flag3 = bitManipulation.CheckBit((long)info.EquipSlots, 6) || bitManipulation.CheckBit((long)info.EquipSlots, 8); if (flag3) { info.Type = 1; } else { info.Type = 6; } } } } try { Parser.Output.ItemNano(info, list.ToArray()); } catch (SQLiteException expr_371) { ProjectData.SetProjectError(expr_371); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_387) { ProjectData.SetProjectError(expr_387); Exception ex3 = expr_387; CustomException ex4 = new CustomException(ex3.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } bool flag4 = true; checked { while (br.Ptr < br.Buffer.Length - 8 && flag4) { switch (br.ReadInt32("ParseSetsKeyNum")) { case 2: this.ParseFunctionSet(ref flag4); break; case 3: case 5: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 15: case 16: case 17: case 18: case 19: case 21: goto IL_4BF; case 4: this.ParseAtkDefSet(ref flag4); break; case 6: { br.SkipBytes(4, "Pre-SkipSet"); int count = br.ReadCNum("SkipSet") * 8; br.SkipBytes(count, "Post-SkipSet"); break; } case 14: this.ParseAnimSoundSet(1, ref flag4); break; case 20: this.ParseAnimSoundSet(2, ref flag4); break; case 22: this.ParseActionSet(ref flag4); break; case 23: this.ParseShopHash(ref flag4); break; default: goto IL_4BF; } continue; IL_4BF: flag4 = this.CritError("Invalid KeyNum"); } try { Parser.Output.ItemNano_End(); } catch (SQLiteException expr_50A) { ProjectData.SetProjectError(expr_50A); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_520) { ProjectData.SetProjectError(expr_520); Exception ex5 = expr_520; CustomException ex6 = new CustomException(ex5.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } } }
private void ParseShopHash(ref bool R) { List<Plugin.ItemNanoFunction> list = new List<Plugin.ItemNanoFunction>(); int eventNum = br.ReadInt32("EventNum"); int num = br.ReadCNum("NumFuncs"); int arg_2D_0 = 1; int num2 = num; int num3 = arg_2D_0; checked { while (true) { int arg_151_0 = num3; int num4 = num2; if (arg_151_0 > num4) { break; } string text = br.ReadString(4, "StrArg"); int num5 = (int)br.ReadByte("numA"); int num6 = (int)br.ReadByte("numB"); bool flag = num5 == 0 && num6 == 0; if (flag) { num5 = (int)br.ReadInt16("numA2"); num6 = (int)br.ReadInt16("numB2"); } int count = Math.Min(11, br.Buffer.Length - br.Ptr); br.SkipBytes(count, "ShopHashSkip"); list.Add(new Plugin.ItemNanoFunction { FunctionArgs = new string[] { text, Conversions.ToString(num5), Conversions.ToString(num6) }, FunctionReqs = new Plugin.ItemNanoRequirement[0], Target = 255, TickCount = 1, TickInterval = 0 }); num3++; } try { Parser.Output.ItemNanoEventAndFunctions(eventNum, list.ToArray()); } catch (SQLiteException expr_16B) { ProjectData.SetProjectError(expr_16B); Parser.ReturnCode = Parser.ParserReturns.Crashed; ProjectData.ClearProjectError(); } catch (Exception expr_181) { ProjectData.SetProjectError(expr_181); Exception ex = expr_181; CustomException ex2 = new CustomException(ex.ToString(), "Plugin Error"); Parser.ReturnCode = Parser.ParserReturns.Crashed; R = false; ProjectData.ClearProjectError(); } } }