Beispiel #1
0
        private void PingSource(CaseSource <T> caseSourceT)
        {
            while (!m_Shutdown)
            {
                try
                {
                    caseSourceT.EndPoint.Ping(m_WSId);

                    if (typeof(T) == typeof(WSCommEndpoint))
                    {
                        Thread.Sleep(_wsCommPingTimeoutMsec);
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }
                }
                catch (Exception)
                {
                    break;
                }
            }

            m_PingThreads.Remove(Thread.CurrentThread);

            RemoveSource(caseSourceT);
        }
Beispiel #2
0
        public void GetManifestList(string sourceAlias, out ObservableCollectionEx <string> manifestList)
        {
            CaseSource <WSCommEndpoint> WSCommSource = FindSource <WSCommEndpoint>(sourceAlias);

            if (default(CaseSource <WSCommEndpoint>) != WSCommSource)
            {
                try
                {
                    WSCommSource.GetManifestList(out manifestList);
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    WSCommSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(WSCommSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(WSCommSource.Alias);
                    }
                    m_WSCommSources.RemoveSource(WSCommSource);

                    throw;
                }
            }
            else
            {
                throw new Exception(ErrorMessages.SOURCE_NOT_AVAILABLE);
            }
        }
Beispiel #3
0
 public void AddSource(CaseSource <T> caseSourceT)
 {
     lock (_lockUpdateEventObject)
     {
         Add(caseSourceT);
         SourceListUpdateEvent(caseSourceT.Alias, true, caseSourceT.IsLoginRequired);
     }
 }
Beispiel #4
0
        public void UpdateProfile(string sourceAlias, string userName, Profile profile)
        {
            CaseSource <WSCommEndpoint>             WSCommSource = FindSource <WSCommEndpoint>(sourceAlias);
            CaseSource <CaseRequestManagerEndpoint> ACSSource    = FindSource <CaseRequestManagerEndpoint>(sourceAlias);

            if (default(CaseSource <WSCommEndpoint>) != WSCommSource)
            {
                try
                {
                    WSCommSource.EndPoint.UpdateProfile(userName, profile);
                }
                catch (FaultException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    if (WSCommSource != null)
                    {
                        WSCommSource.EndPoint.Abort();
                        if (m_SysConfigMgrAccess.Contains(WSCommSource.Alias))
                        {
                            m_SysConfigMgrAccess.Delete(WSCommSource.Alias);
                        }
                        m_WSCommSources.RemoveSource(WSCommSource);
                    }
                    throw;
                }
            }
            else if (default(CaseSource <CaseRequestManagerEndpoint>) != ACSSource)
            {
                try
                {
                    ACSSource.EndPoint.UpdateProfile(userName, profile);
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    if (ACSSource != null)
                    {
                        ACSSource.EndPoint.Abort();
                        if (m_SysConfigMgrAccess.Contains(ACSSource.Alias))
                        {
                            m_SysConfigMgrAccess.Delete(ACSSource.Alias);
                        }
                        m_ACSSources.RemoveSource(ACSSource);
                    }
                    throw;
                }
            }
            else
            {
                throw new Exception(ErrorMessages.SOURCE_NOT_AVAILABLE);
            }
        }
Beispiel #5
0
        public Stream RequestFile(string sourceAlias, string caseId, string filename, FileType filetype)
        {
            CaseDataInfo caseDataInfo = new CaseDataInfo(caseId, filename, filetype);

            CaseSource <WSCommEndpoint>             WSCommSource = FindSource <WSCommEndpoint>(sourceAlias);
            CaseSource <CaseRequestManagerEndpoint> ACSSource    = FindSource <CaseRequestManagerEndpoint>(sourceAlias);

            if (default(CaseSource <WSCommEndpoint>) != WSCommSource)
            {
                try
                {
                    return(WSCommSource.EndPoint.RequestCaseData(caseDataInfo));
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    WSCommSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(WSCommSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(WSCommSource.Alias);
                    }
                    m_WSCommSources.RemoveSource(WSCommSource);

                    throw;
                }
            }
            else if (default(CaseSource <CaseRequestManagerEndpoint>) != ACSSource)
            {
                try
                {
                    return(ACSSource.EndPoint.RequestCaseData(caseDataInfo));
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    ACSSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(ACSSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(ACSSource.Alias);
                    }
                    m_ACSSources.RemoveSource(ACSSource);

                    throw;
                }
            }
            else
            {
                throw new Exception(ErrorMessages.SOURCE_NOT_AVAILABLE);
            }
        }
Beispiel #6
0
 public void RemoveSource(CaseSource <T> caseSourceT)
 {
     lock (_lockUpdateEventObject)
     {
         if (Remove(caseSourceT))
         {
             SourceListUpdateEvent(caseSourceT.Alias, false, false);
         }
     }
 }
Beispiel #7
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);
        }
Beispiel #8
0
        private void ListenForSources()
        {
            HostDiscovery sourceDiscovery = new HostDiscovery(m_ContractType, new TimeSpan(0, 0, 0, _wcfDiscoveryProbeTimeoutPeriodSec, 0),
                                                              _enableDiscoveryManagedMode, _discoveryProxyUri);

            while (!m_Shutdown)
            {
                Collection <EndpointDiscoveryMetadata> sourceEndpoints = sourceDiscovery.GetAvailableConnections();

                if (sourceEndpoints.Count > 0)
                {
                    for (int index = 0; index < sourceEndpoints.Count; index++)
                    {
                        string alias = GetAlias(sourceEndpoints[index].Extensions);
                        if (!String.IsNullOrWhiteSpace(alias))
                        {
                            alias = m_SourceType.ToString() + "-" + alias;

                            if (!ContainsEndPoints(alias))
                            {
                                bool isLoginRequired = GetLoginRequired(sourceEndpoints[index].Extensions);

                                CaseSource <T> caseSourceT = new CaseSource <T>(alias, isLoginRequired);

                                InstanceContext sourceCallback = new InstanceContext(caseSourceT);

                                ServiceEndpoint HostEndPoint =
                                    new ServiceEndpoint(ContractDescription.GetContract(m_ContractType),
                                                        new TCPBinding(),
                                                        sourceEndpoints[index].Address);
                                HostEndPoint.Binding.SendTimeout    = new TimeSpan(0, _wcfTcpBindingSendTimeoutMin, 0);
                                HostEndPoint.Binding.ReceiveTimeout = new TimeSpan(0, _wcfTcpBindingReceiveTimeoutMin, 0);

                                T t = (T)Activator.CreateInstance(typeof(T), new object[] { sourceCallback, HostEndPoint });

                                caseSourceT.EndPoint = t;

                                AddSource(caseSourceT);

                                Thread caseListThread = new Thread(new ParameterizedThreadStart(delegate { try { GetCaseList(caseSourceT, alias); } catch { } }));
                                caseListThread.Start();

                                Thread pingThread = new Thread(new ParameterizedThreadStart(delegate { PingSource(caseSourceT); }));
                                pingThread.Start();

                                m_PingThreads.Add(pingThread);
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
0
 private void GetCaseList(CaseSource <T> caseSourceT, string alias)
 {
     try
     {
         caseSourceT.CaseList = new CaseListDataSet();
         CaseListDataSet tempCaseList = caseSourceT.EndPoint.RequestCaseList(m_WSId);
         lock (caseSourceT.CaseListLock)
         {
             caseSourceT.CaseList.Merge(tempCaseList);
         }
     }
     catch (Exception ex)
     {
         RemoveSource(caseSourceT);
         throw;
     }
 }
Beispiel #10
0
        public void GetCaseList(string sourceAlias, out DataSet caseList)
        {
            caseList = null;

            CaseSource <WSCommEndpoint>             WSCommSource = FindSource <WSCommEndpoint>(sourceAlias);
            CaseSource <CaseRequestManagerEndpoint> ACSSource    = FindSource <CaseRequestManagerEndpoint>(sourceAlias);

            if (default(CaseSource <WSCommEndpoint>) != WSCommSource)
            {
                caseList = WSCommSource.CaseList;
            }
            else if (default(CaseSource <CaseRequestManagerEndpoint>) != ACSSource)
            {
                caseList = ACSSource.CaseList;
            }
            else
            {
                throw new Exception(ErrorMessages.CASE_LIST_NOT_AVAILABLE);
            }
        }
Beispiel #11
0
        public void UpdateCase(string sourceAlias, string caseId, CaseUpdateEnum type, string filename, Stream file, AttachFileTypeEnum attachFileType,
                               WorkstationResult result, string ContainerNum, string UserName, string CreateTime, L3.Cargo.Communications.Interfaces.CaseType caseType)
        {
            UpdateCaseMessage updateCaseMessage = new UpdateCaseMessage(caseId, type, caseType);

            if (type == CaseUpdateEnum.AttachFile)
            {
                updateCaseMessage.AttachFileType = attachFileType;
                updateCaseMessage.File           = file;
                updateCaseMessage.Filename       = filename;
                updateCaseMessage.UserName       = UserName;
            }

            updateCaseMessage.WorkstationId     = m_SysConfigMgrAccess.GetDefaultConfig().WorkstationAlias;
            updateCaseMessage.CaseId            = caseId;
            updateCaseMessage.ObjectId          = ContainerNum;
            updateCaseMessage.workstationResult = result;
            updateCaseMessage.Type       = type;
            updateCaseMessage.CreateTime = CreateTime;
            updateCaseMessage.UserName   = UserName;

            CaseSource <WSCommEndpoint>             WSCommSource = FindSource <WSCommEndpoint>(sourceAlias);
            CaseSource <CaseRequestManagerEndpoint> ACSSource    = FindSource <CaseRequestManagerEndpoint>(sourceAlias);

            if (default(CaseSource <WSCommEndpoint>) != WSCommSource)
            {
                try
                {
                    WSCommSource.EndPoint.UpdateCase(updateCaseMessage);
                }
                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>) != ACSSource)
            {
                try
                {
                    ACSSource.EndPoint.UpdateCase(updateCaseMessage);
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    ACSSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(ACSSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(ACSSource.Alias);
                    }
                    m_ACSSources.RemoveSource(ACSSource);
                    throw;
                }
            }
            else
            {
                throw new Exception(ErrorMessages.SOURCE_NOT_AVAILABLE);
            }
        }
Beispiel #12
0
        public CaseObject RequestCase(string sourceAlias, string caseId, bool isEditable)
        {
            CaseMessage caseMessage = new CaseMessage(caseId, m_WorkstationId);

            caseMessage.IsCaseEditable  = isEditable;
            caseMessage.WorkstationMode = _workstationMode;
            CaseRequestMessageResponse response = new CaseRequestMessageResponse();

            CaseSource <WSCommEndpoint>             WSCommSource = FindSource <WSCommEndpoint>(sourceAlias);
            CaseSource <CaseRequestManagerEndpoint> ACSSource    = FindSource <CaseRequestManagerEndpoint>(sourceAlias);

            if (default(CaseSource <WSCommEndpoint>) != WSCommSource)
            {
                try
                {
                    response = WSCommSource.EndPoint.RequestCase(caseMessage);
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    WSCommSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(WSCommSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(WSCommSource.Alias);
                    }
                    m_WSCommSources.RemoveSource(WSCommSource);

                    throw;
                }
            }
            else if (default(CaseSource <CaseRequestManagerEndpoint>) != ACSSource)
            {
                try
                {
                    response = ACSSource.EndPoint.RequestCase(caseMessage);
                }
                catch (FaultException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    ACSSource.EndPoint.Abort();
                    if (m_SysConfigMgrAccess.Contains(ACSSource.Alias))
                    {
                        m_SysConfigMgrAccess.Delete(ACSSource.Alias);
                    }
                    m_ACSSources.RemoveSource(ACSSource);
                    throw;
                }
            }
            else
            {
                throw new Exception(ErrorMessages.SOURCE_NOT_AVAILABLE);
            }

            CaseObject tmpCaseObj = CaseTranslator.Translate(response.file);

            if (response.AdditionalFiles != null)
            {
                foreach (KeyValuePair <FileType, String> file in response.AdditionalFiles)
                {
                    DataAttachment attach = new DataAttachment();
                    attach.attachmentId = file.Value;
                    switch (file.Key)
                    {
                    case FileType.AnalysisHistory:
                        attach.attachmentType = AttachmentType.AnalysisHistory;
                        break;

                    case FileType.FTIFile:
                        attach.attachmentType = AttachmentType.FTIImage;
                        break;

                    default:
                        attach.attachmentType = AttachmentType.Unknown;
                        break;
                    }
                    tmpCaseObj.attachments.Add(attach);
                }
            }

            tmpCaseObj.caseType = (L3.Cargo.Common.CaseType)response.caseType;

            //Case is editable if it is a primary case and case source specidies result (Decision) is enabled.
            tmpCaseObj.IsCaseEditable = (isEditable && response.IsResultEnabled);

            return(tmpCaseObj);
        }