示例#1
0
        protected void DeleteViewstate(string query, object args)
        {
            SqlConnection conn = new SqlConnection( connectionstringProvider.Connectionstring );

            try
            {
                conn.Open();
                conn.ExecuteMapperCommand(query, args);
            }
            catch(Exception ex)
            {
                AnnotatedException e = new AnnotatedException("Could not delete viewstate from database", ex);
                e.AddAnnotation("Query", query);
                e.AddAnnotations(args);

                throw e;
            }
            finally
            {
                conn.Close();
            }
        }
示例#2
0
        public void SetState(Guid viewStateID, int state)
        {
            SqlConnection conn = new SqlConnection( connectionstringProvider.Connectionstring );
            var args = new
                {
                    ViewStateID = viewStateID,
                    State=state
                };

            try
            {
                conn.Open();
                conn.ExecuteMapperCommand(SetStateQuery, args);
            }
            catch(Exception ex)
            {
                AnnotatedException e = new AnnotatedException("Error saving state for viewstate", ex);
                e.AddAnnotation("Query", SetStateQuery);
                e.AddAnnotations(args);

                throw e;
            }
            finally
            {
                conn.Close();
            }
        }
示例#3
0
        protected void CreateState(Guid viewstateID)
        {
            SqlConnection conn = new SqlConnection(connectionstringProvider.Connectionstring);

            try
            {
                conn.Open();
                conn.ExecuteMapperCommand(CreateStateQuery, new {SessionID = viewstateID});
            }
            catch(Exception ex)
            {
                AnnotatedException e = new AnnotatedException("Could not create state", ex);
                e.AddAnnotation("ViewstateID", viewstateID);

                throw e;
            }
            finally
            {
                conn.Close();
            }
        }
示例#4
0
        public void SaveState(ViewstateContext ctx, bool useGuid = true)
        {
            if ( !useGuid && string.IsNullOrWhiteSpace( ctx.Reference ) )
                useGuid = true;

            string query = useGuid ? SaveStateByGuidQuery : SaveStateByReferenceQuery;
            var args = ctx.GetDatebaseRow();

            SqlConnection conn = new SqlConnection(connectionstringProvider.Connectionstring);
            try
            {
                conn.Open();
                conn.ExecuteMapperCommand(query, args);
            }
            catch(Exception ex)
            {
                AnnotatedException e = new AnnotatedException("Error saving viewstate", ex);
                e.AddAnnotation("UseGuid", useGuid);
                e.AddAnnotation("Query", query);
                e.AddAnnotations(args);

                throw e;
            }
            finally
            {
                conn.Close();
            }
        }