public addVisitorInfo ( AbstractCredentials credentials ) : void | ||
credentials | AbstractCredentials | |
Результат | void |
public void addVisitorInfo(AbstractCredentials credentials)
{
string DUZ = credentials.LocalUid;
string arg = "$P($G(^VA(200," + DUZ + ",0)),\"^\",1)"; //NAME
arg += "_\"^\"_" + "$P($G(^VA(200," + DUZ + ",1)),\"^\",9)";
arg += "_\"^\"_" + "$P($G(^VA(200," + DUZ + ",.13)),\"^\",2)"; //OFFICE PHONE
string response = "";
try
{
response = VistaUtils.getVariableValue(cxn, arg);
}
catch (Exception e)
{
if (e.Message.Contains("M ERROR"))
{
throw new ArgumentException("No such DUZ");
}
else
{
throw e;
}
}
if (response == "")
{
return;
}
string[] flds = StringUtils.split(response, StringUtils.CARET);
credentials.FederatedUid = flds[1];
credentials.SubjectName = flds[0];
credentials.SubjectPhone = flds[2];
credentials.AuthenticationSource.SiteId.Id = cxn.DataSource.SiteId.Id;
credentials.AuthenticationSource.SiteId.Name = cxn.DataSource.SiteId.Name;
}
internal void doTheAuthorize(AbstractCredentials credentials, AbstractPermission permission) { //// if we are requesting CPRS context with a visit and user does not have it - add it to their account if (permission.Name == VistaConstants.CPRS_CONTEXT && !Cxn.Account.Permissions.ContainsKey(VistaConstants.CPRS_CONTEXT) && !Cxn.Account.AuthenticationMethod.Equals(VistaConstants.LOGIN_CREDENTIALS)) { addContextInVista(Cxn.Uid, permission); } else { setContext(permission); } if (String.IsNullOrEmpty(Cxn.Uid)) { if (String.IsNullOrEmpty(credentials.FederatedUid)) { throw new MdoException("Missing federated UID, cannot get local UID"); } VistaUserDao dao = new VistaUserDao(Cxn); Cxn.Uid = dao.getUserIdBySsn(credentials.FederatedUid); if (String.IsNullOrEmpty(Cxn.Uid)) { throw new MdoException("Unable to get local UID for federated ID " + credentials.FederatedUid); } } if (!credentials.Complete) { VistaUserDao dao = new VistaUserDao(Cxn); dao.addVisitorInfo(credentials); } }