Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebServicesExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal WebServicesExerciser(DirtyDeviceManager owner, JediDevice device)
 {
     _owner       = owner;
     _device      = device;
     _webServices = _device.WebServices;
     _snmp        = _device.Snmp;
 }
Exemple #2
0
        /// <summary>
        /// Entry point into the WS* process.
        /// Endpoint: address book, email, FIM, ...
        /// Resource URL: urn:hp:imaging:con:service:email:EmailService
        ///
        /// The call to WSTranferClient.Get will return an XML string of data.36030
        /// </summary>
        /// <param name="endPoint">string</param>
        /// <param name="resourceUri">string</param>
        /// <returns>XElement</returns>
        public XElement GetEndPointLog(string endPoint, string resourceUri)
        {
            XElement xeDeviceData = null;

            JediDevice jedi = DeviceFactory.Create(IPAddress, Password) as JediDevice;

            if (jedi != null)
            {
                try
                {
                    xeDeviceData = jedi.WebServices.GetDeviceTicket(endPoint, resourceUri);
                }
                catch (DeviceCommunicationException dce)
                {
                    if (dce.InnerException != null)
                    {
                        if (!dce.InnerException.GetType().Equals(typeof(System.ServiceModel.EndpointNotFoundException)) && !dce.InnerException.GetType().Equals(typeof(System.ServiceModel.ProtocolException)))
                        {
                            throw;
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to communicate with IP Address " + IPAddress + "\n\r" + dce.Message);
                    }
                }
                catch (EntryPointNotFoundException nf)
                {
                    throw new Exception("Unable to communicate with IP Address " + IPAddress + "\n\r" + nf.Message);
                }
            }
            return(xeDeviceData);
        }
Exemple #3
0
        private bool SetWindowsDomains(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string activityUrn = "urn:hp:imaging:con:service:windowsauthenticationagent:WindowsAuthenticationAgentService:DomainNames";
            string endpoint    = "windowsauthenticationagent";

            Func <WebServiceTicket, WebServiceTicket> change = n =>
            {
                string[] domains = pair.Key.Split(';');
                if (domains.Length != 0)
                {
                    try
                    {
                        string ticketString = n.ToString();
                        string addDomain    = ">";
                        ticketString = ticketString.Remove(ticketString.Length - 2);

                        foreach (string domain in domains)
                        {
                            addDomain += $@"<dd3:DomainName>{domain}</dd3:DomainName>";
                        }
                        addDomain += @"</dd3:DomainNames>";
                        n          = new WebServiceTicket(ticketString + addDomain);
                        return(n);
                    }
                    catch (Exception e)
                    {
                        ExecutionServices.SystemTrace.LogDebug($@"Device {device.Address} failed to set domains {e.Message}");
                        throw;
                    }
                }
                return(n);
            };

            return(UpdateField(change, device, pair, activityUrn, endpoint, assetInfo, fieldChanged, data));
        }
Exemple #4
0
        private bool SetSMTPServer(DataPair <string> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:email:EmailService";
            string endpoint    = "email";
            string name        = "SMTPServer";

            Func <WebServiceTicket, bool> getProperty = n =>
            {
                bool result = true;
                bool useSsl;
                var  values = pair.Key.Split(' ').ToList();
                if (values.Count == 3)
                {
                    values.Add("false");
                }


                bool.TryParse(values[3], out useSsl);
                result &= n.FindElements("NetworkID").Any(x => x.Value == values[0]);
                result &= n.FindElements("Port").Any(x => x.Value == values[1]);
                result &= n.FindElements("MaxAttachmentSize").Any(x => x.Value == values[2]);
                result &= n.FindElements("UseSSL").Any(x => x.Value.Equals(useSsl.ToString(), StringComparison.OrdinalIgnoreCase));
                return(result);
            };

            return(UpdateField(getProperty, device, pair, activityUrn, endpoint, name));
        }
Exemple #5
0
        private bool SetSMTPServer(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string activityUrn = "urn:hp:imaging:con:service:email:EmailService";
            string endpoint    = "email";

            //for the initial option, there wouldn't be any smtp node, and the following code will crash

            Func <WebServiceTicket, WebServiceTicket> change = n =>
            {
                var values = pair.Key.Split(' ').ToList();
                if (values.Count == 3)
                {
                    values.Add("false");
                }

                if (n.Element("NetworkID") == null)
                {
                    AddSmtpServer(n, values);
                }
                else
                {
                    bool useSsl;
                    bool.TryParse(values[3], out useSsl);
                    n.FindElement("NetworkID").SetValue(values[0]);
                    n.FindElement("Port").SetValue(values[1]);
                    n.FindElement("MaxAttachmentSize").SetValue(values[2]);
                    n.FindElement("UseSSL").SetValue(useSsl.ToString().ToLower());
                    n.FindElement("ValidateServerCertificate").SetValue("disabled");
                }

                return(n);
            };

            return(UpdateField(change, device, pair, activityUrn, endpoint, assetInfo, fieldChanged, data));
        }
Exemple #6
0
        public static string GetCdm(JediDevice device)
        {
            string final = $@"https://{device.Address}/hp/network/ioConfig/v1/networkInterfaces/wired1/snmpv1v2Config";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(final);

            request.Method      = "GET";
            request.Credentials = new NetworkCredential("admin", device.AdminPassword);
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            try
            {
                WebResponse response = request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                    return(reader.ReadToEnd());
                }
            }
            catch (WebException ex)
            {
                WebResponse errorResponse = ex.Response;

                using (Stream responseStream = errorResponse.GetResponseStream())
                {
                    StreamReader reader    = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
                    String       errorText = reader.ReadToEnd();
                    //assetId errorText
                    Logger.LogError(errorText);
                }

                return(string.Empty);
            }
        }
        public bool UpdateField <T>(Func <WebServiceTicket, bool> getProperty, JediDevice device, DataPair <T> data, string urn, string endpoint, string activityName)
        {
            bool success;

            if (data != null && data.Value)
            {
                try
                {
                    WebServiceTicket tic = device.WebServices.GetDeviceTicket(endpoint, urn);
                    getProperty(tic);
                    device.WebServices.PutDeviceTicket(endpoint, urn, tic);
                    success = true;
                }
                catch (Exception ex)
                {
                    Logger.LogError($"Failed to set field {activityName}, {ex.Message}");
                    success = false;
                }
            }
            else
            {
                success = true;
            }
            if (!success)
            {
                _failedSettings.Append($"{activityName}, ");
            }

            return(success);
        }
        /// <summary>
        /// Determines whether the simulator is up and ready.
        /// </summary>
        /// <param name="hostAddress">The machine name.</param>
        /// <returns><c>true</c> if the simulator is ready; otherwise, <c>false</c>.</returns>
        public static bool IsSimulatorReady(string hostAddress)
        {
            JediDevice simulator = new JediDevice(hostAddress);

            return(simulator.GetDeviceStatus() == DeviceStatus.Running &&
                   simulator.GetPrinterStatus() >= PrinterStatus.Idle);
        }
Exemple #9
0
        public void SetDefaultPassword(string address, string password)
        {
            var    defPWUrn = "urn:hp:imaging:con:service:security:SecurityService:AdministratorAuthenticationSettings";
            string endpoint = "security";

            ExecutionServices.SystemTrace.LogDebug($"{address}: Setting default password");

            JediDevice dev;

            try
            {
                dev = new JediDevice(address, "");
                WebServiceTicket tic = dev.WebServices.GetDeviceTicket(endpoint, defPWUrn);
                if (password.Length < 8)
                {
                    tic.FindElement("MinLength").SetValue(password.Length - 1);
                    tic.FindElement("IsPasswordComplexityEnabled").SetValue("false");
                }
                tic.FindElement("Password").SetValue(password);
                tic.FindElement("PasswordStatus").SetValue("set");
                dev.WebServices.PutDeviceTicket("security", defPWUrn, tic, false);

                dev = new JediDevice(address, password);
                ExecutionServices.SystemTrace.LogDebug($"{address}: Default password set");
            }
            catch (Exception exception)
            {
                ExecutionServices.SystemTrace.LogError(exception.Message);
                dev = new JediDevice(address, password);
            }
            //disposing the device
            dev.Dispose();
        }
Exemple #10
0
        /// <summary>
        /// Request uninstall to package manager
        /// </summary>
        /// <param name="device">Jedi device</param>
        /// <param name="hpkfile">Hpk file Information</param>
        public void UninstallPackage(JediDevice device, HpkFileInfo hpkfile)
        {
            Uri delete_packages_uri = new Uri($"https://{device.Address}/hp/device/webservices/ext/pkgmgt/installer/uninstall?uuid={hpkfile.Uuid}&clientId=ciGallery");

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            HttpClientHandler httphandler = new HttpClientHandler();

            httphandler.Credentials = new NetworkCredential("admin", device.AdminPassword);
            var client = new HttpClient(httphandler);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, delete_packages_uri);

            try
            {
                using (HttpResponseMessage message = client.SendAsync(request).Result)
                {
                    string s = message.Content.ReadAsStringAsync().Result;
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message + $"Device : {device.Address}");
                throw ex;
            }
        }
        public bool UpdateField <T>(Func <WebServiceTicket, bool> getProperty, JediDevice device, DataPair <T> data, string urn, string endpoint,
                                    string activityName)
        {
            bool success;

            if (data.Value)
            {
                try
                {
                    int oidValue  = data.Key.ToString() == "on" ? 1 : 0;
                    var oidResult = device.Snmp.Get(endpoint);

                    success = oidResult == oidValue.ToString();
                }
                catch (Exception ex)
                {
                    _failedSettings.AppendLine($"Failed to verify field {activityName}, {ex.Message}");
                    success = false;
                }
            }
            else
            {
                success = true;
            }

            if (!success)
            {
                _failedSettings.Append($"{activityName}, ");
            }

            return(success);
        }
Exemple #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UIExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal UIExerciser(DirtyDeviceManager owner, JediOmniDevice device, JediOmniPreparationManager preparationManager)
 {
     _owner              = owner;
     _device             = device;
     _preparationManager = preparationManager;
     _controlPanel       = device.ControlPanel;
 }
Exemple #13
0
        public bool UpdateWithOid <T>(Action <T> oidUsed, JediDevice device, DataPair <T> pair, AssetInfo assetInfo, string fieldChanged, PluginExecutionData pluginData)
        {
            if (pair.Value)
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                bool success = true;
                DeviceConfigResultLog log = new DeviceConfigResultLog(pluginData, assetInfo.AssetId);
                try
                {
                    var snmpData = GetCdm(device); //incase we have issues with endpoint, it is better to fail the setting than to abruptly stop the execution of the plugin
                    if (!string.IsNullOrEmpty(snmpData))
                    {
                        var objectGraph = serializer.DeserializeObject(snmpData) as Dictionary <string, object>;
                        var snmpEnabled = (string)objectGraph["snmpv1v2Enabled"];
                        if (snmpEnabled == "true")
                        {
                            var accessOption = (string)objectGraph["accessOption"];

                            //We need to change from read only
                            if (accessOption == "readOnly")
                            {
                                string jsonContent =
                                    @"{""snmpv1v2Enabled"": ""true"",""accessOption"": ""readWrite"",""readOnlyPublicAllowed"": ""true"",""readOnlyCommunityNameSet"": ""false"",""writeOnlyCommunitryNameSet"": ""false""}";

                                PutCdm(device, jsonContent);
                            }
                        }
                        //snmpv1v2 is disabled we need to enable it
                        else
                        {
                            string jsonContent =
                                @"{""snmpv1v2Enabled"": ""true"",""accessOption"": ""readWrite"",""readOnlyPublicAllowed"": ""true"",""readOnlyCommunityNameSet"": ""false"",""writeOnlyCommunitryNameSet"": ""false""}";
                            PutCdm(device, jsonContent);
                        }
                    }

                    oidUsed(pair.Key);

                    if (!string.IsNullOrEmpty(snmpData))
                    {
                        //Restore state
                        PutCdm(device, snmpData);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError($"Failed to set field {log.FieldChanged}, {ex.Message}");
                    _failedSettings.AppendLine($"Failed to set field {log.FieldChanged}, {ex.Message}");
                    success = false;
                }
                log.FieldChanged   = fieldChanged;
                log.Result         = success ? "Passed" : "Failed";
                log.Value          = pair.Key.ToString();
                log.ControlChanged = "Web/TroubleShooting";

                ExecutionServices.DataLogger.Submit(log);
            }
            return(true);
        }
Exemple #14
0
        private string MacId(JediDevice jediDevice)
        {
            var macIdRawValue = jediDevice.Snmp.GetRaw("1.3.6.1.4.1.11.2.4.3.1.23.0");
            var macIdBytes    = macIdRawValue.ToBytes();
            var macids        = macIdBytes.Select(x => $"{Convert.ToInt32(x):X}");

            return(string.Join(":", macids));
        }
Exemple #15
0
 public void Dispose()
 {
     if (_device != null)
     {
         _device.Dispose();
         _device = null;
     }
 }
Exemple #16
0
        /// <summary>
        /// Control the installation process.
        /// </summary>
        /// <param name="hpkfile">Hpk file infomation</param>
        /// <param name="device">Jedi device</param>
        /// <param name="assetInfo">Asset information</param>
        /// <param name="pluginData">Plugin execution data</param>
        /// <returns></returns>
        public bool UpdateHpk(HpkFileInfo hpkfile, JediDevice device, AssetInfo assetInfo, PluginExecutionData pluginData)
        {
            bool success = false;
            int  count   = 0;
            DeviceConfigResultLog log = new DeviceConfigResultLog(pluginData, assetInfo.AssetId);
            string progressState      = null;

            try
            {
                while (success == false && count < RetryCount)
                {
                    if (InstallPackage(device, hpkfile))
                    {
                        progressState = TrackPackage(device, hpkfile);

                        while (progressState == "psInProgress" || progressState == "404 Not Found" || progressState == "503 Service Unavailable" || string.IsNullOrEmpty(progressState))
                        {
                            Thread.Sleep(3000);
                            progressState = TrackPackage(device, hpkfile);
                        }
                        if (progressState == "psCompleted")
                        {
                            success = true;
                        }
                        else if (progressState == "psFailed")
                        {
                            success = false;
                        }
                        else
                        {
                            success = false;
                        }
                    }
                    else
                    {
                        success = false;
                        Thread.Sleep(10000);
                    }
                    count++;
                }
            }
            catch (Exception ex)
            {
                Logger.LogError($"Failed to install HPK : (Device:{device.Address}){hpkfile.PackageName}, {ex.Message}, progressState = {progressState}");
                _failedSettings.AppendLine($"Failed to install HPK: (Device:{device.Address}){hpkfile.PackageName}, {ex.Message}");
                success = false;
            }

            log.FieldChanged   = hpkfile.PackageName;
            log.Result         = success ? "Passed" : "Failed";
            log.Value          = "HpkInstall Values";
            log.ControlChanged = $@"HpkInstall :{hpkfile.PackageName}";

            ExecutionServices.DataLogger.Submit(log);

            return(success);
        }
Exemple #17
0
        private bool SetFTPQuickSetData(IEnumerable <FTPQuickSetData> group, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData datas)
        {
            string activityUrn = "urn:hp:imaging:con:service:folder:FolderService:PredefinedJobs";
            string endpoint    = "folder";

            _nameSpaceDictionary = new Dictionary <string, XNamespace> {
                { "dsd", _dsd }, { "dd", _dd }, { "folder", _folderNs }, { "security", _securityNs }, { "dd2", _dd2 }, { "dd3", _dd3 }
            };
            var stnfQuickSetDatas = group as IList <FTPQuickSetData> ?? group.ToList();
            DataPair <IEnumerable <FTPQuickSetData> > quick = new DataPair <IEnumerable <FTPQuickSetData> >
            {
                Value = true,
                Key   = stnfQuickSetDatas
            };

            Func <WebServiceTicket, WebServiceTicket> change = n =>
            {
                var folderPredefinedJobs = new XElement(_folderNs + "PredefinedJobs",
                                                        new XAttribute(XNamespace.Xmlns + "dsd", _dsd.NamespaceName),
                                                        new XAttribute(XNamespace.Xmlns + "security", _securityNs.NamespaceName),
                                                        new XAttribute(XNamespace.Xmlns + "dd2", _dd2.NamespaceName),
                                                        new XAttribute(XNamespace.Xmlns + "dd3", _dd3.NamespaceName),
                                                        new XAttribute(XNamespace.Xmlns + "dd", _dd.NamespaceName),
                                                        new XAttribute(XNamespace.Xmlns + "folder", _folderNs.NamespaceName));

                foreach (FTPQuickSetData data in stnfQuickSetDatas)
                {
                    string scanSettings = string.Format(Resources.scanSettings, data.ScanSetData.ContentOrientation.Key,
                                                        data.ScanSetData.OriginalSize.Key, data.ScanSetData.OriginalSides.Key);
                    string attachmentSettings = string.Format(Resources.attachmentSettings,
                                                              data.FileSetData.FileType.Key, data.FileSetData.Resolution.Key);
                    string displaySettings = string.Format(Resources.displaySettings, data.Name, _priority++);


                    List <string> sendFTPDestinations = new List <string>();

                    sendFTPDestinations.Add(string.Format(Resources.sendFTPDestination, data.FTPServer, data.PortNumber, data.DirectoryPath, data.UserName, data.FTPProtocol));


                    var sendFolderDestination = String.Join(String.Empty, sendFTPDestinations);

                    //string extraJob = string.Format(Resources.sendFTPDestination, data.FTPServer.FirstOrDefault());
                    string sendFTPDestination  = string.Format(Resources.sendFTPDestination, data.FTPServer, data.PortNumber, data.DirectoryPath, data.UserName, data.FTPProtocol);
                    string folderPredefinedJob = string.Format(Resources.sendFolderPredefinedJob, data.Name,
                                                               Resources.notificationSettings, scanSettings, data.ScanSetData.ImagePreview.Key,
                                                               attachmentSettings, sendFTPDestination, displaySettings, sendFTPDestination);

                    folderPredefinedJobs.Add(ParseFragment("folder:PredefinedJob", folderPredefinedJob, _nameSpaceDictionary));
                }

                n = new WebServiceTicket(folderPredefinedJobs);

                return(n);
            };

            return(UpdateField(change, device, quick, activityUrn, endpoint, assetInfo, fieldChanged, datas));
        }
        /// <summary>
        /// Execution Entry point
        /// Individual function differences separated into delagate methods.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="assetInfo"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool ExecuteJob(JediDevice device, AssetInfo assetInfo, PluginExecutionData data)
        {
            Type type   = typeof(JobSettingsData);
            bool result = true;

            Dictionary <string, object> properties = new Dictionary <string, object>();

            foreach (PropertyInfo prop in type.GetProperties())
            {
                properties.Add(prop.Name, prop.GetValue(this));
            }

            if (!assetInfo.Attributes.HasFlag(AssetAttributes.Printer))
            {
                _failedSettings.AppendLine("Device has no Print capability, skipping Job Settings");

                DeviceConfigResultLog log =
                    new DeviceConfigResultLog(data, assetInfo.AssetId)
                {
                    FieldChanged   = "Job Settings",
                    Result         = "Skipped",
                    Value          = "NA",
                    ControlChanged = "Job Default"
                };

                ExecutionServices.DataLogger.Submit(log);
                return(false);
            }

            foreach (var item in properties)
            {
                switch (item.Key)
                {
                case "EnableJobStorage":
                    result &= SetJobStorageDefaultValues("StoredJobsEnabled", (DataPair <string>)item.Value, device, assetInfo, "Enable JobStorage", data);
                    break;

                case "MinLengthPin":
                    result &= SetJobStorageDefaultValues("PINLength", (DataPair <string>)item.Value, device, assetInfo, "MinLengthPin", data);
                    break;

                case "JobsPinRequired":
                    result &= SetJobStorageDefaultValues("SaveToDeviceMemoryJobsPinRequired", (DataPair <string>)item.Value, device, assetInfo, "Jobs Pin Requirement", data);
                    break;

                case "DefaultFolderName":
                    result &= SetJobStorageDefaultValues("PublicFolderName", (DataPair <string>)item.Value, device, assetInfo, "Folder Name", data);
                    break;

                case "RetainJobs":
                    result &= SetJobStorageDefaultValues("RetainTemporaryJobsMode", (DataPair <string>)item.Value, device, assetInfo, "Job Retention", data);
                    break;
                }
            }

            return(result);
        }
        /// <summary>
        /// Interface function to drive setting of data fields and return results upstream
        /// </summary>
        /// <param name="device"></param>
        /// <param name="assetInfo"></param>
        /// <param name="pluginExecutionData"></param>
        /// <returns>result</returns>
        public DataPair <string> SetFields(JediDevice device, AssetInfo assetInfo, PluginExecutionData data)
        {
            _failedSettings = new StringBuilder();
            var result = ExecuteJob(device, assetInfo, data);

            return(new DataPair <string> {
                Key = _failedSettings.ToString(), Value = result
            });
        }
        public DataPair <string> VerifyFields(JediDevice device)
        {
            _failedSettings = new StringBuilder();
            var result = GetFields(device);

            return(new DataPair <string> {
                Key = _failedSettings.ToString(), Value = result
            });
        }
        private bool SetActivityTimeout(DataPair <string> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:uiconfiguration:UIConfigurationService";
            string endpoint    = "uiconfiguration";
            string name        = "ActivityTimeout";

            Func <WebServiceTicket, bool> change = n => n.FindElement("InactivityTimeoutInSeconds").Value.Equals(pair.Key, StringComparison.OrdinalIgnoreCase);

            return(UpdateField(change, device, pair, activityUrn, endpoint, name));
        }
        private bool SetSyncWithServer(DataPair <bool> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:time:TimeService";
            string endpoint    = "time";
            string name        = "SyncWithServer";

            Func <WebServiceTicket, bool> change = n => n.FindElement("EnableDisable").Value == pair.Key.ToString();

            return(UpdateField(change, device, pair, activityUrn, endpoint, name));
        }
        private bool SetServerAddress(DataPair <string> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:time:TimeService";
            string endpoint    = "time";
            string name        = "ServerAddress";

            Func <WebServiceTicket, bool> change = n => n.FindElement("SNTPServerAddress").Value.Equals(pair.Key, StringComparison.OrdinalIgnoreCase);

            return(UpdateField(change, device, pair, activityUrn, endpoint, name));
        }
Exemple #24
0
        public bool SetProxyList(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string          oid    = "1.3.6.1.4.1.11.2.4.3.18.16.0";
            Action <string> change = n =>
            {
                device.Snmp.Set(oid, pair.Key);
            };

            return(UpdateWithOid(change, device, pair, assetInfo, fieldChanged, data));
        }
Exemple #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JediDeviceSettingsManager" /> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <exception cref="ArgumentNullException"><paramref name="device" /> is null.</exception>
        public JediDeviceSettingsManager(JediDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            _address  = IPAddress.Parse(device.Address);
            _password = device.AdminPassword;
        }
        private bool GetWindowsAuthentication(DataPair <bool> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:windowsauthenticationagent:WindowsAuthenticationAgentService:AgentSettings";
            string endpoint    = "windowsauthenticationagent";
            string name        = "DefaultDomain";

            Func <WebServiceTicket, bool> getProperty = n => n.FindElement("EnableDisable").Value == pair.Key.ToString();

            return(UpdateField(getProperty, device, pair, activityUrn, endpoint, name));
        }
Exemple #27
0
        private bool SetFileType(DataPair <string> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:email:EmailService:DefaultJob";
            string endpoint    = "email";
            string name        = "FileType";

            Func <WebServiceTicket, bool> change = n => n.FindElement("DSFileType").Value.Equals(pair.Key, StringComparison.OrdinalIgnoreCase);

            return(UpdateField(change, device, pair, activityUrn, endpoint, name));
        }
        private bool SetEnglishDefault(DataPair <bool> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:uiconfiguration:UIConfigurationService:ServiceDefaults";
            string endpoint    = "uiconfiguration";
            string name        = "DefaultToEnglish";

            Func <WebServiceTicket, bool> change = n => n.FindElement("DefaultLanguageSetting").Value == "en-US";

            return(UpdateField(change, device, pair, activityUrn, endpoint, name));
        }
Exemple #29
0
        private bool SetEnableScanToEmail(DataPair <string> pair, JediDevice device)
        {
            string activityUrn = "urn:hp:imaging:con:service:email:EmailService";
            string endpoint    = "email";
            string name        = "EnableScanToEmail";

            Func <WebServiceTicket, bool> getProperty = n => n.FindElement("SendToEmailEnabled").Value.Equals(pair.Key, StringComparison.OrdinalIgnoreCase);

            return(UpdateField(getProperty, device, pair, activityUrn, endpoint, name));
        }
Exemple #30
0
        private bool SetFTPQuickSetData(IEnumerable <FTPQuickSetData> group, JediDevice device)
        {
            string activityUrn      = "urn:hp:imaging:con:service:folder:FolderService:PredefinedJobs";
            string endpoint         = "folder";
            string name             = "FTPQuickSet";
            var    ftpQuickSetDatas = group as IList <FTPQuickSetData> ?? group.ToList();
            DataPair <IEnumerable <FTPQuickSetData> > quick = new DataPair <IEnumerable <FTPQuickSetData> >
            {
                Value = true,
                Key   = ftpQuickSetDatas
            };

            Func <WebServiceTicket, bool> change = n =>
            {
                bool result = true;

                var jobs = n.Elements(_folderNs + "PredefinedJob").ToList();

                foreach (var data in ftpQuickSetDatas)
                {
                    var job = jobs.Find(x => x.Element(_dd + "DeviceJobName").Value == data.Name);
                    if (job == null)
                    {
                        result = false;
                        continue;
                    }

                    result &= job.Descendants(_dd + "OriginalContentOrientation").First().Value.Equals(data.ScanSetData.ContentOrientation.Key, StringComparison.OrdinalIgnoreCase);
                    result &= job.Descendants(_dd + "ScanMediaSize").First().Value.Equals(data.ScanSetData.OriginalSize.Key, StringComparison.OrdinalIgnoreCase);
                    result &= job.Descendants(_dd + "ScanPlexMode").First().Value.Equals(data.ScanSetData.OriginalSides.Key, StringComparison.OrdinalIgnoreCase);

                    result &= job.Descendants(_dd + "DSFileType").First().Value.Equals(data.FileSetData.FileType.Key, StringComparison.OrdinalIgnoreCase);
                    result &= job.Descendants(_dd + "DSImageResolution").First().Value.Equals(data.FileSetData.Resolution.Key, StringComparison.OrdinalIgnoreCase);

                    result &= job.Descendants(_dsd + "ImagePreview").First().Value.Equals(data.ScanSetData.ImagePreview.Key, StringComparison.OrdinalIgnoreCase);

                    var ftpDestinationElement = job.Element(_folderNs + "SendFolderDestinations")?.Element(_folderNs + "SendFTPDestination");
                    if (ftpDestinationElement == null)
                    {
                        result = false;
                        continue;
                    }

                    result &= ftpDestinationElement.Element(_dd3 + "NetworkID").Value.Equals(data.FTPServer, StringComparison.OrdinalIgnoreCase);
                    result &= ftpDestinationElement.Element(_dd + "Port").Value.Equals(data.PortNumber, StringComparison.OrdinalIgnoreCase);
                    result &= ftpDestinationElement.Element(_dd + "DirectoryPath").Value.Equals(data.DirectoryPath, StringComparison.OrdinalIgnoreCase);
                    result &= ftpDestinationElement.Element(_dd + "FTPProtocol").Value.Equals(data.FTPProtocol, StringComparison.OrdinalIgnoreCase);
                    result &= ftpDestinationElement.Descendants(_dd + "UserName").First().Value.Equals(data.UserName, StringComparison.OrdinalIgnoreCase);
                }
                return(result);
            };

            return(UpdateField(change, device, quick, activityUrn, endpoint, name));
        }