Example #1
0
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            GoogleSheetsAccountSettings target = new GoogleSheetsAccountSettings();

            target.ID             = serviceAccount.ServiceAccountId;
            target.Name           = serviceAccount.ServiceAccountName;
            target.Source         = serviceAccount.Source;
            target.Tokens         = new List <GoogleSheetsAccountToken>();
            target.Template       = new List <GoogleSheetsAccountTemplate>();
            target.MinUpdateTime  = serviceAccount.MinUpdateTime;
            target.AccountVersion = serviceAccount.AccountVersion;

            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken();
                    targetToken = (GoogleSheetsAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            if (serviceAccount.MappingTemplates.Length > 0)
            {
                foreach (TemplateDTO template in serviceAccount.MappingTemplates)
                {
                    GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate();
                    targetTemplate = (GoogleSheetsAccountTemplate)targetTemplate.ConvertFromDAO(template);
                    target.Template.Add(targetTemplate);
                }
            }
            return(target);
        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            String newTemplateName = TemplateNameTextBox.Text.Trim();

            if (newTemplateName != String.Empty && MappingDataView.Rows.Count > 0)
            {
                GoogleSheetsAccountTemplate googleSheetsAccountTemplate = new GoogleSheetsAccountTemplate();

                String mapstr = "";
                for (int i = 0; i < MappingDataView.Rows.Count - 1; i++)
                {
                    mapstr += "[" + MappingDataView.Rows[i].Cells[0].Value.ToString() + "-";
                    mapstr += MappingDataView.Rows[i].Cells[1].Value.ToString() + "]";
                }
                googleSheetsAccountTemplate.Mapping      = mapstr;
                googleSheetsAccountTemplate.TemplateName = newTemplateName;
                googleSheetsAccountSettings.Template.Add(googleSheetsAccountTemplate);
                if (SettingsManager.SaveOrUpdateAccount(googleSheetsAccountSettings))
                {
                    RefreshMapSetting();
                }
                else
                {
                    label13.Text = "Error! Please try again";
                }
            }
            else
            {
                label13.Text      = "Name can not be empty string";
                label13.ForeColor = Color.Red;
            }

            TemplateNameTextBox.Text = "";
            groupBox2.Visible        = false;
        }
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            GoogleSheetsAccountSettings target = new GoogleSheetsAccountSettings();
            target.ID = serviceAccount.ServiceAccountId;
            target.Name = serviceAccount.ServiceAccountName;
            target.Source = serviceAccount.Source;
            target.Tokens = new List<GoogleSheetsAccountToken>();
            target.Template = new List<GoogleSheetsAccountTemplate>();
            target.MinUpdateTime = serviceAccount.MinUpdateTime;
            target.AccountVersion = serviceAccount.AccountVersion;

            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken();
                    targetToken = (GoogleSheetsAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            if (serviceAccount.MappingTemplates.Length > 0)
            {
                foreach (TemplateDTO template in serviceAccount.MappingTemplates)
                {
                    GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate();
                    targetTemplate = (GoogleSheetsAccountTemplate)targetTemplate.ConvertFromDAO(template);
                    target.Template.Add(targetTemplate);
                }
            }
            return target;
        }
Example #4
0
        public IAccountTemplate ConvertFromDAO(TemplateDTO template)
        {
            GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate();

            targetTemplate.TemplateId   = template.TemplateId;
            targetTemplate.TemplateName = template.TemplateName;
            if (template.Mapping.Length > 0)
            {
                targetTemplate.Mapping = (from tok in template.Mapping
                                          where tok.Key == "Mapping"
                                          select tok.Value).SingleOrDefault();
            }

            return(targetTemplate);
        }
 private void ActivateTemplateButton_Click(object sender, EventArgs e)
 {
     if (TemplateComboBox.SelectedItem != null) // допилить!
     {
         IAccountSettings result = userGoogleAccounts.SingleOrDefault(x => x.Name == accName);
         if (SettingsManager.GetDetailsForAccount(loggedUser, result.ID) != null)
         {
             googleSheetsAccountSettings = (GoogleSheetsAccountSettings)SettingsManager.GetDetailsForAccount(loggedUser, result.ID);
         }
         // [a1-b1][a2-b2]...[an-bn]
         if (googleSheetsAccountSettings.Tokens.Count > 0)
         {
             googleSheetsAccountTemplate = googleSheetsAccountSettings.Template.SingleOrDefault(x => x.TemplateName == TemplateComboBox.SelectedItem.ToString());
             //googleSheetsAccountTemplate
         }
     }
 }
Example #6
0
        public TemplateDTO ConvertToDAO(IAccountTemplate template)
        {
            TemplateDTO target = new TemplateDTO();
            GoogleSheetsAccountTemplate currentTemplate = (GoogleSheetsAccountTemplate)template;

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

            MappingForSerialization map = new MappingForSerialization();

            map.Key   = "Mapping";
            map.Value = currentTemplate.Mapping;
            mappingList.Add(map);

            target.Mapping = mappingList.ToArray();
            return(target);
        }
        public IAccountTemplate ConvertFromDAO(TemplateDTO template)
        {
            GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate();
            targetTemplate.TemplateId = template.TemplateId;
            targetTemplate.TemplateName = template.TemplateName;
            if (template.Mapping.Length > 0)
            {
                targetTemplate.Mapping = (from tok in template.Mapping
                                          where tok.Key == "Mapping"
                                          select tok.Value).SingleOrDefault();
            }

            return targetTemplate;
        }