예제 #1
0
        public VersionModel clone()
        {
            VersionModel model = new VersionModel();

            model.fromVersion = fromVersion;
            model.toVersion   = toVersion;
            model.resourceUrl = resourceUrl;
            model.md5         = md5;
            model.fileSize    = fileSize;

            model.map_md5  = map_md5;
            model.map_size = map_size;
            model.map_url  = map_url;

            return(model);
        }
        public void parseNormalFlow(string manifestFile, bool forPaste)
        {
            m_TempManifestPath = manifestFile;

            if (m_NormalFlow != null)
            {
                m_NormalFlow.clean();
            }
            else
            {
                m_NormalFlow = new NormalFlow();
            }


            FileInfo fileInfo = new FileInfo(manifestFile);

            if (!fileInfo.Exists)
            {
                //MessageBox.Show("The file " + manifestFile + " is not exists!" );
                Form1.g_Context.ErrorMsg.Text = "The file " + manifestFile + " is not exists!";


                if (!forPaste)
                {
                    //m_NormalFlow.setText();
                }
                return;
            }

            try
            {
                XmlDocument dom = new XmlDocument();
                dom.Load(manifestFile);

                XmlNode rootNode        = dom.SelectSingleNode("ResourceVersion");
                XmlNode ForceUpdateNode = RequireNode(dom, rootNode, "ForceUpdate", "true");
                Boolean.TryParse(ForceUpdateNode.InnerText, out m_NormalFlow.forceUpdate);

                XmlNodeList baseList = dom.SelectNodes("ResourceVersion/VersionBase");
                foreach (XmlNode baseNode in baseList)
                {
                    XmlNode      fromNode     = baseNode.SelectSingleNode("FromVersion");
                    XmlNode      ToVersion    = baseNode.SelectSingleNode("ToVersion");
                    XmlNode      PatchFile    = baseNode.SelectSingleNode("PatchFile");
                    XmlNode      PatchFileMD5 = baseNode.SelectSingleNode("PatchFileMD5");
                    XmlNode      FileSize     = baseNode.SelectSingleNode("FileSize");
                    VersionModel model        = new VersionModel();
                    model.fileSize    = FileSize.InnerText;
                    model.fromVersion = fromNode.InnerText;
                    model.toVersion   = ToVersion.InnerText;
                    model.md5         = PatchFileMD5.InnerText;
                    model.resourceUrl = PatchFile.InnerText;

                    XmlNode mapFile     = baseNode.SelectSingleNode("mapFile");
                    XmlNode mapFileMD5  = baseNode.SelectSingleNode("mapFileMD5");
                    XmlNode mapFileSize = baseNode.SelectSingleNode("mapFileSize");

                    if (mapFile != null)
                    {
                        model.map_url  = mapFile.InnerText;
                        model.map_md5  = mapFileMD5.InnerText;
                        model.map_size = mapFileSize.InnerText;
                    }

                    m_NormalFlow.baseModel.Add(model);
                }

                XmlNodeList patchList = dom.SelectNodes("ResourceVersion/VersionPatch");
                foreach (XmlNode patchNode in patchList)
                {
                    XmlNode fromNode     = patchNode.SelectSingleNode("FromVersion");
                    XmlNode ToVersion    = patchNode.SelectSingleNode("ToVersion");
                    XmlNode PatchFile    = patchNode.SelectSingleNode("PatchFile");
                    XmlNode PatchFileMD5 = patchNode.SelectSingleNode("PatchFileMD5");
                    XmlNode FileSize     = patchNode.SelectSingleNode("FileSize");

                    VersionModel model = new VersionModel();
                    model.fileSize    = FileSize.InnerText;
                    model.fromVersion = fromNode.InnerText;
                    model.toVersion   = ToVersion.InnerText;
                    model.md5         = PatchFileMD5.InnerText;
                    model.resourceUrl = PatchFile.InnerText;

                    m_NormalFlow.patchModel.Add(model);
                }

                XmlNodeList dllList = dom.SelectNodes("ResourceVersion/VersionDll");
                foreach (XmlNode patchNode in dllList)
                {
                    XmlNode fromNode     = patchNode.SelectSingleNode("FromVersion");
                    XmlNode ToVersion    = patchNode.SelectSingleNode("ToVersion");
                    XmlNode PatchFile    = patchNode.SelectSingleNode("PatchFile");
                    XmlNode PatchFileMD5 = patchNode.SelectSingleNode("PatchFileMD5");
                    XmlNode FileSize     = patchNode.SelectSingleNode("FileSize");

                    VersionModel model = new VersionModel();
                    model.fileSize    = FileSize.InnerText;
                    model.fromVersion = fromNode.InnerText;
                    model.toVersion   = ToVersion.InnerText;
                    model.md5         = PatchFileMD5.InnerText;
                    model.resourceUrl = PatchFile.InnerText;

                    m_NormalFlow.dllModel.Add(model);
                }

                XmlNode versionNode    = dom.SelectSingleNode("ResourceVersion/CodeVersion_last/Version");
                XmlNode resVersionNode = dom.SelectSingleNode("ResourceVersion/CodeVersion_last/ResVersion");
                XmlNode urlNode        = dom.SelectSingleNode("ResourceVersion/CodeVersion_last/url");
                XmlNode sizeNode       = dom.SelectSingleNode("ResourceVersion/CodeVersion_last/size");

                m_NormalFlow.appVersion = versionNode.InnerText;
                m_NormalFlow.resVersion = resVersionNode.InnerText;
                m_NormalFlow.url        = urlNode.InnerText;
                if (sizeNode != null)
                {
                    m_NormalFlow.appSize = sizeNode.InnerText;
                }

                if (!forPaste)
                {
                    //m_NormalFlow.setText();
                }
            }
            catch (System.Exception ex)
            {
                //MessageBox.Show(ex.Message);
                Form1.g_Context.ErrorMsg.Text = ex.Message;
            }
        }