public GeneratedFeedFile FeedFileByStore(Store store, string secondFileName = null, string extension = null) { if (store != null) { string ext = extension ?? BaseSettings.ExportFormat; string dir = Path.Combine(HttpRuntime.AppDomainAppPath, "Content\\files\\exportimport"); string fname = "{0}_{1}".FormatWith(store.Id, BaseSettings.StaticFileName); if (ext.HasValue()) { fname = Path.GetFileNameWithoutExtension(fname) + (ext.StartsWith(".") ? "" : ".") + ext; } string url = "{0}content/files/exportimport/".FormatWith(store.Url.EnsureEndsWith("/")); if (!(url.StartsWith("http://") || url.StartsWith("https://"))) { url = "http://" + url; } if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var feedFile = new GeneratedFeedFile() { StoreName = store.Name, FilePath = Path.Combine(dir, fname), FileUrl = url + fname }; if (secondFileName.HasValue()) { string fname2 = store.Id + "_" + secondFileName; feedFile.CustomProperties.Add("SecondFilePath", Path.Combine(dir, fname2)); feedFile.CustomProperties.Add("SecondFileUrl", url + fname2); } return(feedFile); } return(null); }
public GeneratedFeedFile FeedFileByStore(Store store, string secondFileName = null, string extension = null) { if (store != null) { string ext = extension ?? BaseSettings.ExportFormat; string dir = Path.Combine(HttpRuntime.AppDomainAppPath, "Content\\files\\exportimport"); string fname = "{0}_{1}".FormatWith(store.Id, BaseSettings.StaticFileName); if (ext.HasValue()) fname = Path.GetFileNameWithoutExtension(fname) + (ext.StartsWith(".") ? "" : ".") + ext; string url = "{0}content/files/exportimport/".FormatWith(store.Url.EnsureEndsWith("/")); if (!(url.StartsWith("http://") || url.StartsWith("https://"))) url = "http://" + url; if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); var feedFile = new GeneratedFeedFile() { StoreName = store.Name, FilePath = Path.Combine(dir, fname), FileUrl = url + fname }; if (secondFileName.HasValue()) { string fname2 = store.Id + "_" + secondFileName; feedFile.CustomProperties.Add("SecondFilePath", Path.Combine(dir, fname2)); feedFile.CustomProperties.Add("SecondFileUrl", url + fname2); } return feedFile; } return null; }