protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // now, let's assume the identity
            // first, we need a proxy
            // The "False" means we DON'T want the API to throw an exception if an error occurs
            IConciergeAPIService proxy = ConciergeAPIProxyGenerator.GenerateProxy();

            // now, let's contact the API and use the session ID provided
            var loginResult = proxy.WhoAmI();

            if (!loginResult.Success) // something went wrong
            {
                Response.Write("There was a problem: " + loginResult.Errors[0].Message);
                return;
            }

            // let's save the session ID - now, its part of the header
            // once we've done that, we can use the API across postbacks and pages
            // b/c the session will be sent in the header of each request
            ConciergeAPIProxyGenerator.SessionID = loginResult.ResultValue.SessionID;

            msUser user = new msUser(loginResult.ResultValue.User);

            // ok, let's set our user name
            lblUserName.Text       = user.Name;
            tbUserDepartment.Text  = user.Department;
            lblUserDepartment.Text = user.Department;
        }
    }
    /// <summary>
    /// Initializes the target object for the page
    /// </summary>
    /// <remarks>Many pages have "target" objects that the page operates on. For instance, when viewing
    /// an event, the target object is an event. When looking up a directory, that's the target
    /// object. This method is intended to be overriden to initialize the target object for
    /// each page that needs it.</remarks>
    protected override void InitializeTargetObject()
    {
        base.InitializeTargetObject();

        targetRegistration = LoadObjectFromAPI <msEventRegistration>(ContextID);

        if (targetRegistration == null)
        {
            GoToMissingRecordPage();
            return;
        }

        targetEvent  = LoadObjectFromAPI <msEvent>(targetRegistration.Event);
        targetEntity = LoadObjectFromAPI <msEntity>(targetRegistration.Owner);

        if (targetEvent == null || targetEntity == null)
        {
            GoToMissingRecordPage();
            return;
        }

        if (!targetEvent.AllowRegistrantsToChangeSessions ||
            (targetEvent.DeadlineForChangingSessions.HasValue && targetEvent.DeadlineForChangingSessions < DateTime.Now) ||
            !EventLogic.HasSessions(targetEvent.ID))
        {
            liChangeSessions.Visible = false;
        }

        initializeRegistrationFields();

        createdBy = LoadObjectFromAPI <msUser>(targetRegistration.CreatedBy);
        status    = getStatus();

        loadEventOwners();
    }
Exemplo n.º 3
0
    public static string LogException(Exception ex, Uri u)
    {
        //if there's no http context do not log
        //If we don't know what association this is we can't log either because a auditlog requires a wall to save
        if (HttpContext.Current == null ||   CurrentAssociation == null)
            return null;

        try
        {
            NameValueCollection queryStringVariables = new NameValueCollection();
            if (u != null)
                queryStringVariables = HttpUtility.ParseQueryString(u.Query);
            string contextId = queryStringVariables["contextID"];

            MemberSuiteObject contextObject = null;

            using (IConciergeAPIService proxy = ConciergeAPIProxyGenerator.GenerateProxy())
            {
                //Get the current user details from the Concierge API
                LoginResult loginResult = proxy.WhoAmI().ResultValue;
                msUser currentUser = loginResult.PortalUser == null ? loginResult.User.ConvertTo<msUser>() : loginResult.PortalUser.ConvertTo<msUser>();

                //If there's a specified context then get the details on the context object
                if (!string.IsNullOrWhiteSpace(contextId))
                {
                    ConciergeResult<MemberSuiteObject> getResult = proxy.Get(contextId);
                    if (getResult.Success)
                        contextObject = getResult.ResultValue;
                }

                msAuditLog auditLog = constructAuditLog(currentUser, ex, contextId, contextObject);
                ConciergeResult<MemberSuiteObject> saveResult = proxy.RecordErrorAuditLog(auditLog);
                
                if (saveResult.Success)
                    return saveResult.ResultValue.SafeGetValue<string>("ID");
            }
        }
        catch(Exception e)
        {
            Console.WriteLine("Unable to log exception.");
            Console.WriteLine(e.ToString());
            Console.WriteLine(ex.ToString());
        }

        return null;
    }
    protected void btnChangeDepartment_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        IConciergeAPIService proxy = ConciergeAPIProxyGenerator.GenerateProxy();

        // let's get the user from the session
        var loginResult = proxy.WhoAmI();

        if (!loginResult.Success) // something went wrong
        {
            Response.Write("There was a problem: " + loginResult.Errors[0].Message);
            return;
        }


        msUser user = new msUser(loginResult.ResultValue.User);


        // now, change the department
        user.Department = tbUserDepartment.Text;

        // now, we have to save it
        // again, the false keeps an exception from being thrown

        ConciergeResult <MemberSuiteObject> result = proxy.Save(user);

        if (!result.Success)
        {
            Response.Write("Error occured: " + result.Errors[0].Message);
            return;
        }

        user = new msUser(result.ResultValue);
        // store the user in the session - it's serializable

        lblUserDepartment.Text = user.Department;
        tbUserDepartment.Text  = "";

        Response.Write("Department Successfully updated.");
    }
Exemplo n.º 5
0
    private static msAuditLog constructAuditLog(msUser currentUser, Exception ex, string contextId, MemberSuiteObject contextObject)
    {
        msAuditLog result = new msAuditLog();
        result.AffectedRecord_ID = contextId;
        result.Type = AuditLogType.Error;

        if (currentUser != null)
            result.Actor = currentUser.ID;

        if (contextObject != null)
        {
            result.AffectedRecord_Type = contextObject.ClassType;
            result.AffectedRecord_Name = contextObject.SafeGetValue<string>("Name");
        }

        result.Description = ex.ToString();

        return result;
    }
Exemplo n.º 6
0
        void insUser()
        {
            if (txtPass.Text == "")
            {
                MessageBox.Show("Password must be filled");
            }
            else if (txtConfirmPass.Text == "")
            {
                MessageBox.Show("Confirm Password must be filled");
            }
            else if (!txtPass.Text.Equals(txtConfirmPass.Text))
            {
                MessageBox.Show("Password mismatch");
            }
            else
            {
                var newUser = new msUser
                {
                    Id       = getMaxId(),
                    Username = txtUName.Text,
                    Password = txtPass.Text,
                    Name     = txtName.Text,
                    Role     = cbRole.SelectedItem.ToString()
                };

                conn.msUsers.InsertOnSubmit(newUser);

                try
                {
                    conn.SubmitChanges();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
        }