public void Add(RidSource rid)
        {
            Dictionary <string, object> data = new Dictionary <string, object>();
            string code = (defaultTable + rid.Name + rid.Type).RemoveNonAlphaNumeric().ToLower();

            data.Add("Name", rid.Name);
            data.Add("Type", rid.Type);
            data.Add("Code", code);
            if (sqlite.IsExist(defaultTable, "Code", code.ToStringType()))
            {
                sqlite.Update(defaultTable, data, "Code", code);
            }
            else
            {
                sqlite.Insert(defaultTable, data);
            }
        }
        public List <RidSource> GetSources()
        {
            DataTable        dt   = sqlite.Select(string.Format(Queries.SELECT_TABLE_DESC, defaultTable, "ID"));
            List <RidSource> srcs = new List <RidSource>();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    RidSource cmd = new RidSource()
                    {
                        ID   = dr["ID"].ToSafeInteger(),
                        Name = dr["Name"].ToSafeString(),
                        Type = dr["Type"].ToSafeString(),
                        Code = dr["Code"].ToSafeString()
                    };
                    srcs.Add(cmd);
                }
            }
            return(srcs);
        }
        private void Action(string tag)
        {
            switch (tag)
            {
            case "NEW_PROF":
                //NewProfile();
                break;

            case "SAVE_PROF":
                SaveProfile();
                break;

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

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

            case "REFRESH":
                InitWorkspace();
                InitHistory(_workspaceTable);
                break;

            case "UNBIND":
                Unbind();
                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 (_workspacse != 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 <Workspace> ws = _workspacse.GetProfiles();
                        if (ws.Count > 0)
                        {
                            foreach (Workspace w in ws)
                            {
                                _history.ClearHistory(w.Name.RemoveNonAlphaNumeric().ToLower());
                            }
                        }
                        _workspacse.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(listLogs);
                    }
                }
                break;

            case "CLEAR_HISTORY":
                if (_selectedWorkspace != 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))
                    {
                        _history.ClearHistory();
                        InitHistory(_selectedWorkspace.Name);
                    }
                }
                break;

            case "SOURCE_EXT":
            case "SOURCE_FOLDER":
                using (SourceForm s = new SourceForm(tag)) {
                    if (s.ShowDialog().Equals(DialogResult.OK))
                    {
                        string    extension = s.SourceName.StartsWith(".") ? s.SourceName : "." + s.SourceName;
                        RidSource rs        = new RidSource()
                        {
                            Name = (tag.Equals("SOURCE_EXT")) ? extension : s.SourceName,
                            Type = (tag.Equals("SOURCE_EXT")) ? "Extension" : "Folder"
                        };
                        _ridSources.Add(rs);
                        _ridSources.Initialize(listViewRids);
                        _listSources = _ridSources.GetSources();
                    }
                }
                break;

            default:
                break;
            }
        }