Example #1
0
        private RemoteConfigManagerDTO deleteConfig(RemoteConfigManagerDTO remoteConfigManager)
        {
            RemoteConfigManagerDTO result = new RemoteConfigManagerDTO();

            try {
                result.Operation.Result = true;

                string folder = ConfigurationManager.AppSettings["publishFolder"];
                folder = Path.Combine(folder, remoteConfigManager.Operation.Condition);
                if (Directory.Exists(folder))
                {
                    string bakFolder = ConfigurationManager.AppSettings["bakFolder"];
                    bakFolder = Path.Combine(bakFolder, remoteConfigManager.Operation.Condition);
                    if (!Directory.Exists(bakFolder))
                    {
                        Directory.CreateDirectory(bakFolder);
                    }
                    bakFolder = Path.Combine(bakFolder, DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss"));
                    Directory.Move(folder, bakFolder);
                }
            }
            catch (Exception ex) {
                result.Operation.Result     = false;
                result.Operation.ResultInfo = ex.ToString();
            }
            return(result);
        }
Example #2
0
        private RemoteConfigManagerDTO getMajors(RemoteConfigManagerDTO remoteConfigManager)
        {
            RemoteConfigManagerDTO result = new RemoteConfigManagerDTO();

            try {
                result.Operation.Result = true;

                string folder = ConfigurationManager.AppSettings["publishFolder"];
                folder = Path.Combine(folder, remoteConfigManager.Operation.Condition);
                if (!Directory.Exists(folder))
                {
                    return(result);
                }
                string[] majorVersions = Directory.GetDirectories(folder);
                if (majorVersions.Length == 0)
                {
                    return(result);
                }
                foreach (string majorVersion in majorVersions)
                {
                    int major;
                    if (int.TryParse(majorVersion.Substring(folder.Length + 1), out major))
                    {
                        result.RemoteConfigSections.AddSection(remoteConfigManager.Operation.Condition, major, 0);
                    }
                }
            }
            catch (Exception ex) {
                result.Operation.Result     = false;
                result.Operation.ResultInfo = ex.ToString();
            }
            return(result);
        }
Example #3
0
        private RemoteConfigManagerDTO getMinors(RemoteConfigManagerDTO remoteConfigManager)
        {
            RemoteConfigManagerDTO result = new RemoteConfigManagerDTO();

            try {
                result.Operation.Result = true;

                string folder = ConfigurationManager.AppSettings["publishFolder"];
                folder = Path.Combine(folder, remoteConfigManager.Operation.Condition);
                if (Directory.Exists(folder))
                {
                    string[] minorVersions = Directory.GetFiles(folder);
                    if (minorVersions.Length == 0)
                    {
                        return(result);
                    }
                    foreach (string minorVersion in minorVersions)
                    {
                        string[] strs            = remoteConfigManager.Operation.Condition.Split("\\".ToCharArray());
                        string   sectionName     = strs[0];
                        string   applicationName = strs[1];
                        int      major           = Convert.ToInt32(strs[2]);

                        string fileName = minorVersion.Substring(folder.Length + 1);
                        strs = fileName.Split(".".ToCharArray());
                        int minor;
                        if (int.TryParse(strs[1], out minor))
                        {
                            string downloadUrl = GetDownloadUrl(sectionName, applicationName, major, minor);
                            result.RemoteConfigSections.AddSection(Path.Combine(sectionName, applicationName), major, minor, downloadUrl);
                        }
                    }

                    string logFileName = folder + @"\log.txt";
                    if (File.Exists(logFileName))
                    {
                        FileStream   fs = new FileStream(logFileName, FileMode.Open, FileAccess.Read);
                        StreamReader sr = new StreamReader(fs);
                        result.Operation.Log = Encoding.Default.GetBytes(sr.ReadToEnd());
                        sr.Close();
                        fs.Close();
                    }
                }
            }
            catch (Exception ex) {
                result.Operation.Result     = false;
                result.Operation.ResultInfo = ex.ToString();
            }
            return(result);
        }
Example #4
0
        private RemoteConfigManagerDTO createMinor(RemoteConfigManagerDTO remoteConfigManager)
        {
            RemoteConfigManagerDTO result = new RemoteConfigManagerDTO();

            try {
                result.Operation.Result = true;

                string folder = ConfigurationManager.AppSettings["publishFolder"];
                folder = Path.Combine(folder, remoteConfigManager.Operation.Condition);
                //if (!Directory.Exists(folder))
                //    Directory.CreateDirectory(folder);

                string[] strs            = remoteConfigManager.Operation.Condition.Split("\\".ToCharArray());
                string   sectionName     = strs[0];
                string   applicationName = strs[1];
                int      major           = Convert.ToInt32(strs[2]);

                //string[] minorVersions = Directory.GetFiles(folder);
                //if (minorVersions.Length == 0) {
                //    saveConfig(sectionName, applicationName, major, 1, remoteConfigManager.Operation.Value, remoteConfigManager.Operation.OperatorID);
                //    result.Operation.ResultInfo = GetDownloadUrl(sectionName, applicationName, major, 1);
                //    return result;
                //}

                int maxMinor = GetMaxMinVersion(ref major, strs, ConfigurationManager.AppSettings["publishFolder"]);
                //foreach (string minorVersion in minorVersions) {
                //    string fileName = minorVersion.Substring(folder.Length + 1);
                //    strs = fileName.Split(".".ToCharArray());
                //    int minor;
                //    if (int.TryParse(strs[1], out minor)) {
                //        maxMinor = Math.Max(maxMinor, minor);
                //    }
                //}

                SaveConfig(sectionName, applicationName, major, maxMinor + 1, remoteConfigManager.Operation.Value, remoteConfigManager.Operation.OperatorID);
                result.Operation.ResultInfo = GetDownloadUrl(sectionName, applicationName, major, maxMinor + 1);
                return(result);
            }
            catch (Exception ex) {
                result.Operation.Result     = false;
                result.Operation.ResultInfo = ex.ToString();
            }
            return(result);
        }