public async Task <Response <FlowLog> > GetAsync(string resourceGroupName, string networkWatcherName, string flowLogName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (networkWatcherName == null) { throw new ArgumentNullException(nameof(networkWatcherName)); } if (flowLogName == null) { throw new ArgumentNullException(nameof(flowLogName)); } using var message = CreateGetRequest(resourceGroupName, networkWatcherName, flowLogName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { FlowLog value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = FlowLog.DeserializeFlowLog(document.RootElement); } return(Response.FromValue(value, message.Response)); }
protected void lbtSave_Click(object sender, EventArgs e) { Validate("vgUserSelect"); if (IsValid) { //������ archives oldArc = arcClass.getArchives(hfID.Value); FlowLog flog = new FlowLog(); //���̼�¼ oldArc.arState = "�¼�"; flog.arAccess = oldArc.arAccess; flog.arCheck = oldArc.arCheck; flog.arCheckMI = oldArc.arCheckMI; flog.arCode = oldArc.arCode; flog.arContent = oldArc.arContent; flog.arCopy = oldArc.arCopy; flog.arDC = oldArc.arDC; flog.arFM = oldArc.arFM; flog.arFU = oldArc.arFU; flog.arGZ = oldArc.arGZ; flog.arID = oldArc.arID; flog.arIssue = oldArc.arIssue; flog.arMI = oldArc.arMI; flog.arNum = oldArc.arNum; flog.arPT = oldArc.arPT; flog.arSB = oldArc.arSB; flog.arSend = oldArc.arSend; flog.arST = oldArc.arST; flog.arState = oldArc.arState; flog.arTC = oldArc.arTC; flog.arTitle = oldArc.arTitle; flog.flID = oldArc.flID; flog.sUsid = oldArc.sUsid; flog.usID = oldArc.usID; flog.fgInceptTime = oldArc.arUtime; flog.fgCtime = DateTime.Now; flog.fgOrder = flogClass.getMaxFlow("arID=" + flog.arID.ToString()) + 1; flog.fgFlowName = TextBox1.Text; //�����Ĵ��� oldArc.sUsid = oldArc.usID; oldArc.usID = Comp.csParse.ParseSL(rblUsers.SelectedValue); oldArc.arUtime = DateTime.Now; oldArc.arCheckMI = "0"; //���̴��� flowlist oldFlow = flowClass.getFlow(oldArc.flID); flowlist newFlow = flowClass.getFlowbyWhere("flNum=" + (oldFlow.flNum + 1).ToString() + " and flType='1'"); if (newFlow != null) { oldArc.flID = newFlow.flID; } arcClass.saveArchives(oldArc); flogClass.saveFlowLog(flog); Comp.csJscript.AlertAndRedirect("���ļ��ѷ���!", "ArcPendingRequest.aspx"); } }
private MNM.FlowLog GetFlowLogParametersFromRequest() { MNM.FlowLog flowLogParameters = new FlowLog { Location = this.Location, TargetResourceId = this.TargetResourceId, StorageId = this.StorageId, Enabled = this.Enabled, Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true) }; if (this.EnableRetention == true || this.EnableRetention == false) { flowLogParameters.RetentionPolicy = new MNM.RetentionPolicyParameters { Enabled = this.EnableRetention, Days = this.RetentionPolicyDays }; } if (!string.IsNullOrWhiteSpace(this.FormatType) || this.FormatVersion != null) { flowLogParameters.Format = new MNM.FlowLogFormatParameters { Type = "JSON", Version = this.FormatVersion ?? 0 }; } if (ParameterSetName.Contains("WithTA")) { flowLogParameters.FlowAnalyticsConfiguration = new TrafficAnalyticsProperties() { NetworkWatcherFlowAnalyticsConfiguration = new TrafficAnalyticsConfigurationProperties() { Enabled = this.EnableTrafficAnalytics.IsPresent, WorkspaceResourceId = this.TrafficAnalyticsWorkspaceId, TrafficAnalyticsInterval = this.TrafficAnalyticsInterval ?? 60 } }; } return(flowLogParameters); }
public async Task <Response> CreateOrUpdateAsync(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (networkWatcherName == null) { throw new ArgumentNullException(nameof(networkWatcherName)); } if (flowLogName == null) { throw new ArgumentNullException(nameof(flowLogName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, flowLogName, parameters); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); uri.AppendPath(networkWatcherName, true); uri.AppendPath("/flowLogs/", false); uri.AppendPath(flowLogName, true); uri.AppendQuery("api-version", "2020-04-01", true); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); using var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(parameters); request.Content = content; return(message); }
/// <summary> /// 保存 /// </summary> /// <param name="prmFlowLog"></param> public long saveFlowLog(FlowLog prmFlowLog) { long _id = 0; if (prmFlowLog.fgID > 0) { flieds = new NBear.Common.PropertyItem[]{ FlowLog._.arAccess, FlowLog._.arCheck, FlowLog._.arCheckMI, FlowLog._.arCode, FlowLog._.arContent, FlowLog._.arCopy, FlowLog._.arDC, FlowLog._.arFM, FlowLog._.arFU, FlowLog._.arGZ, FlowLog._.arID, FlowLog._.arIssue, FlowLog._.arMI, FlowLog._.arNum, FlowLog._.arPT, FlowLog._.arSB, FlowLog._.arSend, FlowLog._.arST, FlowLog._.arState, FlowLog._.arTC, FlowLog._.arTitle, FlowLog._.flID, FlowLog._.sUsid, FlowLog._.usID, FlowLog._.fgOrder, FlowLog._.fgFlowName, FlowLog._.fgInceptTime, FlowLog._.fgCtime }; values = new object[]{ prmFlowLog.arAccess, prmFlowLog.arCheck, prmFlowLog.arCheckMI, prmFlowLog.arCode, prmFlowLog.arContent, prmFlowLog.arCopy, prmFlowLog.arDC, prmFlowLog.arFM, prmFlowLog.arFU, prmFlowLog.arGZ, prmFlowLog.arID, prmFlowLog.arIssue, prmFlowLog.arMI, prmFlowLog.arNum, prmFlowLog.arPT, prmFlowLog.arSB, prmFlowLog.arSend, prmFlowLog.arST, prmFlowLog.arState, prmFlowLog.arTC, prmFlowLog.arTitle, prmFlowLog.flID, prmFlowLog.sUsid, prmFlowLog.usID, prmFlowLog.fgOrder, prmFlowLog.fgFlowName, prmFlowLog.fgInceptTime, prmFlowLog.fgCtime }; db.Update<FlowLog>(flieds, values, FlowLog._.fgID == prmFlowLog.fgID); _id = prmFlowLog.fgID; } else { _id = db.Save<FlowLog>(prmFlowLog); } return _id; }
/// <summary> /// Create or update a flow log for the specified network security group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='networkWatcherName'> /// The name of the network watcher. /// </param> /// <param name='flowLogName'> /// The name of the flow log. /// </param> /// <param name='parameters'> /// Parameters that define the create or update flow log resource. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <FlowLog> CreateOrUpdateAsync(this IFlowLogsOperations operations, string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkWatcherName, flowLogName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create or update a flow log for the specified network security group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='networkWatcherName'> /// The name of the network watcher. /// </param> /// <param name='flowLogName'> /// The name of the flow log. /// </param> /// <param name='parameters'> /// Parameters that define the create or update flow log resource. /// </param> public static FlowLog CreateOrUpdate(this IFlowLogsOperations operations, string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, networkWatcherName, flowLogName, parameters).GetAwaiter().GetResult()); }
/// <summary> /// Create or update a flow log for the specified network security group. /// </summary> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='networkWatcherName'> /// The name of the network watcher. /// </param> /// <param name='flowLogName'> /// The name of the flow log. /// </param> /// <param name='parameters'> /// Parameters that define the create or update flow log resource. /// </param> /// <param name='customHeaders'> /// The headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public async Task <AzureOperationResponse <FlowLog> > CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send Request AzureOperationResponse <FlowLog> _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, networkWatcherName, flowLogName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); return(await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Create or update a flow log for the specified network security group. /// </summary> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='networkWatcherName'> /// The name of the network watcher. /// </param> /// <param name='flowLogName'> /// The name of the flow log. /// </param> /// <param name='parameters'> /// Parameters that define the create or update flow log resource. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="ErrorResponseException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <AzureOperationResponse <FlowLog> > BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } if (networkWatcherName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "networkWatcherName"); } if (flowLogName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "flowLogName"); } if (parameters == null) { throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); } if (parameters != null) { parameters.Validate(); } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } string apiVersion = "2020-04-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("networkWatcherName", networkWatcherName); tracingParameters.Add("flowLogName", flowLogName); tracingParameters.Add("parameters", parameters); tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/flowLogs/{flowLogName}").ToString(); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{networkWatcherName}", System.Uri.EscapeDataString(networkWatcherName)); _url = _url.Replace("{flowLogName}", System.Uri.EscapeDataString(flowLogName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List <string> _queryParameters = new List <string>(); if (apiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) { _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); } if (Client.AcceptLanguage != null) { if (_httpRequest.Headers.Contains("accept-language")) { _httpRequest.Headers.Remove("accept-language"); } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; if (parameters != null) { _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials if (Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 201) { var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <ErrorResponse>(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; } } catch (JsonException) { // Ignore the exception } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new AzureOperationResponse <FlowLog>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } // Deserialize Response if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <FlowLog>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } // Deserialize Response if ((int)_statusCode == 201) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <FlowLog>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
public virtual FlowLogsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string networkWatcherName, string flowLogName, FlowLog parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (networkWatcherName == null) { throw new ArgumentNullException(nameof(networkWatcherName)); } if (flowLogName == null) { throw new ArgumentNullException(nameof(flowLogName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("FlowLogsClient.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, networkWatcherName, flowLogName, parameters, cancellationToken); return(new FlowLogsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, flowLogName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// 退回操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbtnTJ_Click(object sender, EventArgs e) { if (iId > 0) { FlowLog flogNew = new FlowLog(); archives oldArc = arcClass.getArchives(iId); oldArc.arState = "退件"; //流程记录 flogNew.arAccess = oldArc.arAccess; flogNew.arCheck = oldArc.arCheck; flogNew.arCheckMI = oldArc.arCheckMI; flogNew.arCode = oldArc.arCode; flogNew.arContent = oldArc.arContent; flogNew.arCopy = oldArc.arCopy; flogNew.arDC = oldArc.arDC; flogNew.arFM = oldArc.arFM; flogNew.arFU = oldArc.arFU; flogNew.arGZ = oldArc.arGZ; flogNew.arID = oldArc.arID; flogNew.arIssue = oldArc.arIssue; flogNew.arMI = oldArc.arMI; flogNew.arNum = oldArc.arNum; flogNew.arPT = oldArc.arPT; flogNew.arSB = oldArc.arSB; flogNew.arSend = oldArc.arSend; flogNew.arST = oldArc.arST; flogNew.arState = oldArc.arState; flogNew.arTC = oldArc.arTC; flogNew.arTitle = oldArc.arTitle; flogNew.flID = oldArc.flID; flogNew.sUsid = oldArc.sUsid; flogNew.usID = oldArc.usID; flogNew.fgInceptTime = oldArc.arUtime; flogNew.fgCtime = DateTime.Now; flogNew.fgOrder = flogClass.getMaxFlow("arID=" + flogNew.arID.ToString()) + 1; flogNew.fgFlowName = flowClass.getFlowName(flogNew.flID).ToString(); FlowLog flogOld = flogClass.getMaxFlowLog(flogNew.arID, flogNew.fgOrder - 1); oldArc.arAccess = flogOld.arAccess; oldArc.arCheck = flogOld.arCheck; oldArc.arCheckMI = flogOld.arCheckMI; oldArc.arCode = flogOld.arCode; oldArc.arContent = flogOld.arContent; oldArc.arCopy = flogOld.arCopy; oldArc.arDC = flogOld.arDC; oldArc.arFM = flogOld.arFM; oldArc.arFU = flogOld.arFU; oldArc.arGZ = flogOld.arGZ; oldArc.arIssue = flogOld.arIssue; oldArc.arMI = flogOld.arMI; oldArc.arNum = flogOld.arNum; oldArc.arPT = flogOld.arPT; oldArc.arSB = flogOld.arSB; oldArc.arSend = flogOld.arSend; oldArc.arST = flogOld.arST; oldArc.arTC = flogOld.arTC; oldArc.arTitle = flogOld.arTitle; oldArc.flID = flogOld.flID; oldArc.usID = flogOld.usID; oldArc.sUsid = flogOld.sUsid; oldArc.arUtime = DateTime.Now; arcClass.saveArchives(oldArc); flogClass.saveFlowLog(flogNew); Comp.csJscript.AlertAndRedirect("该文件已退回!", "ArcPendingRequest.aspx"); } }