private void btnExportNameLibrary_Click(object sender, RoutedEventArgs e) { var config = DataExport.ExportNameLibrary(); var path = EmulatorHelper.SaveConfig <NameLibraryEntity>(config, EmulatorHelper.NameLibraryFileName); MessageBox.Show("导出成功,目录:" + path); }
// Start is called before the first frame update void Start() { Destroy(FindObjectOfType <SceneOperator>()); export = ScriptableObject.CreateInstance <DataExport>(); export.Init(FindObjectOfType <DataManager>().AllTracksData); StartCoroutine(SaveData()); }
protected override void ProcessRecord() { WriteObject(""); WriteObject($"FetchXML File: {FetchXmlFile}"); WriteObject($"Output Data Path: {OutputDataPath}{Environment.NewLine}"); var crmParameter = new CrmParameter(ConnectionString) { ExportDirectoryName = OutputDataPath }; var attributesToExcludeArray = AttributesToExclude?.Split(';'); string dataDir = crmParameter.GetSourceDataDirectory(); FetchXmlFile = (string.IsNullOrWhiteSpace(FetchXmlFile) || FetchXmlFile == "NULL" ? @"Veritec.Dynamics.DataMigrate.FetchQuery.xml" : FetchXmlFile); WriteObject($"Connecting ({crmParameter.GetConnectionStringObfuscated()})"); var dataExport = new DataExport(crmParameter, FetchXmlFile); WriteObject($"Fetch queries loaded {Environment.NewLine}"); foreach (var fetchXml in dataExport.FetchXmlQueries) { WriteObject($"Executing Fetch Query: {fetchXml.Key}..."); var queryResultXml = dataExport.ExecuteFetchXmlQuery(fetchXml.Key, fetchXml.Value, attributesToExcludeArray); WriteObject($"Writing Results: {dataDir}{fetchXml.Key}.xml {Environment.NewLine}"); DataExport.SaveFetchXmlQueryResulttoDisk(dataDir, fetchXml.Key, queryResultXml.ToString()); } }
/// <summary> /// 打开需要的工作空间文件及地图 /// Open the workspace and the map /// </summary> private void Initialize() { try { // 打开工作空间及地图 // Open the workspace and the map. WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"..\..\SampleData\DataExchange\DataExchange.smwu"); m_workspace.Open(conInfo); m_srcDatasource = m_workspace.Datasources["SrcDatasource"]; m_desDatasource = m_workspace.Datasources["DesDatasource"]; m_sourceRegion = m_srcDatasource.Datasets["China400"] as DatasetVector; m_sourceImg = m_srcDatasource.Datasets["Day"] as DatasetImage; m_dataExport = new DataExport(); m_dataImport = new DataImport(); this.m_mapControl.Map.Layers.Add(m_sourceRegion, true); this.m_mapControl.Map.Refresh(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void btnExportApiDebug_Click(object sender, RoutedEventArgs e) { var config = DataExport.ExportRequestConfig(true); var path = EmulatorHelper.SaveConfig <RequestConfigEntity>(config, EmulatorHelper.RequestConfigDebugFileName); MessageBox.Show("导出成功,目录:" + path); }
private void btnExportSkill2_Click(object sender, RoutedEventArgs e) { var config = DataExport.ExportSkillTips(true); var path = EmulatorHelper.SaveConfig <SkillTipsEntity>(config, EmulatorHelper.SkilltipFileName); MessageBox.Show("导出成功,目录:" + path); }
private void btnExportFormation_Click(object sender, RoutedEventArgs e) { var config = DataExport.ExportFormationConfig(); var path = EmulatorHelper.SaveConfig <FormationConfigEntity>(config, EmulatorHelper.FormationFileName); MessageBox.Show("导出成功,目录:" + path); }
private void btnExportDescription1_Click(object sender, RoutedEventArgs e) { var config = DataExport.ExportDescriptionDic1(); var path = EmulatorHelper.SaveConfig <DescriptionConfigEntity1>(config, EmulatorHelper.DescriptionDicFileName1); MessageBox.Show("导出成功,目录:" + path); }
/// <summary> /// Export the assembly data to hard disk /// </summary> public void ExportData() { // Get the name of the previously exported file var previousExportFileName = _projectManager.CurrentProject.ExportFileName; // Open save dialog for the user var exportPath = StandaloneFileBrowser.SaveFilePanel( "Export Data", "", string.IsNullOrEmpty(previousExportFileName) ? _projectManager.CurrentProject.Name : previousExportFileName, "bus" ); // If save dialog was canceled, string is empty if (string.IsNullOrEmpty(exportPath)) { return; } // Export data to XML var(success, message) = DataExport.ExportData(exportPath); if (!success) { toast.Error(Toast.Short, message); return; } // Export successful toast.Success(Toast.Short, "Data was exported successfully!"); }
private void btnExportItem_Click(object sender, RoutedEventArgs e) { var config = DataExport.ExportItemTips(); var path = EmulatorHelper.SaveConfig <ItemTipsEntity>(config, EmulatorHelper.ItemtipFileName); CacheDataHelper.Instance.RefreshItemtips(config); MessageBox.Show("导出成功,目录:" + path); }
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { stopTime = DateTime.Now; DataExport.Invoke("CardDemo", tmpexportdata, startTime, stopTime); count++; startTime = stopTime; getdata(); }
private void ExportGridToFile() { if (_activeDataTable == null) { throw new Exception("DataTable can not be extracted from the current gird!"); } DataExport.ExportGridToFile(_activeDataTable); }
private void btnExportDescription_Click(object sender, RoutedEventArgs e) { var config = DataExport.ExportDescriptionDic(); var path = EmulatorHelper.SaveConfig <DescriptionConfigEntity>(config, EmulatorHelper.DescriptionDicFileName); Type tp = typeof(DescriptionConfigEntity); dynamic t = Activator.CreateInstance(tp); DataExport.ActivatorCreateType(tp, t); var summary = DataExport.BuildSummaryDic(Assembly.GetExecutingAssembly(), "Games.NBall.WpfEmulator.XML"); EmulatorHelper.SaveConfig <DescriptionConfigEntity>(t, EmulatorHelper.DescriptionDicDebugFileName, summary); //MessageBox.Show("导出成功,目录:" + path); }
private void btnExportMessage_Click(object sender, RoutedEventArgs e) { try { var message = DataExport.ExportMesseageConfig(); var path = EmulatorHelper.SaveConfig <MessageConfigEntity>(message, EmulatorHelper.MessageFileName); MessageBox.Show("导出成功,目录:" + path); } catch (Exception ex) { LogHelper.Insert(ex); MessageBox.Show("出错了:" + ex.Message); } }
public string ExportData(string fileName) { string error = null; try { DataExport export = new DataExport(); export.Export(fileName, DateFrom, DateTo, TasksGroups); } catch (Exception ex) { error = ex.Message; } return(error); }
public ActionResult ExcelExport() { var dataInput = DataHelper.GenerateData(MAX_RECORD); var exportExcel = new DataExport(); Stopwatch sw = new Stopwatch(); sw.Start(); var resultContent = exportExcel.Export(dataInput, typeof(ReportDataModel).Name, "ReportSummary"); sw.Stop(); return(File(resultContent.Content.ReadAsByteArrayAsync().Result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sw.ElapsedMilliseconds + "_" + exportExcel.FileName)); }
public PSDataExport(DataExport dataExport) { if (dataExport == null) { throw new ArgumentNullException("dataExport"); } DataExportId = dataExport.DataExportId; TableNames = dataExport.TableNames as List <string>; ResourceId = dataExport.ResourceId; DataExportType = dataExport.DataExportType; EventHubName = dataExport.EventHubName; Enable = dataExport.Enable; CreatedDate = dataExport.CreatedDate; LastModifiedDate = dataExport.LastModifiedDate; Name = dataExport.Name; Id = dataExport.Id; Type = dataExport.Type; }
private void _Export(object sender, RoutedEventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "CSV File (*.csv)|*.csv"; Nullable <bool> result = dialog.ShowDialog(); if (result == true) { string jmeno = dialog.FileName; try { DataExport.Save(_readerFactory.Results, dialog.FileName); MessageBox.Show("Data byla uložena!"); } catch (NullReferenceException) {
private void ExportGridToFile() { DataTable dt = null; DataView view = DataView; if (view != null && !String.IsNullOrEmpty(view.RowFilter)) { dt = view.ToTable(); } else { dt = DataTable; } if (dt == null) { throw new Exception("DataTable can not be extracted from the current gird!"); } DataExport.ExportGridToFile(dt); }
public 转为SIT() { dataExport1 = new DataExport(); InitializeComponent(); }
public ActionResult DownRainStation(string sd, string ed, string Station) { DateTime dtStart; DateTime dtEnd; sd = sd.Replace(' ', '-'); ed = ed.Replace(' ', '-'); if (string.IsNullOrEmpty(sd) || string.IsNullOrEmpty(ed)) { dtStart = DateTime.Now; dtEnd = DateTime.Now; } else { string[] aSdt = sd.Split('-'); string[] aEdt = ed.Split('-'); dtStart = new DateTime(Convert.ToInt32(aSdt[0]), Convert.ToInt32(aSdt[1]), Convert.ToInt32(aSdt[2]), Convert.ToInt32(aSdt[3]), 0, 1); dtEnd = new DateTime(Convert.ToInt32(aEdt[0]), Convert.ToInt32(aEdt[1]), Convert.ToInt32(aEdt[2]), Convert.ToInt32(aEdt[3]), 59, 59); } string sStartDate = dtStart.ToString("yyyy-MM-ddTHH:mm:ss"); string sEndDate = dtEnd.ToString("yyyy-MM-ddTHH:mm:ss"); string ssql = @" select * from RainStation where 1=1 and STID = @STID and RTime between @sd and @ed and datepart(mi,RTime) = 0 and datepart(ss,RTime) = 0 order by RTime "; List <RainStation> DataList = new List <RainStation>(); DataList = dbDapper.Query <RainStation>(ssql, new { STID = Station, sd = sStartDate, ed = sEndDate }); //產生檔案路徑 string sTempPath = Path.Combine(Server.MapPath("~/temp/"), DateTime.Now.ToString("yyyyMMdd")); //建立資料夾 Directory.CreateDirectory(sTempPath); string sSaveFilePath = Path.Combine(sTempPath, "RainDataByStation_" + Guid.NewGuid().ToString() + ".csv"); DataTable dt = Utils.ConvertToDataTable <RainStation>(DataList); DataExport de = new DataExport(); Boolean bSuccess = de.ExportBigDataToCsv(sSaveFilePath, dt); if (bSuccess) { string filename = string.Format("RainDataByStation_{0}_{1}.csv", sd, ed).Replace("-", ""); //ASP.NET 回應大型檔案的注意事項 //http://blog.miniasp.com/post/2008/03/11/Caution-about-ASPNET-Response-a-Large-File.aspx //***** 下載檔案過大,使用特殊方法 ***** HttpContext context = System.Web.HttpContext.Current; context.Response.TransmitFile(sSaveFilePath); context.Response.ContentType = "text/csv"; context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename)); Response.End(); } return(null); }
/// <summary> /// Create or update a data export. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='workspaceName'> /// The name of the workspace. /// </param> /// <param name='dataExportName'> /// The data export rule name. /// </param> /// <param name='parameters'> /// The parameters required to create or update a data export. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DataExport> BeginCreateOrUpdateAsync(this IDataExportsOperations operations, string resourceGroupName, string workspaceName, string dataExportName, DataExport parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, workspaceName, dataExportName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public ActionResult DownSoilWaterRainHis(string sd, string ed, string Station) { DateTime dtStart; DateTime dtEnd; sd = sd.Replace(' ', '-'); ed = ed.Replace(' ', '-'); if (string.IsNullOrEmpty(sd) || string.IsNullOrEmpty(ed)) { dtStart = DateTime.Now; dtEnd = DateTime.Now; } else { string[] aSdt = sd.Split('-'); string[] aEdt = ed.Split('-'); dtStart = new DateTime(Convert.ToInt32(aSdt[0]), Convert.ToInt32(aSdt[1]), Convert.ToInt32(aSdt[2]), Convert.ToInt32(aSdt[3]), 0, 1); dtEnd = new DateTime(Convert.ToInt32(aEdt[0]), Convert.ToInt32(aEdt[1]), Convert.ToInt32(aEdt[2]), Convert.ToInt32(aEdt[3]), 59, 59); } string sStartDate = dtStart.ToString("yyyyMMddHH"); string sEndDate = dtEnd.ToString("yyyyMMddHH"); string ssql = @" select * from SoilWaterRainDataHis where 1=1 and STID = @STID and Time between @sd and @ed order by Time "; List <SoilWaterRainDataHis> DataList = new List <SoilWaterRainDataHis>(); DataList = dbDapper.Query <SoilWaterRainDataHis>(ssql, new { STID = Station, sd = sStartDate, ed = sEndDate }); //產生檔案路徑 string sTempPath = Path.Combine(Server.MapPath("~/temp/"), DateTime.Now.ToString("yyyyMMdd")); //建立資料夾 Directory.CreateDirectory(sTempPath); string sSaveFilePath = Path.Combine(sTempPath, "SoilWaterRainDataHisByStation_" + Guid.NewGuid().ToString() + ".xlsx"); DataTable dt = Utils.ConvertToDataTable <SoilWaterRainDataHis>(DataList); List <string> head = new List <string>(); head.Add("站號"); head.Add("時間"); head.Add("Hour"); head.Add("Hour3"); head.Add("Hour6"); head.Add("Hour12"); head.Add("Hour24"); head.Add("DayRainFall"); head.Add("RT"); List <string[]> datas = new List <string[]>(); foreach (SoilWaterRainDataHis item in DataList) { //日期格式化 DateTime MainTime = DateTime.ParseExact(item.Time, "yyyyMMddHH", null); List <string> cols = new List <string>(); cols.Add(item.Stid); cols.Add(MainTime.ToString("yyyy/MM/dd HH:00")); cols.Add(item.Hour.ToString()); cols.Add(item.Hour3.ToString()); cols.Add(item.Hour6.ToString()); cols.Add(item.Hour12.ToString()); cols.Add(item.Hour24.ToString()); cols.Add(item.DayRainfall.ToString()); cols.Add(item.RT.ToString()); datas.Add(cols.ToArray()); } DataExport de = new DataExport(); Boolean bSuccess = de.ExportListToExcel(sSaveFilePath, head, datas); if (bSuccess) { string filename = string.Format("SoilWaterRainDataHis_{0}_{1}_{2}.xlsx", Station, sd, ed).Replace("-", ""); //ASP.NET 回應大型檔案的注意事項 //http://blog.miniasp.com/post/2008/03/11/Caution-about-ASPNET-Response-a-Large-File.aspx //***** 下載檔案過大,使用特殊方法 ***** HttpContext context = System.Web.HttpContext.Current; context.Response.TransmitFile(sSaveFilePath); context.Response.ContentType = "application/vnd.ms-excel"; context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename)); Response.End(); } return(null); }
public ActionResult DownSumRain(string sd, string ed) { DateTime dtStart; DateTime dtEnd; sd = sd.Replace(' ', '-'); ed = ed.Replace(' ', '-'); if (string.IsNullOrEmpty(sd) || string.IsNullOrEmpty(ed)) { dtStart = DateTime.Now; dtEnd = DateTime.Now; } else { string[] aSdt = sd.Split('-'); string[] aEdt = ed.Split('-'); dtStart = new DateTime(Convert.ToInt32(aSdt[0]), Convert.ToInt32(aSdt[1]), Convert.ToInt32(aSdt[2]), Convert.ToInt32(aSdt[3]), 0, 1); dtEnd = new DateTime(Convert.ToInt32(aEdt[0]), Convert.ToInt32(aEdt[1]), Convert.ToInt32(aEdt[2]), Convert.ToInt32(aEdt[3]), 59, 59); } string sStartDate = dtStart.ToString("yyyy-MM-ddTHH:mm:ss"); string sEndDate = dtEnd.ToString("yyyy-MM-ddTHH:mm:ss"); string ssql = @" select STID,STNAME,COUNTY,LAT,LON,sum(CONVERT(float, RAIN)) as RAIN from RainStation where 1=1 and RTime between @sd and @ed and datepart(mi,RTime) = 0 and datepart(ss,RTime) = 0 group by STID,STNAME,COUNTY,LAT,LON "; //List<RainStation> DataList = new List<RainStation>(); var DataList = dbDapper.Query(ssql, new { sd = sStartDate, ed = sEndDate }); //產生檔案路徑 string sTempPath = Path.Combine(Server.MapPath("~/temp/"), DateTime.Now.ToString("yyyyMMdd")); //建立資料夾 Directory.CreateDirectory(sTempPath); string sSaveFilePath = Path.Combine(sTempPath, "SumRainData_" + Guid.NewGuid().ToString() + ".csv"); DataTable dt = new DataTable(); dt.Columns.Add("STID"); dt.Columns.Add("STNAME"); dt.Columns.Add("COUNTY"); dt.Columns.Add("LAT"); dt.Columns.Add("LON"); dt.Columns.Add("RAIN"); foreach (var item in DataList) { DataRow NewRow = dt.NewRow(); NewRow["STID"] = item.STID; NewRow["STNAME"] = item.STNAME; NewRow["COUNTY"] = item.COUNTY; NewRow["LAT"] = item.LAT; NewRow["LON"] = item.LON; NewRow["RAIN"] = item.RAIN; dt.Rows.Add(NewRow); } DataExport de = new DataExport(); Boolean bSuccess = de.ExportBigDataToCsv(sSaveFilePath, dt); if (bSuccess) { string filename = string.Format("SumRainData_{0}_{1}.csv", sd, ed).Replace("-", ""); //ASP.NET 回應大型檔案的注意事項 //http://blog.miniasp.com/post/2008/03/11/Caution-about-ASPNET-Response-a-Large-File.aspx //***** 下載檔案過大,使用特殊方法 ***** HttpContext context = System.Web.HttpContext.Current; context.Response.TransmitFile(sSaveFilePath); context.Response.ContentType = "text/csv"; context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename)); Response.End(); } return(null); }
/// <summary> /// Create or update a data export. /// </summary> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='workspaceName'> /// The name of the workspace. /// </param> /// <param name='dataExportName'> /// The data export rule name. /// </param> /// <param name='parameters'> /// The parameters required to create or update a data export. /// </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 <DataExport> > CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string workspaceName, string dataExportName, DataExport parameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } if (Client.SubscriptionId != null) { if (Client.SubscriptionId.Length < 1) { throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); } } if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } if (resourceGroupName != null) { if (resourceGroupName.Length > 90) { throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); } if (resourceGroupName.Length < 1) { throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); } } if (workspaceName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "workspaceName"); } if (workspaceName != null) { if (workspaceName.Length > 63) { throw new ValidationException(ValidationRules.MaxLength, "workspaceName", 63); } if (workspaceName.Length < 4) { throw new ValidationException(ValidationRules.MinLength, "workspaceName", 4); } if (!System.Text.RegularExpressions.Regex.IsMatch(workspaceName, "^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$")) { throw new ValidationException(ValidationRules.Pattern, "workspaceName", "^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$"); } } if (dataExportName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "dataExportName"); } if (dataExportName != null) { if (dataExportName.Length > 63) { throw new ValidationException(ValidationRules.MaxLength, "dataExportName", 63); } if (dataExportName.Length < 4) { throw new ValidationException(ValidationRules.MinLength, "dataExportName", 4); } if (!System.Text.RegularExpressions.Regex.IsMatch(dataExportName, "^[A-Za-z][A-Za-z0-9-]+[A-Za-z0-9]$")) { throw new ValidationException(ValidationRules.Pattern, "dataExportName", "^[A-Za-z][A-Za-z0-9-]+[A-Za-z0-9]$"); } } if (parameters == null) { throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); } if (parameters != null) { parameters.Validate(); } string apiVersion = "2020-08-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("workspaceName", workspaceName); tracingParameters.Add("dataExportName", dataExportName); tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{workspaceName}", System.Uri.EscapeDataString(workspaceName)); _url = _url.Replace("{dataExportName}", System.Uri.EscapeDataString(dataExportName)); 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 <DataExport>(); _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 <DataExport>(_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 <DataExport>(_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 ActionResult down(string StartDate, string EndDate) { var data = getHisData(StartDate, EndDate); ViewBag.StartDate = StartDate; ViewBag.EndDate = EndDate; //產生檔案路徑 string sTempPath = Path.Combine(Server.MapPath("~/temp/"), DateTime.Now.ToString("yyyyMMdd")); //建立資料夾 Directory.CreateDirectory(sTempPath); string sSaveFilePath = Path.Combine(sTempPath, "ExportAlertLRTI_" + Guid.NewGuid().ToString() + ".xlsx"); DataTable dt = new DataTable(); dt.Columns.Add("RecTime"); dt.Columns.Add("country"); dt.Columns.Add("town"); dt.Columns.Add("village"); dt.Columns.Add("status"); dt.Columns.Add("HOUR1"); dt.Columns.Add("HOUR2"); dt.Columns.Add("HOUR3"); dt.Columns.Add("HOUR6"); dt.Columns.Add("LRTI"); //dt.Columns.Add("ELRTI"); dt.Columns.Add("RT"); dt.Columns.Add("STID"); dt.Columns.Add("STNAME"); dt.Columns.Add("FlowWarning"); dt.Columns.Add("Rt_70"); dt.Columns.Add("R3_70"); dt.Columns.Add("Rt_50"); dt.Columns.Add("R3_50"); dt.Columns.Add("Remark"); foreach (var item in data) { DataRow NewRow = dt.NewRow(); NewRow["RecTime"] = item.RecTime; NewRow["country"] = item.country; NewRow["town"] = item.town; NewRow["village"] = item.village; NewRow["status"] = item.status; NewRow["HOUR1"] = item.HOUR1; NewRow["HOUR2"] = item.HOUR2; NewRow["HOUR3"] = item.HOUR3; NewRow["HOUR6"] = item.HOUR6; NewRow["LRTI"] = item.LRTI; //NewRow["ELRTI"] = item.ELRTI; NewRow["RT"] = item.RT; NewRow["STID"] = item.STID; NewRow["STNAME"] = item.STNAME; NewRow["FlowWarning"] = item.FlowWarning; NewRow["Rt_70"] = item.Rt_70; NewRow["R3_70"] = item.R3_70; NewRow["Rt_50"] = item.Rt_50; NewRow["R3_50"] = item.R3_50; NewRow["Remark"] = item.Remark; dt.Rows.Add(NewRow); } DataExport de = new DataExport(); de.ExportBigDataToExcel(sSaveFilePath, dt); if (System.IO.File.Exists(sSaveFilePath)) { string filename = string.Format("AlertLRTI_{0}_{1}.xlsx", StartDate, EndDate); filename = filename.Replace("-", ""); //讀成串流 Stream iStream = new FileStream(sSaveFilePath, FileMode.Open, FileAccess.Read, FileShare.Read); //回傳出檔案 return(File(iStream, "application/vnd.ms-excel", filename)); } return(View("warnhislist")); }
/// <summary> /// Create or update a data export. /// </summary> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='workspaceName'> /// The name of the workspace. /// </param> /// <param name='dataExportName'> /// The data export rule name. /// </param> /// <param name='parameters'> /// The parameters required to create or update a data export. /// </param> /// <param name='customHeaders'> /// The headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public async Task <AzureOperationResponse <DataExport> > CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string workspaceName, string dataExportName, DataExport parameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send Request AzureOperationResponse <DataExport> _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, workspaceName, dataExportName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); return(await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false)); }
private void exportToFileToolStripMenuItem_Click(object sender, EventArgs e) { DataExport.ExportGridToFile(_dataTbl); }
private void tsmItemExport_Click(object sender, EventArgs e) { DataExport export = new DataExport(this.dgvExpoertData.RowCount, this.m_AppContext); export.DataGrid = this.dgvExpoertData; export.ShowDialog(); }
private void tsmItemExport_Click(object sender, EventArgs e) { DataExport export = new DataExport(this.dataGridView1.RowCount - 1, this.m_TrafficModel.AppContext); export.DataGrid = this.dataGridView1; export.ShowDialog(); }
/// <summary> /// Create or update a data export. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='workspaceName'> /// The name of the workspace. /// </param> /// <param name='dataExportName'> /// The data export rule name. /// </param> /// <param name='parameters'> /// The parameters required to create or update a data export. /// </param> public static DataExport CreateOrUpdate(this IDataExportsOperations operations, string resourceGroupName, string workspaceName, string dataExportName, DataExport parameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, workspaceName, dataExportName, parameters).GetAwaiter().GetResult()); }
private static void StartListener() { UdpClient listener = new UdpClient(listenPort); IPAddress ip = IPAddress.Parse(ipString); IPEndPoint groupEP = new IPEndPoint(ip, listenPort); ResultVM = new MatchResultViewModel(); var p = new Packet(); var sp = new SessionPacket(); int sTick = -1; int pTick = -1; bool isQualiStated = false; bool isRaceStated = false; bool isPlayerStated = false; bool isRacing = true; try { Console.WriteLine($"{DateTime.Now:t} Waiting for broadcast on {ipString}:{listenPort}"); while (true) { byte[] bytes = listener.Receive(ref groupEP); p.LoadBytes(bytes); if (p.PacketType == PacketType.FinalClassification) // once when Qualifying/Race is finished { if (!isRacing && !isQualiStated) { isQualiStated = true; ResultVM.LoadQualiData(bytes); Console.WriteLine($"{DateTime.Now:t} Qualifying time has been recorded."); } else if (isRacing && !isRaceStated) { isRaceStated = true; ResultVM.LoadRaceData(bytes); Console.WriteLine($"{DateTime.Now:t} Players in race : {ResultVM.NumberOfPlayers}"); DataExport.ExportToExcel(ResultVM); DataExport.ExportToConsole(ResultVM); Console.WriteLine($"{DateTime.Now:t} Race result has been exported to Excel file."); } } else if (p.PacketType == PacketType.Session) { sTick = (sTick + 1) % 60; // 2 times per sec; check once per 30s if (sTick != 0) { continue; } sp.LoadBytes(bytes); // SessionType.ShortQualifying actually = 7 ??? if ((int)sp.SessionTypeMode == 7 || sp.SessionTypeMode == SessionPacket.SessionType.OneShotQualifying) { if (isRacing) // First detection of quali session { Console.WriteLine($"{DateTime.Now:t} Current session : Qualifying"); isRacing = false; } } else if (sp.SessionTypeMode == SessionPacket.SessionType.Race || sp.SessionTypeMode == SessionPacket.SessionType.Race2) { if (!isRacing) // First detection of race session { Console.WriteLine($"{DateTime.Now:t} Current session : Race"); isRacing = true; } } } #region refresh name (enabled) else if (p.PacketType == PacketType.Participants) { pTick = (pTick + 1) % 6; // once every 5s; check once per 30s if (pTick != 0) { continue; } ResultVM.LoadParticipantData(bytes); if (!isPlayerStated) { Console.WriteLine($"{DateTime.Now:t} Player names have been recorded."); isPlayerStated = true; } } #endregion // Console.WriteLine($"Received broadcast from {groupEP} :"); } } catch (SocketException e) { Console.WriteLine($"{DateTime.Now:T} {e}"); } finally { listener.Close(); } }