public QvDataContractResponse getLocalDictionaries() { Catalog.Open(); return(new Info { qMessage = JsonConvert.SerializeObject(Catalog._catalog) }); }
public QvDataContractResponse copyDictionaryToLocal(String owner, String name, String displayName) { //Debugger.Launch(); Catalog.Open(); string dictionaryHost = ConfigurationManager.AppSettings["PublicDictionaryHost"]; string repo = String.Format("http://github.com/{0}/{1}", owner, name); string zipurl = String.Format("{0}/archive/master.zip", repo); string configDirectory = @"C:\Program Files\Common Files\Qlik\Custom Data\GenericRestConnector\configs\"; WebRequest wr = WebRequest.Create(zipurl) as HttpWebRequest; wr.Method = "GET"; String tempPath = Path.GetTempPath(); String tempZip = String.Format("{0}{1}.zip", tempPath, name); try { using (var responseStream = wr.GetResponse().GetResponseStream()) { using (FileStream fs = new FileStream(tempZip, FileMode.Create, FileAccess.Write)) { responseStream.CopyTo(fs); } } if (!Directory.Exists(configDirectory + name + "-master")) { ZipFile.ExtractToDirectory(tempZip, configDirectory); } Catalog.AddEntry(displayName, name, repo); return(new Info { qMessage = "\"status\":1" }); // } catch (Exception ex) { Console.Write(ex.Message); return(new Info { qMessage = "\"err\":\"" + ex.Message + "\"" }); } }