Ejemplo n.º 1
0
        public ServiceAccount Convert(IAccountSettings serviceAccount)
        {
            ServiceAccount       target         = new ServiceAccount();
            ExcelAccountSettings currentAccount = (ExcelAccountSettings)serviceAccount;

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

            List <Token>    tok   = new List <Token>();
            List <Template> templ = new List <Template>();

            if (currentAccount.Tokens.Count > 0)
            {
                foreach (ExcelAccountToken token in currentAccount.Tokens)
                {
                    Token localtok = token.Convert(token);
                    tok.Add(localtok);
                }
                target.Tokens = tok;
            }
            if (currentAccount.Template.Count > 0)
            {
                foreach (ExcelAccountTemplate template in currentAccount.Template)
                {
                    Template localtemp = template.Convert(template);
                    templ.Add(localtemp);
                }
                target.MappingTemplates = templ;
            }
            return(target);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
0
        public bool Equals(IAccountSettings other)
        {
            if (other is ExcelAccountSettings)

            {
                ExcelAccountSettings account = (ExcelAccountSettings)other;
                return(this.ID.Equals(account.ID) &&
                       this.AccountVersion.Equals(account.AccountVersion));
            }
            return(false);
        }
Ejemplo n.º 5
0
 public ExcelAdapter(Byte[] bytes, Int32 tokID)
 {
     excelPackegInBytes = bytes;
     currentAccount     = (ExcelAccountSettings)SettingsManager.GetAccountByTokenID(tokID);
     tokenID            = tokID;
 }
Ejemplo n.º 6
0
 public ExcelAdapter(IAccountSettings account, Byte[] bytes)
 {
     currentAccount     = (ExcelAccountSettings)account;
     excelPackegInBytes = bytes;
 }