/// <summary> /// 向服务器发送Request /// </summary> /// <param name="url">字符串</param> /// <param name="method">枚举类型的方法Get或者Post</param> /// <param name="body">Post时必须传值</param> /// <returns></returns> public static byte[] Request(string url, MethodEnum method, string body = "", string contentType = null) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = method.ToString(); //如果是Post的话,则设置body if (method == MethodEnum.POST) { byte[] request_body = Encoding.UTF8.GetBytes(body); request.ContentLength = request_body.Length; if (contentType != null) { request.ContentType = contentType; } Stream request_stream = request.GetRequestStream(); request_stream.Write(request_body, 0, request_body.Length); } if (CookiesContainer == null) { CookiesContainer = new CookieContainer(); } //启用Cookie request.CookieContainer = CookiesContainer; return(Response(request)); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 向服务器发送Request /// </summary> /// <param name="url">字符串</param> /// <param name="method">Get或Post</param> /// <param name="body">Post时必须传值</param> /// <returns></returns> public static byte[] Request(string url, MethodEnum method, string body = "") { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.UserAgent = DefaultUserAgent; request.Method = method.ToString(); if (method == MethodEnum.POST)//post设置body { byte[] request_body = Encoding.UTF8.GetBytes(body); request.ContentLength = request_body.Length; Stream request_stream = request.GetRequestStream(); request_stream.Write(request_body, 0, request_body.Length); } if (CookiesContainer == null) { CookiesContainer = new CookieContainer(); } request.CookieContainer = CookiesContainer; return(Response(request)); } catch { throw; } }
/// <summary> /// Initializes a new instance of the <see cref="Link" /> class. /// </summary> /// <param name="relation">relation (required).</param> /// <param name="href">href (required).</param> /// <param name="description">description.</param> /// <param name="method">method (required).</param> public Link(RelationEnum relation = default(RelationEnum), string href = default(string), string description = default(string), MethodEnum method = default(MethodEnum)) { // to ensure "relation" is required (not null) if (relation == null) { throw new InvalidDataException("relation is a required property for Link and cannot be null"); } else { this.Relation = relation; } // to ensure "href" is required (not null) if (href == null) { throw new InvalidDataException("href is a required property for Link and cannot be null"); } else { this.Href = href; } // to ensure "method" is required (not null) if (method == null) { throw new InvalidDataException("method is a required property for Link and cannot be null"); } else { this.Method = method; } this.Description = description; }
public void RecordLatency(MethodEnum method, int bucket) { lock (_methodLatencies) { try { if (_methodLatencies.TryGetValue(method, out long[] values))
private Task Persist(MethodEnum method, Try <Type> maybeRoot, HttpContext context) { if (maybeRoot.IsFailure) { return(Task.CompletedTask); } var rootType = maybeRoot.Result; var array = Utility.ParseObject(Serialization, rootType.MakeArrayType(), context.Request.Body, false, Locator, context); if (array.IsFailure) { return(Task.CompletedTask); } var arg = (object[])array.Result; return(Converter.PassThrough <PersistAggregateRoot, PersistAggregateRoot.Argument <object> >( context, new PersistAggregateRoot.Argument <object> { RootName = rootType.FullName, ToInsert = method == MethodEnum.Insert ? arg : null, ToUpdate = method == MethodEnum.Update ? CreateKvMethod.MakeGenericMethod(rootType).Invoke(this, new[] { arg }) : null, ToDelete = method == MethodEnum.Delete ? arg : null })); }
private Stream Persist(MethodEnum method, Either <Type> maybeRoot, Stream data) { if (maybeRoot.IsFailure) { return(maybeRoot.Error); } var rootType = maybeRoot.Result; var array = Utility.ParseObject(Serialization, Either <Type> .Succes(rootType.MakeArrayType()), data, false, Locator); if (array.IsFailure) { return(array.Error); } var arg = (object[])array.Result; return (Converter.PassThrough <PersistAggregateRoot, PersistAggregateRoot.Argument <object> >( new PersistAggregateRoot.Argument <object> { RootName = rootType.FullName, ToInsert = method == MethodEnum.Insert ? arg : null, ToUpdate = method == MethodEnum.Update ? CreateKvMethod.MakeGenericMethod(rootType).Invoke(this, new[] { arg }) : null, ToDelete = method == MethodEnum.Delete ? arg : null })); }
internal static string Request <T>(string url, MethodEnum method, T value = default(T)) { string response = string.Empty; if (!string.IsNullOrWhiteSpace(url)) { try { switch (method.EnumDesc().ToUpper(System.Globalization.CultureInfo.CurrentCulture)) { case "GET": response = GetAsync(url).Result; break; case "POST": response = PostAsync(url, value).Result; break; } } catch (Exception) { throw; } } else { throw new Exception("url不能为空"); } return(response); }
/// <summary> /// Initializes a new instance of the <see cref="InlineObject88" /> class. /// </summary> /// <param name="nClusters">nClusters (required).</param> /// <param name="force">force.</param> /// <param name="clusterBy">clusterBy (required).</param> /// <param name="method">method (required).</param> public InlineObject88(int nClusters = default(int), bool force = default(bool), ClusterByEnum clusterBy = default(ClusterByEnum), MethodEnum method = default(MethodEnum)) { // to ensure "nClusters" is required (not null) if (nClusters == null) { throw new InvalidDataException("nClusters is a required property for InlineObject88 and cannot be null"); } else { this.NClusters = nClusters; } // to ensure "clusterBy" is required (not null) if (clusterBy == null) { throw new InvalidDataException("clusterBy is a required property for InlineObject88 and cannot be null"); } else { this.ClusterBy = clusterBy; } // to ensure "method" is required (not null) if (method == null) { throw new InvalidDataException("method is a required property for InlineObject88 and cannot be null"); } else { this.Method = method; } this.Force = force; }
/// <summary> /// Initializes a new instance of the <see cref="ClusterProjectRequest" /> class. /// </summary> /// <param name="nClusters">nClusters (required).</param> /// <param name="force">force.</param> /// <param name="clusterBy">clusterBy (required).</param> /// <param name="method">method (required).</param> /// <param name="requireConfirmation">requireConfirmation.</param> public ClusterProjectRequest(int nClusters = default(int), bool force = default(bool), ClusterByEnum clusterBy = default(ClusterByEnum), MethodEnum method = default(MethodEnum), bool requireConfirmation = default(bool)) { // to ensure "nClusters" is required (not null) if (nClusters == null) { throw new InvalidDataException("nClusters is a required property for ClusterProjectRequest and cannot be null"); } else { this.NClusters = nClusters; } // to ensure "clusterBy" is required (not null) if (clusterBy == null) { throw new InvalidDataException("clusterBy is a required property for ClusterProjectRequest and cannot be null"); } else { this.ClusterBy = clusterBy; } // to ensure "method" is required (not null) if (method == null) { throw new InvalidDataException("method is a required property for ClusterProjectRequest and cannot be null"); } else { this.Method = method; } this.Force = force; this.RequireConfirmation = requireConfirmation; }
/// <summary> /// Initializes a new instance of the <see cref="KratosSubmitSelfServiceSettingsFlowWithPasswordMethodBody" /> class. /// </summary> /// <param name="csrfToken">CSRFToken is the anti-CSRF token.</param> /// <param name="method">Method Should be set to password when trying to update a password. (required).</param> /// <param name="password">Password is the updated password (required).</param> public KratosSubmitSelfServiceSettingsFlowWithPasswordMethodBody(string csrfToken = default(string), MethodEnum method = default(MethodEnum), string password = default(string)) { this.Method = method; // to ensure "password" is required (not null) this.Password = password ?? throw new ArgumentNullException("password is a required property for KratosSubmitSelfServiceSettingsFlowWithPasswordMethodBody and cannot be null"); this.CsrfToken = csrfToken; this.AdditionalProperties = new Dictionary <string, object>(); }
/// <summary> /// Initializes a new instance of the <see cref="KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody" /> class. /// </summary> /// <param name="csrfToken">Sending the anti-csrf token is only required for browser login flows..</param> /// <param name="email">Email to Recover Needs to be set when initiating the flow. If the email is a registered recovery email, a recovery link will be sent. If the email is not known, a email with details on what happened will be sent instead. format: email (required).</param> /// <param name="method">Method supports `link` only right now. (required).</param> public KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody(string csrfToken = default(string), string email = default(string), MethodEnum method = default(MethodEnum)) { // to ensure "email" is required (not null) this.Email = email ?? throw new ArgumentNullException("email is a required property for KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody and cannot be null"); this.Method = method; this.CsrfToken = csrfToken; this.AdditionalProperties = new Dictionary <string, object>(); }
/// <summary> /// Initializes a new instance of the <see cref="WebhookTestRequest" /> class. /// </summary> /// <param name="url">url (required).</param> /// <param name="method">method (required).</param> /// <param name="headers">headers (required).</param> /// <param name="payload">payload.</param> public WebhookTestRequest(string url = default(string), MethodEnum method = default(MethodEnum), Dictionary <string, string> headers = default(Dictionary <string, string>), string payload = default(string)) { // to ensure "url" is required (not null) this.Url = url ?? throw new ArgumentNullException("url is a required property for WebhookTestRequest and cannot be null"); this.Method = method; // to ensure "headers" is required (not null) this.Headers = headers ?? throw new ArgumentNullException("headers is a required property for WebhookTestRequest and cannot be null"); this.Payload = payload; }
public async Task OpenURL(string url, MethodEnum method = MethodEnum.GET, bool includeSessionCookie = false) { ResolveNetworkUtil(); //if (NUtil != null && (NUtil.RemoteHostStatus () == NetworkStatus.NotReachable)) { // DI.Get<UnreachableInvoker> ().Invoke (); //} else { var client = new RestClient(); if (includeSessionCookie) { AppModel AM = DependencyService.Resolve <AppModel>(); var cookieJar = new CookieContainer(); cookieJar.Add(new Uri(Constants.BASE_URI), new Cookie(AM.UserSessionCookie.Name, AM.UserSessionCookie.Value)); client.CookieContainer = cookieJar; } var request = new RestRequest(url, (Method)method) { RequestFormat = DataFormat.Json }; //AddNetworkActivity (url); var cancellationTokenSource = new CancellationTokenSource(); var response = await client.ExecuteTaskAsync(request, cancellationTokenSource.Token); if (response.Cookies.Count > 0) { foreach (var cookie in response.Cookies) { if (cookie.Name == "_whitepaperbible_session") { UserSessionCookie = new SessionCookie { Name = cookie.Name, Value = cookie.Value }; } } } ResponseText = response.Content; RemoveNetworkActivity(url); if (response.ResponseStatus == ResponseStatus.Error) { DispatchError(); } else { DispatchComplete(); } //} }
/// <summary> /// Initializes a new instance of the <see cref="TransactionPost" /> class. /// </summary> /// <param name="_event">Store event that created the transaction. (required).</param> /// <param name="method">The payment method: `credit_card` - a credit-card transaction; `electronic_wallet` - an online wallet; `store_credit` - a transaction using store credit; `gift_certificate` - a transaction using a gift certificate; `custom` - manual payment methods; `token` - payment token; `nonce` - temporary payment token; `offsite` - online payment off the site (e.g., PayPal); `offline` - payment method that takes place offline. (required).</param> /// <param name="amount">Amount of money in the transaction. (required).</param> /// <param name="currency">Currency used for the transaction. (required).</param> /// <param name="gateway">The payment gateway, where applicable. (required).</param> /// <param name="gatewayTransactionId">The transaction ID returned by the payment gateway for this transaction item. .</param> /// <param name="dateCreated">The datetime of the transaction. .</param> /// <param name="test">True if the transaction performed was a test, or if the gateway is in test mode. .</param> /// <param name="status">Status of the transaction. .</param> /// <param name="fraudReview">Result of gateway fraud review, if any. Default is `false`. .</param> /// <param name="referenceTransactionId">Identifier for an existing transaction upon which this transaction acts. .</param> /// <param name="offline">offline.</param> /// <param name="custom">custom.</param> public TransactionPost(EventEnum _event = default(EventEnum), MethodEnum method = default(MethodEnum), float?amount = default(float?), string currency = default(string), GatewayEnum gateway = default(GatewayEnum), string gatewayTransactionId = default(string), DateTime?dateCreated = default(DateTime?), bool?test = default(bool?), StatusEnum?status = default(StatusEnum?), bool?fraudReview = default(bool?), int?referenceTransactionId = default(int?), Offline1 offline = default(Offline1), Custom1 custom = default(Custom1)) { // to ensure "_event" is required (not null) if (_event == null) { throw new InvalidDataException("_event is a required property for TransactionPost and cannot be null"); } else { this.Event = _event; } // to ensure "method" is required (not null) if (method == null) { throw new InvalidDataException("method is a required property for TransactionPost and cannot be null"); } else { this.Method = method; } // to ensure "amount" is required (not null) if (amount == null) { throw new InvalidDataException("amount is a required property for TransactionPost and cannot be null"); } else { this.Amount = amount; } // to ensure "currency" is required (not null) if (currency == null) { throw new InvalidDataException("currency is a required property for TransactionPost and cannot be null"); } else { this.Currency = currency; } // to ensure "gateway" is required (not null) if (gateway == null) { throw new InvalidDataException("gateway is a required property for TransactionPost and cannot be null"); } else { this.Gateway = gateway; } this.GatewayTransactionId = gatewayTransactionId; this.DateCreated = dateCreated; this.Test = test; this.Status = status; this.FraudReview = fraudReview; this.ReferenceTransactionId = referenceTransactionId; this.Offline = offline; this.Custom = custom; }
/// <summary> /// Initializes a new instance of the <see cref="AccountValidationRequest" /> class. /// </summary> /// <param name="bankAccount">Account Number to query.</param> /// <param name="bankCode">Bank Code to query - same codes are used as for creating the transactions.</param> /// <param name="phoneNumber">Phone number to query.</param> /// <param name="mobileProvider">mobileProvider.</param> /// <param name="country">Country of account in 2-character alpha ISO 3166-2 country format (required).</param> /// <param name="currency">The currency the bank account is in (required).</param> /// <param name="method">The method of the payment. Currently bank and mobile are supported (required).</param> public AccountValidationRequest(string bankAccount = default(string), string bankCode = default(string), string phoneNumber = default(string), PayoutMethodMobileProviderEnum mobileProvider = default(PayoutMethodMobileProviderEnum), CountryEnum country = default(CountryEnum), CurrencyEnum currency = default(CurrencyEnum), MethodEnum method = default(MethodEnum)) { this.Country = country; this.Currency = currency; this.Method = method; this.BankAccount = bankAccount; this.BankCode = bankCode; this.PhoneNumber = phoneNumber; this.MobileProvider = mobileProvider; }
/// <summary> /// Initializes a new instance of the <see cref="ClientSubmitSelfServiceRegistrationFlowWithPasswordMethodBody" /> class. /// </summary> /// <param name="csrfToken">The CSRF Token.</param> /// <param name="method">Method to use This field must be set to `password` when using the password method. (required).</param> /// <param name="password">Password to sign the user up with (required).</param> /// <param name="traits">The identity's traits (required).</param> public ClientSubmitSelfServiceRegistrationFlowWithPasswordMethodBody(string csrfToken = default(string), MethodEnum method = default(MethodEnum), string password = default(string), Object traits = default(Object)) { this.Method = method; // to ensure "password" is required (not null) this.Password = password ?? throw new ArgumentNullException("password is a required property for ClientSubmitSelfServiceRegistrationFlowWithPasswordMethodBody and cannot be null"); // to ensure "traits" is required (not null) this.Traits = traits ?? throw new ArgumentNullException("traits is a required property for ClientSubmitSelfServiceRegistrationFlowWithPasswordMethodBody and cannot be null"); this.CsrfToken = csrfToken; this.AdditionalProperties = new Dictionary <string, object>(); }
public void RecordException(MethodEnum method) { try { _exceptionsCounters.AddOrUpdate(method, 1, (key, count) => count + 1); } catch (Exception ex) { _log.Warn("Exception caught executing RecordException", ex); } }
protected override void PacketSent(Result result) { if (Method == MethodEnum.Set) { Method = MethodEnum.Get; Start(); } else { Finished(result); } }
public Endpoint ForMethod(MethodEnum method) { this.Method = method.ToDescriptionString(); this.BaseEndpoint = "http://mixpanel.com/api/2.0/"; if (method == MethodEnum.Export) { this.BaseEndpoint = "http://data.mixpanel.com/api/2.0/"; } return(this); }
private Stream Persist(MethodEnum method, Type root, Stream data) { var array = (object[])Utility.ParseObject(Serialization, root.MakeArrayType(), data, false, Locator); return (Converter.PassThrough <PersistAggregateRoot, PersistAggregateRoot.Argument <object> >( new PersistAggregateRoot.Argument <object> { RootName = root.FullName, ToInsert = method == MethodEnum.Insert ? array : null, ToUpdate = method == MethodEnum.Update ? CreateKvMethod.MakeGenericMethod(root).Invoke(this, new[] { array }) : null, ToDelete = method == MethodEnum.Delete ? array : null })); }
private void SetHeaders(string subscriptionKey, MethodEnum method, HttpWebRequest webRequest, string accessToken, string siteID, string signature, string nonce, bool json) { webRequest.AllowAutoRedirect = true; webRequest.Accept = "*/*"; webRequest.UserAgent = "CSharp Test"; webRequest.Headers.Add("X-Signature", signature); webRequest.Headers.Add("X-Nonce", nonce); webRequest.Headers.Add("ocp-apim-subscription-key", subscriptionKey); webRequest.Timeout = 100000; if (json) { webRequest.ContentType = "application/json"; } else { webRequest.ContentType = "application/x-www-form-urlencoded"; } if (accessToken != "") { string authorization = String.Concat("Bearer ", accessToken); webRequest.Headers.Add("Authorization", authorization); } if (siteID != "") { webRequest.Headers.Add("X-Site", siteID); } switch (method) { case MethodEnum.GET: webRequest.Method = "GET"; break; case MethodEnum.POST: webRequest.Method = "POST"; break; case MethodEnum.PUT: webRequest.Method = "PUT"; break; case MethodEnum.DELETE: webRequest.Method = "DELETE"; break; } }
/// <summary> /// 请求的封装,封装了默认请求方式 /// </summary> /// <param name="url"></param> /// <param name="httpType"></param> /// <param name="query"></param> /// <param name="postdata"></param> /// <returns></returns> public static ReturnMessage Request(string url, MethodEnum method = MethodEnum.Get, string cookStr = "", Dictionary <string, string> query = null, object postdata = null) { Args httpArgs = new Args(); httpArgs.Url = url; httpArgs.Method = method; httpArgs.cookStr = cookStr; if (query != null) { httpArgs.QueryDic = query; } if (postdata != null) { httpArgs.postData.Data = postdata; } return(Request(httpArgs)); }
public static string GetString(this MethodEnum me) { switch (me) { case MethodEnum.Treatment: return("treatment"); case MethodEnum.Treatments: return("treatments"); case MethodEnum.TreatmentWithConfig: return("treatmentWithConfig"); case MethodEnum.TreatmentsWithConfig: return("treatmentsWithConfig"); case MethodEnum.Track: return("track"); default: return("NO VALUE GIVEN"); } }
private Result setSyncMethod(MethodEnum method) { Method = method; return(Invoke()); }
private IAsyncResult setAsyncMethod(MethodEnum method, AsyncCallback callback) { Method = method; return(BeginInvoke(callback)); }
public BackgroundEraser(Boolean fe, MethodEnum m) { // Przypisanie ustawień this.fastErase = fe; this.mode = m; bw = new BackgroundWorker(); // Ciało nowe wątku który zostanie uruchomiony w tle bw.DoWork += ((sender, args) => { BackgroundWorker worker = sender as BackgroundWorker; // Pobranie kopii listy plików List <File> _files = (List <File>)args.Argument; // Liczniki int filesCounter = _files.Count; int filesEraseCounter = 0; /* Tworzymy nową tablicę zadań do wykonania współbieżnego - efektywniejsze niż uruchamianie kilku wątków - komputer sam dobiera liczbę wątków do wykonania tych zadań */ Task[] tasks = new Task[filesCounter]; for (int i = filesCounter; i > 0; i--) { int index = i - 1; string filePath = (string)_files[index].fileFullPath; // Definiowanie zadań - jeden plik do wmazania na jedno zadanie tasks[index] = new Task(() => { try { _files[index].StatusUpdate("Processing..."); // Odświeża progress bar'a i data grid'a if (worker != null) { worker.ReportProgress(filesEraseCounter * 100 / filesCounter); } // Wymazuje dany plik Boolean result = FileEraserFunction(filePath, fastErase, mode); if (result) { _files[index].StatusUpdate("Deleted!"); } else { _files[index].StatusUpdate("Internal Error."); } } catch (OwnException ex) // Własny wyjątek rzucany przez FileEraserFunction gdy plik nie istnieje { System.Windows.MessageBox.Show("File: " + ex.Message + " not found!\nExceptoion source: " + ex.Source, "Oopps!"); _files[index].StatusUpdate("File not found."); } finally { filesEraseCounter++; if (worker != null) { worker.ReportProgress(filesEraseCounter * 100 / filesCounter); } } }); // tasks end } // for end try { // Uruchomienie wykonywania wszystkich zadań w tle for (int a = 0; a < filesCounter; a++) { tasks[a].Start(); } // Czekaj na zakończenie wszystkich zadań Task.WaitAll(tasks); } catch (AggregateException ae) // Jeśli coś poszło nie tak -- przydatne przy debuggowaniu { Console.WriteLine("One or more exceptions occurred: "); foreach (var ex in ae.Flatten().InnerExceptions) { Console.WriteLine("{0}", ex.Message); } } Console.WriteLine("Status of completed tasks:"); foreach (var t in tasks) { Console.WriteLine(">Task #{0}: {1}", t.Id, t.Status); } }); //bw.doWork end /* Reakcja na ReportProgress */ bw.ProgressChanged += ((sender, args) => { MainWindow.main.pBar.Minimum = 0; MainWindow.main.pBar.Maximum = 100; MainWindow.main.pBar.Value = args.ProgressPercentage; }); /* Gdy background worker zakończy swe działanie */ bw.RunWorkerCompleted += ((sender, args) => { Console.WriteLine("Process ended."); MainWindow.main.BackgroundEaserWorkerEnd(); }); } // constructor end
/* Funkcja wymazuje pliki z dysku zadanymi metodami */ private bool FileEraserFunction(string filename, Boolean fastErase, MethodEnum mode) { bool ret = true; const int BufferSize = 1024000; // Wielkość bufora 1MB int eraseLoops; // Ilość pętli wymazujących if (fastErase == false) { eraseLoops = 100; } else { eraseLoops = 32; } // Rzucanie własnego wyjątku jeśli plik nie istnieje na dysku if (!System.IO.File.Exists(filename)) { throw new OwnException(filename); } try { byte[] DataBuffer; if (mode != MethodEnum.ZerosOnes) // Jeśli nie wybrano metody napisania samymi zerami i jedynkami { using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite)) { DataBuffer = new byte[BufferSize]; int readDataNumber = -1; // liczba przeczytanych bajtów FileInfo fileInfo = new FileInfo(filename); // Pobranie informacji o pliku long count = fileInfo.Length; // Licznik danych do pobrania long offset = 0; for (int i = 0; i < eraseLoops; i++) { while (count >= 0) /* Dopóki nie odczytano całego pliku */ { readDataNumber = stream.Read(DataBuffer, 0, BufferSize); if (readDataNumber == 0) { break; } switch (mode) /* Wybór metody wymazywania */ { case MethodEnum.Ones: for (int j = 0; j < readDataNumber; j++) { DataBuffer[j] = 0xFF; } break; case MethodEnum.Zeros: for (int j = 0; j < readDataNumber; j++) { DataBuffer[j] = 0x00; } break; case MethodEnum.Random: default: Random randomBytes = new Random(); randomBytes.NextBytes(DataBuffer); break; } // switch end // Nadpisanie pobranych bajtów jedną z wybranych wartości stream.Seek(offset, SeekOrigin.Begin); stream.Write(DataBuffer, 0, readDataNumber); // Obliczenie przesunięcia w pliku i pomniejszenie licznika bajtów do pobrania offset += readDataNumber; count -= readDataNumber; } //while end } // for end } // using end } // if end /* To samo co wyżej tylko powoduje zniszczenie śladów po pliku na dysku magnetycznym */ using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite)) { FileInfo fileInfo = new FileInfo(filename); long count = fileInfo.Length; long offset = 0; DataBuffer = new byte[BufferSize]; int readDataNumber = -1; for (int i = 0; i < 12; i++) { fileStream.Seek(0, SeekOrigin.Begin); while (count >= 0) { readDataNumber = fileStream.Read(DataBuffer, 0, BufferSize); if (readDataNumber == 0) { break; } for (int j = 0; j < readDataNumber; j++) { DataBuffer[j] = 0x00; } fileStream.Seek(offset, SeekOrigin.Begin); fileStream.Write(DataBuffer, 0, readDataNumber); for (int j = 0; j < readDataNumber; j++) { DataBuffer[j] = 0xFF; } fileStream.Seek(offset, SeekOrigin.Begin); fileStream.Write(DataBuffer, 0, readDataNumber); offset += readDataNumber; count -= readDataNumber; } //while end } //for end } // using end /* Dla utrudnienia ewentualnego odzyskiwania danych zmienia nazwę pliku na losowy ciąg znaków */ string newFileName = ""; Random random = new Random(); string prevName = System.IO.Path.GetFileName(filename); string dirName = System.IO.Path.GetDirectoryName(filename); do { int getRandomLetters = random.Next(9); for (int i = 0; i < prevName.Length + getRandomLetters; i++) { newFileName += random.Next(9).ToString(); } newFileName = dirName + "\\" + newFileName; } while (System.IO.File.Exists(newFileName)); System.IO.File.Move(filename, newFileName); // zmiana nazwy pliku System.IO.File.Delete(newFileName); // Usunięcie pliku } catch { ret = false; } return(ret); } //file eraser end
/// <summary> /// Determins the method of the request, post / get /// </summary> public AjaxRequest Method(MethodEnum ajaxMethod) { _method = ajaxMethod; return this; }
/// <summary> /// Initializes a new instance of the <see cref="KapiRouteResp" /> class. /// </summary> /// <param name="applicationData">applicationData.</param> /// <param name="customApplicationVars">customApplicationVars.</param> /// <param name="customChannelVars">customChannelVars.</param> /// <param name="eventCategory">eventCategory.</param> /// <param name="eventName">eventName.</param> /// <param name="fromRealm">fromRealm.</param> /// <param name="fromURI">fromURI.</param> /// <param name="fromUser">fromUser.</param> /// <param name="method">method (required).</param> /// <param name="planData">planData.</param> /// <param name="prePark">prePark.</param> /// <param name="ringbackMedia">ringbackMedia.</param> /// <param name="routeErrorCode">routeErrorCode.</param> /// <param name="routeErrorMessage">routeErrorMessage.</param> /// <param name="routes">routes.</param> /// <param name="transferMedia">transferMedia.</param> public KapiRouteResp(string applicationData = default(string), Object customApplicationVars = default(Object), Object customChannelVars = default(Object), EventCategoryEnum?eventCategory = default(EventCategoryEnum?), EventNameEnum?eventName = default(EventNameEnum?), string fromRealm = default(string), string fromURI = default(string), string fromUser = default(string), MethodEnum method = default(MethodEnum), string planData = default(string), PreParkEnum?prePark = default(PreParkEnum?), string ringbackMedia = default(string), string routeErrorCode = default(string), string routeErrorMessage = default(string), List <KapiRouteRespRoute> routes = default(List <KapiRouteRespRoute>), string transferMedia = default(string)) { // to ensure "method" is required (not null) if (method == null) { throw new InvalidDataException("method is a required property for KapiRouteResp and cannot be null"); } else { this.Method = method; } this.ApplicationData = applicationData; this.CustomApplicationVars = customApplicationVars; this.CustomChannelVars = customChannelVars; this.EventCategory = eventCategory; this.EventName = eventName; this.FromRealm = fromRealm; this.FromURI = fromURI; this.FromUser = fromUser; this.PlanData = planData; this.PrePark = prePark; this.RingbackMedia = ringbackMedia; this.RouteErrorCode = routeErrorCode; this.RouteErrorMessage = routeErrorMessage; this.Routes = routes; this.TransferMedia = transferMedia; }
private Stream Persist(MethodEnum method, string root, Stream body) { var type = Utility.CheckAggregateRoot(DomainModel, root); return(Persist(method, type, body)); }
private static IEnumerable <Tuple <MethodEnum, NGramsEnum, D_ParamEnum> > GetProcessParams(MethodEnum method) { for (var ngarms = NGramsEnum.ngram_1; ngarms <= NGramsEnum.ngram_4; ngarms++) { for (var d = D_ParamEnum.d0; d <= D_ParamEnum.d2; d++) { yield return(Tuple.Create(method, ngarms, d)); } } }