public void GetListingTest() { DeviceData device = new DeviceData() { Serial = "169.254.109.177:5555", State = DeviceState.Online }; List<FileStatistics> value = null; this.RunTest( OkResponses(2), ResponseMessages(".", "..", "sdcard0", "emulated"), Requests("host:transport:169.254.109.177:5555", "sync:"), SyncRequests(SyncCommand.LIST, "/storage"), new SyncCommand[] { SyncCommand.DENT, SyncCommand.DENT, SyncCommand.DENT, SyncCommand.DENT, SyncCommand.DONE }, new byte[][] { new byte[] { 233, 65, 0, 0, 0, 0, 0, 0, 152, 130, 56, 86 }, new byte[] { 237, 65, 0, 0, 0, 0, 0, 0, 152, 130, 56, 86 }, new byte[] { 255, 161, 0, 0, 24, 0, 0, 0, 152, 130, 56, 86 }, new byte[] { 109, 65, 0, 0, 0, 0, 0, 0, 152, 130, 56, 86 } }, null, () => { using (SyncService service = new SyncService(device)) { value = service.GetDirectoryListing("/storage").ToList(); } }); Assert.AreEqual(4, value.Count); var time = new DateTime(2015, 11, 3, 9, 47, 4, DateTimeKind.Utc).ToLocalTime(); var dir = value[0]; Assert.AreEqual(".", dir.Path); Assert.AreEqual((UnixFileMode)16873, dir.FileMode); Assert.AreEqual(0, dir.Size); Assert.AreEqual(time, dir.Time); var parentDir = value[1]; Assert.AreEqual("..", parentDir.Path); Assert.AreEqual((UnixFileMode)16877, parentDir.FileMode); Assert.AreEqual(0, parentDir.Size); Assert.AreEqual(time, parentDir.Time); var sdcard0 = value[2]; Assert.AreEqual("sdcard0", sdcard0.Path); Assert.AreEqual((UnixFileMode)41471, sdcard0.FileMode); Assert.AreEqual(24, sdcard0.Size); Assert.AreEqual(time, sdcard0.Time); var emulated = value[3]; Assert.AreEqual("emulated", emulated.Path); Assert.AreEqual((UnixFileMode)16749, emulated.FileMode); Assert.AreEqual(0, emulated.Size); Assert.AreEqual(time, emulated.Time); }
public frmSetting() { InitializeComponent(); _settingService = new Service.SettingService(); _storeService = new Service.StoreService(); _service = new SyncService(AppContext.Log); _cmdService = new Service.CommandService(); }
public MainWindow() { DataContext = new GridSize(); var loginWindow = new LoginWindow(); if (loginWindow.ShowDialog() == true) { InitializeComponent(); GridStock.ItemsSource = _stocks; BtnRoles.Visibility = !RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactRole) ? Visibility.Collapsed : Visibility.Visible; BtnUsers.Visibility = !RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactUser) ? Visibility.Collapsed : Visibility.Visible; BtnTva.Visibility = !RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactTva) ? Visibility.Collapsed : Visibility.Visible; BtnGroupsProduct.Visibility = !RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactGroupsProduct) ? Visibility.Collapsed : Visibility.Visible; BtnSyncSettings.Visibility = !RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactSyncSettings) ? Visibility.Collapsed : Visibility.Visible; SyncService.SyncAll(Dispatcher.CurrentDispatcher); GridLoad("b", ClassGridGroup.Grid); GridLoad("a", ClassGridGroup.GridLeft); GridLoad("e", ClassGridGroup.GridRigthBottom); Loaded += MainWindowLoaded; InkInputHelper.DisableWpfTabletSupport(); var langMenu = MenuLanguage.ContextMenu.Items.Cast <MenuItem>().FirstOrDefault(m => m.Tag.ToString() == Config.Language); if (langMenu != null) { langMenu.IsChecked = true; } else { DefoultLangMenu.IsChecked = true; } } else { Close(); } }
public override void Load() { // ViewModels //Bind<SignInViewModel>().ToSelf(); Bind <MainViewModel>().ToSelf(); Bind <WorkoutDetailViewModel>().ToSelf(); Bind <NewWorkoutViewModel>().ToSelf(); Bind <NewExerciseViewModel>().ToSelf(); Bind <LandingViewModel>().ToSelf(); Bind <SignupViewModel>().ToSelf(); Bind <UserDetailViewModel>().ToSelf(); //var baseUrl = "https://jcmfitnessapi.herokuapp.com"; var baseUrl = "https://jcmfitness1.azurewebsites.net"; //var apiAuthToken = Preferences.Get("apitoken", ""); var settings = new RefitSettings(new NewtonsoftJsonContentSerializer()); JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = { new StringEnumConverter() } }; IFitApi refitInstance = RestService.For <IFitApi>(baseUrl, settings); var tripLogService = new FitnessService(refitInstance); var localDBService = new LocalDatabase(); var SyncService = new SyncService(tripLogService, localDBService); /*var fitApiService = new IFitApi(); * * containerBuilder.RegisterInstance(refitInstance) * .As<IFitApi>();*/ Bind <Akavache.IBlobCache>().ToConstant(Akavache.BlobCache.LocalMachine); //Bind<IAuthService>().To<AuthService>().InSingletonScope(); Bind <IFitnessService>() .ToMethod(x => tripLogService) .InSingletonScope(); Bind <ILocalDatabase>() .ToMethod(x => localDBService) .InSingletonScope(); Bind <ISyncService>() .ToMethod(x => SyncService) .InSingletonScope(); }
public void TestAddingHighlights() { var ss = new SyncService(EudicAPIKey, EudicDomain, EudicRetrieveEndpointPath, ReadWiseAPIToken, ReadWiseDomain, ReadWiseAddHighlightsEndpointPath); var testwords = new string[] { "test2", "test3" }; var results = ss.AddHighlights(testwords); Assert.IsFalse(string.IsNullOrEmpty(results)); }
public static void XmlToDbSaveD(XDocument x) { var infoClientsCustomerId = ModePro ? Pro.CustomerId : new Guid("87da7ba2-5e52-4d31-8def-5a2dad508e94"); var di = new DevisIdType(-1, DateTime.Now, false, infoClientsCustomerId, 0); var products = x.GetXElements("check", "product"); var p = new List <XElement>(); foreach (var product in products) { var pf = p.Find(l => (l.GetXElementValue("CustomerId") == product.GetXElementValue("CustomerId"))); if (pf == null || (pf.GetXElementValue("price") != product.GetXElementValue("price"))) { p.Add(product); } else { var qty = pf.GetXElementValue("qty").ToDecimal(); var qty1 = product.GetXElementValue("qty").ToDecimal(); var total = pf.GetXElementValue("total").ToDecimal(); var total1 = product.GetXElementValue("total").ToDecimal(); pf.GetXElement("qty").SetValue(qty + qty1); pf.GetXElement("total").SetValue(total + total1); } } x.GetXElements("check", "product").Remove(); di.DivisWebs = new List <DevisWebType>(); foreach (var product in p) { x.GetXElement("check").Add(product); var prixHt = Math.Round(product.GetXElementValue("price").ToDecimal(), 2); var tva = RepositoryTva.GetById(product.GetXElementValue("tva").ToInt()); var tva1 = PrixTtcOnlyTva(product.GetXElementValue("price").ToDecimal(), tva); var monPrixHt = product.GetXElementValue("contenance").ToDecimal(); var qty = product.GetXElementValue("qty").ToDecimal(); var prixHtValue = prixHt - tva1; var dw = new DevisWebType(Guid.NewGuid(), -1, prixHtValue, monPrixHt == 0 ? 1 : monPrixHt, qty, qty * prixHtValue, 0, true, product.GetXElementValue("CustomerId").ToGuid(), di.InfoClientsCustomerId ?? Guid.Empty); var cusumerIdRealStock = Guid.Parse(product.GetXElementValue("cusumerIdRealStock").Replace('.', ',')); RepositoryStockReal.AddProductCount(-dw.Qty, cusumerIdRealStock); RepositoryStockReal.UpdateProductCountByEstablishment(dw.Qty, Config.IdEstablishmentGros, dw.ProductsCustomerId); di.DivisWebs.Add(dw); } di.Total = di.DivisWebs.Sum(l => l.TotalHt); SyncService.InsDevis(di); FileMove(); }
public JsonResult GetLogonSecretID() { var svSync = new SyncService(); var username = "******"; var password = "******"; var webid = "1"; var secretid = svSync.GetSecretID(username, password, webid); return(Json(secretid)); }
private void UploadFile(string srcFilePath, string targetFilePath, int permissions = 444) { var device = AdbClient.Instance.GetDevices().First(); using (SyncService service = new SyncService(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)), device)) using (Stream stream = File.OpenRead(srcFilePath)) { service.Push(stream, targetFilePath, permissions, DateTime.Now, null, CancellationToken.None); } }
private void DownloadFile(string remoteFilePath, string localPath) { var device = AdbClient.Instance.GetDevices().First(); using (SyncService service = new SyncService(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)), device)) using (Stream stream = File.OpenWrite(localPath)) { service.Pull(remoteFilePath, stream, null, CancellationToken.None); } }
public App() { SQLiteRepository.Init(); RestService.Init(); SyncService.Init(); InitializeComponent(); MainPage = new MainPage(); }
void UploadFile() { var device = AdbClient.Instance.GetDevices().First(); using (SyncService service = new SyncService(AdbSocket, device)) using (Stream stream = File.OpenRead(@"C:\MyFile.txt")) { service.Push(stream, "/data/MyFile.txt", 0777, DateTime.Now, new FileUpDownProgress <int>(), CancellationToken.None); } }
private void OnAppCrashInterpreter() { var request = new BaseInterpreterApiRequest() { CallId = ActiveCallRequest.CallId }; var syncService = new SyncService(); syncService.Post(PauseCallInterpreterAPI, request); }
private void OnAppCrashClient() { var request = new CancelCallRequestModel() { CallId = ActiveCallRequest.CallId }; var syncService = new SyncService(); syncService.Post(CancelCallClientAPI, request); }
public static void OnAddLike(dynamic message, SyncService s, SyncRoom room) { var res = new { CommandType = CommandType.UPDATELIKES.Value, Likes = room.AddLike() }; room.Broadcast(JsonConvert.SerializeObject(res)); }
public static void CreationTime(string Server) { using (SyncService service = new SyncService(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)), device)) using (Stream stream = File.OpenWrite(GlobalVar.Client.Paths.TransfersPath)) { service.Pull($"/data/data/com.quattroplay.Graal{Server}/files/creationtime.dat", stream, null, CancellationToken.None); DateTime Date = DateTime.Now; FileSystem.RenameFile($"{GlobalVar.Client.Paths.TransfersPath}creationtime.so", $"CreationTime({Date.Day}-{Date.Month}-{Date.Year})({Date.Hour}-{Date.Minute}).so"); } }
public void Setup() { _user = new User { ObjectId = Guid.NewGuid().ToString() }; _service1 = Substitute.For <ISyncService>(); _service2 = Substitute.For <ISyncService>(); _persistenceContextFactory = Substitute.For <IPersistenceContextFactory>(); _syncService = new SyncService(_persistenceContextFactory, new [] { _service1, _service2 }); }
private static void RemoveFilePermanently(File fileToRemove) { if (fileToRemove != null) { SyncService.RemoveFile(fileToRemove.SyncpointId, fileToRemove.LatestVersionId, removePermanently: false); SyncService.RemoveFile(fileToRemove.SyncpointId, fileToRemove.LatestVersionId, removePermanently: true); return; } Console.WriteLine("No file to remove."); }
public void Init(SyncService service, IServerConfig config) { m_service = service; m_service.OnSessionCreate += OnSessionCreate; m_service.OnSessionClose += OnSessionClose; m_service.OnPlayerLogin += OnPlayerLogin; m_service.OnPlayerLogout += OnPlayerLogout; OnInit(config); }
private void UploadFile() { var device = AdbClient.Instance.GetDevices().First(); using (var service = new SyncService(device)) using (Stream stream = File.OpenRead(ApkTools.fullfilename)) { service.Push(stream, "/storage/extSdCard/MyFile.apk", 644, DateTime.Now, null, CancellationToken.None); } }
public void Send() { var device = AdbClient.Instance.GetDevices().Single(); using (SyncService service = new SyncService(device)) using (Stream stream = File.OpenRead(filename)) { service.MaxBufferSize = this.BufferSizeInBytes; service.Push(stream, "/data/local/tmp/file.bin", 666, DateTime.Now, null, CancellationToken.None); } }
protected override async Task LoadAsync() { await SetupTask; if (Element == default) { Element = await SyncService.GetElementByIdAsync <T> (this.id); ModifiedElement = Element; } }
private static void RemoveFolderPermanently(long syncpointId, long folderId) { if (_currentFolder != null) { SyncService.RemoveFolder(syncpointId, folderId, removePermanently: false); SyncService.RemoveFolder(syncpointId, folderId, removePermanently: true); return; } Console.WriteLine("No folder to remove."); }
public void Init(SyncService service) { m_service = service; m_service.OnSessionCreate += OnSessionCreate; m_service.OnSessionClose += OnSessionClose; m_service.OnPlayerLogin += OnPlayerLogin; m_service.OnPlayerLogout += OnPlayerLogout; OnInit(); }
void _backWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = (BackgroundWorker)sender; worker.ReportProgress(50); SyncService _syncService = new SyncService(AppContext.Log); _syncService.LoadDataByName(); worker.ReportProgress(100); System.Threading.Thread.Sleep(500); }
public void UploadScript(string path) { var adb = new AdbClient(AdbServer.Instance.EndPoint); adb.ExecuteRemoteCommand("rm -rf /sdcard/TouchSprite/lua/*", Device, this); var sync = new SyncService(Device); var info = new FileInfo(path); sync.Push( File.OpenRead(info.FullName), "/sdcard/TouchSprite/lua/" + System.Web.HttpUtility.UrlEncode(info.Name), 777, DateTime.Now, CancellationToken.None ); }
public async Task EnableServiceAsync(IService service) { if (service is null) { throw new ArgumentNullException(nameof(service)); } PlaySpaceElement space = SelectedElement; string serviceName = service.GetType().GetSimpleTypeName(); if (service is IPairedService pairedService) { var msg = new PairServiceMessage(pairedService); Messenger.Default.Send(msg); if (msg.Result == null) { throw new OperationCanceledException(); } var servicePairings = space.Pairings?.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList <PairedDevice>) new List <PairedDevice> (kvp.Value)) ?? new Dictionary <string, IReadOnlyList <PairedDevice> >(); if (!servicePairings.TryGetValue(serviceName, out var pairings)) { servicePairings[serviceName] = pairings = new List <PairedDevice> (); } var pairing = await msg.Result; ((List <PairedDevice>)pairings).Add(new PairedDevice { Id = pairing.Item1.Id, Pair = pairing.Item2 }); space = space with { Pairings = servicePairings }; } // Paired services may ask user to enable if their only paired devices aren't present, but we don't need to re-add the service if (!space.Services.Contains(serviceName)) { var services = new List <string> (space.Services.Count + 1); services.AddRange(space.Services); services.Add(serviceName); space = space with { Services = services }; } await SyncService.SaveElementAsync(space); await Loading; }
protected override void FixtureSetup() { base.FixtureSetup(); // RoleEnvironment AzureRoleEnvironment.DeploymentId = () => "DEPLOYMENTID"; AzureRoleEnvironment.CurrentRoleInstanceId = () => "ROLEINSTANCEID"; // File Resource Paths var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "")); _sitePath = Path.Combine(basePath, "Sites"); _tempPath = Path.Combine(basePath, "Temp"); _configPath = Path.Combine(basePath, "Config"); _resourcesPath = Path.Combine(basePath, "_resources"); Directory.CreateDirectory(_sitePath); Directory.CreateDirectory(_tempPath); Directory.CreateDirectory(_configPath); // Website Repository var factory = new AzureStorageFactory(CloudStorageAccount.DevelopmentStorageAccount); _repo = new WebSiteRepository(factory); _webSiteTable = factory.GetTable <WebSiteRow>(typeof(WebSiteRow).Name); _bindingTable = factory.GetTable <BindingRow>(typeof(BindingRow).Name); // Clean up IIS and table storage to prepare for test using (var serverManager = new ServerManager()) { _excludedSites = new List <string>(); using (var manager = new ServerManager()) { manager.Sites.Where(s => s.Name != AzureRoleEnvironment.RoleWebsiteName()).ToList().ForEach(s => _excludedSites.Add(s.Name)); } CleanupWebsiteTest(serverManager); } // Sync Service _syncService = new SyncService( _repo, new SyncStatusRepository(factory), CloudStorageAccount.DevelopmentStorageAccount, _sitePath, _tempPath, new string[] { }, _excludedSites, () => true, new IISManager(_sitePath, _tempPath, new SyncStatusRepository(factory), new ConsoleFactory(), LoggerLevel.Debug), new ConsoleFactory(), LoggerLevel.Debug ); }
public frmDownload() { InitializeComponent(); _syncService = new SyncService(AppContext.Log); _backWorker = new BackgroundWorker(); _backWorker.DoWork += _backWorker_DoWork; _backWorker.ProgressChanged += _backWorker_ProgressChanged; _backWorker.RunWorkerCompleted += _backWorker_RunWorkerCompleted; _backWorker.WorkerReportsProgress = true; this.lblMsg.Text = "下载数据,大约持续1分钟,请耐心等待..."; }
public FileStream Pull(string remotePath) { File.Delete("./pull.log"); remotePath = $"/sdcard/Android/data/{GlobalData.Instance.AndroidPackageName}/files/{remotePath}"; var service = new SyncService(m_client, m_deviceData); var stream = new FileStream("./pull.log", FileMode.Create); service.Pull(remotePath, stream, null, CancellationToken.None); service.Dispose(); stream.Seek(0, SeekOrigin.Begin); service.Dispose(); return(stream); }
public MainPage(IDataStore <StudentModel> dataStore) : base() { InitializeComponent(); _dataStore = dataStore; _studentRepository = new StudentRepository(_dataStore); _studentService = new StudentService(_studentRepository); _syncService = new SyncService(_studentService); _dataCollectionController = new DataCollectionController(_studentService); Title = "SignUp"; }
private void ADBImg() { using (SyncService service = new SyncService(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)), data)) if (File.Exists(Application.StartupPath + @"\screentemp.png")) { ShellCommand("screencap /sdcard/screentemp.png"); using (Stream stream = File.OpenWrite(Application.StartupPath + @"\screentemp.png")) { service.Pull("/sdcard/screentemp.png", stream, null, CancellationToken.None); } img = Image.FromFile(Application.StartupPath + @"\screentemp.png"); } }
public void WhenGetItems_ShouldReturnOneItem() { var sourceProvider = new Mock<ICalendarProvider>(); var destinationProvider = new Mock<ICalendarProvider>(); destinationProvider .Setup(p => p.GetCalendarEvents(It.IsAny<DateTime>(), It.IsAny<DateTime>())) .Returns(new List<CalendarEvent>() { new OutlookCalendarEvent() }); SyncService service = new SyncService(sourceProvider.Object, destinationProvider.Object); IEnumerable<CalendarEvent> calendarEvents = service.GetDestinationCalendarItems(); calendarEvents.Count().Should().BeGreaterThan(0); }
public void WhenGetItems_ShouldMatchValue() { var sourceProvider = new Mock<ICalendarProvider>(); var destinationProvider = new Mock<ICalendarProvider>(); destinationProvider .Setup(p => p.GetCalendarEvents(It.IsAny<DateTime>(), It.IsAny<DateTime>())) .Returns(new List<CalendarEvent>() { new OutlookCalendarEvent() { DateFrom = new DateTime(2015, 12, 1), DateTo = new DateTime(2015, 12, 2), Title = "Birthday Leave", Location = "TBA", Description = "Bring your own food" } }); SyncService service = new SyncService(sourceProvider.Object, destinationProvider.Object); IEnumerable<CalendarEvent> calendarEvents = service.GetDestinationCalendarItems(); var expected = new OutlookCalendarEvent() { DateFrom = new DateTime(2015, 12, 1), DateTo = new DateTime(2015, 12, 2), Title = "Birthday Leave", Location = "TBA", Description = "Bring your own food" }; var calendarEvent = calendarEvents.First(); calendarEvent.ShouldBeEquivalentTo(expected); }
public void WhenGetNewItems_ShouldReturnItem() { var sourceProvider = new Mock<ICalendarProvider>(); sourceProvider .Setup(p => p.GetCalendarEvents(It.IsAny<DateTime>(), It.IsAny<DateTime>())) .Returns(new List<CalendarEvent>() { new OutlookCalendarEvent() }); var destinationProvider = new Mock<ICalendarProvider>(); SyncService service = new SyncService(sourceProvider.Object, destinationProvider.Object); var events = service.GetNewCalendarItems(); events.Count().Should().Be(1); }
public void PullTest() { DeviceData device = new DeviceData() { Serial = "169.254.109.177:5555", State = DeviceState.Online }; MemoryStream stream = new MemoryStream(); var content = File.ReadAllBytes("fstab.bin"); this.RunTest( OkResponses(2), ResponseMessages(), Requests("host:transport:169.254.109.177:5555", "sync:"), SyncRequests(SyncCommand.RECV, "/fstab.donatello"), new SyncCommand[] { SyncCommand.DATA, SyncCommand.DONE }, new byte[][] { new byte[] {85, 2, 0, 0}, content }, null, () => { using (SyncService service = new SyncService(this.Socket, device)) { service.Pull("/fstab.donatello", stream, null, CancellationToken.None); } }); // Make sure the data that has been sent to the stream is the expected data CollectionAssert.AreEqual(content, stream.ToArray()); }
public void StatTest() { DeviceData device = new DeviceData() { Serial = "169.254.109.177:5555", State = DeviceState.Online }; FileStatistics value = null; this.RunTest( OkResponses(2), NoResponseMessages, Requests("host:transport:169.254.109.177:5555", "sync:"), SyncRequests(SyncCommand.STAT, "/fstab.donatello"), new SyncCommand[] { SyncCommand.STAT }, new byte[][] { new byte[] { 160, 129, 0, 0, 85, 2, 0, 0, 0, 0, 0, 0 } }, null, () => { using (SyncService service = new SyncService(this.Socket, device)) { value = service.Stat("/fstab.donatello"); } }); Assert.IsNotNull(value); Assert.AreEqual(UnixFileMode.Regular, value.FileMode & UnixFileMode.TypeMask); Assert.AreEqual(597, value.Size); Assert.AreEqual(DateTimeHelper.Epoch.ToLocalTime(), value.Time); }
public void PushTest() { DeviceData device = new DeviceData() { Serial = "169.254.109.177:5555", State = DeviceState.Online }; Stream stream = File.OpenRead("fstab.bin"); var content = File.ReadAllBytes("fstab.bin"); this.RunTest( OkResponses(2), ResponseMessages(), Requests("host:transport:169.254.109.177:5555", "sync:"), SyncRequests( SyncCommand.SEND, "/sdcard/test,644", SyncCommand.DATA, content.Length.ToString(), SyncCommand.DONE, "1446505200"), new SyncCommand[] { SyncCommand.OKAY }, null, new byte[][] { content }, () => { using (SyncService service = new SyncService(this.Socket, device)) { service.Push(stream, "/sdcard/test", 0644, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc), null, CancellationToken.None); } }); }