Ejemplo n.º 1
0
        private AuthenticationLevel LoginToIndividualSource(string sourceAlias, string username, string password)
        {
            AuthenticationLevel ret = AuthenticationLevel.None;

            try
            {
                string          wsId     = m_SysConfig.GetDefaultConfig().WorkstationAlias;
                UserInfo        userInfo = new UserInfo(username, password);
                WorkstationInfo wsInfo   = new WorkstationInfo(wsId, userInfo);

                LoginResponse loginResponse = m_DataSourceAccess.Login(sourceAlias, wsInfo);

                ret = loginResponse.UserAuthenticationLevel;

                if (!ret.Equals(AuthenticationLevel.None))
                {
                    SysConfiguration sysConfig = new SysConfiguration();
                    sysConfig.ID = sourceAlias;
                    sysConfig.ContainerDBConnectionString = loginResponse.systemConfiguration.ContainerDBConnectString;
                    sysConfig.ContainerRefreshPeriodmsecs = loginResponse.systemConfiguration.ContainerRefreshPeriodSeconds * 1000;

                    if (m_SysConfig.Contains(sourceAlias))
                    {
                        m_SysConfig.Delete(sourceAlias);
                    }

                    m_SysConfig.Add(sysConfig);

                    if (m_SysConfig.UserProfileManager.Profile == null)
                    {
                        ProfileObject profile = ProfileTranslator.Translate(loginResponse.UserProfile, 4);
                        profile.SourceAlias = sourceAlias;
                        profile.UserName    = wsInfo.userInfo.UserName;
                        profile.Password    = wsInfo.userInfo.Password;

                        m_SysConfig.UserProfileManager.Profile = profile;
                        m_SysConfig.UserProfileManager.Profile.ProfileUpdatedEvent += new ProfileUpdated(ProfileUpdated);
                    }

                    DataSet caselist = null;
                    m_DataSourceAccess.GetCaseList(sourceAlias, out caselist);

                    if (caselist != null)
                    {
                        CaseListDataSet caseListDataSet = (CaseListDataSet)caselist;
                        caseListDataSet.CaseListTable.CaseListTableRowChanged +=
                            new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_CaseListTableRowChanged);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(ret);
        }
Ejemplo n.º 2
0
        public LoginResponse Login(string sourceAlias, WorkstationInfo workstationInfo)
        {
            CaseSource <WSCommEndpoint>             WSCommSource      = FindSource <WSCommEndpoint>(sourceAlias);
            CaseSource <CaseRequestManagerEndpoint> ArchiveCaseSource = FindSource <CaseRequestManagerEndpoint>(sourceAlias);

            if (default(CaseSource <WSCommEndpoint>) != WSCommSource)
            {
                workstationInfo.WorkstationId = m_WorkstationId;

                try
                {
                    return(WSCommSource.EndPoint.Login(workstationInfo));
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception)
                {
                    WSCommSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(WSCommSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(WSCommSource.Alias);
                    }
                    m_WSCommSources.RemoveSource(WSCommSource);
                    throw;
                }
            }
            else if (default(CaseSource <CaseRequestManagerEndpoint>) != ArchiveCaseSource)
            {
                workstationInfo.WorkstationId = m_WorkstationId;

                try
                {
                    return(ArchiveCaseSource.EndPoint.Login(workstationInfo));
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception)
                {
                    ArchiveCaseSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(ArchiveCaseSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(ArchiveCaseSource.Alias);
                    }
                    m_ACSSources.RemoveSource(ArchiveCaseSource);
                    throw;
                }
            }

            throw new Exception(ErrorMessages.SOURCE_NOT_AVAILABLE);
        }