protected virtual void AfterSaveCompleted(TDraft savedRecord)
 {
     SaveCompleted?.Invoke(this, savedRecord);
     ClearDraftAfterSave();
     StopBeingBusy();
     ReturnDialogResult(true);
 }
示例#2
0
        protected void Save(object sender, AjaxFileUploadEventArgs e)
        {
            string fullPath = Path.Combine(Server.MapPath("~/" + Folder + "/"), e.FileName);

            fileupload.SaveAs(fullPath);

            SaveCompleted?.Invoke(null, fullPath);
        }
示例#3
0
        public void Save()
        {
            IContractEditor edit = this.Editor as IContractEditor;

            edit.Save();

            if (SaveCompleted != null)
            {
                SaveCompleted.Invoke(this, EventArgs.Empty);
            }
        }
示例#4
0
        private async Task ExecuteUpdateRecord()
        {
            if (!CanSave())
            {
                return;
            }
            StartBeingBusy($"Updating ‹{TypeDescription}› record ...");

            UpdateRecord(Draft);
            await UpdateRecordAsync(Draft);

            RecordUpdated?.Invoke(this, Draft);
            SaveCompleted?.Invoke(this, EventArgs.Empty);

            StopBeingBusy();
            ReturnDialogResult(true);
        }
示例#5
0
        private async Task ExecuteSaveDraft()
        {
            if (!CanSave())
            {
                return;
            }
            StartBeingBusy($"Saving new ‹{TypeDescription}› record ...");

            SaveNewRecord(Draft);
            await SaveNewRecordAsync(Draft);

            NewRecordSaved?.Invoke(this, Draft);
            SaveCompleted?.Invoke(this, EventArgs.Empty);

            StopBeingBusy();
            ReturnDialogResult(true);
        }
示例#6
0
        public async Task SaveChangesAsync()
        {
            _saving = true;
            List <ChatMessageDto> temp;

            lock (_syncRoot)
            {
                temp             = _pendingMessages;
                _pendingMessages = new List <ChatMessageDto>();
            }
            var context = new MessagesContext();

            context.Configuration.AutoDetectChangesEnabled = false;
            context.Configuration.ValidateOnSaveEnabled    = false;
            // ReSharper disable once AccessToDisposedClosure
            await Task.Run(() => { context.BulkInsert(temp); });

            context.Dispose();
            SaveCompleted.Invoke(this, DateTime.Now);
            _saving = false;
        }
示例#7
0
        public void Save(SaveData data)
        {
            SaveAsync();


            async void SaveAsync()
            {
                SaveBegin?.Invoke();

                try
                {
                    if (!HasSave())
                    {
                        if (!Directory.Exists(SaveDirectory))
                        {
                            Directory.CreateDirectory(SaveDirectory);
                        }

                        File.Create(SaveFileName).Close();
                    }

                    using (var stw = new StreamWriter(SaveFileName))
                    {
                        var json = JsonUtility.ToJson(data);

                        await stw.WriteLineAsync(json);
                    }
                }
                catch (Exception ex)
                {
                    // LOG?
                }

                SaveCompleted?.Invoke();
            }
        }
示例#8
0
 protected virtual void OnSaveCompleted()
 {
     SaveCompleted?.Invoke();
 }
示例#9
0
 private void OnSaveCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     SaveCompleted?.Invoke(this, new AsyncCompletedEventArgs(e.Error, e.Cancelled, null));
 }
示例#10
0
        /// <summary>
        /// This method will save the song and its settings to a file at the "path" variable's destination
        /// </summary>
        public static void SaveSong(string path)
        {
            StreamWriter sw = new StreamWriter(path);

            sw.WriteLine(Version);
            sw.WriteLine("DELAYS");
            sw.WriteLine(Delays.Count);
            if (Delays.Count != 0)
            {
                foreach (Delay delay in Delays)
                {
                    sw.WriteLine(delay.Character);
                    sw.WriteLine(delay.Time);
                }
            }
            sw.WriteLine("CUSTOM NOTES");
            sw.WriteLine(CustomNotes.Count);
            if (CustomNotes.Count != 0)
            {
                foreach (KeyValuePair <Note, Note> note in CustomNotes)
                {
                    sw.WriteLine(note.Value.Character);
                    sw.WriteLine(note.Key.Character);
                }
            }
            sw.WriteLine("SPEEDS");
            sw.WriteLine(DelayAtNormalSpeed);
            sw.WriteLine(DelayAtFastSpeed);
            sw.WriteLine("NOTES");
            sw.WriteLine(Song.Count);
            if (Song.Count != 0)
            {
                foreach (INote note in Song)
                {
                    if (note is DelayNote)
                    {
                        sw.Write(((DelayNote)note).Character);
                    }
                    else if (note is SpeedChangeNote)
                    {
                        if (((SpeedChangeNote)note).TurnOnFast)
                        {
                            sw.Write("{");
                        }
                        else
                        {
                            sw.Write("}");
                        }
                    }
                    else if (note is Note)
                    {
                        sw.Write(((Note)note).Character);
                    }
                    else if (note is MultiNote)
                    {
                        sw.Write("[");
                        foreach (Note multiNote in ((MultiNote)note).Notes)
                        {
                            sw.Write(multiNote.Character);
                        }
                        sw.Write("]");
                    }
                }
            }
            sw.Dispose();
            sw.Close();
            SaveCompleted?.Invoke();
        }
示例#11
0
 private void OnSaveCompleted(IElementTreeNode saved) => SaveCompleted?.Invoke(saved);
 /// <summary>
 /// Launches the event of save complete
 /// </summary>
 protected virtual void CompleteSave()
 {
     SaveCompleted?.Invoke(this, null);
 }
示例#13
0
 protected virtual void OnSaveCompleted(EventArgs e)
 {
     SaveCompleted?.Invoke(this, e);
 }