// Is the file changed.
        public bool CreateOrUpdated()
        {
            var mapfileContent = JsonConvert.SerializeObject(this.Mapfile);

            // If the file exist, read it and check and update.
            if (!File.Exists(this.filePath))
            {
                // if not exist create the file.
                // Update mapfile.
                MapfileHelper.Save(mapfileContent, this.filePath);
                return(true);
            }

            var oldMapfile = MapfileHelper.Read(this.filePath);

            if (oldMapfile != mapfileContent) //updated
            {
                DeleteUnusedFiles(oldMapfile, this.Mapfile);

                MapfileHelper.Save(mapfileContent, this.filePath);
                return(true);
            }

            return(false);
        }
        // Generate package's info for build old course structure.
        private void BuildPackageInfoFile(long mediaOriginalSize, long mediaZippedSize)
        {
            PackageInfo pi = new PackageInfo();

            pi.PackagePath = this.lessonName + ".zip";
            pi.Size        = mediaOriginalSize;
            pi.ZippedSize  = mediaZippedSize;

            var mapfileContent = JsonConvert.SerializeObject(pi);

            // for every package alwasy use the same package name.
            // lesson_221.json
            var saveTo = this.constants.LocalMediaPath + @"\lesson_" + lesson.Id + ".pinfo";

            MapfileHelper.Save(mapfileContent, saveTo);
        }
Ejemplo n.º 3
0
        // Is the file changed.
        public bool CreateOrUpdated()
        {
            var mapfileContent = JsonConvert.SerializeObject(this.Mapfile);

            // If the file exist, read it and check and update.
            if (!File.Exists(this.filePath))
            {
                // if not exist create the file.
                // Update mapfile.
                MapfileHelper.Save(mapfileContent, this.filePath);
                return(true);
            }

            if (MapfileHelper.Read(this.filePath) != mapfileContent) //updated
            {
                MapfileHelper.Save(mapfileContent, this.filePath);
                return(true);
            }
            else
            {
                return(false);
            }
        }