示例#1
0
    public void Add(string order)
    {
        SecurityElement se;

        if (FileUtils.Exist(PathUtils.RechargeOrderPath) == false)
        {
            se = MonoXmlUtils.Create();
        }
        else
        {
            se = MonoXmlUtils.LoadXmlSE(PathUtils.RechargeOrderPath);
        }

        SecurityElement item;
        bool            found = false;

        if (se.Children != null)
        {
            for (int i = 0, count = se.Children.Count; i < count; ++i)
            {
                item = se.Children[i] as SecurityElement;
                if (item.Text.CompareTo(order) == 0)
                {
                    found = true;
                }
            }
        }

        if (found == false)
        {
            MonoXmlUtils.Add(se, "order", order);

            MonoXmlUtils.SaveXml(PathUtils.RechargeOrderPath, se);
        }
    }
示例#2
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);
        }
示例#3
0
    public List <string> GetAllOrder()
    {
        List <string> result = new List <string>();

        SecurityElement se;

        if (FileUtils.Exist(PathUtils.RechargeOrderPath) == false)
        {
            se = MonoXmlUtils.Create();
        }
        else
        {
            se = MonoXmlUtils.LoadXmlSE(PathUtils.RechargeOrderPath);
        }

        if (se.Children != null)
        {
            SecurityElement item;
            for (int i = 0, count = se.Children.Count; i < count; ++i)
            {
                item = se.Children[i] as SecurityElement;
                result.Add(item.Text);
            }
        }

        return(result);
    }
示例#4
0
    public List <string> GetAllPassward()
    {
        List <string> result = new List <string>();

        SecurityElement se;

        if (FileUtils.Exist(PathUtils.AccountInfo) == false)
        {
            se = MonoXmlUtils.Create();
        }
        else
        {
            se = MonoXmlUtils.LoadXmlSE(PathUtils.AccountInfo);
        }

        if (se.Children != null)
        {
            SecurityElement item;
            string          pwd;
            for (int i = 0, count = se.Children.Count; i < count; ++i)
            {
                item = se.Children[i] as SecurityElement;
                pwd  = item.Attributes["pwd"] as string;
                if (string.IsNullOrEmpty(item.Text) == false && string.IsNullOrEmpty(pwd) == false)
                {
                    result.Add(pwd);
                }
            }
        }

        return(result);
    }
示例#5
0
    public void Add(string account, string password)
    {
        if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(password))
        {
            return;
        }
        SecurityElement se;

        if (FileUtils.Exist(PathUtils.AccountInfo) == false)
        {
            se = MonoXmlUtils.Create();
        }
        else
        {
            se = MonoXmlUtils.LoadXmlSE(PathUtils.AccountInfo);
        }

        SecurityElement item;
        bool            found = false;

        if (se.Children != null)
        {
            int index = 0;
            for (int i = 0, count = se.Children.Count; i < count; ++i)
            {
                item = se.Children[i] as SecurityElement;
                if (string.IsNullOrEmpty(item.Text) == false && item.Text.CompareTo(account) == 0)
                {
                    found = true;
                    index = i;
                    item.SetAttribute("pwd", password);
                }
            }

            if (index != 0)
            {
                ///将本次登录的账号置于第一位,下次登录默认就是这个账号了
                string median = (se.Children[0] as SecurityElement).Text;
                (se.Children[0] as SecurityElement).Text     = (se.Children[index] as SecurityElement).Text;
                (se.Children[index] as SecurityElement).Text = median;
                median = (se.Children[0] as SecurityElement).Attributes["pwd"] as string;
                (se.Children[0] as SecurityElement).SetAttribute("pwd", (se.Children[index] as SecurityElement).Attributes["pwd"] as string);
                (se.Children[index] as SecurityElement).SetAttribute("pwd", median);
            }
        }

        if (found == false)
        {
            MonoXmlUtils.AddAttr(se, account, password);
        }
        MonoXmlUtils.SaveXml(PathUtils.AccountInfo, se);
    }
示例#6
0
        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="baseVersion"></param>
        /// <param name="patchVersion"></param>
        /// <param name="hasCopy"></param>
        /// <param name="appVersion"></param>
        /// <returns></returns>
        public int save(string baseVersion = "", string patchVersion = "", string hasCopy = "", string appVersion = "")
        {
            UpdateLog.INFO_LOG(_TAG + "save()");
            int  ret       = CodeDefine.RET_SUCCESS;
            bool hasChange = false;

            try
            {
                if (!"".Equals(baseVersion) && baseVersion != _baseResVersion)
                {
                    _baseResVersion = baseVersion;
                    set(dom, "local_info/local_base_res_version", baseVersion);
                    hasChange = true;
                }
                if (!"".Equals(patchVersion) && patchVersion != _patchResVersion)
                {
                    _patchResVersion = patchVersion;
                    hasChange        = true;
                    set(dom, "local_info/local_patch_res_version", patchVersion);
                }
                if (!"".Equals(hasCopy) && hasCopy != _hasCopy)
                {
                    _hasCopy  = hasCopy;
                    hasChange = true;
                    set(dom, "local_info/hasCopy", hasCopy);
                }
                if (!"".Equals(appVersion) && appVersion != _localAppVersion)
                {
                    _localAppVersion = appVersion;
                    hasChange        = true;
                    set(dom, "local_info/local_app_version", appVersion);
                }
                if (hasChange)
                {
                    MonoXmlUtils.SaveXml(_localVersionXml, dom);
                }
                else
                {
                    UpdateLog.DEBUG_LOG("没有改动,不保存localversion.xml");
                }
            }
            catch (System.Exception ex)
            {
                ret = CodeDefine.RET_FAIL_SAVE_LOCAL_XML_FILE;
                UpdateLog.ERROR_LOG(_TAG + ex.Message + "\n" + ex.StackTrace);
                UpdateLog.EXCEPTION_LOG(ex);
            }

            return(ret);
        }
示例#7
0
        /// <summary>
        /// 从xml内容解析
        /// </summary>
        /// <param name="xmlText"></param>
        /// <returns></returns>
        public int ParseFromText(string xmlText)
        {
            try
            {
                var rootNode = MonoXmlUtils.GetRootNodeFromString(xmlText);
                parse(rootNode);
            }
            catch (System.Exception ex)
            {
                UpdateLog.ERROR_LOG(ex.Message + "\n" + ex.StackTrace);
                UpdateLog.EXCEPTION_LOG(ex);
                return(CodeDefine.RET_FAIL);
            }

            return(CodeDefine.RET_SUCCESS);
        }
示例#8
0
    public bool Remove(string order)
    {
        if (FileUtils.Exist(PathUtils.RechargeOrderPath) == false)
        {
            return(false);
        }

        SecurityElement se = MonoXmlUtils.LoadXmlSE(PathUtils.RechargeOrderPath);

        if (MonoXmlUtils.RemoveByValue(se, order))
        {
            MonoXmlUtils.SaveXml(PathUtils.RechargeOrderPath, se);
            return(true);
        }
        else
        {
            return(false);
        }
    }
示例#9
0
    public bool Remove(string account)
    {
        if (FileUtils.Exist(PathUtils.AccountInfo) == false)
        {
            return(false);
        }

        SecurityElement se = MonoXmlUtils.LoadXmlSE(PathUtils.AccountInfo);

        if (MonoXmlUtils.RemoveByValue(se, account))
        {
            MonoXmlUtils.SaveXml(PathUtils.AccountInfo, se);
            return(true);
        }
        else
        {
            return(false);
        }
    }
示例#10
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="localVersion"></param>
        /// <returns></returns>
        public int save(LocalVersionXml localVersion)
        {
            UpdateLog.INFO_LOG(_TAG + "save()");
            int ret = CodeDefine.RET_SUCCESS;

            try
            {
                set(dom, "local_info/local_base_res_version", localVersion.BaseResVersion);
                set(dom, "local_info/local_patch_res_version", localVersion.PatchResVersion);
                set(dom, "local_info/hasCopy", localVersion.HasCopy);
                set(dom, "local_info/local_app_version", localVersion.LocalAppVersion);
                MonoXmlUtils.SaveXml(_localVersionXml, dom);
            }
            catch (System.Exception ex)
            {
                ret = CodeDefine.RET_FAIL_SAVE_LOCAL_XML_FILE;
                UpdateLog.ERROR_LOG(_TAG + ex.Message + "\n" + ex.StackTrace);
                UpdateLog.EXCEPTION_LOG(ex);
            }

            return(ret);
        }
示例#11
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);
        }