示例#1
0
        public void CreateTask(ITaskDTO taskData)
        {
            NameSpace ns = null;

            try {
                var application = new Application();
                ns = application.GetNamespace("mapi");
                ns.Logon("Outlook", Missing.Value, false, true);

                var task = application.CreateItem(OlItemType.olTaskItem) as TaskItem;

                if (task != null)
                {
                    task.Assign();
                    task.Subject    = taskData.Subject;
                    task.DueDate    = taskData.DueDate;
                    task.StartDate  = taskData.DueDate;
                    task.Categories = string.Join(";", taskData.Tags.ToArray());
                    task.Importance = GetOutlookPriority(taskData.Importance);
                    task.Save();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            finally {
                if (ns != null)
                {
                    ns.Logoff();
                }
            }
        }
示例#2
0
        public APIResponse <TaskDTO> CreateTask(ITaskDTO dto)
        {
            var input  = dto.Serialize();
            var result = this.Client.CreateTask(input);

            return(result.DeserializeAsResponse <TaskDTO>());
        }
示例#3
0
        public APIResponse <MailDTO> SendMail(IMailDTO mailDTO, ITaskDTO taskDTO)
        {
            var inputMail = mailDTO.Serialize();
            var inputTask = taskDTO.Serialize();
            var result    = this.Client.SendMail(inputMail, inputTask);

            return(result.DeserializeAsResponse <MailDTO>());
        }
示例#4
0
        public APIResponse <ProtocolDTO> InsertProtocol(IProtocolDTO protocolDTO, ITaskDTO taskDTO)
        {
            var inputProtocol = protocolDTO.Serialize();
            var inputTask     = taskDTO.Serialize();
            var result        = this.Client.InsertProtocol(inputProtocol, inputTask);

            return(result.DeserializeAsResponse <ProtocolDTO>());
        }
示例#5
0
        private IRestResponse <TrelloCard> CreateCard(ITaskDTO taskData, RestClient client)
        {
            IRestRequest createCardRequest = new RestRequest(TrelloConfig.Resourses.Cards);

            createCardRequest.Method = Method.POST;
            createCardRequest.AddParameter(TrelloConfig.ParameterNames.Name, taskData.Subject);
            createCardRequest.AddParameter(TrelloConfig.ParameterNames.IdList, TrelloConfig.ListId);
            SetKeyAndTokenParametersOnRequest(createCardRequest);

            IRestResponse <TrelloCard> createResponse = client.Execute <TrelloCard>(createCardRequest);

            return(createResponse);
        }
示例#6
0
        public void CreateTask(ITaskDTO taskData)
        {
            var client = new RestClient("https://api.trello.com/1");

            IRestResponse <TrelloCard> createResponse = CreateCard(taskData, client);

            if (createResponse.StatusCode == HttpStatusCode.Unauthorized)
            {
                Process.Start(
                    string.Format(
                        "https://trello.com/1/authorize?key={0}&name=CreateTask&expiration=1day&response_type=token&scope=read,write",
                        TrelloConfig.Key));

                string newToken = null;
                if (
                    InputBox.Show("Token not valid", "Allow the new token in your webbrowser and paste it in here.", ref newToken) ==
                    DialogResult.OK)
                {
                    TrelloConfig.WriteToken(newToken);
                    createResponse = CreateCard(taskData, client);
                }
                else
                {
                    MessageBox.Show("Exiting CreateTask", "Exiting", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            TrelloCard    card        = createResponse.Data;
            string        label       = "orange"; //Un-prioratized
            IRestResponse labelResult = AddLabelToCard(card, label, client);

            foreach (string tag in taskData.Tags)
            {
                string labelColor = TrelloLabelToColorMapper.MapColor(tag);
                AddLabelToCard(card, labelColor, client);
            }

            IRestRequest dueDateReq = new RestRequest(string.Format("{0}/{1}/due", TrelloConfig.Resourses.Cards, card.id));

            dueDateReq.Method = Method.PUT;
            SetKeyAndTokenParametersOnRequest(dueDateReq);
            dueDateReq.AddParameter(TrelloConfig.ParameterNames.Value, taskData.DueDate.ToString(CultureInfo.InvariantCulture));

            IRestResponse dueResp = client.Execute(dueDateReq);

            //TODO: Verify status else throw exception
        }
示例#7
0
        public void CreateTask(ITaskDTO taskData)
        {
            var client = new RestClient("https://api.trello.com/1");

              IRestResponse<TrelloCard> createResponse = CreateCard(taskData, client);

              if (createResponse.StatusCode == HttpStatusCode.Unauthorized) {
            Process.Start(
              string.Format(
            "https://trello.com/1/authorize?key={0}&name=CreateTask&expiration=1day&response_type=token&scope=read,write",
            TrelloConfig.Key));

            string newToken = null;
            if (
              InputBox.Show("Token not valid", "Allow the new token in your webbrowser and paste it in here.", ref newToken) ==
              DialogResult.OK) {
              TrelloConfig.WriteToken(newToken);
              createResponse = CreateCard(taskData, client);
            }
            else {
              MessageBox.Show("Exiting CreateTask", "Exiting", MessageBoxButtons.OK, MessageBoxIcon.Information);
              return;
            }
              }

              TrelloCard card = createResponse.Data;
              string label = "orange"; //Un-prioratized
              IRestResponse labelResult = AddLabelToCard(card, label, client);

              foreach (string tag in taskData.Tags) {
            string labelColor = TrelloLabelToColorMapper.MapColor(tag);
            AddLabelToCard(card, labelColor, client);
              }

              IRestRequest dueDateReq = new RestRequest(string.Format("{0}/{1}/due", TrelloConfig.Resourses.Cards, card.id));
              dueDateReq.Method = Method.PUT;
              SetKeyAndTokenParametersOnRequest(dueDateReq);
              dueDateReq.AddParameter(TrelloConfig.ParameterNames.Value, taskData.DueDate.ToString(CultureInfo.InvariantCulture));

              IRestResponse dueResp = client.Execute(dueDateReq);

              //TODO: Verify status else throw exception
        }
示例#8
0
        public void CreateTask_ReturnsCorrect_DueDateAndSubjectAndTags()
        {
            string[] args = "Köp vin till festen -p -tm".Split(' ');

            var argumentsParserMock = new Mock <IArgumentParser>();

            argumentsParserMock.Setup(a => a.GetSubject(It.IsAny <string[]>())).Returns("Köp vin till festen");

            var optionsParserMock = new Mock <IOptionsParser>();

            optionsParserMock.SetupGet(o => o.DueDate).Returns(DateTime.Parse("2012-11-16"));
            optionsParserMock.SetupGet(o => o.Tags).Returns(new List <string> {
                "Personal"
            });

            ITaskBuilder tb = new TaskBuilder(args, argumentsParserMock.Object, optionsParserMock.Object);

            ITaskDTO task = tb.CreateTask();

            Assert.Equal(DateTime.Parse("2012-11-16"), task.DueDate);
            Assert.Equal("Köp vin till festen", task.Subject);
            argumentsParserMock.VerifyAll();
            optionsParserMock.VerifyAll();
        }
示例#9
0
        private static void Main(string[] args)
        {
            ContainerBootstrapper.BootstrapStructureMap(args);

            IContainer           container    = ObjectFactory.Container;
            IList <ITaskManager> taskManagers = container.GetAllInstances <ITaskManager>();

            if (ShouldUsageBeShown(args))
            {
                ShowUsage(taskManagers);
                return;
            }

            var argumentParser = ObjectFactory.GetInstance <IArgumentParser>();
            var optionParser   = ObjectFactory.GetInstance <IOptionsParser>();

            ITaskBuilder taskBuilder = new TaskBuilder(args, argumentParser, optionParser);
            ITaskDTO     taskDto     = taskBuilder.CreateTask();
            bool         taskCreated = false;

            ITaskManager taskManagerToRun = ProviderMatcher.GetMatchingTaskManager(args, taskManagers);

            taskManagerToRun.CreateTask(taskDto);
        }
示例#10
0
 public virtual T VisitTask(ITaskDTO task)
 {
     return(VisitAssignable(task));
 }
示例#11
0
        private IRestResponse<TrelloCard> CreateCard(ITaskDTO taskData, RestClient client)
        {
            IRestRequest createCardRequest = new RestRequest(TrelloConfig.Resourses.Cards);
              createCardRequest.Method = Method.POST;
              createCardRequest.AddParameter(TrelloConfig.ParameterNames.Name, taskData.Subject);
              createCardRequest.AddParameter(TrelloConfig.ParameterNames.IdList, TrelloConfig.ListId);
              SetKeyAndTokenParametersOnRequest(createCardRequest);

              IRestResponse<TrelloCard> createResponse = client.Execute<TrelloCard>(createCardRequest);
              return createResponse;
        }