public static FtpAccount GetFtpAccount(int itemId) { // load meta item FtpAccount item = (FtpAccount)PackageController.GetPackageItem(itemId); // load service item FTPServer ftp = new FTPServer(); ServiceProviderProxy.Init(ftp, item.ServiceId); FtpAccount account = ftp.GetAccount(item.Name); // truncate home folder account.Folder = FilesController.GetVirtualPackagePath(item.PackageId, account.Folder); account.Id = item.Id; account.PackageId = item.PackageId; account.ServiceId = item.ServiceId; account.Password = CryptoUtils.Decrypt(item.Password); return account; }
public void ImportItem(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group, string itemName) { // get service id int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName); if (serviceId == 0) return; // FTP provider FTPServer ftp = new FTPServer(); ServiceProviderProxy.Init(ftp, serviceId); if (itemType == typeof(FtpAccount)) { // load FTP account FtpAccount account = ftp.GetAccount(itemName); account.Folder = FilesController.GetFullPackagePath(packageId, "\\"); // root space folder // update FTP account ftp.UpdateAccount(account); // save account account.ServiceId = serviceId; account.PackageId = packageId; PackageController.AddPackageItem(account); } }