/// <summary> /// 写入XML /// </summary> /// <param name="path"></param> private XmlConfigInfo InsertXml(string Vid) { XmlConfigInfo xml = new XmlConfigInfo(); ArrayList vids = GetArray(Vid);//获得相关联的VID IList <PluginInfoTemp> list = new List <PluginInfoTemp>(); SearchVersionTrack searchv = new SearchVersionTrack(); VersionTrack v = null; SearchConfig serach = new SearchConfig(); foreach (string vid in vids) { searchv.VID = vid; v = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0]; PluginInfoTemp p = BoFactory.GetVersionTrackBo.GetPluginTempInfo(v.PluginCode.ToString()); serach.PluginCode = v.PluginCode.ToString(); IList <ConfigTemp> listct = BoFactory.GetVersionTrackBo.GetConfigListTemp(serach);//获取配置信息 IList <ConfigInfo> listc = new List <ConfigInfo>(); foreach (ConfigTemp c in listct) { listc.Add(CommonMethods.ConvertToConfigInfo(c));//转换 } p.configList = listc; list.Add(p); } xml.PluginInfo = list; xml.PluginInfo = xml.PluginInfo.OrderBy(T => T.PluginCode).ToList(); CommonMethods.WritePluginfoConfigXml(xml, Path.Combine(v.FilePath.Trim(), Constants.pluginName)); return(xml); }
private static void GetBaseInfo(PluginInfoTemp pluginInfo, XmlDocument xml) { if (pluginInfo == null) { throw new ArgumentNullException("请给要添加BaseInfo的实体赋值!"); } var pluginBaseInfonodes = xml.SelectNodes("//BaseInfo/*"); if (pluginBaseInfonodes == null) { throw new ArgumentNullException("输入的Xml不存在BaseInfo节点"); } foreach (XmlNode item in pluginBaseInfonodes) { var value = item.InnerText; switch (item.Name) { case "CompanyName": pluginInfo.CompanyName = value; break; case "CompanyLinkman": pluginInfo.CompanyLinkman = value; break; case "CompanyTel": pluginInfo.CompanyTel = value; break; case "CompanyHomePage": pluginInfo.CompanyHomePage = value; break; } } }
private PluginInfoTemp TPluginInfo(PluginInfo plugin) { PluginInfoTemp p = new PluginInfoTemp(); p.CompanyHomePage = plugin.CompanyHomePage; p.CompanyLinkman = plugin.CompanyLinkman; p.CompanyName = plugin.CompanyName; p.CompanyTel = plugin.CompanyTel; p.DirectoryName = plugin.DirectoryName; p.DisplayName = plugin.DisplayName; p.FileName = plugin.FileName; p.HashCode = plugin.HashCode; p.IsDefault = plugin.IsDefault; p.IsNeed = plugin.IsNeed; p.PluginCateCode = plugin.PluginCateCode; p.PluginUrl = plugin.PluginUrl; p.Sequence = plugin.Sequence; p.PluginSummary = plugin.Summary; p.TypeFullName = plugin.TypeFullName; p.Version = plugin.Version; p.PluginCode = plugin.PluginCode; p.IsNew = plugin.IsNew; p.IsUse = plugin.IsUse; p.IsIgnoreConfig = plugin.IsIgnoreConfig; p.configList = plugin.configList; p.ActionCode = plugin.ActionCode; p.ActionSummary = plugin.ActionSummary; p.VersionSummary = plugin.VersionSummary; return(p); }
public ActionResult PublishInfo(string Vid) //vid一定是上一个版本的vid { ArrayList vids = GetArray(Vid); //获得相关联的VID IList <PluginInfoTemp> listtemp = new List <PluginInfoTemp>(); foreach (string vid in vids) { SearchVersionTrack search = new SearchVersionTrack(); search.VID = vid; VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0]; PluginInfoTemp p = BoFactory.GetVersionTrackBo.GetPluginTempInfo(v.PluginCode.ToString()); SearchConfig searchc = new SearchConfig(); searchc.PluginCode = p.PluginCode.ToString(); IList <ConfigTemp> list = BoFactory.GetVersionTrackBo.GetConfigListTemp(searchc); IList <ConfigInfo> listc = new List <ConfigInfo>(); foreach (ConfigTemp c in list) { c.Value1 = c.Value1.Replace("<", "<").Replace(">", ">"); listc.Add(CommonMethods.ConvertToConfigInfo(c)); } p.configList = listc; listtemp.Add(p); } ViewData["vids"] = Vid; return(View(listtemp)); }
public ActionResult UpdatePluginInfo(string Vid, string IsAdd) { ViewData["configList"] = 0; ViewData["IsAdd"] = IsAdd; SearchVersionTrack search = new SearchVersionTrack(); IList <PluginInfoTemp> plist = new List <PluginInfoTemp>(); ArrayList arrVid = GetArray(Vid);//获得相关联的VID foreach (string vid in arrVid) { search.VID = vid; VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0]; PluginInfoTemp p = BoFactory.GetVersionTrackBo.GetPluginTempInfo(v.PluginCode.ToString()); if (p.IsIgnoreConfig == false)//若不忽略配置信息 { SearchConfig searchc = new SearchConfig(); searchc.PluginCode = v.PluginCode.ToString(); searchc.ConfigCategoryCode = Constants.configCategory; IList <ConfigInfo> list = BoFactory.GetVersionTrackBo.GetConfigList(searchc);//获取原有参数 Dictionary <string, ConfigInfo> dic = new Dictionary <string, ConfigInfo>(); foreach (var item in list) { var key = item.Key1 + "_FG$SP_" + item.PluginCode; ConfigInfo temp = new ConfigInfo(); temp.Key1 = item.Key1; temp.OldValue = item.Value1; dic.Add(key, temp); } IList <ConfigTemp> listT = BoFactory.GetVersionTrackBo.GetConfigListTemp(searchc);//现有临时表数据 foreach (var item in listT) { var key = item.Key1 + "_FG$SP_" + item.PluginCode; if (dic.ContainsKey(key)) { dic[key].Value1 = item.Value1; } else { ConfigInfo temp = new ConfigInfo(); temp.Key1 = item.Key1; temp.Value1 = item.Value1; temp.OldValue = ""; dic.Add(key, temp); } } p.configList = dic.Values.ToList <ConfigInfo>(); ViewData["configList"] = (int)ViewData["configList"] + p.configList.Count; SearchPlugin sh = new SearchPlugin(); sh.PluginCateCode = p.PluginCateCode; p.PCname = BoFactory.GetVersionTrackBo.GetPluginCategoryInfos(sh)[0].DisplayName; } plist.Add(p); } return(View(plist)); }
/// <summary> /// 根据xml 获取pluginInfo /// </summary> /// <param name="xml"></param> /// <returns></returns> private static List <PluginInfoTemp> GetPluginInfoFromXml(XmlDocument xml) { List <PluginInfoTemp> pluginInfoList = new List <PluginInfoTemp>(); // GetBaseInfo(pluginInfo, xml); var pluginInfonodes = xml.SelectNodes("//Plugins/*"); if (pluginInfonodes == null) { throw new ArgumentNullException("没有Plugins节点"); } foreach (XmlNode item in pluginInfonodes) { var pluginInfo = new PluginInfoTemp(); pluginInfoList.Add(pluginInfo); GetBaseInfo(pluginInfo, xml); pluginInfo.DisplayName = GetNodeValue(item.SelectSingleNode("./Name")); pluginInfo.PluginCode = GetNodeValue(item.SelectSingleNode("./PluginCode")); pluginInfo.PluginCateCode = GetNodeValue(item.SelectSingleNode("./PluginCateCode")); pluginInfo.TypeFullName = GetNodeValue(item.SelectSingleNode("./TypeFullName")); pluginInfo.FileName = GetNodeValue(item.SelectSingleNode("./MainFileName")); // pluginInfo.PluginSummary = GetNodeValue(item.SelectSingleNode("./PluginDescription")); pluginInfo.PluginSummary = GetNodeValue(item.SelectSingleNode("./Description")); pluginInfo.IsNeed = GetNodeValue(item.SelectSingleNode("./IsNeed")).ToLower() == "true"; //web插件独有 pluginInfo.PluginUrl = GetNodeValue(item.SelectSingleNode("./Url")); //Action插件独有 pluginInfo.ActionCode = GetNodeValue(item.SelectSingleNode("./ActionCode")); pluginInfo.ActionSummary = GetNodeValue(item.SelectSingleNode("./ActionDescription")); //版本信息 必须 pluginInfo.Version = GetNodeValue(item.SelectSingleNode("./VersionCode")); pluginInfo.VersionSummary = GetNodeValue(item.SelectSingleNode("./VersionDescription")); //是否需要权限控制 if (item.SelectSingleNode("./IsPublic") != null && !string.IsNullOrEmpty(GetNodeValue(item.SelectSingleNode("./IsPublic")))) { pluginInfo.IsPublic = Convert.ToBoolean(GetNodeValue(item.SelectSingleNode("./IsPublic"))); } else { pluginInfo.IsPublic = true; } pluginInfo.AppCode = GetNodeValue(item.SelectSingleNode("./AppCode")); pluginInfo.PrivilegeCode = GetNodeValue(item.SelectSingleNode("./PrivilegeCode")); // 获取配置信息 pluginInfo.configList = GetPluginConfigListByXml(item); } return(pluginInfoList); }
public ActionResult UploadVersionFile(string IsAdd, string Vid, string IsUpdate, string PluginCateCode) { ViewData["code"] = ""; ViewData["ver"] = ""; ViewData["weburl"] = ""; ViewData["IsAdd"] = IsAdd; ViewData["PluginCateCode"] = PluginCateCode; ViewData["IsUpdate"] = ""; if (!string.IsNullOrEmpty(Vid) && !Vid.Equals("undefined")) { ViewData["Vid"] = Vid; SearchVersionTrack searchv = new SearchVersionTrack(); searchv.VID = Vid.Split(',')[0]; string pid = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0].PluginCode.ToString(); PluginInfo p = BoFactory.GetVersionTrackBo.GetPluginInfo(pid); PluginInfoTemp pt = BoFactory.GetVersionTrackBo.GetPluginTempInfo(pid); ViewData["code"] = p.PluginCode; if (pt != null) { ViewData["weburl"] = pt.PluginUrl; ViewData["ver"] = pt.Version; } else { ViewData["weburl"] = p.PluginUrl; ViewData["ver"] = p.Version; } } if (!string.IsNullOrEmpty(IsUpdate)) { ViewData["IsUpdate"] = IsUpdate; } return(View()); }
public ActionResult SavePluginInfos(PluginInfoTemp pt, FormCollection form, ConfigTemp c, string IsAdd) { var vmobject = new JsonReturnMessages(); IList <PluginInfoTemp> listtemp = new List <PluginInfoTemp>(); IList <ConfigTemp> list = new List <ConfigTemp>(); string vids = ""; try { string[] keys = form.AllKeys; //获取插件列表 for (int i = 0; i < keys.Length; i++) { if (keys[i].EndsWith(".PluginCode")) { PluginInfoTemp p = new PluginInfoTemp(); string prefix = keys[i].Split('.')[0]; UpdateModel(p, prefix); //其他数据同时可以获得填充进实体对象 p.CompanyHomePage = pt.CompanyHomePage; p.CompanyLinkman = pt.CompanyLinkman; p.CompanyName = pt.CompanyName; p.CompanyTel = pt.CompanyTel; if (p.IsNeed == true) { p.IsDefault = true; } listtemp.Add(p); } } //获取列表参数 if (listtemp[0].IsIgnoreConfig == false) { for (int i = 0; i < keys.Length; i++) { if (keys[i].EndsWith(".Key1")) { ConfigTemp config = new ConfigTemp(); string prefix = keys[i].Split('.')[0]; UpdateModel(config, prefix); //其他数据同时可以获得填充进实体对象 config.PluginCode = prefix.Split('|')[0]; list.Add(config); } } } BoFactory.GetVersionTrackBo.UpdateTempPlugin(listtemp, list, IsAdd, base.CurrentUser.UserUId); } catch (Exception ex) { vmobject.IsSuccess = false; vmobject.Msg = ex.Message; return(Json(vmobject)); } //获取上一个版本数据 SearchVersionTrack sea = new SearchVersionTrack(); sea.PluginCode = listtemp[0].PluginCode; sea.VersionName = listtemp[0].Version; vids = BoFactory.GetVersionTrackBo.GetVersionTrack(sea)[0].VersionId.ToString();//默认为当前临时表第一个 foreach (PluginInfoTemp pti in listtemp) { SearchVersionTrack search = new SearchVersionTrack(); search.PluginCode = pti.PluginCode.ToString(); search.VersionName = pti.Version; VersionTrack vst = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0]; if (vst.PreVersionId != 0) { vids = vst.PreVersionId.ToString();//获得上一个版本,与修改状态时候,直接选择发布获得的vid一致为上个版本vid break; } } vmobject.IsSuccess = true; vmobject.Msg = vids; return(Json(vmobject)); }
public ActionResult SaveVerInfo(VersionTrack ver, string IsAdd, string IsUpdate, FormCollection form, string PluginCateCode) { var vmobject = new JsonReturnMessages(); string vid = ""; XmlConfigInfo xmlInfo = null; try { if (Request.Files.Count > 0) //若有上传文件 { xmlInfo = Decompressing(form["VersionIds"].ToString(), IsAdd); //解压 } else { IList <PluginInfoTemp> listp = new List <PluginInfoTemp>(); PluginInfoTemp p = new PluginInfoTemp(); p.Version = form["VersionName"]; p.PluginUrl = form["PluginUrl"]; p.PluginCode = form["PluginCode"]; listp.Add(p); xmlInfo = new XmlConfigInfo(); xmlInfo.PluginInfo = listp; } if (PluginCateCode.Equals("1"))//若为web插件 { xmlInfo.PluginInfo[0].PluginCateCode = Constants.PluginCateCode; xmlInfo.oldCode = xmlInfo.PluginInfo[0].PluginCode; } foreach (PluginInfoTemp ps in xmlInfo.PluginInfo) { ps.IsPublic = true; ps.IsIgnoreConfig = Convert.ToBoolean(form["ck"]); } vid = BoFactory.GetVersionTrackBo.SavePluingZipInfo(ver, xmlInfo, IsAdd, IsUpdate, base.CurrentUser.UserUId, form["VersionIds"].ToString()); if (Request.Files.Count > 0) //若有上传文件 { MoveFolder(xmlInfo); //移动文件夹及文件 } } catch (Exception ex) { try { string thisFilePath = AppConfig.filePath + Common.Entities.Constants.TempName; while (Directory.Exists(thisFilePath))//先删除原由临时文件夹 { Directory.Delete(thisFilePath, true); } if (!string.IsNullOrEmpty(xmlInfo.savefile)) { FileInfo f = new FileInfo(xmlInfo.savefile);//删除原本保存的zip if (f.Exists) { f.Delete(); } } } catch (Exception fe) { vmobject.IsSuccess = false; vmobject.Msg = fe.Message; } vmobject.IsSuccess = false; vmobject.Msg = vmobject.Msg + "," + ex.Message; return(Json(vmobject, "text/html")); } //获取上一个版本数据 SearchVersionTrack sea = new SearchVersionTrack(); sea.VID = vid; VersionTrack vt = BoFactory.GetVersionTrackBo.GetVersionTrack(sea)[0]; if (vt != null) { if (vt.PreVersionId != 0) { vid = vt.PreVersionId.ToString(); } } vmobject.Msg = vid; vmobject.IsSuccess = true; return(Json(vmobject, "text/html")); }