示例#1
0
        public (FileUploadConfig, string, string) GenerateConvertDirs(string datastoreName, string savedFileName, string scenario)
        {
            FileUploadConfig uploadConfig    = this.dataLoader.GetUploadConfig();
            PersistanceType  persistanceType = this.dataLoader.GetPersistanceType();
            FilePathConfig   filePathConfig  = this.dataLoader.GetFilePathConfig();

            string excelDir = uploadConfig.ExcelDir;

            string pythonArgs = "--configPath \"" + uploadConfig.ColorConfigPath + "\" ";

            pythonArgs += " --srcPaths ";

            pythonArgs += "\"" + excelDir + Path.DirectorySeparatorChar + savedFileName + "\" ";


            pythonArgs += " --scenarios ";


            pythonArgs += "\"" + scenario + "\" ";

            string targetDir = null;

            if (persistanceType == PersistanceType.File && filePathConfig != null)
            {
                targetDir = filePathConfig.RootPath + Path.DirectorySeparatorChar + datastoreName;
            }
            else
            {
                targetDir = excelDir + Path.DirectorySeparatorChar + DateTime.Now.ToString("MMddyyyyHHmmss");
            }

            pythonArgs += " --destPath \"" + targetDir + "\" ";

            return(uploadConfig, pythonArgs, targetDir);
        }
示例#2
0
 public static bool SetCredentials(
     string target, string username, string password, PersistanceType persistenceType)
 {
     return(new Credential {
         Target = target, Username = username,
         Password = password, PersistanceType = persistenceType
     }.Save());
 }
示例#3
0
        /**
         *
         */
        public void SetCredential(string password, PersistanceType persistanceType)
        {
            _credential.Username = _credential.Target;
            _credential.Password = password;

            _credential.PersistanceType = persistanceType;

            _credential.Save();
        }
示例#4
0
 public Credential(string username, string password, string target, CredentialType type)
 {
     Username        = username;
     Password        = password;
     Target          = target;
     Type            = type;
     PersistanceType = PersistanceType.Session;
     _lastWriteTime  = DateTime.MinValue;
 }
示例#5
0
 public static bool SetCredentials(
     string target, string username, string password, PersistanceType persistenceType = PersistanceType.Enterprise)
 {
     return(new Credential
     {
         Target = target,
         Username = username,
         Password = password,
         PersistanceType = persistenceType,
         Type = CredentialType.Generic
     }.Save());
 }
示例#6
0
 internal void LoadInternal(NativeMethods.CREDENTIAL credential)
 {
     Username = credential.UserName;
     if (credential.CredentialBlobSize > 0)
     {
         Password = Marshal.PtrToStringUni(credential.CredentialBlob, credential.CredentialBlobSize / 2);
     }
     Target           = credential.TargetName;
     Type             = (CredentialType)credential.Type;
     PersistanceType  = (PersistanceType)credential.Persist;
     Description      = credential.Comment;
     LastWriteTimeUtc = DateTime.FromFileTimeUtc(credential.LastWritten);
 }
示例#7
0
 internal CredentialOutput(
     CredentialType credentialType,
     string targetName,
     string comment,
     DateTime lastWriteTimeUtc,
     string password,
     PersistanceType persistanceType,
     string userName)
 {
     CredentialType   = credentialType;
     TargetName       = targetName;
     Comment          = comment;
     LastWriteTimeUtc = lastWriteTimeUtc;
     Password         = password;
     PersistanceType  = persistanceType;
     UserName         = userName;
 }
示例#8
0
        protected override void Execute(NativeActivityContext context)
        {
            try
            {
                string          userName        = UserName.Get(context);
                string          password        = Password.Get(context);
                string          applicationName = ApplicationName.Get(context);
                bool            result          = false;
                PersistanceType pt = new PersistanceType();
                if (PersistType == "LocalComputer")
                {
                    pt = PersistanceType.LocalComputer;
                }
                else if (PersistType == "Enterprise")
                {
                    pt = PersistanceType.Enterprise;
                }
                else if (PersistType == "Session")
                {
                    pt = PersistanceType.Session;
                }

                result = new Credential
                {
                    Target          = applicationName,
                    Username        = userName,
                    Password        = password,
                    PersistanceType = pt,
                    Type            = CredentialType.Generic
                }.Save();

                Result.Set(context, result);
            }
            catch (Exception ex)
            {
                Result.Set(context, false);
                Log.Logger.LogData(ex.Message + " in activity CellValue_Clear", LogLevel.Error);
                if (!ContinueOnError)
                {
                    context.Abort();
                }
            }
        }
示例#9
0
        public DataLoader(IConfiguration config)
        {
            this.log = Log.Logger.ForContext <DataLoader>();

            uploadConfig    = config.GetSection("FileUploadConfig").Get <FileUploadConfig>();
            persistanceType = (PersistanceType)Enum.Parse(typeof(PersistanceType), config.GetSection("PersistanceType").Value, true);

            if (persistanceType == PersistanceType.File)
            {
                this.filePathConfig = config.GetSection("FileDataPath").Get <FilePathConfig>();
                this.dataAccessor   = new FileDataAccessor(filePathConfig.RootPath);
            }
            else
            {
                string connectionString = config.GetConnectionString("MongoDbConnection");
                string mgmtDBName       = config.GetConnectionString("DataStoreMgmtDatabaseName");

                this.dataAccessor = new MongoDataAccessor(connectionString, mgmtDBName);
            }
        }
示例#10
0
 public CredentialInput(
     int flags,
     CredentialType credentialType,
     string targetName,
     string comment,
     string password,
     PersistanceType persistanceType,
     string userName)
 {
     if (string.IsNullOrEmpty(userName))
     {
         throw new ArgumentException($"{userName} is null or empty");
     }
     Flags           = flags;
     CredentialType  = credentialType;
     TargetName      = targetName;
     Comment         = comment;
     Password        = password;
     PersistanceType = persistanceType;
     UserName        = userName;
 }
示例#11
0
        public (string, string) GetTargetDirPath(string datastoreName)
        {
            FileUploadConfig uploadConfig    = this.dataLoader.GetUploadConfig();
            PersistanceType  persistanceType = this.dataLoader.GetPersistanceType();
            FilePathConfig   filePathConfig  = this.dataLoader.GetFilePathConfig();

            string configPath = uploadConfig.ColorConfigPath;

            string targetDir = null;

            if (persistanceType == PersistanceType.File && filePathConfig != null)
            {
                targetDir = filePathConfig.RootPath + Path.DirectorySeparatorChar + datastoreName;
            }
            else
            {
                string excelDir = uploadConfig.ExcelDir;
                targetDir = excelDir + Path.DirectorySeparatorChar + DateTime.Now.ToString("MMddyyyyHHmmss");
            }

            return(configPath, targetDir);
        }
        public static NetworkCredential GetCredential(string target, PersistanceType persistanceType)
        {
            var cm = new Credential {
                Target = target, PersistanceType = persistanceType
            };

            if (!cm.Load())
            {
                return(null);
            }

            var networkCredential = new NetworkCredential(cm.Username, cm.Password);

            var userNameParts = networkCredential.UserName.Split('\\');

            if (userNameParts.Length > 1)
            {
                networkCredential.Domain   = userNameParts[0];
                networkCredential.UserName = userNameParts[1];
            }

            return(networkCredential);
        }
示例#13
0
        public static DataLoader initInstance(IConfiguration config)
        {
            if (uniqueInstance == null)
            {
                uniqueInstance = new DataLoader();

                persistanceType = (PersistanceType)Enum.Parse(typeof(PersistanceType), config.GetSection("PersistanceType").Value, true);

                if (persistanceType == PersistanceType.File)
                {
                    filePathConfig = config.GetSection("FileDataPath").Get <FilePathConfig>();
                    uniqueInstance.dataAccessor = new FileDataAccessor(filePathConfig.RootPath);
                }
                else
                {
                    string connectionString = config.GetConnectionString("MongoDbConnection");
                    string mgmtDBName       = config.GetConnectionString("DataStoreMgmtDatabaseName");

                    uniqueInstance.dataAccessor = new MongoDataAccessor(connectionString, mgmtDBName);
                }
            }

            return(uniqueInstance);
        }
示例#14
0
 internal void LoadInternal(NativeMethods.CREDENTIAL credential)
 {
     Username = credential.UserName;
     if (credential.CredentialBlobSize > 0)
     {
         Password = Marshal.PtrToStringUni(credential.CredentialBlob, credential.CredentialBlobSize / 2);
     }
     Target = credential.TargetName;
     Type = (CredentialType)credential.Type;
     PersistanceType = (PersistanceType)credential.Persist;
     Description = credential.Comment;
     LastWriteTimeUtc = DateTime.FromFileTimeUtc(credential.LastWritten);
 }
示例#15
0
 public AddCredential()
 {
     CredentialType  = CredentialType.Generic;
     PersistanceType = PersistanceType.Enterprise;
 }
示例#16
0
 public WincredCredentialsAdapter()
 {
     credentialType  = CredentialType.Generic;
     persistanceType = PersistanceType.LocalComputer;
 }