private void signInControl_AfterSignIn(SignInContext context)
        {
			if (context.ResultType == SignInResultType.Success)
			{
				if (PassportSignInSettings.GetConfig().UseSimulateTime)
				{
					context.SignInInfo.Properties["SimulateTime"] = this.simulateDate.Value;

					IPersistTimePoint persister = TimePointSimulationSettings.GetConfig().Persister;

					if (persister != null)
					{
						OguObjectCollection<IUser> users = OguMechanismFactory.GetMechanism().GetObjects<IUser>(SearchOUIDType.LogOnName, context.SignInInfo.UserID);

						if (users.Count > 0)
						{
							persister.SaveTimePoint(users[0].ID, this.simulateDate.Value);

							TimePointContext tpc = new TimePointContext();

							tpc.UseCurrentTime = this.simulateDate.Value == DateTime.MinValue;
							tpc.SimulatedTime = this.simulateDate.Value;

							tpc.SaveToCookie();
						}
					}
				}
			}
        }
        private void signInControl_AfterSignIn(SignInContext context)
        {
            if (context.ResultType == SignInResultType.Success)
            {
                if (PassportSignInSettings.GetConfig().UseSimulateTime)
                {
                    context.SignInInfo.Properties["SimulateTime"] = this.simulateDate.Value;

                    IPersistTimePoint persister = TimePointSimulationSettings.GetConfig().Persister;

                    if (persister != null)
                    {
                        OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, context.SignInInfo.UserID);

                        if (users.Count > 0)
                        {
                            persister.SaveTimePoint(users[0].ID, this.simulateDate.Value);

                            TimePointContext tpc = new TimePointContext();

                            tpc.UseCurrentTime = this.simulateDate.Value == DateTime.MinValue;
                            tpc.SimulatedTime  = this.simulateDate.Value;

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

                TimePointContext.RestoreCurrentState(state);
                this.disposed = true;
            }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack == false)
            {
                TimePointContext tpc = TimePointContext.LoadFromCookie();

                if (tpc.UseCurrentTime == false)
                {
                    this.simulateDate.Value = tpc.SimulatedTime;
                }
            }
        }
示例#5
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();
            }
        }
示例#6
0
        /// <summary>
        /// 得到数据当前时间的函数。根据配置信息进行判断
        /// </summary>
        /// <param name="context"></param>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static string DBCurrentTimeFunction(this TimePointContext context, ISqlBuilder builder)
        {
            context.NullCheck("context");
            builder.NullCheck("builder");

            string result = builder.DBCurrentTimeFunction;

            TimeZoneContextSettings settings = TimeZoneContextSettings.GetConfig();

            if (settings.Enabled && settings.TimePointKind == DateTimeKind.Utc)
            {
                result = TSqlBuilder.Instance.DBCurrentUtcTimeFunction;
            }

            return(result);
        }
示例#7
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();
            }
        }
示例#8
0
        private static void SaveSimulateTime(SignInContext context, DateTime simulateDate)
        {
            context.SignInInfo.Properties["SimulateTime"] = simulateDate;

            IPersistTimePoint persister = TimePointSimulationSettings.GetConfig().Persister;

            if (persister != null)
            {
                OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, context.SignInInfo.UserID);

                if (users.Count > 0)
                {
                    persister.SaveTimePoint(users[0].ID, simulateDate);

                    TimePointContext tpc = new TimePointContext();

                    tpc.UseCurrentTime = simulateDate == DateTime.MinValue;
                    tpc.SimulatedTime  = simulateDate;

                    tpc.SaveToCookie();
                }
            }
        }
 public TimePointScope()
 {
     this.state = TimePointContext.GetCurrentState();
 }
示例#10
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);
                }
            }
        }