public override UploadResult Upload(Stream stream, string fileName) { UploadResult result = new UploadResult(); try { DropName = "ZScreen_" + ZAppHelper.GetRandomAlphanumeric(10); DropDescription = string.Empty; Drop drop = CreateDrop(DropName, DropDescription, false, false, false); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("version", "2.0"); args.Add("api_key", APIKey); args.Add("format", "xml"); args.Add("token", drop.AdminToken); args.Add("drop_name", drop.Name); string response = UploadData(stream, "http://assets.drop.io/upload", fileName, "file", args); result.Source = response; if (!string.IsNullOrEmpty(response)) { Asset asset = ParseAsset(response); result.URL = string.Format("http://drop.io/{0}/asset/{1}", drop.Name, asset.Name); } } catch (Exception e) { Errors.Add(e.Message); } return(result); }
public Workflow() { this.ID = ZAppHelper.GetRandomAlphanumeric(12); this.Description = "New Workflow"; this.Enabled = true; ApplyDefaultValues(this); }
public bool AddHistoryItem(HistoryItem historyItem) { if (!string.IsNullOrEmpty(xmlPath)) { lock (thisLock) { XmlDocument xml = new XmlDocument(); if (File.Exists(xmlPath)) { xml.Load(xmlPath); } if (xml.ChildNodes.Count == 0) { xml.AppendChild(xml.CreateXmlDeclaration("1.0", "UTF-8", null)); xml.AppendElement("HistoryItems"); } XmlNode rootNode = xml.ChildNodes[1]; if (rootNode.Name == "HistoryItems") { historyItem.ID = ZAppHelper.GetRandomAlphanumeric(12); XmlNode historyItemNode = rootNode.PrependElement("HistoryItem"); historyItemNode.AppendElement("ID", historyItem.ID); historyItemNode.AppendElement("Filename", historyItem.Filename); historyItemNode.AppendElement("Filepath", historyItem.Filepath); historyItemNode.AppendElement("DateTimeUtc", historyItem.DateTimeUtc.ToString("o")); historyItemNode.AppendElement("Type", historyItem.Type); historyItemNode.AppendElement("Host", historyItem.Host); historyItemNode.AppendElement("URL", historyItem.URL); historyItemNode.AppendElement("ThumbnailURL", historyItem.ThumbnailURL); historyItemNode.AppendElement("DeletionURL", historyItem.DeletionURL); historyItemNode.AppendElement("ShortenedURL", historyItem.ShortenedURL); xml.Save(xmlPath); return(true); } } } return(false); }
private static string GenerateNonce() { return(ZAppHelper.GetRandomAlphanumeric(12)); }