如何在Acumatica中自动创建和SFTP传输快照?

如何在Acumatica中自动创建和SFTP传输快照?,acumatica,acumatica-kb,Acumatica,Acumatica Kb,我想在SAAS托管的Acumatica实例中创建某些表的夜间快照,并将生成的XML文件SFTP到给定位置。(我已经为感兴趣的表创建了一个自定义导出模式选项。) 我希望通过Acumatica自动化计划、我可以通过API调用的自定义操作、或对现有Acumatica操作的API调用或上述操作的某种组合来完成此过程 但是,我似乎没有这些选项: 自动计划不支持快照创建() 我尝试将创建快照的操作添加到web服务端点,但似乎无法传递管理弹出窗口所需的参数 试图创建一个定制的Acumatica按钮,我也在努

我想在SAAS托管的Acumatica实例中创建某些表的夜间快照,并将生成的XML文件SFTP到给定位置。(我已经为感兴趣的表创建了一个自定义导出模式选项。)

我希望通过Acumatica自动化计划、我可以通过API调用的自定义操作、或对现有Acumatica操作的API调用或上述操作的某种组合来完成此过程

但是,我似乎没有这些选项:

  • 自动计划不支持快照创建()
  • 我尝试将创建快照的操作添加到web服务端点,但似乎无法传递管理弹出窗口所需的参数
  • 试图创建一个定制的Acumatica按钮,我也在努力找出如何弹出和管理弹出窗口
一旦我创建了快照,我想我需要能够在本地下载它,以便将其SFTP到我想要的位置;我还不知道我是否通过API调用了下载快照按钮,结果文件将放在哪里。

June, 当我遇到ReST或其他集成技术无法触发的问题时,我通常会选择Selenium作为阻力最小的途径。我想指出,我总是错误地将硒作为最后手段。 我通常喜欢将PowerShell selenium模块用于类似的东西。 一旦你的脚本正常工作,你就可以很容易地将它连接到一个标准的Windows调度程序中。 这可能不是最优雅的方式,但它肯定能完成任务。 如果你感兴趣,你可以从这个开始

一旦你熟悉了它,你就可以使用chrome检查工具来挖掘你需要瞄准的元素。您要查找的对话框通常作为iFrame出现在页面中

如果你想尝试这条路线,我可以分享我的一些脚本来帮助你开始

我希望这有帮助。
Robert

我最终创建了一个简单的控制台应用程序,因为它更符合我们的其他应用程序,而且我对C#比PowerShell更熟悉。罗伯特,你的项目对于找出如何引用更复杂的元素是非常宝贵的

我希望设置计划任务,用每个步骤的方法名调用我的应用程序,每个步骤之间有适当的延迟——例如,创建快照大约需要25分钟。有单独的方法来创建快照、下载快照、删除快照,接下来我将致力于将下载的快照下载到其最终目标。我在睡觉,让网站赶上时间;有Waits和WaitForExpectedCondition方法可用,但在这个快速而肮脏的版本中,我没有深入了解它们

这是我的代码的精髓。(我通过Nuget向应用程序添加了WebDriver和ChromeDriver。)


琼,很抱歉耽误了你的时间。这是我最近编写的一个脚本,它贯穿了客户门户购物车流程。看看这是否为你指明了正确的方向。此外,我还自愿为下一次虚拟开发人员会议做了一个关于使用Powershell实现自动化的会议。如果我们确实认为我们无法使用ReST或其他自动化手段来实现这一点,我将倾向于进一步提供帮助,以便能够将其用作使用PowerShell和Selenium的特定用例。我渴望看透这一点,所以让我了解您的最新情况;当我录制脚本时,播放会与下拉选项发生冲突——它可能无法识别我单击时录制的下拉元素,或者如果我单击框本身并键入相应的选项,它会随着单击下一个元素而返回列表中的第一个选项。我刚刚开始在我们的一个服务应用程序中使用WebDriver,希望能有更好的运气,因为我们已经建立了一个框架来启动调用该应用程序的预定任务。我担心WebDriver同样无法处理此页面上的某些元素,但我想继续努力。一般来说,我没有使用Powershell的经验,但如果您对此感兴趣,我将非常感谢有机会在此方面进行合作!我从未发现Selenium IDE非常有用。我只是用检查工具识别元素。有些事情更具挑战性,你经常会遇到赛况,因此你需要使用WebDriverWait或粗略的睡眠延迟来放慢速度。总而言之,硒元素是你工具带的绝佳补充。太棒了!,我很高兴看到你取得了进步。对于一些快速而肮脏的事情,我会编写一个PowerShell脚本来启动流程,然后将工作转移到C#集成测试框架中。selenium PowerShell模块只是您在上面找到并使用的C#WebDriver的包装器。随着你对这一切如何运作有了更深入的了解,最好从C#端了解它。如果你更多地进入PowerShell end,你会发现所有你知道的方法C#side也在PowerShell中工作
using System;
using System.Collections.Generic;
using System.Linq;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading;

namespace InfiniteExport
{
   class Program
    {
        static string connectorInfo;
        static void Main(string[] args)
        {
            string method = "";
            if (args.Count() >= 1)
            {
                method = args[0].ToLower();
            }

            IWebDriver driver = new ChromeDriver(); 
            try
            {
                switch (method)
                {
                    case "createsnapshot":                        
                        Login(driver);                        
                        CreateSnapshot(driver);
                        break;
                    case "downloadsnapshot":
                        Login(driver);
                        DownloadSnapshot(driver);
                        break;
                    case "deletesnapshot":
                        Login(driver);
                        DeleteSnapshot(driver);
                        break;
                    default:
                        break;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                driver.Quit();
            }
        }

        static void Login(IWebDriver driver)
        {
            //This login actually results in a 404 error because there's no redirect embedded in it, but the login itself is successful and creates the session used by the next method navigation 
            driver.Navigate().GoToUrl(InfiniteExport.Properties.Settings.Default.BaseAcumaticaURL + "/Frames/Login.aspx");
            driver.FindElement(By.Id("form1")).Click();
            driver.FindElement(By.Id("txtUser")).SendKeys(InfiniteExport.Properties.Settings.Default.AcumaticaUserName);
            driver.FindElement(By.Id("txtPass")).SendKeys(InfiniteExport.Properties.Settings.Default.AcumaticaPassword);
            driver.FindElement(By.Id("btnLogin")).Click();
            driver.Manage().Window.Maximize();
            Thread.Sleep(5000);
        }

        static void CreateSnapshot(IWebDriver driver)
        {
            driver.Navigate().GoToUrl(@InfiniteExport.Properties.Settings.Default.BaseAcumaticaURL + "/Main?ScreenId=SM203520&_CompanyID=2");
            Thread.Sleep(2000);
            driver.SwitchTo().Frame("main");
            //Click the @$@#%*! unnamed create snapshot button
            driver.FindElement(By.CssSelector(".toolsBtn[data-cmd=exportSnapshotCommand]")).Click();
            Thread.Sleep(2000);
            //Switch to the modal popup to start clicking items on it (this is the "Warning not in maintenance mode" popup)
            driver.SwitchTo().ActiveElement();
            driver.FindElement(By.Id("messageBox_0")).Click();
            Thread.Sleep(2000);
            //Switch to the modal popup with the export options
            driver.SwitchTo().ActiveElement();
            driver.FindElement(By.Id("ctl00_phF_pnlExportSnapshot_frmExportSnapshot_edDescription")).SendKeys("InfiniteExport");

            //Select the dropdown option for the InfiniteExport
            driver.FindElement(By.Id("ctl00_phF_pnlExportSnapshot_frmExportSnapshot_edExportMode_text")).Click();
            driver.FindElement(By.Id("ctl00_phF_pnlExportSnapshot_frmExportSnapshot_edExportMode_text")).SendKeys("InfiniteExport");
            Thread.Sleep(2000);
            driver.FindElement(By.ClassName("ddSelection")).Click();

            driver.FindElement(By.Id("ctl00_phF_pnlExportSnapshot_frmExportSnapshot_chkPrepare")).Click();

            //Select the dropdown option for XML
            driver.FindElement(By.Id("ctl00_phF_pnlExportSnapshot_frmExportSnapshot_edPrepareMode")).Click();
            driver.FindElement(By.Id("ctl00_phF_pnlExportSnapshot_frmExportSnapshot_edPrepareMode_text")).SendKeys("XML");
            Thread.Sleep(2000);
            driver.FindElement(By.ClassName("ddSelection")).Click();
            Thread.Sleep(2000);

            //Click the OK button to start the export
            driver.FindElement(By.Id("ctl00_phF_pnlExportSnapshot_btnExportSnapshotOK")).Click();

            //Wait long enough for the process to start, then quit and come back later to download
            Thread.Sleep(10000);
        }

        static void DownloadSnapshot(IWebDriver driver)
        {
            driver.Navigate().GoToUrl(@InfiniteExport.Properties.Settings.Default.BaseAcumaticaURL + "/Main?ScreenId=SM203520&_CompanyID=2");
            Thread.Sleep(2000);
            driver.SwitchTo().Frame("main");
            //Unless this is made fancier, it will download the active grid row, which is the most recent snapshot created
            driver.FindElement(By.CssSelector(".toolsBtn[data-cmd=downloadSnapshotCommand]")).Click();
            Thread.Sleep(10000);
        }

        static void DeleteSnapshot(IWebDriver driver)
        {
            driver.Navigate().GoToUrl(@InfiniteExport.Properties.Settings.Default.BaseAcumaticaURL + "/Main?ScreenId=SM203520&_CompanyID=2");
            Thread.Sleep(2000);
            driver.SwitchTo().Frame("main");
            //Unless this is made fancier, it will delete the active grid row, which is the most recent snapshot created
            driver.FindElement(By.CssSelector(".toolsBtn[data-cmd=Delete]")).Click();
            Thread.Sleep(2000);
            driver.FindElement(By.CssSelector(".toolsBtn[data-cmd=saveCompanyCommand]")).Click();
            Thread.Sleep(10000);
        }
    }
}