Beispiel #1
0
        private static async Task ExecuteActivity(List <EventSettingModel> appActivities)
        {
            bool removeProess = false;

            if (appActivities != null)
            {
                string timezone = appActivities[0].TimeZone;
                string time     = appActivities[0].Time;
                if (!string.IsNullOrEmpty(timezone) && !string.IsNullOrEmpty(time) && !string.IsNullOrEmpty(appActivities[0].UserId) && !string.IsNullOrEmpty(appActivities[0].Password))
                {
                    try
                    {
                        DateTime currentTime = DateTime.Now;
                        if (SpContentJobManager.IsValidExecutionTime(timezone, time, Convert.ToInt32(SpContentJobConstant.SpContentIntervalInMinute), out currentTime))
                        {
                            _logger.Info($"excecuting setup for {appActivities[0].OrganizationRootUrl} at {currentTime}");
                            List <Task> task = new List <Task>();
                            foreach (var appActivity in appActivities)
                            {
                                long id = appActivity.EventSettingId;
                                if (spContentRetrivalActivities.TryGetValue(id, out id))
                                {
                                    task.Add(ExecuteActivity(appActivity));
                                }
                            }
                            await Task.WhenAll(task);
                        }
                        else
                        {
                            removeProess = true;
                            _logger.Info($"{currentTime} is not setup for {appActivities[0].OrganizationRootUrl}");
                        }
                    }
                    catch (Exception ex)
                    {
                        removeProess = true;
                        _logger.Error($"failed to ExecuteActivity for {appActivities[0].OrganizationRootUrl}", ex);
                    }
                }
                else
                {
                    removeProess = true;
                    _logger.Info($"Either Time/timezone or user/pwd is not setup for {appActivities[0].OrganizationRootUrl}");
                }
            }
            if (removeProess)
            {
                foreach (var item in appActivities)
                {
                    RemoveFromProcess(item.EventSettingId);
                }
            }
            await Task.Delay(0);
        }
Beispiel #2
0
 public static void SetProperties(ILogManager logger, SpContentJobManager jobManager, SPContentManager spServiceManager)
 {
     _logger          = logger;
     JobManager       = jobManager;
     SPServiceManager = spServiceManager;
 }