Example #1
0
        private void btnDownloadMap_Click(object sender, EventArgs e)
        {
            lblMapTip.Text = "";
            if (string.IsNullOrWhiteSpace(comboBoxMap.Text))
            {
                MessageBox.Show("选一个角色");
                return;
            }

            var    executableFileInfo      = new FileInfo(Application.ExecutablePath);
            string executableDirectoryName = executableFileInfo.DirectoryName;

            if (!OraData.GetFileFromDB(1, comboBoxMap.Text, executableDirectoryName + "\\FlyingProfiles"))
            {
                MessageBox.Show("下载失败,看主界面提示信息");
                return;
            }
            lblMapTip.Text = "下载失败";
        }
Example #2
0
        private void btnUploadMap_Click(object sender, EventArgs e)
        {
            lblMapTip.Text = "";
            if (string.IsNullOrWhiteSpace(comboBoxMap.Text))
            {
                MessageBox.Show("选一个角色");
                return;
            }

            if (string.IsNullOrWhiteSpace(txtMapFile.Text))
            {
                MessageBox.Show("选择上传文件");
                return;
            }

            if (!OraData.SaveFileToDB(1, comboBoxMap.Text, txtMapFile.Text))
            {
                MessageBox.Show("上传失败,看主界面提示信息");
                return;
            }
            lblMapTip.Text = "上传成功";
        }
Example #3
0
        // used by both delimited-text and grid-export...
        private void ReportDelimitedText(Database.Query query, ResultFormat format, Notepad pad)
        {
            bool outputQuery = UserOptions.GetBoolean("results/general/outputQuery");
            bool printHeader = UserOptions.GetBoolean("results/general/printHeader");

            StringBuilder sult      = new StringBuilder();
            StringBuilder line      = new StringBuilder();
            string        delimiter = ",";

            switch (format)
            {
            case ResultFormat.CommaDelimited:
                delimiter = ",";
                break;

            case ResultFormat.TabDelimited:
                delimiter = new String((char)0x09, 1);
                break;

            case ResultFormat.SpaceDelimited:
                delimiter = " ";
                break;

            case ResultFormat.CustomDelimited:
                delimiter = UserOptions.GetString("results/general/delimiter");
                break;
            }

            if (outputQuery)
            {
                PrintQueryBox(query.SQL, pad);
            }

            OraData data = query.Data;

            foreach (OraTable table in data)
            {
                if (printHeader && (table.Count > 0))
                {
                    for (int i = 0; i < table.FieldCount; i++)
                    {
                        if (i > 0)
                        {
                            line.Append(delimiter);
                        }
                        line.Append(table.Schema[i].ColumnName);
                    }

                    sult.Append(line.ToString() + CR);
                }

                foreach (OraRow row in table)
                {
                    line.Length = 0;

                    for (int i = 0; i < table.FieldCount; i++)
                    {
                        if (i > 0)
                        {
                            line.Append(delimiter);
                        }
                        if (row[i] != null)
                        {
                            line.Append(row[i].ToString());
                        }
                    }

                    sult.Append(line.ToString() + CR);
                }

                pad.Write(sult.ToString());
                pad.WriteNote(CR + "(" + query.AffectedRecords + " row(s) affected)");
            }
        }
Example #4
0
        private void ReportText(Database.Query query, Notepad pad)
        {
            bool outputQuery   = UserOptions.GetBoolean("results/general/outputQuery");
            bool printHeader   = UserOptions.GetBoolean("results/general/printHeader");
            bool rightAlign    = UserOptions.GetBoolean("results/general/rightAlign");
            bool cleanNewlines = UserOptions.GetBoolean("results/general/cleanNewlines");
            bool ratype        = rightAlign;
            int  totalRows     = 0;

            OraData data = query.Data;

            var    line = new StringBuilder();
            string text;

            if (resultCount > 0)
            {
                var color = pad.ForeColor;
                pad.ForeColor = Color.FromArgb(0x6E96BE);                 // "Number-style" blue
                pad.WriteLine(CR + new String((char)0x2550, 100) + CR);
                pad.ForeColor = color;
            }

            if (outputQuery)
            {
                PrintQueryBox(query.SQL, pad);
            }

            if (query.HasOutputs)
            {
                PrintOutputParameters(query, pad);
            }

            for (int t = 0; t < data.Count; t++)
            {
                OraTable table = data[t];

                if (t > 0)
                {
                    var color = pad.ForeColor;
                    pad.ForeColor = Color.FromArgb(0x6E96BE);                     // "Number-style" blue
                    pad.WriteLine(CR + new String((char)0x2550, 100));
                    pad.ForeColor = color;
                }

                int[] widths = null;
                if (table.Count > 0)
                {
                    widths = MeasureColumns(table);

                    if (printHeader)
                    {
                        BuildTextHeader(table, widths, pad);
                    }

                    foreach (OraRow row in table)
                    {
                        line = new StringBuilder();

                        for (int i = 0; i < table.FieldCount; i++)
                        {
                            if (i > 0)
                            {
                                line.Append(" ");
                            }

                            if (row[i] == null)
                            {
                                text = "...";
                            }
                            else if (table.Schema[i].DataType == typeof(Byte[]))
                            {
                                if (row[i].GetType() == typeof(DBNull))
                                {
                                    text = String.Empty;
                                }
                                else
                                {
                                    Byte[] bytes = (Byte[])row[i];
                                    text = String.Join(
                                        String.Empty,
                                        bytes.Select(b => b.ToString("X2")).ToArray());
                                }
                            }
                            else
                            {
                                text = row[i].ToString();
                            }

                            if (cleanNewlines)
                            {
                                text = text.Replace("\n", String.Empty).Replace("\r", String.Empty);
                            }

                            if (text.Length > widths[i])
                            {
                                line.Append(text.Substring(0, widths[i]));
                            }
                            else
                            {
                                if (rightAlign)
                                {
                                    TypeCode code = Type.GetTypeCode(row[i].GetType());
                                    ratype = ((code != TypeCode.Boolean) &&
                                              (code != TypeCode.Char) &&
                                              (code != TypeCode.String));
                                }

                                if (ratype)
                                {
                                    line.Append(new String(' ', widths[i] - text.Length) + text);
                                }
                                else
                                {
                                    line.Append(text + new String(' ', widths[i] - text.Length));
                                }
                            }
                        }

                        pad.WriteLine(line.ToString());
                    }
                }

                pad.WriteLine();
                pad.WriteNote(String.Format(RxRowsAffected, table.Count));

                totalRows += table.Count;
            }

            if (data.Count == 0)
            {
                totalRows = query.AffectedRecords;
            }

            if (data.Count != 1)
            {
                string msg;
                if (totalRows < 0)
                {
                    msg = RxCompleted;
                }
                else
                {
                    msg = String.Format(RxTotalRowsAffected, totalRows);
                }

                pad.WriteNote(CR + msg);
            }
        }