Example #1
0
        public ShareType DecideShareType(FolderInformation folderInfo, SrmDocument document)
        {
            ShareType shareType = ShareType.DEFAULT;

            var settings = document.Settings;

            Assume.IsTrue(document.IsLoaded);
            var cacheVersion = settings.HasResults ? settings.MeasuredResults.CacheVersion : null;

            if (!cacheVersion.HasValue)
            {
                // The document may not have any chromatogram data.
                return(shareType);
            }

            CacheFormatVersion supportedVersion = GetSupportedSkydVersion(folderInfo);

            if (supportedVersion >= cacheVersion.Value)
            {
                return(shareType);
            }
            var skylineVersion = SkylineVersion.SupportedForSharing().FirstOrDefault(ver => ver.CacheFormatVersion <= supportedVersion);

            if (skylineVersion == null)
            {
                throw new PanoramaServerException(string.Format(
                                                      Resources.PublishDocumentDlg_ServerSupportsSkydVersion_, (int)cacheVersion.Value));
            }
            return(shareType.ChangeSkylineVersion(skylineVersion));
        }
Example #2
0
        public CacheFormatVersion GetSupportedSkydVersion(FolderInformation folderInfo)
        {
            var serverVersionsJson = SupportedVersionsJson(folderInfo.Server);

            if (serverVersionsJson == null)
            {
                // There was an error getting the server-supported skyd version for some reason.
                // Perhaps this is an older server that did not understand the request, or
                // the returned JSON was malformed. Let the document upload continue.
                return(CacheFormatVersion.CURRENT);
            }

            JToken serverSkydVersion;

            if (serverVersionsJson.TryGetValue(@"SKYD_version", out serverSkydVersion))
            {
                int version;
                if (int.TryParse(serverSkydVersion.Value <string>(), out version))
                {
                    return((CacheFormatVersion)version);
                }
            }

            return(CacheFormatVersion.CURRENT);
        }
Example #3
0
        public bool ServerSupportsSkydVersion(FolderInformation folderInfo, IDocumentUIContainer _docContainer, IWin32Window parent)
        {
            var settings = _docContainer.DocumentUI.Settings;

            Assume.IsTrue(_docContainer.DocumentUI.IsLoaded);
            var cacheVersion = settings.HasResults ? settings.MeasuredResults.CacheVersion : null;

            if (cacheVersion == null)
            {
                // The document may not have any chromatogram data.
                return(true);
            }

            var serverVersionsJson = SupportedVersionsJson(folderInfo.Server);

            if (serverVersionsJson == null)
            {
                // There was an error getting the server-supported skyd version for some reason.
                // Perhaps this is an older server that did not understand the request, or
                // the returned JSON was malformed. Let the document upload continue.
                return(true);
            }

            int?   serverVersion = null;
            JToken serverSkydVersion;

            if (serverVersionsJson.TryGetValue("SKYD_version", out serverSkydVersion)) // Not L10N
            {
                int version;
                if (int.TryParse(serverSkydVersion.Value <string>(), out version))
                {
                    serverVersion = version;
                }
            }

            if (serverVersion.HasValue && cacheVersion.Value > serverVersion.Value)
            {
                MessageDlg.Show(parent,
                                string.Format(
                                    Resources.PublishDocumentDlg_ServerSupportsSkydVersion_,
                                    cacheVersion.Value)
                                );
                return(false);
            }

            return(true);
        }