public static string SaveDatasetToFile(ServerDataSource dataSource)//string fullpathfilename, string filetype, string datasetName) { string dirPath = Path.GetDirectoryName(dataSource.FileNameWithPath); string fileName = Path.GetFileName(dataSource.FileNameWithPath); //.Replace("'","\'"); string fullpathfilename = Path.Combine(dirPath, fileName); //dirPath + "\\" + fileName; string datasetname = dataSource.Name; string filetype = dataSource.Extension.ToUpper(); string worksheetname = null; if (filetype.Equals("XLS") || filetype.Equals("XLSX")) { worksheetname = dataSource.SheetName != null && dataSource.SheetName.Length > 0 ? dataSource.SheetName : "Sheet1";//worksheetname = "Sheet1"; } // set some extra parameter here if needed. Like Excel sheetname. replace etc.. if (true) //06Feb2018 now we support SPSS saving. !filetype.Equals("SAV")) { return(string.Format("BSkysaveDataset(fullpathfilename=\"{0}\",filetype='{1}', newWorksheetName='{2}', dataSetNameOrIndex='{3}')", FormatFileName(fullpathfilename), filetype, worksheetname, datasetname)); } else { return(""); } }//Anil #5
public object GetColNumFactors(string colName, string datasetnameorindex) { object r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); r = _userSession.DefaultDispatcher.getColNumFactors(colName, dataSource); return(r); }
public List <FactorMap> GetColumnFactormap(string colName, string datasetnameorindex) { List <FactorMap> r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); r = _userSession.DefaultDispatcher.getColFactormap(colName, dataSource); return(r); }
public UAReturn DataSourceLoad(string datasetName, string fileName, string sheetname) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, fileName, datasetName, sheetname); r = _userSession.DefaultDispatcher.DataSourceLoad(dataSource, sheetname); return(r); //08Jun2013 }
}//Anil #5 public static string closeDataset(ServerDataSource dataSource) { //string dirPath = Path.GetDirectoryName(dataSource.FileNameWithPath); //string fileName = Path.GetFileName(dataSource.FileNameWithPath); //string fullpathfilename = Path.Combine(dirPath, fileName);// dirPath + "\\" + fileName; string datasetname = dataSource.Name; return(string.Format("BSkycloseDataset('{0}')", datasetname)); }//Anil #5
public UAReturn DataFrameLoad(string dframename, string datasetName, string sheetname)//13Feb2014 { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, dframename, datasetName, sheetname); //empty filename sent. r = _userSession.DefaultDispatcher.DataFrameLoad(dataSource, datasetName); return(r); }
public UAReturn RemoveDatagridRow(int rowindex, string datasetnameorindex, string sheetname) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, sheetname); if ((r = _userSession.DefaultDispatcher.removeDatagridRow(rowindex, dataSource)).Success) { return(r); } return(null); }
//06Jun2018 public UAReturn SortDatagridCol(string colName, string sortorder, string datasetnameorindex) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); if ((r = _userSession.DefaultDispatcher.sortDatagridColumn(colName, sortorder, dataSource)).Success) { return(r); } return(null); }
public UAReturn ChangeMissingVals(string colName, string colProp, List <string> newMisVal, string mistype, string datasetnameorindex) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); if ((r = _userSession.DefaultDispatcher.changeMissing(colName, colProp, newMisVal, mistype, dataSource)).Success) { return(r); } return(null); }
public UAReturn AddFactorLevels(string colName, List <string> finalLevelList, string datasetnameorindex) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); if ((r = _userSession.DefaultDispatcher.addColLevels(colName, finalLevelList, dataSource)).Success) { return(r); } return(null); }
//04Aug2016 Delete multiple rows from Vargrid (ie delete multiple columns from dataset in R) //public UAReturn removeMultipleVargridColumn(string[] colNames, string datasetnameorindex) //{ // UAReturn r; // ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex); // if ((r = _userSession.DefaultDispatcher.removeMultipleVarGridCol(colNames, dataSource)).Success) // { // return r; // } // return null; //} public UAReturn ChangeColumnLevels(string colName, List <ValLvlListItem> finalLevelList, string datasetnameorindex) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); if ((r = _userSession.DefaultDispatcher.changeColLevels(colName, finalLevelList, dataSource)).Success) { return(r); } return(null); }
public UAReturn ChangeNominalOrOrdinalToScale(string colName, List <FactorMap> fmap, string changeTo, string datasetnameorindex) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); if ((r = _userSession.DefaultDispatcher.setNominalOrOrdinalToScale(colName, fmap, changeTo, dataSource)).Success) { return(r); } return(null); }
public static string GetColFactorMap(string colName, bool numval, ServerDataSource dataSource) { if (numval) { return(string.Format("BSkyGetFactorMap('{0}', '{1}')$numvalues", colName, dataSource.Name)); //return numeric factor } else { return(string.Format("BSkyGetFactorMap('{0}', '{1}')$lvlnames", colName, dataSource.Name)); //return string factor } }
public UAReturn removeVargridColumn(string colName, string datasetnameorindex) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); if ((r = _userSession.DefaultDispatcher.removeVarGridCol(colName, dataSource)).Success) { return(r); } return(null); }
public UAReturn EditDatagridCell(string colName, string celdata, int rowindex, string datasetnameorindex) { UAReturn r = null; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); r = _userSession.DefaultDispatcher.editDatagridCell(colName, celdata, rowindex, dataSource);//move out of following 'if' condition part if (r.Success) { return(r); } return(null); }
public void LoadSourceState(string path) { int pos, vol; bool playing; lock (DataSource.Lock) { Playlist library = null; if (indexerFinished) { library = DataSource.LibraryPlaylist; } ServerDataSource newSource; using (FileStream fs = File.OpenRead(path)) { Playlist.DeserializeCounters(fs); PlaylistItem.DeserializeCounters(fs); newSource = ServerDataSource.Deserialize(fs); } lock (newSource.Lock) { // Make sure that Current and Next still exist; they might not if the DB was saved when playing from the Library PlaylistItem foo; if (newSource.CurrentItem != null && !newSource.TryGetItem(newSource.CurrentItem.UID, out foo)) { newSource.CurrentItem = null; } if (newSource.NextItemOverride != null && !newSource.TryGetItem(newSource.NextItemOverride.UID, out foo)) { newSource.NextItemOverride = null; } if (indexerFinished) { newSource.LibraryPlaylist = library; } DataSource = newSource; pos = DataSource.Position; vol = DataSource.Volume; playing = DataSource.Playing; BroadcastMessage(HaProtoImpl.Opcode.SETDB, new HaProtoImpl.SETDB() { dataSource = DataSource }); } } mover.OnSetDataSource(); player.OnSongChanged(); player.Playing = playing; player.Position = pos; player.Volume = vol; }
public UAReturn addNewVariable(string colName, string rdataType, string dgridval, int rowindex, string datasetnameorindex)//15Oct2015 modified { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); if ((r = _userSession.DefaultDispatcher.addNewColDatagrid(colName, rdataType, dgridval, rowindex, dataSource)).Success)//2 { return(r); } return(null); }
public UAReturn DatasetSaveAs(string fileName, string filetype, string sheetname, string datasetnameorindex)//Anil #2 { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, fileName, datasetnameorindex, sheetname); if ((r = _userSession.DefaultDispatcher.DatasetSaveas(dataSource)).Success)//2 { return(r); } return(null); }
public UAReturn DataSourceRefresh(string datasetName, string fileName, string sheetname)//25Mar2013 refresh on new row added by compute { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, fileName, datasetName, sheetname); if ((r = _userSession.DefaultDispatcher.DataSourceRefresh(dataSource)).Success) { return(r); } return(null); }
public static string LoadDataSource(ServerDataSource dataSource, string tableOrSheetname = "Sheet1") { dataSource.DataSetType = GetDataSetTypeFromExtension(dataSource.Extension); if (dataSource.DataSetType != ServerDataSourceTypeEnum.Unknown) { //for Excel sheet name must also be set before opening. Anil dataSource.HasHeader = true; dataSource.FieldSperator = ","; return(LoadDataSourceExt(dataSource, tableOrSheetname)); } return(string.Empty); }
public static string LoadDataSource(ServerDataSource dataSource, string tableOrSheetname = "Sheet1")//, IOpenDataFileOptions odfo=null { dataSource.DataSetType = GetDataSetTypeFromExtension(dataSource.Extension); if (dataSource.DataSetType != ServerDataSourceTypeEnum.Unknown) { //for Excel sheet name must also be set before opening. Anil //16Nov2017 No need do it in LoadDataSourceExt dataSource.HasHeader = true; //16Nov2017 No need do it in LoadDataSourceExt dataSource.FieldSperator = ","; return(LoadDataSourceExt(dataSource, tableOrSheetname));//, odfo } return(string.Empty); }
public UAReturn DatasetClose(string fullfilename, string datasetnameorindex, string sheetname)//Anil #2 { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, fullfilename, datasetnameorindex, sheetname); if ((r = _userSession.DefaultDispatcher.CloseDataset(dataSource)).Success)//2 { return(r); } return(null); }
public static string LoadDataframe(ServerDataSource dataSource, string dframe) { dataSource.DataSetType = GetDataSetTypeFromExtension(dataSource.Extension); if (dataSource.DataSetType == ServerDataSourceTypeEnum.Unknown) { //for Excel sheet name must also be set before opening. Anil dataSource.HasHeader = true; dataSource.FieldSperator = ","; string datasetname = dataSource.Name; return(string.Format("BSky.LoadRefresh.Dataframe('{0}')", dframe)); } return(string.Empty); }
public UAReturn EditVarGrid(string datasetnameorindex, string colName, string colProp, string newValue, List <string> colLevels)//Anil. { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); r = _userSession.DefaultDispatcher.editDatasetVarGrid(dataSource, colName, colProp, newValue, colLevels); if (r.Success)//2 { return(r); } return(r); //20Jun2013 return null; }
public static string LoadEmptyDataSource(ServerDataSource dataSource) { dataSource.DataSetType = GetDataSetTypeFromExtension(dataSource.Extension); if (dataSource.DataSetType == ServerDataSourceTypeEnum.Unknown) { //for Excel sheet name must also be set before opening. Anil //16Nov2017 No need do it in LoadDataSourceExt dataSource.HasHeader = true; //16Nov2017 No need do it in LoadDataSourceExt dataSource.FieldSeparator = ","; string datasetname = dataSource.Name; return(string.Format("BSkyOpenNewDataset( datasetName='{0}')", datasetname)); } return(string.Empty); }
//11Oct2017 public UAReturn MakeColNumeric(string datasetnameorindex, string colName)//Anil. { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); r = _userSession.DefaultDispatcher.makeColumnNumeric(dataSource, colName); if (r.Success)//2 { return(r); } return(r); //20Jun2013 return null; }
public static string LoadDataframe(ServerDataSource dataSource, string dframe) { dataSource.DataSetType = GetDataSetTypeFromExtension(dataSource.Extension); if (dataSource.DataSetType == ServerDataSourceTypeEnum.Unknown || dataSource.DataSetType == ServerDataSourceTypeEnum.RDATA) { //for Excel sheet name must also be set before opening. Anil //16Nov2017 No need do it in LoadDataSourceExt dataSource.HasHeader = true; //16Nov2017 No need do it in LoadDataSourceExt dataSource.FieldSeparator = ","; string datasetname = dataSource.Name; return(string.Format("BSky.LoadRefresh.Dataframe('{0}')", dframe)); // prefixing with .GlobalEnv$ can get you to right 'summary' 20Dec2015 } return(string.Empty); }
//25Oct2016 Added 'replace' parameter (to overwrite a dataset with new values) public UAReturn DataSourceLoad(string datasetName, string fileName, string sheetname, bool removeSpacesSPSS = false, bool replace = false, IOpenDataFileOptions odfo = null) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, fileName, datasetName, sheetname, removeSpacesSPSS, replace, odfo); r = _userSession.DefaultDispatcher.DataSourceLoad(dataSource, sheetname, removeSpacesSPSS); //,odfo //08Jun2013 //if ( r.Success) //{ // return r; //} //return null; return(r); //08Jun2013 }
//public void ResetOutput() //{ //} //03Jan2014 public UAReturn EmptyDataSourceLoad(string datasetName, string fileName, string sheetname) { UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, fileName, datasetName, sheetname); r = _userSession.DefaultDispatcher.EmptyDataSourceLoad(dataSource); //08Jun2013 //if ( r.Success) //{ // return r; //} //return null; return(r); //08Jun2013 }
public UAReturn AddNewDatagridRow(string colName, string celdata, string rowdata, int rowindex, string datasetnameorindex) { if (rowdata == null || rowdata.Trim().Length < 2) { rowdata = ""; // or c() or NA } UAReturn r; ServerDataSource dataSource = new ServerDataSource(_userSession.DefaultDispatcher, "", datasetnameorindex, null); r = _userSession.DefaultDispatcher.addNewDataRow(colName, celdata, rowdata, rowindex, dataSource);//move out of following 'if' condition part if (r.Success) { return(r); } return(null); }
protected override void TearDown() { DataSource = null; base.TearDown(); }
protected override void TearDown() { ClientDataSource = null; ServerDataSource = null; base.TearDown(); }
private void HandleAssincConnection(IAsyncResult result) { StreamReader reader; StreamWriter writer; string user, password, mime, uriFile; // accepted connection var listener = (TcpListener) result.AsyncState; var client = listener.EndAcceptTcpClient(result); _connectionHandler.Set(); var clientId = Guid.NewGuid(); Trace.Write("Accepted connection with ID " + clientId, "Information"); try { reader = new StreamReader(client.GetStream()); writer = new StreamWriter(client.GetStream()) {AutoFlush = true}; } catch (Exception) { Trace.WriteLine( "An error during initialization of reader and writer of connection: " + clientId + ". Closing comunication.", "Information"); client.Close(); return; } try { user = reader.ReadLine(); password = reader.ReadLine(); mime = reader.ReadLine(); uriFile = reader.ReadLine(); } catch (Exception) { Trace.WriteLine( "An error reading user, password, mime and uro file of connection: " + clientId + ". Closing comunication.", "Information"); client.Close(); return; } if (user == null || password == null || mime == null || uriFile == null) { Trace.WriteLine( "User or password or mime or uri file are null (connection: " + clientId + "). Closing comunication.", "Information"); client.Close(); return; } // Trace.WriteLine("user: "******"Information"); // Trace.WriteLine("password: "******"Information"); // Trace.WriteLine("mime: " + mime, "Information"); // Trace.WriteLine("uri file: " + uriFile, "Information"); var datasource = new ServerDataSource(); if (!datasource.UserExists(user, password)) { writer.WriteLine("KO"); client.Close(); return; } writer.WriteLine("OK"); IList<BaseTool> processingTools = null; var numberOfTools = 0; try { processingTools = ToolsManifest.GetAvailableTools(mime); numberOfTools = processingTools.Count; } catch { Trace.WriteLine("Error getting available tools (connection: " + clientId + ")", "Information"); } try { //communicating the number of tools writer.WriteLine(numberOfTools); } catch (Exception) { Trace.WriteLine( "Error sending the number of tools to processed file (connection: " + clientId + "). Closing comunication.", "Information"); client.Close(); return; } try { for (var i = 0; i < numberOfTools; ++i) writer.WriteLine(processingTools[i].ToString()); } catch (Exception) { Trace.WriteLine( "Error sending the tools to processed file (connection: " + clientId + "). Closing comunication.", "Information"); client.Close(); return; } string operation; try { operation = reader.ReadLine(); } catch (Exception) { Trace.WriteLine("Error reading the operation (connection: " + clientId + "). Closing comunication.", "Information"); client.Close(); return; } if (operation == null) { Trace.WriteLine("Error reading the operation (connection: " + clientId + "). Closing comunication.", "Information"); client.Close(); return; } Trace.WriteLine("operazione da compiere: " + operation, "Information"); datasource.EnqueueProcessingRequest(new ProcessingMessage(uriFile, mime, operation)); var returnMessage = datasource.DequeueProcessingCompletion(); Trace.WriteLine("File uri: " + returnMessage.FileUri, "Information"); try { writer.WriteLine(returnMessage.FileUri); } catch (Exception) { Trace.WriteLine( "Error sending the uri of processed file (connection: " + clientId + "). Closing comunication.", "Information"); client.Close(); return; } client.Close(); }
protected override void SetUp() { base.SetUp(); ClientDataSource = new ClientDataSource(); ServerDataSource = new ServerDataSource(); }