Ejemplo n.º 1
0
 /// <summary>
 /// 添加养护附件
 /// </summary>
 /// <param name="model"></param>
 public void AddFile(YH_FileModel model)
 {
     using (Entities db = new Entities())
     {
         yh_files yhmodel = new yh_files();
         //yhmodel.fileid = model.fileid;
         yhmodel.filesource = model.filesource;
         yhmodel.sourceid   = model.sourceid;
         yhmodel.filename   = model.filename;
         yhmodel.filetype   = model.filetype;
         yhmodel.filepath   = model.filepath;
         yhmodel.filesize   = model.filesize;
         db.yh_files.Add(yhmodel);
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        public HttpResponseMessage AddLog(YH_YhLogModel model)
        {
            int success = bll.AddLog(model);

            string[]         fileClass = model.uploadpanelValue;
            List <FileClass> list      = new List <FileClass>();

            if (fileClass != null && fileClass.Length > 0)
            {
                foreach (var item in fileClass)
                {
                    FileClass file = new FileClass();
                    JObject   jo   = new JObject();
                    jo = (JObject)JsonConvert.DeserializeObject(item);
                    file.OriginalPath = jo["OriginalPath"] == null ? "" : jo["OriginalPath"].ToString();
                    file.OriginalName = jo["OriginalName"] == null ? "" : jo["OriginalName"].ToString();
                    file.OriginalType = jo["OriginalType"] == null ? "" : jo["OriginalType"].ToString();
                    file.size         = jo["size"] == null ? 0 : (double)jo["size"];
                    list.Add(file);
                }
            }

            foreach (var item in list)
            {
                YH_FileModel filemodel = new YH_FileModel();
                filemodel.filesource = 2;
                filemodel.sourceid   = success;
                filemodel.filename   = item.OriginalName;
                filemodel.filetype   = item.OriginalType;
                filemodel.filepath   = item.OriginalPath;
                filemodel.filesize   = item.size;
                filebll.AddFile(filemodel);
            }

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            if (success > 0)
            {
                response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html");
            }
            else
            {
                response.Content = new StringContent("{\"success\":false}", Encoding.GetEncoding("UTF-8"), "text/html");
            }
            return(response);
        }
Ejemplo n.º 3
0
        public object AddLogApi(YH_YhLogModel model)
        {
            try
            {
                int success = bll.AddLog(model);

                #region 图片处理
                List <FileClass> list       = new List <FileClass>();
                string           OriginPath = ConfigManageClass.YhLogOriginalPath;
                string           smallPath  = ConfigManageClass.YhLogFilesPath;
                if (model.photo1 != null && model.photo1.Length != 0)
                {
                    string[] spilt = model.photo1.Split(',');
                    if (spilt.Length > 1)
                    {
                        byte[]    myByte = Convert.FromBase64String(spilt[1]);
                        FileClass FC     = FileFactory.FileUpload(myByte, ".jpg", OriginPath, smallPath, 100, 100);
                        list.Add(FC);
                    }
                }
                if (model.photo2 != null && model.photo2.Length != 0)
                {
                    string[] spilt = model.photo2.Split(',');
                    if (spilt.Length > 1)
                    {
                        byte[]    myByte = Convert.FromBase64String(spilt[1]);
                        FileClass FC     = FileFactory.FileUpload(myByte, ".jpg", OriginPath, smallPath, 100, 100);
                        list.Add(FC);
                    }
                }
                if (model.photo3 != null && model.photo3.Length != 0)
                {
                    string[] spilt = model.photo3.Split(',');
                    if (spilt.Length > 1)
                    {
                        byte[]    myByte = Convert.FromBase64String(spilt[1]);
                        FileClass FC     = FileFactory.FileUpload(myByte, ".jpg", OriginPath, smallPath, 100, 100);
                        list.Add(FC);
                    }
                }

                #endregion

                foreach (var item in list)
                {
                    YH_FileModel filemodel = new YH_FileModel();
                    filemodel.filesource = 2;
                    filemodel.sourceid   = success;
                    filemodel.filename   = item.OriginalName;
                    filemodel.filetype   = item.OriginalType;
                    filemodel.filepath   = item.OriginalPath;
                    filemodel.filesize   = item.size;
                    filebll.AddFile(filemodel);
                }

                if (success > 0)
                {
                    return(new
                    {
                        msg = "上报成功",
                        resCode = 1
                    });
                }
                else
                {
                    return(new
                    {
                        msg = "json数据不正确",
                        resCode = 0
                    });
                }
            }
            catch (Exception)
            {
                return(new
                {
                    msg = "json数据不正确",
                    resCode = 0
                });
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加养护附件
 /// </summary>
 /// <param name="model"></param>
 public void AddFile(YH_FileModel model)
 {
     dal.AddFile(model);
 }