Example #1
0
        public static List <T_Video> GetList_Video_Info_Like(string name, int top_num = 20)
        {
            //using (var ctx = new myVideoEntities())
            //{
            //    try
            //    {
            //        //Querying with LINQ to Entities
            //        var L2EQuery = ctx.T_Video.Where(s => s.FILE_NAME.Contains(name)).Take(top_num);
            //        var vs = L2EQuery.ToList<T_Video>();
            //        return vs;
            //    }
            //    catch (Exception ex)
            //    {
            //        Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
            //        return new List<T_Video>();
            //    }

            //}
            using (var ctx = new myVideoEntities())
            {
                try
                {
                    var L2EQuery = ctx.T_Video.SqlQuery("select * from T_Video where FILE_NAME like '%" + name + "%' limit 0," + top_num);
                    var vs       = L2EQuery.ToList <T_Video>();
                    return(vs);
                }
                catch (Exception ex)
                {
                    Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
                    return(new List <T_Video>());
                }
            }
        }
Example #2
0
 /// <summary>
 /// 更新影片信息
 /// </summary>
 /// <param name="fi"></param>
 /// <returns></returns>
 public static int Add_Video_Info(File_Info fi)
 {
     using (var ctx = new myVideoEntities())
     {
         try
         {
             T_Video v = new T_Video();
             v.CREATE_TIME    = DateTime.Now;
             v.Device_UID     = fi.fileRootID;
             v.FILESIZE       = fi.fileSize;
             v.FILE_ROOT      = fi.fileRoot;
             v.FILE_DIR       = fi.fileDir;
             v.FILE_EXTENSION = fi.fileExtension;
             v.FILE_FULLPATH  = fi.fileFullPath;
             v.FILE_INDEX     = fi.fileIndex;
             v.FILE_NAME      = fi.fileName;
             ctx.T_Video.Add(v);
             return(ctx.SaveChanges());
         }
         catch (Exception ex)
         {
             Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
             return(0);
         }
     }
 }
Example #3
0
 public static int Add_Task_Info(Task_Info task, List <T_Video> vs)
 {
     using (var ctx = new myVideoEntities())
     {
         try
         {
             T_WORKS  w      = new T_WORKS();
             DateTime dt_now = DateTime.Now;
             w.CREATETIME       = dt_now;
             w.NAME             = task.id;
             w.SOURCE_SIZE      = task.source_size;
             w.TARGET_HD_SIZE   = task.target_size;
             w.TARGET_LOCATION  = task.target;
             w.TARGET_FREE_SIZE = task.target_free_size;
             w.VIDEO_COUNT      = vs.Count;
             w.COPY_COUNT       = 0;
             w.MEMO             = task.copy_type;
             ctx.T_WORKS.Add(w);
             int row = ctx.SaveChanges();
             if (row > 0)
             {
                 foreach (var v in vs)
                 {
                     T_WORKS_SUB ws = new T_WORKS_SUB();
                     ws.CREATE_TIME    = dt_now;
                     ws.FILESIZE       = v.FILESIZE;
                     ws.FILE_DIR       = v.FILE_DIR;
                     ws.FILE_EXTENSION = v.FILE_EXTENSION;
                     ws.FILE_FULLPATH  = v.FILE_FULLPATH;
                     ws.FILE_NAME      = v.FILE_NAME;
                     ws.FILE_ROOT      = v.FILE_ROOT;
                     ws.ID_VIDEO       = v.ID;
                     ws.PID            = w.ID;
                     ctx.T_WORKS_SUB.Add(ws);
                 }
             }
             return(ctx.SaveChanges());
         }
         catch (Exception ex)
         {
             Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
             return(0);
         }
     }
 }
Example #4
0
 public static List <T_CONFIG> GetList_Config(string key)
 {
     using (var ctx = new myVideoEntities())
     {
         try
         {
             //Querying with LINQ to Entities
             var L2EQuery = ctx.T_CONFIG.Where(s => s.KEY == (key));
             var vs       = L2EQuery.ToList <T_CONFIG>();
             return(vs);
         }
         catch (Exception ex)
         {
             Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
             return(null);
         }
     }
 }
Example #5
0
        public static T_Video GetList_Video_Info(string name)
        {
            using (var ctx = new myVideoEntities())
            {
                try
                {
                    //Querying with LINQ to Entities
                    var L2EQuery = ctx.T_Video.FirstOrDefault(s => s.FILE_NAME == (name));

                    return(L2EQuery);
                }
                catch (Exception ex)
                {
                    Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
                    return(null);
                }
            }
        }
Example #6
0
 /// <summary>
 /// 获取硬盘所有信息
 /// </summary>
 /// <returns></returns>
 public static List <T_DISK_INFO> GetList_Disk_Info()
 {
     using (var ctx = new myVideoEntities())
     {
         try
         {
             //Querying with LINQ to Entities
             var L2EQuery = ctx.T_DISK_INFO.OrderBy(s => s.IS_ONLINE);
             var disks    = L2EQuery.ToList <T_DISK_INFO>();
             return(disks);
         }
         catch (Exception ex)
         {
             Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
             return(new List <T_DISK_INFO>());
         }
     }
 }
Example #7
0
        public static int Delete_Video_Info(int disk_id)
        {
            int i_dele = 0;

            using (var ctx = new myVideoEntities())
            {
                try
                {
                    ctx.Database.ExecuteSqlCommand(string.Format("delete from T_VIDEO_TAGS where ID_TAGS in (select ID from T_VIDEO where DEVICE_UID = {0})", disk_id));
                    i_dele = ctx.Database.ExecuteSqlCommand(string.Format("delete from T_VIDEO where DEVICE_UID = {0}", disk_id));
                }
                catch (Exception ex)
                {
                    Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
                }

                return(i_dele);
            }
        }
Example #8
0
        public static int Update_Task_Info(string id, int copy_count)
        {
            int i_dele = 0;

            using (var ctx = new myVideoEntities())
            {
                try
                {
                    i_dele += ctx.Database.ExecuteSqlCommand("update T_Works set COPY_COUNT = " + copy_count + " where NAME = '" + id + "'");
                }
                catch (Exception ex)
                {
                    Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
                }


                return(i_dele);
            }
        }
Example #9
0
        //using (var ctx = new myVideoEntities())
        //{
        //    //Querying with LINQ to Entities
        //    var L2EQuery = ctx.T_DISK_INFO.Where(s => s.LOGICAL_NAME == "C:\\");
        //    var disks = L2EQuery.FirstOrDefault<T_DISK_INFO>();

        //    //LINQ Query syntax:
        //    var L2EQuery2 = from di in ctx.T_DISK_INFO
        //                    where di.LOGICAL_NAME == "C:\\"
        //                    select di;

        //    var disks2 = L2EQuery2.FirstOrDefault<T_DISK_INFO>();


        //    ////Querying with Object Services and Entity SQL
        //    //string sqlString = "select * from T_DISK_INFO as di where di.LOGICAL_NAME == 'C:\\'";
        //    //var objctx = (ctx1 as IObjectContextAdapter).ObjectContext;
        //    //ObjectQuery<T_DISK_INFO> disk3 = objctx.CreateQuery<T_DISK_INFO>(sqlString);
        //    //T_DISK_INFO newDisk = disk3.First<T_DISK_INFO>();

        //    ////Native SQL:
        //    //var disk4 = ctx.T_DISK_INFO.SqlQuery("select * from T_DISK_INFO as di where di.LOGICAL_NAME == 'C:\\'")
        //    //    .FirstOrDefault<T_DISK_INFO>();

        public static int Delete_Disk_Info(List <T_DISK_INFO> ds)
        {
            int i_dele = 0;

            using (var ctx = new myVideoEntities())
            {
                try
                {
                    for (int i = 0; i < ds.Count; i++)
                    {
                        i_dele += ctx.Database.ExecuteSqlCommand("delete from t_disk_info where ID = " + ds[i].ID);
                    }
                }
                catch (Exception ex)
                {
                    Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
                }


                return(i_dele);
            }
        }
Example #10
0
        /// <summary>
        /// 更新硬盘信息
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public static int Update_Disk_Info(List <Disk_Info> ds)
        {
            using (var ctx = new myVideoEntities())
            {
                ctx.Database.ExecuteSqlCommand("update T_DISK_INFO set IS_ONLINE = 0");

                try
                {
                    foreach (var d in ds)
                    {
                        //Querying with LINQ to Entities
                        var L2EQuery = ctx.T_DISK_INFO.Where(s =>
                                                             s.PHYSICAL_NAME == d.disk &&
                                                             s.PHYSCIAL_TOTALSIZE == d.DiskTotal &&
                                                             s.FIELD1 == d.VolumeName &&
                                                             s.LOGICAL_TOTALSIZE == d.LogicalTotal);

                        var disk = L2EQuery.FirstOrDefault <T_DISK_INFO>();
                        if (disk == null)
                        {
                            T_DISK_INFO di = Disk_Info.Get_T_DISK_INFO(d);
                            ctx.T_DISK_INFO.Add(di);
                        }
                        else
                        {
                            disk = Disk_Info.Set_T_DISK_INFO_By_Disk_Info(disk, d);
                        }
                        //ctx.SaveChanges();
                    }
                    return(ctx.SaveChanges());
                }
                catch (Exception ex)
                {
                    Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message);
                    return(0);
                }
            }
        }
Example #11
0
        private void button4_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter      = "文本文件|*.txt";
                ofd.Multiselect = false;                 //是否允许多选,false表示单选
                if (ofd.ShowDialog() == DialogResult.OK) //如果点击的是打开文件
                {
                    lb_Files.Items.Clear();
                    lb_Files.Tag = null;
                    try
                    {
                        //int i_success = 0, i_fail = 0;
                        //string str_temp = "";
                        //List<T_Video> lts = new List<T_Video>();
                        //string[] arr_files = Helper_Txt.ReadAllLines(ofd.FileName, Encoding.UTF8);  //获取全路径文件名

                        //for (int i = 0; i < arr_files.Length; i++)
                        //{
                        //    T_Video v = MyVideoBussiness.GetList_Video_Info(arr_files[i]);
                        //    if (v == null)
                        //    {
                        //        i_fail++;
                        //        str_temp = "NO  NULL  " + arr_files[i];

                        //    }
                        //    else
                        //    {
                        //        i_success++;
                        //        str_temp = "OK  "+ v.FILE_ROOT + "  " + arr_files[i];
                        //        lts.Add(v);
                        //    }
                        //    lb_Files.Items.Add(str_temp);
                        //}
                        //SetMyTextBoxValue(lb_Task_Info, string.Format(str_match_file, i_success, i_fail));
                        //lb_Files.Tag = lts;

                        //if (lts.Count > 0)
                        //{
                        //    Command_info c = new Command_info();
                        //    c.type = 3;
                        //    if (rb_dir.Checked)
                        //    {
                        //        c.msg = string.Join(",.,", lts.Select(s => s.FILE_DIR).Distinct());
                        //        c.msg2 = "1";
                        //    }
                        //    else
                        //    {
                        //        c.msg = string.Join(",.,", lts.Select(s => s.FILE_FULLPATH));
                        //        c.msg2 = "0";
                        //    }
                        //    string str_c = Helper_Json.Encode(c);
                        //    SetrichTextBox("刷新所有硬盘信息.....");
                        //    long r_l = h_redis.RedisPub(str_r_rep, str_c);
                        //    Helper_log.Write_log(str_r_rep + ":" + str_c);
                        //}

                        List <T_Video> lts       = new List <T_Video>();
                        string[]       arr_files = Helper_Txt.ReadAllLines(ofd.FileName, Encoding.UTF8); //获取全路径文件名
                        for (int i = 0; i < arr_files.Length; i++)
                        {
                            T_Video v = MyVideoBussiness.GetList_Video_Info(arr_files[i]);
                            if (v != null)
                            {
                                lts.Add(v);
                            }
                            else
                            {
                                lb_Files.Items.Add("NO  " + arr_files[i]);
                            }
                        }
                        Add_Task_Node(lts);
                    }
                    catch (Exception ex)
                    {
                        Helper_log.Write_Error(ex.Message);
                    }
                }
            }
        }