public virtual DataSet GetLightAppAreaPackageList(string unitCode) { DataSet ds = packageDao.GetLightAppAreaPackageList(unitCode); return ds; DataColumn clmn = ds.Tables[0].Columns.Add("id", typeof(int)); clmn = ds.Tables[0].Columns.Add("name"); clmn.DataType = typeof(string); clmn = ds.Tables[0].Columns.Add("displayname"); clmn.DataType = typeof(string); clmn = ds.Tables[0].Columns.Add("description"); clmn.DataType = typeof(string); clmn = ds.Tables[0].Columns.Add("version"); clmn.DataType = typeof(string); clmn = ds.Tables[0].Columns.Add("buildver"); clmn.DataType = typeof(string); clmn = ds.Tables[0].Columns.Add("downloaduri"); clmn.DataType = typeof(string); foreach (DataRow dr in ds.Tables[0].Rows) { string tablename = dr["tablename"].ToString().ToLower(); int tableid = Convert.ToInt32(dr["tableid"]); switch (tablename) { case "package4ai": Package4AIDao padao = new Package4AIDao(AppConfig.mainDbKey); Package4AI entity = padao.Get(tableid); dr["id"] = tableid; dr["name"] = entity.Name; dr["displayname"] = entity.DisplayName; dr["description"] = entity.Description; dr["version"] = entity.Version; dr["buildver"] = entity.BuildVer; dr["downloaduri"] = entity.DownloadUri; break; case "webapplication": WebApplicationDao wad = new WebApplicationDao(AppConfig.mainDbKey); WebApplication application = wad.Get(tableid); dr["id"] = tableid; dr["name"] = application.ShortName; dr["displayname"] = application.ShortName; dr["description"] = ""; dr["version"] = ""; dr["buildver"] = ""; dr["downloaduri"] = application.Uri; break; case "smc_package4out": SMC_Package4OutDao poDao = new SMC_Package4OutDao(AppConfig.statisticDBKey); SMC_Package4Out outEntity = poDao.Get(tableid); dr["id"] = tableid; dr["name"] = outEntity.Name; dr["displayname"] = outEntity.DisplayName; dr["description"] = outEntity.Description; dr["version"] = outEntity.Version; dr["buildver"] = outEntity.BuildVer; dr["downloaduri"] = outEntity.DownloadUri; break; } } return ds; }
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); }
/// <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); } } }
/// <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); } }