public static void Main(String[] args) { Thread.Sleep(1000); using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { Project p = new Project("SERVERTEST", new User("servertestuserman"), new List<User>()); //var derp = serviceClient.SyncAll(new List<Document>()); //List<Project> list = Storage.ServerGetAllProjects(); //List<SliceOfPie.Project> list = serviceClient.GetAllProjectsOnServer(); //var herp = serviceClient.GetHierachy("p663555625Crelde"); Project bool1 = serviceClient.StartSync(new User("Crelde"), "p663555625Crelde"); //Project fool2 = serviceClient.StartSync(new User("Creldz"), "p663555625Crelde"); //Project fool3 = serviceClient.StartSync(new User("Crelde"), "p3555625Crelde"); //Project bool4 = serviceClient.StartSync(new User("Motor-Bjarne"), "p663555625Crelde"); serviceClient.SendDocument(new Document("", "Document first", new User("Crelde"))); serviceClient.SendDocument(new Document("", "Document 2", new User("Crelde"))); serviceClient.SendDocument(new Document("", "Document third", new User("Crelde"))); serviceClient.SendDocument(new Document("", "4th document", new User("Crelde"))); serviceClient.SendDocument(new Document("", "half tenth doc", new User("Crelde"))); serviceClient.SendDocument(new Document("", "sexy doc", new User("Crelde"))); serviceClient.SendDocument(new Document("", "doc triple 7", new User("Crelde"))); Console.ReadKey(); } }
public static void Main(String[] args) { Thread.Sleep(1000); using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { Project p = new Project("SERVERTEST", new User("servertestuserman"), new List <User>()); //var derp = serviceClient.SyncAll(new List<Document>()); //List<Project> list = Storage.ServerGetAllProjects(); //List<SliceOfPie.Project> list = serviceClient.GetAllProjectsOnServer(); //var herp = serviceClient.GetHierachy("p663555625Crelde"); Project bool1 = serviceClient.StartSync(new User("Crelde"), "p663555625Crelde"); //Project fool2 = serviceClient.StartSync(new User("Creldz"), "p663555625Crelde"); //Project fool3 = serviceClient.StartSync(new User("Crelde"), "p3555625Crelde"); //Project bool4 = serviceClient.StartSync(new User("Motor-Bjarne"), "p663555625Crelde"); serviceClient.SendDocument(new Document("", "Document first", new User("Crelde"))); serviceClient.SendDocument(new Document("", "Document 2", new User("Crelde"))); serviceClient.SendDocument(new Document("", "Document third", new User("Crelde"))); serviceClient.SendDocument(new Document("", "4th document", new User("Crelde"))); serviceClient.SendDocument(new Document("", "half tenth doc", new User("Crelde"))); serviceClient.SendDocument(new Document("", "sexy doc", new User("Crelde"))); serviceClient.SendDocument(new Document("", "doc triple 7", new User("Crelde"))); Console.ReadKey(); } }
/** * Asks the server for a list of all the projects for this user */ public static List<Project> GetAllProjectsAvailable(User user) { List<Project> result; using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { result = serviceClient.GetAllProjectsOnServer(user); } return result; }
/** * Shares the changes the user have made in a project * to the server, and the server shares changes from other * users back. This synchronization is done through a series * of method calls to the server. */ public static void SyncWithServer(Project project, User user) { // Preparing transfer data // finding all modified documents to send List<DocumentStruct> docs = new List<DocumentStruct>(); Folder.GetAllStructs(project, docs); // fill up the list List<DocumentStruct> docsToSend = new List<DocumentStruct>(); foreach (DocumentStruct d in docs) { if (d.Modified) docsToSend.Add(d); } // Call the server using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { // Tell the server who we are and what project we want to sync Project newProj = serviceClient.StartSync(user, project.Id); // If null is returned, means that the project was deleted // or you've lost access to this project, so we delete it if (newProj == null) Controller.DeleteProject(project.Id); else { // Send all modified documents one at a time foreach (DocumentStruct d in docsToSend) { Document document = Controller.OpenDocument(project.Id, d.Id); serviceClient.SendDocument(document); if (document.Deleted) Controller.DeleteDocument(project.Id, document.Id); } // Keep getting new documents from server until there are none remaining while (true) { // Grab a new document from the server Document newDoc = serviceClient.GetUpdatedDocument(); // if null is returned, means that there are no new docs left if (newDoc == null) break; // Delete the old copy and write the new one instead Storage.DeleteDocument(project.Id, newDoc.Id); Storage.WriteToFile(newProj, newDoc, true); } // We're done syncing, close the session with the server serviceClient.StopSync(); } } }
/** * Asks the server for a list of all the projects for this user */ public static List <Project> GetAllProjectsAvailable(User user) { List <Project> result; using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { result = serviceClient.GetAllProjectsOnServer(user); } return(result); }
/** * Get all documents of a project one by one from the server */ public static List<Document> GetAllProjectDocuments(Project p) { List<DocumentStruct> allDocs = new List<DocumentStruct>(); Folder.GetAllStructs(p, allDocs); // get all document reference structs out List<Document> result = new List<Document>(); // ask server for documents using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { foreach (DocumentStruct d in allDocs) { result.Add(serviceClient.OpenDocumentOnServer(p.Id, d.Id)); } } return result; }
/** * Get all documents of a project one by one from the server */ public static List <Document> GetAllProjectDocuments(Project p) { List <DocumentStruct> allDocs = new List <DocumentStruct>(); Folder.GetAllStructs(p, allDocs); // get all document reference structs out List <Document> result = new List <Document>(); // ask server for documents using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { foreach (DocumentStruct d in allDocs) { result.Add(serviceClient.OpenDocumentOnServer(p.Id, d.Id)); } } return(result); }
/** * Shares the changes the user have made in a project * to the server, and the server shares changes from other * users back. This synchronization is done through a series * of method calls to the server. */ public static void SyncWithServer(Project project, User user) { // Preparing transfer data // finding all modified documents to send List <DocumentStruct> docs = new List <DocumentStruct>(); Folder.GetAllStructs(project, docs); // fill up the list List <DocumentStruct> docsToSend = new List <DocumentStruct>(); foreach (DocumentStruct d in docs) { if (d.Modified) { docsToSend.Add(d); } } // Call the server using (SliceOfPieServiceClient serviceClient = new SliceOfPieServiceClient()) { // Tell the server who we are and what project we want to sync Project newProj = serviceClient.StartSync(user, project.Id); // If null is returned, means that the project was deleted // or you've lost access to this project, so we delete it if (newProj == null) { Controller.DeleteProject(project.Id); } else { // Send all modified documents one at a time foreach (DocumentStruct d in docsToSend) { Document document = Controller.OpenDocument(project.Id, d.Id); serviceClient.SendDocument(document); if (document.Deleted) { Controller.DeleteDocument(project.Id, document.Id); } } // Keep getting new documents from server until there are none remaining while (true) { // Grab a new document from the server Document newDoc = serviceClient.GetUpdatedDocument(); // if null is returned, means that there are no new docs left if (newDoc == null) { break; } // Delete the old copy and write the new one instead Storage.DeleteDocument(project.Id, newDoc.Id); Storage.WriteToFile(newProj, newDoc, true); } // We're done syncing, close the session with the server serviceClient.StopSync(); } } }