public HttpResponseMessage Upload_Data__For_ElectronicFile(Upload_Data__For_ElectronicFile_Info info)
        {
            string result = string.Empty;

            try
            {
                Model.ElectronicFile list = new Model.ElectronicFile();

                list.fldReport_Name = info.fldReport_Name;
                list.fldReport_Type = info.fldReport_Type;
                list.fldRName       = info.fldRName;
                list.fldUserID      = info.fldUserID;
                list.fldTime        = DateTime.Now;
                list.fldPath        = info.fldPath;
                list.fldFileName    = info.fldFileName;

                using (Model.EntityContext db = new Model.EntityContext())
                {
                    db.ElectronicFile.Add(list);
                    db.SaveChanges();
                }

                result = rule.JsonStr("ok", "", list);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        public HttpResponseMessage Download_File__For_ElectronicFile(string fldAutoID)
        {
            string result = string.Empty;

            try
            {
                int ID = int.Parse(fldAutoID);

                Model.ElectronicFile list = new Model.ElectronicFile();

                using (Model.EntityContext db = new Model.EntityContext())
                {
                    list = (from x in db.ElectronicFile
                            where x.fldAutoID == ID
                            select x).ToList().FirstOrDefault();
                }


                var FilePath = list.fldPath;



                var stream = new FileStream(FilePath, FileMode.Open);
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new StreamContent(stream);
                response.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = list.fldFileName
                };

                return(response);


                result = rule.JsonStr("ok", "", list);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }



            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        public HttpResponseMessage Upload_Delete_For_ElectronicFile(Upload_Delete_For_ElectronicFile_Info info)
        {
            string result = string.Empty;

            try
            {
                Model.ElectronicFile        list = new Model.ElectronicFile();
                List <Model.ElectronicFile> arr  = new List <Model.ElectronicFile>();

                using (Model.EntityContext db = new Model.EntityContext())
                {
                    foreach (var item in info.fldAutoID.Split(','))
                    {
                        int t = Convert.ToInt32(item.ToString());
                        list = (from x in db.ElectronicFile
                                where x.fldAutoID == t
                                select x).ToList().FirstOrDefault();

                        if (list.fldPath != null && list.fldPath != "")
                        {
                            File.Delete(list.fldPath);
                        }

                        db.ElectronicFile.Remove(list);
                        arr.Add(list);
                    }

                    db.SaveChanges();
                }

                result = rule.JsonStr("ok", "", arr);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }