Exemple #1
0
        private static void Upload(UploadSettings settings)
        {
            var uploader = new SmartObjectDataUploadService(settings);

            uploader.Upload();

            Console.WriteLine(uploader.Message);
        }
Exemple #2
0
        public override void Execute()
        {
            ServicePackage.ResultTable = null;

            var results = new DataTable("Results");

            results.Columns.Add(PropertyConstants.Result);
            results.Columns.Add(PropertyConstants.ImportStatus);
            results.Columns.Add(PropertyConstants.UploadStatus);

            var serviceObj = Service.ServiceObjects[0];
            var properties = serviceObj.Properties;

            var method = serviceObj.Methods[0].Name;

            var row = results.NewRow();

            results.Rows.Add(row);

            try
            {
                var importer = GetImporter(properties, method);
                importer.Parse();

                var resultString = $"Importing {importer.Status}: {importer.Message}";

                row[PropertyConstants.ImportStatus] = importer.Status;

                if (importer.Status == ImportStatus.Complete)
                {
                    var uploadSettings = new UploadSettings
                    {
                        K2Server           = Service.ServiceConfiguration[ServiceObjectNameConstants.K2Server].ToString(),
                        Port               = uint.Parse(Service.ServiceConfiguration[ServiceObjectNameConstants.Port].ToString()),
                        SmartObjectName    = properties.SafeRead(PropertyConstants.SmartObjectName),
                        CreateMethod       = properties.SafeRead(PropertyConstants.SmartObjectMethodName, "Create"),
                        IsBulkImport       = method.Contains("Bulk"),
                        TransactionIdName  = properties.SafeRead(PropertyConstants.TransactionIdProperty),
                        TransactionIdValue = properties.SafeRead(PropertyConstants.TransactionIdValue),
                        HeaderRowSpaces    = properties.SafeRead(PropertyConstants.HeaderRowSpaces, "Remove"),
                        Data               = importer.Results
                    };

                    var uploader = new SmartObjectDataUploadService(uploadSettings);
                    uploader.Upload();

                    resultString += $"Uploading {uploader.Status}: {uploader.Message}";

                    row[PropertyConstants.UploadStatus] = uploader.Status;
                }

                row[PropertyConstants.Result] = resultString;

                ServicePackage.ResultTable  = results;
                ServicePackage.IsSuccessful = true;
            }
            catch (Exception)
            {
                ServicePackage.IsSuccessful = false;
                throw;
            }
        }