Exemplo n.º 1
0
        public virtual async Task RecordSave(IEntity entity, SaveMode saveMode)
        {
            if (!LogEventsAttribute.ShouldLog(entity.GetType()))
            {
                return;
            }

            var eventInfo = CreateApplicationEvent();

            if (eventInfo == null)
            {
                return;
            }

            eventInfo.ItemType = entity.GetType().FullName;
            eventInfo.ItemKey  = entity.GetId().ToString();
            eventInfo.Event    = saveMode.ToString();
            eventInfo.IP       = GetCurrentUserIP();
            eventInfo.UserId   = GetCurrentUserId();

            if (saveMode == SaveMode.Update)
            {
                var changes = await GetChangesXml(entity);

                if (changes.IsEmpty()) // No changes have happened, ignore recording the action:
                {
                    return;
                }

                eventInfo.Data = changes;
            }
            else
            {
                if (!ShouldSkipInsertData)
                {
                    eventInfo.Data = GetDataXml(entity);
                }
            }

            if (OnRecordingSave.IsHandled())
            {
                var args = new AuditSaveEventArgs
                {
                    SaveMode         = saveMode,
                    ApplicationEvent = eventInfo,
                    Entity           = entity
                };

                await OnRecordingSave.Raise(args);

                if (args.Cancel)
                {
                    return;
                }
            }

            await Save(eventInfo);

            ProcessContext <UndoContext> .Current.Perform(c => c.Append(eventInfo, entity));
        }
 public void Write(Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp)
 {
     webApp
     .Update()
     .WithAppSetting("Aggregator_VstsTokenType", DevOpsTokenType.ToString())
     .WithAppSetting("Aggregator_VstsToken", DevOpsToken)
     .WithAppSetting("Aggregator_SaveMode", SaveMode.ToString())
     .Apply();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the string for the value of SaveMode
        /// </summary>
        /// <param name="mode">The given SaveMode</param>
        /// <returns>The string that represents the given SaveMode</returns>
        public static string GetStringValue(this SaveMode mode)
        {
            switch (mode)
            {
            case SaveMode.ErrorIfExists:
                return("error");

            default:
                return(mode.ToString());
            }
        }
        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveFileButtonAsync_Click(object sender, RoutedEventArgs e)
        {
            /*
             * 把 DrawRectangleColor(_model?.GroupDateTimesByTotal()) 写进下面两个 Save 异步方法
             * 可以避免用户触发 CloseButtonClick 事件时对方块颜色重新渲染
             */
            async void saveDialog_PrimaryButtonClick(ContentDialog dialog, ContentDialogButtonClickEventArgs args)
            {
                await SaveOrginalFileAsync();
            }

            async void saveDialog_SecondaryButtonClickAsync(ContentDialog dialog, ContentDialogButtonClickEventArgs args)
            {
                await SaveNewFileAsync();
            }

            void saveDialog_CloseButtonClick(ContentDialog dialog, ContentDialogButtonClickEventArgs args)
            {
                dialog.Hide();
            }

            // 在弹出路径选择器之前应渲染一个悬浮表单,让用户选择
            // 保存方式、文件格式、文件名
            // 给用户提供两种保存方式:
            // 1、更新原有文件
            // 2、作为新文件存储
            switch (_saveMode)
            {
            case SaveMode.NewFile:
                await SaveNewFileAsync();

                _saveMode = SaveMode.OrginalFile;
                break;

            case SaveMode.OrginalFile:
                ContentDialog saveDialog = new ContentDialog()
                {
                    Title               = "SaveMode",
                    Content             = "选择一种保存方式:",
                    PrimaryButtonText   = "更新原有文件",
                    SecondaryButtonText = "作为新文件存储",
                    CloseButtonText     = "放弃更改"
                };
                saveDialog.PrimaryButtonClick   += saveDialog_PrimaryButtonClick;
                saveDialog.SecondaryButtonClick += saveDialog_SecondaryButtonClickAsync;
                saveDialog.CloseButtonClick     += saveDialog_CloseButtonClick;
                await saveDialog.ShowAsync();

                break;

            default:
                throw new InvalidOperationException($"Unknown Error. SaveMode = {_saveMode.ToString()}");
            }
        }
Exemplo n.º 5
0
 private void SetMode(SaveMode mode)
 {
     _mode = mode;
     _changeModeButton.Text = _mode == SaveMode.Save ? "Load" : "Save";
     _headerText.Text       = $"{mode.ToString()} Game";
 }
Exemplo n.º 6
0
 public string GetEncodedFileExtension(PredictorSettings predictorSettings, SaveMode saveMode)
 {
     return($"k{predictorSettings.AcceptedError}p{predictorSettings.Predictor.Code}{saveMode.ToString()}.nlp");
 }
        private Model.SaveMode FromFSharp(SaveMode saveMode)
        {
            switch (saveMode.Tag)
            {
            case SaveMode.Tags.Body:
                return(Model.SaveMode.Body);

                break;

            case SaveMode.Tags.Nothing:
                return(Model.SaveMode.Nothing);

                break;

            case SaveMode.Tags.Message:
                return(Model.SaveMode.Message);

                break;

            case SaveMode.Tags.Stream:
                return(Model.SaveMode.Stream);

                break;

            default:
                throw new InvalidOperationException(string.Format("Unknown save mode %s", saveMode.ToString()));
                break;
            }
        }