public ActionResult TransferCustomers() { //return this.Json("Yay", JsonRequestBehavior.AllowGet); var credentials = AzureAuthenticationHelper.GetReportingCredentials(); if (ServiceHandler.Instance.TryAuthenticate( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword)) { var helper = new PowerBiHelper(AzureAuthenticationHelper.GetSession()); var customersRaw = ServiceHandler.Instance.Client.GetCustomersRaw( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword, Customer.All, 1, AccountManager.All); if (customersRaw.OwnerDocument != null) { var namespaceManager = new XmlNamespaceManager(customersRaw.OwnerDocument.NameTable); namespaceManager.AddNamespace("tlp", "http://www.timelog.com/XML/Schema/tlp/v4_4"); var customers = customersRaw.SelectNodes("tlp:Customer", namespaceManager); if (customers != null) { var tableConstructed = false; var rowsList = new List <string>(); foreach (XmlNode customer in customers) { if (!tableConstructed) { helper.DeleteRows(helper.GetDefaultDatasetId(), "Customers"); var tableSchemaJson = helper.BuildTableSchemaJson("Customers", typeof(Customer)); helper.UpdateTableSchema(helper.GetDefaultDatasetId(), "Customers", tableSchemaJson); tableConstructed = true; } rowsList.Add(helper.BuildTableRowJson(new Customer(customer, namespaceManager))); } helper.AddRows(helper.GetDefaultDatasetId(), "Customers", rowsList, 100); } } return(this.Json("Yay", JsonRequestBehavior.AllowGet)); } return(this.Json("Failed", JsonRequestBehavior.AllowGet)); }
public ActionResult TransferWorkUnits() { return this.Json("Yay", JsonRequestBehavior.AllowGet); var credentials = AzureAuthenticationHelper.GetReportingCredentials(); if (ServiceHandler.Instance.TryAuthenticate( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword)) { var helper = new PowerBiHelper(AzureAuthenticationHelper.GetSession()); var workUnitsRaw = ServiceHandler.Instance.Client.GetWorkUnitsRaw( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword, WorkUnit.All, Employee.All, Allocation.All, Task.All, Project.All, Department.All, DateTime.Now.AddMonths(-6), DateTime.Now); if (workUnitsRaw.OwnerDocument != null) { var namespaceManager = new XmlNamespaceManager(workUnitsRaw.OwnerDocument.NameTable); namespaceManager.AddNamespace("tlp", "http://www.timelog.com/XML/Schema/tlp/v4_4"); var workUnits = workUnitsRaw.SelectNodes("tlp:WorkUnit", namespaceManager); if (workUnits != null) { var tableConstructed = false; var rowsList = new List<string>(); foreach (XmlNode workUnit in workUnits) { if (!tableConstructed) { try { helper.DeleteRows(helper.GetDefaultDatasetId(), "WorkUnits"); } catch (Exception) { // Ignore. Probably first request throw new Exception("PowerBI table definition out of sync. Please delete entire dataset and try transferring again."); } var tableSchemaJson = helper.BuildTableSchemaJson("WorkUnits", typeof(WorkUnit)); helper.UpdateTableSchema(helper.GetDefaultDatasetId(), "WorkUnits", tableSchemaJson); tableConstructed = true; } rowsList.Add(helper.BuildTableRowJson(new WorkUnit(workUnit, namespaceManager))); } helper.AddRows(helper.GetDefaultDatasetId(), "WorkUnits", rowsList, 100); } } return this.Json("Yay", JsonRequestBehavior.AllowGet); } return this.Json("Failed", JsonRequestBehavior.AllowGet); }
public ActionResult TransferWorkUnits() { return(this.Json("Yay", JsonRequestBehavior.AllowGet)); var credentials = AzureAuthenticationHelper.GetReportingCredentials(); if (ServiceHandler.Instance.TryAuthenticate( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword)) { var helper = new PowerBiHelper(AzureAuthenticationHelper.GetSession()); var workUnitsRaw = ServiceHandler.Instance.Client.GetWorkUnitsRaw( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword, WorkUnit.All, Employee.All, Allocation.All, Task.All, Project.All, Department.All, DateTime.Now.AddMonths(-6).ToString(), DateTime.Now.ToString()); if (workUnitsRaw.OwnerDocument != null) { var namespaceManager = new XmlNamespaceManager(workUnitsRaw.OwnerDocument.NameTable); namespaceManager.AddNamespace("tlp", "http://www.timelog.com/XML/Schema/tlp/v4_4"); var workUnits = workUnitsRaw.SelectNodes("tlp:WorkUnit", namespaceManager); if (workUnits != null) { var tableConstructed = false; var rowsList = new List <string>(); foreach (XmlNode workUnit in workUnits) { if (!tableConstructed) { try { helper.DeleteRows(helper.GetDefaultDatasetId(), "WorkUnits"); } catch (Exception) { // Ignore. Probably first request throw new Exception("PowerBI table definition out of sync. Please delete entire dataset and try transferring again."); } var tableSchemaJson = helper.BuildTableSchemaJson("WorkUnits", typeof(WorkUnit)); helper.UpdateTableSchema(helper.GetDefaultDatasetId(), "WorkUnits", tableSchemaJson); tableConstructed = true; } rowsList.Add(helper.BuildTableRowJson(new WorkUnit(workUnit, namespaceManager))); } helper.AddRows(helper.GetDefaultDatasetId(), "WorkUnits", rowsList, 100); } } return(this.Json("Yay", JsonRequestBehavior.AllowGet)); } return(this.Json("Failed", JsonRequestBehavior.AllowGet)); }
public ActionResult TransferCustomers() { //return this.Json("Yay", JsonRequestBehavior.AllowGet); var credentials = AzureAuthenticationHelper.GetReportingCredentials(); if (ServiceHandler.Instance.TryAuthenticate( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword)) { var helper = new PowerBiHelper(AzureAuthenticationHelper.GetSession()); var customersRaw = ServiceHandler.Instance.Client.GetCustomersRaw( credentials.SiteCode, credentials.ApiId, credentials.ApiPassword, Customer.All, 1, AccountManager.All, string.Empty); if (customersRaw.OwnerDocument != null) { var namespaceManager = new XmlNamespaceManager(customersRaw.OwnerDocument.NameTable); namespaceManager.AddNamespace("tlp", "http://www.timelog.com/XML/Schema/tlp/v4_4"); var customers = customersRaw.SelectNodes("tlp:Customer", namespaceManager); if (customers != null) { var tableConstructed = false; var rowsList = new List<string>(); foreach (XmlNode customer in customers) { if (!tableConstructed) { helper.DeleteRows(helper.GetDefaultDatasetId(), "Customers"); var tableSchemaJson = helper.BuildTableSchemaJson("Customers", typeof(Customer)); helper.UpdateTableSchema(helper.GetDefaultDatasetId(), "Customers", tableSchemaJson); tableConstructed = true; } rowsList.Add(helper.BuildTableRowJson(new Customer(customer, namespaceManager))); } helper.AddRows(helper.GetDefaultDatasetId(), "Customers", rowsList, 100); } } return this.Json("Yay", JsonRequestBehavior.AllowGet); } return this.Json("Failed", JsonRequestBehavior.AllowGet); }