protected void Page_Load(object sender, EventArgs e) { grp_nhatkytrucap.AddComponent(btnTruncateHistory, 2); grp_nhatkytrucap.HiddenDuplicateButton(true); if (!ExtNet.IsAjaxRequest) { var accessDiary = new AccessHistory { Function = "Nhật ký truy cập", Description = "Nhật ký truy cập", IsError = false, UserName = CurrentUser.User.UserName, Time = DateTime.Now, BusinessCode = "NHATKY_TRUYCAP", ComputerName = Util.GetInstance().GetComputerName(Request.UserHostAddress), ComputerIP = Request.UserHostAddress, Referent = "" }; AccessHistoryServices.Create(accessDiary); } Button btnChooseTime = new Button() { Text = @"Chọn thời gian", Icon = Icon.Clock, }; btnChooseTime.Listeners.Click.Handler = "#{wdChooseTime}.show();"; if (!ExtNet.IsAjaxRequest) { grp_nhatkytrucap.HiddenAddButton(true); grp_nhatkytrucap.HiddenEditButton(true); grp_nhatkytrucap.HiddenTienIch(true); } grp_nhatkytrucap.AddComponent(btnChooseTime, 0); }
public static AccessHistory CreateAccessHistory( string name, int personId, int portalId, int readerId, int accessType, int?reason = null, int?id = null, DateTime?accessed = null ) { var entity = new AccessHistory { PersonId = personId, PortalId = portalId, ReaderId = readerId, Reason = reason, Type = accessType, Accessed = accessed != null ? (DateTime)accessed : DateTime.Now.Subtract(TimeSpan.FromMinutes(30)), }; entity.Id = id != null ? (int)id : entity.Id; return(entity); }
public void SignIn() { var user = new ApplicationUser(); user.AccessList = new List <AccessHistory>(); var history = new AccessHistory(); history.TenantID = "__YOUR TENANT__"; history.ClientId = "__APP CLIENT ID__"; history.Redirect = new Uri("http://localhost:9457/home"); history.GrantType = "implicit"; history.ResponseType = "code"; history.Scope = "User.Read"; history.AADEndPoint = "v2.0"; user.AccessList.Add(history); TempData["User"] = JsonConvert.SerializeObject(user); Response.Redirect("https://login.microsoftonline.com/" + user.AccessList.LastOrDefault().TenantID + "/oauth2/" + history.AADEndPoint + "/authorize?client_id=" + user.AccessList.LastOrDefault().ClientId + "&redirect_uri=" + user.AccessList.LastOrDefault().Redirect + "&grant_type=" + user.AccessList.LastOrDefault().GrantType + "&response_type=" + user.AccessList.LastOrDefault().ResponseType + "&scope=" + user.AccessList.LastOrDefault().Scope); }
public ActionResult Index() { ApplicationUser user = null; var userInfo = TempData["User"]; if (!string.IsNullOrEmpty(userInfo as string)) { user = JsonConvert.DeserializeObject <ApplicationUser>(userInfo as string); } var context = this.Url.ActionContext.HttpContext; var query = context.Request.Query; var code = string.Empty; var state = string.Empty; if (query.ContainsKey("code")) { code = query["code"]; } if (query.ContainsKey("session_state")) { state = query["session_state"]; } var signIn = false; var token = string.Empty; if (!string.IsNullOrEmpty(code)) { user.AccessList.LastOrDefault().Secret = "__CLIENT SECRET__"; user.AccessList.LastOrDefault().AuthCode = code; user.AccessList.LastOrDefault().AADEndPoint = "v2.0"; signIn = new AccessGraph().GetToken(user); if (signIn) { new AccessGraph().SetUserInfo(user); //Regist '���� �N�N�iTetsuro Takao�j' as Azure Active Directory account. user.GlobalName = string.Join("", Regex.Matches(user.displayName, @"[a-z | A-Z]*")).Trim(); ViewBag.AccountName = user.GlobalName; var grant = "{\"password\":\"__PASSWORD__\",\"username\":\"__ACCOUNT__\"}"; var history = new AccessHistory(); history.GrantType = grant; history.Scope = "files.readwrite"; history.TenantID = user.AccessList.FirstOrDefault().TenantID; history.Redirect = user.AccessList.FirstOrDefault().Redirect; history.ClientId = user.AccessList.FirstOrDefault().ClientId; history.Secret = user.AccessList.FirstOrDefault().Secret; user.AccessList.Add(history); if (new AccessGraph().GetToken(user)) { var webLink = new AccessGraph().GetLink("01N7LZHZCQ2D4PKWJ4OJAKWEOBBJWTCOWG", user); } } } ViewBag.IsSignin = signIn; ViewBag.Menu = new List <string>(); ViewBag.Message = string.Empty; ViewBag.Title = "Show user information"; return(View(new IndexViewModel { Comments = _comments.Take(COMMENTS_PER_PAGE).ToList().AsReadOnly(), CommentsPerPage = COMMENTS_PER_PAGE, Page = 1 })); }
public InternalAtomic(int historyLength, int numThreads, ILookback lookback) { _history = new AccessHistory <T>(historyLength, numThreads, lookback); }