예제 #1
0
        public ActionResult AllUpdates()
        {
            var allUpdates = SandboxContentProviderHost.CurrentProvider.AllUpdates(GetUserToken());
            var zipFile    = new ZipFile();

            foreach (var update in allUpdates)
            {
                // build the CachePwn json for this weenie
                var weenie = SandboxContentProviderHost.CurrentProvider.GetWeenie(GetUserToken(), update.WeenieClassId);
                // var cachePwn = Weenie.ConvertFromWeenie(weenie);
                var settings = new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                };
                var contents = JsonConvert.SerializeObject(weenie, Formatting.None, settings);

                // build filename
                var name        = weenie.Name;
                var removeChars = new List <string>()
                {
                    "\t", "\n", "!", "\""
                };
                foreach (var removeChar in removeChars)
                {
                    name = name.Replace(removeChar, "");
                }

                var filename = $"{update.WeenieClassId} - {name}.json";

                // add json to zip file
                zipFile.AddFile(filename, contents);
            }

            var    bytes = zipFile.BuildZip();
            string date  = string.Format("{0:yyyy-MM-dd_hh-mm}", DateTime.Now);

            return(File(bytes, "application/zip", "GDLE-Latest-Updates-" + date + ".zip"));
        }