Beispiel #1
0
        protected void progressBar_RunTask(object sender, ProgressTaskEventArgs e)
        {
            e.UpdateProgress(0);
            string pathToFileSync = ConfigurationManager.AppSettings["PathToFileSync"];

            //Process p = new Process();
            //p.StartInfo.File
            //Name = pathToFileSync + "Ecas.MakroFileSync.exe";
            //p.Start();

            String sql = "SELECT MVIPK_IP,  \n" +
                         "       MVIPK_IMGFOLDER,  \n" +
                         "       MVIPK_VIDEOFOLDER, \n" +
                         "       MVIPK_NUMETIENDA \n" +
                         "FROM MVIPKIOSKO";

            ArrayList kioskos = DBFunctions.RequestAsCollection(sql);

            e.UpdateProgress(1);

            int razonCambioKiosko = 98 / kioskos.Count;
            int razonCambio       = razonCambioKiosko / 9;
            int progActual        = 1;

            foreach (Hashtable kiosko in kioskos)
            {
                string host        = kiosko["MVIPK_IP"].ToString();
                string imageFolder = kiosko["MVIPK_IMGFOLDER"].ToString();
                string videoFolder = kiosko["MVIPK_VIDEOFOLDER"].ToString();
                string numTienda   = kiosko["MVIPK_NUMETIENDA"].ToString();

                e.UpdateProgress(progActual, String.Format("Sincronizando kiosko {0}...", host));

                try
                {
                    //FileSyncOperator.syncKioskoLinux(host, imageFolder, videoFolder, numTienda, e, progActual, razonCambio);
                    FileSyncOperator.syncKioskoWindows(host, imageFolder, videoFolder, numTienda, e, progActual, razonCambio);
                    divError.InnerText = "OK Fyle";
                }
                catch (Exception ex)
                {
                    e.UpdateProgress(progActual, String.Format(".{0}\n{1}", ex.Message, ex.InnerException));
                    divError.InnerText = ex.Message + " " + ex.InnerException;
                }

                progActual += razonCambioKiosko;
            }

            e.UpdateProgress(100, "Sincronización terminada!");

            Utils.MostrarAlerta(Response, "Sincronización completada!");
            //Response.Redirect("" + ajaxIndexPage + "?process=FileSync.FileManager&sync=1");
        }
Beispiel #2
0
        public static void syncKioskoLinux(string host, string imageFolder, string videoFolder, string numTienda,
                                           ProgressTaskEventArgs e, int progActual, int razonCambio)
        {
            SshExec exec;
            SshTransferProtocolBase sshCp;

            exec           = new SshExec(host, kioskoUser);
            sshCp          = new Sftp(host, kioskoUser);
            exec.Password  = kioskoPass;
            sshCp.Password = kioskoPass;

            progActual += razonCambio;
            exec.Connect();
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            sshCp.Connect();
            e.UpdateProgress(progActual);

            string imageLocalPath = String.Format("{0}{1}", kioskoRepository, imageFolder);
            string videoLocalPath = String.Format("{0}{1}", kioskoRepository, videoFolder);
            string xmlLocalPath   = String.Format("{0}{1}", pathToTemp, "kioskoXML");

            OneWayFolderSyncSSH imageSync = new OneWayFolderSyncSSH(exec, sshCp, imageLocalPath, kioskoPathToImages);
            OneWayFolderSyncSSH videoSync = new OneWayFolderSyncSSH(exec, sshCp, videoLocalPath, kioskoPathToVideos);
            OneWayFolderSyncSSH xmlSync   = new OneWayFolderSyncSSH(exec, sshCp, xmlLocalPath, kioskoPathToXML);
            XmlKioskoLinux      xmlKiosko = new XmlKioskoLinux(kioskoPathToImages, kioskoPathToVideos, pathToTemp, numTienda, exec);

            progActual += razonCambio * 2;
            imageSync.syncFiles("*.jpg");
            e.UpdateProgress(progActual);

            progActual += razonCambio * 2;
            videoSync.syncFiles("*.flv");
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            xmlKiosko.generateServerXML(host);
            xmlKiosko.generateImageXML();
            xmlKiosko.generateVideoXML();
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            xmlSync.syncFiles("*.xml");
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            exec.Close();
            sshCp.Close();
            e.UpdateProgress(progActual);
        }
Beispiel #3
0
        public static void syncKioskoWindows(string host, string imageFolder, string videoFolder, string numTienda,
                                             ProgressTaskEventArgs e, int progActual, int razonCambio)
        {
            string imageLocalPath = String.Format("{0}{1}", kioskoRepository, imageFolder);
            string videoLocalPath = String.Format("{0}{1}", kioskoRepository, videoFolder);
            string xmlLocalPath   = String.Format("{0}{1}", pathToTemp, "kioskoXML\\");

            string imageKioskoPath = String.Format("\\\\{0}\\{1}", host, kioskoPathToImages);
            string videoKioskoPath = String.Format("\\\\{0}\\{1}", host, kioskoPathToVideos);
            string xmlKioskoPath   = String.Format("\\\\{0}\\{1}", host, kioskoPathToXML);

            XmlKioskoWindows xmlKiosko = new XmlKioskoWindows(imageKioskoPath, videoKioskoPath, xmlLocalPath, numTienda);

            try
            {
                FileSyncOptions options =
                    FileSyncOptions.ExplicitDetectChanges |
                    FileSyncOptions.RecycleDeletedFiles |
                    FileSyncOptions.RecyclePreviousFileOnUpdates |
                    FileSyncOptions.RecycleConflictLoserFiles;

                FileSyncScopeFilter filterImages = new FileSyncScopeFilter();
                filterImages.FileNameIncludes.Add("*.jpg");
                FileSyncScopeFilter filterVideos = new FileSyncScopeFilter();
                filterImages.FileNameIncludes.Add("*.flv");
                FileSyncScopeFilter filterXML = new FileSyncScopeFilter();
                filterImages.FileNameIncludes.Add("*.xml");

                DetectChangesOnFileSystemReplica(imageLocalPath, filterImages, options);
                DetectChangesOnFileSystemReplica(imageKioskoPath, filterImages, options);

                DetectChangesOnFileSystemReplica(videoLocalPath, filterImages, options);
                DetectChangesOnFileSystemReplica(videoKioskoPath, filterImages, options);

                progActual += razonCambio * 2;
                e.UpdateProgress(progActual);

                SyncFileSystemReplicasOneWay(imageLocalPath, imageKioskoPath, null, options);
                SyncFileSystemReplicasOneWay(imageKioskoPath, imageLocalPath, null, options);
                progActual += razonCambio * 2;
                e.UpdateProgress(progActual);

                SyncFileSystemReplicasOneWay(videoLocalPath, videoKioskoPath, null, options);
                SyncFileSystemReplicasOneWay(videoKioskoPath, videoLocalPath, null, options);
                progActual += razonCambio * 2;
                e.UpdateProgress(progActual);

                xmlKiosko.generateServerXML(host);
                xmlKiosko.generateImageXML();
                xmlKiosko.generateVideoXML();
                progActual += razonCambio;
                e.UpdateProgress(progActual);

                DetectChangesOnFileSystemReplica(xmlLocalPath, filterImages, options);
                DetectChangesOnFileSystemReplica(xmlKioskoPath, filterImages, options);

                SyncFileSystemReplicasOneWay(xmlLocalPath, xmlKioskoPath, null, options);
                SyncFileSystemReplicasOneWay(xmlKioskoPath, xmlLocalPath, null, options);
                progActual += razonCambio * 2;
                e.UpdateProgress(progActual);
            }
            catch (Exception ex)
            {
                e.UpdateProgress(progActual, String.Format(".{0}\n{1}", ex.Message, ex.InnerException));
            }
        }