예제 #1
0
        void Publish(PublishType publishType)
        {
            try
            {
                // This indicates the name and version of the software used for publishing.
                var pluginName = "C# Publisher Sample";
                //var pluginName = "YanaiTest_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
                var pluginVersion = Assembly.GetExecutingAssembly().GetName().Version;

                // Display the project selection external window and return when the project selection has ended (whether it succeeded or not).
                var settings = WindowFactory.ShowPublisherSettings(pluginName, pluginVersion, publishType);

                // If the user cancels (or in a few other cases), we don't want to export data.
                if (settings != null)
                {
                    Logger.Info($"Logged in as {settings.User.DisplayName}");
                    Logger.Info($"Target project : {settings.TargetProject.Name}");
                    Logger.Info($"Target sync server : {settings.TargetProject.Host.ServerName}");

                    // Let's customize the settings before opening the client
                    CustomizePublisherSettings(settings);

                    // This is the public name of the Source Project you want to export (it doesn't have to be unique).
                    var sourceName = "C# Sample Quad";
                    //var sourceName = "SourceName-YanaiTest_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");

                    // This identifies the Source Project you want to export and must be unique and persistent over multiple publishing sessions.
                    var sourceId = "internal guid";
                    //var sourceId = DateTime.Now.ToString("yyyyMMdd_HHmmss");

                    // Create a Publisher Client, that will allow us to publish data into the selected Target Project.
                    m_PublisherClient = Publisher.OpenClient(sourceName, sourceId, settings);

                    if (publishType == PublishType.Export)
                    {
                        // Simple export flow.
                        PerformExportTransaction();

                        // Properly close the connection to the SyncServer.
                        m_PublisherClient.CloseAndWait();
                    }
                    else if (publishType == PublishType.ExportAndSync)
                    {
                        // Sync flow (first export + sync updates).
                        PerformExportTransaction();
                        PerformSyncUpdates();
                    }
                }
                else
                {
                    Logger.Warn("No project selected.");
                }
            }
            catch (Exception e)
            {
                Logger.Error(e.ToString());
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Please provide a path for the file to write.");
                return;
            }

            var filePath = args[0];
            var settings = WindowFactory.ShowPublisherSettings("ConfigFileCreator", new Version(), PublishType.Export);

            settings.WriteToFile(filePath);
        }