Beispiel #1
0
        //private void triggerGarbageCollectorToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    GC.Collect();
        //}

        private void FindOwningFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode.GetType() != typeof(Json_TN))
            {
                MessageBox.Show("Wasn't a Json_TN");
                return;
            }

            Json_TN node = (Json_TN)treeView1.SelectedNode;

            if (HellionExplorerProgram.docCurrent != null && node != null)
            {
                Json_File file = HellionExplorerProgram.docCurrent.GameData.FindOwningFile(node);

                if (file != null)
                {
                    MessageBox.Show(string.Format("TreeNode {0} is owned by file {1}.", node.FullPath, file.File.FullName));
                }
                else
                {
                    MessageBox.Show("No result found.");
                }
            }
            else
            {
                MessageBox.Show("No open document or selected TreeNode was null.");
            }
        }
Beispiel #2
0
        public tableinfo Post([FromBody] tablename req)
        {
            tableinfo resp = new tableinfo();

            try
            {
                //从配置文件中读取字符串
                Json_File _Json_File    = new Json_File();
                var       configuration = _Json_File.Read_Json_File();
                string    connString    = configuration["conn"];

                MySqlConnection conn = new MySqlConnection(connString);
                using (MySqlCommand cmd = new MySqlCommand())//创建查询命令
                {
                    string sql = "select * from " + req.table;

                    cmd.Connection  = conn;
                    cmd.CommandText = sql;
                    //cmd.Parameters.Add(new MySqlParameter("@tablename",req.table));表名不能进行参数化查询
                    MySqlDataAdapter  reader = new MySqlDataAdapter(cmd); //创建一个执行命令的适配器对象
                    DataSet           ds     = new DataSet();             //相当于建立一个基于前台的虚拟数据库
                    DataTable         dtable;                             //相当于数据库中的一张数据表
                    DataRowCollection coldrow;                            //相当于表中行的集合
                    DataRow           drow;                               //相当于一行中列的数据集合
                    reader.Fill(ds, "ds");                                //将查询的结果存储到虚拟数据库ds的虚拟表student中
                    dtable  = ds.Tables["ds"];                            //将数据表student的数据复制到DataTable对象(取库中的一张数据表)
                    coldrow = dtable.Rows;                                //获取数据表中的所有行
                    int len = coldrow[0].ItemArray.Length;                //获取一行有多少字段

                    resp.countofcolumns = len;                            //数据表列数
                    resp.countofrows    = coldrow.Count;                  //数据表行数

                    resp.tableheader = new string[0];
                    for (int i = 0; i < dtable.Columns.Count; i++)
                    {
                        List <string> b = resp.tableheader.ToList();
                        b.Add(dtable.Columns[i].ColumnName);
                        resp.tableheader = b.ToArray();
                    }
                    resp.tableinformation = new List <List <string> >();
                    for (int inti = 0; inti < coldrow.Count; inti++)
                    {
                        drow = coldrow[inti];
                        List <string> temp = new List <string>();
                        for (int j = 0; j < len; j++)
                        {
                            temp.Add(drow[j].ToString());
                        }
                        resp.tableinformation.Add(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(resp);
        }
Beispiel #3
0
 public ReadController(IConfiguration configuration,
                       Information Information,
                       IOptions <Information> options,
                       Json_File json_File)
 {
     _configuration = configuration;
     _Information   = Information;
     _options       = options;
     _json_File     = json_File;
 }
Beispiel #4
0
        /// <summary>
        /// Triggers loading of the save file.
        /// </summary>
        /// <returns></returns>
        internal static bool FileOpen()
        {
            hellionSaveFile = new Json_File(null, hellionSaveFileInfo, autoDeserialise: false);

            if (hellionSaveFile.LoadError)
            {
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Normal Constructor.
        /// </summary>
        /// <param name="passedSourceNode"></param>
        /// <param name="imageList"></param>
        public JsonDataViewForm(Json_TN passedSourceNode, EmbeddedImages_ImageList imageList) : this()
        {
            // Store a reference to the ImageList
            _imageList = imageList ?? throw new NullReferenceException("passed ImageList was null.");

            SourceNode     = passedSourceNode ?? throw new NullReferenceException("passedSourceNode was null.");
            _formTitleText = passedSourceNode.FullPath;
            Text           = _formTitleText;
            _appliedText   = SourceNode.JData.ToString();


            // Find the parent Json_File.
            Json_File parentFile = HellionExplorerProgram.docCurrent?.GameData.FindOwningFile(SourceNode);

            if (parentFile == HellionExplorerProgram.docCurrent.GameData.SaveFile)
            {
                fastColoredTextBox1.ReadOnly    = false;
                toolStripReadOnlyStatus.Visible = false;
                deserialiseAsYouTypeToolStripMenuItem.Checked = true;
                deserialiseAsYouTypeToolStripMenuItem.Enabled = true;
                applyChangesToolStripMenuItem.Enabled         = true;
            }
            else
            {
                fastColoredTextBox1.ReadOnly = true;
                deserialiseAsYouTypeToolStripMenuItem.Checked = false;
                deserialiseAsYouTypeToolStripMenuItem.Enabled = false;
                toolStripReadOnlyStatus.Visible       = true;
                applyChangesToolStripMenuItem.Enabled = true;
            }


            // Character length limit -  this is a guessed figure!
            if (_appliedText.Length > 25000)
            {
                deserialiseAsYouTypeToolStripMenuItem.Checked = false;
            }

            // Apply the text.
            fastColoredTextBox1.Text = _appliedText;

            // Required as setting the FastColouredTextBox triggers the _isDirty
            IsDirty = false;
        }
Beispiel #6
0
        public string Post([FromBody] message req)
        {
            string resp = "";

            try
            {
                //从配置文件中读取字符串
                Json_File _Json_File    = new Json_File();
                var       configuration = _Json_File.Read_Json_File();
                string    connString    = configuration["conn"];

                MySqlConnection conn = new MySqlConnection(connString);

                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand())//创建查询命令
                {
                    string sql = "insert into the_chat_record(sender_id,receiver_id,date,time,content) " +
                                 "values (@sender_id,@receiver_id,@date,@time,@content)";

                    cmd.Connection  = conn;
                    cmd.CommandText = sql;
                    cmd.Parameters.Add(new MySqlParameter("@sender_id", req.sender_id));
                    cmd.Parameters.Add(new MySqlParameter("@receiver_id", req.receiver_id));
                    cmd.Parameters.Add(new MySqlParameter("@content", req.content));
                    cmd.Parameters.Add(new MySqlParameter("@date", DateTime.Now.ToString("yyyy-MM-dd")));
                    cmd.Parameters.Add(new MySqlParameter("@time", DateTime.Now.ToLongTimeString().ToString()));
                    cmd.ExecuteNonQuery();//用来执行sql语句
                }
                conn.Close();
                resp = "success";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                resp = "fail";
            }

            return(resp);
        }
Beispiel #7
0
        public tableinfo Get(string table)
        {
            tableinfo resp = new tableinfo();

            try
            {
                string ip = Request.Headers["X-Forwarded-For"].FirstOrDefault();
                if (string.IsNullOrEmpty(ip))
                {
                    ip = Request.HttpContext.Connection.RemoteIpAddress.ToString();
                }
                Console.WriteLine("=============================");
                //使用postman调用接口,使用部署后的网站的页面调用接口,看看请求方的IP是不是同一个
                //是的话可以在网站全部部署后阻止跨域ajax请求,提高安全性
                Console.WriteLine(ip);
                Console.WriteLine("=============================");
                //从配置文件中读取字符串
                Json_File _Json_File    = new Json_File();
                var       configuration = _Json_File.Read_Json_File();
                string    connString    = configuration["conn"];

                MySqlConnection conn = new MySqlConnection(connString);
                using (MySqlCommand cmd = new MySqlCommand())//创建查询命令
                {
                    string sql = "select * from " + table;

                    cmd.Connection  = conn;
                    cmd.CommandText = sql;
                    //cmd.Parameters.Add(new MySqlParameter("@tablename",req.table));表名不能进行参数化查询
                    MySqlDataAdapter  reader = new MySqlDataAdapter(cmd); //创建一个执行命令的适配器对象
                    DataSet           ds     = new DataSet();             //相当于建立一个基于前台的虚拟数据库
                    DataTable         dtable;                             //相当于数据库中的一张数据表
                    DataRowCollection coldrow;                            //相当于表中行的集合
                    DataRow           drow;                               //相当于一行中列的数据集合
                    reader.Fill(ds, "ds");                                //将查询的结果存储到虚拟数据库ds的虚拟表student中
                    dtable  = ds.Tables["ds"];                            //将数据表student的数据复制到DataTable对象(取库中的一张数据表)
                    coldrow = dtable.Rows;                                //获取数据表中的所有行
                    int len = coldrow[0].ItemArray.Length;                //获取一行有多少字段

                    resp.countofcolumns = len;                            //数据表列数
                    resp.countofrows    = coldrow.Count;                  //数据表行数

                    resp.tableheader = new string[0];
                    for (int i = 0; i < dtable.Columns.Count; i++)
                    {
                        List <string> b = resp.tableheader.ToList();
                        b.Add(dtable.Columns[i].ColumnName);
                        resp.tableheader = b.ToArray();
                    }
                    resp.tableinformation = new List <List <string> >();
                    for (int inti = 0; inti < coldrow.Count; inti++)
                    {
                        drow = coldrow[inti];
                        List <string> temp = new List <string>();
                        for (int j = 0; j < len; j++)
                        {
                            temp.Add(drow[j].ToString());
                        }
                        resp.tableinformation.Add(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(resp);
        }