示例#1
0
        /// <summary>
        /// Initialises new UI
        /// </summary>
        /// <param name="environment"></param>
        public void Initialize(PluginEnvironment environment)
        {
            if (environment == null)
            {
                return;
            }

            _activityData      = new EwsHeadlessActivityData();
            _payloadRepository = Path.Combine(environment.PluginSettings["DATPayLoadRepository"], "EWSPayLoads");
            LoadUi();
        }
示例#2
0
        /// <summary>
        /// Initialise UI with existing data
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="environment"></param>
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            if (configuration == null || environment == null)
            {
                return;
            }

            _payloadRepository = Path.Combine(environment.PluginSettings["DATPayLoadRepository"], "EWSPayLoads");
            _activityData      = configuration.GetMetadata <EwsHeadlessActivityData>();
            ews_assetSelectionControl.Initialize(configuration.Assets, AssetAttributes.None);
            LoadUi();
        }
        /// <summary>
        /// Execution Entry Point
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            if (executionData == null)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "Execution Data is empty!"));
            }

            _activityData = executionData.GetMetadata <EwsHeadlessActivityData>();
            var printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First();

            _device = DeviceConstructor.Create(printDeviceInfo);
            IEwsCommunicator communicator = EwsCommunicatorFactory.Create(_device);

            EwsPayloadFactory.AddContractLocation(Path.Combine(executionData.Environment.PluginSettings["DATPayLoadRepository"], "EWSContractFiles"));
            EwsPayloadFactory.AddContractLocation(Path.Combine(executionData.Environment.PluginSettings["DATPayLoadRepository"], "EWSPayLoads"));

            if (_activityData.Operation.Equals(_activityData.DeviceSpecificOperation))
            {
                _activityData.DeviceSpecificOperation = string.Empty; //to match the subfilter type in the XML
            }

            //create request to access EWS DAT payloads
            EwsRequest ewsRequest = communicator.CreateRequest(_activityData.Operation, _activityData.DeviceSpecificOperation);

            foreach (var configurationValue in _activityData.ConfigurationValues)
            {
                string valueToBePassed = configurationValue.Value;
                if (valueToBePassed.Equals("[CurrentUser]", StringComparison.OrdinalIgnoreCase))
                {
                    valueToBePassed = executionData.Credential.UserName;
                }

                if ((_device is SiriusDevice) && (_activityData.Operation.Equals("Administration")) && (configurationValue.Key.Equals("Password")))
                {
                    var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(valueToBePassed);
                    valueToBePassed = Convert.ToBase64String(plainTextBytes);
                }
                ewsRequest.Add(configurationValue.Key, valueToBePassed);
            }

            EwsResult result = communicator.Submit(ewsRequest);

            return(result.Exception != null ? new PluginExecutionResult(PluginResult.Failed, result.Exception) : new PluginExecutionResult(PluginResult.Passed));
        }