/// <summary> /// Returns a copy with the specified name. /// </summary> public SharedFolder WithName(string name) { SoapData newData = _data; newData.name = name; return(new SharedFolder(newData)); }
public async Task <SoapData <BudgetServiceResponseHeader, BudgetServiceQueryResponse> > QueryAsync(SoapData <BudgetServiceRequestHeader, BudgetServiceQuery> inData) { var xHeaderData = new XElement(XName.Get("RequestHeader", "https://adwords.google.com/api/adwords/cm/v201609")); inData.Header.WriteTo(xHeaderData); var xBodyData = new XElement(XName.Get("query", "https://adwords.google.com/api/adwords/cm/v201609")); inData.Body.WriteTo(xBodyData); var outData = new SoapData <BudgetServiceResponseHeader, BudgetServiceQueryResponse>(); outData.Header = new BudgetServiceResponseHeader(); outData.Body = new BudgetServiceQueryResponse(); var faultData = new BudgetServiceApiExceptionFault(); var isSuccessful = await GetSoapResultAsync("", xHeaderData, xBodyData, outData, faultData).ConfigureAwait(false); if (!isSuccessful) { if (faultData.Errors.Count == 1) { throw faultData.Errors[0]; } else { throw new AggregateException(faultData.Errors); } } return(outData); }
private SharedFolder DoClone(SoapData newData) { SharedFolder clone = new SharedFolder(newData); clone._sendAsAddress = SendAsAddress; return(clone); }
/// <summary> /// Returns a copy with the specified flags. /// </summary> public SharedFolder WithFlags(ShareFlags flags) { SoapData newData = _data; newData.flags = flags; return(new SharedFolder(newData)); }
/// <summary> /// Creates an instances for the specified folder. /// </summary> public SharedFolder(AvailableFolder folder, string name) { _data = new SoapData() { store = folder.Store.UserName, folderid = folder.BackendId, parentid = folder.ParentIdAsBackend, name = name, type = OutlookConstants.USER_SYNC_TYPES[(int)folder.Type], flags = folder.Type.IsMail() ? ShareFlags.SendAsOwner : ShareFlags.None }; }
/// <summary> /// Returns all the open/active BillingAccounts associated with the current /// manager. /// @return A list of {@link BillingAccount}s. /// @throws ApiException /// </summary> public async Task <IEnumerable <BillingAccount> > GetBillingAccountsAsync() { var binding = new BudgetOrderServiceSoapBinding("https://adwords.google.com/api/adwords/billing/v201609/BudgetOrderService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <BudgetOrderServiceRequestHeader, BudgetOrderServiceGetBillingAccounts>(); inData.Header = new BudgetOrderServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new BudgetOrderServiceGetBillingAccounts(); var outData = await binding.GetBillingAccountsAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Returns a list of all language criteria. /// /// @return A list of languages. /// @throws ApiException when there is at least one error with the request. /// </summary> public async Task <IEnumerable <Language> > GetLanguageCriterionAsync() { var binding = new ConstantDataServiceSoapBinding("https://adwords.google.com/api/adwords/cm/v201609/ConstantDataService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <ConstantDataServiceRequestHeader, ConstantDataServiceGetLanguageCriterion>(); inData.Header = new ConstantDataServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new ConstantDataServiceGetLanguageCriterion(); var outData = await binding.GetLanguageCriterionAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Modifies links to other services for the authorized customer. /// See {@link ServiceType} for information on the various linking types supported. /// /// @param operations to perform /// @throws ApiException /// </summary> public async Task <IEnumerable <ServiceLink> > MutateServiceLinksAsync(IEnumerable <ServiceLinkOperation> operations) { var binding = new CustomerServiceSoapBinding("https://adwords.google.com/api/adwords/mcm/v201609/CustomerService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <CustomerServiceRequestHeader, CustomerServiceMutateServiceLinks>(); inData.Header = new CustomerServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new CustomerServiceMutateServiceLinks(); inData.Body.Operations = new List <ServiceLinkOperation>(operations); var outData = await binding.MutateServiceLinksAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Update the authorized customer. /// /// <p>While there are a limited set of properties available to update, please read this /// <a href="https://support.google.com/analytics/answer/1033981">help center article /// on auto-tagging</a> before updating {@code customer.autoTaggingEnabled}. /// /// @param customer the requested updated value for the customer. /// @throws ApiException /// </summary> public async Task <Customer> MutateAsync(Customer customer) { var binding = new CustomerServiceSoapBinding("https://adwords.google.com/api/adwords/mcm/v201609/CustomerService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <CustomerServiceRequestHeader, CustomerServiceMutate>(); inData.Header = new CustomerServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new CustomerServiceMutate(); inData.Body.Customer = customer; var outData = await binding.MutateAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Uploads new media. Currently, you can upload {@link Image} files and {@link MediaBundle}s. /// /// @param media A list of {@code Media} objects, each containing the data to /// be uploaded. /// @return A list of uploaded media in the same order as the argument list. /// </summary> public async Task <IEnumerable <Media> > UploadAsync(IEnumerable <Media> media) { var binding = new MediaServiceSoapBinding("https://adwords.google.com/api/adwords/cm/v201609/MediaService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <MediaServiceRequestHeader, MediaServiceUpload>(); inData.Header = new MediaServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new MediaServiceUpload(); inData.Body.Media = new List <Media>(media); var outData = await binding.UploadAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Returns the pending invitations for the customer IDs in the selector. /// @param selector the manager customer ids (inviters) or the client customer ids (invitees) /// @throws ApiException when there is at least one error with the request /// </summary> public async Task <IEnumerable <PendingInvitation> > GetPendingInvitationsAsync(PendingInvitationSelector selector) { var binding = new ManagedCustomerServiceSoapBinding("https://adwords.google.com/api/adwords/mcm/v201609/ManagedCustomerService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <ManagedCustomerServiceRequestHeader, ManagedCustomerServiceGetPendingInvitations>(); inData.Header = new ManagedCustomerServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new ManagedCustomerServiceGetPendingInvitations(); inData.Body.Selector = selector; var outData = await binding.GetPendingInvitationsAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Adds labels to the AdGroupAd or removes labels from the AdGroupAd. /// <p>Add - Apply an existing label to an existing {@linkplain AdGroupAd ad group ad}. The /// {@code adGroupId} and {@code adId} must reference an existing /// {@linkplain AdGroupAd ad group ad}. The {@code labelId} must reference an existing /// {@linkplain Label label}. /// <p>Remove - Removes the link between the specified {@linkplain AdGroupAd ad group ad} and /// {@linkplain Label label}. /// @param operations The operations to apply. /// @return A list of AdGroupAdLabel where each entry in the list is the result of /// applying the operation in the input list with the same index. For an /// add operation, the returned AdGroupAdLabel contains the AdGroupId, AdId and the LabelId. /// In the case of a remove operation, the returned AdGroupAdLabel will only have AdGroupId and /// AdId. /// @throws ApiException when there are one or more errors with the request. /// </summary> public async Task <AdGroupAdLabelReturnValue> MutateLabelAsync(IEnumerable <AdGroupAdLabelOperation> operations) { var binding = new AdGroupAdServiceSoapBinding("https://adwords.google.com/api/adwords/cm/v201609/AdGroupAdService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <AdGroupAdServiceRequestHeader, AdGroupAdServiceMutateLabel>(); inData.Header = new AdGroupAdServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new AdGroupAdServiceMutateLabel(); inData.Body.Operations = new List <AdGroupAdLabelOperation>(operations); var outData = await binding.MutateLabelAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Returns the available report fields for a given report type. /// When using this method the {@code clientCustomerId} header field is /// optional. Callers are discouraged from setting the clientCustomerId /// header field in calls to this method as its presence will trigger an /// authorization error if the caller does not have access to the customer /// with the included ID. /// /// @param reportType The type of report. /// @return The list of available report fields. Each /// {@link ReportDefinitionField} encapsulates the field name, the /// field data type, and the enum values (if the field's type is /// {@code enum}). /// @throws ApiException if a problem occurred while fetching the /// ReportDefinitionField information. /// </summary> public async Task <IEnumerable <ReportDefinitionField> > GetReportFieldsAsync(ReportDefinitionReportType?reportType) { var binding = new ReportDefinitionServiceSoapBinding("https://adwords.google.com/api/adwords/cm/v201609/ReportDefinitionService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <ReportDefinitionServiceRequestHeader, ReportDefinitionServiceGetReportFields>(); inData.Header = new ReportDefinitionServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new ReportDefinitionServiceGetReportFields(); inData.Body.ReportType = reportType; var outData = await binding.GetReportFieldsAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Returns the list of SharedSet entities that match the query. /// /// @param query The SQL-like AWQL query string /// @returns A list of SharedSet entities /// @throws ApiException when the query is invalid or there are errors processing the request. /// </summary> public async Task <SharedSetPage> QueryAsync(string query) { var binding = new SharedSetServiceSoapBinding("https://adwords.google.com/api/adwords/cm/v201609/SharedSetService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <SharedSetServiceRequestHeader, SharedSetServiceQuery>(); inData.Header = new SharedSetServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new SharedSetServiceQuery(); inData.Body.Query = query; var outData = await binding.QueryAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Returns a list of AdGroupAds. /// AdGroupAds that had been removed are not returned by default. /// /// @param serviceSelector The selector specifying the {@link AdGroupAd}s to return. /// @return The page containing the AdGroupAds that meet the criteria specified by the selector. /// @throws ApiException when there is at least one error with the request. /// </summary> public async Task <AdGroupAdPage> GetAsync(Selector serviceSelector) { var binding = new AdGroupAdServiceSoapBinding("https://adwords.google.com/api/adwords/cm/v201609/AdGroupAdService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <AdGroupAdServiceRequestHeader, AdGroupAdServiceGet>(); inData.Header = new AdGroupAdServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new AdGroupAdServiceGet(); inData.Body.ServiceSelector = serviceSelector; var outData = await binding.GetAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Returns a list of shopping bidding categories. /// /// A country predicate must be included in the selector, only {@link Predicate.Operator#EQUALS} /// and {@link Predicate.Operator#IN} with a single value are supported in the country predicate. /// An empty parentDimensionType predicate will filter for root categories. /// /// @return A list of shopping bidding categories. /// @throws ApiException when there is at least one error with the request. /// </summary> public async Task <IEnumerable <ProductBiddingCategoryData> > GetProductBiddingCategoryDataAsync(Selector selector) { var binding = new ConstantDataServiceSoapBinding("https://adwords.google.com/api/adwords/cm/v201609/ConstantDataService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <ConstantDataServiceRequestHeader, ConstantDataServiceGetProductBiddingCategoryData>(); inData.Header = new ConstantDataServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new ConstantDataServiceGetProductBiddingCategoryData(); inData.Body.Selector = selector; var outData = await binding.GetProductBiddingCategoryDataAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
/// <summary> /// Mutates BudgetOrders, supported operations are: /// <p><code>ADD</code>: Adds a {@link BudgetOrder} to the billing account /// specified by the billing account ID.</p> /// <p><code>SET</code>: Sets the start/end date and amount of the /// {@link BudgetOrder}.</p> /// <p><code>REMOVE</code>: Cancels the {@link BudgetOrder} (status change).</p> /// <p class="warning"><b>Warning:</b> The <code>BudgetOrderService</code> /// is limited to one operation per mutate request. Any attempt to make more /// than one operation will result in an <code>ApiException</code>.</p> /// @param operations A list of operations, <b>however currently we only /// support one operation per mutate call</b>. /// @return BudgetOrders affected by the mutate operation. /// @throws ApiException /// </summary> public async Task <BudgetOrderReturnValue> MutateAsync(IEnumerable <BudgetOrderOperation> operations) { var binding = new BudgetOrderServiceSoapBinding("https://adwords.google.com/api/adwords/billing/v201609/BudgetOrderService", _config.AccessToken, _config.Timeout, _config.EnableGzipCompression, _netUtil, _logger); var inData = new SoapData <BudgetOrderServiceRequestHeader, BudgetOrderServiceMutate>(); inData.Header = new BudgetOrderServiceRequestHeader(); AssignHeaderValues(inData.Header); inData.Body = new BudgetOrderServiceMutate(); inData.Body.Operations = new List <BudgetOrderOperation>(operations); var outData = await binding.MutateAsync(inData).ConfigureAwait(false); return(outData.Body.Rval); }
override public bool Equals(object o) { if (!(o is SoapData)) { return(false); } SoapData rhs = (SoapData)o; // TODO: this isn't really a full equality test, as flags is masked. This is because Equals is only used // to test if there are changes that need to be applied. It would be nicer to rename this, and // equals in SharedFolder to something like NeedsApply. return (store == rhs.store && folderid == rhs.folderid && parentid == rhs.parentid && name == rhs.name && type == rhs.type && (flags & ShareFlags.Mask_Apply) == (rhs.flags & ShareFlags.Mask_Apply)); }
protected async Task <bool> GetSoapResultAsync <TOutHeader, TOutBody, TError>(string soapAction, XElement xHeaderData, XElement xBodyData, SoapData <TOutHeader, TOutBody> outData, TError errorData) where TOutHeader : ISoapable where TOutBody : ISoapable where TError : ISoapable { CancellationToken ct; if (_timeout > 0) { var cts = new CancellationTokenSource(_timeout); ct = cts.Token; } else { ct = CancellationToken.None; } var xDoc = await GetSoapResultAsync(soapAction, xHeaderData, xBodyData, ct).ConfigureAwait(false); var xRoot = xDoc.Root; xHeaderData = xRoot.Element(XName.Get("Header", NsSoap)).Elements().First(); xBodyData = xRoot.Element(XName.Get("Body", NsSoap)).Elements().First(); outData.Header.ReadFrom(xHeaderData); if (xBodyData.Name == SoapFaultXName) { var detailErrorObj = xBodyData.Element(XName.Get("detail", "")).Elements().FirstOrDefault(); errorData.ReadFrom(detailErrorObj); return(false); } else { outData.Body.ReadFrom(xBodyData); return(true); } }
/// <summary> /// Constructor for Soap deserialisation. FixupSoap must be invoked to finish setting up the object. /// </summary> public AvailableFolder(SoapData data) { this._data = data; Children = new List <AvailableFolder>(); }
/// <summary> /// Soap deserialization constructor /// </summary> public SharedFolder(SoapData data) { this._data = data; }
private static void TestSOAP() { //构造SOAP请求信息 StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<?xml version=\"1.0\" encoding=\"utf - 8\"?><soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"><soap12:Body><getXGInfo xmlns=\"http://tempuri.org/\" /></soap12:Body></soap12:Envelope>"); //stringBuilder.Append("<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"); //stringBuilder.Append("<soap12:Body>"); //stringBuilder.Append("<getXGInfo xmlns=\"http://tempuri.org/\" />"); //stringBuilder.Append("</soap12:Body>"); //stringBuilder.Append("</soap12:Envelope>"); //发送请求 Uri uri = new Uri("http://120.77.66.89:90/WebService1.asmx"); WebRequest webRequest = WebRequest.Create(uri); webRequest.ContentType = "text/xml; charset=utf-8"; webRequest.Method = "POST"; using (Stream requestStream = webRequest.GetRequestStream()) { byte[] paramBytes = Encoding.UTF8.GetBytes(stringBuilder.ToString()); requestStream.Write(paramBytes, 0, paramBytes.Length); } //响应 WebResponse webResponse = webRequest.GetResponse(); using (StreamReader myStreamReader = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8)) { string streamString = myStreamReader.ReadToEnd().Trim().Replace("\n", ""); XmlDocument doc = new XmlDocument(); doc.LoadXml(streamString); string s = doc.DocumentElement["soap:Body"]["getXGInfoResponse"]["getXGInfoResult"]["diffgr:diffgram"].InnerXml; doc.LoadXml(s); XmlNode node = doc.SelectSingleNode("NewDataSet"); List <SoapData> list = new List <SoapData>(); foreach (XmlNode childNode in node.ChildNodes) { SoapData data = new SoapData(); foreach (XmlNode sonNode in childNode.ChildNodes) { switch (sonNode.Name) { case "名称": data.称 = sonNode.InnerText; break; case "id": data.id = Convert.ToInt32(sonNode.InnerText); break; case "设备ID": data.设备ID = Convert.ToInt32(sonNode.InnerText); break; case "记录时间": data.记录时间 = Convert.ToDateTime(sonNode.InnerText); break; case "采集时间": data.采集时间 = Convert.ToDateTime(sonNode.InnerText); break; case "设备状态": data.设备状态 = sonNode.InnerText; break; case "通讯状态": data.通讯状态 = sonNode.InnerText; break; case "数据来源": data.数据来源 = sonNode.InnerText; break; case "压力": data.压力 = Convert.ToDecimal(sonNode.InnerText); break; case "电池电压": data.电池电压 = Convert.ToDecimal(sonNode.InnerText); break; case "信号强度": data.信号强度 = Convert.ToDecimal(sonNode.InnerText); break; case "瞬时流量": data.瞬时流量 = Convert.ToDecimal(sonNode.InnerText); break; case "正累计流量": data.正累计流量 = Convert.ToDecimal(sonNode.InnerText); break; case "负累计流量": data.负累计流量 = Convert.ToDecimal(sonNode.InnerText); break; case "净累计流量": data.净累计流量 = Convert.ToDecimal(sonNode.InnerText); break; case "压力2": data.压力2 = Convert.ToDecimal(sonNode.InnerText); break; case "电池电压报警": data.电池电压报警 = sonNode.InnerText; break; case "压力下限报警": data.压力下限报警 = sonNode.InnerText; break; case "压力上限报警": data.压力上限报警 = sonNode.InnerText; break; case "泵1运行": data.泵1运行 = sonNode.InnerText; break; case "泵1故障": data.泵1故障 = sonNode.InnerText; break; case "泵2运行": data.泵2运行 = sonNode.InnerText; break; case "泵2故障": data.泵2故障 = sonNode.InnerText; break; case "浊度": data.浊度 = Convert.ToDecimal(sonNode.InnerText); break; case "余氯": data.余氯 = Convert.ToDecimal(sonNode.InnerText); break; case "门开关": data.门开关 = sonNode.InnerText; break; case "浊度故障": data.浊度故障 = sonNode.InnerText; break; case "浊度上限报警": data.浊度上限报警 = sonNode.InnerText; break; case "浊度下限报警": data.浊度下限报警 = sonNode.InnerText; break; case "余氯故障": data.余氯故障 = sonNode.InnerText; break; case "余氯上限报警": data.余氯上限报警 = sonNode.InnerText; break; case "余氯下限报警": data.余氯下限报警 = sonNode.InnerText; break; case "水表通讯故障": data.水表通讯故障 = sonNode.InnerText; break; case "浊度状态": data.浊度状态 = sonNode.InnerText; break; case "余氯状态": data.余氯状态 = sonNode.InnerText; break; } } list.Add(data); } } }