public void Test() { // Creating entity using (var session = Domain.OpenSession()) { using (var transactionScope = session.OpenTransaction()) { //AddVersion_1_0_0_0(session); AddVersion_1_0_5_0(session); transactionScope.Complete(); } } // Checking the result entity using (var session = Domain.OpenSession()) { using (var transactionScope = session.OpenTransaction()) { var productVersions = session.Query.All <ProductVersion>().ToList(); var productVersionDtos = productVersions.TransformToDto <ProductVersion, ProductVersionDto>(session); ProductVersionsDto versionsBag = new ProductVersionsDto(productVersionDtos); string xml = SerializeUtils.SerializeDataContract(versionsBag); File.WriteAllText(@"c:\doemd-versions.xml", xml); var dataContract = SerializeUtils.DeserializeDataContract <ProductVersionsDto>(xml); transactionScope.Complete(); } } // Writing message to log Log.Info("Test passed."); }
private ProductVersionsDto GetAllProductVersions(string fileName) { ProductVersionsDto result = HttpContext.Current.Application.Get("AllProductVersions") as ProductVersionsDto; if (result == null) { try { string content = File.ReadAllText(fileName); result = SerializeUtils.DeserializeDataContract <ProductVersionsDto>(content); } catch {} if (result == null) { result = new ProductVersionsDto(); } HttpContext.Current.Application.Set("AllProductVersions", result); } return(result); }
private void GetLatestVersion(HttpContext context, string currentversion, bool isDebug) { context.Response.ContentType = "text/plain"; string result = string.Empty; if (string.IsNullOrEmpty(currentversion)) { result = isDebug ? "Unknown current version" : string.Empty; } else { string localFile = context.Server.MapPath("~/Versions/doemd-versions.xml"); if (File.Exists(localFile)) { try { VersionNumber currentVersionNumber = new VersionNumber(currentversion); ProductVersionsDto allProductVersions = GetAllProductVersions(localFile); ProductVersionDto foundProductVersion = (from productVersion in allProductVersions let versionNumber = new VersionNumber(productVersion.Version) where versionNumber.CompareTo(currentVersionNumber) == 1 orderby versionNumber descending select productVersion).FirstOrDefault(); if (foundProductVersion == null) { result = isDebug ? "Current version is actual latest version." : string.Empty; } else { result = foundProductVersion.ToXml(); context.Response.ContentType = "text/xml"; } } catch (Exception e) { result = isDebug ? string.Format("Error: {0}", e.Message) : string.Empty; } } else { result = isDebug ? "Error processing request #003" : string.Empty; } } context.Response.Write(result); }