public Folder SaveThirdParty(ThirdPartyParams thirdPartyParams) { using (var folderDao = GetFolderDao()) using (var providerDao = GetProviderDao()) { var parentFolder = folderDao.GetFolder(thirdPartyParams.Corporate ? Global.FolderCommon : Global.FolderMy); ErrorIf(!FileSecurity.CanCreate(parentFolder), FilesCommonResource.ErrorMassage_SecurityException_Create); var folderType = thirdPartyParams.Corporate ? FolderType.COMMON : FolderType.USER; int curProviderId; if (string.IsNullOrEmpty(thirdPartyParams.ProviderId)) { ErrorIf(!ImportConfiguration.SupportInclusion, FilesCommonResource.ErrorMassage_SecurityException_Create); curProviderId = providerDao.SaveProviderInfo(thirdPartyParams.ProviderName, thirdPartyParams.CustomerTitle, thirdPartyParams.AuthData, folderType); } else { curProviderId = int.Parse(thirdPartyParams.ProviderId); curProviderId = providerDao.UpdateProviderInfo(curProviderId, thirdPartyParams.CustomerTitle, thirdPartyParams.AuthData, folderType); } var provider = providerDao.GetProviderInfo(curProviderId); var folder = GetFolder(provider.RootFolderId.ToString()); return folder; } }
public FolderContentWrapper SaveThirdParty( String url, String login, String password, String token, bool isCorporate, String customerTitle, String providerKey, String providerid) { var thirdPartyParams = new ThirdPartyParams { AuthData = new AuthData(url, login, password, token), Corporate = isCorporate, CustomerTitle = customerTitle, ProviderId = providerid, ProviderKey = providerKey, }; var folder = _fileStorageService.SaveThirdParty(thirdPartyParams); return ToFolderContentWrapper(folder.ID); }
public Folder SaveThirdParty(ThirdPartyParams thirdPartyParams) { using (var folderDao = GetFolderDao()) using (var providerDao = GetProviderDao()) { var parentFolder = folderDao.GetFolder(thirdPartyParams.Corporate && !CoreContext.Configuration.Personal ? Global.FolderCommon : Global.FolderMy); ErrorIf(!FileSecurity.CanCreate(parentFolder), FilesCommonResource.ErrorMassage_SecurityException_Create); ErrorIf(!Global.IsAdministrator && !FilesSettings.EnableThirdParty, FilesCommonResource.ErrorMassage_SecurityException_Create); var lostFolderType = FolderType.USER; var folderType = thirdPartyParams.Corporate ? FolderType.COMMON : FolderType.USER; int curProviderId; MessageAction messageAction; if (string.IsNullOrEmpty(thirdPartyParams.ProviderId)) { ErrorIf(!ImportConfiguration.SupportInclusion || (!Global.IsAdministrator && !CoreContext.Configuration.Personal && !FilesSettings.EnableThirdParty) , FilesCommonResource.ErrorMassage_SecurityException_Create); try { curProviderId = providerDao.SaveProviderInfo(thirdPartyParams.ProviderKey, thirdPartyParams.CustomerTitle, thirdPartyParams.AuthData, folderType); messageAction = MessageAction.ThirdPartyCreated; } catch(Exception e) { throw GenerateException(e); } } else { curProviderId = Convert.ToInt32(thirdPartyParams.ProviderId); var lostProvider = providerDao.GetProviderInfo(curProviderId); lostFolderType = lostProvider.RootFolderType; if (!thirdPartyParams.Corporate) { var lostFolder = folderDao.GetFolder(lostProvider.RootFolderId); FileMarker.RemoveMarkAsNewForAll(lostFolder); } curProviderId = providerDao.UpdateProviderInfo(curProviderId, thirdPartyParams.CustomerTitle, folderType); messageAction = MessageAction.ThirdPartyUpdated; } var provider = providerDao.GetProviderInfo(curProviderId); var folder = folderDao.GetFolder(provider.RootFolderId); ErrorIf(!FileSecurity.CanRead(folder), FilesCommonResource.ErrorMassage_SecurityException_ViewFolder); FilesMessageService.Send(parentFolder, GetHttpRequest(OperationContext.Current), messageAction, folder.ID.ToString(), provider.ProviderKey); if (thirdPartyParams.Corporate && lostFolderType != FolderType.COMMON) { FileMarker.MarkAsNew(folder); } return folder; } }