Posts

sql server - Extracting a subset of DataTable columns in C# and then sending them to browser client as a JSON string -

Image
here's scenario: c# middle tier webservice has data sent sql server in system.data.datatable object. there dozens of columns in datatable's columns collection. browser client needs see 6 of them. stored proc on server general purpose, not designed specific task. assume have use it, rather writing new sp. is there simple way, perhaps using generics, extract desired subset of columns datatable list or collection, , convert resulting list or collection json using json.net? is possible create skeletal c# class definition foo relevant field names (and datatypes) , match on field names "automagically" , thereby generate list<foo> datatable's rows collection? ideally, during json conversion, sql server datetime values (e.g. 2014-06-24t18:45:00 ) converted value make easy instantiate javascript date in client without having string manipulation of date representation. full working console app code pasted below. 2 main methods need follows. f...

How do you plot a CostSensitiveClassifier tree in R? -

Image
in case i'm using rweka package , j48 within cost sensitive classifier function. know package "party" can plot normal j48 tree, not sure how plot csc output. library(rweka) csc <- costsensitiveclassifier(species ~ ., data = iris, control = weka_control(`cost-matrix` = matrix(c(0,10, 0, 0, 0, 0, 0, 10, 0), ncol = 3), w = "weka.classifiers.trees.j48", m = true)) csc costsensitiveclassifier using minimized expected misclasification cost weka.classifiers.trees.j48 -c 0.25 -m 2 classifier model j48 pruned tree ------------------ petal.width <= 0.6: setosa (50.0) petal.width > 0.6 | petal.width <= 1.7 | | petal.length <= 4.9: versicolor (48.0/1.0) | | petal.length > 4.9 | | | petal.width <= 1.5: virginica (3.0) | | | petal.width > 1.5: versicolor (3.0/1.0) | petal.width > 1.7: virginica (46.0/1.0) number of leaves : 5 size of tree : 9 cost matrix 0 0 0 10 0 10 0 0 0 plot(csc) er...

php - Check entire array for sub array with two values? -

i have mixed array made of events. example: array ( [0] => array ( [start] => 20:00 [end] => 21:00 [title] => test event date [date] => 22 jun 2014 ) [1] => array ( [start] => 20:00 [end] => 22:00 [title] => test event without date [day] => sunday ) ) most events daily (e.g. sunday). however, occasional , have full date. if event full date falls on same day , time daily event (as in example above), daily event not show when step through array in foreach. is there way check if both date , time exist in item somewhere else in array before outputting? this have far: // loop through each day of week foreach ($thisweek $day => $v) { echo '<h3>' . $day . ' ' . $v . '</h3>'; echo '<ul>'; // loop through bunch of hours forea...

mysql - Whats wrong with this SQL query? Syntax error -

this question has answer here: using reserved words in column names 2 answers and error im getting you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'key = (tick)testkey(tick)' select * keys key = 'testkey'; i tried site isn't help. http://www.piliapp.com/mysql-syntax-check/ ticks , apostrophe. this sql passes syntax check @ link provided: select * `keys` `key` = 'testkey';

spring - Update or SaveorUpdate in CRUDRespository, Is there any options available -

i trying crud operations entity bean. crudrepository provide standard methods find , delete , save there no generic method available saveorupdate(entity entity) in turn calls hibernate or hibernatetemplate sessions saveorupdate() methods. the way crudrepository provides functionality use this @modifying @query("update space c set c.owner = :name c.id = :id") integer setnameforid(@param("name") string name, @param("id") but not generic , needs written complete form fields. please let me know if there way or can session of hibernate or object of spring hibernatetemplate solve issue. the implementation of method <s extends t> s save(s entity) from interface crudrepository<t, id extends serializable> extends repository<t, id> automatically want. if entity new call persist on entity manager , otherwise call merge the code looks this: public <s extends t> s save(s entity) { if (entityinfor...

Automatically remove the file generated by Java 7 Annotation Processor when delete the annotation in source file -

i writing java annotation processor java 7 source code. , surely, can use javax.annotation.processing.filer me generate file under project directory automatically. ex: annotation @becare public interface test { @becare int compare(int a, int b); } my annotation processor's job when detects given annotation @becare, generate file me. my question if remove annotation previous code snippet, can let annotation processor aware , delete file created? or there workaround me achieve ? thanks in advance. when create genrated file declare it's linked 'test' interface this: elements eltutils = processingenv.getelementutils(); filer.createsourcefile("testgenerated", eltutils.gettypeelement("test")); when source deleted, processor remove generated file javadoc says: if there no originating elements, none need passed. information may used in incremental environment determine need rerun processors or remove generated files. n...

java - How to print docx and pdf? -

i can print using txt file printer, however, when change docx or pdf many undefined characters cannot understood @ all. guys have ideas on how solve this. the code used. import system import javax.print import java.io java.lang import thread filestream = java.io.bufferedinputstream(java.io.fileinputstream("c:/geeks.txt")) psinformat = javax.print.docflavor.input_stream.autosense mydoc = javax.print.simpledoc(filestream,psinformat,none) aset = javax.print.attribute.hashprintrequestattributeset() aset.add(javax.print.attribute.standard.copies(2)) services = javax.print.printservicelookup.lookupdefaultprintservice() job = services.createprintjob() job.print(mydoc, none) thread.sleep(20000) filestream.close() .docx files have far more formatting , nonsense going on text file. open 1 using notepad , you'll see i'm talking about. because of this, you'll need use dedicated library read docx file, such https://pypi.python.org/pypi/docx/0.2.4 ...