public static bool UpdateFilter(Common.SmsParser smsParser, Common.ParserFormula parserFormula) { Business.SmsParser smsParserController = new Business.SmsParser(); Business.ParserFormula parserFormulaController = new Business.ParserFormula(); smsParserController.BeginTransaction(); try { if (!smsParserController.UpdateFilter(smsParser)) { throw new Exception(Language.GetString("ErrorRecord")); } parserFormula.SmsParserGuid = smsParser.SmsParserGuid; if (!parserFormulaController.InsertFilterOption(parserFormula)) { throw new Exception(Language.GetString("ErrorRecord")); } smsParserController.CommitTransaction(); return(true); } catch (Exception ex) { smsParserController.RollbackTransaction(); throw ex; } }
public bool InsertFilterOption(Common.ParserFormula parserFormula) { return(ExecuteSPCommand("InsertFilterOption", "@Guid", Guid.NewGuid(), "@Key", parserFormula.Key, "@Condition", parserFormula.Condition, "@ReactionExtention", parserFormula.ReactionExtention, "@SmsParserGuid", parserFormula.SmsParserGuid)); }
protected void btnSave_Click(object sender, EventArgs e) { try { Common.SmsParser smsParser = new Common.SmsParser(); Common.ParserFormula parserFormula = new Common.ParserFormula(); ParserFormulaSerialization parserFormulaSerialization = new ParserFormulaSerialization(); smsParser.SmsParserGuid = SmsParserGuid; smsParser.PrivateNumberGuid = Helper.GetGuid(drpNumber.SelectedValue); smsParser.Title = txtTitle.Text; smsParser.Type = (int)SmsParserType.Filter; smsParser.CreateDate = DateTime.Now; smsParser.FromDateTime = DateManager.GetChristianDateTimeForDB(dtpStartDate.FullDateTime); smsParser.ToDateTime = DateManager.GetChristianDateTimeForDB(dtpEndDate.FullDateTime); smsParser.Scope = Helper.GetGuid(hdnScopeGuid.Value.Trim('\'')); smsParser.UserGuid = UserGuid; smsParser.ConditionSender = Helper.GetLocalMobileNumber(txtConditionSender.Text); smsParser.TypeConditionSender = Helper.GetInt(drpTypeConditionSender.SelectedValue); parserFormula.Condition = Helper.GetInt(drpConditions.SelectedValue); switch (parserFormula.Condition) { case (int)SmsFilterConditions.EqualWithPhoneBookField: parserFormula.Key = string.Format("{0}/{1}", hdnConditionGroupGuid.Value, hdnConditionField.Value); break; default: parserFormula.Key = txtCondition.Text; break; } switch (parserFormula.Condition) { case (int)SmsFilterConditions.NationalCode: break; default: if (Facade.SmsParser.IsDuplicateSmsParserKey(SmsParserGuid, smsParser.PrivateNumberGuid, parserFormula.Key)) { throw new Exception(Language.GetString("DuplicateKeyword")); } break; } parserFormulaSerialization.Condition = Helper.GetInt(drpOperations.SelectedValue); switch (parserFormulaSerialization.Condition) { case (int)SmsFilterOperations.AddToGroup: case (int)SmsFilterOperations.RemoveFromGroup: parserFormulaSerialization.ReferenceGuid = Helper.GetGuid(hdnOperationGroupGuid.Value.Trim('\'')); parserFormulaSerialization.Text = txtSmsBody.Text; parserFormulaSerialization.Sender = Helper.GetGuid(drpSenderNumber.SelectedValue); parserFormulaSerialization.VasURL = txtUrl.Text; break; case (int)SmsFilterOperations.SendSmsToGroup: parserFormulaSerialization.Sender = Helper.GetGuid(drpSenderNumber.SelectedValue); parserFormulaSerialization.Text = txtSmsBody.Text; parserFormulaSerialization.ReferenceGuid = Helper.GetGuid(hdnGroupGuid.Value.Trim('\'')); break; case (int)SmsFilterOperations.ForwardSmsToGroup: parserFormulaSerialization.Sender = Helper.GetGuid(drpSenderNumber.SelectedValue); parserFormulaSerialization.ReferenceGuid = Helper.GetGuid(hdnOperationGroupGuid.Value.Trim('\'')); break; case (int)SmsFilterOperations.SendSmsToSender: parserFormulaSerialization.Sender = Helper.GetGuid(drpSenderNumber.SelectedValue); parserFormulaSerialization.Text = txtSmsBody.Text; parserFormulaSerialization.ReferenceGuid = Guid.Empty; break; case (int)SmsFilterOperations.TransferToUrl: parserFormulaSerialization.ReferenceGuid = Helper.GetGuid(drpTrafficRelay.SelectedValue); break; case (int)SmsFilterOperations.TransferToMobile: parserFormulaSerialization.Sender = Helper.GetGuid(drpSenderNumber.SelectedValue); parserFormulaSerialization.Text = txtOpration.Text; break; case (int)SmsFilterOperations.SendSmsFromFormat: parserFormulaSerialization.Sender = Helper.GetGuid(drpSenderNumber.SelectedValue); parserFormulaSerialization.AcceptFormatGuid = Helper.GetGuid(drpAccpetFormat.SelectedValue); parserFormulaSerialization.RejectFormatGuid = Helper.GetGuid(drpRejectFormat.SelectedValue); break; default: parserFormulaSerialization.Text = txtOpration.Text; break; } parserFormula.ReactionExtention = SerializationTools.SerializeToXml(parserFormulaSerialization, parserFormulaSerialization.GetType()); if (smsParser.HasError) { throw new Exception(smsParser.ErrorMessage); } switch (ActionType) { case "insert": if (!Facade.SmsParser.InsertFilter(smsParser, parserFormula)) { throw new Exception(Language.GetString("ErrorRecord")); } break; case "edit": if (!Facade.SmsParser.UpdateFilter(smsParser, parserFormula)) { throw new Exception(Language.GetString("ErrorRecord")); } break; } Response.Redirect(string.Format("/PageLoader.aspx?c={0}", Helper.Encrypt((int)UserControls.UI_SmsParsers_Filters_SmsFilter, Session))); } catch (Exception ex) { ShowMessageBox(ex.Message, string.Empty, "danger"); } }