コード例 #1
0
ファイル: GuestUserController.cs プロジェクト: SubhoM/WebApi
        public HttpResponseMessage CreateTracersGuestUser(string userLogonId, string firstName, string lastName, int?siteId = null)
        {
            try
            {
                string errMsg;

                GuestUserInfo rtn = guestUserService.CreateTracersGuestUser(userLogonId, firstName, lastName, siteId);

                return(Request.CreateResponse(HttpStatusCode.OK, rtn));
            }
            catch (Exception ex)
            {
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ""));
            }
        }
コード例 #2
0
ファイル: GuestUserServices.cs プロジェクト: SubhoM/WebApi
        private GuestUserInfo ParseResultforNewGuestUser(ApiCreateTracersGuestUserReturnModel userData)
        {
            GuestUserInfo user = new GuestUserInfo();

            //User
            ApiCreateTracersGuestUserReturnModel.ResultSetModel1 userInfo   = userData.ResultSet1.FirstOrDefault();
            ApiCreateTracersGuestUserReturnModel.ResultSetModel2 roleInfo   = userData.ResultSet2.FirstOrDefault();
            ApiCreateTracersGuestUserReturnModel.ResultSetModel3 siteInfo   = userData.ResultSet3.FirstOrDefault();
            ApiCreateTracersGuestUserReturnModel.ResultSetModel4 eulaInfo   = userData.ResultSet4.FirstOrDefault();
            ApiCreateTracersGuestUserReturnModel.ResultSetModel5 gAdminInfo = userData.ResultSet5.FirstOrDefault();

            if (userInfo != null)
            {
                user.UserID       = userInfo.UserID;
                user.FirstName    = userInfo.FirstName ?? string.Empty;
                user.LastName     = userInfo.LastName ?? string.Empty;
                user.MiddleName   = userInfo.MiddleName ?? string.Empty;
                user.EmailAddress = userInfo.UserLogonID ?? string.Empty;
                user.IsActive     = Convert.ToBoolean(userInfo.UserStatus);
            }
            //userSiteMap
            if (roleInfo != null)
            {
                user.UserSiteInfo.RoleID          = roleInfo.RoleID;
                user.UserSiteInfo.IsTracersAccess = (bool)roleInfo.TracersAccess;
                user.IsUserSiteMapPresent         = true;
            }
            //Site
            if (siteInfo != null)
            {
                user.UserSiteInfo.SiteID       = siteInfo.SiteID;
                user.UserSiteInfo.SiteName     = siteInfo.SiteName;
                user.UserSiteInfo.IsSiteActive = siteInfo.SiteStatus;
            }
            //User EULA - Product Status
            if (eulaInfo != null)
            {
                user.IsEulaAccepted = Convert.ToBoolean(eulaInfo.IsEulaAccepted);
            }
            //Is this person a Global Administrator
            if (gAdminInfo != null)
            {
                user.IsGlobalAdmin = Convert.ToBoolean(gAdminInfo.IsGlobalAdmin);
            }
            return(user);
        }
コード例 #3
0
ファイル: GuestUserServices.cs プロジェクト: SubhoM/WebApi
        public string CreatePasscode(string email)
        {
            string rtn;

            var userData = new GuestUserInfo();

            ApiSelectUserByUserLogonIdReturnModel userInfo;
            UserServices userService = new UserServices();

            userInfo = userService.GetUserByLogonId(email);

            Random generator = new Random();
            int    passCode  = generator.Next(10000, 99999);

            using (var db = new DBMEdition01Context())
            {
                try
                {
                    List <ApiUpdateSelectPasscodeReturnModel> rtnPassCode = db.ApiUpdateSelectPasscode(userInfo.UserID, userInfo.UserID, passCode);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiUpdateSelectPasscode(" + userInfo.UserID + "," + userInfo.UserID + "," + passCode + ")";
                    string methodName = "JCRAPI/Business/GuestUserServices/CreatePasscode";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userInfo.UserID, null, sqlParam, string.Empty);

                    return(null);
                }
            }
            var actionTypeId = (int)Enums.ActionTypeEnum.GuestAccessPassCode;

            Email setEmail = new Email();

            setEmail.To      = email;
            setEmail.Subject = "Guest Passcode";
            setEmail.Body    = "Dear <strong>" + userInfo.FirstName + " " + userInfo.LastName + "</strong>,<br/><br/>Here is your new passcode. Please use this code to access your Guest Account.<br/><br/>" +
                               "<b>New Passcode: " + passCode + "</b><br/>" +
                               "<br/><i>Please note: This e-mail message was sent from a notification-only address that does not accept incoming e-mail. Do not reply to this message.</i>";

            EmailHelpers.SendEmail(setEmail, actionTypeId, 0, userInfo.UserID, string.Empty, userInfo.FirstName + " " + userInfo.LastName);
            rtn = "Email with new passcode successfully sent. Use the new passcode to view in-progress observations";
            return(rtn);
        }
コード例 #4
0
ファイル: GuestUserServices.cs プロジェクト: SubhoM/WebApi
        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);
        }
コード例 #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ChatId.Length != 0)
            {
                hash ^= ChatId.GetHashCode();
            }
            if (guestUserInfo_ != null)
            {
                hash ^= GuestUserInfo.GetHashCode();
            }
            if (MediaType != global::AcFunDanmu.ChatMediaType.Unknown)
            {
                hash ^= MediaType.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #6
0
ファイル: GuestUserServices.cs プロジェクト: SubhoM/WebApi
        public bool IsUserRegistered(string email)
        {
            bool rtn = false;

            GuestUserInfo guestUserInfo = new GuestUserInfo();
            ApiSelectUserByUserLogonIdReturnModel userInfo;
            UserServices userService = new UserServices();

            userInfo = userService.GetUserByLogonId(email);

            SiteServices siteService = new SiteServices();
            List <ApiSelectTracerSitesByUserReturnModel> sites;
            ApiSelectTracerSitesByUserReturnModel        defaultSite;

            var siteID = 0;

            sites       = siteService.GetTracerSitesByUser(userInfo.UserID, null, null);
            defaultSite = sites.Where(x => x.DefaultSelectedSite == 1).FirstOrDefault();
            if (defaultSite == null)
            {
                defaultSite = sites.FirstOrDefault();
            }

            if (defaultSite != null)
            {
                siteID = defaultSite.SiteID;
            }

            guestUserInfo = ValidateUser(email, siteID);

            if (guestUserInfo.IsRegisteredUser)
            {
                rtn = true;
            }

            return(rtn);
        }
コード例 #7
0
 public void MergeFrom(CommonStateSignalChatReady other)
 {
     if (other == null)
     {
         return;
     }
     if (other.ChatId.Length != 0)
     {
         ChatId = other.ChatId;
     }
     if (other.guestUserInfo_ != null)
     {
         if (guestUserInfo_ == null)
         {
             GuestUserInfo = new global::AcFunDanmu.ZtLiveUserInfo();
         }
         GuestUserInfo.MergeFrom(other.GuestUserInfo);
     }
     if (other.MediaType != global::AcFunDanmu.ChatMediaType.Unknown)
     {
         MediaType = other.MediaType;
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
コード例 #8
0
ファイル: GuestUserServices.cs プロジェクト: SubhoM/WebApi
        public bool AuthenticateGuestUser(string email, string passCode)
        {
            bool          rtn;
            GuestUserInfo guestUserInfo = new GuestUserInfo();

            var passCodeDB = string.Empty;

            ApiSelectUserByUserLogonIdReturnModel userInfo;
            UserServices userService = new UserServices();

            userInfo = userService.GetUserByLogonId(email);

            //SiteServices siteService = new SiteServices();
            //List<ApiSelectTracerSitesByUserReturnModel> sites;
            //ApiSelectTracerSitesByUserReturnModel defaultSite;

            //sites = siteService.GetTracerSitesByUser(userInfo.UserID, null, null);
            //defaultSite = sites.Where(x => x.DefaultSelectedSite == 1).FirstOrDefault();
            //guestUserInfo = ValidateUser(email, defaultSite.SiteID);

            //----------------------------------------------------------------
            //if (!guestUserInfo.IsRegisteredUser)
            //{

            int defaultPassCode = 0;

            using (var db = new DBMEdition01Context())
            {
                try
                {
                    passCodeDB = db.ApiUpdateSelectPasscode(userInfo.UserID, userInfo.UserID, defaultPassCode).FirstOrDefault().Passcode.ToString();
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiUpdateSelectPasscode(" + userInfo.UserID + "," + userInfo.UserID + "," + defaultPassCode + ")";
                    string methodName = "JCRAPI/Business/GuestUserServices/AuthenticateGuestUser";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userInfo.UserID, null, sqlParam, string.Empty);

                    return(false);
                }
            }

            if (!string.Equals(passCode, passCodeDB, StringComparison.InvariantCulture))
            {
                rtn = false;
            }
            else
            {
                rtn = true;
            }

            //}
            //else
            //{
            //    DataSet dsUser = commonService.SelectUserInfoSitesAffiliationAndLicensesForActiveCyclesByLogon(AppSession.EmailAddress, Crypt.Encrypt(passCode.Trim(), WebConstants.ENCRYPT_KEY));

            //    if (dsUser.Tables[0].Rows.Count > 0)
            //        isAuthenticated = true;
            //}

            return(rtn);
        }