Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            HistoryAdapter adapter = new HistoryAdapter();

            string id = context.Request.QueryString["id"];

            if (string.IsNullOrEmpty(id))
            {
                throw new HttpException("必须提供有效的ID参数");
            }

            TimePointContext timeContext = TimePointContext.GetCurrentState();

            TimePointContext.Current.UseCurrentTime = true;

            SchemaObjectBase obj;

            try
            {
                obj = SchemaObjectAdapter.Instance.Load(id);
            }
            finally
            {
                TimePointContext.RestoreCurrentState(timeContext);
            }

            if (obj == null)
            {
                throw new ObjectNotFoundException("不存在id为" + id + "的对象");
            }

            context.Response.ContentType  = "text/xml";
            context.Response.CacheControl = "no-cache";
            using (System.IO.Stream output = context.Response.OutputStream)
            {
                System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(output);
                writer.WriteStartElement("data");

                this.WriteObjectHistory(adapter.GetObjectHistoryEntries(id), writer, id);

                this.WriteReferenceHistory(adapter.GetReferenceHistoryEntries(id), writer, id);

                this.WriteMembershipHistory(adapter.GetMembershipHistoryEntries(id), writer, id);

                writer.WriteEndElement();

                writer.Close();
            }
        }