コード例 #1
0
        public string ReplaceList(string name, string id, string path, string tenantId, string tenantCode)
        {
            var runtime          = ConfigurationSectionLoader.Read <PledgeRuntime>("PledgeRuntime.config");
            var credentialConfig = ConfigurationSectionLoader.Read <Credential>("Credentials.config");

            if (runtime == null || credentialConfig == null)
            {
                return("Unable to load configuration information");
            }

            var credential = Credential.Decrypt(credentialConfig, Constants.Cipher.Decrypt(string.Empty));

            runtime.RemoteSettings.PledgeApiAddress = ApiHelper.FormatUrl(runtime.RemoteSettings.PledgeApiAddress);

            var status = $"Uploading new file for list \"{name}\" from location '{path}' " +
                         $"on behalf of {tenantCode} with u:{credential.UserName} & p:{credential.Password}";

            var listInfo = new ListInfo
            {
                Id       = id,
                Name     = name,
                File     = path,
                TenantId = tenantId
            };

            var subStatus = string.Empty;

            try
            {
                var uploadTask = Upload(runtime.RemoteSettings, credential, listInfo).ContinueWith(task =>
                {
                    subStatus = task.Result;
                });

                uploadTask.Wait();
            }
            catch (Exception error)
            {
                var builder = new StringBuilder($"{error.Message}*****{error.StackTrace}");
                error = error.InnerException;

                while (error != null)
                {
                    builder.AppendLine($"{error.Message}*****{error.StackTrace}");
                    error = error.InnerException;
                }

                subStatus = builder.ToString();
            }

            return($"{status}{Environment.NewLine}{subStatus}");
        }
コード例 #2
0
ファイル: Credential.cs プロジェクト: tuvoksg1/ProvingGround
        /// <summary>
        /// Decrypts the specified passphrase.
        /// </summary>
        /// <param name="passphrase">The passphrase.</param>
        /// <returns></returns>
        public static Credential Decrypt(string passphrase)
        {
            var credential = ConfigurationSectionLoader.Load <Credential>(Constants.CredentialSection);

            return(Decrypt(credential, passphrase));
        }