Esempio n. 1
0
        public CallAnswer Execute()
        {
            var today      = DateTime.Today;
            var lowerLimit = today - TimeSpan.FromDays(365 * 2);

            var(folder, date) = CallFolderManager.GetAllDefinitionCalls(FolderPath).FirstOrDefault(call => call.Date <= today);
            if (date < lowerLimit)
            {
                return(CallAnswer.NoCallToAnswerFound);
            }

            var definition   = SimplePC.GetCurrentMachineDefinition();
            var fileName     = $"{definition.Name}.{definition.Domain}.json";
            var fileFullPath = Path.Combine(folder.FullName, fileName);

            if (File.Exists(fileFullPath))
            {
                if (Repeat)
                {
                    var number = 1;
                    do
                    {
                        fileName     = $"{definition.Name}.{definition.Domain}#{number}.json";
                        fileFullPath = Path.Combine(folder.FullName, fileName);
                        number++;
                    } while (File.Exists(fileFullPath));
                }
                else
                {
                    return(CallAnswer.LastCallAlreadyAnswered);
                }
            }

            definition.WriteToFile(fileFullPath);
            return(CallAnswer.CallAnswered);
        }
Esempio n. 2
0
 public CreateResult Execute() => CallFolderManager.CreateNewDefinitionCall(FolderPath, (UsedDate = ResultingDate).Value);