示例#1
0
        Task <NormalResult> Replication(CancellationToken token)
        {
            return(Task <NormalResult> .Run(() =>
            {
                Replication replication = new Replication();
                LibraryChannel channel = this.GetChannel();
                try
                {
                    int nRet = replication.Initialize(channel,
                                                      out string strError);
                    if (nRet == -1)
                    {
                        return new NormalResult
                        {
                            Value = -1,
                            ErrorInfo = strError
                        }
                    }
                    ;

                    nRet = replication.BuildFirstPlan("*",
                                                      channel,
                                                      (message) =>
                    {
                        OutputHistory(message);
                    },
                                                      out XmlDocument task_dom,
                                                      out strError);
                    _taskDom = task_dom;
                    if (nRet == -1)
                    {
                        return new NormalResult
                        {
                            Value = -1,
                            ErrorInfo = strError
                        }
                    }
                    ;

                    DatabaseConfig.ServerName = "localhost";
                    DatabaseConfig.DatabaseName = "testrep";
                    DatabaseConfig.UserName = "******";
                    DatabaseConfig.Password = "******";

                    nRet = replication.RunFirstPlan(
                        channel,
                        ref task_dom,
                        (message) =>
                    {
                        OutputHistory(message);
                    },
                        token,
                        out strError);
                    if (nRet == -1)
                    {
                        return new NormalResult
                        {
                            Value = -1,
                            ErrorInfo = strError
                        }
                    }
                    ;

                    return new NormalResult();
                }
                finally
                {
                    this.ReturnChannel(channel);
                }
            }));
        }