コード例 #1
0
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            ExcelAccountSettings target = new ExcelAccountSettings();

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

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

            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    ExcelAccountToken targetToken = new ExcelAccountToken();
                    targetToken = (ExcelAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            if (serviceAccount.MappingTemplates.Length > 0)
            {
                foreach (TemplateDTO template in serviceAccount.MappingTemplates)
                {
                    ExcelAccountTemplate targetTemplate = new ExcelAccountTemplate();
                    targetTemplate = (ExcelAccountTemplate)targetTemplate.ConvertFromDAO(template);
                    target.Template.Add(targetTemplate);
                }
            }
            return(target);
        }
コード例 #2
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            if (txtNewTemplateName.Text.Trim() != String.Empty && rtxtMapping.Text.Trim() != String.Empty)
            {
                ExcelAccountTemplate accEx_template = new ExcelAccountTemplate();

                accEx_template = Acc_ExcelMapping();
                accEx_template.TemplateName = txtNewTemplateName.Text.Trim();
                userExcelFullAccount.Template.Add(accEx_template);
                if (SettingsManager.SaveOrUpdateAccount(userExcelFullAccount))
                {
                    ExcelSynchronizer.UpdateWatchibleFiles();
                    ExcelTab.SelectTab(Settings);
                    RefreshMapSetting();
                    btn_AddNewExcelTemplate.Enabled = false;
                    btn_delete_template.Enabled     = true;

                    dataGrid_mapping.RowCount        = 1;
                    dataGrid_mapping.Rows[0].Visible = true;  //не обязательно (если в datagridview не скрывается срока)
                    for (int i = 0; i < dataGrid_mapping.ColumnCount; i++)
                    {
                        dataGrid_mapping[i, 0].Value = null;
                    }
                }
            }
            else
            {
                label5.Show();
                label5.Text      = "Please enter token name and mapping!";
                label5.ForeColor = Color.Red;
            }
        }
コード例 #3
0
        private void btn_delete_template_Click(object sender, EventArgs e)
        {
            if (comboBox_ExcelTemplate.SelectedItem != null)
            {
                ExcelAccountTemplate templateToDelete = userExcelFullAccount.Template.FirstOrDefault();
                if (templateToDelete != null)
                {
                    if (SettingsManager.DeleteTemplate(templateToDelete))
                    {
                        ExcelSynchronizer.UpdateWatchibleFiles();
                        RefreshMapSetting();
                        comboBox_ExcelTemplate.Text = "";

                        btn_AddNewExcelTemplate.Enabled = true;
                        btn_delete_template.Enabled     = false;
                    }
                }


                dataGrid_mapping.RowCount        = 1;
                dataGrid_mapping.Rows[0].Visible = true;  //не обязательно (если в datagridview не скрывается срока)
                for (int i = 0; i < dataGrid_mapping.ColumnCount; i++)
                {
                    dataGrid_mapping[i, 0].Value = null;
                }
            }
        }
コード例 #4
0
        private void FillDataGridWithExistingMapping()
        {
            Dictionary <String, String> templateMapping = new Dictionary <String, String>();
            ExcelAccountTemplate        template        = userExcelFullAccount.Template.FirstOrDefault();

            if (template == null)
            {
                template = new ExcelAccountTemplate();
                FillDataGridWithEmptyMapping(template.AllFieldsInTeemplate);
                return;
            }

            templateMapping = userExcelFullAccount.Template.FirstOrDefault().Mapping;
            List <string> field = templateMapping.Values.Select(value => value).Where(str => !String.IsNullOrEmpty(str)).ToList();

            for (int i = 0; i < templateMapping.Count; i++)
            {
                if (dataGrid_mapping.Rows.Count < templateMapping.Count)
                {
                    dataGrid_mapping.Rows.Add();
                }
                DataGridViewTextBoxCell Cell_Template =
                    (DataGridViewTextBoxCell)dataGrid_mapping.Rows[i].Cells[1];
                Cell_Template.Value = templateMapping.ElementAt(i).Key;

                if (templateMapping.Count > 0)
                {
                    DataGridViewComboBoxCell comboCell_ITask = (DataGridViewComboBoxCell)dataGrid_mapping.Rows[i].Cells[0];
                    comboCell_ITask.DataSource = field;
                    comboCell_ITask.Value      = templateMapping.ElementAt(i).Value;
                }
                else
                {
                    DataGridViewComboBoxCell comboCell_ITask = (DataGridViewComboBoxCell)dataGrid_mapping.Rows[i].Cells[0];
                    comboCell_ITask.DataSource = field;
                    comboCell_ITask.Value      = "";
                }
            }
        }
コード例 #5
0
        private List <String> Import(string file, out ExcelAccountSettings result)
        {
            IAccountSettings     setingForTest;
            ExcelAccountSettings testAcc = new ExcelAccountSettings();

            Byte[] fileInByteArray = testAcc.OpenExcelFileAndReturnByteArray(new AuthorizationResult(true, loggedUser), file);
            if (fileInByteArray == null)
            {
                result = null;
                return(null);
            }
            SettingsManager.AccountSettingsTest(testAcc, fileInByteArray, out setingForTest);
            if (setingForTest != null)
            {
                ExcelAccountSettings resultFromServices = (ExcelAccountSettings)setingForTest;
                ExcelAccountTemplate template           = new ExcelAccountTemplate();
                template = resultFromServices.Template.FirstOrDefault();
                result   = (ExcelAccountSettings)setingForTest;
                return(template.AllFieldsInFile);
            }
            result = null;;
            return(null);
        }
コード例 #6
0
        private void btnChekMapping_Click(object sender, EventArgs e)
        {
            IAccountSettings     testAccRessult;
            ExcelAccountSettings testAcc        = new ExcelAccountSettings();
            ExcelAccountTemplate accEx_template = new ExcelAccountTemplate();

            accEx_template = Acc_ExcelMapping();
            accEx_template.TemplateName = txtNewTemplateName.Text.Trim();

            testAcc.Template.Add(accEx_template);
            if (SettingsManager.AccountSettingsTest(testAcc, testAcc.OpenExcelFileAndReturnByteArray(new AuthorizationResult(true, loggedUser),
                                                                                                     cmbTokens.SelectedItem.ToString()), out testAccRessult))
            {
                btnSaveSettings.Enabled = true;
                label5.Hide();
            }
            else
            {
                btnSaveSettings.Enabled = false;
                label5.Show();
                label5.Text      = "Cant read from file!";
                label5.ForeColor = Color.Red;
            }
        }
コード例 #7
0
        public TemplateDTO ConvertToDAO(IAccountTemplate template)
        {
            TemplateDTO          target          = new TemplateDTO();
            ExcelAccountTemplate currentTemplate = (ExcelAccountTemplate)template;

            target.TemplateName = currentTemplate.TemplateName;
            target.TemplateId   = currentTemplate.TemplateId;
            List <MappingForSerialization> mapList = new List <MappingForSerialization>();

            MappingForSerialization task_ID = new MappingForSerialization();

            task_ID.Key   = "TaskID";
            task_ID.Value = currentTemplate.TaskID;
            mapList.Add(task_ID);

            MappingForSerialization subtaskType = new MappingForSerialization();

            subtaskType.Key   = "SubtaskType";
            subtaskType.Value = currentTemplate.SubtaskType;
            mapList.Add(subtaskType);

            MappingForSerialization summary = new MappingForSerialization();

            summary.Key   = "Summary";
            summary.Value = currentTemplate.Summary;
            mapList.Add(summary);

            MappingForSerialization description = new MappingForSerialization();

            description.Key   = "Description";
            description.Value = currentTemplate.Description;
            mapList.Add(description);

            MappingForSerialization status = new MappingForSerialization();

            status.Key   = "Status";
            status.Value = currentTemplate.Status;
            mapList.Add(status);

            MappingForSerialization priority = new MappingForSerialization();

            priority.Key   = "Priority";
            priority.Value = currentTemplate.Priority;
            mapList.Add(priority);

            MappingForSerialization product = new MappingForSerialization();

            product.Key   = "Product";
            product.Value = currentTemplate.Product;
            mapList.Add(product);

            MappingForSerialization project = new MappingForSerialization();

            project.Key   = "Project";
            project.Value = currentTemplate.Project;
            mapList.Add(project);

            MappingForSerialization createdDate = new MappingForSerialization();

            createdDate.Key   = "CreatedDate";
            createdDate.Value = currentTemplate.CreatedDate;
            mapList.Add(createdDate);

            MappingForSerialization createdBy = new MappingForSerialization();

            createdBy.Key   = "CreatedBy";
            createdBy.Value = currentTemplate.CreatedBy;
            mapList.Add(createdBy);

            MappingForSerialization linkTotracker = new MappingForSerialization();

            linkTotracker.Key   = "LinkToTracker";
            linkTotracker.Value = currentTemplate.LinkToTracker;
            mapList.Add(linkTotracker);

            MappingForSerialization estimation = new MappingForSerialization();

            estimation.Key   = "Estimation";
            estimation.Value = currentTemplate.Estimation;
            mapList.Add(estimation);

            MappingForSerialization targetVersion = new MappingForSerialization();

            targetVersion.Key   = "TargetVersion";
            targetVersion.Value = currentTemplate.TargetVersion;
            mapList.Add(targetVersion);

            MappingForSerialization comments = new MappingForSerialization();

            comments.Key   = "Comments";
            comments.Value = currentTemplate.Comments;
            mapList.Add(comments);

            MappingForSerialization taskParent = new MappingForSerialization();

            taskParent.Key   = "TaskParent";
            taskParent.Value = currentTemplate.TaskParent;
            mapList.Add(taskParent);

            MappingForSerialization assigned = new MappingForSerialization();

            assigned.Key   = "Assigned";
            assigned.Value = currentTemplate.Assigned;
            mapList.Add(assigned);

            MappingForSerialization source = new MappingForSerialization();

            source.Key   = "Source";
            source.Value = currentTemplate.Source.ToString();
            mapList.Add(source);

            target.Mapping = mapList.ToArray();
            return(target);
        }
コード例 #8
0
        public IAccountTemplate ConvertFromDAO(TemplateDTO template)
        {
            ExcelAccountTemplate targetTemplate = new ExcelAccountTemplate();

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

            if (template.Mapping.Length > 0)
            {
                var resultMapping = from customAtrib in template.Mapping
                                    where !customAtrib.Key.Contains("AllFieldsInFile")
                                    select customAtrib;

                foreach (MappingForSerialization map in resultMapping)
                {
                    targetTemplate.Mapping.Add(map.Key, map.Value);
                }

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


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

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

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

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

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

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

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

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

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

                targetTemplate.CreatedBy = (from templ in template.Mapping
                                            where templ.Key == "CreatedBy"
                                            select templ.Value).SingleOrDefault();
                if (targetTemplate.CreatedBy == null)
                {
                    targetTemplate.CreatedBy = "";
                }

                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();
                if (targetTemplate.LinkToTracker == null)
                {
                    targetTemplate.LinkToTracker = "";
                }

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

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

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

                targetTemplate.Assigned = (from templ in template.Mapping
                                           where templ.Key == "Assigned"
                                           select templ.Value).SingleOrDefault();
                if (targetTemplate.Assigned == null)
                {
                    targetTemplate.Assigned = "";
                }


                var resultStrings = from customAtrib in template.Mapping
                                    where customAtrib.Key.Contains("AllFieldsInFile")
                                    select customAtrib.Value;

                targetTemplate.AllFieldsInFile.AddRange(resultStrings);
            }
            return(targetTemplate);
        }
コード例 #9
0
        private ExcelAccountTemplate Acc_ExcelMapping()
        {
            ExcelAccountTemplate accEx_template;

            if (userExcelFullAccount.Template.Count > 0)
            {
                accEx_template = userExcelFullAccount.Template.FirstOrDefault();
            }
            else
            {
                accEx_template = new ExcelAccountTemplate();
            }

            for (int i = 0; i < dataGrid_mapping.Rows.Count - 1; i++)
            {
                DataGridViewComboBoxCell comboCell_file =
                    (DataGridViewComboBoxCell)dataGrid_mapping.Rows[i].Cells[0];
                DataGridViewTextBoxCell combotxtCell =
                    (DataGridViewTextBoxCell)dataGrid_mapping.Rows[i].Cells[1];
                String cellValue  = comboCell_file.Value.ToString();
                String fieldValue = combotxtCell.Value.ToString();
                cellValue = cellValue ?? "";

                if (fieldValue == "TaskID")
                {
                    accEx_template.TaskID = cellValue;
                    continue;
                }
                if (fieldValue == "SubtaskType")
                {
                    accEx_template.SubtaskType = cellValue;
                    continue;
                }
                if (fieldValue == "Summary")
                {
                    accEx_template.Summary = cellValue;
                    continue;
                }
                if (fieldValue == "Description")
                {
                    accEx_template.Description = cellValue;
                    continue;
                }
                if (fieldValue == "Status")
                {
                    accEx_template.Status = cellValue;
                    continue;
                }
                if (fieldValue == "Priority")
                {
                    accEx_template.Priority = cellValue;
                    continue;
                }
                if (fieldValue == "Project")
                {
                    accEx_template.Project = cellValue;
                    continue;
                }
                if (fieldValue == "CreatedDate")
                {
                    accEx_template.CreatedDate = cellValue;
                    continue;
                }
                if (fieldValue == "CreatedBy")
                {
                    accEx_template.CreatedBy = cellValue;
                    continue;
                }
                if (fieldValue == "LinkToTracker")
                {
                    accEx_template.LinkToTracker = cellValue;
                    continue;
                }
                if (fieldValue == "Source")
                {
                    accEx_template.Source = Sources.Excel;
                    continue;
                }
                if (fieldValue == "Estimation")
                {
                    accEx_template.Estimation = cellValue;
                    continue;
                }
                if (fieldValue == "TargetVersion")
                {
                    accEx_template.TargetVersion = cellValue;
                    continue;
                }
                if (fieldValue == "Comments")
                {
                    accEx_template.Comments = cellValue;
                    continue;
                }
                if (fieldValue == "TaskParent")
                {
                    accEx_template.TaskParent = cellValue;
                    continue;
                }
                if (fieldValue == "Assigned")
                {
                    accEx_template.Assigned = cellValue;
                    continue;
                }
            }
            return(accEx_template);
        }