Пример #1
0
        private bool ExportApprovedData(ref string fileToSave, ref string fileName)
        {
            //TODO this check is usually not called, because this option is only available while on server.
            if (!SiteConfigServices.IsServer)
            {
                SetMessage("Error writing file");
                SetMessage("You can only export approved data from a server");
                return false;
            }

            try
            {
                //TODO make sure that all the selected mda's are from the same site
                InstallationServices installationServices = new InstallationServices();
                if (installationServices.MdaIdsBelongToSameInstallation(_selectedMDAS.Select(x => x.id).ToList()))
                {
                    fileToSave = _syncServices.GetApprovedDataToSyncSecure(_selectedMDAS.Select(x => x.id).ToList(), _configurationManager.LoggedInUser);
                    fileName = Constants.SSEPS_FILE_APPROVED;
                    return true;
                }
                else
                {
                    SetMessage("Error writing file");
                    SetMessage("Selected mda's don't belong to same site");
                    return false;
                }
            }
            catch (ArgumentNullException ex)
            {
                SetMessage("Error writing file");
                switch (ex.ParamName)
                {
                    case "plainText":
                        SetMessage("Data to be exported not found 1");
                        break;
                    case "cipherText":
                        SetMessage("Data to be exported not found 2");
                        break;
                    case "sharedSecret":
                        SetMessage("Installation token not found on this machine");
                        break;
                    default:
                        SetMessage("Error type unknown on server");
                        break;
                }
                //TODO handle this exception return;
                return false;
            }
        }