public static ViewStateSql GetViewStateSql(Guid viewStateId) { if (viewStateId == null) { log.Error("This method must be used for a specific control and user"); return(null); } ViewStateSqlDSTableAdapters.ViewStateSqlTableAdapter adapter = new ViewStateSqlDSTableAdapters.ViewStateSqlTableAdapter(); ViewStateSql obj = null; try { ViewStateSqlDS.ViewStateSqlDataTable table = adapter.GetViewStateByGuid(viewStateId); if (table != null && table.Rows.Count > 0) { obj = FillRecord(viewStateId, table[0].Value); } } catch (Exception x) { log.Error("An error was ocurred while getting the saved searches", x); return(null); } return(obj); }
protected override void SavePageStateToPersistenceMedium(object viewState) { Guid viewStateGuid; HtmlInputHidden control; byte[] viewStateArray = null; if (this.IsDesignMode) { return; } viewStateGuid = this.GetViewStateGuid(); using (MemoryStream stream = new MemoryStream()) { this.GetLosFormatter().Serialize(stream, viewState); viewStateArray = stream.ToArray(); } ViewStateSql obj = new ViewStateSql(viewStateGuid, viewStateArray, Artexacta.App.Configuration.Configuration.GetViewStateExpirationForDataBase()); ViewStateSqlBLL.Insert(obj); control = this.FindControl("__VIEWSTATEGUID") as HtmlInputHidden; if (control == null) { ClientScript.RegisterHiddenField("__VIEWSTATEGUID", viewStateGuid.ToString()); } else { control.Value = viewStateGuid.ToString(); } }
public static bool Insert(ViewStateSql newViewStateSql) { if (newViewStateSql == null) { log.Error("New object cannot be null"); return(false); } if (newViewStateSql.ViewStateId == null || newViewStateSql.Value == null) { log.Error("New object's arguments were either null, empty or less than 0: "); return(false); } ViewStateSqlDSTableAdapters.ViewStateSqlTableAdapter adapter = new ViewStateSqlDSTableAdapters.ViewStateSqlTableAdapter(); try { adapter.Insert(newViewStateSql.ViewStateId, newViewStateSql.Value, newViewStateSql.Timeout); return(true); } catch (Exception x) { log.Error("An error was ocurred while inserting the saved search", x); return(false); } }
protected override object LoadPageStateFromPersistenceMedium() { Guid viewStateGuid; object theViewState = null; if (this.IsDesignMode) { return(null); } viewStateGuid = this.GetViewStateGuid(); ViewStateSql obj = ViewStateSqlBLL.GetViewStateSql(viewStateGuid); if (obj == null) { return(theViewState); } using (MemoryStream stream = new MemoryStream(obj.Value)) { theViewState = this.GetLosFormatter().Deserialize(stream); } return(theViewState); }
private static ViewStateSql FillRecord(Guid theId, byte[] theValue) { ViewStateSql obj = new ViewStateSql(theId, theValue, Artexacta.App.Configuration.Configuration.GetViewStateExpirationForDataBase()); return(obj); }