Ejemplo n.º 1
0
        private void FileServiceInit(AuthorizedIdent ident, bool reload)
        {
            if (reload || m_fdss[ident.Name] == null)
            {
                FileDataWebGateway fds = new FileDataWebGateway();
                fds.Url = String.Format("http://{0}/FrontDeskServices/filedataservice.asmx",
                                        Globals.FileSystemAddress);
                string        password = new Users(null).GetPassword(ident.Name);
                ServiceTicket tik      = fds.Authenticate(ident.Name, password);
                fds.ServiceTicketValue = tik;

                m_fdss[m_ident.Name] = fds;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load data for a file
        /// </summary>
        public bool LoadFileData(CFile file)
        {
            if (file.IsDirectory())
            {
                return(false);
            }

            //Authorize
            if (!Authorize(file, FileAction.READ))
            {
                throw new FileOperationException("Permission denied for action: READ");
            }

            //Connect to data service
            FileDataWebGateway fds = (FileDataWebGateway)m_fdss[m_ident.Name];

            if (fds != null)
            {
                DataEnvelope data;
                try {
                    data = fds.LoadFileData(file.ID);
                } catch (Exception) {
                    FileServiceInit(m_ident, true);
                    fds = (FileDataWebGateway)m_fdss[m_ident.Name];
                    try {
                        data = fds.LoadFileData(file.ID);
                    } catch (Exception) {
                        throw new FileOperationException("Unable to connect to the file system or file not found");
                    }
                }
                if (data.Size > 0)
                {
                    file.RawData = data.Data;
                }
                else
                {
                    file.RawData = new byte[0];
                }
            }
            else
            {
                m_fs.FetchData(file);
            }

            return(true);
        }
Ejemplo n.º 3
0
        protected void CopyFileData(string dir, string dbase, string sbase)
        {
            string spath = Path.Combine(sbase, dir);
            CFile  sfile = GetFile(spath);

            if (sfile.IsDirectory())
            {
                foreach (CFile dirmem in ListDirectory(sfile))
                {
                    CopyFileData(Path.Combine(dir, dirmem.Name), dbase, sbase);
                }
            }
            else
            {
                string dpath = Path.Combine(dbase, dir);
                CFile  dfile = GetFile(dpath);

                //Copy file
                FileDataWebGateway fds = (FileDataWebGateway)m_fdss[m_ident.Name];
                if (fds != null)
                {
                    try {
                        fds.CreateFile(sfile.ID);
                        fds.CopyFile(sfile.ID, dfile.ID);
                    } catch (Exception) {
                        FileServiceInit(m_ident, true);
                        fds = (FileDataWebGateway)m_fdss[m_ident.Name];
                        try {
                            fds.CreateFile(sfile.ID);
                            fds.CopyFile(sfile.ID, dfile.ID);
                        } catch (Exception) {
                            throw new FileOperationException("Unable to connect to the file system");
                        }
                    }
                }
                else
                {
                    m_fs.CreateFile(sfile);
                    m_fs.CopyFile(sfile, dfile);
                }
            }
        }
Ejemplo n.º 4
0
        private void DeleteFileData(CFile file)
        {
            FileDataWebGateway fds = (FileDataWebGateway)m_fdss[m_ident.Name];

            if (fds != null)
            {
                try {
                    fds.DeleteFile(file.ID);
                } catch (Exception) {
                    FileServiceInit(m_ident, true);
                    fds = (FileDataWebGateway)m_fdss[m_ident.Name];
                    try {
                        fds.DeleteFile(file.ID);
                    } catch (Exception) {
                        throw new FileOperationException("Unable to connect to the file system");
                    }
                }
            }
            else
            {
                m_fs.DeleteFile(file);
            }
        }