Example #1
0
        /// <summary>
        /// Check the files from the current cached and list the files that has
        /// differences
        /// </summary>
        /// <param name="prj">The current project</param>
        private void CheckFiles(Project prj)
        {
            String msg = null;

            if ((prj.Data.Map.Files.Count() > 0 || prj.Data.Map.Directories.Count() > 0) && AuraSftpClient.TestConnection(prj.Connection.Data, out msg))
            {
                this.PullFromServer(prj, false, true);
                List <MappedPath> files = new List <MappedPath>();
                foreach (var file in prj.Data.Map.Files)
                {
                    if (files.Count(x => x.ProjectCopy == file.ProjectCopy) == 0)
                    {
                        files.Add(file);
                    }
                }
                foreach (var dir in prj.Data.Map.Directories)
                {
                    this.GetPaths(ref files, new DirectoryInfo(dir.ProjectCopy), prj, dir);
                }
                diff_match_patch dmp = new diff_match_patch();
                //Only uploads files with diff
                String[] cExt = Program.Settings.ComparableFilesExt;
                Boolean  isComparable;
                var      filesToUpload = files.Where(x =>
                {
                    isComparable = x.ProjectCopy.IsComparable(cExt);
                    return(!isComparable || (isComparable && !dmp.AreFilesEquals(x.ProjectCopy, x.ServerCopy)));
                });
                if (filesToUpload.Count() > 0)
                {
                    Console.WriteLine(MSG_INF_FILES_WITH_CHANGES);
                    filesToUpload.ToList().ForEach(x =>
                                                   Console.WriteLine(x.ProjectCopy));
                }
                else
                {
                    Console.WriteLine(MSG_INF_PRJ_NO_CHANGES);
                }
            }
            else
            {
                Console.WriteLine(msg == null ? MSG_INF_PRJ_NO_CHANGES : msg);
            }
        }
Example #2
0
 /// <summary>
 /// Push the files to the server only the mapped files are push to the server
 /// </summary>
 /// <param name="prj">The current project</param>
 /// <param name="silentMode">if true push changes without confirmation</param>
 private void PushToServer(Project prj, Boolean silentMode = false)
 {
     if (prj.Data.Map.Files.Count() > 0 || prj.Data.Map.Directories.Count() > 0)
     {
         List <MappedPath> files = new List <MappedPath>();
         foreach (var file in prj.Data.Map.Files)
         {
             if (files.Count(x => x.GetFullProjectCopy() == file.GetFullProjectCopy()) == 0)
             {
                 files.Add(file);
             }
         }
         foreach (var dir in prj.Data.Map.Directories)
         {
             this.GetPaths(ref files, new DirectoryInfo(dir.GetFullProjectCopy()), prj, dir);
         }
         diff_match_patch dmp = new diff_match_patch();
         //Only uploads files with diff
         String[] cExt = Program.Settings.ComparableFilesExt;
         Boolean  isComparable;
         var      filesToUpload = files.Where(x =>
         {
             isComparable = x.GetFullProjectCopy().IsComparable(cExt);
             return(isComparable && !dmp.AreFilesEquals(x.GetFullProjectCopy(), x.GetFullServerCopy() + ".copy"));
         }).ToArray();
         if (filesToUpload.Length > 0)
         {
             SftpUtils.UploadFiles(filesToUpload, prj, silentMode);
         }
         else
         {
             Console.WriteLine(MSG_INF_PRJ_PUSH_NO_CHANGES);
         }
     }
     else
     {
         throw new Exception(MSG_ERR_PRJ_PULL_EMPTY_MAP);
     }
 }