Sunday 26 July 2020

Email manager setup.exe 64bit

How to make setup.exe 64bit

https://www.youtube.com/watch?v=2jdH85teO5Q

Download HxD hex editor
https://download.cnet.com/HxD-Hex-Editor/3000-2352_4-10891068.html

How to create setup.exe in VS 2017



Errors
Unable to find manifest signing certificate in the certificate store
>> Just untick the signing,
https://stackoverflow.com/questions/11957295/unable-to-find-manifest-signing-certificate-in-the-certificate-store-even-wh

https://stackoverflow.com/questions/4517440/why-am-i-getting-unable-to-find-manifest-signing-certificate-in-the-certificate/8117025


Outlook.mailitem is not found
Reference >> Assesmlies >>
Microsoft.office.interop.outlook 15.0

Typ 'PDDocument' is not defined
Below 3 files deleted & re-referenced:

  • PDFBox-0.7.3
  • IKVM.GNU.Classpath
  • IKVM.Runtime




Ignored


Above needs fix.

App.config had the following.
      <add name="AccessConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=M:\db2000.mdb;User Id=admin;Password=;" />

Current Jet.OLEDB does not work in 64bit:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/cfb9efe8-4de2-40b6-b817-553c91b9f9c6/the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine?forum=csharpgeneral

1. You need to use ACE.OLEDB in App.config
    <add name="AccessConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\db2000.mdb;Persist Security Info=False;" />

2. You need to install Access database engine 64bit.



Access connection string
https://www.connectionstrings.com/access/




If you try to install different version (64bit) of Access Database Engine on top of MS office 365 (32bit):





System.TypeLoadException: 'Could not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly

https://stackoverflow.com/questions/5666265/adodbcould-not-load-type-adodb-fieldstointernalfieldsmarshaler-from-assembly


The INSERT INTO statement contains the following unknown field name: 'Comments'
 INSERT INTO tblItemsHistory (WorkOrderID, OrderVersion, ItemCode,Description,Quantity,Location,SOC, QuantityInt, Comments, CancelledItem)  VALUES ('103225189/70',  '1',  'KIT03',  'KITCHEN REPL ( 3 BED)',  '1.000 EA',  'Kitchen',  'KIT03', 1,  'Kitchen Replacement 600mm Benchtop 3 Bedroom tenant happy for pantry to go in lounge room
',False)


  • tblItem
  • tblItemHistory 

required fields:

  • Comments
  • CancelledItem



TEST

- Test if current Email Manager (32bit) works in my machine (64bit) office (32bit)
>> works

- Test if new Email Manager (64bit) works in my machine (64bit) office (64bit)
>> works


To chase up with Sonya

- Can you show me email server? (it's hard to read email from Outlook because version changes every time, and settings change. If I can read email directly from email server, it will be better)



Friday 24 July 2020

How to generate SSL Certificate


  1. go to winhost
  2. SSL Manager
  3. Click green button, 'Generate a new CSR'. This will generate CSR (Certificate s? Request)
  4. Copy CSR

  1. Go to namecheap.com
  2. Product List
  3. Click 'Issue new CSR button'
  4. Paste CSR
  5. Generate
  6. DCV(Domain Control Validation) email is sent to podmaster@dolsoft.com.au

  1. Go to winhost >> Email
  2. Click link in the email
  3. Paste the password given in the email
  4. They will send you another email with attached SSL Certificate.zip
  5. Send the zip file to winhost to install.

How can I check if installed properly?
Winhost >> SSL Cert button on top
Namecheap >> Domain list >> Postive SSL Certificate >> it shows 'Active' (not under progress)

Thursday 23 July 2020

Email Manager 20101110 V6


How to install Email Manager. 
Updated 2020-07-23

1. Download the latest zip file

2. Run setup.exe

3. Create folder C:\EmailManager and copy some setting files in there.

4. Make sure M drive is connected to have db2000.mdb.


Refer below when errors:

- Logged in the new computer and confirmed Access 2019 version
Microsoft 365 MSO (16.0.13) 64-bit

- Fixed Access 64 bit issue

- Changed Non-Unicode system locale to ‘Korean’ to fix Access ActiveX etc error. 

- Changed Y drive to M drive to make EmailManager work

- Installed EmailManager on PC (shortcut is pinned in Start button).

- Created C:\EmailManager folder to make EmailManager work

- Changed PC Date/Time to AU to avoid EmailManager error.
Region >> Formats >> English (Australia)
Region >> Location >> Australia

- I ran Email Manager and confirmed working, but with no work order emails to process.



Monday 1 June 2020

Lumen sorting

You cannot sort workorders by function definition, eg, priority



Sunday 31 May 2020

TimeStamp interesting

I had trouble in saving date into database and read it again.

received date: DateTime
collected date: TimeZone








In summary

  • I created all columns as TimeZone.
  • When read in js side, just do substring(0,10) to remove 10:00 hour time..
  • Show in chrome date type.
  • When saving, rely on whatever API does, and let it save with 10:00 hour time.


MySQL check current time zone (https://stackoverflow.com/questions/2934258/how-do-i-get-the-current-time-zone-of-mysql) shows below. And it seems my MYSQL follows my local machine time stamp - AEST.



So far so good.
The problem happens when reading the date value again in to javascript.





When reading the database value '2020-06-01 10:00 AEST' into API and into js, in some how, it becomes '2020-06-01 00:00 AEST'.

This leads js display incorrect giving 31/5 not 1/6.



The resolutions is, whatever date you have in javascript, you ignore the timezone, and just convert the value (2020-06-01 00:00 AEST) into string.



Javascript fun fact

Datetime is funny in java script. new Date(null) is 1970-1-1.







Friday 29 May 2020

Lumen - insert datetime

At one stage, I couldn't insert a record into table with datetime format.
I know MySQL supports DateTime and TimeStamp for date formats. I tried both of them, error still was same.




Error message was below.

Invalid datetime format: 1292 Incorrect datetime value: '2020-05-29T12:09:52.000Z' for column 'dt_date_received'.

I knew that it was API error. js gave current time as 'new Date()'. And API received it as string. And it had timezone information from the js date (you cannot remove this timezone information because js date is just integer value basically in some way).

Imagine you run SQL command below. You will get exactly the same error as above.



I couldn't figure out, so I tried API Test, which I made for simple CRUD test. It didn't work here either. In below, the first two 'ggg' was inserted into store, but not database. So it didn't show id.



Then I googled how to edit $request data in Laravel. And I found below link!
https://stackoverflow.com/questions/36812476/how-to-change-value-of-a-request-parameter-in-laravel



You can edit the $request data before inserting into database.


The data was inserted as expected!
Further, I replaced the given dt_date_received with replacing 'T' and 'Z'.




It was working.

Actually all this errors happened because I had to include 'dt_date_received' into 'fillable' to update/create record with that column information.



You need this to create record with some timestamp value.


Imagine you omit the line 25 in the above picture. Then it becomes you try below SQL query.


And in this case, because 'dt_date_received' is 'not null' column, you will have another error.
'dt_date'_received' cannot be null.


In Summary,

  1. If insert is not working, go for API Test for simple testing
  2. Read error message
  3. Try API code change to resolve the issue.


Sunday 10 May 2020

EmberTable Debugging

At one stage, ember table showed nothing. Page frozen.

Columns was defined.
this.columns = [
  {
    name: `ID`,    valuePath: `id`  },  {
    name: `Name`,    valuePath: `full_name`  },  {
    name: `VIP`,    valuePath: `vip`  },  {
    name: `Problem`,    valuePath: `problem`  },  {
    name: `Received Date`,    valuePath: `dt_date_received`  },  {
    name: `Quoted Date`,    valuePath: `dt_date_quoted`  },  {
    name: `Prom. Completion Date`,    valuePath: `dt_date_completion`  },  {
    name: `Status`,    valuePath: `status`  },  // {  //   name: `Status Icons`,  //   valuePath: `status_icons`,  //   cellComponent: `custom-cell`,  //   color: `orange`  // },  {
    name: `Priority`,    valuePath: `priority`  }
];

ROws was defined
  get rowsForSortingNFiltering() {


    console.log('model.length', this.model[1].length);
    var rowsFiltered = this.model[1];    return rowsFiltered;
  }

Model was returned as below.
model() {
  let columns = this.dataGenerator.columns;  let filter = this.dataGenerator.workorderFilter;
  /* Whenever looping forever, 1. comment below >> 2. open inspect >> 3.uncomment */  return this.store.findAll('workorder').then(function(workOrders){
    debugger;
    // show some values    if (workOrders.length > 0) {
      console.log("1st workorder:" , workOrders.objectAt(0).id, workOrders.objectAt(0).first_name);    }
    let model = [columns, workOrders, filter];    return model;  });

}

Whenever page was frozen, I had to comment above model. Refresh page. Open Inspector. Uncomment to check the data again.


I tried to removing the hbs table part. >> working, page not frozen
{{!-- workorder list --}}  <div class='demo-container'>      <EmberTable as |t|>          <t.head @columns={{columnsForSorting}}
                  @sorts={{sorts}}
                  @onUpdateSorts={{action (mut sorts)}}
                  @widthConstraint='gte-container'                  @fillMode='first-column'                  as |h|>
              <h.row as |r|>                  <r.cell as |columnValue columnMeta|>                    {{#if showSortIndicator}}
                        <EmberTh::SortIndicator @columnMeta={{columnMeta}} />                    {{/if}}
                    {{columnValue.name}}
                    {{#if showResizeHandle}}
                        <EmberTh::ResizeHandle @columnMeta={{columnMeta}} />                    {{/if}}
                  </r.cell>              </h.row>          </t.head>
          <t.body @rows={{rowsForSortingNFiltering}} as |b|>              <b.row as |r|>                  <r.cell as |cell column|>                    {{#if column.cellComponent}}
                      {{#component column.cellComponent color=column.color statusIcons=cell}}
                      {{!-- {{cell}} --}}                      {{/component}}
                    {{else if (eq column.name "ID")}}
                        <a href="#" class="nav-button">{{cell}}</a>                    {{else}}
                      {{cell}}
                    {{/if}}
                  </r.cell>              </b.row>          </t.body>
      </EmberTable>  </div>

And tried to put each data without EmberTable >> working.
{{#each rowsForSortingNFiltering as |row| }}
  <div>{{row.id}} {{row.full_name}}  {{row.vip}}  {{row.problem}} {{row.dt_date_received}} {{row.dt_date_quoted}} {{row.dt_date_completion}} {{row.status}} {{row.priority}}</div>{{/each}}


Tried put simplest EmberTable >> not working. frozen again.
<EmberTable as |t|>    <t.head @columns={{columnsForSorting}} />    <t.body @rows={{rowsForSortingNFiltering}} /></EmberTable>


Now tried to return rows matching column data only. No extra attribute is defined. New Rows was defined.

  get rowsForSortingNFiltering() {


    console.log('model.length', this.model[1].length);
    var rows = this.model[1];

    var rowsFiltered = [];    rows.forEach(function (elemRaw) {
      var elem = { id: elemRaw.id, full_name: elemRaw.full_name};      rowsFiltered.push(elem);    })


    return rowsFiltered;
  } 

And it finally worked! EmberTable requires exactly same valuePath of columns and rows. Columns can be more valuePath than rows. The missing valuePath will show empty. But rows cannot have more attribute than columns. EmberTable stops working!



Saturday 9 May 2020

Lumen model extra attributes

Lumen php return extra model attribute

Laravel talks about the multators and asscessors, but I couldn't get it until I found the below link. Good one!

https://stackoverflow.com/questions/17232714/add-a-custom-attribute-to-a-laravel-eloquent-model-on-load



https://laravel.com/docs/7.x/eloquent-mutators

So, you can get "full_name" when it is not in the table column.


INstall Lumen on Ubuntu local machine

https://auth0.com/blog/developing-restful-apis-with-lumen/

Start Lumen installation from above site. Lumen home page was hopeless.
Install composer correctly. TRy to read how to install.

When I just copied folder from my Mac into Ubuntu and run local:8000 it showed below error.

Below was unnecessary?
I found that it was not actually MySQL user issue. But wrong id/password in the .env file. I must have set it at some point. Change it with correct user detail, and voila!


Next day, I had this error.



FRom google, I found the issue is symfony version, and I updated following.
https://stackoverflow.com/questions/58975559/symfony-component-debug-exception-fatalerrorexception-laravel-error

But I still had error below.

matthew@SYDNEY-D-003:~/work2/scr-webservice$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - This package requires php ^7.2 but your PHP version (7.1.33) does not satisfy that requirement.
  Problem 2
    - laravel/lumen-framework v6.3.5 requires php ^7.2 -> your PHP version (7.1.33) does not satisfy that requirement.
    - laravel/lumen-framework v6.3.4 requires php ^7.2 -> your PHP version (7.1.33) does not satisfy that requirement.
    - laravel/lumen-framework v6.3.3 requires php ^7.2 -> your PHP version (7.1.33) does not satisfy that requirement.
    - laravel/lumen-framework v6.3.2 requires php ^7.2 -> your PHP version (7.1.33) does not satisfy that requirement.


I found that LUmen requires Php7.2 and I have 7.1 in my ubuntu. I decided to update my php following below url.

https://www.liquidweb.com/kb/install-php-7-2-ubuntu-16-04/


But even after installing 7.2, it showed current version as 7.1. I don't know why. Because I followed above URL, my current apache is using Php7.2





Actually my issue was I was looking at /api/authors not /api/workorders. I don't know what to do now .asl;djf;sjadflks;jadlfj


Friday 8 May 2020

Setup MySQL on UBUNTU

MySQL Workbench was not the best tool in Ubuntu
- Ctrl-ENter sometimes ran previous query not current selected query
- Screen too big
- MOved to PHpSTorm


Open local host
Database >> +Datasource >> MySQL


Loading DOcument - MySQL Workbench

<Where is file>
Dropbox >> TechDoc_Cascade >> AWS_all >> sql
I don't know why I put it there.

<files>
migration1.sql
migtration2.sql


<how to import excel file>

1. COnvert customer's .xlsx file into .csv >> so much convenient later.

2. MySQL WOrkbench >> Server >> Data IMport >> select .csv file. (x)
2. Choose schema, eg, matthew_schema >> Tables >> right clikc >> 'Table Data IMport' (o)

3. Start import
4. Review 'text' data (date data should be exported to text data first for more peaceful import)
5. Keep the table name as raw, eg, JObLIst_import. We will keep this as reference, and create a new table any way.

6. ONce import is finished apply migration1.sql


<MySQL Workbench>
Edit >> Preference >> SQL Editor >> untic 'Safe UPdtes'
SQL Editor >> SQL Execution >> 'Limit ROws' >> 10,000


<Change root user password>
This site messed me up:
https://www.a2hosting.com/kb/developer-corner/mysql/reset-mysql-root-password

This site saved me:
https://stackoverflow.com/questions/30692812/mysql-user-db-does-not-have-password-columns-installing-mysql-on-osx

Below code of the 1st url seems to be old one.

matthew@SYDNEY-D-003:~/work2/$ mkdir -p /var/run/mysqld
mkdir: cannot create directory ‘/var/run/mysqld’: Permission denied
matthew@SYDNEY-D-003:~/work2/$ sudo mkdir -p /var/run/mysqld
matthew@SYDNEY-D-003:~/work2/$ chown mysql:mysql /var/run/mysqld
chown: changing ownership of '/var/run/mysqld': Operation not permitted
matthew@SYDNEY-D-003:~/work2/$ sudo chown mysql:mysql /var/run/mysqld
matthew@SYDNEY-D-003:~/work2/$ sudo mysqld_safe --skip-grant-tables &
[2] 19349
matthew@SYDNEY-D-003:~/work2/$ 2020-05-09T06:27:16.694377Z mysqld_safe Logging to syslog.
2020-05-09T06:27:16.698323Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2020-05-09T06:27:16.728153Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

<MySQL errors>
Access denied for user 'user'@'localhost' (using password: YES) (SQL: select * from `authors`)
>> create user

mysql seems no password required.
if 'mysql -u root -p' doesn't work with you root password you remeber, just type in 'mysql'.

 Even when I typed in correct password, it was returning error message.
ON the contrary, when I just typed in 'mysql', voila!!

 You could even update root user's password.





Monday 27 April 2020

Simplest CRUD - Ember web service (Web API) tutorial

Ember adapters
https://guides.emberjs.com/v3.15.0/models/customizing-adapters/

Serializer
https://guides.emberjs.com/v3.15.0/models/customizing-serializers/

The tutorial
https://medium.com/ember-ish/the-simplest-possible-ember-data-crud-16eacee33ae6

I am following the above tutorial...(27/4/20)

API + db all working well.


CORS issue was also fixed by using middleware.

Enable CORS in Lumen




But I still had issue in GET operation


The lady author says,

"If your POST request failed and this surprises you, a few different things could be wrong:"

I guess the issue is the json format.
https://guides.emberjs.com/v3.15.0/models/customizing-serializers/

My guess was right. Ember serializer default is JsonWAPISerializer. You have to change it to JsonSerializer to work with Lumen's default json formats without 'data' or 'attribute' name conventions.



Now /api/boardgames/1 is working.





But insert is still not working. Why?


Amazingly, the issue was in database. The sample Lumen API server code (not this tutorial) I downloaded from below required updated_at, created_at in each table. After updating the database, POST call to create new boardgame worked fine!!

Lumen tutorial:
https://auth0.com/blog/developing-restful-apis-with-lumen/




Now insert is working




16/5/20. At one stage, insert stopped working again, this time with CORS issue again.  My table had two date columns, middle ware was there (GET was still working). I found suspecious error in Lumen console. It seems my PHP in LInux(7.1) is not good enough for SImpony (lumen insert operation). The same code was working on my mac (php 7.2) fine?





 Why Delete not working?


I know it is an API error while returning the result. because when I refreshed the page, the record was deleted already. And it didn't show any error while debugging. Debugging was a bit tricky to find where to see.


Web API returns string and it was not a correct JSON format. You have to implement Ember serializer.

public function delete($id)
{
BoardGame::findOrFail($id)->delete();
return response('Deleted Successfully', 200);
}

As soon as I change Web API delete as below, Ember site started working.

https://stackoverflow.com/questions/28387693/ember-promise-destroyrecord-then-failing-on-successful-request



public function delete($id)
{
BoardGame::findOrFail($id)->delete();
//return response('Deleted Successfully', 200);
//below is working as well. but you don't seem to get $newContent.
// $newContent = [
// 'data' => 'deleted'
// ];
// return response()->json($newContent, 200);
//https://stackoverflow.com/questions/28387693/ember-promise-destroyrecord-then-failing-on-successful-request
return response('Deleted Successfully', 204);
}



Why update not working?



I found that Ember translates updates as 'PATCH' operation.

  • I tried PATCH in postman it didn't work. 
  • Also PUT operation had to use www-encode option (?). 
  • There must be something special about PUT operation. 
  • Google search 'ember use PUT instead of PATCH'. Then the below link, the 1st solution worked for me not the second. 
  • So you have to convert PATCH to PUT operation with below code
  • app/adapters/application.js


https://github.com/emberjs/data/issues/3870

export default DS.JSONAPIAdapter.extend({
host: 'http://localhost:8000/api',
updateRecord: function (store, type, snapshot) {
var data = {};
var serializer = store.serializerFor(type.modelName);
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
var id = snapshot.id;
var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
return this.ajax(url, 'PUT', { data: data });
}
})

Summary

Make sure you put model() hook in the router not controller js.

Here is the completed Ember web API, the simplest one:
https://github.com/oneman93/ember-simplest-crud


I like to share my web service API as well, but because I did update in there for my personal stuff, I cannot share it. However, the Lumen tutorial above will be enough to start up a web service server.

-----------

Webservice other urls

youtube about ember data
https://www.youtube.com/watch?v=ljLxZw-XStw

mirage tutorial
https://guides.emberjs.com/v3.4.0/tutorial/ember-data/