private void RenumberIssues()
        {
            var tableIssues = Issues.GetDataByStateCode(StateCode)
                              .OrderBy(r => r.IssueOrder);
            var count = 10;

            foreach (var rowIssue in tableIssues)
            {
                Issues.UpdateIssueOrder(count, rowIssue.IssueKey);
                count += 10;
            }
        }
Exemple #2
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                int  found     = 0;
                int  notFound  = 0;
                bool update    = (bool)e.Argument;
                var  stateCode = StateCodeTextBox.Text.Trim().ToUpperInvariant();
                if (!StateCache.IsValidStateCode(stateCode))
                {
                    throw new VoteException("Invalid state code");
                }
                var table = Issues.GetDataByStateCode(stateCode);
                foreach (var row in table)
                {
                    if (!row.IsIssueOmit)
                    {
                        if (!row.IssueKey.StartsWith("C" + stateCode))
                        {
                            throw new VoteException("Bad IssueKey: " + row.IssueKey);
                        }
                        string tableKey = row.IssueKey.Substring(3);
                        string issueGroupSuffix;
                        if (IssueGroupDictionary.TryGetValue(tableKey, out issueGroupSuffix))
                        {
                            found++;
                        }
                        else
                        {
                            notFound++;
                            AppendStatusText("Key not found: " + row.IssueKey);
                        }
                    }
                }
                AppendStatusText("{0} found, {1} not found", found, notFound);
                if (notFound > 0 || !update)
                {
                    AppendStatusText("Not updated");
                }
                else
                {
                    foreach (var row in table)
                    {
                        if (!row.IsIssueOmit)
                        {
                            string tableKey         = row.IssueKey.Substring(3);
                            string issueGroupSuffix = IssueGroupDictionary[tableKey];
                            IssueGroupsIssues.Insert(
                                issueGroupKey: stateCode + issueGroupSuffix, issueKey: row.IssueKey,
                                issueOrder: 0);
                        }
                    }
                    AppendStatusText("Table updated");
                }
            }
            catch (Exception ex)
            {
                AppendStatusText("Exception: " + ex.Message);
            }

            AppendStatusText("Process is complete.");
        }