Ejemplo n.º 1
0
        public void DeserializeTest1()
        {
            //Test1
            string xmlText = XmlTool.Serialize(typeof(TestObject), this.Test);

            byte[]       array   = Encoding.ASCII.GetBytes(xmlText);
            MemoryStream stream  = new MemoryStream(array);
            TestObject   getTest = XmlTool.Deserialize <TestObject>(stream);

            Assert.AreEqual(getTest.id, Test.id);
            Assert.AreEqual(getTest.Name, Test.Name);
            Assert.AreEqual(getTest.Count, Test.Count);
            Assert.AreEqual(getTest.Sub.SubName, Test.Sub.SubName);
            //Test2
            string xmlText2 = "123";

            byte[]       array2   = Encoding.ASCII.GetBytes(xmlText2);
            MemoryStream stream2  = new MemoryStream(array2);
            TestObject   getTest2 = XmlTool.Deserialize <TestObject>(stream2);

            Assert.IsNull(getTest2);
        }
Ejemplo n.º 2
0
    IEnumerator LoadServerPatchXML()
    {
        m_CurState = eVCstate.TRY_LOAD_SERVER_XML;
        string strCDNurl = "Path";

        if (string.IsNullOrEmpty(strCDNurl) == true)
        {
            Debug.LogError("strCDNurl is empty");
            m_CurState = eVCstate.FAIL_LOAD_SERVER_XML;
            yield break;
        }

        string fileURL = strCDNurl + VersionXML.VersionFileName;

        //WWW serverXMLwww = new WWW(fileURL);
        UnityWebRequest serverXMLwww = UnityWebRequest.Get(fileURL);

        yield return(serverXMLwww.SendWebRequest());

        if (serverXMLwww.error != null)
        {
            Debug.LogError("Load XML failed : " + serverXMLwww.error);
            m_CurState = eVCstate.FAIL_LOAD_SERVER_XML;
            yield break;
        }

        XmlDocument serverXML = XmlTool.loadXml(serverXMLwww.downloadHandler.data);

        if (serverXML == null)
        {
            Debug.LogError("serverXML is null");
            m_CurState = eVCstate.FAIL_LOAD_SERVER_XML;
            yield break;
        }

        m_LoadedServerInfo.ParseXML(serverXML, strCDNurl);

        m_CurState = eVCstate.FINISH_LOAD_SERVER_XML;
    }
Ejemplo n.º 3
0
        public void ReadXml(XmlReader reader)
        {
            Position = new Position();
            Position.ReadXml(reader);

            if (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    XmlRootAttribute root = new XmlRootAttribute()
                    {
                        ElementName = reader.Name,
                        IsNullable  = true
                    };
                    var obj = Reflection.CreateObject(reader.Name);
                    Item = (T)XmlTool.Deserialize(obj.GetType(), reader, root);
                    (Item as UIObject).Initialize();
                    (Item as UIObject).Setup();
                    reader.ReadEndElement();
                }
            }
        }
Ejemplo n.º 4
0
        public void ArcSegment_Serializable()
        {
            Point3D center = new Point3D()
            {
                X = 0, Y = 0, Z = 0
            };
            Point3D start = new Point3D()
            {
                X = 0, Y = 1, Z = 0
            };
            Point3D end = new Point3D()
            {
                X = 1, Y = 0, Z = 0
            };
            ArcSegment arc     = new ArcSegment(center, start, end, ArcDirctionType.CLOCK_WISE);
            string     xmlText = XmlTool.Serialize(typeof(ArcSegment), arc);

            Assert.IsNotNull(xmlText);
            ArcSegment ad = XmlTool.Deserialize(typeof(ArcSegment), xmlText) as ArcSegment;

            Assert.IsTrue(arc.Equals(ad));
        }
Ejemplo n.º 5
0
        public ThreeDSAuthorization1Response ThreeDSAuthorize1(ThreeDSAuthorization1Request request)
        {
            // Validate request
            RequestValidator.ValidateThreeDSAuthorize1Request(request);
            // Map input request in the XML Request
            var requestXML = RequestMapper.MapThreeDSAuthorization1Request(request, _shopId);

            // Calculate and set MAC
            requestXML.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(requestXML), _apiResultKey);
            var xmlBody = XmlTool.Serialize(requestXML);
            // Do call to VPOS
            var xmlResponse = _restClient.CallApi(_urlAPI, xmlBody);
            // Map response
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <Data3DSResponse> >(xmlResponse);

            // Verify Mac Response
            VerifyMacResponse(objectResponse);
            VerifyAuthorization(objectResponse.Data.Authorization);
            VerifyPanAliasData(objectResponse.Data.PanAliasData);
            VerifyThreeDSChallenge(objectResponse.Data.ThreeDSChallenge);
            return(ResponseMapper.MapThreeDSAuthorization1(objectResponse));
        }
Ejemplo n.º 6
0
        public AuthorizeResponse Authorize(AuthorizeRequest authorize)
        {
            // Validate request
            RequestValidator.ValidateAuthorizeRequest(authorize);
            // Map input request in the XML Request
            var request = RequestMapper.MapAuthorizeRequest(authorize, _shopId);

            // Calculate and set MAC
            request.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(request), _apiResultKey);
            var xmlBody = XmlTool.Serialize(request);
            // Do call to VPOS
            var xmlResponse = _restClient.CallApi(_urlAPI, xmlBody);
            // Map response
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <DataAuthorize> >(xmlResponse);

            // Verify Response MAC
            VerifyMacResponse(objectResponse);
            VerifyAuthorization(objectResponse.Data.Authorization);
            VerifyPanAliasData(objectResponse.Data.PanAliasData);
            //Response Mapping
            return(ResponseMapper.MapAuthorize(objectResponse));;
        }
Ejemplo n.º 7
0
        public void PostXml()
        {
            // NOTE : 이 테스트가 실패한다면, 웹 서버 Page의 ValidateRequest 옵션이 False 인지를 확인해라.
            //
            foreach (string url in testUrls)
            {
                try {
                    XmlDocument postDoc = XmlTool.CreateXmlDocument("<PostXml>Data for PostXml</PostXml>");
                    var         doc     = XmlHttpClient.PostXml(url + XmlHttpMethods.PostXml, postDoc, true);

                    Assert.IsNotNull(doc, "url=" + url);
                    Assert.IsTrue(doc.IsValidDocument(), "url=" + url);

                    Console.WriteLine("url=" + url);
                    Console.WriteLine("returns=" + doc.OuterXml);
                }
                catch (Exception ex) {
                    if (log.IsErrorEnabled)
                    {
                        log.ErrorException("웹 서버 Page의 ValidateRequest=False 이어야 합니다.", ex);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Create a new instance of <see cref="XdsRequestDocument"/> from the specified file.
        /// </summary>
        /// <param name="filename">full file path</param>
        /// <returns>instance of <see cref="XdsRequestDocument"/></returns>
        public static XdsRequestDocument LoadFromFile(string filename)
        {
            if (IsDebugEnabled)
            {
                log.Debug("Load from file to build request document. filename=[{0}]", filename);
            }

            if (File.Exists(filename) == false)
            {
                throw new FileNotFoundException("File not found.", filename);
            }

            XdsRequestDocument result = null;

            using (var stream = FileTool.GetBufferedFileStream(filename, FileOpenMode.Read)) {
                result = XmlTool.Deserialize <XdsRequestDocument>(stream);
            }
            if (IsDebugEnabled)
            {
                log.Debug("Load from file and build XdsRequestDocument is finished.");
            }

            return(result);
        }
Ejemplo n.º 9
0
        public OrderStatusResponse GetOrderStatus(OrderStatusRequest orderStatusRequest)
        {
            // Validate Request
            RequestValidator.ValidateOrderStatusRequest(orderStatusRequest);
            // Build Request object
            var request = RequestMapper.MapOrderStatusRequest(orderStatusRequest, _shopId);

            request.Request.MAC = _encoder.GetMac(RequestHandler.GetMacDictionary(request), _apiResultKey);
            var xmlBody = XmlTool.Serialize(request);
            // Do call to VPOS
            var xmlResponse = _restClient.CallApi(_urlAPI, xmlBody);
            // Map response
            var objectResponse = XmlTool.Deserialize <BPWXmlResponse <DataOrderStatus> >(xmlResponse);

            // Verify Mac Response
            VerifyMacResponse(objectResponse);
            VerifyPanAliasData(objectResponse.Data.PanAliasData);
            foreach (var authorization in objectResponse.Data.Authorizations)
            {
                VerifyAuthorization(authorization);
            }

            return(ResponseMapper.MapOrderStatusResponse(objectResponse));
        }
Ejemplo n.º 10
0
    private void InitData()
    {
        //if (null != mRuleList)
        //	return;

        mRuleList = new List <RuleObject>();
        XmlData root = XmlTool.GetXmlData(ERuleParam4Editor.RuleConfigUrlForEditor);

        if (null == root)
        {
            return;
        }

        foreach (var data in root.Childs)
        {
            RuleObject ruleObject = new RuleObject();
            if (!ruleObject.XmlDeserilize(data))
            {
                continue;
            }

            mRuleList.Add(ruleObject);
        }
    }
Ejemplo n.º 11
0
        /// <summary>
        /// load all setting
        /// </summary>
        internal static void LoadSetting()
        {
            BasicConfigLoaded = true;
            string styleXPath    = "/DbConfig/DbStyle";
            string trustedXPath  = "/DbConfig/DbTrusted";
            string hostXPath     = "/DbConfig/DbHost";
            string userXPath     = "/DbConfig/DbUser";
            string passwordXPath = "/DbConfig/DbPassword";
            string portXPath     = "/DbConfig/DbPort";
            string instanceXPath = "/DbConfig/DbInstance";
            string nameXPath     = "/DbConfig/DbName";
            string embedXPath    = "/DbConfig/DbEmbed";
            string positionXPath = "/DbConfig/DbPosition";
            string dbStyle       = XmlTool.GetNodeValueByXPath(styleXPath, _path);

            switch (dbStyle.ToLower())
            {
            case "sqlserver":
                DbStyle = DbStyleDefine.SqlServer;
                break;

            case "oracle":
                DbStyle = DbStyleDefine.Oracle;
                break;

            case "postgres":
                DbStyle = DbStyleDefine.Postgres;
                break;

            case "mysql":
                DbStyle = DbStyleDefine.MySql;
                break;

            case "firebird":
                DbStyle = DbStyleDefine.Firebird;
                break;

            case "sqlite":
                DbStyle = DbStyleDefine.Sqlite;
                break;

            case "access":
                DbStyle = DbStyleDefine.Access;
                break;

            default:
                DbStyle = DbStyleDefine.MySql;
                break;
            }
            DbTrusted  = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(trustedXPath, _path));
            DbHost     = XmlTool.GetNodeValueByXPath(hostXPath, _path);
            DbUser     = XmlTool.GetNodeValueByXPath(userXPath, _path);
            DbPassword = XmlTool.GetNodeValueByXPath(passwordXPath, _path);
            DbPort     = ConvertTool.GetInt(XmlTool.GetNodeValueByXPath(portXPath, _path));
            if (DbPort > 65535)
            {
                DbPort = 65534;
                XmlTool.SetNodeValueByXPath(portXPath, DbPort.ToString(), _path);
            }
            DbInstance = XmlTool.GetNodeValueByXPath(instanceXPath, _path);
            DbName     = XmlTool.GetNodeValueByXPath(nameXPath, _path);
            DbEmbed    = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(embedXPath, _path));
            DbPosition = XmlTool.GetNodeValueByXPath(positionXPath, _path);
        }
Ejemplo n.º 12
0
 public static XmlTool Xml()
 {
     return(XmlTool.New());
 }
Ejemplo n.º 13
0
    void InitPlayerInfoData()
    {
        playerinfo.Languege  = "zh";
        playerinfo.MineCount = 0;
        playerinfo.Money     = 0;

        playerinfo.MapInfoList                   = new ArrayList();
        playerinfo.MaterialInfoList              = new MaterialInfo();
        playerinfo.MaterialInfoList.Items        = new ArrayList();
        playerinfo.MaterialInfoList.Minds        = new ArrayList();
        playerinfo.MaterialInfoList.SpecialItems = new ArrayList();
        playerinfo.MaterialInfoList.Propertys    = new ArrayList();
        playerinfo.SenceInfoList                 = new ArrayList();
        playerinfo.CompleteEvents                = new ArrayList();
        playerinfo.QuestList      = new ArrayList();
        playerinfo.CompleteQuests = new ArrayList();

        //初始材料
        foreach (Materiral.Items m in Materiral.GetItemList())
        {
            ItemsInfo _m = new ItemsInfo();
            _m.ID           = m.ID;
            _m.PutCount     = 0;
            _m.SellCount    = 0;
            _m.RecipeCount  = 0;
            _m.CollectCount = 0;
            playerinfo.MaterialInfoList.Items.Add(_m);
        }
        foreach (Materiral.Minds m in Materiral.GetMindList())
        {
            MindsInfo _m = new MindsInfo();
            _m.ID           = m.ID;
            _m.PutCount     = 0;
            _m.SellCount    = 0;
            _m.RecipeCount  = 0;
            _m.CollectCount = 0;
            playerinfo.MaterialInfoList.Minds.Add(_m);
        }
        foreach (Materiral.SpecialItem m in Materiral.GetSpecialItemList())
        {
            SpecialItemsInfo _m = new SpecialItemsInfo();
            _m.ID           = m.ID;
            _m.PutCount     = 0;
            _m.SellCount    = 0;
            _m.RecipeCount  = 0;
            _m.CollectCount = 0;
            playerinfo.MaterialInfoList.SpecialItems.Add(_m);
        }
        foreach (Materiral.Property m in Materiral.GetPropertyList())
        {
            PropertysInfo _m = new PropertysInfo();
            _m.ID          = m.ID;
            _m.RecipeCount = 0;
            playerinfo.MaterialInfoList.Propertys.Add(_m);
        }

        //初始化场景数据
        for (int i = 0; i <= 1; i++)
        {
            SenceInfo s = new SenceInfo();
            s.ID      = i;
            s.InCount = 0;
            playerinfo.SenceInfoList.Add(s);
        }

        ////初始化地图路点数据
        XmlTool   xt    = new XmlTool();
        ArrayList _list = xt.loadPathXmlToArray();

        MapPathManager.Path[] PathList = new MapPathManager.Path[_list.Count];
        _list.CopyTo(PathList);
        xt = null; _list.Clear();

        foreach (MapPathManager.Path p in PathList)
        {
            MapInfo m = new MapInfo();
            m.ID      = p.Map;
            m.InCount = 0;
            playerinfo.MapInfoList.Add(m);
        }
    }
Ejemplo n.º 14
0
 public void SetEntityOverride(EntityStyle value)
 {
     EntityOverride = XmlTool.CloneUsingXml(value);
 }
Ejemplo n.º 15
0
    public void LoadConfig(Server server)
    {
        string filename = "ServerConfig.txt";

        if (!File.Exists(Path.Combine(GameStorePath.gamepathconfig, filename)))
        {
            Console.WriteLine(server.language.ServerConfigNotFound());
            SaveConfig(server);
            return;
        }
        try
        {
            using (TextReader textReader = new StreamReader(Path.Combine(GameStorePath.gamepathconfig, filename)))
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(ServerConfig));
                server.config = (ServerConfig)deserializer.Deserialize(textReader);
                textReader.Close();
            }
        }
        catch //This if for the original format
        {
            try
            {
                using (Stream s = new MemoryStream(File.ReadAllBytes(Path.Combine(GameStorePath.gamepathconfig, filename))))
                {
                    server.config = new ServerConfig();
                    StreamReader sr = new StreamReader(s);
                    XmlDocument  d  = new XmlDocument();
                    d.Load(sr);
                    server.config.Format = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/Format"));
                    server.config.Name   = XmlTool.XmlVal(d, "/ManicDiggerServerConfig/Name");
                    server.config.Motd   = XmlTool.XmlVal(d, "/ManicDiggerServerConfig/Motd");
                    server.config.Port   = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/Port"));
                    string maxclients = XmlTool.XmlVal(d, "/ManicDiggerServerConfig/MaxClients");
                    if (maxclients != null)
                    {
                        server.config.MaxClients = int.Parse(maxclients);
                    }
                    string key = XmlTool.XmlVal(d, "/ManicDiggerServerConfig/Key");
                    if (key != null)
                    {
                        server.config.Key = key;
                    }
                    server.config.IsCreative  = Misc.ReadBool(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/Creative"));
                    server.config.Public      = Misc.ReadBool(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/Public"));
                    server.config.AllowGuests = Misc.ReadBool(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/AllowGuests"));
                    if (XmlTool.XmlVal(d, "/ManicDiggerServerConfig/MapSizeX") != null)
                    {
                        server.config.MapSizeX = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/MapSizeX"));
                        server.config.MapSizeY = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/MapSizeY"));
                        server.config.MapSizeZ = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/MapSizeZ"));
                    }
                    server.config.BuildLogging            = bool.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/BuildLogging"));
                    server.config.ServerEventLogging      = bool.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/ServerEventLogging"));
                    server.config.ChatLogging             = bool.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/ChatLogging"));
                    server.config.AllowScripting          = bool.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/AllowScripting"));
                    server.config.ServerMonitor           = bool.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/ServerMonitor"));
                    server.config.ClientConnectionTimeout = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/ClientConnectionTimeout"));
                    server.config.ClientPlayingTimeout    = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerConfig/ClientPlayingTimeout"));
                }
                //Save with new version.
                SaveConfig(server);
            }
            catch
            {
                //ServerConfig is really messed up. Backup a copy, then create a new one.
                try
                {
                    File.Copy(Path.Combine(GameStorePath.gamepathconfig, filename), Path.Combine(GameStorePath.gamepathconfig, filename + ".old"));
                    Console.WriteLine(server.language.ServerConfigCorruptBackup());
                }
                catch
                {
                    Console.WriteLine(server.language.ServerConfigCorruptNoBackup());
                }
                server.config = null;
                SaveConfig(server);
            }
        }
        server.language.OverrideLanguage = server.config.ServerLanguage;  //Switch to user-defined language.
        Console.WriteLine(server.language.ServerConfigLoaded());
    }
Ejemplo n.º 16
0
 protected virtual void LoadFromXml(XmlElement xml)
 {
     XmlTool.LoadProperties(this, xml);
 }
Ejemplo n.º 17
0
    void OnGUI()
    {
        GUIStyle styleCmdArea = new GUIStyle();

        styleCmdArea.normal.background = MakeTex(600, 80, Color.white);

        //	info area
        GUILayout.BeginArea(new Rect(10, 10, 600, 80), styleCmdArea);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Platform:", GUILayout.Width(200));
        selectedPlatform = EditorGUILayout.Popup(selectedPlatform, listPlatform.ToArray());
        switch (selectedPlatform)
        {
        case 0:
            if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
                LoadConfigXML(CommonPatcherData.cnfFN);
                LoadVersionXML();
            }
            else
            {
                GUILayout.EndHorizontal();
            }
            break;

        case 1:
            if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows);
                LoadConfigXML(CommonPatcherData.cnfFN);
                LoadVersionXML();
            }
            else
            {
                GUILayout.EndHorizontal();
            }
            break;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("Last Version : " + lastMajorVersion + "." + lastMinorVersion);
        GUILayout.Label(">>>");
        GUILayout.Label("New Version :");
        chkLastMajorVersion = GUILayout.TextField("" + chkLastMajorVersion);
        chkLastMinorVersion = GUILayout.TextField("" + chkLastMinorVersion);
        if (GUILayout.Button("Apply", GUILayout.Width(70)))
        {
            //	apply last version info and make folders and modify xml files.
            if (EditorUtility.DisplayDialog("You know that ?!", "This work just makes a folder for new version and change the text of last version. Later, you can make new resources for next patch when you press the button [Upload to repository].", "I see!!") == true)
            {
                SaveVersionXML();
            }
        }
        if (GUILayout.Button("Rollback", GUILayout.Width(70)))
        {
            string prevVersion = PatchVersion.getPreviousVersion(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN);
            int    prevMajor   = Convert.ToInt32(prevVersion.Split('_')[1]);
            int    prevMinor   = Convert.ToInt32(prevVersion.Split('_')[2]);

            string curVersion = verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value;
            int    curMajor   = Convert.ToInt32(curVersion.Split('_')[1]);
            int    curMinor   = Convert.ToInt32(curVersion.Split('_')[2]);

            if (EditorUtility.DisplayDialog("Caution!!", "Your last version(VER " + curMajor.ToString("D2") + "." + curMinor.ToString("D3") + ") data will remove complete. Are you sure?", "YES", "NO") == true)
            {
                //	check last version
                Debug.Log("Rollback to previous Version >> " + prevVersion);

                //	modify patch.xml file
                verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value = prevVersion;
                PatchVersion.removeVersionNode(verDoc, curMajor, curMinor);
                XmlTool.writeXml(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN, verDoc);

                //	remove assets.xml and files, and backup folder
                string _dn = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/VER_" + curMajor.ToString("D2") + "/" + curMinor.ToString("D3");
                Directory.Delete(_dn, true);

                //	latest folder change
                Directory.Delete(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo, true);
                Directory.Move(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo + "_VER_" + curMajor.ToString("D2") + "_" + curMinor.ToString("D3"),
                               CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo);

                lastMajorVersion    = prevMajor;
                chkLastMajorVersion = curMajor.ToString("D2");
                lastMinorVersion    = prevMinor;
                chkLastMinorVersion = curMinor.ToString("D3");
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Path :");
        CommonPatcherData.repoPath = GUILayout.TextField(CommonPatcherData.repoPath);
        //	read config file
        if (GUILayout.Button("Read", GUILayout.Width(100)))
        {
            LoadConfigXML(CommonPatcherData.cnfFN);
        }

        if (GUILayout.Button("Save", GUILayout.Width(100)))
        {
            cnfDoc.SelectSingleNode("/ToolConfig/Repository").Attributes ["path"].Value = CommonPatcherData.repoPath;
            SaveConfigXML(CommonPatcherData.cnfFN, cnfDoc);
            MakeLocalRepo();
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        //	command area
        GUILayout.BeginArea(new Rect(10, 100, 600, 140));
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Build AssetBundles", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.Build;
            BuildScript.BuildAssetBundles();
            return;
        }

        if (GUILayout.Button("unregisted assets", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.Unregisted;
            checkUnregistedAssets();
        }

        if (GUILayout.Button("All AssetBundles List", GUILayout.Width(150)))
        {
            ActiveABMWType = ABMWType.PatchInfo;
            checkRegistedAssets();
        }

        if (GUILayout.Button("Upload to repository", GUILayout.Width(150)))
        {
            if (EditorUtility.DisplayDialog("Upload !!", "Did you make a folder for new version?! If not, press the button [apply]. This will make a folder and change the version number for new version.", "I DID!!", "Ooops!") == true)
            {
                ActiveABMWType = ABMWType.Upload;
                BuildScript.BuildAssetBundles();

                //	compare all AssetBundles with "repoPath + lastVersionRepo"'s all files
                List <FileInfo> listNew     = new List <FileInfo>();
                List <FileInfo> listModify  = new List <FileInfo>();
                List <FileInfo> listRemoved = new List <FileInfo>();

                {
                    DirectoryInfo latestDir     = new DirectoryInfo(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget);
                    FileInfo []   latestABFiles = latestDir.GetFiles("*.*", SearchOption.AllDirectories);

                    DirectoryInfo buildDir   = new DirectoryInfo(BuildScript.GetAssetBundleBuildPath() + "/" + EditorUserBuildSettings.activeBuildTarget);
                    FileInfo []   newABFiles = buildDir.GetFiles("*.*", SearchOption.AllDirectories);

                    int newIndex = 0;
                    foreach (FileInfo fi in newABFiles)
                    {
                        int latestIndex = 0;
                        foreach (FileInfo latefi in latestABFiles)
                        {
                            int ret = compareFile(fi, latefi);
                            if (ret == 0)                              //	completely different
                            {
                            }
                            else if (ret == 1)                              //	same exactly
                            {
                                break;
                            }
                            else if (ret == 2)                               //	modified
                            {
                                listModify.Add(fi);
                                break;
                            }
                            latestIndex++;
                        }

                        if (latestIndex == latestABFiles.Length)
                        {
                            listNew.Add(fi);
                        }
                        newIndex++;
                    }

                    foreach (FileInfo latefiR in latestABFiles)
                    {
                        int chkIndex = 0;
                        foreach (FileInfo fiR in newABFiles)
                        {
                            if (fiR.Name == latefiR.Name)
                            {
                                break;
                            }
                            chkIndex++;
                        }
                        if (chkIndex == latestABFiles.Length)
                        {
                            listRemoved.Add(latefiR);
                        }
                    }
                }

                //	upload updated AssetBundles to the new repository.
                SaveAssetsXML(listNew, listModify, listRemoved);
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        //	console area
        GUILayout.BeginArea(new Rect(10, 150, 600, 600));
        switch (ActiveABMWType)
        {
        case ABMWType.Build:

            break;

        case ABMWType.Unregisted:
            ListUnregistedAssets();
            break;

        case ABMWType.PatchInfo:
            ListRegistedAssets();
            break;

        case ABMWType.Upload:

            break;
        }
        GUILayout.EndArea();
    }
Ejemplo n.º 18
0
    public static XmlDocument MakeVersionFile(uint totalCRC, string srcPath, List <stAssetInfo> listAssetNotVersioned = null, bool isFirst = false)
    {
        string targetPath = GetVersionFilePath(srcPath);

        if (isFirst == false)
        {
            LoadVersionFile(srcPath);
            if (CachedVerInfo == null)
            {
                Debug.Log("No Cached File, make new ..");
                LoadedVerDoc = MakeVersionFile(0, srcPath, null, true);                 // ���� ����X�� �⺻��
                //CachedVerInfo = new VersionInfo(LoadedVerDoc);
            }
        }
        else
        {
            CachedVerInfo = new VersionInfo();
        }

        //string strMajor = EnvVariable.GetEnvStr(MajorVerKey);
        //string strMinor = EnvVariable.GetEnvStr(MinorVerKey);
        //string strRevision = EnvVariable.GetEnvStr(RevisionKey);
        //string strAssetVer = EnvVariable.GetEnvStr(AssetVerKey);

        uint uAssetVer = 0;

        uAssetVer = CachedVerInfo.AssetVersion;

        //uint.TryParse(strAssetVer, out uAssetVer);

        VersionInfo newVerInfo = new VersionInfo();
        {
            newVerInfo.Init();
            //newVerInfo.Major = strMajor;
            //newVerInfo.Minor = strMinor;
            //newVerInfo.Revision = strRevision;
            newVerInfo.AssetVersion = uAssetVer;
            newVerInfo.AssetCRC     = totalCRC;

            //newVerInfo.SetVersion(UnityEditor.PlayerSettings.bundleVersion);
            Debug.Log("new version is now " + UnityEditor.PlayerSettings.bundleVersion);

            if (newVerInfo.AssetCRC == CachedVerInfo.AssetCRC)             // CRC ������ ���� �ø��� �ʴ´�
            {
                newVerInfo.AssetDict = CachedVerInfo.AssetDict;
            }
            else
            {                                                                                                                                                           // �Ȱ����� �־��� �����ͷ� ���� �ø���
                if (listAssetNotVersioned != null)
                {
                    newVerInfo.AssetVersion++;

                    for (int i = 0; i < listAssetNotVersioned.Count; ++i)
                    {
                        stAssetInfo tempAssetInfo = listAssetNotVersioned[i];                                   // �� ���� ��� ������ ���� ���� ����
                        tempAssetInfo.Version = newVerInfo.AssetVersion;

                        if (CachedVerInfo.AssetDict.ContainsKey(tempAssetInfo.Name))                                // �ڽ��� �����ִ� ����߿� ���� ����� ���� ��
                        {
                            stAssetInfo cachedAssetInfo = CachedVerInfo.AssetDict[tempAssetInfo.Name];

                            if (tempAssetInfo.CRC == cachedAssetInfo.CRC)                                           // �� ��ü�� CRC ���� ������ ������ �ٲ��� �ʴ´�
                            {
                                tempAssetInfo.Version = cachedAssetInfo.Version;
                            }
                        }

                        newVerInfo.AssetDict[tempAssetInfo.Name] = tempAssetInfo;
                    }
                }
            }
        }

        XmlDocument newDocu = newVerInfo.ToXML();

        CachedVerInfo = newVerInfo;

        if (File.Exists(targetPath) == true)                            // ������ ���� ����
        {
            File.Delete(targetPath);
        }

        XmlTool.writeXml(targetPath, newDocu);                  // ���� ����

        Debug.LogError("Save in MakeVersionFile");

        return(newDocu);
    }
Ejemplo n.º 19
0
        private void install_Click(object sender, EventArgs e)
        {
            log.Visible = false;
            try
            {
                progress.Visible = true;
                WebClient client = new WebClient();
                Step(1, "Downloading metadata");
                XElement meta = XDocument.Load("https://github.com/JFronny/UpTool2/releases/latest/download/meta.xml")
                                .Element("meta");
                Step(2, "Downloading binary");
                byte[] dl = client.DownloadData(meta.Element("File").Value);
                Step(3, "Verifying integrity");
                using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
                {
                    string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
                    if (pkgHash != meta.Element("Hash").Value.ToUpper())
                    {
                        throw new Exception(
                                  $@"The hash is not equal to the one stored in the repo:
Package: {pkgHash}
Online: {meta.Element("Hash").Value.ToUpper()}");
                    }
                }
                Step(4, "Extracting");
                if (Directory.Exists(PathTool.GetRelative("Install")))
                {
                    Directory.Delete(PathTool.GetRelative("Install"), true);
                }
                Directory.CreateDirectory(PathTool.GetRelative("Install"));
                using (MemoryStream ms = new MemoryStream(dl))
                {
                    using ZipArchive ar = new ZipArchive(ms);
                    ar.ExtractToDirectory(PathTool.GetRelative("Install"), true);
                }
                Step(5, "Creating shortcut");
                Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"),
                              System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
                                                     "UpTool2.lnk"));
                Step(6, "Preparing Repos");
                XmlTool.FixXml();
                RepoManagement.FetchRepos();
                if (pathBox.Checked)
                {
                    Step(7, startupBox.Checked ? "Creating PATH & Autostart entry" : "Creating PATH entry");
                    if (!Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install"))))
                    {
                        Path.Append(PathTool.GetRelative("Install"));
                    }
                    if (startupBox.Checked)
                    {
                        _rkApp.SetValue(AppName, updateAppsBox.Checked ? "uptool dist-upgrade" : "uptool upgrade-self");
                    }
                    else if (_rkApp.GetValue(AppName) != null)
                    {
                        _rkApp.DeleteValue(AppName, false);
                    }
                }
                Step(8, "Done!");
            }
            catch (Exception ex)
            {
                Step(progress.Value, $"Failed!{Environment.NewLine}{ex}");
                BackColor         = Color.Red;
                processLabel.Text = "Failed";
                new Thread(() =>
                {
                    Thread.Sleep(1000);
                    Invoke(new Action(() =>
                    {
                        BackColor        = SystemColors.Control;
                        progress.Visible = false;
                    }));
                }).Start();
            }
            finally
            {
                log.Visible = true;
            }
        }
Ejemplo n.º 20
0
 public static void WriteRow(StreamWriter fw, ITableStructure table, IBedRecord record, IBedValueFormatter formatter)
 {
     fw.Write("<ss:Row>\n");
     for (int i = 0; i < record.FieldCount; i++)
     {
         string sval  = null;
         string stype = "String";
         string style = "";
         record.ReadValue(i);
         var type = record.GetFieldType();
         if (type.IsDateRelated())
         {
             stype = "DateTime";
             style = " ss:StyleID=\"sDateTime\" ";
         }
         else if (type.IsNumber())
         {
             stype = "Number";
         }
         formatter.ReadFrom(record);
         sval = formatter.GetText();
         //object val = record.GetValue(i);
         //if (val is DateTime)
         //{
         //    stype = "DateTime";
         //    sval = ((DateTime)val).ToString("s", CultureInfo.InvariantCulture);
         //    style = " ss:StyleID=\"sDateTime\" ";
         //}
         //else if (val != null && val.GetType().IsNumberType())
         //{
         //    stype = "Number";
         //    sval = Convert.ToString(val, CultureInfo.InvariantCulture);
         //}
         //if (sval == null) sval = XmlTool.ObjectToString(val);
         fw.Write("<ss:Cell {2}><Data ss:Type=\"{0}\">{1}</Data></ss:Cell>\n", stype, XmlTool.QuoteEntities(sval), style);
     }
     fw.Write("</ss:Row>\n");
 }
Ejemplo n.º 21
0
    //	config xml file
    ///////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////
    //	version xml file
    void LoadVersionXML()
    {
        string url = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN;

        verDoc = XmlTool.loadXml(url);

        if (verDoc == null)
        {
            //	make local repo
            {
                MakeLocalRepo();                        //
            }

            verDoc = new XmlDocument();
            XmlNode root = verDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            verDoc.AppendChild(root);

            XmlNode node      = verDoc.CreateElement("VERSIONS");
            XmlNode nodeChild = verDoc.CreateElement("PATCH");
            //	Add attribute info for Last Version
            {
                XmlAttribute attr = verDoc.CreateAttribute("LastVersion");
                attr.Value = "VER_00_000";
                nodeChild.Attributes.Append(attr);
                node.AppendChild(nodeChild);
            }

            //	add major and minor's version info
            {
                XmlNode nodeMajor = verDoc.CreateElement("MAJOR");
                //	Add attribute info for Major version
                {
                    XmlAttribute attr = verDoc.CreateAttribute("value");
                    attr.Value = "00";
                    nodeMajor.Attributes.Append(attr);
                }

                XmlNode nodeMinor = verDoc.CreateElement("MINOR");
                //	Add attribute info for Major version
                {
                    XmlAttribute attr = verDoc.CreateAttribute("value");
                    attr.Value = "000";
                    nodeMinor.Attributes.Append(attr);
                }

                nodeMajor.AppendChild(nodeMinor);
                node.AppendChild(nodeMajor);
            }

            verDoc.AppendChild(node);

            SaveConfigXML(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN, verDoc);
        }
        else
        {
            string    ver  = verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes ["LastVersion"].Value;
            string [] data = ver.Split('_');
            if (data.Length < 2)
            {
                Debug.LogError("data is incorrect!!");
            }
            else
            {
                lastMajorVersion    = Convert.ToInt32(data[1]);
                lastMinorVersion    = Convert.ToInt32(data[2]);
                chkLastMajorVersion = (Convert.ToInt32(data[1])).ToString("D2");
                chkLastMinorVersion = (Convert.ToInt32(data[2]) + 1).ToString("D3");
            }
        }
        //	make sub folder
        MakeLocalRepo();
    }
Ejemplo n.º 22
0
    //	version xml file
    ///////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////
    //	assets xml file
    void SaveAssetsXML(List <FileInfo> listNew, List <FileInfo> listModify, List <FileInfo> listRemoved)
    {
        XmlDocument xmlDoc = new XmlDocument();
        XmlNode     root   = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);

        xmlDoc.AppendChild(root);

        XmlNode nodeMain = xmlDoc.CreateElement("AssetBundles");

        XmlNode      nodeVer = xmlDoc.CreateElement("VERSION");
        XmlAttribute attrVer = xmlDoc.CreateAttribute("value");

        attrVer.Value = "VER_" + lastMajorVersion.ToString("D2") + "_" + lastMinorVersion.ToString("D3");
        nodeVer.Attributes.Append(attrVer);
        nodeMain.AppendChild(nodeVer);

        {
            XmlNode nodeCreate = xmlDoc.CreateElement("CREATE");
            foreach (FileInfo info in listNew)
            {
                XmlNode      nodeFILE = xmlDoc.CreateElement("FILE");
                XmlAttribute attrName = xmlDoc.CreateAttribute("name");
                attrName.Value = info.Name;
                nodeFILE.Attributes.Append(attrName);
                nodeCreate.AppendChild(nodeFILE);
            }
            nodeMain.AppendChild(nodeCreate);
        }

        {
            XmlNode nodeModify = xmlDoc.CreateElement("MODIFY");
            foreach (FileInfo info in listModify)
            {
                XmlNode      nodeFILE = xmlDoc.CreateElement("FILE");
                XmlAttribute attrName = xmlDoc.CreateAttribute("name");
                attrName.Value = info.Name;
                nodeFILE.Attributes.Append(attrName);
                nodeModify.AppendChild(nodeFILE);
            }
            nodeMain.AppendChild(nodeModify);
        }

        {
            XmlNode nodeRemove = xmlDoc.CreateElement("REMOVE");
            foreach (FileInfo info in listRemoved)
            {
                XmlNode      nodeFILE = xmlDoc.CreateElement("FILE");
                XmlAttribute attrName = xmlDoc.CreateAttribute("name");
                attrName.Value = info.Name;
                nodeFILE.Attributes.Append(attrName);
                nodeRemove.AppendChild(nodeFILE);
            }
            nodeMain.AppendChild(nodeRemove);
        }

        xmlDoc.AppendChild(nodeMain);

        string xmlFullpath = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + "VER_" + lastMajorVersion.ToString("D2") + "/" + lastMinorVersion.ToString("D3") + "/" + CommonPatcherData.assetbundleFN;

        XmlTool.writeXml(xmlFullpath, xmlDoc);

        //	backup all AssetBundles from "repopath/ostype/latest/"  to "repopath/ostype/latest_ver_XX_XXX"
        string latest     = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo;
        string backuppath = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo + "_VER_" + lastMajorVersion.ToString("D2") + "_" + lastMinorVersion.ToString("D3");

        if (lastMajorVersion != 0 || lastMinorVersion != 0)
        {
            //Directory.CreateDirectory(backuppath);
            Directory.Move(latest, backuppath);
            Directory.CreateDirectory(latest);
        }

        // copy all AssetBundles to "repopath/ostype/latest/"
        BuildScript.CopyAssetBundlesTo(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo);

        // copy some assetbundles for patching to "repopath/ostype/ver_xx/xxx/
        string vertargetPath = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + "VER_" + lastMajorVersion.ToString("D2") + "/" + lastMinorVersion.ToString("D3");

        foreach (FileInfo info in listNew)
        {
            File.Copy(info.FullName, vertargetPath + "/" + info.Name);
        }
        foreach (FileInfo info in listModify)
        {
            File.Copy(info.FullName, vertargetPath + "/" + info.Name);
        }
        foreach (FileInfo info in listRemoved)
        {
            File.Copy(info.FullName, vertargetPath + "/" + info.Name);
        }
    }
Ejemplo n.º 23
0
 void SaveConfigXML(string _fn, XmlDocument _doc)
 {
     XmlTool.writeXml(_fn, _doc);
 }
Ejemplo n.º 24
0
 public virtual void SaveToXml(XmlElement xml)
 {
     xml.SetAttribute("datatype", Code.ToString().ToLower());
     XmlTool.SaveProperties(this, xml);
 }
Ejemplo n.º 25
0
    void SaveVersionXML()
    {
        string url = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN;

        if (verDoc == null)
        {
            LoadVersionXML();
            if (verDoc == null)
            {
                Debug.LogError(" Restart AssetBundleMngWindow. Version data is incorrect!");
                return;
            }
        }
        if (lastMajorVersion >= Convert.ToInt32(chkLastMajorVersion) && lastMinorVersion >= Convert.ToInt32(chkLastMinorVersion))
        {
            Debug.LogError(" Version is incorrect! New version is higher than old version.");
            return;
        }
        if (getVersionNode(Convert.ToInt32(chkLastMajorVersion), Convert.ToInt32(chkLastMinorVersion)) != null)
        {
            Debug.LogError(" This version is exist! Please re-check the version.");
            return;
        }

        lastMajorVersion = Convert.ToInt32(chkLastMajorVersion);
        lastMinorVersion = Convert.ToInt32(chkLastMinorVersion);

        XmlNode _parent     = getVersionNode(lastMajorVersion);
        bool    _bNewParent = false;

        if (_parent == null)
        {
            _parent = verDoc.CreateElement("MAJOR");
            XmlAttribute attr = verDoc.CreateAttribute("value");
            attr.Value = lastMajorVersion.ToString("D2");
            _parent.Attributes.Append(attr);
            _bNewParent = true;
        }

        XmlNode      _child = verDoc.CreateElement("MINOR");
        XmlAttribute attrC  = verDoc.CreateAttribute("value");

        attrC.Value = lastMinorVersion.ToString("D3");
        _child.Attributes.Append(attrC);
        _parent.AppendChild(_child);
        if (_bNewParent)
        {
            verDoc.AppendChild(_parent);
        }
        XmlNode _last = verDoc.SelectSingleNode("/VERSIONS/PATCH");

        _last.Attributes["LastVersion"].Value = "VER_" + lastMajorVersion.ToString("D2") + "_" + lastMinorVersion.ToString("D3");

        XmlTool.writeXml(url, verDoc);

        chkLastMajorVersion = lastMajorVersion.ToString("D2");
        chkLastMinorVersion = (lastMinorVersion + 1).ToString("D3");

        //	make sub folder
        MakeLocalRepo();
    }
Ejemplo n.º 26
0
    public void LoadServerClient(Server server)
    {
        string filename = "ServerClient.txt";

        if (!File.Exists(Path.Combine(GameStorePath.gamepathconfig, filename)))
        {
            Console.WriteLine(server.language.ServerClientConfigNotFound());
            SaveServerClient(server);
        }
        else
        {
            try
            {
                using (TextReader textReader = new StreamReader(Path.Combine(GameStorePath.gamepathconfig, filename)))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(ServerClient));
                    server.serverClient = (ServerClient)deserializer.Deserialize(textReader);
                    textReader.Close();
                    server.serverClient.Groups.Sort();
                    SaveServerClient(server);
                }
            }
            catch //This if for the original format
            {
                using (Stream s = new MemoryStream(File.ReadAllBytes(Path.Combine(GameStorePath.gamepathconfig, filename))))
                {
                    server.serverClient = new ServerClient();
                    StreamReader sr = new StreamReader(s);
                    XmlDocument  d  = new XmlDocument();
                    d.Load(sr);
                    server.serverClient.Format                 = int.Parse(XmlTool.XmlVal(d, "/ManicDiggerServerClient/Format"));
                    server.serverClient.DefaultGroupGuests     = XmlTool.XmlVal(d, "/ManicDiggerServerClient/DefaultGroupGuests");
                    server.serverClient.DefaultGroupRegistered = XmlTool.XmlVal(d, "/ManicDiggerServerClient/DefaultGroupRegistered");
                }
                //Save with new version.
                SaveServerClient(server);
            }
        }
        if (server.serverClient.DefaultSpawn == null)
        {
            // server sets a default spawn (middle of map)
            int x = server.d_Map.MapSizeX / 2;
            int y = server.d_Map.MapSizeY / 2;
            server.defaultPlayerSpawn = server.DontSpawnPlayerInWater(new Vector3i(x, y, MapUtil.blockheight(server.d_Map, 0, x, y)));
        }
        else
        {
            int z;
            if (server.serverClient.DefaultSpawn.z == null)
            {
                z = MapUtil.blockheight(server.d_Map, 0, server.serverClient.DefaultSpawn.x, server.serverClient.DefaultSpawn.y);
            }
            else
            {
                z = server.serverClient.DefaultSpawn.z.Value;
            }
            server.defaultPlayerSpawn = new Vector3i(server.serverClient.DefaultSpawn.x, server.serverClient.DefaultSpawn.y, z);
        }

        server.defaultGroupGuest = server.serverClient.Groups.Find(
            delegate(ManicDigger.Group grp)
        {
            return(grp.Name.Equals(server.serverClient.DefaultGroupGuests));
        }
            );
        if (server.defaultGroupGuest == null)
        {
            throw new Exception(server.language.ServerClientConfigGuestGroupNotFound());
        }
        server.defaultGroupRegistered = server.serverClient.Groups.Find(
            delegate(ManicDigger.Group grp)
        {
            return(grp.Name.Equals(server.serverClient.DefaultGroupRegistered));
        }
            );
        if (server.defaultGroupRegistered == null)
        {
            throw new Exception(server.language.ServerClientConfigRegisteredGroupNotFound());
        }
        Console.WriteLine(server.language.ServerClientConfigLoaded());
    }
Ejemplo n.º 27
0
 /// <summary>
 /// Serialized 된 정보를 Deserialize 를 수행해서 객체로 반환한다.
 /// </summary>
 /// <param name="data">serialized data to be deserialized.</param>
 /// <returns>deserialized object</returns>
 public T Deserialize(byte[] data)
 {
     return(XmlTool.Deserialize <T>(data));
 }
Ejemplo n.º 28
0
        public override XdsResponseDocument ExecuteXmlDataManager(XdsRequestDocument requestDocument)
        {
            var responseXml = XmlHttpTool.PostXml(ScriptPath, requestDocument.ToXmlDocument(XmlTool.XmlEncoding));

            return(XmlTool.Deserialize <XdsResponseDocument>(responseXml));
        }
Ejemplo n.º 29
0
    IEnumerator getPatchInfo(XmlDocument _verDoc)
    {
        //	get all list for patching
        List <string> versions = PatchVersion.getPatchList(_verDoc, PatchVersion.major, PatchVersion.minor);

        //	get all assetbundle's version when you got them last time.
        Dictionary <string, int> verList = PatchVersion.getAssetBundleVerList();

        List <string> patchList = new List <string> ();
        Dictionary <string, string> patchListPath = new Dictionary <string, string> ();         //	file name, fullpath

        //	sort patch files list
        foreach (string verStr in versions)
        {
            string [] ver      = verStr.Split('_');
            string    listPath = url + ver[0] + "_" + ver[1] + "/" + ver[2] + "/" + CommonPatcherData.assetbundleFN;

            WWW patchListWWW = new WWW(listPath);
            yield return(patchListWWW);

            XmlDocument xmlDoc = XmlTool.loadXml(patchListWWW.bytes);

            if (xmlDoc != null)
            {
                {                       //	create files
                    XmlNode _nodeCreate  = xmlDoc.SelectSingleNode("/AssetBundles/CREATE");
                    XmlNode _nodeC_Files = _nodeCreate.FirstChild;
                    while (_nodeC_Files != null)
                    {
                        string name = _nodeC_Files.Attributes["name"].Value;

                        if (patchList.FindIndex(delegate(string r){ return(r == name); }) == -1)
                        {
                            patchList.Add(name);
                        }
                        patchListPath[name] = url + ver[0] + "_" + ver[1] + "/" + ver[2] + "/" + name;

                        _nodeC_Files = _nodeC_Files.NextSibling;
                    }
                }

                {                       //	modify files
                    XmlNode _nodeModify  = xmlDoc.SelectSingleNode("/AssetBundles/MODIFY");
                    XmlNode _nodeM_Files = _nodeModify.FirstChild;
                    while (_nodeM_Files != null)
                    {
                        string name = _nodeM_Files.Attributes["name"].Value;
                        if (patchList.FindIndex(delegate(string r){ return(r == name); }) == -1)
                        {
                            patchList.Add(name);
                        }
                        patchListPath[name] = url + ver[0] + "_" + ver[1] + "/" + ver[2] + "/" + name;

                        _nodeM_Files = _nodeM_Files.NextSibling;
                    }
                }
            }
        }
        //	start downloading dictionary
        int count = 0;

        foreach (string name in patchList)
        {
            PatchMessage = "Downloading.. " + name + "(" + count + "/" + patchList.Count + ")";
            int newversion = 0;
            if (verList.ContainsKey(name))
            {
                newversion = verList[name] + 1;
            }
            else
            {
                verList.Add(name, 0);
            }

            yield return(StartCoroutine(Downloading(patchListPath[name], newversion)));

            verList[name] += 1;
            count++;
            PatchProgress = (count * 100) / patchList.Count;
        }

        PatchVersion.setAssetBundleVerList(verList);
    }
Ejemplo n.º 30
0
        protected override void DoRun(IShellContext context)
        {
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(FtpDirectory);

            //request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
            request.Method = WebRequestMethods.Ftp.ListDirectory;

            string pwd = Password;

            if (!String.IsNullOrEmpty(PasswordEncoded))
            {
                pwd = XmlTool.SafeDecodeString(PasswordEncoded);
            }

            //request.KeepAlive = false;
            //request.UseBinary = true;
            request.UsePassive  = PassiveMode;
            request.Credentials = new NetworkCredential(Login, pwd);

            var files = new List <string>();

            using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
            {
                var responseStream = response.GetResponseStream();
                using (var reader = new StreamReader(responseStream))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine()?.Trim();
                        if (String.IsNullOrEmpty(line))
                        {
                            continue;
                        }
                        if (line == "." || line == "..")
                        {
                            continue;
                        }
                        files.Add(line);
                    }
                }
            }

            foreach (string file in files)
            {
                FtpWebRequest requestLength = (FtpWebRequest)WebRequest.Create(FtpDirectory + file);
                requestLength.UsePassive  = PassiveMode;
                requestLength.Credentials = new NetworkCredential(Login, pwd);
                requestLength.Method      = WebRequestMethods.Ftp.GetFileSize;

                long ftpSize;
                using (FtpWebResponse response = (FtpWebResponse)requestLength.GetResponse())
                {
                    ftpSize = response.ContentLength;
                    response.Close();
                }

                long   localSize = 0;
                string localFile = Path.Combine(LocalDirectory, file);
                if (System.IO.File.Exists(localFile))
                {
                    localSize = new FileInfo(localFile).Length;
                }

                if (localSize != ftpSize)
                {
                    context.OutputMessage($"Downloading file {file}, size={ftpSize}");

                    FtpWebRequest requestFile = (FtpWebRequest)WebRequest.Create(FtpDirectory + file);
                    requestFile.UsePassive  = PassiveMode;
                    requestFile.Credentials = new NetworkCredential(Login, pwd);
                    requestFile.Method      = WebRequestMethods.Ftp.DownloadFile;

                    using (var response = requestFile.GetResponse())
                    {
                        using (Stream stream = response.GetResponseStream())
                        {
                            using (BinaryWriter writer = new BinaryWriter(System.IO.File.Open(localFile, FileMode.Create)))
                            {
                                int    bytesRead = 0;
                                byte[] buffer    = new byte[1024];

                                while (true)
                                {
                                    bytesRead = stream.Read(buffer, 0, buffer.Length);
                                    if (bytesRead == 0)
                                    {
                                        break;
                                    }
                                    writer.Write(buffer, 0, bytesRead);
                                }
                            }
                        }
                    }
                }
                else
                {
                    context.OutputMessage($"Skipping file {file}");
                }
            }
        }