//http://dqf.taus.net/api/v1/productivityProject?name=My+first+DQF+productivity+project&quality_level=1&process=2&source_language=en-US&contentType=1&industry=1 public ProductivityProject PostDqfProject(string dqfPmanagerKey, ProductivityProject productivityProject) { var url = Configuration.DqfServerRoot + Configuration.DqfApiVersion; url += "productivityProject?"; url += "name=" + productivityProject.Name.Replace(" ", "+"); url += "&quality_level=" + productivityProject.QualityLevel; url += "&process=" + productivityProject.Process; url += "&source_language=" + productivityProject.SourceLanguage; url += "&contentType=" + productivityProject.ContentType; url += "&industry=" + productivityProject.Industry; var uri = new Uri(url); //Headers = {Access-Control-Allow-Headers: Content-Type, api_key, Authorization //Access-Control-Allow-Methods: GET, POST, DELETE, PUT //Access-Control-Allow-Origin: * //project_id: 1565 //project_key: 8teu3289m3vmrb6jcvkq39g9g83u0ofqn67lvrobaumrqv0jp1l4 //Connection: close... //Headers {Access-Control-Allow-Headers: Content-Type, api_key, Authorization //Access-Control-Allow-Methods: GET, POST, DELETE, PUT //Access-Control-Allow-Origin: * //project_id: 1566 //project_key: 4mrnet0dr5e7aemghps07rqbnvr2al01vanuv8c54vjnp6bni4rc //Connection: close //Content-Length: 79 //Content-Type: application/json //Date: Sat, 30 May 2015 21:36:52 GMT //Server: Apache var webRequest = (HttpWebRequest)WebRequest.Create(uri); webRequest.KeepAlive = false; webRequest.Method = @"POST"; webRequest.ContentLength = 0; webRequest.Proxy = null; webRequest.Headers.Add("DQF_PMANAGER_KEY", dqfPmanagerKey); webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; .NET CLR 3.5.30729;)"; using (var webResponse = webRequest.GetResponse() as HttpWebResponse) { if (webResponse == null) { return(productivityProject); } productivityProject.ProjectId = Convert.ToInt32(webResponse.Headers["project_id"]); productivityProject.ProjectKey = webResponse.Headers["project_key"]; var reader = new StreamReader(webResponse.GetResponseStream()); reader.ReadToEnd(); } return(productivityProject); }
public void NewDqfProject() { if (Tracked.Settings.DqfSettings.UserKey.Trim() == string.Empty) { MessageBox.Show(PluginResources.The_DQF_API_key_cannot_be_null + "\r\n\r\n" + PluginResources.To_create_a_TAUS_DQF_Project__you_must_first_save_your_DQF_API_key_ , Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } var f = new DqfProjectCreate { DqfProject = new DqfProject { Name = Project.Name } }; f.ShowDialog(); if (!f.Saved) { return; } if (Project != null && Project.DqfProjects.Exists(a => a.Name.ToLower().Trim() == f.DqfProject.Name.ToLower().Trim())) { MessageBox.Show(PluginResources.The_DQF_project_name_already_exists, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { try { var dqfProject = f.DqfProject; dqfProject.ProjectId = Project.Id; dqfProject.ProjectIdStudio = Project.StudioProjectId; dqfProject.SourceLanguage = Project.SourceLanguage; dqfProject.Created = DateTime.Now; dqfProject.DqfPmanagerKey = Tracked.Settings.DqfSettings.UserKey; dqfProject.DqfProjectId = -1; dqfProject.DqfProjectKey = string.Empty; dqfProject.Imported = false; var processor = new Processor(); var productivityProject = new ProductivityProject { Name = dqfProject.Name, QualityLevel = dqfProject.QualityLevel, SourceLanguage = dqfProject.SourceLanguage, Process = dqfProject.Process, ContentType = dqfProject.ContentType, Industry = dqfProject.Industry }; productivityProject = processor.PostDqfProject(Tracked.Settings.DqfSettings.UserKey, productivityProject); dqfProject.DqfProjectId = productivityProject.ProjectId; dqfProject.DqfProjectKey = productivityProject.ProjectKey; var query = new Query(); dqfProject.Id = query.CreateDqfProject(Tracked.Settings.ApplicationPaths.ApplicationMyDocumentsDatabaseProjectsPath, dqfProject); var tn = treeView_dqf_projects.Nodes.Add(dqfProject.Name); tn.ImageIndex = 0; tn.SelectedImageIndex = tn.ImageIndex; tn.Tag = dqfProject; Project.DqfProjects.Add(dqfProject); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }