Example #1
0
 public static void Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer, TraceWriter log)
 {
     _oceanModel             = new OCEAN_MODEL();
     _logModel               = new LOG_MODEL();
     _log                    = log;
     _fileListToNeedDownload = new List <string[]>();
     // function 다른 instance가 동작하고 있으면 이중으로 실행하지 않도록 작동 중지.
     if (_functionIsRunningOrNot == true)
     {
         _log.Info($"Other Instance is Running at: {DateTime.Now}");
         return;
     }
     try
     {
         _functionIsRunningOrNot = true;
         CheckToGetGfsFile();
         FtpDownLoad();
     }
     catch (Exception e)
     {
         log.Info($"error: {e.ToString()}");
     }
     finally
     {
         _functionIsRunningOrNot = false;
     }
 }
Example #2
0
        public static void MakeLatLonKey()
        {
            var kdTree = MemoryRoad();

            OCEAN_MODEL oceanModel = new OCEAN_MODEL();
            List <RTOFS_POSITION_CONVERT> oceanLatLon = new List <RTOFS_POSITION_CONVERT>();

            kdTree.Distance = Accord.Math.Distance.Euclidean;

            for (int i = 0; i < 360; i++)
            {
                for (int j = 0; j < 720; j++)
                {
                    var lat          = 90 - (float)i / 2;
                    var lon          = (float)j / 2;
                    var lonForSearch = (float)j / 2 > 74 ? (float)j / 2 : 360 + (float)j / 2;
                    var keygeo       = kdTree.Nearest(new double[] { lat, lonForSearch }, neighbors: 400).OrderBy(s => s.Distance).First().Node.Value;
                    var refid        = i * 720 + j;

                    oceanLatLon.Add(new RTOFS_POSITION_CONVERT
                    {
                        LAT = (decimal)lat,
                        LON = (decimal)lon,
                        KEY = keygeo
                    });
                }
            }

            using (var oceanMoel = new OCEAN_MODEL())
            {
                oceanMoel.Database.CommandTimeout = 30000;
                EFBatchOperation.For(oceanMoel, oceanMoel.RTOFS_POSITION_CONVERT).InsertAll(oceanLatLon);
                oceanMoel.Dispose();
                oceanLatLon.Clear();
            }
        }