Exemplo n.º 1
0
        private static void ShowInfo(DBUtils dbu)
        {
            var curVer = dbu.GetCurrentVersion();

            Console.Out.WriteLine("Local backup copies:");
            ICollection <BackupInfo> biColl = new System.Collections.ObjectModel.Collection <BackupInfo>(dbu.GetLocalBackups());

            foreach (var i in biColl.Select(p => p.Version).Distinct())
            {
                Console.Out.WriteLine("\t{0}", i);
            }
            Console.Out.WriteLine("\nCurrently installed:");
            Console.Out.WriteLine("\t{0}", curVer);
        }
Exemplo n.º 2
0
        public static IEnumerable <Uri> getActiveHosts()
        {
            DiscoveryClient discoveryClient =
                new DiscoveryClient(new UdpDiscoveryEndpoint());

            System.Collections.ObjectModel.Collection <EndpointDiscoveryMetadata> cielServices =
                discoveryClient.Find(new FindCriteria(typeof(IExtDataService))
            {
                Duration = TimeSpan.FromSeconds(2)
            }).Endpoints;

            discoveryClient.Close();

            return(cielServices
                   .Select(cs => cs.Address.Uri));
        }
Exemplo n.º 3
0
 void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection <ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
 {
     //do nothing
     Debug.WriteLine(String.Format("IServiceBehavior.AddBindingParameters -- Service name: {0}  namespace: {1}", serviceDescription.Name, serviceDescription.Namespace));
     Debug.WriteLine(String.Concat(endpoints.Select(d => String.Format("Contract: {0} Address: {1}\n", d.Contract, d.Address)).ToArray()));
 }
Exemplo n.º 4
0
        private static void Restore(DBUtils dbu)
        {
            ICollection <BackupInfo> biColl = new System.Collections.ObjectModel.Collection <BackupInfo>(dbu.GetLocalBackups());
            var toVersion = string.Empty;

            if (ArgsDict.Keys.Contains("ver"))
            {
                toVersion = ArgsDict["ver"];
            }
            var tsFilter = string.Empty;

            if (ArgsDict.Keys.Contains("ts"))
            {
                tsFilter = ArgsDict["ts"];
            }
            while (string.IsNullOrEmpty(toVersion))
            {
                Console.Out.WriteLine("Local versions:");
                foreach (var i in biColl.Select(p => p.Version).Distinct())
                {
                    Console.Out.WriteLine("\t{0}", i);
                }
                Console.Out.Write("Enter version to restore (or \"exit\" to exit):");
                var res = Console.ReadLine();
                if (res == "exit")
                {
                    return;
                }
                var bi = biColl.Where(c => c.Version.Equals(res)).FirstOrDefault();
                if (bi != null)
                {
                    toVersion = bi.Version;
                }
            }
            DateTime ts = DateTime.MinValue;
            Dictionary <int, DateTime> tss = new Dictionary <int, DateTime>();
            int num = 0;

            foreach (var bi in biColl.Where(c => c.Version.Equals(toVersion)).OrderByDescending(p => p.Timestamp))
            {
                if (string.IsNullOrWhiteSpace(tsFilter) || bi.Timestamp.ToString(BaseUtils.TimestampFormatString).StartsWith(tsFilter, StringComparison.InvariantCultureIgnoreCase))
                {
                    tss.Add(num++, bi.Timestamp);
                }
            }
            while (ts == DateTime.MinValue)
            {
                Console.Out.WriteLine("Local backups for version {0}:", toVersion);
                foreach (var k in tss.Keys)
                {
                    Console.Out.WriteLine("{0,3:D}\t{1}", k, tss[k]);
                }
                Console.Out.Write("Enter backup number to restore (or \"exit\" to exit):");
                var res = Console.ReadLine();
                if (res == "exit")
                {
                    return;
                }
                num = -1;
                if (int.TryParse(res, out num) && tss.Keys.Contains(num))
                {
                    ts = tss[num];
                }
            }
            if (!dbu.GetCurrentVersion().Equals("none", StringComparison.InvariantCultureIgnoreCase))
            {
                Console.Out.Write("You are going to replace current version \"{0}\" with version \"{1} ({2})\".\nContinue(Y/N)?", dbu.GetCurrentVersion(), toVersion, ts);
                var ans = Console.ReadLine();
                if (ans != "Y" && ans != "y")
                {
                    return;
                }
                Console.Out.Write("Backup current version \"{0}\" before(Y/N)?", dbu.GetCurrentVersion());
                ans = Console.ReadLine();
                if (ans == "Y" || ans == "y")
                {
                    dbu.BackupDBS();
                }
            }
            dbu.RestoreDBS(toVersion, ts);
        }