示例#1
0
        public List <FileOp> MyReceive(string userid)
        {
            List <FileOp> list = new List <FileOp>();
            DataTable     dt   = sel.ToMyShare(userid);

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    FileOp fo       = new FileOp();
                    string filepath = dt.Rows[i]["jw_filepath"].ToString();
                    fo.Date    = dt.Rows[i]["jw_createtime"].ToString();
                    fo.Shareid = dt.Rows[i]["jw_shareid"].ToString();
                    fo.Userid  = dt.Rows[i]["jw_userid"].ToString();
                    DataTable dtt = sel.GetUserByUserid(fo.Userid);
                    if (dtt.Rows.Count > 0)
                    {
                        fo.Username = dtt.Rows[0]["ri_realname"].ToString();
                    }
                    else
                    {
                        fo.Username = "";
                    }

                    //List<string> li = JsonConvert.DeserializeObject<List<string>>(filepath);
                    List <string> li = filepath.Split(',').ToList();
                    if (li.Count == 1)
                    {
                        fo.FileUrl = li[0];

                        string path = AppDomain.CurrentDomain.BaseDirectory + li[0];
                        if (File.Exists(path))
                        {
                            FileInfo fi = new FileInfo(path);
                            fo.Name = fi.Name;
                            fo.Size = FileOperate.GetFileSize(fi.Length);
                            fo.Type = path.Substring(path.LastIndexOf('.') + 1);
                        }
                        else if (Directory.Exists(path))
                        {
                            DirectoryInfo di = new DirectoryInfo(path);
                            fo.Name = di.Name;
                            fo.Type = "1";
                            fo.Size = "--";
                        }
                    }
                    else if (li.Count > 1)
                    {
                        fo.Type    = "3";
                        fo.FileUrl = JsonConvert.SerializeObject(li.ToArray());
                        fo.Name    = li[0].Substring(li[0].LastIndexOf('/') + 1) + "等多个文件";
                        fo.Size    = "--";
                    }
                    if (string.IsNullOrEmpty(fo.Name))
                    {
                        continue;
                    }
                    list.Add(fo);
                }
            }
            return(list);
        }