Пример #1
0
        protected async ValueTask Archive(bool force = false)
        {
            if (Snapshot.Base.Version != Snapshot.Base.DoingVersion)
            {
                throw new StateInsecurityException(Snapshot.Base.StateId.ToString(), GrainType, Snapshot.Base.DoingVersion, Snapshot.Base.Version);
            }
            if (force || NewArchive.IsCompletedArchive(ArchiveOptions, LastArchive))
            {
                var task = OnStartArchive();
                if (!task.IsCompletedSuccessfully)
                {
                    await task;
                }
                await ArchiveStorage.Insert(NewArchive, Snapshot);

                BriefArchiveList.Add(NewArchive);
                LastArchive = NewArchive;
                NewArchive  = default;
                var onTask = OnArchiveCompleted();
                if (!onTask.IsCompletedSuccessfully)
                {
                    await onTask;
                }
            }
        }
Пример #2
0
    private NewArchive GetData(SQLiteDataReader reader, string tbl)
    {
        NewArchive x = new NewArchive();

        switch (tbl)
        {
        case "clients":
            x.id = reader.GetValue(0) == DBNull.Value ? null : reader.GetString(0);
            string firstName = reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1);
            string lastName  = reader.GetValue(2) == DBNull.Value ? null : reader.GetString(2);
            x.title = string.Format("{0} {1}", firstName, lastName);
            x.date  = reader.GetValue(3) == DBNull.Value ? DateTime.Today.ToString() : reader.GetString(3);
            break;

        case "menus":
        case "weeklymenus":
            x.id    = reader.GetValue(0) == DBNull.Value ? null : reader.GetString(0);
            x.title = reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1);
            x.date  = reader.GetValue(2) == DBNull.Value ? DateTime.UtcNow.ToString() : reader.GetString(2);
            break;

        case "recipes":
        case "foods":
            x.id    = reader.GetValue(0) == DBNull.Value ? null : reader.GetString(0);
            x.title = reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1);
            break;

        case "appointments":
            x.id    = reader.GetValue(0) == DBNull.Value ? null : Convert.ToString(reader.GetInt32(0));
            x.title = reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1);
            x.date  = reader.GetValue(2) == DBNull.Value ? DateTime.UtcNow.ToString() : Convert.ToString(reader.GetInt64(2));
            break;

        default:
            break;
        }
        return(x);
    }
        private void Action(string tag)
        {
            switch (tag)
            {
            case "NEW_PROF":
                //NewProfile();
                break;

            case "CREATE_ENV":
                using (NewEnvForm env = new NewEnvForm()) {
                    if (env.ShowDialog().Equals(DialogResult.OK))
                    {
                        // Check if exist name

                        if (_envVariables.SetEnvironmentVariable(env.EnvName, env.EnvValue))
                        {
                            using (RestartForm r = new RestartForm(env.EnvName, tag)) {
                                if (r.ShowDialog().Equals(DialogResult.OK))
                                {
                                    Application.Restart();
                                }
                                else
                                {
                                    InitEnvironmentVariables();
                                }
                            }
                        }
                    }
                }
                break;

            case "ENV_UPDATE":
                DialogResult resu = MessageBox.Show(string.Format("Are you sure you want to update {0} in environment variable?", txtEnvName.Text), "Update Environment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (resu.Equals(DialogResult.Yes))
                {
                    if (_envVariables.SetEnvironmentVariable(txtEnvName.Text, txtEnvValue.Text))
                    {
                        using (RestartForm r = new RestartForm(txtEnvName.Text, tag)) {
                            if (r.ShowDialog().Equals(DialogResult.OK))
                            {
                                InitEnvironmentVariables();
                            }
                        }
                    }
                }
                break;

            case "ENV_DELETE":
                DialogResult resd = MessageBox.Show(string.Format("Are you sure you want to delete {0} in environment variable?", txtEnvName.Text), "Delete Environment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (resd.Equals(DialogResult.Yes))
                {
                    if (_envVariables.DeleteEnvironmentVariable(txtEnvName.Text))
                    {
                        using (RestartForm r = new RestartForm(txtEnvName.Text, tag)) {
                            if (r.ShowDialog().Equals(DialogResult.OK))
                            {
                                InitEnvironmentVariables();
                            }
                        }
                    }
                }
                break;

            case "FIND":
                break;

            case "SAVE":
                if (_isLoading)
                {
                    return;
                }
                using (NewArchive na = new NewArchive()) {
                    if (na.ShowDialog().Equals(DialogResult.OK))
                    {
                    }
                }
                break;

            case "ADD_FILE":
                AddFiles(AddFile.FILES);
                break;

            case "ADD_FOLDER":
                AddFiles(AddFile.FOLDER);
                break;

            case "REFRESH":
                InitWorkspace();
                break;

            case "SERVER_CONFIG":
            case "OPTIONS":
                using (ConfigServerForm config = new ConfigServerForm(tag.Equals("SERVER_CONFIG") ? 1 : 0)) {
                    if (config.ShowDialog().Equals(DialogResult.OK))
                    {
                        InitSettings();
                    }
                }
                break;

            case "EXIT":
                Close();
                break;

            case "ABOUT":
                using (AboutForm about = new AboutForm()) {
                    about.ShowDialog();
                }
                break;

            case "HELP":
                using (HelpForm help = new HelpForm()) {
                    help.ShowDialog();
                }
                break;

            case "TOOLBAR":
                RegConfig.Set <bool>("Toolbar", hideToolbarToolStripMenuItem.Checked);
                toolStripUploader.Visible = hideToolbarToolStripMenuItem.Checked;
                break;

            case "STATUSBAR":
                RegConfig.Set <bool>("Statusbar", hideStatusbarToolStripMenuItem.Checked);
                statusStripUploader.Visible = hideStatusbarToolStripMenuItem.Checked;
                break;

            case "PROFILE_DETAILS":
                break;

            case "PROFILE_EXPLORER":
                RegConfig.Set <bool>("ProfileExplorer", profileExplorerToolStripMenuItem.Checked);
                splitContainer1.Panel1Collapsed = !profileExplorerToolStripMenuItem.Checked;
                break;

            case "LOGS":
                RegConfig.Set <bool>("Logs&Details", logsToolStripMenuItem.Checked);
                splitContainer2.Panel2Collapsed = !logsToolStripMenuItem.Checked;
                break;

            case "CLEAR_WORKSPACE":
                if (_archives != null)
                {
                    if (MessageBox.Show("Workspace will be deleted permanently!\nAre you sure you want to clear all workspace?", "Clear Workspace", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                        List <Archive> ws = _archives.GetProfiles();
                        if (ws.Count > 0)
                        {
                            foreach (Archive w in ws)
                            {
                            }
                        }
                        _archives.ClearWorkspaces();
                        InitWorkspace();
                    }
                }
                break;

            case "CLEAR_LOGS":
                if (_logs != null)
                {
                    if (MessageBox.Show("Logs will be deleted permanently!\nAre you sure you want to clear all logs?", "Clear Logs", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                        _logs.ClearAllLog();
                        _logs.Initialize(logsListBox);
                    }
                }
                break;

            case "CLEAR_HISTORY":
                if (_selectedArchive != null)
                {
                    if (MessageBox.Show("History will be deleted permanently!\nAre you sure you want to clear all history?", "Clear History", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                    }
                }
                break;

            case "SOURCE_EXT":
            case "SOURCE_FOLDER":

                break;

            default:
                break;
            }
        }