Upvise Client Library: Project Class (.NET)
| Base Fields string id string name string owner string note int status string code DateTime startdate DateTime enddate | Address Properties string street string city string zipcode string state string country string geo | Client Properties string contactid string companyid |
| Group & Region Fields string groupid string regionid | Constants static const OPEN static const CLOSED | Custom Fields void setCustomField(key, value) string getCustomField(key) |
| Parsing & Serialization static Project fromJson(JSONObject obj) JSONObject toJson() | Linked Forms Form[] getForms(since) | Archiving static void archive(string id, Query query) |
Overview
The Project class of the Upvise Client Library represent a record in the Projects.projects Upvise table of the Projects Application
Project Sample on GithubUsage
Insert a new Project
using UpviseClient;
...
Query query = new Query(token);
Project newproject = new Project();
newproject.id = "ID1";
newproject.status = Project.OPEN;
newproject.name = "Maintain Air Conditining";
newproject.code = "TRE453";
newproject.note = "Verify gaz pressure";
newproject.startdate = DateTime.Today;
newproject.enddate = DateTime.Today.addMonths(3);
newproject.owner = "John"; // if you want to assign a Job, set the Upvise user Display name here
newproject.street = "1 infinite Loop";
newproject.city = "Cupertino";
newproject.zipcode = "";
newproject.country = "USA";
newproject.geo = "12,3.444"; // set the coordinates for the job
// set some custom fields values
newproject.setCustomField("F1", "WATER");
newproject.setCustomField("F2", "12");
// Perform insert
query.insert(Project.TABLE, newproject.toJson());
Insert multiple Projects in Batch
using UpviseClient;
...
Query query = new Query(token);
query.beginBatch();
for (var i = 0; i < 10; i++) {
Project project = new Project();
project.id = "ID" + i;
project.status = Project.OPEN;
project.name = "Maintain Air Conditining " + i;
project.startdate = DateTime.Today;
...
query.insert(Project.TABLE, project.toJson());
}
query.commitBatch();
Retrieve Project Forms
using UpviseClient;
...
Query query = new Query(token);
var projectid = "PROJID";
JSONObject obj = query.selectId(Project.TABLE, projectid);
Project project = Project.fromJSON(obj);
long sinceDate = 0;
Form[] forms = project.selectForms(query, sinceDate);
// Iterate through all forms, ad ignore DRAFT ones
foreach (Form form in forms) {
if (form.status != Form.DRAFT) {
// get the form data
string xml = form.writeXml();
// TODO : save the xml file to disk
// download the PDF file for the form (work only if the correct settings in Forms Web has been set in Options)
byte[] pdfcontent = form.downloadPdfArchive(query);
// TODO : save the pdf file to disk
}
}
static void archive(string id, Query query)
Archives one project and its linked notes, tasks, milestones, products, forms, and photos / files. It does NOT ARCHIVE linked quotes or invoices.- id is the project id to be archived
- query is the query object used to connect to the target account