private void _AddAction4Android(Package4AI package, SMC_PackageExt ext) { if (!String.IsNullOrEmpty(ext.pe_ApplicationCode)) { string[] apps = ext.pe_ApplicationCode.Split(",".ToCharArray()); if (apps != null && apps.Length > 0) { ApplicationDao appDao = new ApplicationDao(AppConfig.mainDbKey); App4AIDao app4AIDao = new App4AIDao(AppConfig.mainDbKey); string TEMPPATH = Path.Combine(AppConfig.PackUploadFolder, "Temp"); int idx = 1; Action4AndroidDao action4AndroidDao = new Action4AndroidDao(AppConfig.mainDbKey); foreach (string appCode in apps) { if (String.IsNullOrEmpty(appCode)) continue; List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>(); pars.Add(new KeyValuePair<string, object>("[NAME]", appCode)); Application application = appDao.Get(pars); //for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++) //{ Action4Android action4Android = new Action4Android(); action4Android.Seq = idx;//Convert.ToInt32(form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.DisplayName = "";//form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.IsLaunch = true;//Convert.ToBoolean(form["ActivityLaunch_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.IconUri = "";//GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), form["ActivityIco_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.ShortName = "";//form["ActivityShortName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.Name = "";//form["ActivityName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.CreateTime = DateTime.Now; action4Android.UpdateTime = DateTime.Now; action4Android.CreateUid = "";//CurrentUser.UserUId; action4Android.UpdateUid = "";//CurrentUser.UserUId; action4AndroidDao.Insert(action4Android); //} ++idx; } } } }
public JsonResult CreateApplicationPackage(FormCollection form) { JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" }; Package4AI package = new Package4AI(); Hashtable extentInfo = new Hashtable(); try { package.CreateUid = CurrentUser.UserUId; package.UpdateUid = CurrentUser.UserUId; package.CreateTime = DateTime.Now; package.UpdateTime = DateTime.Now; package.DownloadUri = form["packageFileName"]; package.Name = form["packageName"]; package.DisplayName = form["packageDisplayName"]; package.ClientType = form["packageClientType"]; package.Type = form["packageType"]; package.Version = form["packageVersion"]; package.BuildVer = Convert.ToInt32(form["packageBuildVer"]); package.Description = form["packageDescription"]; List<KeyValuePair<string, object>> _pars = new List<KeyValuePair<string, object>>(); _pars.Add(new KeyValuePair<string, object>("Name", package.Name)); _pars.Add(new KeyValuePair<string, object>("ClientType", package.ClientType)); Package4AI pai = BoFactory.GetPackage4AIBO.Get(_pars); if (pai != null) { throw new ArgumentException("不能发布重复的包"); } SMC_PackageExt packageExt = new SMC_PackageExt(); List<Hashtable> applications = new List<Hashtable>(); extentInfo["Applications"] = applications; for (int appIndex = 0; appIndex < Convert.ToInt32(form["applicationCount"]); appIndex++) { Hashtable application = new Hashtable(); applications.Add(application); Hashtable AppIcons = new Hashtable(); application["ApplicationIcon"] = AppIcons; App4AI app4AI = new App4AI(); if (!"".Equals(form["AppCode_" + appIndex.ToString()])) { app4AI.AppID = Convert.ToInt32(form["AppCode_" + appIndex.ToString()]); } app4AI.AppCode = form["AppName_" + appIndex.ToString()]; packageExt.pe_ApplicationCode += app4AI.AppCode + ","; List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>(); KeyValuePair<string, object> par = new KeyValuePair<string, object>("Name", app4AI.AppCode); pars.Add(par); Application app = BoFactory.GetApplicationBO.Get(pars); string applicationName = ""; if (app != null) applicationName = app.DisplayName; packageExt.pe_ApplicationName += applicationName + ","; app4AI.ClientType = form["AppCheckClentType_" + appIndex.ToString()]; application["ApplicationID"] = form["AppCode_" + appIndex.ToString()]; AppIcons["AppIconName"] = form["AppIco_" + appIndex.ToString()]; //AppIcons.Add(new Tuple<string, string, object>("ApplicationID", form["AppCode_" + appIndex.ToString()], form["AppIco_" + appIndex.ToString()])); app4AI.IconUri = GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), form["AppIco_" + appIndex.ToString()]); AppIcons["AppIconUri"] = app4AI.IconUri; app4AI.Seq = appIndex + 1; app4AI.CreateTime = DateTime.Now; app4AI.UpdateTime = DateTime.Now; app4AI.CreateUid = CurrentUser.UserUId; app4AI.UpdateUid = CurrentUser.UserUId; List<Hashtable> activities = new List<Hashtable>(); application["activities"] = activities; for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++) { Action4Android action4Android = new Action4Android(); action4Android.Seq = Convert.ToInt32(form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.DisplayName = form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.IsLaunch = Convert.ToBoolean(form["ActivityLaunch_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.IconUri = GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), form["ActivityIco_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.ShortName = form["ActivityShortName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.Name = form["ActivityName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.CreateTime = DateTime.Now; action4Android.UpdateTime = DateTime.Now; action4Android.CreateUid = CurrentUser.UserUId; action4Android.UpdateUid = CurrentUser.UserUId; Hashtable activity = new Hashtable(); activity["DisplayName"] = form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; activity["ActivitySeq"] = form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; activity["IsLaunch"] = action4Android.IsLaunch; activity["IconUri"] = action4Android.IconUri; activity["ShortName"] = action4Android.ShortName; activity["Name"] = action4Android.Name; activity["CreateTime"] = action4Android.CreateTime; activity["UpdateTime"] = action4Android.UpdateTime; activity["CreateUid"] = action4Android.CreateUid; activity["UpdateUid"] = action4Android.UpdateUid; activities.Add(activity); app4AI.ActionList.Add(action4Android); } package.App4AIList.Add(app4AI); } string saveFileName = string.Format("{0}_v{1}_{2}{3}", package.Name, package.BuildVer, DateTime.Now.ToString("yyyyMMddHHmmss"), Path.GetExtension(package.DownloadUri)); string tempFilePath = Path.Combine(TEMPPATH, package.DownloadUri); string saveFilePath = Path.Combine(SAVEPATH, saveFileName); if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase)) { var mainConfig = AppConfig.PublishConfig.GetValue(package.ClientType); if (package.ClientType.EndsWith("ios", StringComparison.CurrentCultureIgnoreCase)) { mainConfig.Url = IOS_URL_PREFIX + mainConfig.Url; } package.DownloadUri = mainConfig.Url; saveFilePath = mainConfig.Path; } else { package.DownloadUri = Path.Combine(AppConfig.PackUrl, saveFileName); } GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth"); packageExt.pe_id = BoFactory.GetVersionTrackBo.GetMaxPackageExtId() + 1; packageExt.pe_ExtentInfo = Newtonsoft.Json.JsonConvert.SerializeObject(extentInfo); if (parm.ConfigValue == "0") { //不需要审核 BoFactory.GetVersionTrackBo.InsertPackage4AI(package, tempFilePath, saveFilePath); packageExt.pe_UsefulStstus = "1";//上架状态 packageExt.pe_UsefulTime = DateTime.Now; packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId; packageExt.pe_UsefulOperatorName = CurrentUser.UnitName; packageExt.pe_AuthStatus = 1;//审核通过 packageExt.pe_AuthTime = DateTime.Now; packageExt.pe_AuthSubmitName = CurrentUser.FullName; packageExt.pe_AuthSubmitUID = CurrentUser.UserUId; packageExt.pe_AuthManUID = CurrentUser.UserUId; packageExt.pe_AuthMan = CurrentUser.FullName; packageExt.pe_SyncStatus = 0; packageExt.pe_Direction = "发布"; packageExt.pe_AuthSubmitTime = DateTime.Now; } else { string serializationPath = Server.MapPath("~/PackageSerialization/") + packageExt.pe_id + "/"; if (!Directory.Exists(serializationPath)) Directory.CreateDirectory(serializationPath); using (Stream fStream = new FileStream(serializationPath + "package.xml", FileMode.Create, FileAccess.ReadWrite)) { XmlSerializer xmlFormat = new XmlSerializer(typeof(Package4AI)); xmlFormat.Serialize(fStream, package); fStream.Close(); fStream.Dispose(); } XmlDocument xmlDoc = new XmlDocument(); string content = String.Format("<PackagePath><TempFilePath>{0}</TempFilePath><SaveFileName>{1}</SaveFileName></PackagePath>", tempFilePath, saveFilePath); xmlDoc.LoadXml(content); xmlDoc.Save(serializationPath + "path.xml"); //审核通过后再同步到Package4AI表 packageExt.pe_UsefulStstus = "0";//上架状态 packageExt.pe_Direction = "上架"; packageExt.pe_AuthStatus = 0;//待审核 packageExt.pe_AuthSubmitTime = DateTime.Now; packageExt.pe_AuthSubmitName = CurrentUser.FullName; packageExt.pe_AuthSubmitUID = CurrentUser.UserUId; packageExt.pe_Direction = "发布"; packageExt.pe_UsefulTime = DateTime.Now; packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId; packageExt.pe_UsefulOperatorName = CurrentUser.FullName; System.IO.File.Copy(tempFilePath, saveFilePath, true); } //插入扩展表 packageExt.pe_ClientType = package.ClientType; var s1 = form["IsRecom"]; var s2 = form["IsMust"]; packageExt.pe_IsTJ = form["IsRecom"]; packageExt.pe_IsBB = form["IsMust"]; FileInfo fi = new FileInfo(saveFilePath); packageExt.pe_Size = (int)fi.Length; packageExt.TableName = "Package4AI"; packageExt.TableID = package.ID; packageExt.pe_UnitCode = form["Unit"]; packageExt.pe_CategoryID = form["AppID"]; packageExt.pe_Category = BoFactory.GetVersionTrackBo.GetApplicationCategory(form["AppID"]).DisplayName; packageExt.pe_UnitName = BoFactory.GetSMC_UnitBo.Get(packageExt.pe_UnitCode).Unit_Name; packageExt.pe_CreateUid = CurrentUser.UserUId; packageExt.pe_CreatedTime = DateTime.Now; packageExt.pe_UpdateUid = CurrentUser.UserUId; packageExt.pe_UpdateTime = DateTime.Now; packageExt.pe_Version = form["packageVersion"]; packageExt.pe_BuildVer = form["packageBuildVer"]; packageExt.pe_Name = form["packageDisplayName"]; packageExt.pe_DisplayName = form["packageDisplayName"]; packageExt.pe_Description = form["packageDescription"]; packageExt.pe_Firmware = form["Firmware"]; packageExt.pe_Type = package.Type; string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径 string pDir = Path.Combine(SAVEOUTPATH, packageExt.pe_id.ToString());//相对路径 用安装包ID做文件夹名 string saveDir = Path.Combine(conSolePath, pDir); if (!System.IO.Directory.Exists(saveDir)) { System.IO.Directory.CreateDirectory(saveDir); } //生成下载url,并生成二维码 string url = package.DownloadUri; string pe_2dPictureUrl = Save2DPicture(packageExt.pe_id, url); //保存安装包 string packageName = "Package4AI-" + Path.GetFileName(tempFilePath); string packageFilePath = System.IO.Path.Combine(saveDir, packageName); System.IO.File.Copy(saveFilePath, packageFilePath, true); packageExt.pe_FileUrl = "~/PackageExt/" + packageExt.pe_id + "/" + packageName; packageExt.pe_2dPictureUrl = pe_2dPictureUrl;// @"~/" + pDir + "/二维码图片.jpeg"; //packageExt.pe_2dPictureUrl = packageExt.pe_2dPictureUrl.Replace(@"\\", "/"); packageExt.pe_DownloadUri = url.Replace(@"\", "/"); int i = Request.Files.Count; string iconSavePath = ""; if (i > 0) { //保存安装包图标 HttpPostedFileBase icon = Request.Files[0]; string iconFileName = "AppIcon.png"; iconSavePath = System.IO.Path.Combine(saveDir, iconFileName); if (System.IO.File.Exists(iconSavePath)) { System.IO.File.Delete(iconSavePath); } icon.SaveAs(iconSavePath); packageExt.pe_PictureUrl = @"~/" + pDir + "/AppIcon.png"; packageExt.pe_PictureUrl = packageExt.pe_PictureUrl.Replace(@"\\", "/"); } BoFactory.GetVersionTrackBo.InsertPackageExt(packageExt); if (parm.ConfigValue == "0") { //不需要审核,直接同步到应用中心 //同步至外网数据 _SyncPackageExt(packageExt); } if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase)) { try { //更新server缓存 SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient(); cli.ResetClientVer(); } catch { data.Msg = "操作成功,更新SmartBox服务缓存失败。"; } } //app更新到外网 BoFactory.GetCommonBO.CopyAppFilesToAppCenterServer(saveFilePath, packageExt.pe_id); #region pad布局检查 if (package.ClientType.StartsWith("Pad", StringComparison.CurrentCultureIgnoreCase)) { PageView view = new PageView(); view.PageSize = 15; view.PageIndex = 0; int HomePlans = BoFactory.GetVersionTrackBo.QueryHomePlanList(view).rows.Count; if (HomePlans < 1) { data.Msg += " \n没有页面布局,请在Home布局管理中增加."; } } #endregion } catch (Exception ex) { Log4NetHelper.Error(ex); data.IsSuccess = false; data.Msg = ex.Message; } return Json(data, "text/html"); }
private Package4AI ReadIOSPackage(string tempPackagePath) { XmlDocument xml = new XmlDocument(); XmlDocument plist = new XmlDocument(); using (ZipFile zip = new ZipFile(tempPackagePath)) { const string IPHONEPLIST = "Info.plist"; const string IPHONEXML = "package.xml"; ZipEntry zipXML = null; ZipEntry zipPlist = null; foreach (ZipEntry item in zip) { string[] filename = item.Name.Split('/'); if (filename.Length == 3 && filename[2].Equals(IPHONEPLIST, StringComparison.CurrentCultureIgnoreCase)) { zipPlist = item; } else if (IPHONEXML.Equals(filename[filename.Length - 1], StringComparison.CurrentCultureIgnoreCase)) { zipXML = item; } if (zipXML != null && zipPlist != null) { break; } } if (zipXML == null) { throw new Exception("安装包中未找到package.xml文件!,请上传正确的安装包!"); } if (zipPlist == null) { throw new Exception("安装包中未找到Info.plist文件!,请上传正确的安装包!"); } Stream xmlStream = zip.GetInputStream(zipXML); xml.LoadXml(ConvertPlist.ConvertPlist.plist2xml(xmlStream)); Stream plistStream = zip.GetInputStream(zipPlist); var plistXml = ConvertPlist.ConvertPlist.plist2xml(plistStream); using (var reader = new StringReader(plistXml)) { XmlReaderSettings xs = new XmlReaderSettings(); xs.XmlResolver = null; xs.ProhibitDtd = false; plist.Load(XmlReader.Create(reader, xs)); } } XmlNode xmlPackage = xml.GetElementsByTagName("package")[0]; XmlNode buildVer = plist.SelectSingleNode("/plist/dict/key[.='CFBundleVersion']"); XmlNode version = plist.SelectSingleNode("/plist/dict/key[.='CFBundleShortVersionString']"); Package4AI package = new Package4AI(); package.CreateUid = CurrentUser.UserUId; package.UpdateUid = CurrentUser.UserUId; package.CreateTime = DateTime.Now; package.UpdateTime = DateTime.Now; package.DownloadUri = Path.GetFileName(tempPackagePath); package.Description = xmlPackage.Attributes["description"] != null ? xmlPackage.Attributes["description"].Value : string.Empty; package.DisplayName = xmlPackage.Attributes["displayName"] != null ? xmlPackage.Attributes["displayName"].Value : string.Empty; if (xmlPackage.Attributes["name"] == null) { throw new Exception("未找到安装包客户端名称,请上传正确的安装包!"); } package.Name = xmlPackage.Attributes["name"].Value; if (xmlPackage.Attributes["clientType"] == null) { throw new Exception("未找到安装包客户端类型,请上传正确的安装包!"); } package.ClientType = xmlPackage.Attributes["clientType"].Value; if (xmlPackage.Attributes["type"] == null) { throw new Exception("未找到安装包类型,请上传正确的安装包!"); } package.Type = xmlPackage.Attributes["type"].Value; package.Version = version != null ? version.NextSibling.InnerText : string.Empty; if (buildVer == null) { throw new Exception("未找到内部版本号,请上传正确的安装包!"); } int _buildVer = Convert.ToInt32(float.Parse(buildVer.NextSibling.InnerText)); package.BuildVer = _buildVer; foreach (XmlNode application in xml.GetElementsByTagName("application")) { App4AI app4AI = new App4AI(); app4AI.AppCode = application.Attributes["name"] != null ? application.Attributes["name"].Value : string.Empty; app4AI.ClientType = application.Attributes["type"] != null ? application.Attributes["type"].Value : package.ClientType; app4AI.IconUri = application.Attributes["ico"] != null ? application.Attributes["ico"].Value : string.Empty; app4AI.AppName = application.Attributes["code"] != null ? application.Attributes["code"].Value : string.Empty; app4AI.Seq = 1; app4AI.CreateTime = DateTime.Now; app4AI.UpdateTime = DateTime.Now; app4AI.CreateUid = CurrentUser.UserUId; app4AI.UpdateUid = CurrentUser.UserUId; foreach (XmlNode action in application.SelectNodes("activity/action")) { Action4Android action4Android = new Action4Android(); action4Android.Seq = action.Attributes["sort"] != null ? Convert.ToInt32(action.Attributes["sort"].Value) : 1; action4Android.DisplayName = action.Attributes["label"] != null ? action.Attributes["label"].Value : string.Empty; action4Android.IsLaunch = action.Attributes["isLaunch"] != null ? Convert.ToBoolean(action.Attributes["isLaunch"].Value) : false; action4Android.IconUri = action.Attributes["ico"] != null ? action.Attributes["ico"].Value : string.Empty; action4Android.ShortName = action.Attributes["shortName"] != null ? action.Attributes["shortName"].Value : string.Empty; action4Android.Name = action.Attributes["name"] != null ? action.Attributes["name"].Value : string.Empty; app4AI.ActionList.Add(action4Android); } package.App4AIList.Add(app4AI); } return package; }
private Package4AI ReadAndroidPackage(string tempPackagePath) { XmlDocument xmlPlugin = new XmlDocument(); const string ANDROID = "assets/plugin.xml"; using (ZipFile zip = new ZipFile(tempPackagePath)) { ZipEntry zipPlugin = zip.GetEntry(ANDROID); if (zipPlugin == null) { throw new Exception("请检查上传的包是否是内部app!"); } Stream stream = zip.GetInputStream(zipPlugin); xmlPlugin.Load(stream); } XmlNode xmlPackage = xmlPlugin.GetElementsByTagName("package")[0]; Package4AI package = new Package4AI(); package.CreateUid = CurrentUser.UserUId; package.UpdateUid = CurrentUser.UserUId; package.CreateTime = DateTime.Now; package.UpdateTime = DateTime.Now; package.DownloadUri = Path.GetFileName(tempPackagePath); package.Description = xmlPackage.Attributes["description"] != null ? xmlPackage.Attributes["description"].Value : string.Empty; package.DisplayName = xmlPackage.Attributes["displayName"] != null ? xmlPackage.Attributes["displayName"].Value : string.Empty; if (xmlPackage.Attributes["name"] == null) { throw new Exception("未找到安装包客户端名称,请上传正确的安装包!"); } package.Name = xmlPackage.Attributes["name"].Value; if (xmlPackage.Attributes["clientType"] == null) { throw new Exception("未找到安装包客户端类型,请上传正确的安装包!"); } package.ClientType = xmlPackage.Attributes["clientType"].Value; if (xmlPackage.Attributes["type"] == null) { throw new Exception("未找到安装包类型,请上传正确的安装包!"); } package.Type = xmlPackage.Attributes["type"].Value; package.Version = xmlPackage.Attributes["ver"] != null ? xmlPackage.Attributes["ver"].Value : string.Empty; if (xmlPackage.Attributes["buildver"] == null) { throw new Exception("未找到内部版本号,请上传正确的安装包!"); } package.BuildVer = Convert.ToInt32(xmlPackage.Attributes["buildver"].Value); foreach (XmlNode application in xmlPlugin.GetElementsByTagName("application")) { App4AI app4AI = new App4AI(); app4AI.AppName = application.Attributes["code"] != null ? application.Attributes["code"].Value : string.Empty; app4AI.AppCode = application.Attributes["name"] != null ? application.Attributes["name"].Value : string.Empty; app4AI.ClientType = package.ClientType; app4AI.IconUri = application.Attributes["ico"] != null ? BoFactory.GetCommonBO.GetAndroidApplicationIcoUri(tempPackagePath, application.Attributes["ico"].Value) : string.Empty; app4AI.Seq = 1; app4AI.CreateTime = DateTime.Now; app4AI.UpdateTime = DateTime.Now; app4AI.CreateUid = CurrentUser.UserUId; app4AI.UpdateUid = CurrentUser.UserUId; foreach (XmlNode action in application.SelectNodes("activity/action")) { Action4Android action4Android = new Action4Android(); action4Android.Seq = action.Attributes["sort"] != null ? Convert.ToInt32(action.Attributes["sort"].Value) : 1; action4Android.DisplayName = action.Attributes["label"] != null ? action.Attributes["label"].Value : string.Empty; action4Android.IsLaunch = action.Attributes["isLaunch"] != null ? Convert.ToBoolean(action.Attributes["isLaunch"].Value) : false; action4Android.IconUri = action.Attributes["ico"] != null ? BoFactory.GetCommonBO.GetAndroidApplicationIcoUri(tempPackagePath, action.Attributes["ico"].Value) : string.Empty; action4Android.ShortName = action.Attributes["shortName"] != null ? action.Attributes["shortName"].Value : string.Empty; action4Android.Name = action.Attributes["name"] != null ? action.Attributes["name"].Value : string.Empty; app4AI.ActionList.Add(action4Android); } package.App4AIList.Add(app4AI); } return package; }
public JsonResult UpdatePackage(FormCollection form) { JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" }; Package4AI package = new Package4AI(); SMC_PackageExtHistory history = new SMC_PackageExtHistory(); package.CreateUid = form["packageCreateUser"]; package.UpdateUid = CurrentUser.UserUId; package.CreateTime = Convert.ToDateTime(form["packageCreateDateTime"]); package.UpdateTime = DateTime.Now; package.DownloadUri = form["packageFileName"]; package.Name = form["packageName"]; package.DisplayName = form["packageDisplayName"]; package.ClientType = form["packageClientType"]; package.Type = form["packageType"]; package.Version = form["packageVersion"]; package.BuildVer = Convert.ToInt32(form["packageBuildVer"]); package.Description = form["packageDescription"]; package.ID = Convert.ToInt32(form["packageID"]); SMC_PackageExt ext = BoFactory.GetAppCenterBO.GetPackageExt(package.ID); string tableName = ext.TableName.ToLower(); if (tableName != "webapplication" && tableName != "smc_package4out") { package.ID = ext.TableID; } for (int appIndex = 0; appIndex < Convert.ToInt32(form["applicationCount"]); appIndex++) { App4AI app4AI = new App4AI(); if (!"".Equals(form["AppCode_" + appIndex.ToString()])) { app4AI.AppID = Convert.ToInt32(form["AppCode_" + appIndex.ToString()]); } app4AI.AppCode = form["AppName_" + appIndex.ToString()]; app4AI.ClientType = form["AppCheckClentType_" + appIndex.ToString()]; app4AI.IconUri = form["AppIco_" + appIndex.ToString()]; app4AI.Seq = 1; app4AI.CreateTime = package.CreateTime; app4AI.UpdateTime = DateTime.Now; app4AI.CreateUid = package.CreateUid; app4AI.UpdateUid = CurrentUser.UserUId; for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++) { Action4Android action4Android = new Action4Android(); action4Android.Seq = Convert.ToInt32(form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.DisplayName = form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.IsLaunch = Convert.ToBoolean(form["ActivityLaunch_" + appIndex.ToString() + "_" + activtyIndex.ToString()]); action4Android.IconUri = form["ActivityIco_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.ShortName = form["ActivityShortName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.Name = form["ActivityName_" + appIndex.ToString() + "_" + activtyIndex.ToString()]; action4Android.CreateTime = package.CreateTime; action4Android.UpdateTime = DateTime.Now; action4Android.CreateUid = package.CreateUid; action4Android.UpdateUid = CurrentUser.UserUId; app4AI.Package4AIID = package.ID; action4Android.App4AIID = package.ID; Action4Android a4a = BoFactory.GetAction4AndroidBO.Get(action4Android.Name); if (a4a == null) app4AI.ActionList.Add(action4Android); } IList<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>(); pars.Add(new KeyValuePair<string, object>("Package4AIID", app4AI.Package4AIID)); pars.Add(new KeyValuePair<string, object>("AppCode", app4AI.AppCode)); pars.Add(new KeyValuePair<string, object>("ClientType", app4AI.ClientType)); App4AI _app4ai = BoFactory.GetApp4AIBO.Get(pars); if (_app4ai == null) { package.App4AIList.Add(app4AI); } else { _app4ai.AppID = app4AI.AppID; BoFactory.GetApp4AIBO.Update(_app4ai); } } try { string saveFileName = string.Format("{0}_v{1}_{2}{3}", package.Name, package.BuildVer, DateTime.Now.ToString("yyyyMMddHHmmss"), Path.GetExtension(package.DownloadUri)); string tempFilePath = Path.Combine(TEMPPATH, package.DownloadUri); string saveFilePath = Path.Combine(SAVEPATH, saveFileName); if (package.ClientType.EndsWith("ios", StringComparison.CurrentCultureIgnoreCase)) { string padUrl = string.Empty; string phoneUrl = string.Empty; Common.Configuration.IOSConfiguration iosConfig = (Common.Configuration.IOSConfiguration)System.Configuration.ConfigurationManager.GetSection("PublishConfig"); if (iosConfig != null && iosConfig.IOSPublishs != null) { foreach (Common.Configuration.IOSPublishElement item in iosConfig.IOSPublishs) { if (item.ClientType.StartsWith("Pad/iOS", StringComparison.CurrentCultureIgnoreCase)) padUrl = item.Url; if (item.ClientType.StartsWith("Phone/iOS", StringComparison.CurrentCultureIgnoreCase)) phoneUrl = item.Url; } } if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase)) { if (package.ClientType.StartsWith("Pad", StringComparison.CurrentCultureIgnoreCase)) { package.DownloadUri = @"itms-services://?action=download-manifest&url=" + padUrl; } else if (package.ClientType.StartsWith("Phone", StringComparison.CurrentCultureIgnoreCase)) { package.DownloadUri = @"itms-services://?action=download-manifest&url=" + phoneUrl; } } } else { string padUrl = string.Empty; string phoneUrl = string.Empty; Common.Configuration.IOSConfiguration iosConfig = (Common.Configuration.IOSConfiguration)System.Configuration.ConfigurationManager.GetSection("PublishConfig"); if (iosConfig != null && iosConfig.IOSPublishs != null) { foreach (Common.Configuration.IOSPublishElement item in iosConfig.IOSPublishs) { if (item.ClientType.StartsWith("Pad/Android", StringComparison.CurrentCultureIgnoreCase)) padUrl = item.Url; if (item.ClientType.StartsWith("Phone/Android", StringComparison.CurrentCultureIgnoreCase)) phoneUrl = item.Url; } } if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase)) { package.DownloadUri = Path.Combine(AppConfig.PackUrl, saveFileName); } } SMC_PackageExt _ext = BoFactory.GetAppCenterBO.GetPackage("Package4AI", package.ID.ToString()); _ext.pe_LastVersion = _ext.pe_Version; _ext.pe_Version = package.Version; _ext.pe_FileUrl = "~/PackageExt/" + _ext.pe_id + "/" + Path.GetFileName(tempFilePath); GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth"); if (parm.ConfigValue != "0") { string serializationPath = Server.MapPath("~/PackageSerialization/") + _ext.pe_id + "/"; if (!Directory.Exists(serializationPath)) Directory.CreateDirectory(serializationPath); using (Stream fStream = new FileStream(serializationPath + "package.xml", FileMode.Create, FileAccess.ReadWrite)) { XmlSerializer xmlFormat = new XmlSerializer(typeof(Package4AI)); xmlFormat.Serialize(fStream, package); fStream.Close(); fStream.Dispose(); } XmlDocument xmlDoc = new XmlDocument(); string content = String.Format("<PackagePath><TempFilePath>{0}</TempFilePath><SaveFileName>{1}</SaveFileName></PackagePath>", tempFilePath, saveFilePath); xmlDoc.LoadXml(content); xmlDoc.Save(serializationPath + "path.xml"); //审核通过后再同步到Package4AI表 _ext.pe_UsefulStstus = "0";//上架状态 _ext.pe_AuthStatus = 0; _ext.pe_AuthSubmitName = CurrentUser.FullName; _ext.pe_AuthSubmitTime = DateTime.Now; _ext.pe_AuthSubmitUID = CurrentUser.UserUId; _ext.pe_UsefulTime = DateTime.Now; _ext.pe_UsefulOperatorUID = CurrentUser.UserUId; _ext.pe_UsefulOperatorName = CurrentUser.FullName; if (package.ClientType.ToLower().IndexOf("ios") != -1) _ext.pe_DownloadUri = package.DownloadUri; } _ext.pe_Version = form["packageVersion"]; _ext.pe_BuildVer = form["packageBuildVer"]; Bo.BoFactory.GetSMC_PackageExtBO.Save(_ext); if (parm.ConfigValue == "0") { //不需要审核,直接同步到应用中心 //同步至外网数据 BoFactory.GetVersionTrackBo.UpdatePackage(package, tempFilePath, saveFilePath); _ext.pe_UsefulStstus = "1";//上架状态 _ext.pe_UsefulTime = DateTime.Now; _ext.pe_UsefulOperatorUID = CurrentUser.UserUId; _ext.pe_UsefulOperatorName = CurrentUser.FullName; _ext.pe_AuthStatus = 1;//审核通过 _ext.pe_AuthTime = DateTime.Now; _ext.pe_AuthManUID = CurrentUser.UserUId; _ext.pe_AuthMan = CurrentUser.FullName; _ext.pe_DownloadUri = ConfigurationManager.AppSettings["packUrl"] + saveFileName; if (package.ClientType.ToLower().IndexOf("ios") != -1) _ext.pe_DownloadUri = package.DownloadUri; //内部发布到Package4AI BoFactory.GetCommonBO.SMC_PackageExtInternalRelease(_ext); //同步到应用中心 _SyncPackageExt(_ext); } #region 上传文件自动发布 if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase)) { //更新server缓存 try { SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient(); cli.ResetClientVer(); } catch { data.Msg = "操作成功,更新Server缓存失败。如遇到未提示版本更新问题请联系管理员重启服务。"; } } #endregion } catch (Exception ex) { Log4NetHelper.Error(ex); data.IsSuccess = false; data.Msg = ex.Message; } return Json(data); }
public JsonResult EditApplicationPackage(FormCollection form) { Package4AI package = new Package4AI(); package.UpdateUid = CurrentUser.UserUId; package.UpdateTime = DateTime.Now; package.CreateUid = form["packageCreateUser"]; package.CreateTime = Convert.ToDateTime(form["packageCreateDateTime"]); package.ID = Convert.ToInt32(form["packageID"]); package.DownloadUri = form["packageDownloadUrl"]; package.Name = form["packageName"]; package.DisplayName = form["packageDisplayName"]; package.ClientType = form["packageClientType"]; package.Type = form["packageType"]; package.Version = form["packageVersion"]; package.BuildVer = Convert.ToInt32(form["packageBuildVer"]); package.Description = form["packageDescription"]; for (int appIndex = 0; appIndex < Convert.ToInt32(form["applicationCount"]); appIndex++) { string appIndexStr = appIndex.ToString(); App4AI app4AI = new App4AI(); app4AI.ID = Convert.ToInt32(form["AppID_" + appIndexStr]); if (!"".Equals(form["AppCode_" + appIndexStr])) { app4AI.AppID = Convert.ToInt32(form["AppCode_" + appIndexStr]); } app4AI.AppCode = form["AppName_" + appIndexStr]; app4AI.ClientType = form["AppCheckClentType_" + appIndexStr]; app4AI.IconUri = form["AppIco_" + appIndexStr]; app4AI.Seq = Convert.ToInt32(form["AppSeq_" + appIndexStr]); app4AI.Package4AIID = Convert.ToInt32(form["AppPackageID_" + appIndexStr]); app4AI.PackageName = form["AppPackageName_" + appIndexStr]; app4AI.CreateTime = Convert.ToDateTime(form["AppCreateDateTime_" + appIndexStr]); app4AI.CreateUid = form["AppCreateUser_" + appIndexStr]; app4AI.UpdateTime = DateTime.Now; app4AI.UpdateUid = CurrentUser.UserUId; for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++) { string activtyIndexStr = activtyIndex.ToString(); Action4Android action4Android = new Action4Android(); action4Android.App4AIID = Convert.ToInt32(form["ActivityAppID_" + appIndexStr + "_" + activtyIndexStr]); action4Android.Seq = Convert.ToInt32(form["ActivitySeq_" + appIndexStr + "_" + activtyIndexStr]); action4Android.DisplayName = form["ActivityDisplayName_" + appIndexStr + "_" + activtyIndexStr]; action4Android.IsLaunch = Convert.ToBoolean(form["ActivityLaunch_" + appIndexStr + "_" + activtyIndexStr]); action4Android.IconUri = form["ActivityIco_" + appIndexStr + "_" + activtyIndexStr]; action4Android.ShortName = form["ActivityShortName_" + appIndexStr + "_" + activtyIndexStr]; action4Android.Name = form["ActivityName_" + appIndexStr + "_" + activtyIndexStr]; action4Android.CreateTime = Convert.ToDateTime(form["ActivityCreateDateTime_" + appIndexStr + "_" + activtyIndexStr]); action4Android.UpdateTime = DateTime.Now; action4Android.CreateUid = form["ActivityCreateUser_" + appIndexStr + "_" + activtyIndexStr]; action4Android.UpdateUid = CurrentUser.UserUId; app4AI.ActionList.Add(action4Android); } package.App4AIList.Add(app4AI); } JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" }; //package数据 string pe_id = BoFactory.GetVersionTrackBo.GetPeId(package.ID.ToString(), "Package4AI"); SMC_PackageExt pe = BoFactory.GetVersionTrackBo.GetPackageExt(pe_id); pe.pe_UpdateUid = CurrentUser.UserUId; pe.pe_UpdateTime = DateTime.Now; pe.pe_IsTJ = form["pe_IsTJ"]; pe.pe_IsBB = form["pe_IsBB"]; pe.pe_CategoryID = form["AppID"]; pe.pe_Category = BoFactory.GetVersionTrackBo.GetApplicationCategory(form["AppID"]).DisplayName; pe.pe_UnitCode = form["Unit"]; pe.pe_Name = package.Name; pe.pe_DisplayName = package.DisplayName; SMC_Unit unit = BoFactory.GetSMC_UnitBo.Get(pe.pe_UnitCode); package.DownloadUri = pe.pe_DownloadUri; if (unit != null && !string.IsNullOrEmpty(unit.Unit_Name)) { pe.pe_UnitName = unit.Unit_Name; } try { BoFactory.GetVersionTrackBo.UpdatePackage4AI(package); BoFactory.GetVersionTrackBo.UpdatePackageExt(pe); } catch (Exception ex) { Log4NetHelper.Error(ex); data.IsSuccess = false; data.Msg = ex.Message; } return Json(data); }