コード例 #1
0
        /// <summary>
        /// Start a document download
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="DocumentId"></param>
        /// <returns></returns>
        public StartDocumentDownloadReturnValue StartDocumentDownloadForMatter(Guid logonId, Guid projectId,
                                                                               int DocumentId /* TODO Replace this or add extra parameters needed to identify the document required */)
        {
            StartDocumentDownloadReturnValue ReturnValue = new StartDocumentDownloadReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    switch (ApplicationSettings.Instance.UserType)
                    {
                    case DataConstants.UserType.Staff:
                        // Can do everything
                        break;

                    case DataConstants.UserType.Client:
                    case DataConstants.UserType.ThirdParty:
                        if (!SrvMatterCommon.WebAllowedToAccessMatter(projectId))
                        {
                            throw new Exception("Access denied");
                        }
                        break;

                    default:
                        throw new Exception("Unknown UserType");
                    }

                    // TODO this is just a test file name, you must put the ILB document extraction code here
                    // and set SourceFileName appropriately
                    string SourceFileName = @"c:\work\SetupWebLinkDemo.exe";

                    FileDownloadInfo FileInfoData = FileTransfer.StartFileDownload(logonId, SourceFileName, false);

                    ReturnValue.TransferId   = FileInfoData.TransferId;
                    ReturnValue.FileName     = FileInfoData.FileName;
                    ReturnValue.Size         = FileInfoData.Size;
                    ReturnValue.ModifiedDate = FileInfoData.ModifiedDate;
                    ReturnValue.Hash         = FileInfoData.Hash;
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (Exception ex)
            {
                ReturnValue.Success = false;
                ReturnValue.Message = ex.Message;
            }

            return(ReturnValue);
        }
コード例 #2
0
        /// <summary>
        /// Start a document download
        /// </summary>
        /// <param name="oHostSecurityToken"></param>
        /// <param name="DocumentId"></param>
        /// <returns></returns>
        public StartDocumentDownloadReturnValue StartDocumentDownloadForMatter(HostSecurityToken oHostSecurityToken, Guid projectId,
                                                                               int DocumentId)
        {
            StartDocumentDownloadReturnValue ReturnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDocumentService = new DocumentService();
                ReturnValue      = oDocumentService.StartDocumentDownloadForMatter(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId, DocumentId);
            }
            else
            {
                ReturnValue         = new StartDocumentDownloadReturnValue();
                ReturnValue.Success = false;
                ReturnValue.Message = "Invalid Token";
            }
            return(ReturnValue);
        }
コード例 #3
0
        /// <summary>
        /// Start a document download
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="DocumentId"></param>
        /// <returns></returns>
        public StartDocumentDownloadReturnValue StartDocumentDownloadForMatter(Guid logonId, Guid projectId,
            int DocumentId)
        {
            StartDocumentDownloadReturnValue ReturnValue = new StartDocumentDownloadReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Check permission
                            if (!UserSecuritySettings.GetUserSecuitySettings(9))
                                throw new Exception("You do not have sufficient permissions to carry out this request");
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            if (!SrvMatterCommon.WebAllowedToAccessMatter(projectId))
                                throw new Exception("Access denied");

                            // Must check that document belongs to the matter
                            // (otherwise any docId could be passed and the matter security check above is meaningless)
                            this.CheckDocumentBelongsToMatter(projectId, DocumentId);

                            // if user is client or third party and the document is not public, throw an access denied exception
                            SrvDocument srvDoc = new SrvDocument();
                            srvDoc.Load(DocumentId);

                            if (!srvDoc.IsPublic)
                                throw new Exception("Access denied");
                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    string SourceFileName = string.Empty;
                    string downloadedFilePath = string.Empty;
                    string originalFilePath = string.Empty;
                    Common dmCommon = new Common();

                    try
                    {
                        originalFilePath = dmCommon.GetDownloadDocPath(DocumentId);
                        if (!string.IsNullOrEmpty(originalFilePath))
                        {
                            downloadedFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + Path.GetExtension(originalFilePath));
                            File.Copy(originalFilePath, downloadedFilePath, true);

                            // If originalFilePath is of Temp folder then that means the original file which was in encrypted format
                            // is now decrypted and stored in Temp folder.
                            // After copying the original file(decrypted) into the temp folder delete that file(decrypted).
                            string decryptedFilePath = Path.Combine(Path.GetTempPath(), new FileInfo(originalFilePath).Name);
                            if (File.Exists(decryptedFilePath))
                            {
                                File.Delete(decryptedFilePath);
                            }
                        }
                        else
                        {
                            throw new Exception("Download failed while contacting server for file.");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    SourceFileName = downloadedFilePath;

                    FileDownloadInfo FileInfoData = FileTransfer.StartFileDownload(logonId, SourceFileName, true);

                    ReturnValue.TransferId = FileInfoData.TransferId;
                    //ReturnValue.FileName = FileInfoData.FileName;
                    ReturnValue.FileName = new FileInfo(originalFilePath).Name;
                    ReturnValue.Size = FileInfoData.Size;
                    ReturnValue.ModifiedDate = FileInfoData.ModifiedDate;
                    ReturnValue.Hash = FileInfoData.Hash;

                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                ReturnValue.Success = false;
                ReturnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                ReturnValue.Success = false;
                ReturnValue.Message = ex.Message;
            }

            return ReturnValue;
        }
コード例 #4
0
        /// <summary>
        /// Start a document download
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="DocumentId"></param>
        /// <returns></returns>
        public StartDocumentDownloadReturnValue StartDocumentDownloadForMatter(Guid logonId, Guid projectId,
            int DocumentId /* TODO Replace this or add extra parameters needed to identify the document required */)
        {
            StartDocumentDownloadReturnValue ReturnValue = new StartDocumentDownloadReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    switch (ApplicationSettings.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            if (!SrvMatterCommon.WebAllowedToAccessMatter(projectId))
                                throw new Exception("Access denied");
                            break;
                        default:
                            throw new Exception("Unknown UserType");
                    }

                    // TODO this is just a test file name, you must put the ILB document extraction code here
                    // and set SourceFileName appropriately
                    string SourceFileName = @"c:\work\SetupWebLinkDemo.exe";

                    FileDownloadInfo FileInfoData = FileTransfer.StartFileDownload(logonId, SourceFileName, false);

                    ReturnValue.TransferId = FileInfoData.TransferId;
                    ReturnValue.FileName = FileInfoData.FileName;
                    ReturnValue.Size = FileInfoData.Size;
                    ReturnValue.ModifiedDate = FileInfoData.ModifiedDate;
                    ReturnValue.Hash = FileInfoData.Hash;
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (Exception ex)
            {
                ReturnValue.Success = false;
                ReturnValue.Message = ex.Message;
            }

            return ReturnValue;
        }