コード例 #1
0
        /// <summary>
        /// エンドポイント
        /// </summary>
        /// <param name="args">引数</param>
        static void Main(string[] args)
        {
            // ログ出力用メソッド名
            string methodName = MethodBase.GetCurrentMethod().Name;

            // 開始ログ
            Log.Write(methodName, "PnPバッチ開始");

            try
            {
                // 引数解析
                AppArgs appArgs = new AppArgs(args);
                Log.Write(methodName, appArgs.LogMsg.ToArray());

                // 処理
                if (appArgs.Retrived)
                {
                    // サイト情報
                    var site = new SiteConnectionInfo(appArgs.SiteUrl, appArgs.Account, appArgs.Password);

                    // 保存先
                    var template = new FileSystemConnectionInfo(appArgs.FolderPath, appArgs.FileName);

                    // 進捗報告
                    var progress = new Progress <string>((log) => { Log.Write(methodName, log); });

                    // 実行
                    var task = (appArgs.Mode == AppArgs.MODE.GET)? PnPUtility.SaveSiteAsProvisioningTemplateAsync(site, template, progress) : PnPUtility.ApplyProvisioningTemplateAsync(site, template, progress);
                    task.ConfigureAwait(false);
                    task.Wait();
                }
            }
            catch (Exception ex)
            {
                var message = (ex.InnerException != null) ? ex.InnerException : ex;
                Log.Write(methodName, message);
            }

            // 終了ログ
            Log.Write(methodName, "PnPバッチ終了");
        }
コード例 #2
0
        /// <summary>
        /// 検索実行
        /// </summary>
        private async Task DoSearch(Dispatcher d)
        {
            try
            {
                // テンプレートを選択
                var dialog = new OpenFileDialog()
                {
                    Title       = "テンプレートファイルの選択",
                    Multiselect = false,
                    Filter      = $"XML(*.xml)|*.xml"
                };

                // 取得を実行
                if (dialog.ShowDialog() == true)
                {
                    // ログタブに切り替え
                    await d.Execute(() => { _vm.LogTabSelected = true; }, true).ConfigureAwait(false);

                    // サイト情報
                    var site = new SiteConnectionInfo(_vm.SelectedSite.URL, _vm.Tenant.UserAccount, _vm.Tenant.UserPassword);

                    // テンプレート
                    var template = new FileSystemConnectionInfo(Path.GetDirectoryName(dialog.FileName), Path.GetFileName(dialog.FileName));

                    // ログ
                    var progress = new Progress <string>(WriteLog);

                    // テンプレート適用
                    var   task = PnPUtility.ApplyProvisioningTemplateAsync(site, template, progress);
                    await task;

                    if (task.Exception == null)
                    {
                        // テンプレート取得終了
                        await d.Execute(() => {
                            _vm.IsApplying = false;
                        }, true).ConfigureAwait(false);
                    }
                    else
                    {
                        // テンプレート取得終了
                        await d.Execute(() => { _vm.IsApplying = false; }, true).ConfigureAwait(false);

                        MessageBox.Show($"テンプレート取得に失敗しました。\r\n{ task.Exception.InnerException?.Message?.ToString() }");
                    }
                }
                else
                {
                    // テンプレート取得終了
                    await d.Execute(() => { _vm.IsApplying = false; }, true).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                // テンプレート取得終了
                await d.Execute(() => { _vm.IsApplying = false; }, true).ConfigureAwait(false);

                var message = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message;
                MessageBox.Show($"テンプレート取得に失敗しました。\r\n{ message }");
            }
        }