public ActionResult GetUserInfo(FormCollection form, string UserStatus)
 {
     JsonFlexiGridData data = null;
     PageView view = new PageView(form);
     SearchConfig search = new SearchConfig();
     search.status = UserStatus;
     data = BoFactory.GetVersionTrackBo.GetUserInfo(view, search);
     return Json(data);
 }
        public virtual void UpdateTempPlugin(IList<PluginInfoTemp> plist, IList<ConfigTemp> listc, string IsAdd, string uid)
        {
            try
            {
                foreach (PluginInfoTemp p in plist)
                {
                    if (!string.IsNullOrEmpty(p.ActionCode))
                    {
                        SearchConfig search = new SearchConfig();
                        search.code = p.ActionCode;
                        IList<ActionExtend> list = QueryActionExtend(search);
                        if (list != null)
                        {
                            if (list.Count > 0 && !list[0].PluginCode.Equals(p.PluginCode))
                                throw new BOException("插件扩展信息标识不能重复");
                        }
                        IList<PluginInfoTemp> listtemp = QueryActionExtends(search);
                        if (listtemp != null)
                        {
                            if (listtemp.Count > 0 && !listtemp[0].PluginCode.Equals(p.PluginCode))
                                throw new BOException("插件扩展信息标识不能重复");
                        }
                    }
                    plugintempDao.Update(p);//更新临时插件

                    if (p.IsIgnoreConfig == false)
                    {
                        SearchConfig searchc = new SearchConfig();
                        searchc.PluginCode = p.PluginCode;
                        configTempDao.DeleteInfo(searchc);
                    }
                }

                if (plist[0].IsIgnoreConfig == false)
                {
                    if (listc != null)
                    {
                        if (listc.Count > 0)
                            InserConfigInfo(listc, plist[0].PluginCode, Constants.configCategory);//更新配置
                    }
                }
            }
            catch (DalException ex)
            {
                throw new BOException("新增插件扩展信息出错", ex);
            }
        }
        /// <summary>
        /// �XML
        /// </summary>
        /// <param name="path"></param>
        private XmlMainConfigInfo InsertXml(string Vid)
        {
            XmlMainConfigInfo xml = new XmlMainConfigInfo();
            SearchVersionTrack searchv = new SearchVersionTrack();
            SearchConfig serach = new SearchConfig();

            searchv.VID = Vid;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0];

            serach.PluginCode = v.PluginCode.ToString();
            IList<ConfigTemp> listct = BoFactory.GetVersionTrackBo.GetConfigListTemp(serach);//��ȡ������Ϣ

            IList<ConfigInfoPC> listc = new List<ConfigInfoPC>();
            foreach (ConfigTemp c in listct)
            {
                listc.Add(CommonMethods.ConvertToConfigInfoPC(c));//ת��
            }
            xml.configList = listc;

            CommonMethods.WriteMaininfoConfigXml(listc, Path.Combine(v.FilePath.Trim() , Constants.UpdaterName));

            return xml;
        }
        public ActionResult UpdatePluginInfo(string Vid, string IsAdd)
        {
            ViewData["configList"] = 0;
            ViewData["IsAdd"] = IsAdd;
            SearchVersionTrack search = new SearchVersionTrack();
            search.VID = Vid;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];

            SearchConfig searchc = new SearchConfig();
            searchc.PluginCode = v.PluginCode.ToString();
            searchc.ConfigCategoryCode = Constants.UpdaterConfig;
            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 + "_FG$SP_" + item.ConfigCategoryCode;
                ConfigInfo temp = new ConfigInfo();
                temp.Key1 = item.Key1;
                temp.OldValue = item.Value1;
                temp.ConfigCategoryCode = item.ConfigCategoryCode;
                temp.PluginCode = Constants.UpdaterCode;
                dic.Add(key, temp);
            }
            IList<ConfigTemp> listT = BoFactory.GetVersionTrackBo.GetConfigListTemp(searchc);//������ʱ������
            foreach (var item in listT)
            {
                var key = item.Key1 + "_FG$SP_" + item.PluginCode + "_FG$SP_" + item.ConfigCategoryCode;
                if (dic.ContainsKey(key))
                    dic[key].Value1 = item.Value1;
                else
                {
                    ConfigInfo temp = new ConfigInfo();
                    temp.Key1 = item.Key1;
                    temp.Value1 = item.Value1;
                    temp.OldValue = "";
                    temp.PluginCode = Constants.UpdaterCode;
                    temp.ConfigCategoryCode = item.ConfigCategoryCode;
                    dic.Add(key, temp);
                }
            }

            IList<ConfigInfo> listconfigs = dic.Values.ToList<ConfigInfo>();
            listconfigs = InitConfigs(listconfigs);//��ʼ��
            v.configList = listconfigs;

            IEnumerable<IGrouping<string, ConfigInfo>> listccc = v.configList.GroupBy(T => T.ConfigCategoryCode).ToList();
            listccc = listccc.OrderBy(T => T.Key);
            ViewData["keys"] = listccc.First().Key;
            ViewData["lists"] = listccc;
            ViewData["configList"] = v.configList.Count;

            return View(v);
        }
        public ActionResult PublishInfo(string Vid)
        {
            SearchVersionTrack search = new SearchVersionTrack();
            search.VID = Vid;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];

            SearchConfig searchc = new SearchConfig();
            searchc.PluginCode = Constants.UpdaterCode;
            IList<ConfigTemp> list = BoFactory.GetVersionTrackBo.GetConfigListTemp(searchc);

            IList<ConfigInfo> listc = new List<ConfigInfo>();
            foreach (ConfigTemp c in list)
            {
                c.Value1 = c.Value1.Replace("<", "&lt;").Replace(">", "&gt;");
                listc.Add(CommonMethods.ConvertToConfigInfo(c));
            }

            listc = InitConfigs(listc);//��ʼ��
            v.configList = listc;
            IEnumerable<IGrouping<string, ConfigInfo>> listccc = v.configList.GroupBy(T => T.ConfigCategoryCode).ToList();
            listccc = listccc.OrderBy(T => T.Key);

            ViewData["keys"] = listccc.First().Key;
            ViewData["lists"] = listccc;
            ViewData["configList"] = v.configList.Count;

            return View(v);
        }
        /// <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;
        }
        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);
        }
        //vidһ������һ���汾��vid
        public ActionResult PublishInfo(string 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("<", "&lt;").Replace(">", "&gt;");
                    listc.Add(CommonMethods.ConvertToConfigInfo(c));
                }
                p.configList = listc;

                listtemp.Add(p);
            }
            ViewData["vids"] = Vid;
            return View(listtemp);
        }
 private void resumeVersionInfoByMain(ArrayList activeVersion, ArrayList resumeVersion, XmlMainConfigInfo xml, string code)
 {
     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<ConfigInfoPC> plist = xml.configList;
         //更新除了versiontrack之外的所有表信息
         for (int i = 0; i < plist.Count; i++)
         {
             SearchConfig search = new SearchConfig();
             search.PluginCode = code;
             configInfoDao.DeleteConfigInfo(search);//删除配置
             foreach (ConfigInfoPC c in plist)
             {
                 c.PluginCode = code;
                 configInfoPCDao.Insert(c);//插入配置
             }
         }
         //发布更新
         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);
     }
 }
        /// <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);
            }
        }
        private void InserConfigInfo(IList<ConfigTemp> coglist, string PluginCode)
        {
            try
            {
                foreach (ConfigTemp cog in coglist)
                {
                    if (string.IsNullOrEmpty(cog.Key1))
                        throw new BOException("配置信息中的健值不能为空");
                    //验证同一个插件的key不能重复
                    SearchConfig search = new SearchConfig();
                    search.key = cog.Key1;
                    search.PluginCode = cog.PluginCode;
                    if (string.IsNullOrEmpty(cog.PluginCode))
                    {
                        search.PluginCode = PluginCode;
                        cog.PluginCode = PluginCode;
                    }
                    search.ConfigCategoryCode = cog.ConfigCategoryCode;
                    IList<ConfigTemp> list = configTempDao.GetConfigList(search);
                    if (list != null)
                    {
                        if (list.Count > 0)
                            throw new BOException("该主程序配置信息中的键已经存在!");
                    }
                    configTempDao.Insert(cog);
                }

            }
            catch (DalException ex)
            {
                throw new BOException("新赠配置表信息", ex);
            }
        }
        public virtual string UpdateWebPluginInfo(PluginInfo pInfo, ActionExtend action, VersionTrack version, string isAdd, string uid)
        {
            try
            {
                string verfilepath = "";
                string oldfilepath = "";
                if (isAdd.Equals("0"))//若为修改
                {
                    SearchVersionTrack search = new SearchVersionTrack();
                    search.VID = version.VersionId.ToString();
                    VersionTrack ver = GetVersionTrack(search)[0];
                    oldfilepath = ver.FilePath;
                    ver.VersionName = version.VersionName;//修改的版本号
                    ver.FilePath = Path.Combine(AppConfig.filePath + pInfo.PluginCode, version.VersionName);
                    ver.LastModTime = DateTime.Now;
                    ver.LastModUid = uid;

                    verfilepath = ver.FilePath;

                    UpdateVersionTrack(ver);//更新版本表
                }
                else//若为升级
                {
                    verfilepath = version.FilePath;
                    InsertVersionTrack(version);
                }

                UpdatePluginInfo(pInfo, action);//更新插件表和扩展信息表

                SearchConfig searchcof = new SearchConfig();
                searchcof.PluginCode = pInfo.PluginCode.ToString();
                BoFactory.GetVersionTrackBo.DeleteConfigInfo(searchcof);//先删除原由配置信息,若存在

                if (Directory.Exists(oldfilepath)) //5.修改需要删除原由文件
                    Directory.Delete(oldfilepath, true);

                return verfilepath;
            }
            catch (DalException ex)
            {
                throw new BOException("更新web插件相关所有信息出错", ex);
            }
        }
 public virtual void UpdateUpdaterTempPlugin(IList<ConfigTemp> listc, string uid)
 {
     try
     {
         SearchConfig searchc = new SearchConfig();
         searchc.PluginCode = Constants.UpdaterCode;
         configTempDao.DeleteInfo(searchc);
         if (listc != null)
         {
             if (listc.Count > 0)
                 InserConfigInfo(listc, Constants.UpdaterCode);//更新配置
         }
     }
     catch (DalException ex)
     {
         throw new BOException("新增插件扩展信息出错", ex);
     }
 }
        public virtual void UpdateUpdaterPlushVersionTracks(XmlMainConfigInfo xml, string vid, string uid)
        {
            try
            {
                SearchConfig search = new SearchConfig();
                search.PluginCode = Constants.UpdaterCode;
                configInfoDao.DeleteConfigInfo(search);//先删除原由真实参数表数据

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

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

                //更新原由版本为过期,当前版本为正在使用
                SearchVersionTrack searchtemps = new SearchVersionTrack();
                searchtemps.VID = vid;
                VersionTrack vsss = versionTrackDao.GetVersionTrackList(searchtemps)[0];//当前版本
                VersionTrack oldver = versionTrackDao.Get(vsss.PreVersionId);//获取上个版本即正在使用的版本
                if (oldver != null)
                {
                    oldver.VersionStatus = 2;
                    versionTrackDao.Update(oldver);
                }
                vsss.VersionStatus = 1;
                versionTrackDao.Update(vsss);
            }
            catch (DalException ex)
            {
                throw new BOException("修改主程序版本信息出错", ex);
            }
        }
        public virtual void UpdateUpdaterConfigInfos(IList<ConfigInfo> list)
        {
            try
            {
                SearchConfig search = new SearchConfig();
                search.PluginCode = Constants.UpdaterCode;
                configInfoDao.DeleteConfigInfo(search);
                foreach (ConfigInfo c in list)
                {
                    if (string.IsNullOrEmpty(c.Key1))
                        throw new BOException("配置信息中的健值不能为空");
                    SearchConfig searchc = new SearchConfig();
                    searchc.key = c.Key1;
                    searchc.PluginCode = c.PluginCode;
                    searchc.ConfigCategoryCode = c.ConfigCategoryCode;
                    IList<ConfigInfo> listc = configInfoDao.GetConfigList(searchc);
                    if (listc != null)
                    {
                        if (listc.Count > 0)
                            throw new BOException("单个插件的关键值不能重复");
                    }
                    configInfoDao.Insert(c);
                }

            }
            catch (DalException ex)
            {
                throw new BOException("更新配置信息出错", ex);
            }
        }
        public ActionResult UpdateConfigInfo(string id)
        {
            string type = Request.QueryString["type"];
            ViewData["vid"] = id;
            IList<PluginInfo> plist = new List<PluginInfo>();
            ViewData["configList"] = 0;

            SearchVersionTrack searchv = new SearchVersionTrack();
            searchv.VID = id;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0];

            SearchConfig search = new SearchConfig();
            search.PluginCode = Constants.MianName;

            if (type == "pc")
            {
                search.ConfigCategoryCode = Constants.SystemConfig; //Constants.PCGlobalConfig;

            }else if(type =="mobile")
            {
                search.ConfigCategoryCode = Constants.SystemConfig + "," + Constants.AppNameConfig + "," + Constants.GlobalConfig;
            }
            //search.ConfigCategoryCode = Constants.PCGlobalConfig + "," + Constants.SystemConfig + "," + Constants.AppNameConfig + "," + Constants.GlobalConfig;
            IList<ConfigInfo> listconfigs = null;
            switch (type)
            {
                case "pc":
                    listconfigs = BoFactory.GetVersionTrackBo.GetPCConfigList(search);
                    break;
                case "mobile":
                    listconfigs = BoFactory.GetVersionTrackBo.GetMobileConfigList(search);
                    break;
            }

            //if (type == "mobile")
            if( listconfigs == null || listconfigs.Count == 0)
            {
                listconfigs = InitConfigs(listconfigs);//��ʼ��
            }
            v.configList = listconfigs;

            IEnumerable<IGrouping<string, ConfigInfo>> listccc = v.configList.GroupBy(T => T.ConfigCategoryCode).ToList();
            ViewData["keys"] = listccc.First().Key;
            ViewData["lists"] = listccc;
            ViewData["configList"] = v.configList.Count;

            return View(v);
        }
        /// <summary>
        /// �XML
        /// </summary>
        /// <param name="path"></param>
        private XmlMainConfigInfo InsertXml(string Vid)
        {
            XmlMainConfigInfo xml = new XmlMainConfigInfo();
            SearchVersionTrack searchv = new SearchVersionTrack();
            SearchConfig serach = new SearchConfig();

            searchv.VID = Vid;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0];

            serach.PluginCode = v.PluginCode.ToString();
            IList<ConfigTemp> listct = BoFactory.GetVersionTrackBo.GetConfigListTemp(serach);//��ȡ������Ϣ

            IList<ConfigInfoPC> listc = new List<ConfigInfoPC>();
            foreach (ConfigTemp c in listct)
            {
                listc.Add(CommonMethods.ConvertToConfigInfoPC(c));//ת��
            }
            xml.configList = listc;

            //����
            IList<ConfigInfoPC> listA = new List<ConfigInfoPC>();
            IList<ConfigInfoPC> listS = new List<ConfigInfoPC>();
            IList<ConfigInfoPC> listG = new List<ConfigInfoPC>();
            foreach (var config in listc)
            {
                if (config.ConfigCategoryCode.Equals(Constants.SystemConfig))
                    listS.Add(config);
                else if (config.ConfigCategoryCode.Equals(Constants.GlobalConfig))
                    listG.Add(config);
                else
                    listA.Add(config);
            }

            CommonMethods.WriteMaininfoConfigXml(listA, Path.Combine(v.FilePath.Trim(), Constants.AppName));
            CommonMethods.WriteMaininfoConfigXml(listS, Path.Combine(v.FilePath.Trim(), Constants.systemName));
            CommonMethods.WriteMaininfoConfigXml(listG, Path.Combine(v.FilePath.Trim(), Constants.globalName));

            return xml;
        }
        public virtual void DelAllVersionByMain(ArrayList arr)
        {
            try
            {
                string vpath = "";
                foreach (string a in arr)
                {
                    SearchVersionTrack se1 = new SearchVersionTrack();
                    se1.VID = a;
                    VersionTrack v = versionTrackDao.GetVersionTrackList(se1)[0];
                    vpath = v.FilePath;
                    string pcode = v.PluginCode;//查出当前插件code
                    SearchConfig search = new SearchConfig();
                    search.PluginCode = pcode;
                    configInfoDao.DeleteConfigInfo(search);//配置删除
                    SearchVersionTrack se = new SearchVersionTrack();
                    se.PluginCode = pcode;
                    versionTrackDao.DeleteInfo(se);//删版本
                    //删临时表
                    configTempDao.DeleteInfo(search);
                }

                string[] codes = vpath.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.DeleteApplication(name);

                //zip不删,由原来存在相同会自动删除
                vpath = vpath.Substring(0, vpath.LastIndexOf("\\"));

                if (Directory.Exists(vpath)) //删除原由文件夹
                    Directory.Delete(vpath, true);

            }
            catch (DalException ex)
            {
                throw new BOException("删除版本出错", ex);
            }
        }
        public ActionResult UpdateConfigInfo(string id)
        {
            ViewData["vid"] = id;
            ArrayList vids = GetArrays(id);
            IList<PluginInfo> plist = new List<PluginInfo>();
            ViewData["configList"] = 0;
            foreach (string vid in vids)
            {
                SearchVersionTrack searchv = new SearchVersionTrack();
                searchv.VID = vid;
                id = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0].PluginCode.ToString();
                PluginInfo p = BoFactory.GetVersionTrackBo.GetPluginInfo(id);
                p.VersionSummary = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0].VersionSummary;
                SearchConfig search = new SearchConfig();
                if (p.IsIgnoreConfig == false)
                {
                    search.PluginCode = id;
                    search.ConfigCategoryCode = Constants.configCategory;
                    p.configList = BoFactory.GetVersionTrackBo.GetConfigList(search);
                }
                if (p.PluginCateCode.Equals(Constants.ActionCateCode))
                {
                    search.PluginCode = id;
                    IList<ActionExtend> alist = BoFactory.GetVersionTrackBo.QueryActionExtend(search);
                    if (alist.Count > 0)
                    {
                        ActionExtend a = alist[0];
                        p.ActionCode = a.ActionCode;
                        p.ActionSummary = a.Summary;
                    }
                }
                SearchPlugin sh = new SearchPlugin();
                sh.PluginCateCode = p.PluginCateCode;
                p.PCname = BoFactory.GetVersionTrackBo.GetPluginCategoryInfos(sh)[0].DisplayName;

                plist.Add(p);

                ViewData["configList"] = (int)ViewData["configList"] + p.configList.Count;
            }
            return View(plist);
        }
 public virtual void DeleteConfigInfo(SearchConfig search)
 {
     try
     {
         configInfoDao.DeleteConfigInfo(search);
     }
     catch (DalException ex) { throw new BOException("删除配置表所有相关插件信息", ex); }
 }
        public ActionResult ViewPluginInfo(string id)
        {
            ViewData["Vid"] = id;
            SearchVersionTrack search = new SearchVersionTrack();
            search.VID = id;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];

            PluginInfo p = BoFactory.GetVersionTrackBo.GetPluginInfo(v.PluginCode);
            SearchConfig searchc = new SearchConfig();
            searchc.PluginCode = v.PluginCode;
            IList<ConfigInfo> list = BoFactory.GetVersionTrackBo.GetConfigList(searchc);
            //ת��
            foreach (ConfigInfo c in list)
            {
                c.Value1 = c.Value1.Replace("<", "&lt;").Replace(">", "&gt;");
            }
            p.configList = list;
            p.VersionSummary = v.VersionSummary;

            SearchPlugin sh = new SearchPlugin();
            sh.PluginCateCode = p.PluginCateCode;
            p.PCname = BoFactory.GetVersionTrackBo.GetPluginCategoryInfos(sh)[0].DisplayName;

            return View(p);
        }
        public JsonResult GetUserInfo(FormCollection form,string id)
        {
            JsonFlexiGridData data = null;
            PageView view = new PageView(form);
            SearchConfig search = new SearchConfig();
            search.PluginCode = id;

            data = BoFactory.GetVersionTrackBo.QueryUserInfoByPId(search, view);
            return Json(data);
        }
        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;
        }
 public JsonResult GetUserNotByIdInfo(FormCollection form, string id)
 {
     JsonFlexiGridData data = null;
     PageView view = new PageView(form);
     SearchConfig search = new SearchConfig();
     search.PluginCode = id;
     SearchVersionTrack searchv = new SearchVersionTrack();
     string sid = form["SID"].Trim();
     string sname = form["Sname"].Trim();
     string sgust = form["Sgust"].Trim();
     if (sgust.Equals(sname))
         searchv.UserUid = sid;
     else
         searchv.UserName = sgust;
     data = BoFactory.GetVersionTrackBo.QueryUserInfoNotByPId(search,searchv, view);
     return Json(data);
 }
        public ActionResult UpdateConfigInfo(string id)
        {
            ViewData["vid"] = id;
            IList<PluginInfo> plist = new List<PluginInfo>();
            ViewData["configList"] = 0;

            SearchVersionTrack searchv = new SearchVersionTrack();
            searchv.VID = id;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0];

            SearchConfig search = new SearchConfig();
            search.PluginCode = Constants.UpdaterCode;
            search.ConfigCategoryCode = Constants.UpdaterConfig;
            IList<ConfigInfo> listconfigs = BoFactory.GetVersionTrackBo.GetConfigList(search);
            listconfigs = InitConfigs(listconfigs);//��ʼ��
            v.configList = listconfigs;

            IEnumerable<IGrouping<string, ConfigInfo>> listccc = v.configList.GroupBy(T => T.ConfigCategoryCode).ToList();
            ViewData["keys"] = listccc.First().Key;
            ViewData["lists"] = listccc;
            ViewData["configList"] = v.configList.Count;

            return View(v);
        }
        public ActionResult UpdatePluginInfo(string verid)
        {
            ViewData["actionCode"] = "";
            ViewData["summary"] = "";
            ViewData["IsAction"] = "";
            SearchVersionTrack search = new SearchVersionTrack();
            search.VID = verid;
            VersionTrack version = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];//��ȡ���ID

            PluginInfo pinfo = BoFactory.GetVersionTrackBo.GetPluginInfo(version.PluginCode.ToString());//��ȡ�����Ϣ
            if (pinfo.PluginCateCode.Equals(Constants.ActionCateCode))
                ViewData["IsAction"] = "1";

            IList<PluginCategory> list = BoFactory.GetVersionTrackBo.GetPluginCategoryInfo();//��ȡ��web����ķ�����Ϣ
            if (list != null)
            {
                if (list.Count > 0)
                {
                    IResourceData[] datas = new IResourceData[list.Count];
                    for (int i = 0; i < list.Count; i++)
                    {
                        datas[i] = ResourceDataFactory.GetResourceDataInstance();
                        datas[i].Code = list[i].PluginCateCode;
                        datas[i].Name = list[i].DisplayName;
                    }
                    ViewData["list"] = datas;
                }
            }

            SearchConfig searchconfig = new SearchConfig();
            searchconfig.PluginCode = version.PluginCode.ToString();
            IList<ActionExtend> listAction = BoFactory.GetVersionTrackBo.QueryActionExtend(searchconfig);//��ȡ��չ��Ϣ
            if (listAction.Count > 0)
            {
                ViewData["actionCode"] = listAction[0].ActionCode;
                ViewData["summary"] = listAction[0].Summary;
            }

            ViewData["versionId"] = verid;
            ViewData["vername"] = version.VersionName;

            return View(pinfo);
        }
        /// <summary>
        /// �XML
        /// </summary>
        /// <param name="path"></param>
        private XmlMainConfigInfo InsertConfigXml(string Vid)
        {
            XmlMainConfigInfo xml = new XmlMainConfigInfo();
            SearchVersionTrack searchv = new SearchVersionTrack();
            SearchConfig serach = new SearchConfig();

            searchv.VID = Vid;
            VersionTrack v = BoFactory.GetVersionTrackBo.GetVersionTrack(searchv)[0];

            serach.PluginCode = v.PluginCode.ToString();
            IList<ConfigInfoPC> listc = BoFactory.GetVersionTrackBo.GetConfigPCList(serach);//��ȡ������Ϣ

            xml.configList = listc;

            CommonMethods.WriteMaininfoConfigXml(listc, Path.Combine(v.FilePath.Trim(), Constants.UpdaterName));

            return xml;
        }
        /// <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);
        }
 public JsonResult GetConfigInfo(FormCollection form,string id)
 {
     JsonFlexiGridData data = null;
     PageView view = new PageView(form);
     SearchConfig search = new SearchConfig();
     search.PluginCode = id;//pluginId
     data = BoFactory.GetVersionTrackBo.QueryConfigInfo(view, search);
     return Json(data);
 }
        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);
            }
        }