public async Task <ActionResult> NewOrder() { //string apiKey = HttpContext.Session.GetString("apiKey"); string environment = HttpContext.Session.GetString("environment"); string apiKey = await chiliConnector.GenerateApiKey(environment, "ProfileServer", "password"); if (apiKey != null) { string currentTemplateJson = HttpContext.Session.GetString("currentWorkingTemplate"); if (currentTemplateJson != null) { ChiliResource currentTemplate = JsonConvert.DeserializeObject <ChiliResource>(currentTemplateJson); Task <string> pdfUrlTask = chiliConnector.DocumentCreatePdf(apiKey, currentTemplate.id, "76e02f73-c687-4ae3-b5e7-f6e5f2c707e8"); while (pdfUrlTask.IsCompleted == false) { } string pdfUrl = pdfUrlTask.Result; if (!pdfUrl.ToLower().Contains("error")) { return(Json(new { success = "true", url = pdfUrl })); } } } return(Json(new { success = "false" })); }
public async Task <ActionResult> Edit(string id) { //string apiKey = HttpContext.Session.GetString("apiKey"); string apiKey = HttpContext.Session.GetString("serverKey"); if (apiKey != null) { string templatesJsonArray = HttpContext.Session.GetString("currentChoicesArray"); if (templatesJsonArray != null) { // Deserialize from session ChiliResource[] templatesArray = JsonConvert.DeserializeObject <ChiliResource[]>(templatesJsonArray); ChiliResource template = templatesArray.Single(cr => cr.id == id); string userName = HttpContext.Session.GetString("username"); string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.DayOfWeek.ToString(); ChiliResource newTemplate = await chiliConnector.ResourceItemCopy(apiKey, ChiliResource.ResourceType.Documents, template.id, $"Users/{userName}/temp/{date}"); if (newTemplate != null) { HttpContext.Session.SetString("currentWorkingTemplate", JsonConvert.SerializeObject(newTemplate)); return(Redirect("/storefront/editor")); } } } return(Redirect("/storefront/index")); }
private void GetXmlItemsInFolder(XmlNode folderNode, ref List <ChiliResource> resourceList, ChiliResource.ResourceType resourceType, int level) { foreach (XmlNode node in folderNode.ChildNodes) { if (node.Attributes["isFolder"] != null) { if (node.Attributes["isFolder"].Value == "false") { string id = node.Attributes["id"].Value; string name = node.Attributes["name"].Value; string previewUrl = url.Replace("main.asmx", "") + node.Attributes["iconURL"].Value; string path = node.Attributes["path"].Value; ChiliResource chiliResource = new ChiliResource(id, name, resourceType) { previewUrl = previewUrl, pathOnServer = path }; resourceList.Add(chiliResource); } else { GetXmlItemsInFolder(node, ref resourceList, resourceType, level + 1); } } } }
public async Task <ChiliResource> ResourceItemCopy(string apiKey, ChiliResource.ResourceType resourceType, string id, string copyToPath, string newName = null) { XmlDocument xmlDocument = new XmlDocument(); if (newName == null) { ResourceItemGetDefinitionXMLResponse responseGet = await soapClient.ResourceItemGetDefinitionXMLAsync(apiKey, resourceType.ToString(), id); xmlDocument.LoadXml(responseGet.Body.ResourceItemGetDefinitionXMLResult); XmlNode xmlInfoNode = xmlDocument.SelectSingleNode("//item[@name and @id]"); if (xmlInfoNode == null) { throw new NotImplementedException("Info node is blank and you didn't do anything thing"); } else { newName = xmlInfoNode.Attributes["name"].Value; } } ResourceItemCopyResponse response = await soapClient.ResourceItemCopyAsync(apiKey, resourceType.ToString(), id, newName, copyToPath); xmlDocument.LoadXml(response.Body.ResourceItemCopyResult); //<item name="Cat.zip" id="4a769cd7-a702-496f-be20-f59c9dc4ba18" relativePath="Blank\Cat.zip.xml" documentVersion="5.4.1.1" lastAcceptedVersion="5.4.1.1"><fileInfo fileIndexed="2019-05-12T17:00:33" numPages="1" resolution="72" width="595.266" height="841.8762" fileSize="13.15 Kb"><metaData><item name="Num. Pages" value="1" /><item name="Width" value="210 mm" /><item name="Height" value="297 mm" /></metaData><boxes /></fileInfo></item> XmlNodeList nodes = xmlDocument.GetElementsByTagName("item"); if (nodes.Count > 0) { XmlNode xmlInfoNode = nodes[0]; string resourceName = xmlInfoNode.Attributes["name"].Value; string resourceID = xmlInfoNode.Attributes["id"].Value; string resourcePath = xmlInfoNode.Attributes["relativePath"].Value; ChiliResource chiliResource = new ChiliResource(resourceID, resourceName, resourceType) { pathOnServer = resourcePath, previewUrl = GetResourcePreviewUrl(apiKey, resourceType, resourceID, PreviewType.thumb) }; return(chiliResource); } return(null); }
public ActionResult Editor() { string apiKey = HttpContext.Session.GetString("apiKey"); if (apiKey != null) { string newTemplateJson = HttpContext.Session.GetString("currentWorkingTemplate"); if (newTemplateJson != null) { ChiliResource newTemplate = JsonConvert.DeserializeObject <ChiliResource>(newTemplateJson); string environment = HttpContext.Session.GetString("environment"); ViewBag.templateCopyId = newTemplate.id; ViewBag.editorUrl = chiliConnector.GetEditorUrl(apiKey, newTemplate.id, environment); return(View()); } } return(Redirect("/storefront/index")); }
public string GetResourcePreviewUrl(string apiKey, ChiliResource chiliResource, PreviewType previewType) { return(GetResourcePreviewUrl(apiKey, chiliResource.resourceType, chiliResource.id, previewType)); }