Exemplo n.º 1
0
        public static Disk_Info Get_Disk_Info(T_DISK_INFO tdi)
        {
            Disk_Info di = new Disk_Info();

            di.disk      = tdi.PHYSICAL_NAME;
            di.DiskTotal = tdi.PHYSCIAL_TOTALSIZE.Value;
            di.Caption   = tdi.LOGICAL_NAME;
            if (tdi.LOGICAL_TOTALSIZE.HasValue)
            {
                di.LogicalTotal = tdi.LOGICAL_TOTALSIZE.Value;
            }
            if (tdi.LOGICAL_USESPACE.HasValue)
            {
                di.UseSpace = tdi.LOGICAL_USESPACE.Value;
            }
            if (tdi.LOGICAL_PERCENT.HasValue)
            {
                di.Percent = tdi.LOGICAL_PERCENT.Value;
            }
            if (tdi.LOGICAL_FREESPACE.HasValue)
            {
                di.FreeSpace = tdi.LOGICAL_FREESPACE.Value;
            }
            di.VolumeName  = tdi.FIELD1;
            di.Description = tdi.FIELD2;


            return(di);
        }
Exemplo n.º 2
0
 public static T_DISK_INFO Set_T_DISK_INFO_By_Disk_Info(T_DISK_INFO disk, Disk_Info d)
 {
     disk.PHYSICAL_NAME      = d.disk;
     disk.PHYSCIAL_TOTALSIZE = d.DiskTotal;
     disk.LOGICAL_NAME       = d.Caption;
     disk.LOGICAL_TOTALSIZE  = d.LogicalTotal;
     disk.LOGICAL_USESPACE   = d.UseSpace;
     disk.LOGICAL_PERCENT    = d.Percent;
     disk.LOGICAL_FREESPACE  = d.FreeSpace;
     disk.IS_ONLINE          = 1;
     disk.FIELD1             = d.VolumeName;
     disk.FIELD2             = d.Description;
     disk.FIELD3             = "";
     disk.FIELD4             = "";
     return(disk);
 }
Exemplo n.º 3
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);
                }
            }
        }