public virtual void InsertPackageExt(SMC_PackageExt packageExt) { packageExtDao.Insert(packageExt); }
public virtual void UpdatePackageExt(SMC_PackageExt packageExt) { packageExtDao.Update(packageExt); }
public JsonResult EditWebApplication(WebApplication webApplication, string pe_IsTJ, string pe_IsBB, string id) { JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" }; webApplication.UpdateTime = DateTime.Now; webApplication.UpdateUid = CurrentUser.UserUId; try { if (string.IsNullOrEmpty(Convert.ToString(webApplication.ID)) || webApplication.ID == 0) {//新增 webApplication.CreateTime = DateTime.Now; webApplication.CreateUid = CurrentUser.UserUId; BoFactory.GetVersionTrackBo.InsertWebApplication(webApplication); //插入packageExt SMC_PackageExt pe = new SMC_PackageExt(); pe.pe_id = BoFactory.GetVersionTrackBo.GetMaxPackageExtId() + 1; pe.pe_IsTJ = pe_IsTJ; pe.pe_IsBB = pe_IsBB; pe.pe_PictureUrl = webApplication.IconUri; pe.pe_ClientType = webApplication.ClientType; pe.pe_DownloadUri = webApplication.Uri; pe.TableName = "WebApplication"; pe.TableID = webApplication.ID; pe.pe_UnitCode = webApplication.Unit; pe.pe_ApplicationCode = Request.Form["ApplicationID"]; if (!String.IsNullOrEmpty(pe.pe_ApplicationCode)) { string[] appIds = pe.pe_ApplicationCode.Split(",".ToCharArray()); string appNames = ""; foreach (string appid in appIds) { Application application = Bo.BoFactory.GetVersionTrackBo.GetApplication(appid); if (application != null) { appNames += application.DisplayName + ","; } } pe.pe_ApplicationName = appNames; } pe.pe_UnitName = BoFactory.GetSMC_UnitBo.Get(pe.pe_UnitCode).Unit_Name; pe.pe_CreatedTime = webApplication.CreateTime; pe.pe_CreateUid = webApplication.CreateUid; pe.pe_UpdateTime = webApplication.UpdateTime; pe.pe_LastVersion = ""; pe.pe_Version = ""; pe.pe_BuildVer = ""; pe.pe_Type = "web"; pe.pe_CategoryID = webApplication.AppID.ToString(); pe.pe_ClientType = webApplication.ClientType; pe.pe_Category = BoFactory.GetVersionTrackBo.GetApplicationCategory(webApplication.AppID.ToString()).DisplayName; pe.pe_DisplayName = webApplication.ShortName; pe.pe_Description = webApplication.ShortName; pe.pe_Name = webApplication.ShortName; pe.pe_Firmware = ""; GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth"); if (parm.ConfigValue == "1") { //需要审核 pe.pe_AuthStatus = 0;//待审核 pe.pe_AuthSubmitTime = DateTime.Now; pe.pe_AuthSubmitName = CurrentUser.FullName; pe.pe_AuthSubmitUID = CurrentUser.UserUId; pe.pe_Direction = "发布"; pe.pe_UsefulStstus = "0"; pe.pe_UsefulTime = DateTime.Now; pe.pe_UsefulOperatorUID = CurrentUser.UserUId; pe.pe_UsefulOperatorName = CurrentUser.FullName; } else { pe.pe_AuthStatus = 1;//审核通过 pe.pe_AuthSubmitTime = DateTime.Now; pe.pe_AuthTime = DateTime.Now; pe.pe_AuthSubmitName = CurrentUser.FullName; pe.pe_AuthSubmitUID = CurrentUser.UserUId; pe.pe_AuthManUID = CurrentUser.UserUId; pe.pe_AuthMan = CurrentUser.FullName; pe.pe_SyncStatus = 0; pe.pe_Direction = "发布"; pe.pe_UsefulStstus = "1"; pe.pe_UsefulTime = DateTime.Now; pe.pe_UsefulOperatorUID = CurrentUser.UserUId; pe.pe_UsefulOperatorName = CurrentUser.FullName; } string pe_2dPictureUrl = Save2DPicture(pe.pe_id, pe.pe_DownloadUri); pe.pe_2dPictureUrl = pe_2dPictureUrl; int i = Request.Files.Count; if (i > 0) { HttpPostedFileBase icon = null; int packageId = pe.pe_id; string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径 string pDir = SAVEOUTPATH + @"\" + packageId.ToString();//相对路径 用安装包ID做文件夹名 string saveDir = conSolePath + pDir; //图标文件 icon = Request.Files[0]; string iconFileName = "AppIcon.png"; string savePath = System.IO.Path.Combine(saveDir, iconFileName); if (!System.IO.Directory.Exists(saveDir)) { System.IO.Directory.CreateDirectory(saveDir); } if (System.IO.File.Exists(savePath)) { System.IO.File.Delete(savePath); } icon.SaveAs(savePath); pe.pe_PictureUrl = @"~/" + pDir + "/AppIcon.png"; pe.pe_PictureUrl = pe.pe_PictureUrl.Replace(@"\\", "/"); } BoFactory.GetVersionTrackBo.InsertPackageExt(pe); if (parm.ConfigValue == "0") { //不需要审核,直接同步到应用中心 //同步至外网数据 _SyncPackageExt(pe); } } else { //修改 BoFactory.GetVersionTrackBo.UpdateWebApplication(webApplication); string pe_id = BoFactory.GetVersionTrackBo.GetPeId(webApplication.ID.ToString(), "WebApplication"); SMC_PackageExt pe = BoFactory.GetVersionTrackBo.GetPackageExt(pe_id); pe.pe_IsBB = pe_IsBB; pe.pe_IsTJ = pe_IsTJ; pe.pe_UpdateTime = DateTime.Now; pe.pe_UpdateUid = CurrentUser.UserUId; pe.pe_CategoryID = webApplication.AppID.ToString(); pe.pe_ClientType = webApplication.ClientType; pe.pe_Category = BoFactory.GetVersionTrackBo.GetApplicationCategory(webApplication.AppID.ToString()).DisplayName; pe.pe_DisplayName = webApplication.ShortName; pe.pe_Description = webApplication.ShortName; pe.pe_Name = webApplication.ShortName; pe.pe_UnitCode = webApplication.Unit; pe.pe_UnitName = BoFactory.GetSMC_UnitBo.Get(pe.pe_UnitCode).Unit_Name; int i = Request.Files.Count; pe.pe_ApplicationCode = Request.Form["ApplicationID"]; if (!String.IsNullOrEmpty(pe.pe_ApplicationCode)) { string[] appIds = pe.pe_ApplicationCode.Split(",".ToCharArray()); string appNames = ""; foreach (string appid in appIds) { Application application = Bo.BoFactory.GetVersionTrackBo.GetApplication(appid); if (application != null) { appNames += application.DisplayName + ","; } } pe.pe_ApplicationName = appNames; } GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth"); if (parm.ConfigValue == "1") { //需要审核 pe.pe_AuthStatus = 0;//待审核 pe.pe_AuthSubmitTime = DateTime.Now; pe.pe_AuthSubmitName = CurrentUser.FullName; pe.pe_AuthSubmitUID = CurrentUser.UserUId; pe.pe_Direction = "发布"; pe.pe_Type = "web"; pe.pe_UsefulStstus = "0"; pe.pe_UsefulTime = DateTime.Now; pe.pe_UsefulOperatorUID = CurrentUser.UserUId; pe.pe_UsefulOperatorName = CurrentUser.FullName; } else { pe.pe_AuthStatus = 1;//审核通过 pe.pe_AuthSubmitTime = DateTime.Now; pe.pe_AuthTime = DateTime.Now; pe.pe_AuthSubmitName = CurrentUser.FullName; pe.pe_AuthSubmitUID = CurrentUser.UserUId; pe.pe_AuthManUID = CurrentUser.UserUId; pe.pe_AuthMan = CurrentUser.FullName; pe.pe_SyncStatus = 0; pe.pe_Direction = "发布"; pe.pe_Type = "web"; pe.pe_UsefulStstus = "1"; pe.pe_UsefulTime = DateTime.Now; pe.pe_UsefulOperatorUID = CurrentUser.UserUId; pe.pe_UsefulOperatorName = CurrentUser.FullName; } string pe_2dPictureUrl = Save2DPicture(pe.pe_id, pe.pe_DownloadUri); pe.pe_2dPictureUrl = pe_2dPictureUrl; if (i > 0) { HttpPostedFileBase icon = null; int packageId = pe.pe_id; string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径 string pDir = SAVEOUTPATH + @"\" + packageId.ToString();//相对路径 用安装包ID做文件夹名 string saveDir = conSolePath + pDir; //图标文件 icon = Request.Files[0]; string iconFileName = "AppIcon.png"; string savePath = System.IO.Path.Combine(saveDir, iconFileName); if (!System.IO.Directory.Exists(saveDir)) { System.IO.Directory.CreateDirectory(saveDir); } if (System.IO.File.Exists(savePath)) { System.IO.File.Delete(savePath); } icon.SaveAs(savePath); pe.pe_PictureUrl = @"~/" + pDir + "/AppIcon.png"; pe.pe_PictureUrl = pe.pe_PictureUrl.Replace(@"\\", "/"); } pe.pe_ClientType = webApplication.ClientType; BoFactory.GetVersionTrackBo.UpdatePackageExt(pe); if (parm.ConfigValue == "0") { //不需要审核,直接同步到应用中心 //同步至外网数据 _SyncPackageExt(pe); } } } catch (Exception ex) { Log4NetHelper.Error(ex); data.IsSuccess = false; data.Msg = ex.Message; } return Json(data, "text/html"); }
private void _SMC_PackageExtInternalRelease(SMC_PackageExt ext) { if (ext == null) return; string tableName = ext.TableName.ToLower(); int tableId = ext.TableID; List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>(); switch (tableName) { case "webapplication": pars.Add(new KeyValuePair<string, object>("id", tableId)); WebApplication webApplication = daoWebApplication.Get(pars); if (webApplication == null) { webApplication = new WebApplication(); CopyPackageExt2WebApplication(ext, webApplication); daoWebApplication.Insert(webApplication); ext.TableID = webApplication.ID; } else { CopyPackageExt2WebApplication(ext, webApplication); daoWebApplication.Update(webApplication); } break; case "package4ai": pars.Add(new KeyValuePair<string, object>("id", tableId)); Package4AI package4AI = daoPackage4AI.Get(pars); if (package4AI == null) { package4AI = new Package4AI(); CopyPackageExt2Package4AI(ext, package4AI); daoPackage4AI.Insert(package4AI); ext.TableID = package4AI.ID; } else { CopyPackageExt2Package4AI(ext, package4AI); daoPackage4AI.Update(package4AI); } try { _AddApp4AI(package4AI, ext); } catch (Exception ex) { Log4NetHelper.Error(ex); } try { _AddAction4Android(package4AI, ext); } catch (Exception ex) { Log4NetHelper.Error(ex); } break; case "smc_package4out": pars.Add(new KeyValuePair<string, object>("po_ID", tableId)); SMC_Package4Out package4Out = daoSMC_Package4Out.Get(pars); if (package4Out == null) { package4Out = new SMC_Package4Out(); CopyPackageExt2SMC_Package4Out(ext, package4Out); daoSMC_Package4Out.Insert(package4Out); ext.TableID = package4Out.po_ID; } else { CopyPackageExt2SMC_Package4Out(ext, package4Out); daoSMC_Package4Out.Update(package4Out); } break; } daoSMC_PackageExt.Update(ext); _CopyExtFileToUpdateFilesFolder(ext); }
public virtual void Save(SMC_PackageExt _ext) { packageDao.Update(_ext); }
public bool PackageExtSync(SMC_PackageExt entity) { try { return bo.PackageExtSyncInsideToOutside(entity); } catch (Exception e) { Log4NetHelper.Error(e); return false; } }
protected SMC_Package4Out CopyPackageExt2SMC_Package4Out(SMC_PackageExt ext, SMC_Package4Out packageOut) { packageOut.BuildVer = int.Parse(ext.pe_BuildVer); packageOut.ClientType = ext.pe_ClientType; packageOut.CreateTime = ext.pe_CreatedTime; packageOut.CreateUid = ext.pe_CreateUid; packageOut.Description = ext.pe_Description; packageOut.DisplayName = ext.pe_DisplayName; packageOut.DownloadUri = ext.pe_DownloadUri; packageOut.Name = ext.pe_Name; packageOut.Type = ext.pe_Type; packageOut.UpdateTime = DateTime.Now; packageOut.UpdateUid = ext.pe_UpdateUid; packageOut.Version = ext.pe_Version; if (packageOut.Type == null) packageOut.Type = "plugin"; return packageOut; }
protected void SyncPackageExtToAppCenter(SMC_PackageExt ext, Hashtable r, int batch_no) { SmartBox.Console.Bo.AppCenter.AppCenterBO bo = Bo.BoFactory.GetAppCenterBO; Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService(); string smartbox_console_path = HttpRuntime.AppDomainAppPath; Service.ApplicationCenterWS.SMC_PackageExt entity = CopyPackageExt(ext); bool flag = true; //Log4NetHelper.Info("wsurl:" + ws.Url); try { //同步安装包到外网应用中心 ws.PackageExtSync(entity); Service.ApplicationCenterWS.SMC_PackageFAQ faqEntity = new Service.ApplicationCenterWS.SMC_PackageFAQ(); //同步应用手册到外网应用中心 IList<SMC_PackageManual> manuals = bo.GetPackageManuals(entity.pe_id); foreach (SMC_PackageManual _manual in manuals) { Service.ApplicationCenterWS.SMC_PackageManual manual = CopyPackageManual(_manual); bool f = ws.PackageManualSync(manual); flag = flag && f; } //同步截图表到外网应用中心 IList<SMC_PackagePicture> pics = bo.GetPackagePictures(entity.pe_id); if (pics.Count > 0) { foreach (SMC_PackagePicture _pic in pics) { Service.ApplicationCenterWS.SMC_PackagePicture pic = CopyPackagePicture(_pic); bool f = ws.PackagePictuerSync(pic); flag = flag && f; } } //同步附件到外网应用中心 string entityFolder = smartbox_console_path + "\\PackageExt\\" + ext.pe_id; if (Directory.Exists(entityFolder)) { string[] files = System.IO.Directory.GetFiles(entityFolder); List<Service.ApplicationCenterWS.FileEntity> fs = new List<Service.ApplicationCenterWS.FileEntity>(); foreach (string filePath in files) { if (System.IO.File.Exists(filePath)) { FileStream s = new FileStream(filePath, FileMode.Open, FileAccess.Read); Service.ApplicationCenterWS.FileEntity fEntity = new Service.ApplicationCenterWS.FileEntity(); fEntity.Content = new byte[s.Length]; s.Read(fEntity.Content, 0, (int)s.Length); s.Close(); s.Dispose(); fEntity.FileName = Path.GetFileName(filePath); fs.Add(fEntity); } } bool f = true; if (fs.Count > 0) { f = ws.PackageFilesSync(fs.ToArray(), ext.pe_id); } flag = flag && f; } r["r"] = flag; r["d"] = "同步" + (flag ? "成功!" : "失败!"); //同步成功 ext.pe_SyncStatus = flag ? 1 : 2; BoFactory.GetVersionTrackBo.UpdatePackageExt(ext); SMC_PackageExtSyncToOutside sync = new SMC_PackageExtSyncToOutside(); sync.sync_bat_no = batch_no; sync.pe_id = ext.pe_id; sync.pe_name = ext.pe_Name; sync.sync_status = true; sync.sync_time = DateTime.Now; sync.description = "同步成功"; BoFactory.GetSMC_PackageExtSyncToOutsideBO.Insert(sync); } catch (Exception xe) { Log4NetHelper.Error(xe); //同步失败 BoFactory.GetVersionTrackBo.UpdatePackageExt(ext); SMC_PackageExtSyncToOutside sync = new SMC_PackageExtSyncToOutside(); sync.sync_bat_no = batch_no; sync.pe_id = ext.pe_id; sync.pe_name = ext.pe_Name; sync.sync_status = false; sync.sync_time = DateTime.Now; sync.description = xe.Message; BoFactory.GetSMC_PackageExtSyncToOutsideBO.Insert(sync); r["r"] = false; r["d"] = "同步失败!"; } }
public virtual void SMC_PackageExtInternalRelease(SMC_PackageExt ext) { _SMC_PackageExtInternalRelease(ext); }
protected Package4AI CopyPackageExt2Package4AI(SMC_PackageExt ext, Package4AI package4AI) { package4AI.BuildVer = int.Parse(ext.pe_BuildVer); package4AI.ClientType = ext.pe_ClientType; package4AI.CreateTime = ext.pe_CreatedTime; package4AI.CreateUid = ext.pe_CreateUid; package4AI.Description = ext.pe_Description; package4AI.DisplayName = ext.pe_DisplayName; package4AI.DownloadUri = ext.pe_DownloadUri; if (String.IsNullOrEmpty(package4AI.Type)) package4AI.Type = ext.pe_Type; package4AI.UpdateTime = ext.pe_UpdateTime; package4AI.UpdateUid = ext.pe_UpdateUid; package4AI.Version = ext.pe_Version; package4AI.UpdateTime = DateTime.Now; if (package4AI.Type == null) { package4AI.Type = "plugin"; } return package4AI; }
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"); }
public JsonResult UploadOutPackage(FormCollection form) { JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" }; int i = Request.Files.Count; HttpPostedFileBase file = null; HttpPostedFileBase icon = null; string filePath = ""; string packageFileName = ""; SMC_PackageExt packageExt = new SMC_PackageExt(); int packageId = BoFactory.GetVersionTrackBo.GetMaxPackageExtId() + 1; string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径 string pDir = SAVEOUTPATH + @"\" + packageId.ToString();//相对路径 用安装包ID做文件夹名 string saveDir = conSolePath + pDir; string fileUrl = ""; try { if (i > 0) { file = Request.Files[0];//安装包文件 filePath = file.FileName; packageFileName = "Package4Out-" + Path.GetFileName(filePath); string savePath = System.IO.Path.Combine(saveDir, packageFileName); if (!System.IO.Directory.Exists(saveDir)) { System.IO.Directory.CreateDirectory(saveDir); } if (System.IO.File.Exists(savePath)) { System.IO.File.Delete(savePath); } file.SaveAs(savePath); fileUrl = packageFileName; //图标文件 icon = Request.Files[1]; string iconFileName = "AppIcon.png"; savePath = System.IO.Path.Combine(saveDir, iconFileName); if (System.IO.File.Exists(savePath)) { System.IO.File.Delete(savePath); } icon.SaveAs(savePath); //插入数据 SMC_Package4Out package = new SMC_Package4Out(); package.po_ID = BoFactory.GetVersionTrackBo.GetMaxOutPackageId() + 1; package.Name = packageFileName; package.Type = "main"; package.ClientType = form["ClientType"]; package.DisplayName = form["DisplayName"]; package.Description = form["Description"]; package.Version = form["Version"]; package.BuildVer = -1; package.DownloadUri = packageId.ToString() + @"\" + packageFileName;// savePath; package.CreateUid = CurrentUser.UserUId; package.CreateTime = DateTime.Now; package.UpdateUid = CurrentUser.UserUId; package.UpdateTime = DateTime.Now; BoFactory.GetVersionTrackBo.InsertOutPackage(package); //插入扩展表 packageExt.pe_id = packageId; packageExt.pe_ClientType = package.ClientType; packageExt.pe_IsTJ = form["IsRecom"]; packageExt.pe_IsBB = form["IsMust"]; packageExt.pe_Size = file.ContentLength; packageExt.pe_Firmware = form["Firmware"]; 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_DisplayName = form["DisplayName"]; packageExt.pe_Description = form["Description"]; packageExt.pe_Version = form["Version"]; packageExt.pe_BuildVer = form["Version"]; packageExt.pe_Name = packageExt.pe_DisplayName; //packageExt.pe_PictureUrl = form["IconUri"]; packageExt.TableName = "SMC_Package4Out"; packageExt.TableID = package.po_ID; packageExt.pe_CreateUid = CurrentUser.UserUId; packageExt.pe_CreatedTime = DateTime.Now; packageExt.pe_UpdateUid = CurrentUser.UserUId; packageExt.pe_UpdateTime = DateTime.Now; packageExt.pe_ApplicationCode = Request.Form["ApplicationID"]; if (!String.IsNullOrEmpty(packageExt.pe_ApplicationCode)) { string[] appIds = packageExt.pe_ApplicationCode.Split(",".ToCharArray()); string appNames = ""; foreach (string appid in appIds) { Application application = Bo.BoFactory.GetVersionTrackBo.GetApplication(appid); if (application != null) { appNames += application.DisplayName + ","; } } packageExt.pe_ApplicationName = appNames; } GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth"); if (parm.ConfigValue == "1") { //需要审核 packageExt.pe_AuthStatus = 0;//待审核 packageExt.pe_AuthSubmitTime = DateTime.Now; packageExt.pe_AuthSubmitName = CurrentUser.FullName; packageExt.pe_AuthSubmitUID = CurrentUser.UserUId; packageExt.pe_Direction = "发布"; packageExt.pe_Type = ""; packageExt.pe_UsefulStstus = "0"; packageExt.pe_UsefulTime = DateTime.Now; packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId; packageExt.pe_UsefulOperatorName = CurrentUser.FullName; } else { packageExt.pe_AuthStatus = 1;//审核通过 packageExt.pe_AuthSubmitTime = DateTime.Now; 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_Type = ""; packageExt.pe_UsefulStstus = "1"; packageExt.pe_UsefulTime = DateTime.Now; packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId; packageExt.pe_UsefulOperatorName = CurrentUser.FullName; } //生成外网下载url,并生成二维码 string outWebHost = AppConfig.OutWebHost; if (outWebHost.EndsWith("/") == false) outWebHost = outWebHost + "/"; string url = outWebHost + AppConfig.OutPackUploadFolder + "/" + packageId.ToString() + '/' + packageFileName; System.Drawing.Bitmap bmp = GetDimensionalCode(url); string imgPath = System.IO.Path.Combine(saveDir, "二维码图片.jpeg"); bmp.Save(imgPath, System.Drawing.Imaging.ImageFormat.Jpeg); packageExt.pe_2dPictureUrl = @"~/" + pDir + "/二维码图片.jpeg"; packageExt.pe_2dPictureUrl = packageExt.pe_2dPictureUrl.Replace(@"\\", "/"); packageExt.pe_DownloadUri = url.Replace(@"\", "/"); packageExt.pe_PictureUrl = @"~/" + pDir + "/AppIcon.png"; packageExt.pe_PictureUrl = packageExt.pe_PictureUrl.Replace(@"\\", "/"); BoFactory.GetVersionTrackBo.InsertPackageExt(packageExt); packageExt.pe_FileUrl = "~/PackageExt/" + packageExt.pe_id + "/" + fileUrl; BoFactory.GetSMC_PackageExtBO.Update(packageExt); if (parm.ConfigValue == "0") { //不需要审核,直接同步到应用中心 //同步至外网数据 _SyncPackageExt(packageExt); } } } catch (Exception e) { Log4NetHelper.Error(e); data.IsSuccess = false; data.Msg = e.Message; } return Json(data, "text/html"); }
public JsonResult ImportOldPackage4AI(string ids) { JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "" }; try { string[] idarray = ids.Split(",".ToCharArray()); VersionTrackBo verBO = BoFactory.GetVersionTrackBo; List<SMC_PackageExt> exts = new List<SMC_PackageExt>(); GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth"); foreach (string id in idarray) { if (String.IsNullOrEmpty(id)) continue; Package4AI pack = verBO.GetPackage4AI(id); App4AI app4ai = verBO.GetApp4AI(pack.ID.ToString()); Application app = null; if (app4ai.AppID != null) app = verBO.GetApplication(app4ai.AppID.ToString()); else { List<KeyValuePair<string, object>> _pars = new List<KeyValuePair<string, object>>(); _pars.Add(new KeyValuePair<string, object>("[name]", app4ai.AppCode)); app = Bo.BoFactory.GetApplicationBO.Get(_pars); } bool is_pe_insert = true; SMC_PackageExt ext = new SMC_PackageExt(); List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>(); pars.Add(new KeyValuePair<string, object>("tablename", "Package4AI")); pars.Add(new KeyValuePair<string, object>("tableid", id)); SMC_PackageExt _ext = Bo.BoFactory.GetSMC_PackageExtBO.Get(pars); if (_ext != null) { ext = _ext; is_pe_insert = false; } ext.TableName = "Package4AI"; ext.TableID = pack.ID; ext.pe_Version = pack.Version; ext.pe_UnitName = ""; ext.pe_Name = pack.Name; ext.pe_DisplayName = pack.DisplayName; ext.pe_Description = pack.Description; ext.pe_BuildVer = pack.BuildVer.ToString(); ext.pe_ClientType = pack.ClientType; if (app != null) { ext.pe_UnitCode = app.Unit; } else ext.pe_UnitCode = ""; string cateid = ""; if (app != null && !String.IsNullOrEmpty(app.CategoryIDs)) { string[] cateids = app.CategoryIDs.Split(",".ToCharArray()); if (cateids != null && cateids.Length > 0) { foreach (string cat in cateids) { if (!String.IsNullOrEmpty(cat)) { cateid = cat; break; } } } } ext.pe_CategoryID = cateid; ext.pe_CreatedTime = DateTime.Now; ext.pe_CreateUid = ""; ext.pe_UpdateTime = DateTime.Now; ext.pe_UpdateUid = ""; ext.pe_Firmware = ""; ext.pe_IsBB = "1"; ext.pe_IsTJ = "1"; if (parm.ConfigValue == "1") { //需要审核 ext.pe_AuthStatus = 0;//待审核 ext.pe_AuthSubmitTime = DateTime.Now; ext.pe_AuthSubmitName = CurrentUser.FullName; ext.pe_AuthSubmitUID = CurrentUser.UserUId; ext.pe_Direction = "发布"; ext.pe_Type = pack.Type; ext.pe_UsefulStstus = "0"; ext.pe_UsefulTime = DateTime.Now; ext.pe_UsefulOperatorUID = CurrentUser.UserUId; ext.pe_UsefulOperatorName = CurrentUser.FullName; } else { ext.pe_AuthStatus = 1;//审核通过 ext.pe_AuthSubmitTime = DateTime.Now; ext.pe_AuthTime = DateTime.Now; ext.pe_AuthSubmitName = CurrentUser.FullName; ext.pe_AuthSubmitUID = CurrentUser.UserUId; ext.pe_AuthManUID = CurrentUser.UserUId; ext.pe_AuthMan = CurrentUser.FullName; ext.pe_SyncStatus = 0; ext.pe_Direction = "发布"; ext.pe_Type = pack.Type; ext.pe_UsefulStstus = "1"; ext.pe_UsefulTime = DateTime.Now; ext.pe_UsefulOperatorUID = CurrentUser.UserUId; ext.pe_UsefulOperatorName = CurrentUser.FullName; } //exts.Add(ext); if (is_pe_insert) BoFactory.GetSMC_PackageExtBO.Insert(ext); else BoFactory.GetSMC_PackageExtBO.Update(ext); //复制安装包 string pubFolder = System.Configuration.ConfigurationManager.AppSettings["pubFolder"]; string pubUrl = System.Configuration.ConfigurationManager.AppSettings["pubUrl"]; string OutWebHost = System.Configuration.ConfigurationManager.AppSettings["OutWebHost"]; string packUrl = System.Configuration.ConfigurationManager.AppSettings["packUrl"]; string outpackUploadFolder = System.Configuration.ConfigurationManager.AppSettings["outpackUploadFolder"]; string outPackUrl = Path.Combine(OutWebHost, outpackUploadFolder); outPackUrl = Path.Combine(outPackUrl, ext.pe_id.ToString()); outPackUrl = outPackUrl.Replace("\\", "/") + "/"; ext.pe_DownloadUri = pack.DownloadUri.Replace(packUrl, outPackUrl); string fileFolder = Path.Combine("~/", outpackUploadFolder); if (!Directory.Exists(Server.MapPath(fileFolder))) Directory.CreateDirectory(Server.MapPath(fileFolder)); fileFolder = Path.Combine(fileFolder, ext.pe_id.ToString()); fileFolder = Server.MapPath(fileFolder); string fileName = Path.GetFileName(ext.pe_DownloadUri); if (!Directory.Exists(fileFolder)) Directory.CreateDirectory(fileFolder); string destFile = Path.Combine(fileFolder, fileName); string sourceFile = Path.Combine(pubFolder, Path.GetFileName(ext.pe_DownloadUri)); if (System.IO.File.Exists(sourceFile)) System.IO.File.Copy(sourceFile, destFile, true); //图标 string destIconFile = Path.Combine(fileFolder, "No.png"); string sourceIconFile = Server.MapPath("~/Images/no.png"); if (System.IO.File.Exists(sourceIconFile)) System.IO.File.Copy(sourceIconFile, destIconFile, true); ext.pe_PictureUrl = "~/" + ext.pe_id + @"/" + "No.png"; System.Drawing.Bitmap bmp = GetDimensionalCode(ext.pe_DownloadUri); //保存文件 string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径 string savePath = System.IO.Path.Combine(fileFolder, "二维码图片.jpeg"); if (System.IO.File.Exists(savePath)) { System.IO.File.Delete(savePath); } bmp.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg); ext.pe_2dPictureUrl = "~/" + ext.pe_id + @"/" + "二维码图片.jpeg"; BoFactory.GetSMC_PackageExtBO.Update(ext); if (parm.ConfigValue == "0") { //不需要审核,直接同步到应用中心 //同步至外网数据 _SyncPackageExt(ext); } } //BoFactory.GetAppCenterBO.AddSMC_PackageExt(exts); data.IsSuccess = true; data.Msg = "导入数据成功!"; } catch (Exception e) { data.IsSuccess = false; data.Msg = e.Message; Log4NetHelper.Error(e); } return Json(data); }
public bool _SyncPackageExt(SMC_PackageExt ext) { Hashtable r = new Hashtable(); int batch_no = BoFactory.GetSMC_AutoTableIDBo.GetMaxId("SMC_PackageExtSyncToOutside", "sync_bat_no"); batch_no++; SyncPackageExtToAppCenter(ext, r, batch_no); return (bool)r["r"]; }
protected WebApplication CopyPackageExt2WebApplication(SMC_PackageExt ext, WebApplication webApplication) { //webApplication.AppID = ext.pe_ApplicationCode; webApplication.ClientType = ext.pe_ClientType; webApplication.CreateTime = ext.pe_CreatedTime; webApplication.CreateUid = ext.pe_CreateUid; webApplication.ShortName = ext.pe_Name; webApplication.Unit = ext.pe_UnitCode; webApplication.UpdateTime = ext.pe_UpdateTime; webApplication.UpdateUid = ext.pe_UpdateUid; //webApplication.Uri = ext. return webApplication; }
protected Service.ApplicationCenterWS.SMC_PackageExt CopyPackageExt(SMC_PackageExt ext) { Service.ApplicationCenterWS.SMC_PackageExt entity = new Service.ApplicationCenterWS.SMC_PackageExt(); entity.pe_2dPictureUrl = ext.pe_2dPictureUrl; entity.pe_BuildVer = ext.pe_BuildVer; entity.pe_Category = ext.pe_Category; entity.pe_CategoryID = ext.pe_CategoryID; entity.pe_ClientType = ext.pe_ClientType; entity.pe_CreatedTime = ext.pe_CreatedTime; entity.pe_CreateUid = ext.pe_CreateUid; entity.pe_Description = ext.pe_Description; entity.pe_DisplayName = ext.pe_DisplayName; entity.pe_DownCount = ext.pe_DownCount; entity.pe_DownloadUri = ext.pe_DownloadUri; entity.pe_Firmware = ext.pe_Firmware; entity.pe_id = ext.pe_id; entity.pe_IsBB = ext.pe_IsBB; entity.pe_IsTJ = ext.pe_IsTJ; entity.pe_Name = ext.pe_Name; entity.pe_PictureUrl = ext.pe_PictureUrl; entity.pe_Size = ext.pe_Size; entity.pe_UnitCode = ext.pe_UnitCode; entity.pe_UnitName = ext.pe_UnitName; entity.pe_UpdateTime = ext.pe_UpdateTime; entity.pe_UpdateUid = ext.pe_UpdateUid; entity.pe_Version = ext.pe_Version; entity.TableID = ext.TableID; entity.TableName = ext.TableName; entity.pe_UsefulStstus = ext.pe_UsefulStstus; return entity; }
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 virtual bool PackageExtSyncInsideToOutside(SMC_PackageExt entity) { SMC_PackageExt ext = packageDao.Get(entity.pe_id); string peDownloadUrl = entity.pe_DownloadUri; if (ext == null) { packageDao.Insert(entity); } else { packageDao.Update(entity); } if (peDownloadUrl.EndsWith(".apk")) { string applicationCenterSiteUrl = ConfigurationManager.AppSettings["applicationCenterSiteUrl"]; string fileName = Path.GetFileName(peDownloadUrl); entity.pe_FileUrl = "~/PackageExt/" + entity.pe_id + "/" + fileName; entity.pe_DownloadUri = applicationCenterSiteUrl + "/PackageExt/" + entity.pe_id + "/" + fileName; packageDao.Update(entity); string packUploadFolder = ConfigurationManager.AppSettings["packUploadFolder"]; string packDestFolder = ConfigurationManager.AppSettings["attachPath"] + "\\" + entity.pe_id + "\\"; try { if (!Directory.Exists(packDestFolder)) Directory.CreateDirectory(packDestFolder); } catch (Exception ex) { Log4NetHelper.Error(ex); } try { string s = ""; if (packUploadFolder.IndexOf("$") != -1) { string[] folders = packUploadFolder.Split("$".ToCharArray()); if (folders.Length == 1) s = folders[0]; else if (folders.Length >= 2) s = folders[1]; } else { s = packUploadFolder; } File.Copy(s + "\\" + fileName, packDestFolder + fileName, true); } catch (Exception ex) { Log4NetHelper.Error(ex); } } return true; }
private void _AddApp4AI(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; Hashtable extendInfo = null; JObject extObj = null; if (!String.IsNullOrEmpty(ext.pe_ExtentInfo)) { extendInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Hashtable>(ext.pe_ExtentInfo); extObj = JObject.Parse(ext.pe_ExtentInfo); } Newtonsoft.Json.Linq.JArray appsHash = (Newtonsoft.Json.Linq.JArray)extendInfo["Applications"]; JArray appsJobj = (JArray)extObj["Applications"]; foreach (string appCode in apps) { if (String.IsNullOrEmpty(appCode)) continue; if (extendInfo.Count > 0) { } //appsHash.Select(e => { e.}); List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>(); pars.Add(new KeyValuePair<string, object>("[NAME]", appCode)); Application application = appDao.Get(pars); App4AI app4AI = new App4AI(); app4AI.AppID = application.ID; //Newtonsoft.Json.Linq.JToken.EqualityComparer = new Newtonsoft.Json.Linq.JTokenEqualityComparer(); //ec. string AppIconUri = ""; foreach (var j in appsJobj) { var i = (JObject)j; string ApplicationID = (string)i["ApplicationID"]; if (ApplicationID == application.ID.ToString()) { var oIcon = (JObject)i["ApplicationIcon"]; AppIconUri = (string)oIcon["AppIconUri"]; break; } } //Hashtable appHash = appsHash.Find(e => e["ApplicationID"] == application.ID.ToString()); //Hashtable appIconHash = (Hashtable)appHash["ApplicationIcon"]; //string AppIconUri = (string)appIconHash["AppIconUri"]; app4AI.Package4AIID = package.ID; //app4AI.PackageName = package.Name; app4AI.AppCode = appCode; app4AI.ClientType = package.ClientType;//form["AppCheckClentType_" + appIndex.ToString()]; //string appIco = "";//form["AppIco_" + appIndex.ToString()] app4AI.IconUri = AppIconUri;// GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), appIco); app4AI.Seq = idx; app4AI.CreateTime = DateTime.Now; app4AI.UpdateTime = DateTime.Now; app4AI.CreateUid = ""; app4AI.UpdateUid = ""; 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 = app4AIDao.Get(_pars); if (_app4ai == null) { //package.App4AIList.Add(app4AI); app4AIDao.Insert(app4AI); } else { app4AIDao.Update(app4AI); } ++idx; } } } }
public JsonResult EditIOSOutsideApp(IOSOutsideApp webApplication) { JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" }; webApplication.UpdateTime = DateTime.Now; webApplication.UpdateUid = CurrentUser.UserUId; try { if (string.IsNullOrEmpty(Convert.ToString(webApplication.ID)) || webApplication.ID == 0) {//新增 webApplication.CreateTime = DateTime.Now; webApplication.CreateUid = CurrentUser.UserUId; BoFactory.GetVersionTrackBo.InsertIOSOutSideApp(webApplication); } else { BoFactory.GetVersionTrackBo.UpdateIOSOutSideApp(webApplication); } SMC_PackageExt packageExt = new SMC_PackageExt(); packageExt.pe_id = BoFactory.GetVersionTrackBo.GetMaxPackageExtId() + 1; packageExt.pe_ClientType = webApplication.ClientType; packageExt.pe_IsTJ = Request.Form["IsRecom"]; packageExt.pe_IsBB = Request.Form["IsMust"]; //FileInfo fi = new FileInfo(saveFilePath); packageExt.pe_Size = 0;// (int)fi.Length; packageExt.TableName = "IOSOutsideApplication"; packageExt.TableID = webApplication.ID; packageExt.pe_UnitCode = Request.Form["Unit"]; packageExt.pe_CategoryID = Request.Form["Cate"]; packageExt.pe_Category = BoFactory.GetVersionTrackBo.GetApplicationCategory(Request.Form["Cate"]).DisplayName; packageExt.pe_ApplicationCode = Request.Form["AppID"]; if (!String.IsNullOrEmpty(packageExt.pe_ApplicationCode)) { string[] appIds = packageExt.pe_ApplicationCode.Split(",".ToCharArray()); string appNames = ""; foreach (string appid in appIds) { Application application = Bo.BoFactory.GetVersionTrackBo.GetApplication(appid); if (application != null) { appNames += application.DisplayName + ","; } } packageExt.pe_ApplicationName = appNames; } 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 = Request.Form["Version"];// form["packageVersion"]; packageExt.pe_BuildVer = Request.Form["BuildVer"];// form["packageBuildVer"]; packageExt.pe_Name = Request.Form["DisplayName"];// form["packageDisplayName"]; packageExt.pe_DisplayName = Request.Form["DisplayName"];// form["packageDisplayName"]; packageExt.pe_Description = "";// form["packageDescription"]; packageExt.pe_Firmware = Request.Form["Firmware"]; packageExt.pe_DownloadUri = Request.Form["Uri"]; string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径 string pDir = SAVEOUTPATH + @"\" + packageExt.pe_id.ToString();//相对路径 用安装包ID做文件夹名 string saveDir = conSolePath + pDir; //生成下载url,并生成二维码 string url = packageExt.pe_DownloadUri; string uri = base.Save2DPicture(packageExt.pe_id, url); packageExt.pe_2dPictureUrl = uri; 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(@"\\", "/"); } GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth"); if (parm.ConfigValue == "1") { //需要审核 packageExt.pe_AuthStatus = 0;//待审核 packageExt.pe_AuthSubmitTime = DateTime.Now; packageExt.pe_AuthSubmitName = CurrentUser.FullName; packageExt.pe_AuthSubmitUID = CurrentUser.UserUId; packageExt.pe_Direction = "发布"; packageExt.pe_Type = "ios_out"; packageExt.pe_UsefulStstus = "0"; packageExt.pe_UsefulTime = DateTime.Now; packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId; packageExt.pe_UsefulOperatorName = CurrentUser.FullName; } else { packageExt.pe_AuthStatus = 1;//审核通过 packageExt.pe_AuthSubmitTime = DateTime.Now; 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_Type = "ios_out"; packageExt.pe_UsefulStstus = "1"; packageExt.pe_UsefulTime = DateTime.Now; packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId; packageExt.pe_UsefulOperatorName = CurrentUser.FullName; } BoFactory.GetVersionTrackBo.InsertPackageExt(packageExt); if (parm.ConfigValue == "0") { //不需要审核,直接同步到应用中心 //同步至外网数据 _SyncPackageExt(packageExt); } } catch (Exception ex) { data.IsSuccess = false; data.Msg = ex.Message.Replace("'", "`"); Log4NetHelper.Error(ex); } return Json(data); }
/// <summary> /// 复制安装包到更新文件目录 /// </summary> /// <param name="ext"></param> private void _CopyExtFileToUpdateFilesFolder(SMC_PackageExt ext) { string pathSource = HttpContext.Current.Server.MapPath(ext.pe_FileUrl); //string[] files = Directory.GetFiles(pathSource); Dao.Package4AIDao daoPackage4AI = new Package4AIDao(AppConfig.mainDbKey); IList<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>(); pars.Add(new KeyValuePair<string, object>("id", ext.TableID)); Package4AI package4AI = daoPackage4AI.Get(pars); //string sourceFileName = Path.GetFileName(ext.pe_FileUrl); //foreach (string file in files) { string sFileName = Path.GetFileName(pathSource); if (sFileName.EndsWith(".ipa") || sFileName.EndsWith(".apk")) { string destFileName = Path.GetFileName(ext.pe_DownloadUri); string destFolder = AppConfig.PackUploadFolder; if (destFolder.EndsWith(@"\") == false) { destFolder += @"\"; } destFolder += destFileName; try { File.Copy(pathSource, destFolder, true); } catch (Exception ex) { Log4NetHelper.Error(ex); } } string savefilePath = AppConfig.PublishConfig.GetValue(ext.pe_ClientType).Path; //saveFileName = savefilePath; string saveFilePathOut = ""; if (savefilePath.IndexOf("$") != -1) { string[] savefilePaths = savefilePath.Split("$".ToCharArray()); savefilePath = savefilePaths[0]; saveFilePathOut = savefilePaths[1]; } //内网本地存储固定名称的主程序 try { System.IO.File.Copy(pathSource, savefilePath, true); } catch (Exception ex) { Log4NetHelper.Error(ex); } Service.ApplicationCenterWS.WebService acws = new Service.ApplicationCenterWS.WebService(); //StreamReader sr = new StreamReader(); FileStream fs = new FileStream(pathSource, FileMode.Open); byte[] content = new byte[fs.Length]; fs.Read(content, 0, (int)fs.Length - 1); fs.Close(); fs.Dispose(); //发布到外网存储固定名称的主程序 if (package4AI != null && package4AI.Type.ToLower() == "main") acws.RemotePublish(content, saveFilePathOut); } }
static OutsideWS.SMC_PackageExt CopyPackageExt(SMC_PackageExt ext) { OutsideWS.SMC_PackageExt entity = new OutsideWS.SMC_PackageExt(); entity.pe_2dPictureUrl = ext.pe_2dPictureUrl; entity.pe_BuildVer = ext.pe_BuildVer; entity.pe_Category = ext.pe_Category; entity.pe_ClientType = ext.pe_ClientType; entity.pe_CreatedTime = ext.pe_CreatedTime; entity.pe_CreateUid = ext.pe_CreateUid; entity.pe_Description = ext.pe_Description; entity.pe_DisplayName = ext.pe_DisplayName; entity.pe_DownCount = ext.pe_DownCount; entity.pe_DownloadUri = ext.pe_DownloadUri; entity.pe_Firmware = ext.pe_Firmware; entity.pe_id = ext.pe_id; entity.pe_IsBB = ext.pe_IsBB; entity.pe_IsTJ = ext.pe_IsTJ; entity.pe_Name = ext.pe_Name; entity.pe_PictureUrl = ext.pe_PictureUrl; entity.pe_Size = ext.pe_Size; entity.pe_UnitCode = ext.pe_UnitCode; entity.pe_UnitName = ext.pe_UnitName; entity.pe_UpdateTime = ext.pe_UpdateTime; entity.pe_UpdateUid = ext.pe_UpdateUid; entity.pe_Version = ext.pe_Version; entity.TableID = ext.TableID; entity.TableName = ext.TableName; return entity; }
public ActionResult EditAppPackage(string pe_id) { SMC_PackageExt ext = Bo.BoFactory.GetSMC_PackageExtBO.Get(pe_id); if (ext == null) { ext = new SMC_PackageExt(); } string packageName = ""; string packageType = ""; if (ext.TableID == 0) { Package4AI package = null; string path = Server.MapPath("~/PackageSerialization/" + pe_id + "/package.xml"); if (System.IO.File.Exists(path)) { using (Stream fStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { XmlSerializer xmlFormat = new XmlSerializer(typeof(Package4AI)); object o = xmlFormat.Deserialize(fStream); package = (Package4AI)o; fStream.Close(); fStream.Dispose(); } } if (package != null) { packageName = package.Name; packageType = package.Type; } } ViewData["packageName"] = packageName; ViewData["packageType"] = packageType; return View(ext); }