Example #1
0
        public HttpResponseMessage GetGuestLink(string lnk)
        {
            try
            {
                string errMsg = string.Empty;

                GuestLink guestLink = guestUserService.LookupByGuestLink(lnk);

                if (guestLink.GuestLinkGUID == Guid.Empty)
                {
                    errMsg = "No valid guest links available. Please contact your Program Administrator";
                }

                if (string.IsNullOrEmpty(errMsg))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, guestLink));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden, errMsg));
                }
            }
            catch (Exception ex)
            {
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Example #2
0
        public void GetTracerLicenseDetails(GuestLink guestLink)
        {
            ApiGetLicenseDetailsForGuestLinkReturnModel rtn;

            using (var db = new DBMEdition01Context())
            {
                try
                {
                    rtn = db.ApiGetLicenseDetailsForGuestLink(guestLink.GuestLinkID).FirstOrDefault();
                    guestLink.IsSiteActive         = (bool)rtn.IsSiteActive;
                    guestLink.TracerExpirationDate = (DateTime)rtn.ExpirationDate;
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiGetLicenseDetailsForGuestLink(" + guestLink.GuestLinkID + ")";
                    string methodName = "JCRAPI/Business/GuestUserServices/GetTracerLicenseDetails";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, null, sqlParam, string.Empty);
                }
            }
        }
Example #3
0
        public GuestUserInfo GetGuessInfoByLink(string email, string gtlink, out string rtnErr)
        {
            int           errorID = 0;
            string        errorMessage;
            GuestUserInfo userInfo = new GuestUserInfo();

            //step 1 Look up GuessLink, get guestLink object
            rtnErr = string.Empty;
            GuestLink guestLink = LookupByGuestLink(gtlink);

            if (guestLink.GuestLinkGUID == Guid.Empty)
            {
                rtnErr = "No valid guest links available. Please contact your Program Administrator";
            }
            else
            {
                //step 2 Check guest link Error or not

                if (IsErrorLink(guestLink, out errorID, out errorMessage))
                {
                    rtnErr = errorMessage;
                }
                else
                {
                    //step 3 Check Domain
                    MailAddress address     = new MailAddress(email);
                    string      currentHost = "@" + address.Host;


                    var isInvalidDomain = GetGuestAccessDomains(guestLink.SiteID, currentHost);
                    if (isInvalidDomain)
                    {
                        rtnErr = "You do not have access to this guest tracer. Please contact your Program Administrator.";
                    }
                    userInfo = ValidateUser(email, guestLink.SiteID);
                }
            }

            return(userInfo);
        }
Example #4
0
        public bool IsErrorLink(GuestLink guestLink, out int errorID, out string errorMessage)
        {
            errorID      = 0;
            errorMessage = string.Empty;

            if (guestLink.IsExpired)
            {
                errorID      = 104;
                errorMessage = guestLink.ExpirationDate1.ToString();
                return(true);
            }

            if (guestLink.ExpirationDate1.HasValue && guestLink.ExpirationDate1 < DateTime.Now)
            {
                errorID      = 101;
                errorMessage = guestLink.SiteName;
                return(true);
            }

            if (!guestLink.IsSiteActive)
            {
                errorID      = 102;
                errorMessage = guestLink.SiteName;
                return(true);
            }

            guestLink.IsSetupForGuestAccess = IsFeatureEnabled(guestLink.SiteID, 1);
            if (!guestLink.IsSetupForGuestAccess)
            {
                errorID = 109;
                return(true);
            }

            if (!guestLink.IsEnabled)
            {
                errorID      = 105;
                errorMessage = guestLink.UpdatedDate.ToString();
                return(true);
            }


            if (guestLink.TracerStatusID != (UInt32)Enums.TracerStatusID.Published)
            {
                errorID = 103;

                switch (guestLink.TracerStatusID)
                {
                case (int)Enums.TracerStatusID.Deleted:
                    errorMessage = "Deleted ";
                    break;

                case (int)Enums.TracerStatusID.Closed:
                    errorMessage = "Closed ";
                    break;

                case (int)Enums.TracerStatusID.Unpublished:
                    errorMessage = "Unpublished ";
                    break;
                }
                return(true);
            }

            int numberOfInactiveDepartments = GetDepartmentCount(guestLink.SiteID, guestLink.ProgramID);

            if (numberOfInactiveDepartments == 0)
            {
                errorID      = 107;
                errorMessage = guestLink.SiteName;
                return(true);
            }

            return(false);
        }
Example #5
0
        public GuestLink LookupByGuestLink(string guidWithoutDashes)
        {
            string sql = string.Empty;
            string cs  = string.Empty;

            //var guestLink = new GuestLink();

            ApiGuestLinkReadReturnModel glnk = new ApiGuestLinkReadReturnModel();
            GuestLink guestLink = new GuestLink();
            //string guidWithDashes = string.Format("{0}-{1}-{2}-{3}-{4}", guidWithoutDashes.Substring(0, 8),
            //    guidWithoutDashes.Substring(8, 4),
            //    guidWithoutDashes.Substring(12, 4),
            //    guidWithoutDashes.Substring(16, 4),
            //    guidWithoutDashes.Substring(20, 12));

            // This code is here to validate an edge case where a user tries to access a guestlink using the following URL:
            // http://localhost:55556/GuestAccess/UserPrompt.aspx?lnk=261bd67c03f9453e977564f03332XXXX

            Guid validGuid;

            if (Guid.TryParse(guidWithoutDashes, out validGuid))
            {
                // Nothing to do.
            }
            else
            {
                return(guestLink);
            }
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            try
            {
                glnk = isGuestLinkValidated(new System.Guid(guidWithoutDashes));

                if (guestLink != null)
                {
                    guestLink.GuestLinkID        = glnk.GuestLinkID;
                    guestLink.GuestLinkGUID      = glnk.GuestLinkGUID;
                    guestLink.IsEnabled          = glnk.IsEnabled;
                    guestLink.SiteID             = glnk.SiteID;
                    guestLink.SiteName           = glnk.SiteName;
                    guestLink.TracerCustomID     = glnk.TracerCustomID;
                    guestLink.TracerCustomName   = glnk.TracerCustomName;
                    guestLink.TracerStatusID     = (int)glnk.TracerStatusID;
                    guestLink.ProgramID          = (int)glnk.ProgramID;
                    guestLink.ProgramName        = glnk.ProgramName;
                    guestLink.ExpirationDate     = glnk.ExpirationDate;
                    guestLink.CreatedByID        = glnk.CreatedByID;
                    guestLink.CreatedDate        = glnk.CreatedDate;
                    guestLink.UpdatedByID        = glnk.UpdatedByID;
                    guestLink.UpdatedDate        = glnk.UpdatedDate;
                    guestLink.CycleID            = (int)glnk.CycleID;
                    guestLink.IsCmsLicenseActive = glnk.IsCmsLicenseActive.HasValue ? glnk.IsCmsLicenseActive.Value : false;
                    guestLink.TracerType         = glnk.TracerType;

                    if (string.IsNullOrEmpty(guestLink.ExpirationDate) == false)
                    {
                        guestLink.ExpirationDate1 = Convert.ToDateTime(guestLink.ExpirationDate);
                        if (guestLink.ExpirationDate1 < DateTime.Now)
                        {
                            guestLink.IsExpired = true;
                        }
                    }
                    GetTracerLicenseDetails(guestLink);
                }
                else
                {
                    guestLink.GuestLinkGUID = Guid.Empty;
                }
            }
            catch (Exception ex)
            {
            }
            return(guestLink);
        }