Ejemplo n.º 1
0
        public StartDocumentUploadReturnValue StartNewDocumentUploadForMatter(Guid logonId, Guid projectId,
                                                                              string FileName, DateTime ModifiedDate, long Size, byte[] Hash
                                                                              /* TODO Insert parameters here that ILB requires to store the document */)
        {
            StartDocumentUploadReturnValue ReturnValue = new StartDocumentUploadReturnValue();

            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");
                    }

                    DocumentStorageData DocumentStorageData = Host.GetDocumentStorageData(logonId);

                    DocumentStorageData.ExitingDocument = false;
                    DocumentStorageData.ProjectId       = projectId;
                    // TODO set other properties on DocumentStorageData so we know everything needed to store the document
                    // when it has finished uploading
                    //DocumentStorageData.othervalue = .....

                    ReturnValue.MaxChunkSize = Host.FileTransferChunkSize;

                    ReturnValue.TransferId = FileTransfer.StartFileUpload(logonId, FileName, ModifiedDate, Size, 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);
        }
        /// <summary>
        /// Start existing Document Upload for the specific Organisation
        /// </summary>
        /// <param name="oHostSecurityToken"></param>
        /// <param name="projectId"></param>
        /// <param name="FileName"></param>
        /// <param name="ModifiedDate"></param>
        /// <param name="Size"></param>
        /// <param name="Hash"></param>
        /// <param name="docId"></param>
        /// <returns></returns>
        public StartDocumentUploadReturnValue StartExistingDocumentUploadForOrganisation(HostSecurityToken oHostSecurityToken,
                                                                                         DateTime ModifiedDate, long Size, byte[] Hash, DocumentSearchItem docSearchItem)
        {
            StartDocumentUploadReturnValue ReturnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDocumentService = new DocumentService();
                ReturnValue      = oDocumentService.StartExistingDocumentUploadForOrganisation(Functions.GetLogonIdFromToken(oHostSecurityToken), ModifiedDate, Size, Hash, docSearchItem);
            }
            else
            {
                ReturnValue         = new StartDocumentUploadReturnValue();
                ReturnValue.Success = false;
                ReturnValue.Message = "Invalid Token";
            }
            return(ReturnValue);
        }
        /// <summary>
        /// Start New Document Upload for the specific organisation
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="ModifiedDate"></param>
        /// <param name="Size"></param>
        /// <param name="Hash"></param>
        /// <param name="docSearchItem"></param>
        /// <returns></returns>
        public StartDocumentUploadReturnValue StartNewDocumentUploadForOrganisation(Guid logonId,
            DateTime ModifiedDate, long Size, byte[] Hash, DocumentSearchItem docSearchItem)
        {
            StartDocumentUploadReturnValue ReturnValue = new StartDocumentUploadReturnValue();

            docSearchItem.ProjectId = Guid.Empty;
            docSearchItem.MemberId = Guid.Empty;

            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:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, docSearchItem.OrganisationId) || !UserSecuritySettings.GetUserSecuitySettings(274))
                                throw new Exception("Access denied");
                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    // Check File Type before upload
                    this.CheckFileTypeBeforeUpload(Path.GetFileName(docSearchItem.FileName));

                    DocumentStorageData documentStorageData = Host.GetDocumentStorageData(logonId);

                    #region Load Associate Data to DocumentStorageData

                    documentStorageData.ExitingDocument = false;
                    documentStorageData.DocDetails = docSearchItem;

                    SrvDocument srvDoc = new SrvDocument();
                    // If New document is being uploaded, Get the volume location which will help to upload document on documentuploadcomplete
                    srvDoc.ApplicationId = (int)DataConstants.Application.PMS;
                    srvDoc.FileName = docSearchItem.FileName;
                    srvDoc.DocumentModuleId = docSearchItem.OrganisationId;
                    srvDoc.Type = DmEnums.DmPMSDocType.Org;

                    bool isVoumeCreated = false;
                    Common commonFunction = new Common();
                    isVoumeCreated = commonFunction.GetVolumeLocation(ref srvDoc);

                    if (!isVoumeCreated)
                    {
                        throw new Exception("Upload document failed on the server.");
                    }
                    else
                    {
                        documentStorageData.VolumeLocation = srvDoc.VolumeLocation;
                        documentStorageData.VolumeId = srvDoc.VolumeId;
                        documentStorageData.FileName = srvDoc.FileName;
                    }

                    #endregion

                    ReturnValue.MaxChunkSize = Host.FileTransferChunkSize;

                    ReturnValue.TransferId = FileTransfer.StartFileUpload(logonId, Path.GetFileName(docSearchItem.FileName), ModifiedDate, Size, Hash, documentStorageData);
                }
                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;
        }
        /// <summary>
        /// Start existing Document Upload for the specific organisation
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="ModifiedDate"></param>
        /// <param name="Size"></param>
        /// <param name="Hash"></param>
        /// <param name="docSearchItem"></param>
        /// <returns></returns>
        public StartDocumentUploadReturnValue StartExistingDocumentUploadForOrganisation(Guid logonId,
            DateTime ModifiedDate, long Size, byte[] Hash, DocumentSearchItem docSearchItem)
        {
            StartDocumentUploadReturnValue ReturnValue = new StartDocumentUploadReturnValue();

            docSearchItem.ProjectId = Guid.Empty;
            docSearchItem.MemberId = Guid.Empty;

            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:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                            if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, docSearchItem.OrganisationId))
                                throw new Exception("Access denied");

                            this.CheckDocumentBelongsToOrganisation(docSearchItem.OrganisationId, docSearchItem.Id);

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

                            if (!srvDoc.IsPublic)
                                throw new Exception("Access denied");

                            break;
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    // Check File Type before upload
                    this.CheckFileTypeBeforeUpload(Path.GetFileName(docSearchItem.FileName));

                    DocumentStorageData documentStorageData = Host.GetDocumentStorageData(logonId);

                    documentStorageData.DocDetails = docSearchItem;

                    documentStorageData.ExitingDocument = true;

                    // Saving this data is not required here, hence commented out
                    // This information will not be requiring in UploadDocumentComplete
                    // as we are calling Reupload method & this method is handling all type of file handling
                    // like, versioning, encryption etc
                    // Reupload method gets this information using DocumentId
                    // SrvDocument srvDoc = new SrvDocument();
                    //srvDoc.Load(docSearchItem.Id);
                    //documentStorageData.VolumeLocation = srvDoc.VolumeLocation;
                    //documentStorageData.VolumeId = 0;
                    //documentStorageData.FileName = srvDoc.FileName;

                    ReturnValue.MaxChunkSize = Host.FileTransferChunkSize;

                    ReturnValue.TransferId = FileTransfer.StartFileUpload(logonId, Path.GetFileName(docSearchItem.FileName), ModifiedDate, Size, Hash, documentStorageData);
                }
                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;
        }
        public StartDocumentUploadReturnValue StartNewDocumentUploadForMatter(Guid logonId, Guid projectId,
            string FileName, DateTime ModifiedDate, long Size, byte[] Hash
            /* TODO Insert parameters here that ILB requires to store the document */)
        {
            StartDocumentUploadReturnValue ReturnValue = new StartDocumentUploadReturnValue();

            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");
                    }

                    DocumentStorageData DocumentStorageData = Host.GetDocumentStorageData(logonId);

                    DocumentStorageData.ExitingDocument = false;
                    DocumentStorageData.ProjectId = projectId;
                    // TODO set other properties on DocumentStorageData so we know everything needed to store the document
                    // when it has finished uploading
                    //DocumentStorageData.othervalue = .....

                    ReturnValue.MaxChunkSize = Host.FileTransferChunkSize;

                    ReturnValue.TransferId = FileTransfer.StartFileUpload(logonId, FileName, ModifiedDate, Size, 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;
        }