public void Dispose()
            {
                if (this.disposed)
                {
                    throw new InvalidOperationException("The TimePointScope is disposed");
                }

                TimePointContext.RestoreCurrentState(state);
                this.disposed = true;
            }
示例#2
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();
            }
        }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request["id"];

            try
            {
                id.NullCheck("id");

                SchemaObjectPhoto photo = null;

                if (context.Request["time"] == "now")
                {
                    TimePointContext tpc = TimePointContext.GetCurrentState();

                    try
                    {
                        TimePointContext.Current.SimulatedTime  = DateTime.MinValue;
                        TimePointContext.Current.UseCurrentTime = true;

                        photo = SchemaObjectAdapter.Instance.GetObjectPhoto(id, "PhotoKey", DateTime.MinValue);
                    }
                    finally
                    {
                        TimePointContext.RestoreCurrentState(tpc);
                    }
                }
                else
                {
                    photo = SchemaObjectAdapter.Instance.GetObjectPhoto(id, "PhotoKey", TimePointContext.Current.SimulatedTime);
                }

                if (photo != null)
                {
                    ResponsePhoto(WebUtility.GetContentTypeByFileName(photo.ImageInfo.OriginalName), photo.ContentData);
                }
                else
                {
                    ReponseDefaultPhoto();
                }
            }
            catch (System.Exception)
            {
                ReponseDefaultPhoto();
            }
        }
示例#4
0
        protected void OK_Click(object sender, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                TimePointContext context = TimePointContext.GetCurrentState();

                try
                {
                    TimePointContext.Current.SimulatedTime  = DateTime.MinValue;
                    TimePointContext.Current.UseCurrentTime = true;

                    var user = PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(StandardObjectSchemaType.Users.ToString(), this.txtLogOnName.Text, SchemaObjectStatus.Normal, DateTime.MinValue);

                    if (user != null)
                    {
                        if (user.CurrentParentRelations.Exists(p => p.Status == SchemaObjectStatus.Normal && p.ParentSchemaType == "Organizations" && p.Parent.Status == SchemaObjectStatus.Normal) == false)
                        {
                            throw new InvalidOperationException(string.Format("没有找到对应登录名 {0} 的用户的组织,必须先将用户加入组织。", this.txtLogOnName.Text));
                        }

                        var  userId = user.ID;
                        bool valid  = false;
                        if (this.SupervisiorMode)
                        {
                            if (this.txtLogOnName.Text == Util.CurrentUser.LogOnName)
                            {
                                // 管理员修改自己的
                                if (UserPasswordAdapter.Instance.CheckPassword(userId, UserPasswordAdapter.GetPasswordType(), this.tb_OldPassword.Value) == true)
                                {
                                    valid = true;
                                }
                                else
                                {
                                    this.passwordresult.InnerText = "原始密码不正确";
                                }
                            }
                            else
                            {
                                // 修改别人的,检查管理员的密码是否正确
                                if (UserPasswordAdapter.Instance.CheckPassword(Util.CurrentUser.ID, UserPasswordAdapter.GetPasswordType(), this.tb_OldPassword.Value) == true)
                                {
                                    valid = true;
                                }
                                else
                                {
                                    this.passwordresult.InnerText = "管理员密码错误";
                                }
                            }
                        }
                        else
                        {
                            if (UserPasswordAdapter.Instance.CheckPassword(userId, UserPasswordAdapter.GetPasswordType(), this.tb_OldPassword.Value) == true)
                            {
                                valid = true;
                            }
                            else
                            {
                                this.passwordresult.InnerText = "原始密码不正确";
                            }
                        }

                        if (valid)
                        {
                            UserPasswordAdapter.Instance.SetPassword(userId, UserPasswordAdapter.GetPasswordType(), this.tb_NewPassword.Value);

                            ScriptManager.RegisterClientScriptBlock(this.passwordUpdatePanel, this.GetType(), "master", "top.window.close();", true);
                        }
                    }
                    else
                    {
                        throw new ObjectNotFoundException(string.Format("未能找到对应登录名 {0} 的用户。", this.txtLogOnName.Text));
                    }
                }
                catch (Exception ex)
                {
                    this.passwordresult.InnerText = string.Format("无法验证用户,{0}", ex.Message);

                    // WebUtility.RegisterClientErrorMessage(ex);
                    // ScriptManager.RegisterStartupScript(this.passwordUpdatePanel, this.GetType(), "提示", "window.alert('原密码不正确')", true);
                }
                finally
                {
                    TimePointContext.RestoreCurrentState(context);
                }
            }
        }