Пример #1
0
        void AddRecord(object parameter)
        {
            if (!ValidateParams(parameter))
            {
                ShowInfoWindow("Podaj poprawne dane");
                return;
            }
            var    values = (object[])parameter;
            Record r      = new Record
            {
                type = values[0].ToString(),
                name = values[1].ToString()
            };

            recordService.AddRecord(r);
            UpdateRecordGrid();
        }
Пример #2
0
        public void RoomEnd(HttpListenerContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            string roomid     = request.QueryString["roomid"];
            string createtime = request.QueryString["createtime"];

            //读取客户端发送过来的数据
            string filename = "";

            using (Stream body = request.InputStream)
            {
                if (!Directory.Exists("frame"))
                {
                    Directory.CreateDirectory("frame");
                }
                filename = "frame/" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".bin";
                FileStream fs    = new FileStream(filename, FileMode.Create);
                byte[]     buff  = new byte[1024];
                int        count = 0;
                while ((count = body.Read(buff, 0, 1024)) != 0)
                {
                    fs.Write(buff, 0, count);
                }
                fs.Close();
            }

            Dictionary <string, object> result = new Dictionary <string, object>();
            Record record = RecordService.AddRecord(int.Parse(roomid), createtime, filename);

            if (record != null)
            {
                result.Add("code", 0);
                result.Add("data", new Dictionary <string, object>());
            }
            else
            {
                result.Add("code", -1);
                result.Add("msg", "operate fail");
            }

            Response(context, result);
        }