Ejemplo n.º 1
0
        /// <summary>
        /// 使用这个 CommandSet 方法的方法,不和 RepositoryTrans 使用同一事务对象
        /// </summary>
        /// <param name="tc"></param>
        /// <returns></returns>
        private CommandSet <T> GetCommandSet(TransContext tc)
        {
            var cs = tc.CommandSet <T>();

            this.Sql = cs;
            return(cs);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 使用这个 CommandSet 方法的方法,不和 RepositoryTrans 使用同一事务对象
        /// </summary>
        /// <param name="tc"></param>
        /// <returns></returns>
        private CommandSet <T> GetCommandSet(TransContext tc)
        {
            var cs = tc.CommandSet <T>(new SqlProvider <T>(Dialect), Throws);

            this.Sql = cs;
            return(cs);
        }
Ejemplo n.º 3
0
 public string UpdateItem(long id, int amountOfLikes)
 {
     using (var db = new TransContext())
     {
         return(db.editLikes(id, amountOfLikes));
     }
 }
Ejemplo n.º 4
0
 public IEnumerable <TransportationML> GetTransInfo()
 {
     using (var db = new TransContext())
     {
         var items = db.Transportations.AsQueryable().ToList();
         List <TransportationML> transportationMLs = new List <TransportationML>();
         double min = 0;
         double max = 0;
         foreach (var item in items)
         {
             var input = new ModelInput();
             input.VehicleType   = item.vehicleType;
             input.RoutToCountry = item.routToCountry;
             ModelOutput result = ConsumeModel.Predict(input);
             if (result.Score > max)
             {
                 max = result.Score;
             }
             if (result.Score < min)
             {
                 min = result.Score;
             }
             transportationMLs.Add(new TransportationML
             {
                 transportationInfo = item,
                 likeProbability    = result.Score
             });
         }
         foreach (var item in transportationMLs)
         {
             item.percentage = (int)Math.Round(100 * (item.likeProbability + Math.Abs(min)) / Math.Abs(max - min));
         }
         return(transportationMLs);
     }
 }
Ejemplo n.º 5
0
        public async static Task loopWithTimer(TimeSpan timeSpan)
        {
            //List<TransportationInfo> items = new List<TransportationInfo>();
            List <TransportationInfo> items = FetchDataFromWebSite();
            //RabbitMQSet(items);
            TransContext ctx = new TransContext();

            ctx.SetMany(items);
            await Task.Delay(timeSpan);
        }
Ejemplo n.º 6
0
 private DataService()
 {
     transInfo = new List <TransportationInfo>();
     db        = new TransContext();
     subscribeIntoDataFromTheQueue();
 }
Ejemplo n.º 7
0
 public TransController(TransContext context)
 {
     _context = context;
 }