Пример #1
0
 public override void Execute(NinServiceContext context)
 {
     using (var sql = new SqlStatement(Sql, Config.Settings.ConnectionString))
     {
         sql.ExecuteNonQuery();
     }
 }
Пример #2
0
        public override void Execute(NinServiceContext context)
        {
            Values = SqlServer.GetAreaLayerValues(AreaType, Number);

            var layer = Config.Settings.Map.FindLayer(MapLayerName);
            var store = new Cache <VectorQuadTile>(new DiskTileStore(layer));
            var tiler = new VectorTiler(store, layer);

            var        areas       = SqlServer.GetAreas(AreaType, 0, Number);
            ZoomFactor zf          = layer.GetZoomFactors(AreaType);
            string     allAffected = "";

            foreach (var area in areas)
            {
                for (int zoom = zf.Minimum; zoom <= zf.Maximum; zoom++)
                {
                    var      distanceTolerance = layer.SimplificationToleranceAtZoom0 * Math.Pow(0.25, zoom);
                    var      fullRes           = DotSpatialGeometry.From(area.Geometry);
                    Geometry simpler           = VectorTiler.Simplify(fullRes, distanceTolerance);
                    if (simpler.IsEmpty)
                    {
                        continue;
                    }
                    var område = Map.Tiles.Geometri.Område.Fra(area);
                    Log.v("TILE", $"Area type {område.Type} #{område.Number}: {fullRes.Coordinates.Count} => {simpler.Coordinates.Count} (zoom {zoom})");
                    var affected = tiler.Update(område, simpler, zoom);
                    if (allAffected.Length > 0)
                    {
                        allAffected += ",";
                    }
                    allAffected += affected;
                }
            }
            Affected = allAffected;
        }
Пример #3
0
 public override void Execute(NinServiceContext context)
 {
     try
     {
         Http.Get(Url);
     }
     catch (Exception e)
     {
         Notify(context, e);
     }
 }
Пример #4
0
        private void Notify(NinServiceContext context, Exception exception)
        {
            var email = new SendEmailTask
            {
                To      = "*****@*****.**",
                Subject = "Service down: " + exception.Message,
                Body    = Url + Environment.NewLine + Environment.NewLine + exception
            };

            context.TaskQueue.Enqueue(email);
        }
Пример #5
0
        public override void Execute(NinServiceContext context)
        {
            var settings = Config.Settings.ExternalDependency.Email;
            var smtp     = new SmtpClient(settings.Server, 25)
            {
                UseDefaultCredentials = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                EnableSsl             = false
            };

            var mail = new MailMessage {
                From = new MailAddress(settings.SenderEmail, settings.SenderName)
            };

            mail.To.Add(new MailAddress(To));
            mail.Subject = Subject;
            mail.Body    = Body;
            smtp.Send(mail);
        }
Пример #6
0
        public static bool Process(NinServiceContext context, Task task)
        {
            if (task == Task.Idle)
            {
                return(false);
            }
            var watch = Stopwatch.StartNew();

            try
            {
                task.Execute(context);
            }
            catch (Exception caught)
            {
                MoveToErrorQueue(task.Id, caught);
                throw new Exception(task + " suspended.", caught);
            }
            watch.Stop();
            Remove(task, watch.ElapsedMilliseconds);
            return(true);
        }
Пример #7
0
 public abstract void Execute(NinServiceContext context);
Пример #8
0
        public static bool ProcessNext(NinServiceContext context)
        {
            var task = PeekNext();

            return(Process(context, task));
        }
Пример #9
0
 public override void Execute(NinServiceContext context)
 {
 }
Пример #10
0
 public override void Execute(NinServiceContext context)
 {
     Thread.Sleep(4000);
 }
Пример #11
0
 public override void Execute(NinServiceContext context)
 {
     Naturkodetrær.Refresh(KodetreType);
 }