コード例 #1
0
ファイル: Main.cs プロジェクト: rashoodkhan/Rainy
        public static void AddDummyUserIfRequired(Funq.Container container)
        {
            // create a dummy user
            var fac = container.Resolve<IDbConnectionFactory> ();
            using (var db = fac.OpenDbConnection ()) {

                if (db.FirstOrDefault<DBUser> (u => u.Username == "dummy") == null) {

                    var user = new DBUser ();
                    user.Username = "******";
                    user.CreateCryptoFields ("foobar123");
                    user.FirstName = "John Dummy";
                    user.LastName = "Doe";
                    user.AdditionalData  = "Dummy user that is created when in development mode";
                    user.IsActivated = true;
                    user.IsVerified = true;
                    user.Manifest.LastSyncRevision = 0;
                    user.EmailAddress = "*****@*****.**";
                    db.Insert<DBUser> (user);
                    // insert some sample notes
                    var f = container.Resolve<IDbStorageFactory> ();
                    var key = user.GetPlaintextMasterKey ("foobar123");
                    var r = new RequestingUser {
                        Username = "******",
                        EncryptionMasterKey = key.ToHexString ()
                    };
                    using (var storage = f.GetDbStorage (r)) {
                        var sample_notes = new DiskStorage ();
                        sample_notes.SetPath ("../../../sample_notes/");
                        sample_notes.CopyTo (storage);
                    }

                }
            }
        }
コード例 #2
0
ファイル: SampleServerTestBase.cs プロジェクト: BooTeK/Rainy
        public override void SetUp()
        {
            base.SetUp ();
            DTOUser user;
            List<DTONote> sample_notes;
            JsonServiceClient client = GetAdminServiceClient ();

            user = new DTOUser() {
                Username = "******",
                Password = "******",
                AdditionalData = "Its just john"
            };
            var user_url = new Rainy.WebService.Management.UserRequest ().ToUrl("POST");
            client.Post<DTOUser> (user_url, user);
            sampleUser.Add (user);

            // add sample notes
            sample_notes = AbstractSyncServerTests.GetSomeSampleNotes ()
                .Select (n => n.ToDTONote ()).ToList ();

            var syncServer = new WebSyncServer (testServer.RainyListenUrl, testServer.GetAccessToken ());

            var storage = new DiskStorage ();
            var tmpPath = "/tmp/sync1";
            storage.SetPath (tmpPath);
            var engine = new Engine (storage);
            var syncClient = new FilesystemSyncClient (engine, new SyncManifest ());

            var syncManager = new Tomboy.Sync.SyncManager (syncClient, syncServer);
            syncManager.DoSync ();

            sampleNotes[user.Username] = sample_notes;

            user = new DTOUser() {
                Username = "******",
                Password = "******",
                AdditionalData = "Jane, Johns wife"
            };
            client.Post<DTOUser> (user_url, user);
            sampleUser.Add (user);
            sampleNotes[user.Username] = AbstractSyncServerTests.GetSomeSampleNotes ()
                .Select (n => n.ToDTONote ()).ToList ();

            // add sample user data
        }