public object Persist(DataPair DataPair, int PersistencyType, IDictionary <string, object> Parameters)
        {
            switch (PersistencyType)
            {
            case 0:
            {
                this.helper            = new FileSystemHelper();
                this.helper.Parameters = Parameters;
                break;
            }

            case 1:
            {
                this.helper            = new RDBMSHelper();
                this.helper.Parameters = Parameters;
                break;
            }

            default:
            {
                this.helper = null;
                break;
            }
            }

            return(this.helper == null ? null : this.helper.Save(DataPair));
        }
Exemplo n.º 2
0
 /// <summary>
 /// this function use to add data to
 /// </summary>
 /// <param name="p"></param>
 public void Add(DataPair p)
 {
     lock (data0)
     {
         data0.Add(p);
     }
 }
Exemplo n.º 3
0
        public ActionResult Index(int?index)
        {
            Game currentGame = Session["game"] as Game;

            if (currentGame == null)
            {
                currentGame     = new Game();
                Session["game"] = currentGame;
            }
            ViewBag.Rules = currentGame.Rules;
            if (index == null)
            {
                return(View());
            }
            DataPair answer = currentGame.GetNumber((int)index);

            if (!string.IsNullOrEmpty(answer.TransformationLog))
            {
                ViewBag.Answer = answer.TransformationLog.Replace("\n", "<br/>");
            }
            else
            {
                ViewBag.Answer = "Der Index " + index + " ist unverändert";
            }
            return(View());
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
 public FileSettings()
 {
     FileName = new DataPair <string> {
         Key = string.Empty
     };
     FileNamePrefix = new DataPair <string> {
         Key = string.Empty
     };
     FileNameSuffix = new DataPair <string> {
         Key = string.Empty
     };
     FileType = new DataPair <string> {
         Key = string.Empty
     };
     Resolution = new DataPair <string> {
         Key = string.Empty
     };
     FileSize = new DataPair <string> {
         Key = string.Empty
     };
     FileColor = new DataPair <string> {
         Key = string.Empty
     };
     FileNumbering = new DataPair <string> {
         Key = string.Empty
     };
 }
Exemplo n.º 6
0
        public void populateGrid(string result)
        {
            dp = new List <DataPair>();
            Dictionary <string, List <string> > dictionary = FormatFunctions.createValuePairs(FormatFunctions.SplitToPairs(result));

            if (dictionary.Count > 0)
            {
                for (int i = 0; i < dictionary["IDKey"].Count; i++)
                {
                    DataPair         d    = new DataPair(int.Parse(dictionary["IDKey"][i]), dictionary["Index"][i], dictionary["Value"][i]);
                    List <UIElement> list = new List <UIElement>()
                    {
                        d.Index, d.Value
                    };
                    d.Index.Text = FormatFunctions.PrettyDate(dictionary["Index"][i]);
                    if (d.Index.Text.Contains("~"))
                    {
                        d.Value.Text = FormatFunctions.lookupAgentName(int.Parse(dictionary["Value"][i]));
                    }
                    else
                    {
                        d.Value.Text = FormatFunctions.PrettyDate(dictionary["Value"][i]);
                    }
                    GridFiller.rapidFillPremadeObjects(list, bodyGrid, new bool[] { true, true });
                    dp.Add(d);
                }
            }
        }
        static double GetMaxPrice(List <DataPair> originalList)
        {
            double max = 0;
            //using a new list and copying using foreach does not change the behaviour
            List <DataPair> copy = new List <DataPair>();

            foreach (var item in originalList)
            {
                DataPair a = (DataPair)item.Clone();
                copy.Add(a);
            }
            //List<DataPair> copy = originalList.Select(elt => elt.Clone()).ToList();

            copy.Sort();
            if (copy.Count > 0)
            {
                max = copy[originalList.Count - 1].Price;
            }

            foreach (DataPair item in copy)
            {
                item.Price = item.Volume = 0;
            }

            return(max);
        }
Exemplo n.º 8
0
        public ActionResult GetPositionDataBZ()
        {
            List <string>     legendData = new List <string>();
            StatisticsBZModel bz         = new StatisticsBZModel()
            {
                text    = "职位统计",
                subText = "统计时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
            };

            var             pos  = PositionService.LoadEntities(p => p.Id != 0);
            List <DataPair> data = new List <DataPair>();

            foreach (var item in pos)
            {
                int      count = UserInfoService.LoadEntities(u => u.PositionId == item.Id).Count();
                DataPair dp    = new DataPair()
                {
                    name  = item.Name,
                    value = count.ToString()
                };
                data.Add(dp);
                legendData.Add(item.Name);
            }
            bz.data       = data;
            bz.legendData = legendData;
            return(Json(bz, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
            // returns old value if the key already existed, IntPtr.Zero otherwise
            public IntPtr AddOrSet(uint key, IntPtr value)
            {
                // TODO: AddOrSet/Remove use linear search, binary search could be used
                // insert keeping the array sorted
                DataPair pairToInsert = new DataPair {
                    Key = key, Value = value
                };

                foreach (ref var pair in Pairs)
                {
                    if (pair.Key == pairToInsert.Key)
                    {
                        // key already exists, replace its value
                        var tmp = pair.Value;
                        pair.Value = pairToInsert.Value;
                        return(tmp);
                    }

                    // key does not exist, insert it in the middle, and move back the remaining pairs
                    if (pair.Key > pairToInsert.Key)
                    {
                        // swap
                        var tmp = pair;
                        pair         = pairToInsert;
                        pairToInsert = tmp;
                    }
                }

                // add the last pair
                Pairs.Add() = pairToInsert;
                return(IntPtr.Zero);
            }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes an instance of CopySettings Data.
        /// </summary>
        public CopySettingsData()
        {
            Copies = new DataPair <string> {
                Key = String.Empty
            };
            CopySides = new DataPair <string> {
                Key = String.Empty
            };
            Color = new DataPair <string> {
                Key = String.Empty
            };
            ScanMode = new DataPair <string> {
                Key = String.Empty
            };
            ReduceEnlarge = new DataPair <string> {
                Key = String.Empty
            };
            Collate = new DataPair <string> {
                Key = String.Empty
            };
            PagesPerSheet = new DataPair <string> {
                Key = string.Empty
            };

            ScanSettingsData = new ScanSettings();
        }
Exemplo n.º 11
0
        private void startListener()
        {
            this.communicationManager = new CommunicationManager()
            {
                LocalAddress  = ConfigurationManager.AppSettings.Get("LocalAddress"),
                RemoteAddress = ConfigurationManager.AppSettings.Get("RemoteAddress"),
                LocalPort     = int.Parse(ConfigurationManager.AppSettings.Get("LocalPort")),
                RemotePort    = int.Parse(ConfigurationManager.AppSettings.Get("RemotePort")),
                TimeToLive    = int.Parse(ConfigurationManager.AppSettings.Get("TimeToLive"))
            };

            this.communicationManager.Start();

            byte[] bytesReceived = null;

            int bytesCount = -1;

            while (true)
            {
                bytesReceived = this.communicationManager.Receive(out bytesCount);

                if ((bytesCount > 0) && (bytesReceived != null) && (bytesReceived.Length > 0))
                {
                    DataIdentifier identifier = CommonUtility.BinaryDeserialize(bytesReceived) as DataIdentifier; //JsonUtility.JsonDeserialize(bytesReceived, typeof(DataIdentifier), null, null) as DataIdentifier;

                    DataPair pair = this.doAcquisition(identifier);

                    this.saveDataPair(pair);

                    Thread thread = new Thread(this.threadProcSafe);

                    thread.Start(pair);
                }
            }
        }
        public void PostResult(AgentInstructions instructions, AgentInstructionsResult r)
        {
            DataPair[] results = r.Data;
            if (results == null)
            {
                throw new Exception("Get Initial Data received no response data");
            }
            DataPair result = results.FirstOrDefault(x => x.Name == "initialData");

            if (result == null || !(result.OutputValue is OpcInitialData))
            {
                throw new Exception("Get Initial Data did not get the expected data");
            }
            OpcInitialData initialData = result.OutputValue as OpcInitialData;

            string url = instructions.Data.FirstOrDefault(d => d.Name == "opcServerUrl")?.OutputValue as string;

            if (string.IsNullOrEmpty(url))
            {
                throw new Exception("No URL found in agent instructions");
            }
            bool?valuesOnly = instructions.Data.FirstOrDefault(d => d.Name == "valuesOnly")?.OutputValue as bool?;

            if (valuesOnly == false && initialData.Values == null)
            {
                throw new Exception("No values found in agent instructions");
            }

            OPCEngine.HandleInitialData(url, initialData);
        }
Exemplo n.º 13
0
        private void saveDataPair(DataPair pair)
        {
            string imageStore = this.textBoxDefaultImageStore.Text;

            imageStore = imageStore.EndsWith("\\") ? imageStore.Substring(0, (imageStore.Length - 1)) : imageStore;

            string imageDirectory = String.Format("{0}\\{1}", imageStore, pair.Identifier.DataUniqueID);

            if (!Directory.Exists(imageDirectory))
            {
                Directory.CreateDirectory(imageDirectory);
            }

            string filePath;

            FileStream fileStream;

            foreach (DataItem item in pair.Items)
            {
                filePath = String.Format("{0}\\{1}.bmp", imageDirectory, item.CreationTime.ToString("yyyy-MM-dd-hh-mm-ss"));

                fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Write);

                fileStream.Write(pair.Items[0].DataBytes, 0, pair.Items[0].DataBytes.Length);

                fileStream.Flush();

                fileStream.Close();

                this.acquiredImagePaths.Add(filePath);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        ///     스트림에서 설정을 읽어옵니다.
        /// </summary>
        /// <param name="stream">읽어올 스트림입니다.</param>
        public override void Read(Stream stream)
        {
            StreamReader streamReader = new StreamReader(stream, Encoding.UTF8);

            while (!streamReader.EndOfStream)
            {
                string data = streamReader.ReadLine();

                //분할 코드 추출
                DivisionCode currentDivisionCode = AccessibleConfig.GetDivisionCode(data);
                if (currentDivisionCode != DivisionCode.None)
                {
                    string divisionString = AccessibleConfig.GetDivisionString(currentDivisionCode);
                    int    index          = data.IndexOf(divisionString);

                    string   key      = data.Substring(0, index);
                    string   value    = data.Substring(index + divisionString.Length);
                    DataPair dataPair = new DataPair(currentDivisionCode, value);

                    //읽어온 설정을 등록
                    if (this.configData.ContainsKey(key))
                    {
                        this.configData.Remove(key);
                    }
                    this.configData.Add(key, dataPair);
                }
            }
        }
Exemplo n.º 15
0
 private void btnShowData_Click(object sender, RoutedEventArgs e)
 {
     if (_DoubleTimeSeries != null)
     {
         datagrid.ItemsSource = DataPair.ToList(_DoubleTimeSeries);
     }
 }
Exemplo n.º 16
0
        public void populateFields(string result)
        {
            Dictionary <string, List <string> > dictionary = FormatFunctions.createValuePairs(FormatFunctions.SplitToPairs(result));

            this.entryDict = new List <DataPair>();
            if (dictionary.Count > 0)
            {
                for (int i = 0; i < dictionary["Index"].Count; i++)
                {
                    DataPair dataPair = new DataPair(int.Parse(dictionary["IDKey"][i]), dictionary["Value"][i], dictionary["Index"][i]);
                    dataPair.Value.Text              = dictionary["Value"][i];
                    dataPair.Value.Placeholder       = "Value here";
                    dataPair.Value.FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                    dataPair.Value.VerticalOptions   = LayoutOptions.CenterAndExpand;
                    dataPair.Value.HorizontalOptions = LayoutOptions.StartAndExpand;
                    dataPair.Index.Text              = dictionary["Index"][i];
                    dataPair.Index.Placeholder       = "Index here";
                    dataPair.Index.FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                    dataPair.Index.VerticalOptions   = LayoutOptions.CenterAndExpand;
                    dataPair.Index.HorizontalOptions = LayoutOptions.EndAndExpand;
                    ViewCell    viewCell    = new ViewCell();
                    StackLayout stackLayout = new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal
                    };
                    this.entryDict.Add(dataPair);

                    List <View> list = new List <View>();
                    list.Add(dataPair.Value);
                    list.Add(dataPair.Index);
                    GridFiller.rapidFillPremadeObjects(list, TSection, new bool[] { true, true });
                }
            }
        }
Exemplo n.º 17
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));
        }
Exemplo n.º 18
0
        public void populatePage(string result)
        {
            Dictionary <string, List <string> > dictionary = FormatFunctions.createValuePairs(FormatFunctions.SplitToPairs(result));

            entryDict           = new List <DataPair>();
            NameDisplay.Content = FormatFunctions.PrettyDate(dictionary["Name"][0]);
            if (dictionary.Count > 0)
            {
                for (int i = 0; i < dictionary["Index"].Count; i++)
                {
                    DataPair dataPair = new DataPair(int.Parse(dictionary["FID"][i]), dictionary["value"][i], dictionary["Index"][i]);
                    dataPair.Value.Text    = FormatFunctions.PrettyDate(dictionary["value"][i]);
                    dataPair.Value.ToolTip = "Value here";
                    dataPair.Index.Text    = FormatFunctions.PrettyDate(dictionary["Index"][i]);
                    dataPair.Index.ToolTip = "Index here";
                    List <UIElement> list = new List <UIElement>()
                    {
                        dataPair.Index, dataPair.Value
                    };
                    int[]  space = new int[] { 2, 2 };
                    bool[] box   = new bool[] { true, true };
                    GridFiller.rapidFillSpacedPremadeObjects(list, mainGrid, space, box);
                    this.entryDict.Add(dataPair);
                }
            }
            //this.populateFileList();
        }
Exemplo n.º 19
0
        public PrintSettingsData()
        {
            PrintFromUsb = new DataPair <string> {
                Key = string.Empty
            };
            Copies = new DataPair <string> {
                Key = String.Empty
            };
            OriginalSize = new DataPair <string> {
                Key = String.Empty
            };

            PaperType = new DataPair <string> {
                Key = String.Empty
            };
            PaperTray = new DataPair <string> {
                Key = String.Empty
            };

            OutputSides = new DataPair <string> {
                Key = String.Empty
            };
            OutputBin = new DataPair <string> {
                Key = String.Empty
            };

            Resolution = new DataPair <string> {
                Key = String.Empty
            };
        }
Exemplo n.º 20
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));
        }
Exemplo n.º 21
0
        public void populatePage(string result)
        {
            Dictionary <string, List <string> > dictionary = FormatFunctions.createValuePairs(FormatFunctions.SplitToPairs(result));

            entryDict        = new List <DataPair>();
            NameDisplay.Text = dictionary["Name"][0];
            if (dictionary.Count > 0)
            {
                for (int i = 0; i < dictionary["Index"].Count; i++)
                {
                    DataPair dataPair = new DataPair(int.Parse(dictionary["FID"][i]), dictionary["value"][i], dictionary["Index"][i]);
                    dataPair.Value.Text              = dictionary["value"][i];
                    dataPair.Value.Placeholder       = "Value here";
                    dataPair.Value.FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                    dataPair.Value.VerticalOptions   = LayoutOptions.CenterAndExpand;
                    dataPair.Value.HorizontalOptions = LayoutOptions.StartAndExpand;
                    dataPair.Index.Text              = dictionary["Index"][i];
                    dataPair.Index.Placeholder       = "Index here";
                    dataPair.Index.FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                    dataPair.Index.VerticalOptions   = LayoutOptions.CenterAndExpand;
                    dataPair.Index.HorizontalOptions = LayoutOptions.EndAndExpand;
                    List <View> list = new List <View>()
                    {
                        dataPair.Index, dataPair.Value
                    };
                    int[]  space = new int[] { 2, 2 };
                    bool[] box   = new bool[] { true, true };
                    GridFiller.rapidFillSpacedPremadeObjects(list, mainGrid, space, box);
                    this.entryDict.Add(dataPair);
                }
            }
            this.populateFileList();
        }
        // from Decisions.Agent.Handlers.Helpers.DataPairExtensions
        public static T GetValueByKey <T>(this DataPair[] data, string key)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            DataPair pair = data.FirstOrDefault(d => (d.Name == key));

            if (pair == null)
            {
                throw new Exception(string.Format("Data is not found by name: {0}", key));
            }
            if (pair.OutputValue == null)
            {
                return(default(T));
            }
            if (false == pair.OutputValue is T)
            {
                throw new Exception(string.Format("Value ({0}) is not type of {1}", key, typeof(T).Name));
            }
            return((T)pair.OutputValue);
        }
Exemplo n.º 23
0
        public void onClickAddFields(object sender, EventArgs e)
        {
            DataPair dataPair = new DataPair(0, "", "");

            dataPair.setNew();
            dataPair.Value.Text              = "";
            dataPair.Value.Placeholder       = "Index here";
            dataPair.Value.FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
            dataPair.Value.VerticalOptions   = LayoutOptions.CenterAndExpand;
            dataPair.Value.HorizontalOptions = LayoutOptions.StartAndExpand;
            dataPair.Index.Text              = "";
            dataPair.Index.Placeholder       = "Value here";
            dataPair.Index.FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
            dataPair.Index.VerticalOptions   = LayoutOptions.CenterAndExpand;
            dataPair.Index.HorizontalOptions = LayoutOptions.EndAndExpand;
            ViewCell    viewCell    = new ViewCell();
            StackLayout stackLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal
            };
            List <View> list = new List <View>();

            list.Add(dataPair.Value);
            list.Add(dataPair.Index);
            GridFiller.rapidFillPremadeObjects(list, TSection, new bool[] { true, true });
            this.entryDict.Add(dataPair);
        }
Exemplo n.º 24
0
 public EmailSettingsData()
 {
     EnableScanToEmail = new DataPair <string> {
         Key = string.Empty
     };
     SMTPServer = new DataPair <string> {
         Key = string.Empty
     };
     FromUser = new DataPair <string> {
         Key = string.Empty
     };
     DefaultFrom = new DataPair <string> {
         Key = string.Empty
     };
     To = new DataPair <string> {
         Key = string.Empty
     };
     OriginalSize = new DataPair <string> {
         Key = string.Empty
     };
     OriginalSides = new DataPair <string> {
         Key = string.Empty
     };
     ImagePreview = new DataPair <string> {
         Key = string.Empty
     };
     FileType = new DataPair <string> {
         Key = string.Empty
     };
     Resolution = new DataPair <string> {
         Key = string.Empty
     };
 }
Exemplo n.º 25
0
 public ItemOutDoubleArrayBase(string id, ITime initialTime, double[] initialValues, double relaxation)
     : base(id)
 {
     _initial     = new DataPair(initialTime, initialValues);
     _relaxation  = relaxation;
     _arrayLength = initialValues.Length;
 }
Exemplo n.º 26
0
 public ManageTraysSettingData()
 {
     UseRequestedTray = new DataPair <string> {
         Key = string.Empty
     };
     ManualFeedPrompt = new DataPair <string> {
         Key = string.Empty
     };
     SizeTypePrompt = new DataPair <string> {
         Key = string.Empty
     };
     UseAnotherTray = new DataPair <string> {
         Key = string.Empty
     };
     AlternativeLetterHeadMode = new DataPair <string> {
         Key = string.Empty
     };
     DuplexBlankPages = new DataPair <string> {
         Key = string.Empty
     };
     ImageRotation = new DataPair <string> {
         Key = string.Empty
     };
     OverrideA4Letter = new DataPair <string> {
         Key = string.Empty
     };
 }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
0
        private bool GetFaxDefaultJobValues(string elementName, DataPair <string> itemValue, JediDevice device, string fieldChanged)
        {
            string activityUrn = "urn:hp:imaging:con:service:fax:FaxService:DefaultJobs";
            string endpoint    = "fax";
            Func <WebServiceTicket, bool> getProperty = n => n.FindElement(elementName).Value.Equals(itemValue.Key, StringComparison.OrdinalIgnoreCase);

            return(UpdateField(getProperty, device, itemValue, activityUrn, endpoint, fieldChanged));
        }
Exemplo n.º 29
0
 public QuickSetSettingsData()
 {
     QuickSetData = new DataPair <Collection <AQuickSet> >
     {
         Key   = new Collection <AQuickSet>(),
         Value = true
     };
 }
        public override DataPair[] GetValue()
        {
            DataPair pair = new DataPair();

            pair.Name        = ElementData.Child.DataName;
            pair.OutputValue = (View as RadioButton).IsChecked;
            return(new DataPair[] { pair });
        }