using framework_business; using framework_library; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Hosting; /// /// Summary description for update /// public class xService { public xService() { // // TODO: Add constructor logic here // } #region version methods /// /// Byte Array to get a version /// /// /// /// /// /// public static byte[] GetVersion(string customerCode, string licenceKey, string versionNo, string file) { byte[] result = null; Stream fs = new MemoryStream(); string path = String.Empty; try { //first validate the licence if (licenceHandler.GetLicence(licenceKey).customerCode == customerCode) { //validate the folder is there utils.validateFolder(HostingEnvironment.MapPath("~/release/" + versionNo + "/")); path = HostingEnvironment.MapPath("~/release/" + versionNo + "/" + file); //check if the file exists if (File.Exists(path)) { //Create File Stream fs = new FileStream(path, FileMode.Open, FileAccess.Read); //Create Byte result = new Byte[fs.Length]; //Read the File from the Memory Stream fs.Read(result, 0, result.Length); //Close File Stream fs.Close(); } } } catch (Exception ex) { throw ex; } return result; } /// /// bool to save a version release /// /// /// /// /// public static bool SaveVersion(byte[] versionData, string versionNo, string file) { bool result = false; Stream fs = new MemoryStream(); string path = String.Empty; try { //validate the folder utils.validateFolder(HostingEnvironment.MapPath("~/release/" + versionNo + "/")); path = HostingEnvironment.MapPath("~/release/" + versionNo + "/" + file); //delete previous version of the file if (File.Exists(path)) File.Delete(path); fs = new FileStream(path, FileMode.Create, FileAccess.Write); fs.Write(versionData, 0, versionData.Length); fs.Close(); result = true; } catch (Exception ex) { throw ex; } return result; } #endregion }