Esempio n. 1
0
        public void DoSync(int serverType)
        {
            var syncInfo = GetSyncInfo();

            if (syncInfo == null)
            {
                throw new Exception("无法获取到同步信息的 json");
            }

            //判断是调用ClientSync.cs  ServerSync.cs
            var sync = new SyncFactory().GetInstance(serverType);

            syncInfo = sync.Import(syncInfo);

            //从U盘到客户端服务器
            if (serverType == 2 && syncInfo.ClientWriteSuccess)
            {
                string webAppDir = Utils.GetWebAppDir();
                Utils.CopyNewFiles(syncInfo.PathList, USBFilePath, webAppDir);
            }

            //从服务器下载到U盘
            var newSyncInfo = sync.Export(syncInfo);

            if (serverType == 1 && newSyncInfo.PathList.Any())
            {
                string webAppDir = Utils.GetServerUrl();
                Utils.CopyNewFiles(newSyncInfo.PathList, webAppDir, USBFilePath);
            }

            ClearData(syncInfo);
            WriteSyncInfo(newSyncInfo);
        }
Esempio n. 2
0
        public void DoSync(int serverType, string webAppDir)
        {
            var syncInfo = GetSyncInfo();

            if (syncInfo == null)
            {
                throw new Exception("无法获取到同步信息的 json");
            }

            var sync = new SyncFactory().GetInstance(serverType);

            syncInfo = sync.Import(syncInfo);

            if (serverType == 2 && syncInfo.ClientWriteSuccess)
            {
                Utils.CopyNewFiles(syncInfo.PathList, USBFilePath, webAppDir);
            }

            var newSyncInfo = sync.Export(syncInfo);

            if (serverType == 1 && newSyncInfo.PathList.Any())
            {
                Utils.CopyNewFiles(newSyncInfo.PathList, webAppDir, USBFilePath);
            }

            ClearData(syncInfo);
            WriteSyncInfo(newSyncInfo);
        }