Exemplo n.º 1
0
        public void Did_JSON_Deserialize_Successfully()
        {
            string jsonString = JSONHelper.DownloadJSON().Result;

            modelLocator.ViewModel.AllPlayers = JSONHelper.DeserializeJSON(jsonString);
            Assert.IsNotNull(modelLocator.ViewModel.AllPlayers);
        }
Exemplo n.º 2
0
        public void Did_Two_Selectable_Players_Populate()
        {
            string jsonString = JSONHelper.DownloadJSON().Result;

            modelLocator.ViewModel.AllPlayers = JSONHelper.DeserializeJSON(jsonString);
            modelLocator.ViewModel.RandomizeSelectablePlayers();

            Assert.IsNotNull(modelLocator.ViewModel.SelectablePlayers);
        }
Exemplo n.º 3
0
        protected void upload_Click(object sender, EventArgs e)
        {
            var message = TextArea1.InnerText;

            if (ProjectName.Text.Trim() != "")
            {
                if (message.Length < 500)
                {
                    if (FileUpload1.HasFile)
                    {
                        try
                        {
                            string datetime = "" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second;
                            string filePath = Server.MapPath("UploadFile/") + datetime + FileUpload1.FileName;
                            FileUpload1.SaveAs(filePath);
                            string JSONString = fileHelper.FileStreamReader(filePath);
                            string sqlInsert;
                            //JSON反序列化
                            JArray ja = JSONHelper.DeserializeJSON(JSONString);
                            if (ja != null)
                            {
                                //string s = "";
                                //以时间+项目名作为projectId
                                sqlInsert = $"insert into projectinfo(projectId,projectname,username,createtime,message) values('{datetime + ProjectName.Text}','{ProjectName.Text}','{username}','{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day} {DateTime.Now.Hour}:{DateTime.Now.Minute}:{DateTime.Now.Second}','{message}')";
                                SQLHelper.GetExecuteNonQuery(sqlInsert);
                                for (int i = 0; i < ja.Count; i++)
                                {
                                    JObject o = (JObject)ja[i];
                                    //以时间+key+顺序i作为textId
                                    sqlInsert = $"insert into textinfo(textId,[key],text,projectId) values('{datetime + o["key"].ToString() + i}','{o["key"].ToString()}','{ o["text"].ToString()}','{datetime + ProjectName.Text}')";
                                    SQLHelper.GetExecuteNonQuery(sqlInsert);
                                    // s += "KEY:" + o["key"].ToString();
                                    //s += "TEXT:" + o["text"].ToString();
                                }
                                // usermsg.Text = s;
                                Response.AddHeader("Refresh", "0");
                            }
                            else
                            {
                                usermsg.Text = "文件格式错误,请检查上传的文件";
                            }
                        }
                        catch (Exception)
                        {
                            usermsg.Text = "文件格式错误,请检查上传的文件";
                        }
                    }
                    else
                    {
                        usermsg.Text = "请选择要上传的文件";
                    }
                }
                else
                {
                    usermsg.Text = "项目介绍应小于500字";
                }
            }
            else
            {
                usermsg.Text = "请输入项目名";
            }
        }