Example #1
0
        public IAccountSettings Convert(ServiceAccount serviceAccount)
        {
            ExcelAccountSettings target = new ExcelAccountSettings();

            target.ID             = serviceAccount.ServiceAccountId;
            target.Name           = serviceAccount.ServiceAccountName;
            target.Source         = serviceAccount.Source;
            target.TestResult     = serviceAccount.TestResult;
            target.AccountVersion = serviceAccount.AccountVersion;
            target.MinUpdateTime  = serviceAccount.MinUpdateTime;

            target.Tokens   = new List <ExcelAccountToken>();
            target.Template = new List <ExcelAccountTemplate>();

            if (serviceAccount.Tokens.Count > 0)
            {
                foreach (Token token in serviceAccount.Tokens)
                {
                    ExcelAccountToken targetToken = new ExcelAccountToken();
                    targetToken = (ExcelAccountToken)targetToken.Convert(token);
                    target.Tokens.Add(targetToken);
                }
            }
            if (serviceAccount.MappingTemplates.Count > 0)
            {
                foreach (Template template in serviceAccount.MappingTemplates)
                {
                    ExcelAccountTemplate targetTemplate = new ExcelAccountTemplate();
                    targetTemplate = (ExcelAccountTemplate)targetTemplate.Convert(template);
                    target.Template.Add(targetTemplate);
                }
            }
            return(target);
        }
Example #2
0
        public Template Convert(IAccountTemplate template)
        {
            Template             target          = new Template();
            ExcelAccountTemplate currentTemplate = (ExcelAccountTemplate)template;

            target.TemplateName = currentTemplate.TemplateName;
            target.TemplateId   = currentTemplate.TemplateId;

            target.Mapping.Add("TaskID", currentTemplate.TaskID);
            target.Mapping.Add("SubtaskType", currentTemplate.SubtaskType);
            target.Mapping.Add("Summary", currentTemplate.Summary);
            target.Mapping.Add("Description", currentTemplate.Description);
            target.Mapping.Add("Status", currentTemplate.Status);
            target.Mapping.Add("Priority", currentTemplate.Priority);
            target.Mapping.Add("Product", currentTemplate.Product);
            target.Mapping.Add("Project", currentTemplate.Project);
            target.Mapping.Add("CreatedDate", currentTemplate.CreatedDate);
            target.Mapping.Add("CreatedBy", currentTemplate.CreatedBy);
            target.Mapping.Add("Source", currentTemplate.Source.ToString());
            target.Mapping.Add("Estimation", currentTemplate.Estimation);
            target.Mapping.Add("TargetVersion", currentTemplate.TargetVersion);
            target.Mapping.Add("Comments", currentTemplate.Comments);
            target.Mapping.Add("TaskParent", currentTemplate.TaskParent);
            target.Mapping.Add("Assigned", currentTemplate.Assigned);
            target.Mapping.Add("LinkToTracker", currentTemplate.LinkToTracker);



            for (int i = 0; i < currentTemplate.AllFieldsInFile.Count; i++)
            {
                target.Mapping.Add(String.Format("AllFieldsInFile{0}", i), currentTemplate.AllFieldsInFile[i]);
            }

            return(target);
        }
Example #3
0
        public IAccountSettings TestAccount(IAccountSettings testAccount)
        {
            currentAccount = (ExcelAccountSettings)testAccount;

            if (currentAccount.Template.Count > 0)
            {
                currentAccount.TestResult = TryReadTasksFromFile();
                return(currentAccount);
            }
            else
            {
                ExcelAccountTemplate newTemplate = new ExcelAccountTemplate();
                newTemplate.AllFieldsInFile = GetAllColumnsName(OpenExcelFromByteArray());

                if (newTemplate.AllFieldsInFile.Count > 0)
                {
                    currentAccount.TestResult = true;
                    currentAccount.Template.Add(newTemplate);
                }
                else
                {
                    currentAccount.TestResult = false;
                }

                return(currentAccount);
            }
        }
Example #4
0
        public IAccountTemplate Convert(Template template)
        {
            ExcelAccountTemplate targetTemplate = new ExcelAccountTemplate();

            targetTemplate.TemplateId   = template.TemplateId;
            targetTemplate.TemplateName = template.TemplateName;

            if (template.Mapping.Count > 0)
            {
                targetTemplate.TaskID = (from templ in template.Mapping
                                         where templ.Key == "TaskID"
                                         select templ.Value).SingleOrDefault();

                targetTemplate.SubtaskType = (from templ in template.Mapping
                                              where templ.Key == "SubtaskType"
                                              select templ.Value).SingleOrDefault();

                targetTemplate.Summary = (from templ in template.Mapping
                                          where templ.Key == "Summary"
                                          select templ.Value).SingleOrDefault();

                targetTemplate.Description = (from templ in template.Mapping
                                              where templ.Key == "Description"
                                              select templ.Value).SingleOrDefault();

                targetTemplate.Status = (from templ in template.Mapping
                                         where templ.Key == "Status"
                                         select templ.Value).SingleOrDefault();

                targetTemplate.Priority = (from templ in template.Mapping
                                           where templ.Key == "Priority"
                                           select templ.Value).SingleOrDefault();

                targetTemplate.Product = (from templ in template.Mapping
                                          where templ.Key == "Product"
                                          select templ.Value).SingleOrDefault();

                targetTemplate.Project = (from templ in template.Mapping
                                          where templ.Key == "Project"
                                          select templ.Value).SingleOrDefault();

                targetTemplate.CreatedDate = (from templ in template.Mapping
                                              where templ.Key == "CreatedDate"
                                              select templ.Value).SingleOrDefault();

                targetTemplate.CreatedBy = (from templ in template.Mapping
                                            where templ.Key == "CreatedBy"
                                            select templ.Value).SingleOrDefault();
                Sources sour;
                var     result = (from templ in template.Mapping
                                  where templ.Key == "Source"
                                  select templ.Value).SingleOrDefault();
                Enum.TryParse(result, out sour);
                targetTemplate.Source = sour;

                targetTemplate.LinkToTracker = (from templ in template.Mapping
                                                where templ.Key == "LinkToTracker"
                                                select templ.Value).SingleOrDefault();


                targetTemplate.TaskParent = (from templ in template.Mapping
                                             where templ.Key == "TaskParent"
                                             select templ.Value).SingleOrDefault();

                targetTemplate.Estimation = (from templ in template.Mapping
                                             where templ.Key == "Estimation"
                                             select templ.Value).SingleOrDefault();

                targetTemplate.TargetVersion = (from templ in template.Mapping
                                                where templ.Key == "TargetVersion"
                                                select templ.Value).SingleOrDefault();

                targetTemplate.Comments = (from templ in template.Mapping
                                           where templ.Key == "Comments"
                                           select templ.Value).SingleOrDefault();

                targetTemplate.Assigned = (from templ in template.Mapping
                                           where templ.Key == "Assigned"
                                           select templ.Value).SingleOrDefault();
            }
            return(targetTemplate);
        }
Example #5
0
        private void Write_list(List <KeyValuePair <String, String> > oneTask)
        {
            ExcelAccountTemplate template = currentAccount.Template.FirstOrDefault();

            if (template == null)
            {
                return;
            }
            TaskMain task = new TaskMain();

            task.TaskID = (from keyValue in oneTask
                           where keyValue.Key == template.TaskID
                           select keyValue.Value).SingleOrDefault <String>();

            task.Summary = (from keyValue in oneTask
                            where keyValue.Key == template.Summary
                            select keyValue.Value).SingleOrDefault <String>();

            task.SubtaskType = (from keyValue in oneTask
                                where keyValue.Key == template.SubtaskType
                                select keyValue.Value).SingleOrDefault <String>();

            task.Status = (from keyValue in oneTask
                           where keyValue.Key == template.Status
                           select keyValue.Value).SingleOrDefault <String>();

            task.Priority = (from keyValue in oneTask
                             where keyValue.Key == template.Priority
                             select keyValue.Value).SingleOrDefault <String>();

            task.CreatedDate = (from keyValue in oneTask
                                where keyValue.Key == template.CreatedDate
                                select keyValue.Value).SingleOrDefault <String>();

            task.CreatedBy = (from keyValue in oneTask
                              where keyValue.Key == template.CreatedBy
                              select keyValue.Value).SingleOrDefault <String>();

            task.Description = (from keyValue in oneTask
                                where keyValue.Key == template.Description
                                select keyValue.Value).SingleOrDefault <String>();

            task.Product = (from keyValue in oneTask
                            where keyValue.Key == template.Product
                            select keyValue.Value).SingleOrDefault <String>();

            task.Project = (from keyValue in oneTask
                            where keyValue.Key == template.Project
                            select keyValue.Value).SingleOrDefault <String>();

            task.Estimation = (from keyValue in oneTask
                               where keyValue.Key == template.Estimation
                               select keyValue.Value).SingleOrDefault <String>();

            task.TargetVersion = (from keyValue in oneTask
                                  where keyValue.Key == template.TargetVersion
                                  select keyValue.Value).SingleOrDefault <String>();

            task.Comments = (from keyValue in oneTask
                             where keyValue.Key == template.Comments
                             select keyValue.Value).SingleOrDefault <String>();

            var parentTask = (from keyValue in oneTask
                              where keyValue.Key == template.TaskParent
                              select keyValue.Value).SingleOrDefault <String>();

            if (!String.IsNullOrEmpty(parentTask))
            {
                parentTasks.Add(task.TaskID, parentTask);
            }

            var assigned = (from keyValue in oneTask
                            where keyValue.Key == template.Assigned
                            select keyValue.Value).SingleOrDefault <String>();

            if (!String.IsNullOrEmpty(assigned))
            {
                UserDAO user = UserDAO.FindUserFromDBByName(assigned);
                if (user != null)
                {
                    task.Assigned.Add(ConverterDAOtoDomain.UserDaoToUser(user));
                }
            }

            task.LinkToTracker = (from token in currentAccount.Tokens
                                  where token.TokenId == tokenID
                                  select token.TokenName).SingleOrDefault();


            task.Source = Sources.Excel;

            task.TokenID = tokenID;

            list_task.Add(task);
        }