Beispiel #1
0
 public bool DeleteDirectory(string directoryPath)
 {
     try
     {
         if (string.IsNullOrEmpty(ServerPath))
         {
             throw RaiseException("DeleteDirectory", "未设置服务器文件目录!");
         }
         if (string.IsNullOrEmpty(directoryPath) ||
             ServerPath.EndsWith(directoryPath, StringComparison.CurrentCultureIgnoreCase))
         {
             throw RaiseException("DeleteDirectory", "不能删除服务器根目录!");
         }
         FileUtil.DeleteDirectory(ServerPath + @"\\" + directoryPath);
         //Directory.Delete(ServerPath + @"\\" + directoryPath, true);
         return(true);
     }
     catch (IOException e)
     {
         Log.Warn(e);
         throw RaiseException("DeleteDirectory", e.Message);
     }
     catch (Exception e)
     {
         Log.Warn(e);
         throw RaiseException("DeleteDirectory", e.Message);
     }
 }
Beispiel #2
0
 private string GetFileDirectory(string directoryPath)
 {
     if (string.IsNullOrEmpty(ServerPath))
     {
         throw RaiseException("GetFileDirectory", "未获取到服务器文件目录!");
     }
     if (string.IsNullOrEmpty(directoryPath) || ServerPath.EndsWith(directoryPath, StringComparison.CurrentCultureIgnoreCase))
     {
         return(ServerPath);
     }
     return(ServerPath + directoryPath + @"\\");
 }
Beispiel #3
0
        //loads the configuration file
        public bool Load(string configurationFile)
        {
            XmlDocument docConfig = new XmlDocument();
            XmlNode     xmlNode;

            try
            {
                docConfig.Load(configurationFile);

                //read server path
                xmlNode    = docConfig.GetElementsByTagName("server")[0];
                ServerPath = xmlNode.Attributes["path"].Value;
                if (ServerPath != "" && !ServerPath.EndsWith("/"))
                {
                    ServerPath += "/";
                }

                //read game path
                xmlNode  = docConfig.GetElementsByTagName("game")[0];
                GamePath = xmlNode.Attributes["path"].Value;
                if (GamePath != "" && !GamePath.EndsWith("/"))
                {
                    GamePath += "/";
                }
                GameConfigurationFile = xmlNode.Attributes["configFile"].Value;

                //read relative server path of the Updater
                xmlNode = docConfig.GetElementsByTagName("updater")[0];
                RelUpdaterPathOnServer = xmlNode.Attributes["serverpath"].Value;
                if (RelUpdaterPathOnServer != "" && !RelUpdaterPathOnServer.EndsWith("/"))
                {
                    RelUpdaterPathOnServer += "/";
                }

                //set absolute server path of the Updater
                AbsUpdaterPathOnServer = ServerPath + RelUpdaterPathOnServer;

                //read name of the administrated versions configuration file
                xmlNode = docConfig.GetElementsByTagName("versionsFile")[0];
                VersionsConfigurationFile = xmlNode.Attributes["name"].Value;

                //read name of a update configuration file
                xmlNode = docConfig.GetElementsByTagName("updateConfig")[0];
                UpdateConfigurationFile = xmlNode.Attributes["name"].Value;

                //read name of a full version configuration file
                xmlNode = docConfig.GetElementsByTagName("fullVersionConfig")[0];
                FullVersionConfigurationFile = xmlNode.Attributes["name"].Value;

                //read name of the temporary download folder
                xmlNode    = docConfig.GetElementsByTagName("temp")[0];
                TempFolder = xmlNode.Attributes["path"].Value;

                //read name of the Udater executeable
                xmlNode    = docConfig.GetElementsByTagName("updaterExe")[0];
                UpdaterExe = xmlNode.Attributes["name"].Value;

                //read name of the Installer executeable
                xmlNode      = docConfig.GetElementsByTagName("installerExe")[0];
                InstallerExe = xmlNode.Attributes["name"].Value;

                //read version of the Updater
                xmlNode       = docConfig.GetElementsByTagName("version")[0];
                VersionNumber = xmlNode.Attributes["name"].Value;

                //check version syntax
                if (!Version.CheckVersionSyntax(VersionNumber))
                {
                    return(false);
                }

                //read number of last background image and image-update flag
                xmlNode = docConfig.GetElementsByTagName("pictures")[0];
                LastBackgroundImgNumber = int.Parse(xmlNode.Attributes["lastNumber"].Value);
                UpdatePictures          = bool.Parse(xmlNode.Attributes["update"].Value);

                //read all background images
                foreach (XmlNode pictureNode in xmlNode.ChildNodes)
                {
                    BackgroundImgList.Add(int.Parse(pictureNode.Attributes["number"].Value),
                                          pictureNode.Attributes["path"].Value);
                }

                //set next background image number
                NextBackgroundImgNumber = GetNextBackgroundImgNumber(LastBackgroundImgNumber);
            }
            catch (Exception e)
            {
                ErrorLog.Add(this, e.Message);
                return(false);
            }

            return(true);
        }