private bool GetNetwork() { bool result = false; APIResponse apiresponse = _connect.Get("/network", Connect.Method.GET); if (apiresponse.StatusCode == 200) { API_Network apinetwork = JSON.Deserialize <API_Network>(apiresponse.Response); if (apinetwork != null) { NetworkSetting tmp = new NetworkSetting(); tmp.IPAddress = apinetwork.data.attributes.ipAddress; tmp.NetMask = apinetwork.data.attributes.ipNetmask; tmp.Gateway = apinetwork.data.attributes.ipGateway; tmp.MACAddress = apinetwork.data.attributes.macAddress; tmp.UseDhcp = apinetwork.data.attributes.useDhcp; if (Network == null) { Network = new NetworkSetting(); } if (!Network.Equals(tmp)) { Network = tmp; NetworkSettingsEvent(this, new EventArgs()); } result = true; } } return(result); }
void SetCurrentDNSExcute() { string[] dns = new string[] { ActiveDNS.DNS1, ActiveDNS.DNS2 }; NetworkSetting.SetDNS(dns); SystemDNS.RefreshSystemDNS(); }
public Task <object> SetSettings(NetworkSetting settings) { var request = NewRequest("setGeneralSettings"); request.Params = settings; var result = RunCmd <object>(request); return(result); }
/// <summary> /// Creates the campaign with a portfolio bidding strategy. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="name">The campaign name.</param> /// <param name="biddingStrategyId">The bidding strategy id.</param> /// <param name="sharedBudgetId">The shared budget id.</param> /// <returns>The campaign object.</returns> private Campaign CreateCampaignWithBiddingStrategy(AdWordsUser user, string name, long biddingStrategyId, long sharedBudgetId) { using (CampaignService campaignService = (CampaignService)user.GetService(AdWordsService.v201806.CampaignService)) { // Create campaign. Campaign campaign = new Campaign { name = name, advertisingChannelType = AdvertisingChannelType.SEARCH, // Recommendation: Set the campaign to PAUSED when creating it to prevent // the ads from immediately serving. Set to ENABLED once you've added // targeting and the ads are ready to serve. status = CampaignStatus.PAUSED, // Set the budget. budget = new Budget { budgetId = sharedBudgetId } }; // Set bidding strategy (required). BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration { biddingStrategyId = biddingStrategyId }; campaign.biddingStrategyConfiguration = biddingStrategyConfiguration; // Set network targeting (recommended). NetworkSetting networkSetting = new NetworkSetting { targetGoogleSearch = true, targetSearchNetwork = true, targetContentNetwork = true }; campaign.networkSetting = networkSetting; // Create operation. CampaignOperation operation = new CampaignOperation { operand = campaign, @operator = Operator.ADD }; return(campaignService.mutate(new CampaignOperation[] { operation }).value[0]); } }
public void RefreshSystemDNS() { string[] dns = NetworkSetting.GetSystemDNS(); if (dns.Count() > 0) { DNS1 = dns[0]; } if (dns.Count() > 1) { DNS2 = dns[1]; } }
private static void SaveIPSetting(XmlDocument config, UserOperation operation, XmlNode operationSetting) { NetworkSetting ns = operation.Setting as NetworkSetting; XmlNode ip = config.CreateNode(XmlNodeType.Element, "IP", null); ip.InnerText = ns.Ip; XmlNode port = config.CreateNode(XmlNodeType.Element, "Port", null); port.InnerText = ns.Port.ToString(); operationSetting.AppendChild(ip); operationSetting.AppendChild(port); }
private void btnSetting_Click(object sender, EventArgs e) { if (cbOprationType.Text == "TCP" || cbOprationType.Text == "UDP") { IpSetting settingForm = new IpSetting(); if (Setting != null && (Setting as NetworkSetting) != null) { NetworkSetting ns = (NetworkSetting)Setting; settingForm.Ip = ns.Ip; settingForm.Port = ns.Port; } if (settingForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { NetworkSetting ns = new NetworkSetting(); ns.Ip = settingForm.Ip; ns.Port = settingForm.Port; Setting = ns; } } else if (cbOprationType.Text == "串口") { SerialPortSetting settingForm = new SerialPortSetting(); if (Setting != null && (Setting as ComSetting) != null) { ComSetting cs = (ComSetting)Setting; settingForm.ComNumber = cs.ComNumber; settingForm.BaudRate = cs.BaudRate; settingForm.Databit = cs.DataBits; settingForm.StopBit = cs.StopBits; settingForm.Parity = cs.Parity; } if (settingForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ComSetting cs = new ComSetting(); cs.ComNumber = settingForm.ComNumber; cs.BaudRate = settingForm.BaudRate; cs.StopBits = settingForm.StopBit; cs.DataBits = settingForm.Databit; cs.Parity = settingForm.Parity; Setting = cs; } } }
private void Client_Settings(string id, Settings e) { if (hybridsCreated || e.Key != "asterisk_hybrid_extensions" || e.Items.Count < 1) { return; } hybridsCreated = true; NetworkSetting setting = e.Items.First(); int[] hybrids = (int[])setting.Value; Grid grid = CreateHybridGrid(hybrids); HybridsFrame.Content = grid; }
/// <summary> /// Creates the campaign with a shared bidding strategy. /// </summary> /// <param name="campaignService">The campaign service.</param> /// <param name="name">The campaign name.</param> /// <param name="biddingStrategyId">The bidding strategy id.</param> /// <param name="sharedBudgetId">The shared budget id.</param> /// <returns>The campaign object.</returns> private Campaign CreateCampaignWithBiddingStrategy(CampaignService campaignService, string name, long biddingStrategyId, long sharedBudgetId) { // Create campaign. Campaign campaign = new Campaign(); campaign.name = name; campaign.advertisingChannelType = AdvertisingChannelType.SEARCH; // Set the budget. campaign.budget = new Budget(); campaign.budget.budgetId = sharedBudgetId; // Set bidding strategy (required). BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration(); biddingStrategyConfiguration.biddingStrategyId = biddingStrategyId; campaign.biddingStrategyConfiguration = biddingStrategyConfiguration; // Set keyword matching setting (required). KeywordMatchSetting keywordMatchSetting = new KeywordMatchSetting(); keywordMatchSetting.optIn = true; campaign.settings = new Setting[] { keywordMatchSetting }; // Set network targeting (recommended). NetworkSetting networkSetting = new NetworkSetting(); networkSetting.targetGoogleSearch = true; networkSetting.targetSearchNetwork = true; networkSetting.targetContentNetwork = true; campaign.networkSetting = networkSetting; // Create operation. CampaignOperation operation = new CampaignOperation(); operation.operand = campaign; operation.@operator = Operator.ADD; return(campaignService.mutate(new CampaignOperation[] { operation }).value[0]); }
/// <summary> /// Creates the campaign with a portfolio bidding strategy. /// </summary> /// <param name="campaignService">The campaign service.</param> /// <param name="name">The campaign name.</param> /// <param name="biddingStrategyId">The bidding strategy id.</param> /// <param name="sharedBudgetId">The shared budget id.</param> /// <returns>The campaign object.</returns> private Campaign CreateCampaignWithBiddingStrategy(CampaignService campaignService, string name, long biddingStrategyId, long sharedBudgetId) { // Create campaign. Campaign campaign = new Campaign(); campaign.name = name; campaign.advertisingChannelType = AdvertisingChannelType.SEARCH; // Recommendation: Set the campaign to PAUSED when creating it to prevent // the ads from immediately serving. Set to ENABLED once you've added // targeting and the ads are ready to serve. campaign.status = CampaignStatus.PAUSED; // Set the budget. campaign.budget = new Budget(); campaign.budget.budgetId = sharedBudgetId; // Set bidding strategy (required). BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration(); biddingStrategyConfiguration.biddingStrategyId = biddingStrategyId; campaign.biddingStrategyConfiguration = biddingStrategyConfiguration; // Set network targeting (recommended). NetworkSetting networkSetting = new NetworkSetting(); networkSetting.targetGoogleSearch = true; networkSetting.targetSearchNetwork = true; networkSetting.targetContentNetwork = true; campaign.networkSetting = networkSetting; // Create operation. CampaignOperation operation = new CampaignOperation(); operation.operand = campaign; operation.@operator = Operator.ADD; return(campaignService.mutate(new CampaignOperation[] { operation }).value[0]); }
/// <summary> /// Creates the campaign with a shared bidding strategy. /// </summary> /// <param name="campaignService">The campaign service.</param> /// <param name="name">The campaign name.</param> /// <param name="biddingStrategyId">The bidding strategy id.</param> /// <param name="sharedBudgetId">The shared budget id.</param> /// <returns>The campaign object.</returns> private Campaign CreateCampaignWithBiddingStrategy(CampaignService campaignService, string name, long biddingStrategyId, long sharedBudgetId) { // Create campaign. Campaign campaign = new Campaign(); campaign.name = name; campaign.advertisingChannelType = AdvertisingChannelType.SEARCH; // Set the budget. campaign.budget = new Budget(); campaign.budget.budgetId = sharedBudgetId; // Set bidding strategy (required). BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration(); biddingStrategyConfiguration.biddingStrategyId = biddingStrategyId; campaign.biddingStrategyConfiguration = biddingStrategyConfiguration; // Set network targeting (recommended). NetworkSetting networkSetting = new NetworkSetting(); networkSetting.targetGoogleSearch = true; networkSetting.targetSearchNetwork = true; networkSetting.targetContentNetwork = true; campaign.networkSetting = networkSetting; // Create operation. CampaignOperation operation = new CampaignOperation(); operation.operand = campaign; operation.@operator = Operator.ADD; return campaignService.mutate(new CampaignOperation[] {operation}).value[0]; }
//加载时间轴配置 public List <UserAction> LoadTimeShaft() { try { XmlDocument config = new XmlDocument(); config.Load(_configFile); XmlNode root = config.SelectSingleNode("Root"); #region LoadTimeShaft XmlNode timeShafts = root.SelectSingleNode("TimeShaft"); XmlNodeList timeActions = timeShafts.SelectNodes("Action"); _shaft_actions.Clear(); foreach (XmlNode action in timeActions) { string actionName = action.SelectSingleNode("ActionName").InnerText; string actionReceiveData = action.SelectSingleNode("ActionReceiveData").InnerText; UserAction userAction = new UserAction(actionName, actionReceiveData); _shaft_actions.Add(userAction); XmlNodeList operations = action.SelectNodes("Operation"); foreach (XmlNode operation in operations) { string operationName = operation.SelectSingleNode("OperationName").InnerText; string operationTypeString = operation.SelectSingleNode("OperationType").InnerText; CommunicationType operationType = (CommunicationType)Enum.Parse(typeof(CommunicationType), operationTypeString, true); XmlNode operationSetting = operation.SelectSingleNode("OperationSetting"); object setting = null; if (operationType == CommunicationType.Com) { ComSetting cs = new ComSetting(); cs.ComNumber = operationSetting.SelectSingleNode("ComNumber").InnerText; cs.BaudRate = int.Parse(operationSetting.SelectSingleNode("BaudRate").InnerText); cs.DataBits = int.Parse(operationSetting.SelectSingleNode("DataBit").InnerText); cs.StopBits = int.Parse(operationSetting.SelectSingleNode("StopBit").InnerText); cs.Parity = (Parity)Enum.Parse(typeof(Parity), operationSetting.SelectSingleNode("Parity").InnerText); setting = cs; } else if (operationType == CommunicationType.TCP || operationType == CommunicationType.UDP) { NetworkSetting ns = new NetworkSetting(); ns.Ip = operationSetting.SelectSingleNode("IP").InnerText; ns.Port = int.Parse(operationSetting.SelectSingleNode("Port").InnerText); setting = ns; } string dataTypeString = operation.SelectSingleNode("OperationDataType").InnerText; DataType dataType = (DataType)Enum.Parse(typeof(DataType), dataTypeString, true); string data = operation.SelectSingleNode("OperationData").InnerText; int time = int.Parse(operation.SelectSingleNode("OperationTime").InnerText); UserOperation userOperation = new UserOperation(operationName, operationType, dataType, setting, data, time); userAction.Operations.Add(userOperation); } } return(_shaft_actions); #endregion } catch (Exception ex) { Helper.ShowMessageBox("提示", "未找到配置命令!"); return(null); } }
public SetNetworkSettingRequest(NetworkSetting networkSetting) : base( _commandText + $"\"{networkSetting.ToJson(true)}\"") { }
public async Task <bool> SetNetworkSetting(NetworkSetting networkSetting) { var result = await _omvNetworkClient.SetSettings(networkSetting); return(result != null); }
//加载预约配置 public List <UserOrder> LoadOrderConfig() { try { XmlDocument config = new XmlDocument(); config.Load(_timelineConfig); XmlNode root = config.SelectSingleNode("Root"); XmlNodeList areas = root.SelectNodes("DelayTime"); _orders.Clear(); foreach (XmlNode area in areas) { string areaName = area.SelectSingleNode("TimeValue").InnerText; UserOrder order = new UserOrder(0, 0); order.SetValue(areaName); _orders.Add(order); XmlNodeList operations = area.SelectNodes("Operation"); foreach (XmlNode operation in operations) { string operationName = operation.SelectSingleNode("OperationName").InnerText; string operationTypeString = operation.SelectSingleNode("OperationType").InnerText; CommunicationType operationType = (CommunicationType)Enum.Parse(typeof(CommunicationType), operationTypeString, true); XmlNode operationSetting = operation.SelectSingleNode("OperationSetting"); object setting = null; if (operationType == CommunicationType.Com) { ComSetting cs = new ComSetting(); cs.ComNumber = operationSetting.SelectSingleNode("ComNumber").InnerText; cs.BaudRate = int.Parse(operationSetting.SelectSingleNode("BaudRate").InnerText); cs.DataBits = int.Parse(operationSetting.SelectSingleNode("DataBit").InnerText); cs.StopBits = int.Parse(operationSetting.SelectSingleNode("StopBit").InnerText); cs.Parity = (Parity)Enum.Parse(typeof(Parity), operationSetting.SelectSingleNode("Parity").InnerText); setting = cs; } else if (operationType == CommunicationType.TCP || operationType == CommunicationType.UDP) { NetworkSetting ns = new NetworkSetting(); ns.Ip = operationSetting.SelectSingleNode("IP").InnerText; ns.Port = int.Parse(operationSetting.SelectSingleNode("Port").InnerText); setting = ns; } string dataTypeString = operation.SelectSingleNode("OperationDataType").InnerText; DataType dataType = (DataType)Enum.Parse(typeof(DataType), dataTypeString, true); string data = operation.SelectSingleNode("OperationData").InnerText; int time = int.Parse(operation.SelectSingleNode("OperationTime").InnerText); UserOperation userOperation = new UserOperation(operationName, operationType, dataType, setting, data, time); order.Operations.Add(userOperation); } } return(_orders); } catch (Exception ex) { Helper.ShowMessageBox("提示", "未找到配置文件!"); return(null); } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { // Get the TargetingIdeaService. TargetingIdeaService targetingIdeaService = (TargetingIdeaService)user.GetService(AdWordsService.v201601.TargetingIdeaService); // Create selector. TargetingIdeaSelector selector = new TargetingIdeaSelector(); selector.requestType = RequestType.IDEAS; selector.ideaType = IdeaType.KEYWORD; selector.requestedAttributeTypes = new AttributeType[] { AttributeType.KEYWORD_TEXT, AttributeType.SEARCH_VOLUME, AttributeType.CATEGORY_PRODUCTS_AND_SERVICES }; // Create the search parameters. string keywordText = "mars cruise"; // Create related to query search parameter. RelatedToQuerySearchParameter relatedToQuerySearchParameter = new RelatedToQuerySearchParameter(); relatedToQuerySearchParameter.queries = new String[] { keywordText }; // Add a language search parameter (optional). // The ID can be found in the documentation: // https://developers.google.com/adwords/api/docs/appendix/languagecodes // Note: As of v201302, only a single language parameter is allowed. LanguageSearchParameter languageParameter = new LanguageSearchParameter(); Language english = new Language(); english.id = 1000; languageParameter.languages = new Language[] { english }; // Add network search parameter (optional). NetworkSetting networkSetting = new NetworkSetting(); networkSetting.targetGoogleSearch = true; networkSetting.targetSearchNetwork = false; networkSetting.targetContentNetwork = false; networkSetting.targetPartnerSearchNetwork = false; NetworkSearchParameter networkSearchParameter = new NetworkSearchParameter(); networkSearchParameter.networkSetting = networkSetting; // Set the search parameters. selector.searchParameters = new SearchParameter[] { relatedToQuerySearchParameter, languageParameter, networkSearchParameter }; // Set selector paging (required for targeting idea service). Paging paging = Paging.Default; TargetingIdeaPage page = new TargetingIdeaPage(); try { int i = 0; do { // Get related keywords. page = targetingIdeaService.get(selector); // Display related keywords. if (page.entries != null && page.entries.Length > 0) { foreach (TargetingIdea targetingIdea in page.entries) { string keyword = null; string categories = null; long averageMonthlySearches = 0; foreach (Type_AttributeMapEntry entry in targetingIdea.data) { if (entry.key == AttributeType.KEYWORD_TEXT) { keyword = (entry.value as StringAttribute).value; } if (entry.key == AttributeType.CATEGORY_PRODUCTS_AND_SERVICES) { IntegerSetAttribute categorySet = entry.value as IntegerSetAttribute; StringBuilder builder = new StringBuilder(); if (categorySet.value != null) { foreach (int value in categorySet.value) { builder.AppendFormat("{0}, ", value); } categories = builder.ToString().Trim(new char[] { ',', ' ' }); } } if (entry.key == AttributeType.SEARCH_VOLUME) { averageMonthlySearches = (entry.value as LongAttribute).value; } } Console.WriteLine("Keyword with text '{0}', and average monthly search volume " + "'{1}' was found with categories: {2}", keyword, averageMonthlySearches, categories); i++; } } selector.paging.IncreaseOffset(); } while (selector.paging.startIndex < page.totalNumEntries); Console.WriteLine("Number of related keywords found: {0}", page.totalNumEntries); } catch (Exception e) { throw new System.ApplicationException("Failed to retrieve related keywords.", e); } }
public List <UserDefinedOperation> LoadUserDefinedData() { try { #region LoadUserDefinedData XmlDocument config = new XmlDocument(); config.Load(_userdefinedConfigFile); XmlNode root = config.SelectSingleNode("Root"); XmlNodeList actions = root.SelectNodes("Action"); _userdefineNames.Clear(); foreach (XmlNode action in actions) { string _actionName = action.Attributes["Name"].Value; UserDefinedOperation _deName = new UserDefinedOperation(_actionName); XmlNodeList operations = action.SelectNodes("Operation"); foreach (XmlNode operation in operations) { string operationName = operation.SelectSingleNode("OperationName").InnerText; string operationTypeString = operation.SelectSingleNode("OperationType").InnerText; CommunicationType operationType = (CommunicationType)Enum.Parse(typeof(CommunicationType), operationTypeString, true); XmlNode operationSetting = operation.SelectSingleNode("OperationSetting"); object setting = null; if (operationType == CommunicationType.Com) { ComSetting cs = new ComSetting(); cs.ComNumber = operationSetting.SelectSingleNode("ComNumber").InnerText; cs.BaudRate = int.Parse(operationSetting.SelectSingleNode("BaudRate").InnerText); cs.DataBits = int.Parse(operationSetting.SelectSingleNode("DataBit").InnerText); cs.StopBits = int.Parse(operationSetting.SelectSingleNode("StopBit").InnerText); cs.Parity = (Parity)Enum.Parse(typeof(Parity), operationSetting.SelectSingleNode("Parity").InnerText); setting = cs; } else if (operationType == CommunicationType.TCP || operationType == CommunicationType.UDP) { NetworkSetting ns = new NetworkSetting(); ns.Ip = operationSetting.SelectSingleNode("IP").InnerText; ns.Port = int.Parse(operationSetting.SelectSingleNode("Port").InnerText); setting = ns; } string dataTypeString = operation.SelectSingleNode("OperationDataType").InnerText; DataType dataType = (DataType)Enum.Parse(typeof(DataType), dataTypeString, true); string data = operation.SelectSingleNode("OperationData").InnerText; int time = int.Parse(operation.SelectSingleNode("OperationTime").InnerText); UserOperation userOperation = new UserOperation(operationName, operationType, dataType, setting, data, time); _deName.AddOperation(userOperation); } _userdefineNames.Add(_deName); } return(_userdefineNames); #endregion } catch (Exception ex) { Helper.ShowMessageBox("提示", "未找到自定义配置文件"); return(null); } }
public string Get() { var user = new AdWordsUser(); using (TargetingIdeaService targetingIdeaService = (TargetingIdeaService)user.GetService(Google.Api.Ads.AdWords.Lib.AdWordsService.v201802.TargetingIdeaService)) { // Create selector. TargetingIdeaSelector selector = new TargetingIdeaSelector(); selector.requestType = RequestType.STATS; selector.ideaType = IdeaType.KEYWORD; selector.requestedAttributeTypes = new AttributeType[] { AttributeType.KEYWORD_TEXT, AttributeType.SEARCH_VOLUME }; List <SearchParameter> searchParameters = new List <SearchParameter>(); // Create related to query search parameter. RelatedToQuerySearchParameter relatedToQuerySearchParameter = new RelatedToQuerySearchParameter(); relatedToQuerySearchParameter.queries = new String[] { "bakery" }; searchParameters.Add(relatedToQuerySearchParameter); // Add a language search parameter (optional). // The ID can be found in the documentation: // https://developers.google.com/adwords/api/docs/appendix/languagecodes LanguageSearchParameter languageParameter = new LanguageSearchParameter(); Language english = new Language(); english.id = 1000; languageParameter.languages = new Language[] { english }; searchParameters.Add(languageParameter); // Add network search parameter (optional). NetworkSetting networkSetting = new NetworkSetting(); networkSetting.targetGoogleSearch = true; networkSetting.targetSearchNetwork = false; networkSetting.targetContentNetwork = false; networkSetting.targetPartnerSearchNetwork = false; NetworkSearchParameter networkSearchParameter = new NetworkSearchParameter(); networkSearchParameter.networkSetting = networkSetting; searchParameters.Add(networkSearchParameter); // Set the search parameters. selector.searchParameters = searchParameters.ToArray(); // Set selector paging (required for targeting idea service). Paging paging = Paging.Default; selector.paging = paging; TargetingIdeaPage page = new TargetingIdeaPage(); int i = 0; do { // Get related keywords. page = targetingIdeaService.get(selector); // Display related keywords. if (page.entries != null && page.entries.Length > 0) { foreach (var targetingIdea in page.entries) { Dictionary <AttributeType, Google.Api.Ads.AdWords.v201802.Attribute> ideas = targetingIdea.data.ToDict(); string keyword = (ideas[AttributeType.KEYWORD_TEXT] as StringAttribute).value; long averageMonthlySearches = (ideas[AttributeType.SEARCH_VOLUME] as LongAttribute).value; i++; } } selector.paging.IncreaseOffset(); } while (selector.paging.startIndex < page.totalNumEntries); } return("value"); }
private void statusThread_DoWork(object sender, DoWorkEventArgs e) { while (true) { string strOutput = startProcess("netsh", "wlan show hostednetwork"); string[] strOutputArray = strOutput.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); List <NetworkSetting> settings = new List <NetworkSetting>(); for (int i = 0; i < strOutputArray.Length; i++) { NetworkSetting ns = new NetworkSetting(strOutputArray[i]); if (ns.ToString() != "") { settings.Add(ns); } } StringBuilder text = new StringBuilder(); settings.ForEach((NetworkSetting item) => { text.AppendLine(item.ToString()); }); Invoke((MethodInvoker) delegate { statusBox.Text = text.ToString(); if (settings.Count < 3) { // wlan host is not available statusBox.Text = strOutput; button1.Visible = false; button2.Visible = false; inputName.Enabled = false; inputPass.Enabled = false; } else if (settings.Count > 6) { // network enabled button1.Visible = false; button2.Visible = true; inputName.Enabled = false; inputPass.Enabled = false; } else { // network disabled button1.Visible = true; button2.Visible = false; inputName.Enabled = true; inputPass.Enabled = true; if (Properties.Settings.Default.AutoStart) { startHostedNetwork(); Thread.Sleep(1000); } } }); } int timeout = (this.WindowState == FormWindowState.Minimized) ? 7500 : 500; Thread.Sleep(timeout); }
/// <summary> /// 加载配置文件 /// </summary> private void LoadConfig() { try { XmlDocument config = new XmlDocument(); config.Load(_configFile); XmlNode root = config.SelectSingleNode("Root"); #region LoadNormalCommand XmlNodeList areas = root.SelectNodes("Area"); _areas.Clear(); foreach (XmlNode area in areas) { string areaName = area.SelectSingleNode("AreaName").InnerText; Area tempArea = new Area(areaName); _areas.Add(tempArea); XmlNodeList actions = area.SelectNodes("Action"); foreach (XmlNode action in actions) { string actionName = action.SelectSingleNode("ActionName").InnerText; string actionReceiveData = action.SelectSingleNode("ActionReceiveData").InnerText; UserAction useraction = new UserAction(actionName, actionReceiveData); //tempArea.Actions.Add(useraction); _userAction.Add(useraction); XmlNodeList oprations = action.SelectNodes("Operation"); foreach (XmlNode operation in oprations) { string operationName = operation.SelectSingleNode("OperationName").InnerText; string operationTypeString = operation.SelectSingleNode("OperationType").InnerText; OprationType operationType = (OprationType)Enum.Parse(typeof(OprationType), operationTypeString, true); XmlNode operationSetting = operation.SelectSingleNode("OperationSetting"); object setting = null; if (operationType == OprationType.Com) { ComSetting cs = new ComSetting(); cs.ComNumber = operationSetting.SelectSingleNode("ComNumber").InnerText; cs.BaudRate = int.Parse(operationSetting.SelectSingleNode("BaudRate").InnerText); cs.DataBits = int.Parse(operationSetting.SelectSingleNode("DataBit").InnerText); cs.StopBits = int.Parse(operationSetting.SelectSingleNode("StopBit").InnerText); cs.Parity = (Parity)Enum.Parse(typeof(Parity), operationSetting.SelectSingleNode("Parity").InnerText); setting = cs; } else if (operationType == OprationType.TCP || operationType == OprationType.UDP) { NetworkSetting ns = new NetworkSetting(); ns.Ip = operationSetting.SelectSingleNode("IP").InnerText; ns.Port = int.Parse(operationSetting.SelectSingleNode("Port").InnerText); setting = ns; } string dataTypeString = operation.SelectSingleNode("OperationDataType").InnerText; DataType dataType = (DataType)Enum.Parse(typeof(DataType), dataTypeString, true); string data = operation.SelectSingleNode("OperationData").InnerText; int time = int.Parse(operation.SelectSingleNode("OperationTime").InnerText); UserOperation userOperation = new UserOperation(operationName, operationType, dataType, setting, data, time); _userOperation.Add(userOperation); } } } _arealist.Refresh(); #endregion } catch (Exception ex) { MessageBox.Show("未找到配置命令!"); } }
public Task <object> SetSettings(NetworkSetting settings) { throw new NotImplementedException(); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="adGroupId">ID of the ad group to use for generating ideas.</param> public void Run(AdWordsUser user, long?adGroupId) { using (TargetingIdeaService targetingIdeaService = (TargetingIdeaService)user.GetService(AdWordsService.v201710.TargetingIdeaService)) { // Create selector. TargetingIdeaSelector selector = new TargetingIdeaSelector(); selector.requestType = RequestType.IDEAS; selector.ideaType = IdeaType.KEYWORD; selector.requestedAttributeTypes = new AttributeType[] { AttributeType.KEYWORD_TEXT, AttributeType.SEARCH_VOLUME, AttributeType.AVERAGE_CPC, AttributeType.COMPETITION, AttributeType.CATEGORY_PRODUCTS_AND_SERVICES }; List <SearchParameter> searchParameters = new List <SearchParameter>(); // Create related to query search parameter. RelatedToQuerySearchParameter relatedToQuerySearchParameter = new RelatedToQuerySearchParameter(); relatedToQuerySearchParameter.queries = new String[] { "bakery", "pastries", "birthday cake" }; searchParameters.Add(relatedToQuerySearchParameter); // Add a language search parameter (optional). // The ID can be found in the documentation: // https://developers.google.com/adwords/api/docs/appendix/languagecodes LanguageSearchParameter languageParameter = new LanguageSearchParameter(); Language english = new Language(); english.id = 1000; languageParameter.languages = new Language[] { english }; searchParameters.Add(languageParameter); // Add network search parameter (optional). NetworkSetting networkSetting = new NetworkSetting(); networkSetting.targetGoogleSearch = true; networkSetting.targetSearchNetwork = false; networkSetting.targetContentNetwork = false; networkSetting.targetPartnerSearchNetwork = false; NetworkSearchParameter networkSearchParameter = new NetworkSearchParameter(); networkSearchParameter.networkSetting = networkSetting; searchParameters.Add(networkSearchParameter); // Optional: Use an existing ad group to generate ideas. if (adGroupId != null) { SeedAdGroupIdSearchParameter seedAdGroupIdSearchParameter = new SeedAdGroupIdSearchParameter(); seedAdGroupIdSearchParameter.adGroupId = adGroupId.Value; searchParameters.Add(seedAdGroupIdSearchParameter); } // Set the search parameters. selector.searchParameters = searchParameters.ToArray(); // Set selector paging (required for targeting idea service). selector.paging = Paging.Default; TargetingIdeaPage page = new TargetingIdeaPage(); try { int i = 0; do { // Get related keywords. page = targetingIdeaService.get(selector); // Display related keywords. if (page.entries != null && page.entries.Length > 0) { foreach (TargetingIdea targetingIdea in page.entries) { Dictionary <AttributeType, Google.Api.Ads.AdWords.v201710.Attribute> ideas = targetingIdea.data.ToDict(); string keyword = (ideas[AttributeType.KEYWORD_TEXT] as StringAttribute).value; IntegerSetAttribute categorySet = ideas[AttributeType.CATEGORY_PRODUCTS_AND_SERVICES] as IntegerSetAttribute; string categories = ""; if (categorySet != null && categorySet.value != null) { categories = string.Join(", ", categorySet.value); } long averageMonthlySearches = (ideas[AttributeType.SEARCH_VOLUME] as LongAttribute).value; Money averageCpc = (ideas[AttributeType.AVERAGE_CPC] as MoneyAttribute).value; double competition = (ideas[AttributeType.COMPETITION] as DoubleAttribute).value; Console.WriteLine("Keyword with text '{0}', average monthly search " + "volume {1}, average CPC {2}, and competition {3:F2} was found with " + "categories: {4}", keyword, averageMonthlySearches, averageCpc?.microAmount, competition, categories); Console.WriteLine("Keyword with text '{0}', and average monthly search volume " + "'{1}' was found with categories: {2}", keyword, averageMonthlySearches, categories); i++; } } selector.paging.IncreaseOffset(); } while (selector.paging.startIndex < page.totalNumEntries); Console.WriteLine("Number of related keywords found: {0}", page.totalNumEntries); } catch (Exception e) { throw new System.ApplicationException("Failed to retrieve related keywords.", e); } } }
public async Task <bool> SetNetworkSetting(NetworkSetting networkSetting) { var obj = await RunCmd <object>(new SetNetworkSettingRequest(networkSetting)); return(obj != null); }