public double Ratio(DisconnectedImportEntity orientative)
        {
            double total = orientative.Total !.Value;

            double result = 0;

            if ((RestoreDatabase.HasValue || SynchronizeSchema.HasValue) && orientative.RestoreDatabase.HasValue) //Optional
            {
                result += (orientative.RestoreDatabase.Value) / total;
            }

            if (!SynchronizeSchema.HasValue)
            {
                return(result);
            }
            result += (orientative.SynchronizeSchema !.Value) / total;

            if (!DisableForeignKeys.HasValue)
            {
                return(result);
            }
            result += (orientative.DisableForeignKeys !.Value) / total;

            result += Copies.Where(c => c.CopyTable.HasValue).Join(
                orientative.Copies.Where(o => o.CopyTable.HasValue && o.CopyTable.Value > 0),
                c => c.Type, o => o.Type, (c, o) => o.CopyTable !.Value / total).Sum();

            if (!Copies.All(a => a.CopyTable.HasValue))
            {
                return(result);
            }

            if (!Unlock.HasValue)
            {
                return(result);
            }
            result += (orientative.Unlock !.Value) / total;

            if (!EnableForeignKeys.HasValue)
            {
                return(result);
            }
            result += (orientative.EnableForeignKeys !.Value) / total;

            if (!DropDatabase.HasValue)
            {
                return(result);
            }
            result += (orientative.DropDatabase !.Value) / total;

            return(result);
        }
        void DownloadDatabase_Loaded(object sender, RoutedEventArgs e)
        {
            estimation = Server.Return((IDisconnectedServer ds) => ds.GetUploadEstimation(DisconnectedMachineEntity.Current));

            UploadDatabase().ContinueWith(cl =>
            {
                pbUploading.Dispatcher.BeginInvoke(() =>
                {
                    currentLite = cl.Result;

                    pbImporting.Minimum = 0;
                    pbImporting.Maximum = 1;

                    timer.Tick += new EventHandler(timer_Tick);

                    timer.Interval = TimeSpan.FromSeconds(1);

                    timer.Start();
                });
            });
        }
        public double Ratio(DisconnectedImportEntity orientative)
        {
            double total = orientative.Total.Value;

            double result = 0;

            if ((RestoreDatabase.HasValue || SynchronizeSchema.HasValue) && orientative.RestoreDatabase.HasValue) //Optional
                result += (orientative.RestoreDatabase.Value) / total;

            if (!SynchronizeSchema.HasValue)
                return result;
            result += (orientative.SynchronizeSchema.Value) / total;

            if (!DisableForeignKeys.HasValue)
                return result;
            result += (orientative.DisableForeignKeys.Value) / total;

            result += Copies.Where(c => c.CopyTable.HasValue).Join(
                orientative.Copies.Where(o => o.CopyTable.HasValue && o.CopyTable.Value > 0),
                c => c.Type, o => o.Type, (c, o) => o.CopyTable.Value / total).Sum();

            if (!Copies.All(a => a.CopyTable.HasValue))
                return result;

            if (!Unlock.HasValue)
                return result;
            result += (orientative.Unlock.Value) / total;

            if (!EnableForeignKeys.HasValue)
                return result;
            result += (orientative.EnableForeignKeys.Value) / total;

            if (!DropDatabase.HasValue)
                return result;
            result += (orientative.DropDatabase.Value) / total;

            return result;
        }