/// <summary> /// 移动文件夹 /// </summary> /// <param name="xmlInfo"></param> private void MoveFolder(XmlConfigInfo xmlInfo) { FileInfo f = new FileInfo(xmlInfo.savefile); FileInfo oldfile = new FileInfo(xmlInfo.oldfile); if (oldfile.Exists)//判断是否需要删除原由文件 { oldfile.Delete(); } f.MoveTo(xmlInfo.oldfile);//规则:code+版本名 string thisFilePath = AppConfig.filePath + Common.Entities.Constants.TempName; //创建文件以versionname为名的文件夹在指定根目录下 //string FilePath = AppConfig.filePath + xmlInfo.PluginInfo.PluginCode;//当前插件CODE文件夹 //while (!Directory.Exists(FilePath)) //{ // Directory.CreateDirectory(FilePath); //} //string thispath = FilePath + @"\"; //+ xmlInfo.VersionName;//当前移动的去的文件夹 //if (Directory.Exists(thispath)) // Directory.Delete(thispath, true); //Directory.Move(thisFilePath, thispath);//移动 }
/// <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); }
/// <summary> /// 解压、获取信息、移动文件夹 /// </summary> /// <returns></returns> private XmlConfigInfo Decompressing() { string thisFilePath = AppConfig.filePath + Common.Entities.Constants.TempName; while (!Directory.Exists(thisFilePath))//创建临时文件夹 { Directory.CreateDirectory(thisFilePath); } string zipPaht = AppConfig.SaveZipPath; while (!Directory.Exists(zipPaht))//创建存放zip文件的文件夹 { Directory.CreateDirectory(zipPaht); } string saveFile = zipPaht + @"\" + System.Guid.NewGuid().ToString() + ".zip"; Request.Files[0].SaveAs(saveFile); //保存zip去文件夹下 CommonMethods.Uncompress(saveFile, thisFilePath); //解压 XmlConfigInfo xmlInfo = GetXmlInfo(thisFilePath); //获取解析出来的配置信息 //string oldfilepath = zipPaht + @"\" + xmlInfo.PluginInfo.PluginCode + xmlInfo.PluginInfo.Version + ".zip";//已上传的zip文件 //xmlInfo.savefile = saveFile; //xmlInfo.oldfile = oldfilepath; return(xmlInfo); }
/// <summary> /// 解析XML获取信息 /// </summary> /// <returns></returns> private XmlConfigInfo GetXmlInfo(string xmlpath) { XmlConfigInfo x = CommonMethods.GetEntityFromXML(Path.Combine(xmlpath, Common.Entities.Constants.PluginPath)); x.PluginInfo = x.PluginInfo.OrderBy(T => T.PluginCode).ToList(); return(x); }
/// <summary> /// 移动文件夹 /// </summary> /// <param name="xmlInfo"></param> private void MoveFolder(XmlConfigInfo xmlInfo) { FileInfo f = new FileInfo(xmlInfo.savefile); //移动前。需要删除移动去的位置是否存在原由文件 FileInfo oldfile = new FileInfo(xmlInfo.oldfile); if (oldfile.Exists)//判断是否需要删除原由文件 { oldfile.Delete(); } f.MoveTo(xmlInfo.oldfile);//规则:code+版本名 string thisFilePath = AppConfig.filePath + Common.Entities.Constants.TempName; //创建文件以versionname为名的文件夹在指定根目录下 string FilePath = Path.Combine(AppConfig.filePath, xmlInfo.oldCode);//当前插件CODE文件夹 while (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } //规则:以第一个插件的CODE为主文件夹,以第一个插件的CODE+版本命名的版本文件夹 string thispath = Path.Combine(FilePath, xmlInfo.PluginInfo[0].PluginCode + "_FG$SP_" + xmlInfo.PluginInfo[0].Version);//当前移动的去的文件夹 //移动前删除新CODE下是否存在该版本文件夹 if (Directory.Exists(thispath)) { Directory.Delete(thispath, true); } Directory.Move(thisFilePath, thispath);//移动 }
/// <summary> /// 写入XML /// </summary> /// <param name="path"></param> private void InsertXml(VersionTrack ver) { XmlConfigInfo xml = new XmlConfigInfo(); //xml.VersionName = ver.VersionName; //xml.PluginInfo = BoFactory.GetVersionTrackBo.GetPluginInfo(ver.PluginCode.ToString());//获取插件信息 SearchConfig serach = new SearchConfig(); serach.PluginCode = ver.PluginCode.ToString(); //xml.configList = BoFactory.GetVersionTrackBo.GetConfigList(serach);//获取配置信息 CommonMethods.WritePluginfoConfigXml(xml, ver.FilePath.Trim() + @"\" + Constants.pluginName); }
/// <summary> /// 解压、获取信息 /// </summary> /// <returns></returns> private XmlConfigInfo Decompressing(string vid, string isAdd) { string thisFilePath = AppConfig.filePath + Common.Entities.Constants.TempName; while (!Directory.Exists(thisFilePath))//创建临时文件夹 { Directory.CreateDirectory(thisFilePath); } string zipPaht = AppConfig.SaveZipPath; while (!Directory.Exists(zipPaht))//创建存放zip文件的文件夹 { Directory.CreateDirectory(zipPaht); } string saveFile = Path.Combine(zipPaht, System.Guid.NewGuid().ToString() + ".zip"); Request.Files[0].SaveAs(saveFile); //保存zip去文件夹下 CommonMethods.Uncompress(saveFile, thisFilePath); //解压 XmlConfigInfo xmlInfo = new XmlConfigInfo(); xmlInfo.savefile = saveFile; xmlInfo = GetXmlInfo(thisFilePath);//获取解析出来的配置信息 //若升级,以原由CODE文件夹+第一个插件版本名命 if (isAdd.Equals("0")) { SearchVersionTrack search = new SearchVersionTrack(); search.VID = vid; VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0]; string[] codes = v.FilePath.Split(new string[] { "\\" }, StringSplitOptions.None); xmlInfo.oldCode = codes[codes.Length - 2]; } else { xmlInfo.oldCode = xmlInfo.PluginInfo[0].PluginCode;//否则以第一个排序后的CODE为文件夹 } //zip文件有第一个CODE+版本号命名 string oldfilepath = Path.Combine(zipPaht, xmlInfo.PluginInfo[0].PluginCode + "_FG$SP_" + xmlInfo.PluginInfo[0].Version + ".zip");//重命名的zip文件 xmlInfo.savefile = saveFile; xmlInfo.oldfile = oldfilepath; return(xmlInfo); }
public ActionResult SaveVerInfo(VersionTrack ver, string IsAdd, FormCollection form) { var vmobject = new JsonReturnMessages(); string vid = ""; if (Request.Files.Count > 0) { XmlConfigInfo xmlInfo = Decompressing(); try { //vid = BoFactory.GetVersionTrackBo.SavePluingZipInfo(ver, xmlInfo, IsAdd, base.CurrentUser.UserUId); MoveFolder(xmlInfo); } catch (Exception ex) { string thisFilePath = AppConfig.filePath + Common.Entities.Constants.TempName; while (Directory.Exists(thisFilePath)) //先删除原由临时文件夹 { Directory.Delete(thisFilePath, true); } FileInfo f = new FileInfo(xmlInfo.savefile); //删除原本保存的zip f.Delete(); vmobject.IsSuccess = false; vmobject.Msg = ex.Message; return(Json(vmobject, "text/html")); } } else { vid = ver.VersionId.ToString(); } vmobject.IsSuccess = true; vmobject.Msg = vid; return(Json(vmobject, "text/html")); }
public ActionResult SavePublishInfo(string Vid, FormCollection form) { var vmobject = new JsonReturnMessages(); try { XmlConfigInfo x = InsertXml(Vid); //写入XML SearchVersionTrack search = new SearchVersionTrack(); ArrayList vids = GetArray(Vid); //获得相关联的VID search.VID = vids[0].ToString(); VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0]; string[] codes = v.FilePath.Split(new string[] { "\\" }, StringSplitOptions.None); string name = codes[codes.Length - 2];//获取插件code Beyondbit.AutoUpdate.IPublisher pub = new Beyondbit.SmartBox.Publisher.SmartBoxPublisher(); if (Directory.Exists(Path.Combine(AppConfig.pubFolder, name + AppConfig.subFix)))//如果存在次文件夹 { pub.UpdateApplication(v.FilePath, name); } else { pub.CreateApplication(v.FilePath, name); } BoFactory.GetVersionTrackBo.UpdatePlushVersionTracks(x, Vid, base.CurrentUser.UserUId);//更新状态 vmobject.IsSuccess = true; vmobject.Msg = "操作成功"; } catch (Exception ex) { vmobject.IsSuccess = false; vmobject.Msg = ex.Message; } return(Json(vmobject)); }
private XmlConfigInfo InsertXmlByConfig(string Vid) { XmlConfigInfo xml = new XmlConfigInfo(); ArrayList vids = GetArrays(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]; PluginInfo p = BoFactory.GetVersionTrackBo.GetPluginInfo(v.PluginCode.ToString()); serach.PluginCode = v.PluginCode.ToString(); IList <ConfigInfo> listct = BoFactory.GetVersionTrackBo.GetConfigList(serach);//获取配置信息 p.configList = listct; p.VersionSummary = v.VersionSummary; if (p.PluginCateCode.Equals(Constants.ActionCateCode)) { SearchConfig search = new SearchConfig(); search.PluginCode = p.PluginCode; ActionExtend a = BoFactory.GetVersionTrackBo.QueryActionExtend(search)[0]; p.ActionCode = a.ActionCode; p.ActionSummary = a.Summary; } list.Add(TPluginInfo(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); }
/// <summary> /// 解析XML获取信息 /// </summary> /// <returns></returns> private XmlConfigInfo GetXmlInfo(string xmlpath) { XmlConfigInfo x = CommonMethods.GetEntityFromXML(xmlpath + @"\" + Common.Entities.Constants.PluginPath); return(x); }
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")); }