public static ApplicationBuild SaveBuild(string BuildNotes, string FilePath, string CurrentUserName, int environmentId) { ApplicationBuild retval = null; string BuildType = Platforms.Common.GetFilesBuildPlatform(Path.GetFileName(FilePath)); Guid uniqueBuildId = new Guid(System.IO.Path.GetFileNameWithoutExtension(FilePath)); if (BuildType.ToUpper() == Constants.BUILD_PLATFORM_ANDROID) { Platforms.Android.AndroidManifestData data = Platforms.Android.AndroidPackage.GetManifestData(FilePath); CreateAndGetApplicationIfNoExists(data.ApplicationName, data.PackageName, Constants.BUILD_PLATFORM_ANDROID, CurrentUserName); using (var context = new Repository.BetaDepotContext()) { Repository.ApplicationBuild buildToSave = new Repository.ApplicationBuild() { AddedDtm = DateTime.UtcNow, Application = context.Applications.Where(w => w.ApplicationIdentifier == data.PackageName).FirstOrDefault(), UniqueIdentifier = uniqueBuildId, Notes = BuildNotes, versionNumber = data.VersionName, versionCode = data.VersionCode, Platform = Constants.BUILD_PLATFORM_ANDROID, AddedBy = context.TeamMembers.Where(w => w.UserName == CurrentUserName).FirstOrDefault(), Environment = context.Environments.Where(w => w.Id == environmentId).FirstOrDefault() }; context.Builds.Add(buildToSave); context.SaveChanges(); retval = buildToSave; } } else if (BuildType.ToUpper() == Constants.BUILD_PLATFORM_IOS) { Platforms.iOS.iOSBundleData data = Platforms.iOS.iOSBundle.GetIPABundleData(FilePath); CreateAndGetApplicationIfNoExists(data.BundleAppName, data.BundleIdentifier, Constants.BUILD_PLATFORM_IOS, CurrentUserName); using (var context = new Repository.BetaDepotContext()) { Repository.ApplicationBuild buildToSave = new Repository.ApplicationBuild() { AddedDtm = DateTime.UtcNow, Application = context.Applications.Where(w => w.ApplicationIdentifier == data.BundleIdentifier).FirstOrDefault(), UniqueIdentifier = Guid.NewGuid(), Notes = BuildNotes, versionNumber = data.BundleVersion, Platform = Constants.BUILD_PLATFORM_IOS, AddedBy = context.TeamMembers.Where(w => w.UserName == CurrentUserName).FirstOrDefault(), Environment = context.Environments.Where(w => w.Id == environmentId).FirstOrDefault() }; context.Builds.Add(buildToSave); context.SaveChanges(); retval = buildToSave; } } return retval; }
public static ApplicationBuild SaveBuild(string BuildNotes, string FilePath, string CurrentUserName, int environmentId) { ApplicationBuild retval = null; string BuildType = Platforms.Common.GetFilesBuildPlatform(Path.GetFileName(FilePath)); Guid uniqueBuildId = new Guid(System.IO.Path.GetFileNameWithoutExtension(FilePath)); if (BuildType.ToUpper() == Constants.BUILD_PLATFORM_ANDROID) { Platforms.Android.AndroidManifestData data = Platforms.Android.AndroidPackage.GetManifestData(FilePath); CreateAndGetApplicationIfNoExists(data.ApplicationName, data.PackageName, Constants.BUILD_PLATFORM_ANDROID, CurrentUserName); using (var context = new Repository.BetaDepotContext()) { Repository.ApplicationBuild buildToSave = new Repository.ApplicationBuild() { AddedDtm = DateTime.UtcNow, Application = context.Applications.Where(w => w.ApplicationIdentifier == data.PackageName).FirstOrDefault(), UniqueIdentifier = uniqueBuildId, Notes = BuildNotes, versionNumber = data.VersionName, versionCode = data.VersionCode, Platform = Constants.BUILD_PLATFORM_ANDROID, AddedBy = context.TeamMembers.Where(w => w.UserName == CurrentUserName).FirstOrDefault(), Environment = context.Environments.Where(w => w.Id == environmentId).FirstOrDefault() }; context.Builds.Add(buildToSave); context.SaveChanges(); retval = buildToSave; } } else if (BuildType.ToUpper() == Constants.BUILD_PLATFORM_IOS) { Platforms.iOS.iOSBundleData data = Platforms.iOS.iOSBundle.GetIPABundleData(FilePath); CreateAndGetApplicationIfNoExists(data.BundleAppName, data.BundleIdentifier, Constants.BUILD_PLATFORM_IOS, CurrentUserName); using (var context = new Repository.BetaDepotContext()) { Repository.ApplicationBuild buildToSave = new Repository.ApplicationBuild() { AddedDtm = DateTime.UtcNow, Application = context.Applications.Where(w => w.ApplicationIdentifier == data.BundleIdentifier).FirstOrDefault(), UniqueIdentifier = Guid.NewGuid(), Notes = BuildNotes, versionNumber = data.BundleVersion, Platform = Constants.BUILD_PLATFORM_IOS, AddedBy = context.TeamMembers.Where(w => w.UserName == CurrentUserName).FirstOrDefault(), Environment = context.Environments.Where(w => w.Id == environmentId).FirstOrDefault() }; context.Builds.Add(buildToSave); context.SaveChanges(); retval = buildToSave; } } return(retval); }