/// <summary> /// Initializes a new instance of the <see cref="InsertTableOnlineRequest"/> class. /// </summary> /// <param name="document">The document.</param> /// <param name="table">Table parameters.</param> /// <param name="nodePath">The path to the node in the document tree.</param> /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param> /// <param name="password">Password for opening an encrypted document.</param> /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param> /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param> /// <param name="revisionDateTime">The date and time to use for revisions.</param> public InsertTableOnlineRequest(System.IO.Stream document, TableInsert table, string nodePath = null, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null) { this.Document = document; this.Table = table; this.NodePath = nodePath; this.LoadEncoding = loadEncoding; this.Password = password; this.DestFileName = destFileName; this.RevisionAuthor = revisionAuthor; this.RevisionDateTime = revisionDateTime; }
/// <summary> /// Initializes a new instance of the <see cref="InsertTableRequest"/> class. /// </summary> /// <param name="name">The filename of the input document.</param> /// <param name="table">Table parameters.</param> /// <param name="nodePath">The path to the node in the document tree.</param> /// <param name="folder">Original document folder.</param> /// <param name="storage">Original document storage.</param> /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param> /// <param name="password">Password for opening an encrypted document.</param> /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param> /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param> /// <param name="revisionDateTime">The date and time to use for revisions.</param> public InsertTableRequest(string name, TableInsert table, string nodePath = null, string folder = null, string storage = null, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null) { this.Name = name; this.Table = table; this.NodePath = nodePath; this.Folder = folder; this.Storage = storage; this.LoadEncoding = loadEncoding; this.Password = password; this.DestFileName = destFileName; this.RevisionAuthor = revisionAuthor; this.RevisionDateTime = revisionDateTime; }
public void TestInsertTable() { var localName = "TablesGet.docx"; var remoteName = "TestInsertTable.docx"; var fullName = Path.Combine(this.dataFolder, remoteName); var tableDto = new TableInsert { ColumnsCount = 5, RowsCount = 4 }; this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(this.tableFolder) + localName)); var request = new InsertTableRequest(remoteName, this.dataFolder, table: tableDto); var actual = this.WordsApi.InsertTable(request); Assert.AreEqual(200, actual.Code); }
public int checkAndStoreSensorData() { int result = 0; //getting now time DateTime nowTime = DateTime.Now; //getting latest time in database TableFk tb = new TableFk(); //To prepare iMISID field long theId = 1; theId = tb.GetFk("dbo", "etc", "recordNum"); string strtheId = Convert.ToString(theId - 1); //get the latest time based on the main key string latedDatabaseTime = ""; TableSelect tbSelect = new TableSelect(); DataTable dt = tbSelect.DoSelect("etc", "dbo", "recordNum,ts", " recordNum=" + strtheId, "recordNum"); if (dt.Rows.Count == 0) { ////Display("The database is empty. Transferring all data from the hosting server."); //this will never happer because some records should be imported in the initial stage. } else { //Get the latest time of database latedDatabaseTime = dt.Rows[0]["ts"].ToString(); } DateTime latestDatabaseTime = Convert.ToDateTime(latedDatabaseTime); TimeSpan hoursSpan = nowTime - latestDatabaseTime; double passedHours = hoursSpan.TotalHours; double iPassedHours = Math.Round(passedHours); TimeSpan hourIntervel = new TimeSpan(0, 1, 0, 0); //one hour DateTime tempDateTime = DateTime.Now; string theYear = ""; string theMonth = ""; string theDay = ""; string theHour = ""; string theFileName = ""; if (passedHours >= 1) { tempDateTime = latestDatabaseTime; for (int i = 1; i <= iPassedHours; i++) { tempDateTime = tempDateTime + hourIntervel; theYear = Convert.ToString(tempDateTime.Year); if (tempDateTime.Month > 9) { theMonth = Convert.ToString(tempDateTime.Month); } else { theMonth = "0" + Convert.ToString(tempDateTime.Month); } if (tempDateTime.Day > 9) { theDay = Convert.ToString(tempDateTime.Day); } else { theDay = "0" + Convert.ToString(tempDateTime.Day); } if (tempDateTime.Hour > 9) { theHour = Convert.ToString(tempDateTime.Hour); } else { theHour = "0" + Convert.ToString(tempDateTime.Hour); } theYear = Convert.ToString(tempDateTime.Year); theFileName = "Waverley_" + theYear + "-" + theMonth + "-" + theDay + "_" + theHour + "-00_FluxData" + ".dat"; string path1 = ReadSetting("etDatafilePath"); //string filePath = @"e:\etcData"; string filePath = path1; string dataLine = ""; string errors = ""; ////localhostETC.etcWebService etcService = new localhostETC.etcWebService(); try { dataLine = ReadTextData(filePath, theFileName); } catch (Exception ex) { errors = ex.ToString(); } if (dataLine != "")// transferred the .dat file data into database { string[] stringArray = dataLine.Split(','); //processing stringArray[0] string stringArray0 = stringArray[0]; stringArray0 = stringArray0.Substring(1, stringArray0.Length - 2); stringArray[0] = stringArray0; TableInsert tbinsert = new TableInsert(); int operationResultStat = 0; string tableName = "etc"; string userName = "******"; string tbfileds = "recordNum,ts"; for (int j = 2; j < dt.Columns.Count; j++) { tbfileds = tbfileds + "," + dt.Columns[i]; } tbfileds = tbfileds + ",[cov_h2o_Ux_Avg],[cov_h2o_Uy_Avg],[cov_h2o_Uz_Avg],[cov_h2o_Uz_Tot],[cov_co2_Ux_Avg],[cov_co2_Uy_Avg],[cov_co2_Uz_Avg],[cov_co2_Uz_Tot]" + ",[wnd_dir_compass_Avg],[wnd_dir_csat3_Avg],[wnd_spd_Avg],[rslt_wnd_spd_Avg],[Hs],[Fc_wpl],[LE_wpl],[Hc],[tau],[u_star]" + ",[Ts_mean],[stdev_Ts],[cov_Ts_Ux],[cov_Ts_Uy],[cov_Ts_Uz],[co2_mean],[stdev_co2],[cov_co2_Ux],[cov_co2_Uy],[cov_co2_Uz]" + ",[h2o_Avg],[stdev_h2o],[cov_h2o_Ux],[cov_h2o_Uy],[cov_h2o_Uz],[Ux_Avg],[stdev_Ux],[cov_Ux_Uy],[cov_Ux_Uz],[Uy_Avg]" + ",[stdev_Uy],[cov_Uy_Uz],[Uz_Avg],[stdev_Uz],[press_mean],[rho_a_mean],[wnd_dir_compass],[wnd_dir_csat3],[wnd_spd],[rslt_wnd_spd]" + ",[std_wnd_dir],[Fc_irga],[LE_irga],[co2_wpl_LE],[co2_wpl_H],[h2o_wpl_LE],[h2o_wpl_H],[SHF1_raw_Avg],[SHF2_raw_Avg],[SHF_mean_Avg]" + ",[SR01Up_Avg] ,[SR01Dn_Avg],[IR01Up_Avg],[IR01Dn_Avg],[NR01TC_Avg],[NR01TK_Avg],[NetRs_Avg],[NetRl_Avg],[Albedo_Avg],[UpTot_Avg]" + ",[DnTot_Avg],[NetTot_Avg],[IR01UpCo_Avg],[IR01DnCo_Avg],[Canopy_Temp_Avg],[AirTC1_Avg],[RH1_Avg],[e_kPa1_Avg],[e_Sat1_Avg],[VPD1_Avg]" + ",[AirTC2_Avg],[RH2_Avg],[e_kPa2_Avg],[e_Sat2_Avg],[VPD2_Avg],[n_Tot],[csat_warnings],[irga_warnings],[del_T_f_Tot],[sig_lck_f_Tot]" + ",[amp_h_f_Tot],[amp_l_f_Tot],[chopper_f_Tot],[detector_f_Tot],[pll_f_Tot],[sync_f_Tot],[agc_Avg],[panel_temp_Avg],[batt_volt_Avg]"; string recordValues = Convert.ToString(stringArray[1]) + ",'" + Convert.ToString(stringArray[0]) + "'"; for (int j = 2; j < stringArray.Length; j++) { recordValues = recordValues + "," + Convert.ToString(stringArray[j]); } operationResultStat = tbinsert.Insert(tableName, userName, tbfileds, recordValues); result = operationResultStat; } ////TextBox1.Text = dataLine; } } //Display("New ID number is created."); return(result); }
public ActionResult InputRainfallData(rainfallData model) { string userInput = model.theDate + "|| " + Convert.ToString(model.theHour) + " : " + Convert.ToString(model.theData); int result = 0; DateTime inputDate = Convert.ToDateTime(model.theDate); string stringMinDate = "2010-01-01"; DateTime minDate = Convert.ToDateTime(stringMinDate); DateTime tempDateTime = inputDate; string theHour = Convert.ToString(model.theHour); string inputRainfall = Convert.ToString(model.theData); string theYear = ""; string theMonth = ""; string theDay = ""; theYear = Convert.ToString(tempDateTime.Year); if (tempDateTime.Month > 9) { theMonth = Convert.ToString(tempDateTime.Month); } else { theMonth = "0" + Convert.ToString(tempDateTime.Month); } if (tempDateTime.Day > 9) { theDay = Convert.ToString(tempDateTime.Day); } else { theDay = "0" + Convert.ToString(tempDateTime.Day); } string theFinalInputDateTime = theYear + "-" + theMonth + "-" + theDay + " " + theHour + ":00:00.000"; //check if this hour data has been stored in the database. If no insert else update //preparing to insert data TableFk tb = new TableFk(); //To prepare iMISID field long theId = 1; theId = tb.GetFk("dbo", "rainfall", "recordNum"); string strtheId = Convert.ToString(theId); //check if this data has been inserted TableSelect tbSelect = new TableSelect(); DataTable dt = tbSelect.DoSelect("rainfall", "dbo", "recordNum,ts", " ts='" + theFinalInputDateTime + "'", "recordNum"); if (minDate < inputDate) { if ((dt != null) && (dt.Rows.Count > 0)) { //updating int theresult = 0; TableUpdate updatetable = new TableUpdate(); string tableName = "rainfall"; string userName = "******"; string fieldvalue = "rainfall=" + inputRainfall; string conditions = "ts='" + theFinalInputDateTime + "'"; theresult = updatetable.Update(tableName, userName, fieldvalue, conditions); } else { //inserting TableInsert tbinsert = new TableInsert(); int operationResultStat = 0; string tableName = "rainfall"; string userName = "******"; string tbfileds = "recordNum,ts,rainfall"; string recordValues = strtheId + ",'" + theFinalInputDateTime + "'," + inputRainfall; operationResultStat = tbinsert.Insert(tableName, userName, tbfileds, recordValues); result = operationResultStat; } //get the 24 hour data of the date to display string dateTime1 = theYear + "-" + theMonth + "-" + theDay + " 00:00:00"; string dateTime2 = theYear + "-" + theMonth + "-" + theDay + " 23:00:00"; dt = tbSelect.DoSelect("rainfall", "dbo", "ts,rainfall", " ts>='" + dateTime1 + "' and ts<='" + dateTime2 + "'", "recordNum"); ViewData["oneDayData"] = dt; //ViewBag.theDayData = dt; } ViewBag.fromControllerMessage = "The user input is " + userInput; return(View()); }
public int storeRainfallData(string theFileName) { int result = 0; //string filePath = @"D:\etc\etc\uploadedFiles"; string path1 = ReadSetting("rainFallDatafilePath"); //string filePath = @"C:\2016codes\etc\etc\uploadedFiles"; string filePath = path1; string[] dataLine = null; string errors = ""; ////localhostETC.etcWebService etcService = new localhostETC.etcWebService(); try { dataLine = ReadTextData1(filePath, theFileName); if (theFileName.Length > 0) { int theOperationResultStat = DeleteRainfallDataFile(theFileName); result = theOperationResultStat; } } catch (Exception ex) { errors = ex.ToString(); } if (dataLine != null)// transferred the .dat file data into database { //check and insert rainfall data string[] theSeparator2 = { "," }; string theYear = ""; string theMonth = ""; string theDay = ""; for (int i = 1; i < dataLine.Length; i++) { string[] lineData = dataLine[i].Split(theSeparator2, StringSplitOptions.None); string lineDate = lineData[0]; DateTime theLineDate = Convert.ToDateTime(lineDate); DateTime tempDateTime = theLineDate; theYear = Convert.ToString(tempDateTime.Year); if (tempDateTime.Month > 9) { theMonth = Convert.ToString(tempDateTime.Month); } else { theMonth = "0" + Convert.ToString(tempDateTime.Month); } if (tempDateTime.Day > 9) { theDay = Convert.ToString(tempDateTime.Day); } else { theDay = "0" + Convert.ToString(tempDateTime.Day); } string theDateTime = theYear + "-" + theMonth + "-" + theDay + " " + lineData[1]; string totalRain = lineData[14]; // select the dateTime in the rainfall table, if not exite, insert it into the table // select //preparing to insert data TableFk tb = new TableFk(); //To prepare iMISID field long theId = 1; theId = tb.GetFk("dbo", "rainfall", "recordNum"); string strtheId = Convert.ToString(theId); //check if this data has been inserted TableSelect tbSelect = new TableSelect(); DataTable dt = tbSelect.DoSelect("rainfall", "dbo", "recordNum,ts", " ts='" + theDateTime + "'", "recordNum"); if ((dt != null) && (dt.Rows.Count > 0)) { //nothing to do } else { //inserting TableInsert tbinsert = new TableInsert(); int operationResultStat = 0; string tableName = "rainfall"; string userName = "******"; string tbfileds = "recordNum,ts,rainfall"; string recordValues = strtheId + ",'" + theDateTime + "'," + totalRain; operationResultStat = tbinsert.Insert(tableName, userName, tbfileds, recordValues); result = operationResultStat; } } //for int test = 1; } return(result); }