Ejemplo n.º 1
0
        private string tryGetWallpaperPreviewUrlForm(DateTime date)
        {
            if (retryCount >= 3)
            {
                getWallpaperPreviewFailed();
                return(null);
            }

            string formatString;

            try
            {
                formatString = GetRespondFromUrl(MotivateDesktopUtility.FormatAPIUrl + "?date=" + date.ToString("yyyy-M-d"));
            }
            catch
            {
                retryCount = 0;
                getWallpaperPreviewFailed();
                return(null);
            }
            formatString = formatString.Substring(0, formatString.IndexOf("[REQ_RESULT_END]"));
            switch (formatString.Split(':')[1])
            {
            case "JPG":
                retryCount      = 0;
                WallpaperDate   = date;
                WallpaperFormat = WallpaperFormats.JPG;
                return(MotivateDesktopUtility.ImgServerUrl + date.ToString("yyyy.M") + "/" + date.ToString("yyyy.M.d") + "_480x300.jpg");

            case "PNG":
                retryCount      = 0;
                WallpaperDate   = date;
                WallpaperFormat = WallpaperFormats.PNG;
                return(MotivateDesktopUtility.ImgServerUrl + date.ToString("yyyy.M") + "/" + date.ToString("yyyy.M.d") + "_480x300.png");

            case "MISSING":
                retryCount++;
                DateTime prevDate = date.AddDays(-1);
                return(tryGetWallpaperPreviewUrlForm(prevDate));

            default:
                retryCount = 0;
                getWallpaperPreviewFailed();
                return(null);
            }
        }
Ejemplo n.º 2
0
        private string tryGetWallpaperPreviewUrlForm(DateTime date)
        {
            if (retryCount >= 3)
            {
                getWallpaperPreviewFailed();
                return null;
            }

            string formatString;
            try
            {
                formatString = GetRespondFromUrl(MotivateDesktopUtility.FormatAPIUrl + "?date=" + date.ToString("yyyy-M-d"));
            }
            catch
            {
                retryCount = 0;
                getWallpaperPreviewFailed();
                return null;
            }
            formatString = formatString.Substring(0, formatString.IndexOf("[REQ_RESULT_END]"));
            switch (formatString.Split(':')[1])
            {
                case "JPG":
                    retryCount = 0;
                    WallpaperDate = date;
                    WallpaperFormat = WallpaperFormats.JPG;
                    return MotivateDesktopUtility.ImgServerUrl + date.ToString("yyyy.M") + "/" + date.ToString("yyyy.M.d") + "_480x300.jpg";
                case "PNG":
                    retryCount = 0;
                    WallpaperDate = date;
                    WallpaperFormat = WallpaperFormats.PNG;
                    return MotivateDesktopUtility.ImgServerUrl + date.ToString("yyyy.M") + "/" + date.ToString("yyyy.M.d") + "_480x300.png";
                case "MISSING":
                    retryCount++;
                    DateTime prevDate = date.AddDays(-1);
                    return tryGetWallpaperPreviewUrlForm(prevDate);
                default:
                    retryCount = 0;
                    getWallpaperPreviewFailed();
                    return null;
            }
        }