예제 #1
0
        public void UpdateCleanDataScheduler(DataSchedulerContract scheduler)
        {
            if (WebOperationContext.Current != null && WebOperationContext.Current.IncomingRequest.Method == "OPTIONS")
            {
                WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
                return;
            }

            if (scheduler.SchedulePeriod < TimeSpan.FromMinutes(20))
            {
                LogErrorMessage(ErrorMessage.ErorCode.SetObjectStatusError,
                                $"Period for data cleaning must be more then 10 min");
            }

            var serializer         = new RestSharpDataContractJsonSerializer();
            var serializedProperty = serializer.Serialize(scheduler);

            SetKeplerConfigProperty(scheduler.Name, serializedProperty);
        }
예제 #2
0
        public DataSchedulerContract GetCleanDataScheduler(string schedulerName)
        {
            // check scheduler name
            switch (schedulerName)
            {
            case "buildCleanScheduler":
            case "logCleanScheduler":
                break;

            default:
                LogErrorMessage(ErrorMessage.ErorCode.SetObjectStatusError,
                                $"Scheduler name {schedulerName} is not recognized. Possible values: buildCleanScheduler, logCleanScheduler");
                return(null);
            }

            var schedulerProperty = GetKeplerConfigProperty(schedulerName);

            if (!string.IsNullOrEmpty(schedulerProperty))
            {
                return(new RestSharpDataContractJsonDeserializer().Deserialize <DataSchedulerContract>(schedulerProperty));
            }

            // if scheduler is'n initialized (first time, when applications start)
            var scheduler = new DataSchedulerContract()
            {
                Name           = schedulerName,
                SchedulePeriod = TimeSpan.FromDays(30),
                NextStartTime  = DateTime.Now,
                HistoryItemsNumberToPreserve = 3
            };

            var serializer         = new RestSharpDataContractJsonSerializer();
            var serializedProperty = serializer.Serialize(scheduler);

            SetKeplerConfigProperty(schedulerName, serializedProperty);

            return(scheduler);
        }
예제 #3
0
 protected SerializationTest()
 {
     Serializer = new RestSharpDataContractJsonSerializer();
 }