示例#1
0
        /// <summary>
        /// 从文件解析
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public int parseLocalVersionXml(string path)
        {
            UpdateLog.INFO_LOG(_TAG + "parseLocalVersionXml(string path):  " + path);

            int ret = CodeDefine.RET_SUCCESS;

            try
            {
                var sp = MonoXmlUtils.LoadXmlEx(path);
                if (sp == null || sp.ToXml() == null)
                {
                    UpdateLog.ERROR_LOG(_TAG + "File not exist or invalid: " + path);
                    return(CodeDefine.RET_FAIL_PARSE_LOCAL_XML_FILE);
                }

                dom = sp.ToXml();
                _localVersionXml = path;
                parse(dom);
            }
            catch (System.Exception ex)
            {
                ret = CodeDefine.RET_FAIL_PARSE_LOCAL_XML_FILE;

                UpdateLog.ERROR_LOG(_TAG + ex.Message + "\n" + ex.StackTrace);
                UpdateLog.EXCEPTION_LOG(ex);
            }

            return(ret);
        }
示例#2
0
        //解析xml
        public int parseResouceVersionXml(string path)
        {
            UpdateLog.INFO_LOG(_TAG + "parseResouceVersionXml(string path):" + path);

            int ret = CodeDefine.RET_SUCCESS;

            try
            {
                var sp = MonoXmlUtils.LoadXmlEx(path);
                if (sp == null || sp.ToXml() == null)
                {
                    return(CodeDefine.RET_FAIL_PARSE_RES_XML_FILE);
                }

                var dom = sp.ToXml();

                //正式流程
                parse(dom, "ResourceVersion/VersionBase", NormalFollow.VersionModelBaseList);
                parse(dom, "ResourceVersion/VersionPatch", NormalFollow.VersionModelPatchList);
                NormalFollow.AppVersion = parse(dom, "ResourceVersion/CodeVersion_last/Version");
                NormalFollow.ClientUrl  = parse(dom, "ResourceVersion/CodeVersion_last/url");
                NormalFollow.AppSize    = parse(dom, "ResourceVersion/CodeVersion_last/size");
                NormalFollow.Language   = parse(dom, "ResourceVersion/loginSever/language");
                bool enable = true;
                if (!Boolean.TryParse(parse(dom, "ResourceVersion/ForceUpdate"), out enable))
                {
                    enable = true;
                }
                NormalFollow.EnableForceUpdate = enable;
                NormalFollow.PatchVersion      = GetMaxPatchVersion(NormalFollow.VersionModelPatchList);

                //测试流程
                parse(dom, "ResourceVersion/test_tag/VersionBase", TestFollow.VersionModelBaseList);
                parse(dom, "ResourceVersion/test_tag/VersionPatch", TestFollow.VersionModelPatchList);
                TestFollow.AppVersion = parse(dom, "ResourceVersion/test_tag/app_current_version");
                TestFollow.ClientUrl  = parse(dom, "ResourceVersion/test_tag/app_update_url");
                TestFollow.AppSize    = parse(dom, "ResourceVersion/test_tag/test_size");
                TestFollow.Language   = parse(dom, "ResourceVersion/test_tag/language");
                if (!Boolean.TryParse(parse(dom, "ResourceVersion/test_tag/ForceUpdate"), out enable))
                {
                    enable = true;
                }
                TestFollow.EnableForceUpdate = enable;
                TestFollow.PatchVersion      = GetMaxPatchVersion(TestFollow.VersionModelPatchList);

                //白名单 mac地址
                var macList = parseNodes(dom, "ResourceVersion/test_tag/legal_client_machine_list/legal_client_machine");
                for (int i = 0; macList != null && i < macList.Length; i++)
                {
                    if (macList[i] == null)
                    {
                        continue;
                    }
                    WhiteCode.Add(macList[i].Text);
                }

                //白名单 用户名
                var userList = parseNodes(dom, "ResourceVersion/test_tag/legal_client_user_list/legal_client_user");
                for (int i = 0; userList != null && i < userList.Length; i++)
                {
                    if (userList[i] == null)
                    {
                        continue;
                    }
                    WhiteUsers.Add(userList[i].Text);
                }

                //白名单 ip地址
                var ipList = parseNodes(dom, "ResourceVersion/test_tag/legal_client_ip_list/legal_client_ip");
                for (int i = 0; ipList != null && i < ipList.Length; i++)
                {
                    if (ipList[i] == null)
                    {
                        continue;
                    }
                    WhiteIp.Add(ipList[i].Text);
                }
            }
            catch (System.Exception ex)
            {
                ret = CodeDefine.RET_FAIL_PARSE_RES_XML_FILE;
                UpdateLog.ERROR_LOG(_TAG + ex.Message + "/n" + ex.StackTrace);
                UpdateLog.EXCEPTION_LOG(ex);
            }


            return(ret);
        }