Exemplo n.º 1
0
        /// <summary>
        /// 根据xml生成XmlConfigInfo实体
        /// </summary>
        /// <param name="xmlPath"></param>
        /// <returns></returns>
        public static XmlConfigInfo GetEntityFromXML(string xmlPath)
        {
            var configInfo = new XmlConfigInfo();
            var xml        = new XmlDocument();

            xml.Load(xmlPath);
            configInfo.PluginInfo = GetPluginInfoFromXml(xml);


            // configInfo.configList = GetPluginConfigListByXml(xml);
            return(configInfo);
        }
        /// <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);//�ƶ�
        }
        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>
        /// <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 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, 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");
        }
        /// <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 + Common.Entities.Constants.MianName;//��ǰ�������ļ���
            while (!Directory.Exists(FilePath))
            {
                Directory.CreateDirectory(FilePath);
            }

            //string thispath = FilePath + @"\" + xmlInfo.PluginInfo.Version;//��ǰ�ƶ�ȥ���ļ���
            //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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="activeVersion">正在使用的版本</param>
        /// <param name="resumeVersion">恢复的版本</param>
        private void resumeVersionInfo(ArrayList activeVersion, ArrayList resumeVersion, XmlConfigInfo xml)
        {
            try
            {
                string filepaht = "";
                if (activeVersion != null)//若有正在使用的版本(未删除正在使用的版本)
                {
                    foreach (var a in activeVersion)
                    {
                        SearchVersionTrack searchv = new SearchVersionTrack();
                        searchv.VID = a.ToString();
                        VersionTrack v = versionTrackDao.GetVersionTrackList(searchv)[0];
                        v.VersionStatus = 2;
                        versionTrackDao.Update(v);//更新正在使用的版本为过期
                    }
                }
                foreach (var a in resumeVersion)
                {
                    SearchVersionTrack searchv = new SearchVersionTrack();
                    searchv.VID = a.ToString();
                    VersionTrack v = versionTrackDao.GetVersionTrackList(searchv)[0];
                    v.VersionStatus = 1;
                    filepaht = v.FilePath;
                    versionTrackDao.Update(v);//更新正在使用的版本为正在使用
                }
                IList<PluginInfoTemp> plist = xml.PluginInfo;
                //更新除了versiontrack之外的所有表信息
                for (int i = 0; i < plist.Count; i++)
                {
                    SearchConfig search = new SearchConfig();
                    search.PluginCode = plist[i].PluginCode;
                    configInfoDao.DeleteConfigInfo(search);//删除配置

                    ActionExtend action = null;
                    if (plist[i].PluginCateCode.Equals(Constants.ActionCateCode))
                    {
                        actionExtendDao.DelActionExtendInfo(search);//删除action
                        action = new ActionExtend();
                        action.PluginCode = plist[i].PluginCode;
                        action.ActionCode = plist[i].ActionCode;
                        action.Summary = plist[i].ActionSummary;
                    }
                    PluginInfo p = TPluginInfo(plist[i]);//转换
                    p.IsUse = true;//设置使用
                    pluginDao.Delete(p);//删除插件(可能前一个版本是1个插件,当前版本2个插件)
                    ///////////////////////////////////////////////////////////////////////
                    pluginDao.Insert(p);//新增插件
                    foreach (ConfigInfo c in plist[i].configList)
                    {
                        c.ConfigCategoryCode = Constants.configCategory;
                        c.PluginCode = plist[i].PluginCode;
                        configInfoDao.Insert(c);//插入配置
                    }
                    if (plist[i].PluginCateCode.Equals(Constants.ActionCateCode))
                    {
                        InsertActionExtend(action);// 新增action
                    }
                }
                //发布更新
                if (!plist[0].PluginCateCode.Equals(Constants.PluginCateCode))
                {
                    string[] codes = filepaht.Split(new string[] { "\\" }, StringSplitOptions.None);
                    string name = codes[codes.Length - 2];//获取插件code
                    Beyondbit.AutoUpdate.IPublisher pub = new Beyondbit.SmartBox.Publisher.SmartBoxPublisher();
                    pub.UpdateApplication(filepaht, name);
                }
            }
            catch (DalException ex)
            {
                throw new BOException("恢复版本出错", ex);
            }
            catch (Exception e)
            {
                throw new BOException("恢复版本出错", e);
            }
        }
Exemplo n.º 10
0
        public virtual void UpdatePlushVersionTracks(XmlConfigInfo xml, string vid, string uid)
        {
            try
            {
                foreach (PluginInfoTemp pt in xml.PluginInfo)
                {
                    if (pt.IsIgnoreConfig == false)
                    {
                        SearchConfig search = new SearchConfig();
                        search.PluginCode = pt.PluginCode;
                        configInfoDao.DeleteConfigInfo(search);//先删除原由真实参数表数据
                    }
                }

                string[] arrs = xml.PluginInfo[0].PreVersionPCs.Split(new string[] { "_FG$SP_" }, StringSplitOptions.None);
                //设置原有版本的插件为未发布。再设置当前的插件为发布
                if (!string.IsNullOrEmpty(xml.PluginInfo[0].PreVersionPCs))
                {
                    foreach (string arr in arrs)
                    {
                        PluginInfo pp = pluginDao.Get(arr);
                        if (pp != null)
                        {
                            pp.IsUse = false;
                            pluginDao.Update(pp);
                        }
                    }
                }
                //更新原由版本为过期
                SearchVersionTrack searchtemps = new SearchVersionTrack();
                searchtemps.VID = vid;
                VersionTrack vsss = versionTrackDao.GetVersionTrackList(searchtemps)[0];
                string filepath = vsss.FilePath;
                SearchVersionTrack setemp = new SearchVersionTrack();
                setemp.filepath = filepath;
                IList<VersionTrack> vlisttemp = versionTrackDao.GetVersionTrackList(setemp);//获得上一所有插件版本
                foreach (VersionTrack v in vlisttemp)
                {
                    v.VersionStatus = 2;
                    versionTrackDao.Update(v);
                }

                foreach (PluginInfoTemp pt in xml.PluginInfo)
                {
                    PluginInfo p = TPluginInfo(pt);
                    p.CreateTime = DateTime.Now;
                    p.CreateUid = uid;
                    p.LastModTime = DateTime.Now;
                    p.LastModUid = uid;
                    int a = 0;
                    foreach (string arr in arrs)
                    {
                        if (pt.PluginCode.Equals(arr))
                        {
                            a = 1;
                            break;
                        }
                    }
                    //更新插件信息
                    if (a == 1)
                    {
                        PluginInfo oldP = pluginDao.Get(p.PluginCode);
                        p.CreateUid = oldP.CreateUid;
                        p.CreateTime = oldP.CreateTime;
                        p.IsUse = true;//设置为发布
                        pluginDao.Update(p);
                    }
                    else
                    {
                        p.IsUse = true;//设置为发布
                        InsertPluginInfo(p, uid);
                    }

                    plugintempDao.Delete(pt);//删除插件临时表

                    if (pt.IsIgnoreConfig == false)
                    {
                        SearchConfig search = new SearchConfig();
                        search.PluginCode = pt.PluginCode;

                        //没修改基本信息,直接发布,需要覆盖
                        foreach (ConfigInfo c in pt.configList)
                        {
                            SearchConfig searchcc = new SearchConfig();
                            searchcc.PluginCode = pt.PluginCode;
                            searchcc.ConfigCategoryCode = Constants.configCategory;
                            searchcc.key = c.Key1;
                            IList<ConfigInfo> listct = configInfoDao.GetConfigList(searchcc);
                            c.ConfigCategoryCode = Constants.configCategory;
                            if (listct.Count > 0)
                                configInfoDao.Update(c);
                            else
                                configInfoDao.Insert(c);
                        }

                        configTempDao.DeleteInfo(search);//删除当前插件临时表数据
                    }

                    //修改扩展信息
                    if (pt.PluginCateCode.Equals(Constants.ActionCateCode))
                    {
                        ActionExtend action = new ActionExtend();
                        action.PluginCode = pt.PluginCode;
                        action.ActionCode = pt.ActionCode;
                        action.Summary = pt.ActionSummary;

                        SearchConfig searchconfig = new SearchConfig();
                        searchconfig.PluginCode = pt.PluginCode.ToString();
                        IList<ActionExtend> listAction = BoFactory.GetVersionTrackBo.QueryActionExtend(searchconfig);
                        if (listAction.Count > 0)//若存在记录,即更新
                            UpdateActionExtend(action);
                        else
                            InsertActionExtend(action);
                    }

                    SearchVersionTrack searchv = new SearchVersionTrack();
                    searchv.PluginCode = pt.PluginCode;
                    searchv.VersionName = pt.Version;
                    VersionTrack ver = versionTrackDao.GetVersionTrackList(searchv)[0];//当前版本
                    ver.VersionStatus = 1;
                    ver.VersionSummary = pt.VersionSummary;
                    versionTrackDao.Update(ver);
                }
            }
            catch (DalException ex)
            {
                throw new BOException("修改主程序版本信息出错", ex);
            }
        }
Exemplo n.º 11
0
        public virtual string SavePluingZipInfo(VersionTrack version, XmlConfigInfo xmlInfo, string IsAdd, string IsUpdate, string uid, string vids)
        {
            string oldfp = "";
            string oldname = "";
            string PluginCode = "";
            IList<PluginInfoTemp> plist = xmlInfo.PluginInfo;
            SearchVersionTrack search = new SearchVersionTrack();
            ArrayList arrVid = new ArrayList();
            string arrCode = "";

            try
            {
                //升级(修改)的时候
                //获得关联的vid和code(根据相同的filepath获得相关的VID)
                search.VID = vids.Split(',')[0];
                if (!string.IsNullOrEmpty(vids))
                {
                    VersionTrack vs = versionTrackDao.GetVersionTrackList(search)[0];

                    if (IsAdd.Equals("0"))
                    {
                        int ass = 0;
                        for (int i = 0; i < plist.Count; i++)
                        {
                            if (vs.PluginCode.Equals(plist[i].PluginCode))
                            {
                                ass = 1;
                                break;
                            }
                        }
                        if (ass == 0)
                        {
                            throw new BOException("上传插件code不匹配");
                        }
                    }

                    string filepath = vs.FilePath;
                    SearchVersionTrack setemp = new SearchVersionTrack();
                    setemp.filepath = filepath;
                    IList<VersionTrack> vlisttemp = versionTrackDao.GetVersionTrackList(setemp);//获得当前关联所有插件版本
                    foreach (VersionTrack vtemp in vlisttemp)
                    {
                        SearchVersionTrack searcht = new SearchVersionTrack();
                        searcht.PreVersionId = vtemp.VersionId.ToString();//查找下一个最新版本是否存在
                        IList<VersionTrack> templist = versionTrackDao.GetVersionTrackList(searcht);
                        if (templist.Count > 0)
                        {
                            filepath = templist[0].FilePath;
                            break;
                        }
                    }

                    SearchVersionTrack se = new SearchVersionTrack();
                    se.filepath = filepath;
                    IList<VersionTrack> vlist = versionTrackDao.GetVersionTrackList(se);//获取最新当前所有关联版本信息
                    foreach (VersionTrack v1 in vlist)
                    {
                        arrVid.Add(v1.VersionId);//获取要删除的版本ID(最新版本)

                    }

                    se.filepath = vs.FilePath;
                    IList<VersionTrack> vlistc = versionTrackDao.GetVersionTrackList(se);
                    foreach (VersionTrack v1 in vlistc)
                    {
                        arrCode += v1.PluginCode + "_FG$SP_";//获取插件CODE(原由版本)

                    }
                    arrCode = arrCode.Substring(0, arrCode.Length - 7);
                }
                //删除
                if (!string.IsNullOrEmpty(IsUpdate))//若为修改
                {
                    for (int i = 0; i < arrVid.Count; i++)
                    {
                        search.VID = arrVid[i].ToString();
                        VersionTrack v = versionTrackDao.GetVersionTrackList(search)[0];//2.获取表一记录
                        PluginCode = v.PluginCode;
                        if (i == 0)//第一个插件CODE
                        {
                            string[] codes = v.FilePath.Split(new string[] { "\\" }, StringSplitOptions.None);
                            oldfp = v.FilePath;
                            oldname = codes[codes.Length - 1];//版本名
                        }
                        //1.先删除插件临时表
                        SearchConfig searchc = new SearchConfig();
                        searchc.PluginCode = PluginCode.ToString();
                        configTempDao.DeleteInfo(searchc);

                        plugintempDao.DeleteInfo(searchc);//删除配置信息临时表
                        //2.删除版本表信息
                        versionTrackDao.DeleteInfo(search);
                        //3.若是新增(修改)
                        if (IsAdd.Equals("1"))
                        {
                            pluginDao.DeleteInfo(searchc);//.删除插件表
                        }
                    }
                }
                //这里开始新增或者升级或者修改的共同部分处理
                for (int i = 0; i < plist.Count; i++)
                {
                    PluginInfo p = TPluginInfo(plist[i]);//转换
                    if (IsAdd.Equals("1"))//若新增
                    {
                        p.IsUse = false;//设置为未发布
                        plist[i].IsUse = false;
                        PluginCode = InsertPluginInfo(p, uid);//.新增插件表
                    }
                    else//若升级
                    {
                        p.IsUse = false;
                        plist[i].IsUse = false;
                        PluginCode = p.PluginCode;
                    }
                    //4.新增版本表
                    version.PluginCode = PluginCode;
                    version.FilePath = Path.Combine(AppConfig.filePath + xmlInfo.oldCode, xmlInfo.PluginInfo[0].PluginCode + "_FG$SP_" + xmlInfo.PluginInfo[0].Version);//以第一个插件CODE+版本号记录,3个版本存放位置相同
                    version.VersionName = plist[i].Version;
                    version.CreateUid = uid;
                    version.LastModUid = uid;
                    version.VersionStatus = 3;
                    version.VersionSummary = plist[i].VersionSummary;
                    if (IsAdd.Equals("0"))
                        version.VersionStatus = 0;
                    if (i == 0)
                        vids = InsertVersionTrack(version).ToString();//记录第一个vid
                    else
                        InsertVersionTrack(version).ToString();//升级可以重复覆盖原由版本,新赠插件的时候,不可能出现重复版本
                    //5.新赠插件临时表
                    PluginInfoTemp pt = plist[i];
                    pt.PluginCode = PluginCode;
                    //记录原先的上一版本的所有插件CODE,用于更新发布状态
                    if (IsAdd.Equals("0"))//若升级
                    {
                        pt.PreVersionPCs = arrCode;
                    }
                    else
                    {
                        foreach (PluginInfoTemp pi in plist)
                        {
                            pt.PreVersionPCs += pi.PluginCode + "_FG$SP_";
                        }
                        pt.PreVersionPCs = pt.PreVersionPCs.Substring(0, pt.PreVersionPCs.Length - 7);
                    }

                    plugintempDao.Insert(pt);

                    //若不是web插件
                    if (!plist[i].PluginCateCode.Equals(Constants.PluginCateCode))
                    {
                        if (plist[i].IsIgnoreConfig == false)//非忽略配置信息
                        {
                            //转换
                            IList<ConfigTemp> listts = new List<ConfigTemp>();
                            foreach (ConfigInfo c in plist[i].configList)
                            {
                                listts.Add(CommonMethods.ConvertToConfigInfo(c));
                            }
                            InserConfigInfo(listts, PluginCode.ToString(), Constants.configCategory);//新赠插件配置临时表
                        }
                    }
                }

                if (Directory.Exists(oldfp)) //5.需要删除原由文件夹
                    Directory.Delete(oldfp, true);
                //需要删除存在的位置的原由文件
                FileInfo f = new FileInfo(Path.Combine(AppConfig.SaveZipPath, oldname + ".zip"));
                if (f.Exists)
                    f.Delete();

                if (plist[0].PluginCateCode.Equals(Constants.PluginCateCode))//若是web插件
                {
                    while (!Directory.Exists(version.FilePath))//单独创建文件夹
                    {
                        Directory.CreateDirectory(version.FilePath);
                    }
                }

                return vids;
            }
            catch (DalException ex)
            {
                throw new BOException("上传插件zip文件出错", ex);
            }
        }
Exemplo n.º 12
0
        /*
        public static void WriteConfigListXml(IList<ConfigInfo> list, string fileName)
        {
            XmlDocument xml = SetXmlByConfigList(list);
            xml.Save(fileName);

        }
        */
        public static void WritePluginfoConfigXml(XmlConfigInfo configInfo, string fileName)
        {
            XmlDocument xml = new XmlDocument();
            XmlNode declare = xml.CreateXmlDeclaration("1.0", "UTF-8", "yes");
            xml.AppendChild(declare);

            XmlElement pluginInfoElement = xml.CreateElement("PluginInfo");
            xml.AppendChild(pluginInfoElement);

            XmlElement baseInfoElement = xml.CreateElement("BaseInfo");
            pluginInfoElement.AppendChild(baseInfoElement);

            XmlElement Plugins = xml.CreateElement("Plugins");
            pluginInfoElement.AppendChild(Plugins);

            int i = 0;
            foreach (var PluginInfo in configInfo.PluginInfo)
            {
                #region  BaseInfo

                i++;
                if (i <= 1)
                {
                    XmlElement CompanyNameElement = xml.CreateElement("CompanyName");

                    CompanyNameElement.InnerText = PluginInfo.CompanyName;
                    baseInfoElement.AppendChild(CompanyNameElement);

                    XmlElement CompanyLinkmanElement = xml.CreateElement("CompanyLinkman");
                    CompanyLinkmanElement.InnerText = PluginInfo.CompanyLinkman;
                    baseInfoElement.AppendChild(CompanyLinkmanElement);

                    XmlElement CompanyTelElement = xml.CreateElement("CompanyTel");
                    CompanyTelElement.InnerText = PluginInfo.CompanyTel;
                    baseInfoElement.AppendChild(CompanyTelElement);

                    XmlElement CompanyHomePageElement = xml.CreateElement("CompanyHomePage");
                    CompanyHomePageElement.InnerText = PluginInfo.CompanyHomePage;
                    baseInfoElement.AppendChild(CompanyHomePageElement);
                }
                #endregion

                #region Plugin

                XmlElement Plugin = xml.CreateElement("Plugin");
                Plugins.AppendChild(Plugin);

                XmlElement NameElement = xml.CreateElement("Name");
                NameElement.InnerText = PluginInfo.DisplayName;
                Plugin.AppendChild(NameElement);
                XmlElement CodeElement = xml.CreateElement("PluginCode");
                CodeElement.InnerText = PluginInfo.PluginCode;
                Plugin.AppendChild(CodeElement);
                XmlElement PluginCateCodeElement = xml.CreateElement("PluginCateCode");
                PluginCateCodeElement.InnerText = PluginInfo.PluginCateCode;
                Plugin.AppendChild(PluginCateCodeElement);
                XmlElement TypeFullNameElement = xml.CreateElement("TypeFullName");
                TypeFullNameElement.InnerText = PluginInfo.TypeFullName;
                Plugin.AppendChild(TypeFullNameElement);
                XmlElement MainFileNameElement = xml.CreateElement("MainFileName");
                MainFileNameElement.InnerText = PluginInfo.FileName;
                Plugin.AppendChild(MainFileNameElement);
                XmlElement DescriptionElement = xml.CreateElement("Description");
                DescriptionElement.InnerText = PluginInfo.PluginSummary;
                Plugin.AppendChild(DescriptionElement);
                XmlElement IsNeedElement = xml.CreateElement("IsNeed");
                IsNeedElement.InnerText = PluginInfo.IsNeed.ToString().ToLower();
                Plugin.AppendChild(IsNeedElement);
                XmlElement FileHashElement = xml.CreateElement("FileHash");
                FileHashElement.InnerText = PluginInfo.HashCode;
                Plugin.AppendChild(FileHashElement);
                XmlElement UrlElement = xml.CreateElement("Url");
                UrlElement.InnerText = PluginInfo.PluginUrl;
                Plugin.AppendChild(UrlElement);

                //IsPublic
                XmlElement IsPublicElement = xml.CreateElement("IsPublic");
                IsPublicElement.InnerText = PluginInfo.IsPublic.ToString();
                Plugin.AppendChild(IsPublicElement);

                #region VersionInfo

                XmlElement VersionElement = xml.CreateElement("VersionCode");
                VersionElement.InnerText = PluginInfo.Version;
                Plugin.AppendChild(VersionElement);

                XmlElement VersionDesElement = xml.CreateElement("VersionDescription");
                VersionDesElement.InnerText = PluginInfo.VersionSummary;
                Plugin.AppendChild(VersionDesElement);

                #endregion

                #region Action
                XmlElement ActionElement = xml.CreateElement("ActionCode");
                ActionElement.InnerText = PluginInfo.ActionCode;
                Plugin.AppendChild(ActionElement);
                XmlElement ActionDescriptionElement = xml.CreateElement("ActionDescription");
                ActionDescriptionElement.InnerText = PluginInfo.ActionSummary;
                Plugin.AppendChild(ActionDescriptionElement);
                #endregion

                #endregion

                #region  Configs
                XmlElement configListElement = xml.CreateElement("Configs");

                //    Plugins.AppendChild(configListElement);
                Plugin.AppendChild(configListElement);
                foreach (var c in PluginInfo.configList)
                {
                    XmlElement configElement = xml.CreateElement("Config");
                    configListElement.AppendChild(configElement);

                    XmlElement keyElement = xml.CreateElement("key");
                    keyElement.InnerText = c.Key1;
                    configElement.AppendChild(keyElement);

                    XmlElement valueElement = xml.CreateElement("value");
                    valueElement.InnerText = c.Value1;
                    configElement.AppendChild(valueElement);

                }
                #endregion

            }

            xml.Save(fileName);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 根据xml生成XmlConfigInfo实体
        /// </summary>
        /// <param name="xmlPath"></param>
        /// <returns></returns>
        public static XmlConfigInfo GetEntityFromXML(string xmlPath)
        {
            var configInfo = new XmlConfigInfo();
            var xml = new XmlDocument();
            xml.Load(xmlPath);
            configInfo.PluginInfo = GetPluginInfoFromXml(xml);

            // configInfo.configList = GetPluginConfigListByXml(xml);
            return configInfo;
        }
Exemplo n.º 14
0
        /*
         * public static void WriteConfigListXml(IList<ConfigInfo> list, string fileName)
         * {
         *  XmlDocument xml = SetXmlByConfigList(list);
         *  xml.Save(fileName);
         *
         * }
         */
        public static void WritePluginfoConfigXml(XmlConfigInfo configInfo, string fileName)
        {
            XmlDocument xml     = new XmlDocument();
            XmlNode     declare = xml.CreateXmlDeclaration("1.0", "UTF-8", "yes");

            xml.AppendChild(declare);

            XmlElement pluginInfoElement = xml.CreateElement("PluginInfo");

            xml.AppendChild(pluginInfoElement);

            XmlElement baseInfoElement = xml.CreateElement("BaseInfo");

            pluginInfoElement.AppendChild(baseInfoElement);

            XmlElement Plugins = xml.CreateElement("Plugins");

            pluginInfoElement.AppendChild(Plugins);

            int i = 0;

            foreach (var PluginInfo in configInfo.PluginInfo)
            {
                #region  BaseInfo

                i++;
                if (i <= 1)
                {
                    XmlElement CompanyNameElement = xml.CreateElement("CompanyName");

                    CompanyNameElement.InnerText = PluginInfo.CompanyName;
                    baseInfoElement.AppendChild(CompanyNameElement);

                    XmlElement CompanyLinkmanElement = xml.CreateElement("CompanyLinkman");
                    CompanyLinkmanElement.InnerText = PluginInfo.CompanyLinkman;
                    baseInfoElement.AppendChild(CompanyLinkmanElement);

                    XmlElement CompanyTelElement = xml.CreateElement("CompanyTel");
                    CompanyTelElement.InnerText = PluginInfo.CompanyTel;
                    baseInfoElement.AppendChild(CompanyTelElement);

                    XmlElement CompanyHomePageElement = xml.CreateElement("CompanyHomePage");
                    CompanyHomePageElement.InnerText = PluginInfo.CompanyHomePage;
                    baseInfoElement.AppendChild(CompanyHomePageElement);
                }
                #endregion

                #region Plugin


                XmlElement Plugin = xml.CreateElement("Plugin");
                Plugins.AppendChild(Plugin);

                XmlElement NameElement = xml.CreateElement("Name");
                NameElement.InnerText = PluginInfo.DisplayName;
                Plugin.AppendChild(NameElement);
                XmlElement CodeElement = xml.CreateElement("PluginCode");
                CodeElement.InnerText = PluginInfo.PluginCode;
                Plugin.AppendChild(CodeElement);
                XmlElement PluginCateCodeElement = xml.CreateElement("PluginCateCode");
                PluginCateCodeElement.InnerText = PluginInfo.PluginCateCode;
                Plugin.AppendChild(PluginCateCodeElement);
                XmlElement TypeFullNameElement = xml.CreateElement("TypeFullName");
                TypeFullNameElement.InnerText = PluginInfo.TypeFullName;
                Plugin.AppendChild(TypeFullNameElement);
                XmlElement MainFileNameElement = xml.CreateElement("MainFileName");
                MainFileNameElement.InnerText = PluginInfo.FileName;
                Plugin.AppendChild(MainFileNameElement);
                XmlElement DescriptionElement = xml.CreateElement("Description");
                DescriptionElement.InnerText = PluginInfo.PluginSummary;
                Plugin.AppendChild(DescriptionElement);
                XmlElement IsNeedElement = xml.CreateElement("IsNeed");
                IsNeedElement.InnerText = PluginInfo.IsNeed.ToString().ToLower();
                Plugin.AppendChild(IsNeedElement);
                XmlElement FileHashElement = xml.CreateElement("FileHash");
                FileHashElement.InnerText = PluginInfo.HashCode;
                Plugin.AppendChild(FileHashElement);
                XmlElement UrlElement = xml.CreateElement("Url");
                UrlElement.InnerText = PluginInfo.PluginUrl;
                Plugin.AppendChild(UrlElement);

                //IsPublic
                XmlElement IsPublicElement = xml.CreateElement("IsPublic");
                IsPublicElement.InnerText = PluginInfo.IsPublic.ToString();
                Plugin.AppendChild(IsPublicElement);

                #region VersionInfo


                XmlElement VersionElement = xml.CreateElement("VersionCode");
                VersionElement.InnerText = PluginInfo.Version;
                Plugin.AppendChild(VersionElement);

                XmlElement VersionDesElement = xml.CreateElement("VersionDescription");
                VersionDesElement.InnerText = PluginInfo.VersionSummary;
                Plugin.AppendChild(VersionDesElement);

                #endregion

                #region Action
                XmlElement ActionElement = xml.CreateElement("ActionCode");
                ActionElement.InnerText = PluginInfo.ActionCode;
                Plugin.AppendChild(ActionElement);
                XmlElement ActionDescriptionElement = xml.CreateElement("ActionDescription");
                ActionDescriptionElement.InnerText = PluginInfo.ActionSummary;
                Plugin.AppendChild(ActionDescriptionElement);
                #endregion

                #endregion

                #region  Configs
                XmlElement configListElement = xml.CreateElement("Configs");

                //    Plugins.AppendChild(configListElement);
                Plugin.AppendChild(configListElement);
                foreach (var c in PluginInfo.configList)
                {
                    XmlElement configElement = xml.CreateElement("Config");
                    configListElement.AppendChild(configElement);


                    XmlElement keyElement = xml.CreateElement("key");
                    keyElement.InnerText = c.Key1;
                    configElement.AppendChild(keyElement);

                    XmlElement valueElement = xml.CreateElement("value");
                    valueElement.InnerText = c.Value1;
                    configElement.AppendChild(valueElement);
                }
                #endregion
            }


            xml.Save(fileName);
        }