示例#1
0
 void SaveAbandonedReason(zfcs_nsiAbandonedReasonType[] nsiAbandonedReason)
 {
     using (var db = _govDb.GetContext())
     {
         foreach (var ar in nsiAbandonedReason)
         {
             NsiAbandonedReason NsiAReason = new NsiAbandonedReason()
             {
                 Code       = ar.code,
                 Name       = ar.name,
                 docType    = JsonConvert.SerializeObject(ar.docType),
                 objectName = ar.objectName,
                 PlacingWay = JsonConvert.SerializeObject(ar.placingWay),
                 Type       = ar.type.ToString(),
                 Fz_type    = FLType.Fl44,
                 Actual     = ar.actual,
                 OosId      = ar.id
             };
             try {
                 var find = db.NsiAReasons.Where(x => x.Code == NsiAReason.Code &&
                                                 x.OosId == ar.id &&
                                                 x.Fz_type == FLType.Fl44).FirstOrDefault();
                 if (find == null)
                 {
                     db.NsiAReasons.Add(NsiAReason);
                     db.SaveChanges();
                 }
                 else
                 {
                     //find.objectName = NsiAReason.objectName;
                     find.Actual = NsiAReason.Actual;
                     //find.docType= NsiAReason.docType;
                     //find.objectName = NsiAReason.objectName;
                     db.NsiAReasons.Update(find);
                     db.SaveChanges();
                 }
             }
             catch (Exception ex)
             {
                 _logger.LogError(ex, ex.Message);
             }
         }
     }
 }
        bool GetDBfile(string FullPath)
        {
            NsiFileCashes find = null;

            using (var db = _govDb.GetContext())
            {
                find = db.NsiFileCashes
                       .AsNoTracking()
                       .Where(x => x.Full_path == FullPath)
                       .OrderByDescending(x => x.Date)
                       .FirstOrDefault();
            }
            if (find == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#3
0
 private void SavePath(FileCashes item)
 {
     try
     {
         using (var db = _govDb.GetContext())
         {
             db.FileCashes.Add(item);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, ex.Message);
     }
 }
示例#4
0
        /// <summary>
        /// Получение списка файлов из кэша.
        /// </summary>
        /// <param name="lim"></param>
        /// <param name="status"></param>
        /// <param name="fz_type"></param>
        /// <param name="basepath"></param>
        /// <param name="dirtype"></param>
        /// <returns></returns>
        public List <NsiFileCashes> GetNsiDBList(int lim, Status status, FLType fz_type, string basepath, string dirtype)
        {
            //throw new NotImplementedException();

            List <NsiFileCashes> data = new List <NsiFileCashes>();

            using (var db = _govDb.GetContext())
            {
                data = db.NsiFileCashes
                       .AsNoTracking()
                       .Where(x => x.Status == status &&
                              x.Fz_type == fz_type &&
                              x.BaseDir == basepath &&
                              x.Dirtype == dirtype)
                       .OrderBy(x => x.Date)
                       //.OrderByDescending(x => x.Date)
                       .Take(lim)
                       .ToList();
            }
            return(data);
        }