public void SetupAppVersion <T>(T appItem, App app, string appfileName) where T : QihooAppStoreApp { if (!string.IsNullOrEmpty(appItem.DownloadURL)) { FileInfo fi = new FileInfo(Path.Combine(APK_Folder_Base, appfileName)); if (fi != null && fi.Exists) { AppVersion ver = new AppVersion { FileSize = (int)fi.Length, FileUrl = appfileName, PublishDateTime = appItem.UpdateTime.ToExactDateTime("yyyy-MM-dd"), Status = 1, VersionName = appItem.VersionName, Id = appItem.VersionCode }; AndroidPackageView apkInfo = FileService.GetAndroidPackageInfomation(fi.FullName); apkInfo.Id = ver.Id; var originalApp = RedisService.Get <App>(app.Id); if (app.Status == 0) { RedisService.UpdateWithRebuildIndex <App>(originalApp, app); LogHelper.WriteInfo(string.Format("This App {0} status is invaild", app.Name), ConsoleColor.Gray); } RedisService.SetSubModel <App, AppVersion>(app.Id, ver); RedisService.SetSubModel <App, AndroidPackageView>(app.Id, apkInfo); AppStoreUIService.SetAppCurrentTestVersion(app.Id, ver.Id); AppStoreUIService.PublishAppVersion(app.Id); } } }
private AppProject AddNewApp(TencentAppStoreModel.AppListItem app, AppProject appProject, AppInfo appInfo) { try { #region Set up Applist appProject = new AppProject(); var appProjectId = RedisService.Add <AppProject>(appProject); App ap = new App(); var appId = RedisService.Add <App>(ap); AppSettingsForAppList appSetting = new AppSettingsForAppList() { Id = appId, CreateDateTime = DateTime.Now }; CustomProperty prop = new CustomProperty() { Id = AppConfigKey.OS_ATTR_ID, Value = AppConfigKey.OS_ATTR_VALUE }; RedisService.AddCustomPropertyFor <App, CustomProperty>(ap.Id, prop); var lcdDetails = AppStoreUIService.GetElementDetailList(AppConfigKey.LCD_ATTR_ID); foreach (var lcd in lcdDetails) { SetLCD(ap.Id, lcd.Value.ToString()); } AppStoreUIService.SetAppForAppList <AppProject>(appProjectId, appSetting); #endregion #region Set up app project var originalAppProject = CloneHelper.DeepClone <AppProject>(appProject); appProject.AppNo = "tencent_" + app.appid; appProject.Creator = app.cpname; appProject.LogoFile = GetFileNameFromUri(appInfo.logo); appProject.Name = appInfo.name; appProject.PackageName = appInfo.packageName; appProject.Rate = appInfo.star.ToFloat(); RedisService.UpdateWithRebuildIndex <AppProject>(originalAppProject, appProject); #endregion #region Set up App var originalApp = CloneHelper.DeepClone <App>(ap); var originalApp2 = RedisService.Get <App>(ap.Id); ap.AppNo = appProject.AppNo; ap.AppProjectId = appProject.Id; ap.UseGreaterVersion = true; ClientImageInfo lg = new ClientImageInfo { BelongsToAppId = ap.Id, FileUrl = Path.Combine(LogoDirRoot, GetFileNameFromUri(appInfo.logo)), TypeId = "1" }; RedisService.Add <ClientImageInfo>(lg); ap.ClientLogos = new List <ClientImageInfo> { lg }; ImageInfo lg2 = new ImageInfo { BelongsToAppId = ap.Id, FileUrl = Path.Combine(LogoDirRoot, GetFileNameFromUri(appInfo.logo)) }; RedisService.Add <ImageInfo>(lg2); ap.Logo = lg2; ap.Name = appInfo.name; ap.OrderNumber = appInfo.downnum; ap.DownloadTimes = appInfo.downnum; ap.Status = 1; foreach (var s in appInfo.images) { ImageInfo ss = new ImageInfo { BelongsToAppId = ap.Id, FileUrl = Path.Combine(ScreenshotDirRoot, GetFileNameFromUri(s)) }; RedisService.Add <ImageInfo>(ss); ap.ScreenShot.Add(ss); } ap.PlatformType = AppConfigKey.PLATFORM_TYPE_ID.ConfigValue().ToInt32(); ap.Summary = appInfo.detail.Replace("<br/>", string.Empty).Replace("<br>", string.Empty); RedisService.UpdateWithRebuildIndex <App>(originalApp2, ap); #endregion #region Set up App Version if (!string.IsNullOrEmpty(appInfo.apkurl)) { FileInfo fi = new FileInfo(Path.Combine(APK_Folder_Base, GetFileNameFromUri(appInfo.apkurl))); if (fi != null && fi.Exists) { AppVersion ver = new AppVersion { FileSize = (int)fi.Length, FileUrl = GetFileNameFromUri(appInfo.apkurl), PublishDateTime = appInfo.updatetime, Status = 1, VersionName = appInfo.apkver, Id = appInfo.versionCode.ToString() }; RedisService.SetSubModel <App, AppVersion>(ap.Id, ver); AppStoreUIService.SetAppCurrentTestVersion(appId, ver.Id); AppStoreUIService.PublishAppVersion(appId); AndroidPackageView apkInfo = FileService.GetAndroidPackageInfomation(fi.FullName); apkInfo.Id = ver.Id; RedisService.SetSubModel <App, AndroidPackageView>(ap.Id, apkInfo); } } #endregion #region Set up tags if (appInfo.type.StartsWith("soft", StringComparison.OrdinalIgnoreCase)) { AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_SOFTWARE, appProject.Id); AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_TOT_10_SOFTWARE, appProject.Id); } else { AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_GAME, appProject.Id); AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_TOT_10_GAMES, appProject.Id); } AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_LATEST, appProject.Id); AppStoreUIService.AddTagForAppProject(appInfo.category, appProject.Id); AddMarketTag(appInfo.category, ap.Id); AppStoreUIService.AddTagForApp("Live", ap.Id); AppStoreUIService.AddTagForApp("Valid", ap.Id); AppStoreUIService.AddTagForAppProject("From_tencent", appProject.Id); #endregion } catch (Exception ex) { LogHelper.WriteError(ex.Message + ex.StackTrace); LogHelper.WriteInfo(string.Format("This AppProject {0} will delete, appProjectId is {1}", appProject.Name, appProject.Id)); AppProjectDelete(appProject.Id); } return(appProject); }
private int AddNewVersionForApp(int newVersionCount, TencentAppStoreModel.AppListItem app, App a) { newVersionCount++; #region Checked TYD App var tags = AppStoreUIService.GetTagsByApp(a.Id); // if the app has "TYD手动维护" tag, skip it. if (tags.FindIndex(x => (x.Name == AppConfigKey.TAG_TYD_SKIP) || (x.Id == AppConfigKey.TAG_TYD_SKIP_ID)) != -1) { LogHelper.WriteInfo(string.Format("TYD手动维护 -- {0}, skipped", app.name), ConsoleColor.Yellow); return(newVersionCount); } LogHelper.WriteInfo(string.Format("Has new version for app, name {0}, downloading...", app.name), ConsoleColor.Yellow); #endregion #region Set up App Version AppInfo appInfo = DowloadAppInfoAndResources(app.appid.ToString()); if (!string.IsNullOrEmpty(appInfo.apkurl)) { FileInfo fi = new FileInfo(Path.Combine(APK_Folder_Base, GetFileNameFromUri(appInfo.apkurl))); if (fi != null && fi.Exists) { AppVersion ver = new AppVersion { FileSize = (int)fi.Length, FileUrl = GetFileNameFromUri(appInfo.apkurl), PublishDateTime = appInfo.updatetime, Status = 1, VersionName = appInfo.apkver, Id = appInfo.versionCode.ToString() }; var originalApp = RedisService.Get <App>(a.Id); AndroidPackageView apkInfo = FileService.GetAndroidPackageInfomation(fi.FullName); apkInfo.Id = ver.Id; if (a.Status == 0) { RedisService.UpdateWithRebuildIndex <App>(originalApp, a); LogHelper.WriteInfo(string.Format("This App {0} status is invaild", a.Name), ConsoleColor.Gray); } RedisService.SetSubModel <App, AppVersion>(a.Id, ver); RedisService.SetSubModel <App, AndroidPackageView>(a.Id, apkInfo); AppStoreUIService.SetAppCurrentTestVersion(a.Id, ver.Id); AppStoreUIService.PublishAppVersion(a.Id); } } #endregion #region Set up tags if (a.Status != 0) { AppStoreUIService.AddTagForApp("Valid", a.Id); } AppStoreUIService.AddTagForApp(appInfo.category, a.Id); AddMarketTag(appInfo.category, a.Id); AppStoreUIService.AddTagForApp("From_tencent", a.Id); AppStoreUIService.AddTagForApp("Live", a.Id); #endregion return(newVersionCount); }
private void SaveSDKInfos(AndroidPackageView ret, XmlNode sdkNode) { if (sdkNode != null) { ret.MinSDKVersion = Convert.ToInt32(GetValueFromXmlAttribute(sdkNode, "android:minSdkVersion", "0x0"), 16); ret.TargetSDKVersion = Convert.ToInt32(GetValueFromXmlAttribute(sdkNode, "android:targetSdkVersion", "0x0"), 16); } }
private void SaveSupportScreenInfos(AndroidPackageView ret, XmlNode screenNode) { ret.SupportScreen = new AndroidScreenView(); if (screenNode != null) { ret.SupportScreen.AnyDensity = Convert.ToInt32(GetValueFromXmlAttribute(screenNode, "android:anyDensity", "0x0"), 16) == 0 ? false : true; ret.SupportScreen.NormalScreens = Convert.ToInt32(GetValueFromXmlAttribute(screenNode, "android:normalScreens", "0x0"), 16) == 0 ? false : true; ret.SupportScreen.Resizeable = Convert.ToInt32(GetValueFromXmlAttribute(screenNode, "android:resizeable", "0x0"), 16) == 0 ? false : true; ret.SupportScreen.SmallScreens = Convert.ToInt32(GetValueFromXmlAttribute(screenNode, "android:smallScreens", "0x0"), 16) == 0 ? false : true; ret.SupportScreen.LargeScreens = Convert.ToInt32(GetValueFromXmlAttribute(screenNode, "android:largeScreens", "0x0"), 16) == 0 ? false : true; } }
private void SavePermissionNames(AndroidPackageView ret, XmlNodeList permissionNodes) { ret.Permissions = new List<string>(); if (permissionNodes != null) { foreach (XmlNode p in permissionNodes) { ret.Permissions.Add(GetValueFromXmlAttribute(p, "android:name")); } } }
public AndroidPackageView GetAndroidPackageInfomation(string filePath) { var apkToolPath = APK_TOOL; if (!File.Exists(apkToolPath)) { if (File.Exists(ResourcesFilePathHelper.APKToolPath)) { apkToolPath = ResourcesFilePathHelper.APKToolPath; } else { throw new FileNotFoundException("Can not find aapt.exe"); } } if (!File.Exists(filePath)) throw new FileNotFoundException("Can not find " + filePath); var ret = new AndroidPackageView(); var argument = string.Format(" dump xmltree \"{0}\" AndroidManifest.xml", new FileInfo(filePath).FullName); var startInfo = new ProcessStartInfo(apkToolPath, argument) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, }; using (var process = Process.Start(startInfo)) { string output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); output = RemoveBraceContent(output); var lines = output.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); var doc = GetXmlDocument(lines); SaveAndroidManifestInfo(ret, doc); } var guid = Guid.NewGuid().ToString(); const string outputDirectory = @"C:\temp\"; var tempFilePath = string.Format("{0}{1}.txt", outputDirectory, guid); if (!Directory.Exists(outputDirectory)) Directory.CreateDirectory(outputDirectory); var argumentBadging = string.Format("/c {0} dump badging \"{1}\" > {2}", apkToolPath, new FileInfo(filePath).FullName, tempFilePath); var startInfoBadging = new ProcessStartInfo("cmd.exe", argumentBadging) { CreateNoWindow = true, UseShellExecute = false, }; using (var process = Process.Start(startInfoBadging)) { process.WaitForExit(); } var badgingFileContent = this.Read(tempFilePath, Encoding.UTF8); var match = Cronus.Framework.Utilities.RegexHelper.GetMatch(badgingFileContent, PATTERN); if (match.Success) { ret.VersionName = match.Groups["vern"].Value; } if (File.Exists(tempFilePath)) File.Delete(tempFilePath); // get File md5 ret.MD5 = this.GetFileMd5(filePath); return ret; }
private void SaveFeatureNames(AndroidPackageView ret, XmlNodeList featureNodes) { ret.Features = new List<string>(); if (featureNodes != null) { foreach (XmlNode f in featureNodes) { ret.Features.Add(GetValueFromXmlAttribute(f, "android:name")); } } }
private void SaveManifestInfos(AndroidPackageView ret, XmlNode manifestNode) { if (manifestNode != null) { ret.VersionCode = Convert.ToInt32(GetValueFromXmlAttribute(manifestNode, "android:versionCode", "0x0"), 16).ToString(); ret.VersionName = GetValueFromXmlAttribute(manifestNode, "android:versionName"); ret.PackageName = GetValueFromXmlAttribute(manifestNode, "package"); } }
private void SaveAndroidManifestInfo(AndroidPackageView ret, XmlDocument doc) { var manifestNode = doc.SelectSingleNode("/manifest"); var activityNodes = doc.SelectNodes("/manifest/application/activity"); var sdkNode = doc.SelectSingleNode("/manifest/uses-sdk"); var permissionNodes = doc.SelectNodes("/manifest/uses-permission"); var screenNode = doc.SelectSingleNode("/manifest/supports-screens"); var featureNodes = doc.SelectNodes("/manifest/uses-feature"); SaveActivityNames(ret, activityNodes); SaveFeatureNames(ret, featureNodes); SavePermissionNames(ret, permissionNodes); SaveSDKInfos(ret, sdkNode); SaveSupportScreenInfos(ret, screenNode); SaveManifestInfos(ret, manifestNode); }
private void SaveActivityNames(AndroidPackageView ret, XmlNodeList activityNodes) { ret.ActivityNames = new List<string>(); if (activityNodes != null) { foreach (XmlNode a in activityNodes) { if (a.ChildNodes.Count > 0) { var intentFilterActions = a.SelectNodes("descendant::intent-filter/action"); if (intentFilterActions != null && intentFilterActions.Count > 0) { ret.ActivityNames.Add(GetValueFromXmlAttribute(a, "android:name")); } } } } }
public ActionResult NewVersionUploadForNAppProject(AppVersion model, HttpPostedFileBase appFile) { if (appFile == null) { TempData["errorMsg"] = "AppFile Required"; return RedirectToAction("NewVersionUpload", new { AppId = Request.Form["AppId"], appProjectId = Request.Form["appProjectId"], IsUpdate = Request.Form["IsUpdate"], originalVersionId = Request.Form["originalVersionId"] }); } var appId = Request.Form["AppId"]; var appProjectId = Request.Form["appProjectId"]; var app = RedisService.Get<App>(appId); var allAppVersion = RedisService.GetAllSubModelsByType<App, AppVersion>(app.Id); allAppVersion.Sort(delegate(AppVersion a, AppVersion b) { long result = (b.CreateDateTime.Ticks - a.CreateDateTime.Ticks); if (result > 0) { return 1; } else if (result == 0) { return 0; } else { return -1; } }); var newVersionNum = "1"; if (allAppVersion != null && allAppVersion.Count > 0) { newVersionNum = (allAppVersion[0].Id.ToInt32() + 1).ToString(); } var appFilePath = SaveResourceFile("AppFiles", ResourcesFilePathHelper.AppFilePath, appFile, string.Format("{0}_{1}_{2}_{3}_{4}", appProjectId, appId, Guid.NewGuid().ToString(), app.AppNo, Path.GetExtension(appFile.FileName)).NormalzieFileName()); AndroidPackageView androidPackageView = new AndroidPackageView(); string versionNum = GetVersionInfoFromAppFile(appFilePath, app.PlatformType, out androidPackageView); if (TempData["errorMsg"] != null && !string.IsNullOrWhiteSpace(TempData["errorMsg"].ToString())) { return RedirectToAction("NewVersionUpload", new { AppId = appId, appProjectId = appProjectId }); } if (!string.IsNullOrEmpty(androidPackageView.PackageName)) { versionNum = androidPackageView.VersionCode; var appProject = RedisService.Get<NAppProject>(appProjectId); var originalAppProject = CloneHelper.DeepClone<NAppProject>(appProject); if (!CanUploadPackage(androidPackageView, appProject.Id)) { TempData["errorMsg"] = string.Format("PackageName为{0}的包已存在,不能上传相同 PackageName 的软件包!", androidPackageView.PackageName); return RedirectToAction("NewVersionUpload", new { AppId = appId, appProjectId = appProjectId }); } if (!androidPackageView.PackageName.EqualsOrdinalIgnoreCase(appProject.PackageName)) { TempData["errorMsg"] = "Warning: APK package name was changed to " + androidPackageView.PackageName; } appProject.PackageName = androidPackageView.PackageName; RedisService.UpdateWithRebuildIndex<NAppProject>(originalAppProject, appProject); } model.CreateDateTime = DateTime.Now; model.FileSize = appFile.ContentLength; model.Status = 1; model.VersionName = androidPackageView == null ? string.Empty : androidPackageView.VersionName; model.Id = string.IsNullOrWhiteSpace(versionNum) ? model.Id : versionNum.ToString(); if (string.IsNullOrEmpty(model.Id)) { model.Id = newVersionNum; } var newFileName = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", appProjectId, appId, model.Id, Guid.NewGuid().ToString(), app.AppNo, Path.GetExtension(appFile.FileName)).NormalzieFileName(); var newFilePath = Path.Combine(Path.GetDirectoryName(appFilePath), newFileName); if (FileService.RenameFile(appFilePath, newFilePath)) { model.FileUrl = newFileName; } else { model.FileUrl = Path.GetFileName(appFilePath); } var existedVer = RedisService.GetSubModel<App, AppVersion>(appId, model.Id.MakeSureNotNull()); if (existedVer != null) { model.PublishDateTime = existedVer.PublishDateTime; } UIService.AddAppVersion(appId, model); if (!string.IsNullOrEmpty(androidPackageView.PackageName)) { androidPackageView.Id = model.Id; RedisService.SetSubModel<App, AndroidPackageView>(model.Id, androidPackageView); } return RedirectToAction("AppDetails", new { appProjectId = appProjectId, appId = appId }); }
private string GetVersionInfoFromAppFile(string appFilePath, int platformType, out AndroidPackageView androidPackageInfo) { string versionNum = string.Empty; androidPackageInfo = new AndroidPackageView(); if (Path.GetExtension(appFilePath).EqualsOrdinalIgnoreCase(".yll")) { try { versionNum = this.FileService.GetYllFileVersion(appFilePath).ToString(); } catch { TempData["errorMsg"] = "无法从 .yll文件获取版本信息"; } } else if (Path.GetExtension(appFilePath).EqualsOrdinalIgnoreCase(".ylc")) { // TODO: get version from .ylc file } else if (Path.GetExtension(appFilePath).EqualsOrdinalIgnoreCase(".jar")) { // TODO: get version from .jar file } else if (Path.GetExtension(appFilePath).EqualsOrdinalIgnoreCase(".apk")) { try { androidPackageInfo = this.FileService.GetAndroidPackageInfomation(appFilePath); } catch { TempData["errorMsg"] = "无法从 .apk文件获取版本信息"; } } if (platformType == (int)PlatformType.Txt) { return versionNum; } string[] allowFileTypes = AppConfigKeys.ALLOWED_FILE_TYPES.ConfigValue().Split(';'); bool isAllowed = false; foreach (var t in allowFileTypes) { if (Path.GetExtension(appFilePath).EqualsOrdinalIgnoreCase(t)) { isAllowed = true; break; } } if (!isAllowed) { TempData["errorMsg"] = string.Format("应用文件类型应该是 {0} 文件", AppConfigKeys.ALLOWED_FILE_TYPES.ConfigValue().Replace(";", " ")); } return versionNum; }
private ActionResult AppUploadForNAppProject(App model, HttpPostedFileBase appFile, HttpPostedFileBase appLogo) { if (appFile == null && string.IsNullOrEmpty(Request.Form["IsUpdate"])) { TempData["errorMsg"] = "AppFile Required"; return RedirectToAction("AppUpload", new { AppId = model.Id, appProjectId = model.AppProjectId }); } var originalApp = RedisService.Get<App>(model.Id); model.ScreenShot = originalApp.ScreenShot; model.Logo = originalApp.Logo; model.ClientLogos = originalApp.ClientLogos; model.AppProjectId = originalApp.AppProjectId; model.AppNo = originalApp.AppNo; //var CategoryId = model.CategoryName; //model.CategoryId = CategoryId; model.CategoryName = ((CategoryForApp)model.CategoryId.ToInt32()).ToString(); for (int i = 0; i < Request.Files.Count; i++) { if (Request.Files.AllKeys[i].EqualsOrdinalIgnoreCase("screenshot") && !string.IsNullOrWhiteSpace(Request.Files[i].FileName)) { var appScreenshotPath = SaveResourceFile("Screenshots", ResourcesFilePathHelper.AppScreenshotPath, Request.Files[i], string.Format("{0}_{1}_{2}", model.Id, Guid.NewGuid().ToString(), Path.GetExtension(Request.Files[i].FileName)).NormalzieFileName()); ImageInfo img = new ImageInfo() { BelongsToAppId = model.Id, FileUrl = appScreenshotPath }; RedisService.Add<ImageInfo>(img); model.ScreenShot.Add(img); } } if (appLogo != null) { var appLogoPath = SaveResourceFile("AppLogos", ResourcesFilePathHelper.AppLogoPath, appLogo, string.Format("{0}_{1}_{2}", model.Id, Guid.NewGuid().ToString(), Path.GetExtension(appLogo.FileName)).NormalzieFileName()); ImageInfo img = new ImageInfo() { BelongsToAppId = model.Id, FileUrl = appLogoPath, }; RedisService.Add<ImageInfo>(img); model.Logo = img; } model.CreateDateTime = DateTime.Now; //model.PermittedIMEIs = originalApp.PermittedIMEIs; if (!string.IsNullOrWhiteSpace(model.Summary)) { //FullTextSearchService.BuildIndexForApp(model.Id, model.Summary); } RedisService.UpdateWithRebuildIndex<App>(originalApp, model); if (model.Status > 0) { UIService.AddTagForApp(TYD.Mobile.Infrastructure.Domain.Services.AppStoreService.STATUS_VALID, model.Id); } else { UIService.DeleteTagForApp(UIService.GetTagIdByName(TYD.Mobile.Infrastructure.Domain.Services.AppStoreService.STATUS_VALID), model.Id); } if (string.IsNullOrEmpty(Request.Form["IsUpdate"])) { string versionNum = string.Empty; var appFilePath = SaveResourceFile("AppFiles", ResourcesFilePathHelper.AppFilePath, appFile, string.Format("{0}_{1}_{2}_{3}_{4}", model.AppProjectId, model.Id, Guid.NewGuid().ToString(), model.AppNo, Path.GetExtension(appFile.FileName)).NormalzieFileName()); AndroidPackageView androidPackageView = new AndroidPackageView(); versionNum = GetVersionInfoFromAppFile(appFilePath, model.PlatformType, out androidPackageView); if (TempData["errorMsg"] != null && !string.IsNullOrWhiteSpace(TempData["errorMsg"].ToString())) { return RedirectToAction("AppUpload", new { AppId = model.Id }); } if (!string.IsNullOrEmpty(androidPackageView.PackageName)) { versionNum = androidPackageView.VersionCode; var appProject = RedisService.Get<NAppProject>(model.AppProjectId); var originalAppProject = CloneHelper.DeepClone<NAppProject>(appProject); if (!CanUploadPackage(androidPackageView, appProject.Id)) { TempData["errorMsg"] = string.Format("PackageName为{0}的包已存在,不能上传相同 PackageName 的软件包!", androidPackageView.PackageName); return RedirectToAction("AppUpload", new { AppId = model.Id, appProjectId = model.AppProjectId }); } appProject.PackageName = androidPackageView.PackageName; RedisService.UpdateWithRebuildIndex<NAppProject>(originalAppProject, appProject); } AppVersion version = new AppVersion(); version.CreateDateTime = DateTime.Now; version.Id = string.IsNullOrEmpty(versionNum) ? string.IsNullOrEmpty(Request.Form["NewVersion"]) ? "10000" : Request.Form["NewVersion"] : versionNum; var newFileName = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", model.AppProjectId, model.Id, version.Id, Guid.NewGuid().ToString(), model.AppNo, Path.GetExtension(appFile.FileName)).NormalzieFileName(); var newFilePath = Path.Combine(Path.GetDirectoryName(appFilePath), newFileName); if (FileService.RenameFile(appFilePath, newFilePath)) { version.FileUrl = newFileName; } else { version.FileUrl = Path.GetFileName(appFilePath); } version.FileSize = appFile.ContentLength; //version.PublishDateTime = version.CreateDateTime; version.UpdateTypeId = Request.Form["UpdateTypes"].ToInt32(); version.Tip = Request.Form["Tip"]; version.VersionName = androidPackageView == null ? string.Empty : androidPackageView.VersionName; RedisService.SetSubModel<App, AppVersion>(model.Id, version); if (!string.IsNullOrEmpty(androidPackageView.PackageName)) { androidPackageView.Id = version.Id; RedisService.SetSubModel<App, AndroidPackageView>(model.Id, androidPackageView); } } return RedirectToAction("AppDetails", new { appProjectId = model.AppProjectId, appId = model.Id }); }