Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-11-22T13:16:57Z
Updated: 9 hours 1 min ago

Different project share mappings in Fluent NHibernate

Wed, 08/16/2017 - 14:41

In my solution, I have two projects that uses NHibernate (ApplicationServices and ApplicationServicesPreProduction). And in my DDD I have 3 class libraries with one that contains my mappings (Domain.Entities).

I need my two projects store the same object in two differents tables in my Oracle Express DB (MESURES and MESURES_PREPROD).

My problem is that I have mapping in my second project (ApplicationServicesPreProduction) and in the Domain.Entites class Library.

ApplicationServices references Domain.Entities but ApplicationServicesPreProduction (ASPP) doesn't.

ApplicationServices doesn't references ASPP. When i'm at compilation time, I can see that there's 5 DLL that are created.

I understood that Fluent takes all the mappings in the Assembly so I believe it creates a conflict. But I also understood that an Assembly is the DLL so why ApplicationServices takes ASPP mappings in considerations ?

Here is my project structure to see :

I first believed that because I was referencing some objects from Domain.Entities from ASPP, it all linked everything. But now it's ApplicationServices that seems to reference something from ASPP.

Now I have few questions if you cannot help me directly :

  • What's an assembly exactly ?
  • How do you separate two projects from an assembly ?
  • Can I just, in my Nhibernate Session creator, reference only ONE ClassMap and not from the assembly ?

Wait until process exit that run by Runtime.exec("wcim process call create notepad.exe")

Wed, 08/16/2017 - 14:40

I am working on an application which is able to run programs, monitoring them to reopen in case the user closes them accidentally and close programs on log out.

I am able to get process id of program by parsing the input stream of "wcim process call create ".

I use this code snippet to run programs and detect when program is closed by user. My problem is the command i use(wcim) to run programs exit immediately after running them. How can i achieve detection of program exit? (note: i dont want to use tasklist command and compare whether process has exited)

My code:

Process process = null; try { process = Runtime.getRuntime() .exec("wmic process call create \"notepad.exe\""); BufferedReader stdin = new BufferedReader( new InputStreamReader(process.getInputStream())); String processIdLine = ""; String line; while ((line = stdin.readLine()) != null) { if (line.contains("ProcessId")) { processIdLine = line; break; } System.out.println(line); } stdin.close(); String[] param = processIdLine.split("="); if (param.length > 1) { String pId = param[1]; pId = pId.replaceAll(";", " "); pId = pId.replaceAll(" ", ""); System.out.println("ID : " + pId); } try { process.waitFor(); // I want it to hang here till notepad closed. } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("PROCESSE EXIT"); } catch (IOException e) { e.printStackTrace(); }

Need SAMBA c++ API's for authenticating Active Directory user

Wed, 08/16/2017 - 14:40

to authenticating active directory user we can use LogonUser() windows function. and default provider that will use kerberos or if not possible uses NTLM.

I found similar post for this but it doesn't talk about SAMBA: Authenticate linux client app to windows server app via kerberos or any secure protocol

Please let me know how to imeplement this using SAMBA c++ library if any?

Publicar en IIS 7

Wed, 08/16/2017 - 14:40

Necesito publicar una solucion en visual studio 2015 con 3 proyectos, 1 la web del cliente, 2 la api del lado del servidor y el WS. Hay posibilidad de publicar la solucion completa en IIS? de no poder publicarse asi, como seria? Gracias!

Configure Netbeans to use Symfony - OSX

Wed, 08/16/2017 - 14:40

Symfony does not offer an installer package to be downloaded anymore, so I can't point an installer when Netbeans asks me to.

I am working with OSX Sierra. Also coudln't run mysql directly, so I installed MAMP.

That's what I need: run Symfony from Netbeans, using PHP and Mysql from MAMP.

Why do my ViewPager always show the next page?

Wed, 08/16/2017 - 14:40

Below is my source code. I can show the content of Fragment, but it always show the next page data (the original position + 1). I tried to print the position of getItem and it printed the correct position + 2 additional items for the previous and next page offset. Then, when I slide right, it will show a blank page. In my log, I can see it printed (the original position + 2), but I saw nothing. But, when I slide back, it show the content of (the original position + 2).

I think the problem is with the ViewPager, not with my PagerAdapter because I can show the page, I can slide it, and from my log, it print the correct item.

activity_data.xml

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="wrap_content" />

DataPagerAdapter.java

public class DataPagerAdapter extends FragmentStatePagerAdapter { private List<Data> data; public ItemPagerAdapter(FragmentManager fm, List<Data> data) { super(fm); this.data = data; } @Override public Fragment getItem(int position) { return DataFragment.newInstance(data.get(position)); } @Override public int getCount() { return data.size(); } }

ActivityData.java

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_data); setDisplayHomeAsUpEnabled(true); ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); viewPager.setAdapter(new DataPagerAdapter(getSupportFragmentManager(), data)); viewPager.setCurrentItem(3); }

Python Code for Abaqus

Wed, 08/16/2017 - 14:40

I am new to coding and trying to work with Python specifically for Abaqus. I have to implement certain formulation to compute stress values in a certain way and modify the odb file and store the recently computed stress values at the Integration Point of the elements.

I obtain the values of stresses as a list of values. Attached is a link to an answer which deals with exact same Kind of Problem: How to update nodal value of Abaqus odb file using python script? Also I checked in Abaqus Scripting reference guide and they have implemented almost the same Thing. Now my specific question is that,in the attached answer it has been pointed out that in "field.addData()" I am supposed to add my data(which is a list in my case).However when I try to do it,I get an error stating that it is a keyword error. Is it not allowed to supply a list as my data? Is there a specific data structure that Needs to be implemented ? Thanks!

Selected Option in dropdownlisfor not work

Wed, 08/16/2017 - 14:40

I have this model

public string Rol { get; set; } [Display(Name = "Perfil:")] [Required(ErrorMessage = "Seleccione un perfil para el usuario")] public static IEnumerable<SelectListItem> Roles { get { yield return new SelectListItem { Text = "Administrador", Value = "1" }; yield return new SelectListItem { Text = "Consultor", Value = "2" }; } } public int IdProject { get; set; } public string ProjectDesc { get; set; }

my controller:

public ActionResult _Update(string user, string name, string rol) { var obj = new AdministracionDto { User = user, Name = name, Rol = "2" }; // ViewBag.Roles1 = new SelectList(AdministracionDto.Roles, "Id", "Name"); return PartialView("_Update", obj); }

the partial view is a Pop Up, where the user click on link "Actualizar" of the view. and shows the popup

@using (Html.BeginForm("Update", "Login", FormMethod.Post, new { style = register", style = "height: 34px;" } }) <b>@Html.LabelFor(model => model.Name)</b> @Html.EditorFor(model => model.Name, new { htmlAttributes = new { PlaceHolder = "Ingrese nombre", @required = "required", @class = "input-register", style = "height: 34px;" } }) @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" }) <b>@Html.LabelFor(model => model.Rol)</b> @Html.DropDownListFor(m => m.Rol, AdministracionDto.Roles, "--Seleccione Perfil", new { @class = "form-control", @required = "required" }) @Html.ValidationMessageFor(model => model.Rol, "", new { @class = "text- danger" }) </div> <div class="clearfix"> <button type="button"class="close" data- dismiss="modal">Cancelar</button> <button type="submit" class="signupbtn" value="Create">Actualizar</button> </div>

}

but my problem is: that when goes to the actionresult _Update. I lose the selected value in the dropdownlisFor . but I need establish the value in "2.

Cordova video capture - how can I save file it out to server?

Wed, 08/16/2017 - 14:36

I'm successfully capturing a video stream via Cordova Video Capture, and the file is saved to something like file:///storage/emulated/....

However I'm stuck on how to save the file out to a remote server by sending its source code (blob data?)

What I've tried (path is the path to the saved video.)

Attempt 1

This does return the file, but only as garbled text. If I set dataType: 'blob', the callback never fires.

Dom7.ajax({ //<-- I'm using Framework7, hence the Dom7 DOM/AJAX library url: path, success: function(file_content) { } });

Attempt 2 - native AJAX - success callback never fires

var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if (this.readyState == 4 && this.status == 200) { console.log('AJAX', typeof this.response); } } xhr.open('GET', path); xhr.responseType = 'blob'; xhr.send();

Attempt 3 - via Cordova File plugin

window.resolveLocalFileSystemURL( cordova.file.applicationStorageDirectory, function(dir) { console.log('got app storage dir', dir); //<-- this fires dir.getFile(path, {create:false}, function(fileEntry) { console.log('got file!!!'); //<-- this doesn't fileEntry.file(function(file) { var reader = new FileReader(); reader.onloadend = function(e) { console.log(e); }; reader.readAsDataURL(file); }); }); }, function(err) {alert('didn\'t get it'); console.log(err); } );

...but since the file doesn't live in application storage (or its external application storage counterpart) this is academic.

This does return the file, but as text. How can I get it / convert it to a format I can send to a remote server over CORS?

To be clear, it's not the CORS part I'm asking about, just the getting of the video file content in a format suitable for sending.

Python: change parent class property from child class

Wed, 08/16/2017 - 14:32

In python (v3.6.1), I am looking to write a class like this:

class SecondClass(FirstClass): property = "custom" print(SecondClass.name) #=> "john" class SecondClass(FirstClass): property = "notcustom" print(SecondClass.name) #=> "steve"

I have tried to set up the FirstClass class like this:

class FirstClass: if property == "custom": name = "john" else: name = "steve"

But I don't seem to be able to edit the property of the FirstClass from the SecondClass.

Is this possible?

Swagger re-use definition but make attribute required?

Wed, 08/16/2017 - 14:28

I have a definition used in multiple places throughout an API:

definitions: Camera: type: object properties: ip: description: device IP address type: string name: description: name of camera type: string # additional attributes ...

I want to make IP required on the endpoint where a new object is created but not where it is updated. Here is what I'm trying, see last 2 lines:

parameters: - name: deviceId in: path description: get a device required: true type: integer format: int64 - name: body in: body required: true schema: $ref: '#/definitions/Camera' required: - ip

The above returns the warning: Extra JSON Reference properties will be ignored: required

Is it possible to re-use a definition, having an attribute required on one endpoint but not another?

Thread::Join vs detach

Wed, 08/16/2017 - 14:27

Why should I using std::thread::join and then wait until this thread has ended? I thougt the purpose of multithreading is, that I start more threads paralelly. Instead of join(), I also could call the function "normally", like foo(). So why is their join()? Isn't the only thing I need detach()?

How to open camera in android webview?

Wed, 08/16/2017 - 14:24

I have a web page that is opening in android webview. The requirement is to launch Camera directly on tapping file chooser.

I have written following code for selecting image:

<input id="files" type="file" name="images[]" multiple accept="image/*" capture="camera"/>

This works fine in chrome browser and opens camera for capturing image. But, when same page is called inside webview, it asks for choose from Camera, Gallery and similar apps.

How to make a C program that can read a data and copy some in a variable?

Wed, 08/16/2017 - 14:24

I'm a student, I am wondering... How can I make a program that can Get some data from my text file to a variable on my program and print them

Example:

(TEXT FILE:)

I,Ate,Cookies She,Drink,Coffee Tom,Wears,Pyjamas

(my code)

main() { FILE *fp=fileopen("c:\\textfile.txt","r"); char name[20],action[20],item[20]; prinf("Enter name: \n"); scanf("%s",&name); /* I dont Know what to do next */ }

I want it to be like this

if (name=nametxt) /*nametxt is the first line on the text file */ { printf("%s\n %s\n %s\n",name,action,item); }

the output will be like this if name=I

Enter name: I I Eat Cookies

if name=She

Enter name: She She Drinks Coffee

if name=Tom

Enter Name: Tom Wears Pyjamas

A help will satisfy my curiosity thanks in advance

Angualr 4x label for doesn't work

Wed, 08/16/2017 - 14:21

I am using angularjs 4.3.4 via angular CLI which is working fine. However I am getting strange issue. I had created a custom component with checkbox and label. the id and for property value comes from custom tag attribute. When I see the html code I can see that it has been generated the id and for attribute as expected. But clicking on label doesn't check or uncheck the checkbox. Here is my code:

input.component.html (Option 1)

<div class="form-group input-group"> <span> <input id="{{id}}" type="checkbox" placeholder="Name"/> <label for="{{id}}">{{title}}</label> </span> </div>

input.component.html (Option 2)

<div class="form-group input-group"> <span> <input bind.id="id" type="checkbox" placeholder="Name"/> <label bind.for="id">{{title}}</label> </span> </div>

input.component.html (Option 3)

<div class="form-group input-group"> <span> <input [id]="id" type="checkbox" placeholder="Name"/> <label [for]="id">{{title}}</label> </span> </div>

input.component.html (Option 4)

<div class="form-group input-group"> <span> <input attr.id="id" type="checkbox" placeholder="Name"/> <label attr.for="id">{{title}}</label> </span> </div>

None of the above mentioned options are working.

input.component.ts

import { Component, OnInit, Input } from '@angular/core'; @Component({ selector: 'my-input', templateUrl: './input.component.html', styleUrls: ['./input.component.less'] }) export class InputComponent implements OnInit { @Input() title: string; @Input() id: string; constructor() { } ngOnInit() { } }

app.component.html

<my-input title="Testing" id="checkBox"></my-input>

Please help me how can I fix that?

Thanks

multiple unions ms access

Wed, 08/16/2017 - 14:20

I've been looking for an example online for multiple unions on a single table, only solution I found similar to the issue I am having is this thread.

This is the query i've built in MS ACCESS

SELECT chat_tb.tag_1 AS [tag_desc], Count(chat_tb.tag_1) AS [Count_of_tag] FROM chat_tb GROUP BY chat_tb.tag_1 UNION SELECT chat_tb.tag_2 AS [tag_desc], Count(chat_tb.tag_2) AS [Count_of_tag] FROM chat_tb GROUP BY chat_tb.tag_2 UNION SELECT chat_tb.tag_3 AS [tag_desc], Count(chat_tb.tag_3) AS [Count_of_tag] FROM chat_tb GROUP BY chat_tb.tag_3;

But I get the following error, Im assuming since it is linking to MySQL table I cannot perform the union as the current syntax, can anyone assist me in changing it to mysql format, thank you in advance!

View Error Message

Angular4 Web Worker application not displaying

Wed, 08/16/2017 - 14:12

I have a website that is heavy on CPU usage that I decide to port to web workers.

I have followed this step by step tutorial: https://medium.com/@enriqueoriol/angular-with-web-workers-step-by-step-dc11d5872135

I have cloned this rep and made it seem identical: https://github.com/kaikcreator/angular-cli-web-worker

I encountered a few issues where the document was not defined or the window. In these cases I tested on the github rep if its a problem with or with the module and it was the module so I removed them.

Basically I have no error right now and the page simply doesn't display:

I assume it is because Angular has no way to access the window object so it can't inject the code.

My app.module complained about lacking platform location providers so I added:

import { WORKER_APP_LOCATION_PROVIDERS } from '@angular/platform-webworker';

while replacing the BrowserModule with the WorkerAppModule

Here is my main.ts

import { enableProdMode } from '@angular/core'; import { bootstrapWorkerUi } from '@angular/platform-webworker'; import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; if (environment.production) { enableProdMode(); } bootstrapWorkerUi('webworker.bundle.js');

My workerLoader.ts

import 'polyfills.ts'; import '@angular/core'; import '@angular/common'; import { platformWorkerAppDynamic } from '@angular/platform-webworker-dynamic'; import { AppModule } from './app/app.module'; platformWorkerAppDynamic().bootstrapModule(AppModule);

My webpack config is: https://gist.github.com/misha130/9a21e1c08ca9e0bf79635dedc3279b2d

What could be the problem that stops it from rendering the page?

EDIT: After investigation this caused the problem and the usage of the router module causes the problem for me. How do I use PlatformLocations and RouterModule and Web Workers?

Listing Products List when clicking the checkbox which comes from Database

Wed, 08/16/2017 - 14:10

My question is about listing product list. I have a category list I've created with checkbox. When clicking the checkbox, the product list must be listed according checkbox. I tried to do with json and ajax,but I didn't manage to do. Are there are any ideas ?

example

Is there a way to extract information about my Google Drive like in a JSON file?

Wed, 08/16/2017 - 13:04

I was wondering if there is a way to extract information about a Google Drive folder to see how the access management is done, which users are granted with specific entitlements and so on. I read that Google storage provides this in a JSON file.

Using the right python package to achieve result

Wed, 08/16/2017 - 12:31

I have a fixed width text file that I must convert to a .csv where all numbers have to be converted to integers (no commas, dollar signs, quotes, etc). I have currently parsed the text file using plain python, but when utilizing the right package I seem to be at an impasse.

With csv, I can use writer.writerows in place of my print statement to write the output into my csv file, but the problem is that I have more columns (such as the date and time) that I must add after these rows that I cannot seem to do with csv. I also cannot seem to find a way to translate the blank columns in my text document to blank columns in output. csv seems to write in order.

I was reading the documentation on xlsxwriter and I see how you can write to individual columns with a set formatting, but I am unsure if it would work with my .csv requirement

My input text has a series of random groupings throughout the 50k line document but follows the below format

* START ******************************************************************************************************************** START * * START ******************************************************************************************************************** START * * START ******************************************************************************************************************** START * 1-------------------- 1ANTECR09 CHEK DPCK_R_009 TRANSIT EXTRACT SUB-SYSTEM CURRENT DATE = 08/03/2017 JOURNAL REPORT PAGE 1 PROCESS DATE = ID = 022000046-MNT FILE HEADER = H080320171115 +____________________________________________________________________________________________________________________________________ R T SEQUENCE CR BT A RSN ITEM ITEM CHN USER REASO NBR NBR OR PIC NBR DB NBR NBR COD AMOUNT SERIAL IND .......FIELD.. DESCR 5,556 01 7450282689 C 538196640 9835177743 15 $9,064.81 00 CREDIT 5,557 01 7450282690 D 031301422 362313705 38 $592.35 43431 DR CR 5,558 01 7450282691 D 021309379 601298839 38 $1,491.04 44896 DR CR 5,559 01 7450282692 D 071108834 176885 38 $6,688.00 1454 DR CR 5,560 01 7450282693 D 031309123 1390001566241 38 $293.42 6878 DR CR

My code currently parses this document, pulls the date, time, and prints only the lines where the sequence number starts with 42 and the CR is "C"

lines = [] a = 'PRINT DATE:' b = 'ARCHIVE' c = 'PRINT TIME:' with open(r'textfile.txt') as in_file: for line in in_file: values = line.split() if 'PRINT DATE:' in line: dtevalue = line.split(a,1)[-1].split(b)[0] lines.append(dtevalue) elif 'PRINT TIME:' in line: timevalue = line.split(c,1)[-1].split(b)[0] lines.append(timevalue) elif (len(values) >= 4 and values[3] == 'C' and len(values[2]) >= 2 and values[2][:2] == '41'): print(line) print (lines[0]) print (lines[1])

What would be the cleanest way to achieve this result, and am I headed in the right direction by writing out the parsing first or should I have just done everything within a package first? Any help is appreciated

Edit: the header block (between 1----------, and +___________) is repeated throughout the document, as well as different sized groupings separated by -------

-------------------- 34,615 207 4100223726 C 538196620 9866597322 10 $645.49 00 CREDIT 34,616 207 4100223727 D 022000046 8891636675 31 $645.49 111583 DR ON- -------------------- 34,617 208 4100223728 C 538196620 11701364 10 $756.19 00 CREDIT 34,618 208 4100223729 D 071923828 00 54 $305.31 11384597 BAD AC 34,619 208 4100223730 D 071923828 35110011 30 $450.88 10913052 6 DR SEL --------------------

Pages