Exemplo n.º 1
0
        public Error SendPickToWarehouse(PickHeaderModel pickM)
        {
            var error = new Error();

            var pickH = db.FindPickHeader(pickM.Id);

            if (pickH == null)
            {
                error.SetRecordError("PickHeader", pickM.Id);
            }
            else
            {
                var location = pickH.Location ?? new Location {
                    Id = 0, LocationName = "[Unknown]"
                };
                var transferConfig = DataTransferService.FindFileTransferConfigurationModel(location.Id,
                                                                                            FileTransferType.Send,
                                                                                            FileTransferDataType.WarehousePick);
                if (transferConfig == null)
                {
                    error.SetError(EvolutionResources.errCannotDropOrderNoDataTransfer, pickH.Id.ToString(), location.LocationName);
                }
                else
                {
                    error = processPick(pickM, transferConfig);
                }
            }
            return(error);
        }
Exemplo n.º 2
0
        public void FindDataTransferTemplatesListItemModelTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);
            var model       = DataTransferService.FindDataTransferTemplatesListItemModel();

            int expected = 1,
                actual   = model.Count();

            Assert.IsTrue(actual > expected, $"Error: {actual} items were found when more than {expected} were expected");

            // Add another item a make sure it is found
            string templateFolder = GetAppSetting("SiteFolder", "") + "\\App_Data\\DataTransferTemplates";
            string newFile        = RandomInt().ToString() + ".xml";
            string newTemplate    = templateFolder + "\\" + newFile;

            LogTestFile(newTemplate);
            using (var sw = new StreamWriter(newTemplate)) {
                sw.WriteLine(LorumIpsum());
            }

            model = DataTransferService.FindDataTransferTemplatesListItemModel();
            var testItem = model.Where(i => i.Text == newFile).FirstOrDefault();

            Assert.IsTrue(testItem != null, "Error: A NULL value was returned when a non-NULL value was expected");

            // Delete it and make sure it disappears
            File.Delete(newTemplate);

            model    = DataTransferService.FindDataTransferTemplatesListItemModel();
            testItem = model.Where(i => i.Text == newFile).FirstOrDefault();
            Assert.IsTrue(testItem == null, "Error: A non-NULL value was returned when a NULL value was expected");
        }
Exemplo n.º 3
0
        public async System.Threading.Tasks.Task TestMethod1Async()
        {
            SetupEnvironment();

            var _svc   = new DataTransferService();
            var result = await _svc.LoadAllData();
        }
Exemplo n.º 4
0
 static DataTransferService()
 {
     LifecycleManager.SubscribeToWorldInit(() =>
     {
         _service = null;
     });
 }
Exemplo n.º 5
0
        private FileTransferConfigurationModel getFileTransferConfigurationModel(PurchaseOrderHeader poh,
                                                                                 FileRecipient fileRecipient)
        {
            FileTransferConfigurationModel template = null;

            switch (fileRecipient)
            {
            case FileRecipient.Warehouse:
                LocationModel warehouse = null;
                if (poh.LocationId != null)
                {
                    warehouse = LookupService.FindLocationModel(poh.LocationId.Value, false);
                }
                if (warehouse != null)
                {
                    template = DataTransferService.FindFileTransferConfigurationForWarehouseModel(warehouse, FileTransferDataType.WarehousePurchase);
                }
                break;

            case FileRecipient.FreightForwarder:
                FreightForwarderModel freightForwarder = null;
                if (poh.FreightForwarderId != null)
                {
                    freightForwarder = LookupService.FindFreightForwarderModel(poh.FreightForwarderId.Value, false);
                }
                if (freightForwarder != null)
                {
                    template = DataTransferService.FindFileTransferConfigurationForFreightForwarder(freightForwarder, FileTransferDataType.FreightForwarderPurchase);
                }
                break;
            }

            return(template);
        }
Exemplo n.º 6
0
        public void DeleteDataTransferConfigurationTest()
        {
            // Get a test user
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            // Create a price level
            var model = createDataTransfer(testCompany, testUser);

            var error = DataTransferService.InsertOrUpdateDataTransferConfiguration(model, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            // Check that it was written
            var result = db.FindFileTransferConfiguration(model.Id);
            var test   = DataTransferService.MapToModel(result);

            AreEqual(model, test);

            // Now delete it
            DataTransferService.DeleteDataTransferConfiguration(model.Id);

            // And check that is was deleted
            result = db.FindFileTransferConfiguration(model.Id);
            Assert.IsTrue(result == null, "Error: A non-NULL value was returned when a NULL value was expected - record delete failed");
        }
Exemplo n.º 7
0
        public void LockDataTransferConfigurationTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            // Create a record
            var model = createDataTransfer(testCompany, testUser);

            var error = DataTransferService.InsertOrUpdateDataTransferConfiguration(model, testUser, "");

            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");

            // Get the current Lock
            string lockGuid = DataTransferService.LockDataTransferConfiguration(model);

            Assert.IsTrue(!string.IsNullOrEmpty(lockGuid), "Error: Lock record was not found");

            // Simulate another user updating the record
            var otherUser = GetTestUser();

            error = DataTransferService.InsertOrUpdateDataTransferConfiguration(model, otherUser, lockGuid);
            Assert.IsTrue(!error.IsError, error.Message);

            // Now get the first user to update the record
            error = DataTransferService.InsertOrUpdateDataTransferConfiguration(model, testUser, lockGuid);
            Assert.IsTrue(error.IsError, "Error: The lock should have caused an error as it has changed");

            // Try to update with the new lock
            lockGuid = DataTransferService.LockDataTransferConfiguration(model);
            error    = DataTransferService.InsertOrUpdateDataTransferConfiguration(model, testUser, lockGuid);
            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");
        }
        public void CreatePickDocumentRetailPdfTest()
        {
            var testUser     = GetTestUser();
            var testCompany  = GetTestCompany(testUser);
            var testCustomer = GetTestCustomer(testCompany, testUser);
            var testCustomerAdditionalInfo = CustomerService.FindCustomerAdditionalInfoModel(testCustomer.Id, testCompany);

            testCustomerAdditionalInfo.ShippingTemplateId = LookupService.FindDocumentTemplateModel(DocumentTemplateCategory.Pickslip, DocumentTemplateType.PackingSlipRetail).Id;
            var error = CustomerService.InsertOrUpdateCustomerAdditionalInfo(testCustomerAdditionalInfo, testUser, CustomerService.LockCustomer(testCustomer));

            Assert.IsTrue(!error.IsError, error.Message);

            var testCreditCard       = GetTestCreditCard(testCompany, testCustomer);
            var testSalesOrderHeader = GetTestSalesOrderHeader(testCompany, testCustomer, testUser, 41);
            var location             = LookupService.FindLocationModel(testCompany.DefaultLocationID.Value);

            CreateTestTransfers(testCompany, testUser);

            var testFolder   = Path.GetTempPath() + RandomString();
            var transferName = "Test Transfer:Send-" + FileTransferDataType.WarehousePick;
            var sendConfig   = DataTransferService.FindDataTransferConfigurationModel(transferName);

            testSalesOrderHeader.NextActionId     = LookupService.FindSaleNextActionId(Enumerations.SaleNextAction.ShipSomething);
            testSalesOrderHeader.FreightCarrierId = LookupService.FindFreightCarriersListModel(testCompany.Id).Items.FirstOrDefault().Id;
            testSalesOrderHeader.CreditCardId     = testCreditCard.Id;
            error = SalesService.InsertOrUpdateSalesOrderHeader(testSalesOrderHeader, testUser, SalesService.LockSalesOrderHeader(testSalesOrderHeader));
            Assert.IsTrue(!error.IsError, error.Message);

            error = SalesService.CreatePicks(testCompany, testUser, testSalesOrderHeader.Id.ToString(), false);
            Assert.IsTrue(!error.IsError, error.Message);
        }
Exemplo n.º 9
0
 public HttpResponseMessage AuthenticateUser(LoginDataModel loginDetail)
 {
     try
     {
         DataTransferService service = new DataTransferService(ConfigurationManager.ConnectionStrings["AutoSaloonDbConnection"].ConnectionString);
         LoginDetail         detail  = service.GetLoginDetail(loginDetail.UserName, loginDetail.Password);
         if (detail != null)
         {
             HttpResponseMessage returnMessage = new HttpResponseMessage(HttpStatusCode.OK);
             var jObject = JObject.Parse(JsonConvert.SerializeObject(detail));
             returnMessage.Content = new StringContent(jObject.ToString(), Encoding.UTF8, "application/json");
             return(returnMessage);
         }
         else
         {
             HttpResponseMessage returnMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized);
             var jObject = JObject.Parse(JsonConvert.SerializeObject("Invalid user!"));
             returnMessage.Content = new StringContent(jObject.ToString(), Encoding.UTF8, "application/json");
             return(returnMessage);
         }
     }
     catch (Exception ex)
     {
         HttpResponseMessage returnMessage = new HttpResponseMessage(HttpStatusCode.ExpectationFailed);
         var jObject = JObject.Parse(JsonConvert.SerializeObject(ex.Message));
         returnMessage.Content = new StringContent(jObject.ToString(), Encoding.UTF8, "application/json");
         return(returnMessage);
     }
 }
Exemplo n.º 10
0
        private Error processPick(PickHeaderModel pickH,
                                  FileTransferConfigurationModel template)
        {
            var error = new Error();

            // Load the template configuration file
            var configFile = getTemplateFileName(template);

            XElement doc  = XElement.Load(configFile);
            var      file = doc.Element("File");
            var      extn = file.Attribute("DataFileExtension").Value;

            var tempFile = Path.GetTempPath() + pickH.Id + ".CSV";   // extn;
            var zipFile  = "";

            // Check if the pick's files are to be compressed and sent in a ZIP.
            // A pick can be a single CSV file or a CSV with onr or more PDF's.
            // A single file can optionally be compressed whereas multiple files must be compressed
            // as a package of files.
            // The requirement is that a single file is dropped for FTP.
            bool bCompress = file.Attribute("CompressFile").Value.ParseBool();

            if (bCompress || pickH.PickFiles.Count() > 1)
            {
                // File(s) are to be compressed/combined
                zipFile = tempFile.ChangeExtension(".zip");

                error = Zip.ZipFiles(pickH.PickFiles, zipFile);

                if (error.IsError)
                {
                    FileManagerService.FileManagerService.DeleteFile(zipFile);
                }
                else
                {
                    tempFile = zipFile;
                }
            }

            if (!error.IsError)
            {
                if (file.Attribute("FTPFile").Value.ParseBool())
                {
                    // Copy the file to the FTP pickup folder
                    error = moveFileToFTPFolder(tempFile,
                                                template.SourceFolder,
                                                DataTransferService.GetTargetFileName(template,
                                                                                      tempFile,
                                                                                      pickH.Id));
                }
            }
            FileManagerService.FileManagerService.DeleteFile(tempFile);

            return(error);
        }
Exemplo n.º 11
0
        public ActionResult Edit(int id)
        {
            var model = new EditFileTransferConfigurationViewModel();

            prepareEditModel(model);

            model.FileTransferConfiguration = DataTransferService.FindDataTransferConfigurationModel(id, true);
            model.LGS = DataTransferService.LockDataTransferConfiguration(model.FileTransferConfiguration);

            return(View(model));
        }
Exemplo n.º 12
0
        public async Task TransferAsync_TestDataAdapter_DataTransferContextPassed()
        {
            const string SourceAdapterName = "TestSource";
            const string SinkAdapterName   = "TestSink";

            var sourceMock = new Mock <IDataSourceAdapter>();

            sourceMock
            .Setup(m => m.ReadNextAsync(It.IsAny <ReadOutputByRef>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <IDataItem>(null));

            var sinkMock = new Mock <IDataSinkAdapter>();

            sinkMock
            .Setup(m => m.WriteAsync(It.IsAny <IDataItem>(), It.IsAny <CancellationToken>()))
            .Returns(TaskHelper.NoOp);

            var sourceFactoryMock = new Mock <IDataSourceAdapterFactoryAdapter>();

            sourceFactoryMock
            .Setup(m => m.CreateAsync(It.IsAny <object>(), It.IsAny <IDataTransferContext>(), It.IsAny <CancellationToken>()))
            .Callback <object, IDataTransferContext, CancellationToken>((a, c, ct) =>
                                                                        Assert.AreEqual(SourceAdapterName, c.SourceName, TestResources.InvalidDataSourceNameInTransferContext))
            .Returns(Task.FromResult(sourceMock.Object));

            var sinkFactoryMock = new Mock <IDataSinkAdapterFactoryAdapter>();

            sinkFactoryMock
            .Setup(m => m.CreateAsync(It.IsAny <object>(), It.IsAny <IDataTransferContext>(), It.IsAny <CancellationToken>()))
            .Callback <object, IDataTransferContext, CancellationToken>((a, c, ct) =>
                                                                        Assert.AreEqual(SinkAdapterName, c.SinkName, TestResources.InvalidDataSinkNameInTransferContext))
            .Returns(Task.FromResult(sinkMock.Object));

            var service = new DataTransferService(
                new Dictionary <string, IDataSourceAdapterFactoryAdapter>
            {
                { SourceAdapterName, sourceFactoryMock.Object }
            },
                new Dictionary <string, IDataSinkAdapterFactoryAdapter>
            {
                { SinkAdapterName, sinkFactoryMock.Object }
            },
                Mocks.Of <IDataTransferAction>()
                .Where(a => a.ExecuteAsync(
                           It.IsAny <IDataSourceAdapter>(), It.IsAny <IDataSinkAdapter>(),
                           It.IsAny <ITransferStatistics>(), It.IsAny <CancellationToken>()) == Task.FromResult <object>(null))
                .First()
                );

            await service.TransferAsync(
                SourceAdapterName, null, SinkAdapterName, null,
                new DummyTransferStatisticsMock(),
                CancellationToken.None);
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            Stream tradeStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("No7.Solution.Console.trades.txt");

            var service = new DataTransferService(new DataProvider(tradeStream),
                                                  new DbStorage(ConfigurationManager.ConnectionStrings[CONNECTION_DATA].ConnectionString),
                                                  new Parser());

            service.Transfer();

            System.Console.ReadKey();
        }
Exemplo n.º 14
0
        void prepareEditModel(EditFileTransferConfigurationViewModel model)
        {
            PrepareViewModel(model, EvolutionResources.bnrAddEditDataTransfer);

            model.CompanyList               = CompanyService.FindCompaniesListItemModel();
            model.TransferTypeList          = LookupService.FindFileTransferTypeListItemModel();
            model.DataTypeList              = LookupService.FindLOVItemsListItemModel(CurrentCompany, LOVName.FileTransferDataType);
            model.FTPProtocolList           = LookupService.FindFTPProtocolListItemModel();
            model.LocationList              = LookupService.FindLocationListItemModel(model.CurrentCompany, true);
            model.FreightForwarderList      = LookupService.FindFreightForwardersListItemModel(model.CurrentCompany, true);
            model.ConfigurationTemplateList = DataTransferService.FindDataTransferTemplatesListItemModel();
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            using (Stream stream = File.OpenRead(ConfigurationManager.AppSettings["txtPath"]))
            {
                var xmlFile = new FileInfo(ConfigurationManager.AppSettings["xmlPath"]);

                var service = new DataTransferService(new DataProvider(stream), new XMLStorage(xmlFile), new Parser());

                service.Transfer();
            }

            System.Console.ReadKey();
        }
Exemplo n.º 16
0
        public ActionResult Delete(int index, int id)
        {
            var model = new FileTransferConfigurationListModel {
                GridIndex = index
            };

            try {
                DataTransferService.DeleteDataTransferConfiguration(id);
            } catch (Exception e1) {
                model.Error.SetError(e1);
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 17
0
        public async Task TransferAsync_TestDataAdapters_DisposeCalled()
        {
            const string SourceAdapterName = "TestSource";
            const string SinkAdapterName   = "TestSink";

            var sourceMock = new Mock <IDataSourceAdapter>();

            sourceMock
            .Setup(m => m.ReadNextAsync(It.IsAny <ReadOutputByRef>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <IDataItem>(null));
            sourceMock
            .Setup(m => m.Dispose())
            .Verifiable();

            var sinkMock = new Mock <IDataSinkAdapter>();

            sinkMock
            .Setup(m => m.WriteAsync(It.IsAny <IDataItem>(), It.IsAny <CancellationToken>()))
            .Returns(TaskHelper.NoOp);
            sinkMock
            .Setup(m => m.Dispose())
            .Verifiable();

            var service = new DataTransferService(
                new Dictionary <string, IDataSourceAdapterFactoryAdapter>
            {
                { SourceAdapterName, Mocks.Of <IDataSourceAdapterFactoryAdapter>()
                  .Where(m => m.CreateAsync(It.IsAny <object>(), It.IsAny <IDataTransferContext>(), It.IsAny <CancellationToken>()) ==
                         Task.FromResult(sourceMock.Object)).First() }
            },
                new Dictionary <string, IDataSinkAdapterFactoryAdapter>
            {
                { SinkAdapterName, Mocks.Of <IDataSinkAdapterFactoryAdapter>()
                  .Where(m => m.CreateAsync(It.IsAny <object>(), It.IsAny <IDataTransferContext>(), It.IsAny <CancellationToken>()) ==
                         Task.FromResult(sinkMock.Object)).First() }
            },
                Mocks.Of <IDataTransferAction>()
                .Where(a => a.ExecuteAsync(
                           It.IsAny <IDataSourceAdapter>(), It.IsAny <IDataSinkAdapter>(),
                           It.IsAny <ITransferStatistics>(), It.IsAny <CancellationToken>()) == Task.FromResult <object>(null))
                .First()
                );

            await service.TransferAsync(
                SourceAdapterName, null, SinkAdapterName, null,
                new DummyTransferStatisticsMock(),
                CancellationToken.None);

            sourceMock.Verify();
            sinkMock.Verify();
        }
Exemplo n.º 18
0
        public void FindDataTransferConfigurationModelTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            var model = createDataTransfer(testCompany, testUser);
            var error = DataTransferService.InsertOrUpdateDataTransferConfiguration(model, testUser, "");

            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");

            var test = DataTransferService.FindDataTransferConfigurationModel(model.Id, false);

            AreEqual(model, test);
        }
Exemplo n.º 19
0
        private Error createDocuments(CompanyModel company, List <PickHeaderModel> picks)
        {
            var error = new Error();

            var pick = picks.FirstOrDefault();      // Validation ensures that there will always be at least one pick

            var location = LookupService.FindLocationModel(pick.LocationId.Value, false);

            if (location != null && location.LocationIdentification.ToLower() == "warehouse")
            {
                // Warehouse requires supporting PDF document

                // TBD: The type of PDF is specified in the customer record
                // Combined orders can only be for the same customer, so there will only
                // ever be one customer, irrespective of single or combined picks.
                var customer = db.FindCustomer(pick.CustomerId ?? 0);
                if (customer == null)
                {
                    error.SetRecordError("Customer", pick.CustomerId ?? 0);
                }
                else
                {
                    var template = LookupService.FindDocumentTemplateModel(customer.ShippingTemplateId ?? 0);

                    var config = DataTransferService.FindFileTransferConfigurationForWarehouseModel(location, FileTransferDataType.WarehousePick);
                    if (config == null)
                    {
                        error.SetError(EvolutionResources.errCannotDropOrderNoDataTransfer, pick.Id.ToString(), location.LocationName);
                    }
                    else
                    {
                        var pdfFile = MediaServices.GetMediaFolder(MediaFolder.Temp, company.Id) +
                                      DataTransferService.GetTargetFileName(config, "", pick.Id).ChangeExtension(".pdf");
                        string outputFile = "";
                        error = CreatePickDocumentPdf(pick, template, pdfFile, false, ref outputFile, int.MaxValue);
                        pick.PickFiles.Add(outputFile);

                        // TBD: Add the document to the sale notes/attachments
                    }
                }
            }

            return(error);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Inserts a data transfer request.
        /// Documentation https://developers.google.com/datatransfer/datatransfer_v1/reference/transfers/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated DataTransfer service.</param>
        /// <param name="body">A valid DataTransfer datatransfer_v1 body.</param>
        /// <returns>DataTransferResponse</returns>
        public static DataTransfer Insert(DataTransferService service, DataTransfer body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Make the request.
                return(service.Transfers.Insert(body).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Transfers.Insert failed.", ex);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Retrieves a data transfer request by its resource ID.
        /// Documentation https://developers.google.com/datatransfer/datatransfer_v1/reference/transfers/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated DataTransfer service.</param>
        /// <param name="dataTransferId">ID of the resource to be retrieved. This is returned in the response from the insert method.</param>
        /// <returns>DataTransferResponse</returns>
        public static DataTransfer Get(DataTransferService service, string dataTransferId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (dataTransferId == null)
                {
                    throw new ArgumentNullException(dataTransferId);
                }

                // Make the request.
                return(service.Transfers.Get(dataTransferId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Transfers.Get failed.", ex);
            }
        }
Exemplo n.º 22
0
        public void FindDataTransferConfigurationsListModelTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);
            var model       = DataTransferService.FindDataTransferConfigurationsListModel(0, 1, PageSize, "");
            var dbData      = db.FindFileTransferConfigurations(true);

            int expected = dbData.Count(),
                actual   = model.Items.Count();

            Assert.IsTrue(actual == expected, $"Error: {actual} items were found when {expected} were expected");

            // Check that all the items match
            foreach (var item in model.Items)
            {
                var dbItem = dbData.Where(m => m.Id == item.Id).FirstOrDefault();
                Assert.IsTrue(dbItem != null, "Error: Model item not found in db item list");
                var temp = DataTransferService.MapToModel(dbItem);
                AreEqual(item, temp);
            }

            // Add another item a make sure it is found
            var newItem = createDataTransfer(testCompany, testUser);
            var error   = DataTransferService.InsertOrUpdateDataTransferConfiguration(newItem, testUser, "");

            Assert.IsTrue(!error.IsError, $"Error: {error.Message}");

            model = DataTransferService.FindDataTransferConfigurationsListModel(0, 1, PageSize, "");
            var testItem = model.Items.Where(i => i.Id == newItem.Id).FirstOrDefault();

            Assert.IsTrue(testItem != null, "Error: A NULL value was returned when a non-NULL value was expected");

            // Delete it and make sure it disappears
            DataTransferService.DeleteDataTransferConfiguration(newItem.Id);

            model    = DataTransferService.FindDataTransferConfigurationsListModel(0, 1, PageSize, "");
            testItem = model.Items.Where(i => i.Id == newItem.Id).FirstOrDefault();
            Assert.IsTrue(testItem == null, "Error: A non-NULL value was returned when a NULL value was expected");
        }
Exemplo n.º 23
0
 public ActionResult Save(EditFileTransferConfigurationViewModel model, string command)
 {
     if (command.ToLower() == "save")
     {
         var modelError = DataTransferService.InsertOrUpdateDataTransferConfiguration(model.FileTransferConfiguration, CurrentUser, model.LGS);
         if (modelError.IsError)
         {
             PrepareViewModel(model, EvolutionResources.bnrAddEditDataTransfer);
             model.SetErrorOnField(ErrorIcon.Error,
                                   modelError.Message,
                                   "FileTransferConfiguration_" + modelError.FieldName);
             return(View("Edit", model));
         }
         else
         {
             return(RedirectToAction("DataTransfers"));
         }
     }
     else
     {
         return(RedirectToAction("DataTransfers"));
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Lists the transfers for a customer by source user, destination user, or status.
        /// Documentation https://developers.google.com/datatransfer/datatransfer_v1/reference/transfers/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated DataTransfer service.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>DataTransfersListResponseResponse</returns>
        public static DataTransfersListResponse List(DataTransferService service, TransfersListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Building the initial request.
                var request = service.Transfers.List();

                // Applying optional parameters to the request.
                request = (TransfersResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Transfers.List failed.", ex);
            }
        }
Exemplo n.º 25
0
 public ActionResult GetDataTransfers(int index, int pageNo, int pageSize, string search)
 {
     return(Json(DataTransferService.FindDataTransferConfigurationsListModel(index, pageNo, pageSize, search), JsonRequestBehavior.AllowGet));
 }