Example #1
0
        public override void UpdateCase(UpdateCaseMessage message)
        {
            if (caseList.AssignedId(message.CaseId) == message.WorkstationId)
            {
                if (message.Type == CaseUpdateEnum.ReleaseCase)
                {
                    try
                    {
                        m_CargoHostEndPoint.ReleaseCase(message.CaseId);
                        SetLoadBalancecaseRequestedCurrently(message.WorkstationId, false);

                        if (m_TIPManagerComm != null)
                        {
                            m_TIPManagerComm.ProcessedCase(message.CaseId);
                        }
                    }
                    catch (Exception exp)
                    {
                        throw new FaultException(new FaultReason(exp.Message));
                    }
                }
                else if (message.Type == CaseUpdateEnum.CloseCase && message.CaseType != L3.Cargo.Communications.Interfaces.CaseType.FTICase)
                {
                    lock (_updateCaseAssignmentLock)
                    {
                        base.ClearAssignment(message.CaseId);
                        CaseListUpdateEvent(message.CaseId, string.Empty, string.Empty, true);

                        if (message.CaseType == L3.Cargo.Communications.Interfaces.CaseType.CTICase)
                        {
                            m_TIPManagerComm.RemoveCTICaseAssignment(message.CaseId);
                            CaseListUpdateEvent(message.CaseId, String.Empty, String.Empty, false);
                            base.caseList.Delete(message.CaseId);
                        }
                    }
                }
                else if (message.Type == CaseUpdateEnum.CloseCase && message.CaseType == L3.Cargo.Communications.Interfaces.CaseType.FTICase)
                {
                    WorkstationResult result = new WorkstationResult();

                    TimeSpan analysisTime = DateTime.Now.Subtract(DateTime.Parse(message.CreateTime));

                    result.AnalysisTime  = (uint)analysisTime.TotalSeconds;
                    result.CaseId        = message.CaseId;
                    result.CaseType      = message.CaseType;
                    result.Comment       = string.Empty;
                    result.CreateTime    = message.CreateTime;
                    result.Decision      = WorkstationDecision.Unknown;
                    result.Reason        = WorkstationReason.NotApplicable;
                    result.UserName      = message.UserName;
                    result.WorkstationId = message.WorkstationId;
                    m_TIPManagerComm.TipResult(result);
                }
                else if (message.Type == CaseUpdateEnum.Result)
                {
                    try
                    {
                        if (message.CaseType == L3.Cargo.Communications.Interfaces.CaseType.CTICase ||
                            message.CaseType == L3.Cargo.Communications.Interfaces.CaseType.FTICase)
                        {
                            if (message.workstationResult.CaseType == L3.Cargo.Communications.Interfaces.CaseType.CTICase)
                            {
                                lock (_updateCaseAssignmentLock)
                                {
                                    CaseListUpdateEvent(message.CaseId, String.Empty, String.Empty, false);
                                    base.caseList.Delete(message.CaseId);
                                }
                            }

                            m_TIPManagerComm.TipResult(message.workstationResult);
                        }
                        else
                        {
                            l3.cargo.corba.Result result = new l3.cargo.corba.Result();
                            result.mAnalysisTime = message.workstationResult.AnalysisTime.ToString();
                            result.mComment      = message.workstationResult.Comment;
                            result.mCreateTime   = message.workstationResult.CreateTime;

                            if (message.workstationResult.Decision == WorkstationDecision.Unknown)
                            {
                                result.mDecision = l3.cargo.corba.ResultDecision.RESULT_UNKNOWN;
                            }
                            else if (message.workstationResult.Decision == WorkstationDecision.Reject)
                            {
                                result.mDecision = l3.cargo.corba.ResultDecision.REJECT;
                            }
                            else if (message.workstationResult.Decision == WorkstationDecision.Clear)
                            {
                                result.mDecision = l3.cargo.corba.ResultDecision.CLEAR;
                            }
                            else
                            {
                                result.mDecision = l3.cargo.corba.ResultDecision.CAUTION;
                            }

                            result.mReason      = message.workstationResult.Reason.ToString();
                            result.mStationType = message.workstationResult.WorkstationType;
                            result.mUserName    = message.workstationResult.UserName;

                            m_CargoHostEndPoint.SetResult(message.CaseId, result);
                        }
                    }
                    catch (Exception exp)
                    {
                        throw new FaultException(new FaultReason(exp.Message));
                    }
                }
                else if (message.CaseType == L3.Cargo.Communications.Interfaces.CaseType.FTICase || message.CaseType == L3.Cargo.Communications.Interfaces.CaseType.CTICase)
                {
                    //Do Nothing
                }
                else if (message.Type == CaseUpdateEnum.AttachFile)
                {
                    String TempDirectory = ConfigurationManager.AppSettings["hostTempDirectory"];
                    try
                    {
                        if (!Directory.Exists(TempDirectory))
                        {
                            Directory.CreateDirectory(TempDirectory);
                        }

                        using (FileStream stream = new FileStream(Path.Combine(TempDirectory, message.Filename), FileMode.OpenOrCreate))
                        {
                            message.File.CopyTo(stream);
                        }

                        m_CargoHostEndPoint.AddAttachment(message.CaseId, Path.Combine(TempDirectory, message.Filename),
                                                          message.AttachFileType.ToString(), message.UserName, message.CreateTime);
                    }
                    catch (Exception exp)
                    {
                        throw new FaultException(new FaultReason(exp.Message));
                    }
                }
                else if (message.Type == CaseUpdateEnum.ObjectID)
                {
                    try
                    {
                        m_CargoHostEndPoint.SetContainerID(message.CaseId, message.ObjectId);
                    }
                    catch (Exception exp)
                    {
                        throw new FaultException(new FaultReason(exp.Message));
                    }
                }
            }
        }