Wednesday, June 8, 2022

AWS EC2 - SSH locked with UFW

Need to update the instance's user data:

1. Stop the instance

2. Right click (windows) or ctrl + click (Mac) on the instance to open a context menu, then go to Instance Settings -> Edit User Data or select the instance and go to Actions -> Instance Settings -> Edit User Data

If you're still on the old AWS console, select the instance, go to Actions -> Instance Settings -> View/Change User Data

3. Past following in: 


ontent-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
ufw disable
iptables -L
iptables -F

--//


4. Once added, restart the instance and ssh should work. 

The user-data disables ufw if enabled and also flushes any iptable rules blocking ssh access.

Friday, March 18, 2022

Nginx Virtual Hosts on Ubuntu

Nginx Virtual Hosts on Ubuntu


1. Create Root Directory

sudo mkdir -p /var/www/login.jordan.app/html

sudo chown -R $USER:$USER /var/www/login.jordan.app/html

sudo chmod -R 755 /var/www/login.jordan.app


2. Creating Sample Pages

vi /var/www/login.jordan.app/html/index.html

<html>
    <head>
        <title>Welcome to login.jordan.app!</title>
    </head>
    <body>
        <h1>Success! The jordan.app server block is working!</h1>
    </body>
</html>


3. Create Block Files

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/login.jordan.app

sudo vi /etc/nginx/sites-available/login.jordan.app

server {
        listen 80;
        listen [::]:80;

        root /var/www/login.jordan.app/html;
        index index.html index.htm index.nginx-debian.html;

        server_name jordan.app www.jordan.app login.jordan.app;

        location / {
                try_files $uri $uri/ =404;
        }
}

grep -R default_server /etc/nginx/sites-enabled/


4. Enabling Server Block

sudo ln -s /etc/nginx/sites-available/login.jordan.app /etc/nginx/sites-enabled/


5. Modify config file

sudo vi /etc/nginx/nginx.conf

Remove the # symbol to uncomment

server_names_hash_bucket_size 64;
    
sudo nginx -t
    

6. Restart 

sudo systemctl restart nginx
    
    
7. Modify host file 

sudo vi /etc/hosts
    
3.104.250.177 jordan.app www.jordan.app login.jordan.app


Friday, July 24, 2020

Weblogic 10.3.6 Installer Insufficient Disk Space

Weblogic 10.3.6 Installer fails with the insufficient disk space issue please use one of the following command to ignore disk space detection:


java -Dos.name=unix -jar wls1035_generic.jar

or

java -Xmx1024M -Dspace.detection=false -jar wls1035_generic.jar


Thursday, April 30, 2020

Disable Directory Listing Apache2

Edit the following file:

/etc/apache2/apache2.conf

Remove 'Indexes' from default root directory setting:

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

Updated apache2.conf file:

<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>

Restart the apache2 server instance.

Thursday, March 5, 2020

SdkMan CLI

SDKMAN (Software Development Kit Manager CLI) is a tool for managing parallel Versions of multiple Software Development Kits on any Unix based system. It provides a convenient command line interface for installing, switching, removing and listing Candidates.

Installation:

 #curl -s "https://get.sdkman.io" | bash

 #source "$HOME/.sdkman/bin/sdkman-init.sh"

Check Version:

 #sdk versiokn

Development Kits
    Install:

     #sdk list <software> 
     #sdk list java

     #sdk install java 7.0.181-zulu
     #sdk install java 11.0.6.j9-adpt

     The installation could be find in: 
        <user.home>/.sdkman/candidates/

    Uninstall:
      #sdk uninstall java 7.0.181-zulu 
      
    User Version:
       #sdk use java 7.0.181-zulu 
      
    Default Version:
       #sdk default java 7.0.181-zulu 
    
    View Current Versions:
       #sdk current
    
    Upgrade Version:
       #sdk upgrade java
       #sdk upgrade
    
 for more reference http://sdkman.io


Thursday, January 2, 2020

Default Web Server on Mac

The web server can be started on my in any directory through the following command:

# python -m SimpleHTTPServer 8000

(port number can be changed) 

or the default apache server can also be started through: 

# sudo apachectl start

The default localhost folder located here: /Library/WebServer/Documents or as per
configuration in apache2 config files.

Default apache is installed in /etc/apache2/ with all
its configuration files (httpd.conf).

Sunday, December 1, 2019

Docker


1. docker container can be find / downloaded from docker hub / docker store.

    http://hub.docker.com
 
    i.e
        $docker run ansible
        $docker run mogodb
        $docker run redis
        $docker run nodejs
     
2. Docker have two addition
    i. Community Edition
    ii. Enterprise Edition
 
3. Community Edition are availble for mac/windows/cloud (AWS)

4. Install docker desktop for windows / mac from http://docs.docker.com/install

5.  It will be eaiser to install docker through convenience script, instruction must  be found on http://docs.docker.com/install

6. Download images/container from http://hub.docker.com

7. To test visit the hub.docker and search for whalesay image to test the docker installation.

 $sudo docker run docker/whalesay cowsay HelloWorld

 Docker will pull the image and runs it.

 8. Docker Command
    i. $docker run <<container-name>> : to run the image, the image will be downloaded if not available.
 
    ii. $docker ps : will list all the containers
             -a : show the status and other details
           
    iii. $docker stop <<container-name>>
 
    iv. $docker rm <<container-name>> : remove the installed docker.
 
    v. $docker images : list down the downloaded images.
 
    vi. $docker rmi <<image-name>> : to remove the downloaded image.
        a. Stop and delete all the dependent container to remove image.
     
    vii. $docker pull <<image-name>> : just to pull the image without running it.
 
    viii. $docker run ubuntu : to run the container
 
    ix. $docker ps -a : list down the running container.
 
    x. Why the containers are in Exited status?
        Containers are ment to run process / tasks /webserer / application server/database instance not operating system once the task / process is completed the container exists.
     
        $docker run ubuntu sleep 5 : the ubuntun imaghe will start and sleep for 5 seconds one the task is completed the ubuntu iamge will be in Existed.
     
    xi. $docker exec distracted_mcclintock cat /etc/hosts : execute command inside the container to display the file content.
 
    xii. Processes runs either on four ground / active mode.
        a. $docker run kodekloud/simple-webapp : Run the image on attached mode.
     
        b. $docker run -d kodekloud/simple-webapp : Run the image in detach mode (backgroundm ode).
 
        - $kdocker attach <<image-name>> / <<image-id>> : to connect the detach container run the following command

        - first five character of docker image id are enough to run any docker command.
     
    ix. $docker run redis : to run the latest redis server
        $docker run redis:4.0 : to run the older version redis use the tag, the tag can be used with any image.
     
    xx. The hub.docker.com listdown all the versions / tags for all the available images.
 
    xxi. $docker run -i my/simple-prompt-docker : where -i is for an interactive mode to receive command line input and pass as parameter in application.
         $docker run -it my/simple-prompt-docker : for more interactive mode where you will see the application asking for input and you need to type you value and application will process that input further.
       
    xxii. Port forwarding:
 
    $docker run my/webapp: to start the web application image, the webapp is running on 5000 port (i.e http://172.17.0.2:5000/). Every machine have default IP and only accessable from docker host and not accessable outside the host.
 
    $docker run -p 80:5000 my/webapp : Map the port to access docker webapp image instance running on 5000 port.
 
    - this way you can run multipule instance of application using different ports.
    i.e
      $docker run -p 8000:5000 my/webapp
      $docker run -p 9000:5000 my/webapp
   
      $docker run -p 3306:3306 mysql
      $docker run -p 8306:3306 mysql
      $docker run -p 9306:3306 mysql
   
      - all above host ports are forwarded to one post of docker image.
 
    xxiii. Volume Mapping
 
    i.e $docker run mysql
        $docker stop mysql
        $docker rm mysql
     
        Onec the container removed all the data inside mysql database will be removed as well to prevent this we need to map the mysql data files with host file path.
     
        $docker run -v /opt/datadir:/var/lib/mysql mysql
     
        one the container starts with volume mapping all the data will be stored in the host system. Removing the mysql container will not effect the stored data.
     
    xxiv. Inspect Container:
        $docker inspect <<container-name>> : will return the json contain the details about container.
     
    xxv. Container logs (Processing running in detach mode)
     
        $ docker logs <<container-name>>
     
    xxvi. Set Environment Variables:
        The environment varabiles can be used inside the application and to set those run the following command:
     
        $docker run -e APP_COLOR=blue myweb
        $docker run -e APP_COLOR=red myweb
        $docker run -e APP_COLOR=green myweb
     
        to view the envrionment variable of container use inspect command
     
        $docker inspect <<container-name>>
        You will find the list of ENV in config tag of josn returned by inspect command.
 
     
9. Free lab to prectise the lab and quiz http://kodekloud.com/p/docker-labs

10. Create your own docker image.
    - Task list
        i. Install OS (ubuntu)
        ii. Update apt repository
        iii. Install apt updates
        iv. Install the python and its dependencies
        v. Copy the source
        vi. Run the application
     
       
    - Process
        i. Create docker file 'Dockerfile' and put all the commands are you will execute on OS.
     
            i.e
            --------------------------------
            FROM Ubuntu

            RUN apt-get update
            RUN apt-get install python
            RUN pip install flask
            RUN pip install flask-mysql

            COPY ./opt/source-code

            ENTRYPOINT FLASK_APP=/opt/source-code/app.py flask run
            ----------------------------------
         
            - In the above file, everything on left (i.e FORM, RUN, COPY) are instruction and text on the right side are Argument.
         
            -FROM Ubuntu: deifne the base OS required for docker image.

        ii. Build you image with docker build command using Dockerfile as parameter.
     
        $docker build Dockerfile -t isyed/my-python-app

        or
     
        $docker build .
            - If you want to re-run / contine if the building image failed on any step.
     
        iii. Run the push command to push the newly created image to public hub docker repository.
     
        $docker push isyed/my-python-app
            - here isyed is my account name which is created on docker website.
     
        $docker history isyed/my-python-app
            - to know the history and size of container image.
        

Design Patterns

Singleton 
---------------
class App{
    private App(){}
    static App createInstance(){}
}


Factory
---------------
interface App{
    public void develop();
    public void test();
    public void debug();
    public void deliver();
}
public class IOSApp implements App{}
public class TVApp implements App{}
public class WatchApp implements App{}

class AppStoreFactory{
   public App createApp(AppType type) {
       App app;
       switch (type) {
       case IOS:
           app = new IOSApp();
           break;
       case TV:
           app = new TVApp();
           break;
       case GLASS:
           app = new GlassApp();
           break;
       default:
           app = new GlassApp();
           break;
       }
       return app;
   }
}

Composite
---------------
Compose objects into tree structures to represent part-whole hierarchies. Composite lets client treat individual objects and compositions of objects uniformly.

Employee
Manager implements Employee
VP extends Manager
SectionManager extends Manager
TeamLeader extends Manager
Developer implements Employee

Adapter
---------------
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.


Prototype
---------------
public abstract class App implements Cloneable {}
public class IOSApp extends App {}
public class WatchApp extends App {}


public class BasicAppCache {
     public void load() {}
     public App get(AppType type) {}
}

or

public class AdvancedAppCache {
    private App load(AppType type) {}
    public App get(AppType type) {}
}


public class AppFactory {
    BasicAppCache appCache;
    public App createApp(AppType type) {
        return this.appCache.get(type);
    }
}

public class AppStore {
    public static void main(String... args) {
        final App app = new AppFactory().createApp(AppType.WATCH));
    }
}


Proxy
--------------
Allows for object-level access control by acting as a pass-through entity or a placeholder object.

public interface Book {}
public class RealBook implements Book {}
public class ProxyBook implements Book {}
public class LibraryService {

}

Object-Oriented Design Principles (OODP)



1. DRY (Don't repeat yourself) : Don't duplicate code reusability is the best approach.

2. Encapsulate What Changes: Use the access specified wisely and not everything should be public (class/object/variable).

3. Open Closed Design Principle: Classes, methods or functions should be Open for extension (new functionality) and Closed for modification.

4. Single Responsibility Principle (SRP) : There should not be more than one reason for a class to change, or a class should always handle single functionality.

5. Dependency Injection or Inversion principle

6. Favor Composition over Inheritance : Always favor composition over inheritance. Composition allows changing the behavior of a class at run-time by setting property during run-time and by using Interfaces to compose a class we use polymorphism which provides flexibility to replace with better implementation at any time.

7. Liskov Substitution Principle (LSP) : Methods or functions which use the superclass type must be able to work with the object of subclass without any issue.

8. Interface Segregation Principle (ISP) : A client should not implement an interface if it doesn't use that. This happens mostly when one interface contains more than one functionality, and the client only needs one functionality and no other.

9. Programming for Interface not implementation 

10. Delegation principles : Don't do all stuff by yourself,  delegate it to the respective class. Classical example of delegation design principle is equals() and hashCode() method in Java.

Tuesday, July 16, 2019

Apache Reverse Proxy with mod_proxy

Follow the steps to install and configure apache as a reverse proxy. 

1. Install apache2 

    sudo apt-get update; sudo apt-get upgrade; sudo apt-get install apache2


2. Enable apache2 modules 

     sudo a2enmod proxy
     sudo a2enmod proxy_http
     sudo a2enmod proxy_balancer
     sudo a2enmod lbmethod_byrequests

3. Update apache2 default configuration file 

     sudo vi /etc/apache2/sites-available/000-default.conf

       <VirtualHost *:80>
              ProxyPreserveHost On
              ProxyPass / http://localhost:8080/
              ProxyPassReverse / http://localhost:8080/

              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
       </VirtualHost>

Multiple hosts:

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass /web http://localhost:8080/web
    ProxyPassReverse /web http://localhost:8080/web

    ProxyPass /micro http://localhost:8081/micro
    ProxyPassReverse /micro http://localhost:8081/micro
        
#ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

4. Restart the apache2 server 
        sudo systemctl restart apache2





Saturday, March 2, 2019

Enable CORS on Wildfly

Cross-Origin Resource Sharing (CORS) response headers to Camunda REST engine in wildfly (standalone.xml) distribution.

<subsystem xmlns="urn:jboss:domain:undertow:3.0">

    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
            <filter-ref name="Access-Control-Allow-Origin"/>
            <filter-ref name="Access-Control-Allow-Methods"/>
            <filter-ref name="Access-Control-Allow-Headers"/>
            <filter-ref name="Access-Control-Allow-Credentials"/>
            <filter-ref name="Access-Control-Max-Age"/>
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <filters>
        <response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
        <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
        <response-header name="Access-Control-Allow-Origin" header-name="Access-Control-Allow-Origin" header-value="*"/>
        <response-header name="Access-Control-Allow-Methods" header-name="Access-Control-Allow-Methods" header-value="GET, POST, OPTIONS, PUT"/>
        <response-header name="Access-Control-Allow-Headers" header-name="Access-Control-Allow-Headers" header-value="accept, authorization, content-type, x-requested-with"/>
        <response-header name="Access-Control-Allow-Credentials" header-name="Access-Control-Allow-Credentials" header-value="true"/>
        <response-header name="Access-Control-Max-Age" header-name="Access-Control-Max-Age" header-value="1"/>
    </filters>
</subsystem>


For Testing: http://www.apirequest.io/



Monday, August 13, 2018

Migrate an Enterprise Capture Workspace


This can be accomplished by using the WLST commands "exportWorkspace" on the source Enterprise Capture system and "importWorkspace" on the target Enterprise Capture system.

The exact steps are :

1) Run the wlst command (.sh for Linux, .cmd for Windows) from the Middleware home /common/bin directory:

  wlst.sh

2) Connect to the Capture managed server:

    wls:/offline> connect("weblogic","welcome1","t3://localhost:16400")

3) Retrieve Workspace ID, which is passed to the export command.  To get a list of current workspaces and their IDs:

    wls:/content/serverConfig>listWorkspaces()

The list will look like the following:

         8 wkspace1

         6 fred-wk2

         7 test-capture1

4) Run the export command:

    wls:/content/serverConfig>exportWorkspace(8,'/home/isyed/wkspace1.xml')

5) Import the workspace to the same instance (only if you deleted the workspace since exporting) or a different Capture instance:

   wls:/content/serverConfig>importWorkspace('/home/isyed/wkspace1.xml')


Sunday, August 12, 2018

Multiple eclipse instances on Mac

OSX Eclipse Launcher utility plugin

Follow these simple instructions
  1. Go to help --> Eclipse Marketplace...
  2. Search for "OS X Eclipse laucher utility"
  3. Cick Install, Next, Finish and restart your eclipse.
Once the plugin is installed, click on File --> Open Workspace.  Here you go, a new instance of eclipse is opened with a new workspace.

Thursday, July 12, 2018

Advance Scripts for Oracle WebCenter Capture

More documentation can be found here: https://docs.oracle.com/cd/E29542_01/doc.1111/e28275/c01_intro.htm

Script to generate the logs:

----------------------------------------------------------------------------------------------
load("nashorn:mozilla_compat.js");

function logRPCEvent (rpc, funcName) {
var logger = rpc.getLogger();
logger.info("PrintRecogProcEvents.js entered function: " + funcName);
}

function initialize(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "initialize");
}

function processBatch(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "processBatch");
}

function restoreCaptureBatch(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "restoreCaptureBatch");
}

function beginPhase(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "beginPhase");
}

function endPhase(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "endPhase");
}

function extractBatchItem(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "extractBatchItem");
}

function barcodesFoundOnItem(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "barcodesFoundOnItem");
}

function batchItemAllValidBarcodes(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "batchItemAllValidBarcodes");
}

function determineSeparatorPage(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "determineSeparatorPage");
}

function batchItemValidBarcode(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "batchItemValidBarcode");
}

function determineDocType(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "determineDocType");
}

function beginDatabaseLookup(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "beginDatabaseLookup");
}

function determineIndexValues(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "determineIndexValues");
}

function renameOrigCaptureDocTitle(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "renameOrigCaptureDocTitle");
}

function createCaptureDoc(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "createCaptureDoc");
}

function postProcess(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "postProcess");
}

function endBatchProcess(rpc) { // RecognitionProcessorContext
logRPCEvent(rpc, "endBatchProcess");
}
----------------------------------------------------------------------------------------------

Script to Update the Date format 

----------------------------------------------------------------------------------------------
load("nashorn:mozilla_compat.js");
importClass(java.text.SimpleDateFormat);
importClass(java.util.Date);

function logRPCEvent(rpc, logText) {
    var logger = rpc.getLogger();
    logger.info("[WWW] - " + logText);
}

function determineIndexValues(rpc) { // RecognitionProcessorContext
    logRPCEvent(rpc, "determineIndexValues");
    convertDateFormat(rpc);
}



function convertDateFormat(rpc) {
    logRPCEvent(rpc, "convertDateFormat");
    var DOCUMENT_DATE_FIELD = "Document Date";

    var documentDate = getIndexID(rpc, DOCUMENT_DATE_FIELD);
    logRPCEvent(rpc, "Get Index Field Id: " + documentDate);

    var capturedDocument = rpc.getBle().getBatch().getDocuments().get(0);
    logRPCEvent(rpc, "Captured Document : " + capturedDocument);

    var indexValues = rpc.getDocument().getIndexValues();
    for (var i = 0; i < indexValues.size(); i++) {
        var iv = indexValues.get(i);
        if (iv.getFieldID().equals(documentDate)) {
            logRPCEvent(rpc, "FieldID: [" + iv.getFieldID() + "] FieldValue: [" + iv.getFieldValue() + "]");
            var documentDateCapturedValue = iv.getFieldValue();
            iv.setFieldValue(formatRequiredDate(documentDateCapturedValue));
        }
    }
}

// @Format the date to yyyy-MM-dd'T'HH:mm:ss'Z'
function formatRequiredDate(currentDate) {

    var REQUIRED_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    var LOOKUP_DATE_PATTERN = "MM-dd-yyyy";
    var currentDateFormat = new SimpleDateFormat(LOOKUP_DATE_PATTERN);
    var inputDate = currentDateFormat.parse(currentDate);
    currentDateFormat.applyPattern(REQUIRED_PATTERN);

    return currentDateFormat.format(inputDate);
}

// @Return the field object from document
function getFieldDefination(document, field) {
    return document.getParentBatch().getWorkspace().getFieldDefinitions().findByName(field);
}

// @Get the index Id
function getIndexID(rpc, indexName) {
    var workspace = rpc.getWorkspaceEntity();
    var indexDef = findIndexDefinitionByName(workspace, indexName, rpc);

    if (indexDef != null) {
        var indexID = indexDef.getIndexFieldID();
    }
    logRPCEvent(rpc, " In getIndexID : indexID [" + indexID + "]");
    return indexID;
}

// @Get the index definition by name
function findIndexDefinitionByName(workspace, indexName, rpc) {
    logRPCEvent(rpc, " In findIndexDefinitionByName : Workspace [" + workspace + "], Index Name: [" + indexName + "]");
    var indexDefs = workspace.getIndexDefinitions();
    var size = indexDefs.size();
    var foundIndexDef = null;
    for (var i = 0; i < size; i++) {
        var indexDef = indexDefs.get(i);
        if (indexName.equals(indexDef.getFieldName())) {
            foundIndexDef = indexDef;
            break;
        }
    }
    logRPCEvent(rpc, " In findIndexDefinitionByName : foundIndexDef [" + foundIndexDef + "]");
    return foundIndexDef;
}
----------------------------------------------------------------------------------------------

Steps to configure in Capture:


  1. Copy the following code to a text file.
  2. Open the WebCenter Workspace Console.
  3. Select the desired Workspace.
  4. Select the "Advanced" train stop / tab.
  5. Click the "Add New Script" button.
  6. Select type "Recognition Processor" and name the script appropriately. For example, LogsRecProcEvents.
  7. Select the file created above and click submit.
  8. Select the "Processing" tab.
  9. Select the desired Recognition Processor job and click the Edit (pencil) icon.
  10. Go to the "Extensions" train stop / tab.
  11. Click the "Script" pulldown menu.
  12. Select the script created in the Advanced Tab, (e.g. LogsRecProcEvents).
  13. Click "Submit" to apply the script.



Welcome to Vagrant

1. Download and Install the Vagrant  - (https://www.vagrantup.com/downloads.html)
i. Check the vagrant installed version: vagrant -vagrant
ii. Check the OS path if you can find the vagrant command.

2. Download and Install the Oracle Virtual Box - (https://www.virtualbox.org/wiki/Downloads)

3. Create a new folder for Vagrant box instances - vagrant-boxes

4. Get the required box name from the vagrant catalog - https://app.vagrantup.com/boxes/search

5. Go to the newly created folder (vagrant-boxes) and run command to create the vagrant instance.
- vagrant init ubuntu/trusty64
        i.  ubuntu/trusty64 is the vagrant box available in the catalog.
       ii. You get the following error:
                  The box 'xxxxxx' could not be found or could not be accessed in the remote catalog.
Use the following command to download the vagrant intance
- vagrant box add ubuntu/trusty64 https://app.vagrantup.com/ubuntu/boxes/trusty64


6. The vagrant will create an instance configuration file (VagranFile). Review the file and update the configuration only if you are sure what you are doing.

7.  Run the command to up the vagrant instance, the command will download the instance and make it ready to use.
   - vagrant up
   i.e Just make sure you are on the right path/directory.

   - vagrant destroy : to delete the vagrant instance
   - vagrant suspend : to shutdown the vagrant instance
   - vanrant resume  : to started the suspended instance
   - bagramt reload  : to reload the instance incase of change in vm configuration.

8.  The VM system specification(RAM, Processor, Hard drive) can be updated in vagrantfile (the configuration file which created in step#5)
#Provider Settings
config.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vm.cpus = 4
end

- vagrant reload
   The specification can be updated through the oracle box. ??!! (Need to verify)

9.  SSH the box through vagrant command and continue with setuping other apps (apache, mysql, etc) on box.
- vagrant ssh

10. Enable the network settings in vagrantfile (the configuration file which created in step#5)

#Network Settings
config.vm.network "forwarded_port", guest: 80, host: 8080
#If wanted to use private network ip then above statment must be commited
config.vm.network "private_network", ip: "192.168.10.10"

    - vagrant reload

11. Add hostname/domain name on the local environment, it's completely based on OS like in Linux: \etc\hosts
        192.168.10.10 mybox.local www.mybox.local

12. Setup share folder in vagrantfile (the configuration file which created in step#5)

#Folder Settings
config.vm.synced_folder ".", "/vagrant_data", mount_options =>["dmode=777","fmode=666"]
# . is a current folder of host OS and it can be different path like /home/isyed/Downloads
# "/vagrant_data" is destination folder and it can also be any file path in gest os.
# mount_options =>["dmode=777","fmode=666"]  are the permission on the folder to make it more secure
# Check NFS with Vagrant to increase the performance for network shared folders - :nfs => { :mount_options =>["dmode=777","fmode=666"]}
   config.vm.synced_folder ".", "/vagrant_data", :nfs => { :mount_options =>["dmode=777","fmode=666"]}

- vagrant reload

13. Setup a provision Settings : You can add the list of command which is going to be executed by vagrant once the instance is recreated.

#Provision Settings
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y apache2
SHELL

The provision command can be stored in different provision file, to do so update the provision settings:
#Provision Settings
config.vm.provision "shell", path:"bootstrap.sh"

Add new file bootstrap.sh file and add the all the commands which you need to execute after the instance is up.

Vagrantfile

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Vagrant.configure("2") do |config|
  
  config.vm.box = "ubuntu/trusty64"

  # config.vm.box_check_update = false
  # config.vm.network "forwarded_port", guest: 80, host: 8080
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # config.vm.network "private_network", ip: "192.168.0.8"
  # config.vm.network "public_network"
  # config.vm.synced_folder "../data", "/vagrant_data"
    
   # config.vm.hostname = "vlamp"
   # config.ssh.username = "vlamp"

   # config.vm.network "public_network", bridge:"en0: Wi-Fi (AirPort)", ip: "192.168.0.120”

   config.vm.network "public_network", :bridge => "eth0", ip: "192.168.0.180", :netmask => "255.255.255.128", auto_config: false

   # config.vm.network "public_network", use_dhcp_assigned_default_route: true
   # Attempt to 'guess' the default network
   # config.vm.network :public_network, :bridge => 'en0: Wi-Fi (AirPort)'

   config.vm.provider "virtualbox" do |vb|
     
     # Set Instance Name
     vb.name = "vlamp"
     # Display the VirtualBox GUI when booting the machine
     vb.gui = false
  
     # Customize the amount of memory on the VM:
      vb.memory = "1024"
   end

   config.vm.provision "shell", inline: <<-SHELL
     apt-get update
     #apt-get install -y apache2
   SHELL

end

--------------------------------------------------------------------------------------------------------------------------

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  # config.vm.box_check_update = false
  # config.vm.network "forwarded_port", guest: 80, host: 8080
    config.vm.network "private_network", ip: "192.168.10.10"
  # config.vm.network "public_network"

   config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
   config.vm.provider "virtualbox" do |vb|
     vb.gui = false
vb.name = "coremedia9"
vb.cpus = 4
     vb.memory = "1024"
   end
 
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL

end

--------------------------------------------------------------------------------------------------------------------------
 



Saturday, July 7, 2018

Disable 8dot3


Disable 8dot3 naming, what is requested during UCM install procedure, by running "Installer DisableNtfs8dot3" and then restarting windows. This procedure can be run after UCM installation is done.

Run: DomainHome\ucm\cs\bin\Installer.exe DisableNtfs8dot3
Page 153: http://download.oracle.com/docs/cd/E17904_01/doc.1111/e14495.pdf

If that still leaves 8dot3 naming enabled, modify registry:
1. Start/Run/regedit
2. In the left pane of the window navigate to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
3. In the right pane of the window, edit the DWORD "NtfsDisable8dot3NameCreation" and set its value to 1 (The default value is 2)
4. Reboot the system

RCU-6080:Global prerequisite check failed

RCU-6080:Global prerequisite check failed – The selected Oracle database is a multitenant container database (CDB).


Steps : 

1) Check where are your PDB installed

SQL> select name from v$services;
NAME
—————————————————————-
pdborcl
weblogicXDB
weblogic
SYS$BACKGROUND
SYS$USERS

2. Alter your database:
SQL>  alter pluggable database all open;

3.  insert the correct service name. On my case, is pdborcl:

Monday, November 21, 2016

Laserfiche WCC Integration SQL Queries

Integration Application

ReportTotalRemainingDocs

getRemainingDocs:
SELECT DISTINCT TOC.tocid,pagecount, (SELECT str_val FROM propval WHERE prop_id =14 AND propval.tocid =TOC.tocid) as CR_NUMBER, (SELECT str_val FROM propval WHERE prop_id =27 AND propval.tocid =TOC.tocid) as MLTR_NUMBER FROM TOC,DOC WHERE etype <> 0 and TOC.tocid=DOC.tocid and DOC.pagenum not in (select WCC_PAGE_NUM FROM WCC_DOCS_MIGRATION where WCC_TOC_ID =TOC.tocid)

getArchivedPages:
SELECT COUNT(*) as WCC_PAGES_NUM FROM WCC_DOCS_MIGRATION WHERE WCC_STATUS=0 OR WCC_STATUS=1

getSentForReviewPages:
SELECT COUNT(*) as SENT_FOR_REVIEW_PAGES_NUM FROM WCC_DOCS_MIGRATION WHERE WCC_STATUS=2

getArchDocsNum:
SELECT DISTINCT MainTable.tocid,pagecount, (SELECT str_val FROM propval WHERE prop_id =14 AND propval.tocid =MainTable.tocid) as CR_NUMBER, (SELECT str_val FROM propval WHERE prop_id =27 AND propval.tocid =MainTable.tocid) as MILITARY_NUMBER FROM toc MainTable,WCC_DOCS_MIGRATION, DOC  WHERE etype <> 0 AND MainTable.tocid=WCC_TOC_ID and DOC.pagenum in (select WCC_PAGE_NUM FROM WCC_DOCS_MIGRATION where WCC_TOC_ID =MainTable.tocid AND (WCC_STATUS=1 OR WCC_STATUS=0))

getArchDocsNumTimoutError:
SELECT DISTINCT MainTable.tocid,pagecount, (SELECT str_val FROM propval WHERE prop_id =14 AND propval.tocid =MainTable.tocid) as CR_NUMBER, (SELECT str_val FROM propval WHERE prop_id =27 AND propval.tocid =MainTable.tocid) as MILITARY_NUMBER, (SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID = MainTable.tocid AND (WCC_STATUS=1 OR WCC_STATUS=0)) as WCC_PAGES_NUM, (SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID = MainTable.tocid AND (WCC_STATUS=2)) as SENT_FOR_REVIEW_PAGES_NUM FROM toc MainTable,WCC_DOCS_MIGRATION  WHERE etype <> 0 AND MainTable.tocid=WCC_TOC_ID

getTotalDocsNum:
SELECT pagecount FROM toc WHERE etype <> 0

getTotalDocsNumWith
SELECT COUNT(*) as TOTAL_DOCS FROM toc as tocTable, propval as propTable WHERE etype <> 0 AND propTable.tocid = tocTable.tocid AND prop_id =" & propId & " AND str_val is not null

getArchivedPagesByTocID:
SELECT COUNT(*) as ArchPages FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID =" & tocID,


ReportProductionFrm

Print:
select CHECKED_BY, (select COUNT(*) from (select checked_by,WCC_ID from dbo.WCC_DOCS_MIGRATION where (WCC_STATUS=1 OR WCC_STATUS=0) and CONVERT(datetime,checked_date,103)>=CONVERT(datetime,'" & txtFromDate.Text & "  00:00',103) and CONVERT(datetime,checked_date,103)<=CONVERT(datetime,'" & txtTotDate.Text & " 23:59',103) and CHECKED_BY=MAIN_TABLE.CHECKED_BY group by checked_by,WCC_ID) as ARCH_COUNT) as NUM_DOCUMENTS  from dbo.WCC_DOCS_MIGRATION as MAIN_TABLE where (WCC_STATUS=1 OR WCC_STATUS=0) and CONVERT(datetime,checked_date,103)>=CONVERT(datetime,'" & txtFromDate.Text & "  00:00',103) and CONVERT(datetime,checked_date,103)<=CONVERT(datetime,'" & txtTotDate.Text & " 23:59',103) group by CHECKED_BY

SELECT COUNT(CHECKED_BY) as NUM_PAGES FROM WCC_DOCS_MIGRATION WHERE (WCC_STATUS=1 OR WCC_STATUS=0) and CHECKED_BY=' dataSet.Tables(0).Rows(i)("CHECKED_BY") & "' and CONVERT(datetime,checked_date,103)>=CONVERT(datetime,'" & txtFromDate.Text & "  00:00',103) and CONVERT(datetime,checked_date,103)<=CONVERT(datetime,'" & txtTotDate.Text & " 23:59',103)

ReportArchDocsFrms
SELECT WCC_TOC_ID FROM WCC_DOCS_MIGRATION WHERE WCC_STATUS=1 AND CHECKED_BY='" & cmbUserName.SelectedValue &"' AND CONVERT(datetime,checked_date,103)>=CONVERT(datetime,'" & txtFromDate.Text &
"  00:00',103) and CONVERT(datetime,checked_date,103)<=CONVERT(datetime,'" & txtToDate.Text & " 23:59',103) GROUP BY WCC_TOC_ID

SELECT USER_ID, userFullName FROM WCC_USER Order by userFullName ASC

MappingOptionsFrm

MappingOptionsFrm_Load:
SELECT WCC_MAPPING_ID, WCC_MAPPING_SET_ID, WCC_MAPPING_SET, WCC_MAPPING_Type, WCC_MAPPING_PATH, WCC_MAPPING_dDocType, " & "WCC_MAPPING_xClassification, WCC_MAPPING_xServiceType FROM WCC_DOC_TYPES_MAPPING " & setFilterCondition & " order by WCC_MAPPING_ID


Globals

fillDocumentSetCombobox:
SELECT pset_id, pset_name FROM propset ORDER BY pset_id ASC

Form1

GetDataView

        Dim cmdstr As String = "SELECT Top " & recoedsCountsTxt.Value & " tocid,parentid,pagecount"
        If UserType = 1 Then 'normal user
            cmdstr += ",MIGRATED_PAGES_NUM FROM WCC_DOCS WHERE pagecount > MIGRATED_PAGES_NUM "
        Else 'reviewrs
            cmdstr += " FROM WCC_DOCS as tocTable, WCC_DOCS_MIGRATION WHERE tocid=WCC_TOC_ID AND WCC_STATUS=2 "
        End If

'If only the Doc Type selected from the filter
        If Not IsDBNull(cmbDocType.SelectedValue) AndAlso cmbDocType.SelectedIndex <> -1 Then
            cmdstr = "SELECT distinct Top " & recoedsCountsTxt.Value & " tocTable.tocid, parentid,pagecount " '
            If UserType = 1 Then 'normal user
                cmdstr += ",MIGRATED_PAGES_NUM FROM WCC_DOCS as tocTable WHERE pagecount > MIGRATED_PAGES_NUM "
            Else 'reviewrs
                cmdstr += "FROM WCC_DOCS as tocTable, WCC_DOCS_MIGRATION WHERE tocTable.tocid=WCC_TOC_ID AND WCC_STATUS=2 "
            End If
            cmdstr &= " AND prop_id= " & getPropIdFromSetCombo() & " AND str_val like N'%" & cmbDocType.SelectedValue.Trim & "%' "
        End If

'Advanced Filters
        If txtCPRNumber.Text <> "" Or txtMilitaryNumber.Text <> "" Or txtEmployeeName.Text <> "" Then 'Or (cmbDocType.SelectedIndex <> -1 And Not IsDBNull(cmbDocType.SelectedValue))
            Dim propIdToFilter As String = ""
            Dim valuesToCompare As String = ""


            cmdstr = "SELECT distinct Top " & recoedsCountsTxt.Value & " tocTable.tocid, parentid,pagecount " '
            If UserType = 1 Then 'normal user
                cmdstr += ",MIGRATED_PAGES_NUM FROM WCC_DOCS as tocTable WHERE pagecount > MIGRATED_PAGES_NUM "
            Else 'reviewrs
                cmdstr += "FROM WCC_DOCS as tocTable, WCC_DOCS_MIGRATION WHERE tocTable.tocid=WCC_TOC_ID AND WCC_STATUS=2 "
            End If

            If txtCPRNumber.Text <> "" Then
                propIdToFilter &= "14,"
                valuesToCompare &= " str_val='" & txtCPRNumber.Text.Trim & "' OR"
            End If

            If txtMilitaryNumber.Text <> "" Then
                propIdToFilter &= "27,"
                valuesToCompare &= " str_val='" & txtMilitaryNumber.Text.Trim & "' OR"
            End If
            If txtEmployeeName.Text <> "" Then
                propIdToFilter &= "13,"
                valuesToCompare &= " str_val like N'%" & txtEmployeeName.Text.Trim & "%' OR"
            End If
            If Not IsDBNull(cmbDocType.SelectedValue) AndAlso cmbDocType.SelectedIndex <> -1 Then
                propIdToFilter &= getPropIdFromSetCombo() & ","
                valuesToCompare &= " str_val like N'%" & cmbDocType.SelectedValue.Trim & "%' OR"
            End If

            propIdToFilter = propIdToFilter.Substring(0, propIdToFilter.Length - 1)
            valuesToCompare = valuesToCompare.Substring(0, valuesToCompare.Length - 2)

            cmdstr += "AND prop_id in (" & propIdToFilter & ") AND (" & valuesToCompare & ")"
        End If
'Doc Set
        If cmbDocSet.SelectedIndex <> -1 Then cmdstr &= " AND pset_id=" & cmbDocSet.SelectedValue
        cmdstr &= " AND created > CONVERT(datetime,'" & HideDateGlobal & "',103)"
        If UserType <> 1 Then cmdstr += " group by tocTable.tocid,parentid,pagecount "

getData:

Dim cmdstr As String = "SELECT DISTINCT Top " & recoedsCountsTxt.Value & " TOC.tocid,TOC.parentid,TOC.pagecount "

        If UserType = 1 Then 'normal user
            cmdstr += " FROM TOC,DOC WHERE etype <> 0 and TOC.tocid=DOC.tocid and DOC.pagenum not in (select WCC_PAGE_NUM FROM WCC_DOCS_MIGRATION where WCC_TOC_ID =TOC.tocid) "
        Else 'reviewrs
            cmdstr += " FROM TOC, WCC_DOCS_MIGRATION WHERE etype <> 0 AND tocid=WCC_TOC_ID AND WCC_STATUS=2 "
        End If


        'If only the Doc Type selected from the filter
        If Not IsDBNull(cmbDocType.SelectedValue) AndAlso cmbDocType.SelectedIndex <> -1 Then
            cmdstr = "SELECT distinct Top " & recoedsCountsTxt.Value & "  TOC.tocid,TOC.parentid,TOC.pagecount " '
            If UserType = 1 Then 'normal user
                cmdstr += " FROM TOC,DOC, propval as propTable WHERE etype <> 0 AND propTable.tocid = TOC.tocid  and DOC.pagenum not in (select WCC_PAGE_NUM FROM WCC_DOCS_MIGRATION where WCC_TOC_ID =TOC.tocid) and TOC.tocid=DOC.tocid"
            Else 'reviewrs
                cmdstr += " FROM TOC, propval as propTable, WCC_DOCS_MIGRATION WHERE etype <> 0 AND propTable.tocid = TOC.tocid " & _
                            "AND TOC.tocid=WCC_TOC_ID AND WCC_STATUS=2 "
            End If
            cmdstr &= " AND prop_id= " & getPropIdFromSetCombo() & " AND str_val like N'%" & cmbDocType.SelectedValue.Trim & "%' "
        End If


        'Advanced Filters
        If txtCPRNumber.Text <> "" Or txtMilitaryNumber.Text <> "" Or txtEmployeeName.Text <> "" Then 'Or (cmbDocType.SelectedIndex <> -1 And Not IsDBNull(cmbDocType.SelectedValue))
            Dim propIdToFilter As String = ""
            Dim valuesToCompare As String = ""

            cmdstr = "SELECT distinct Top " & recoedsCountsTxt.Value & " TOC.tocid,TOC.parentid,TOC.pagecount " '
            If UserType = 1 Then 'normal user
                cmdstr += " FROM TOC,DOC, propval as propTable WHERE etype <> 0 AND propTable.tocid = TOC.tocid  and DOC.pagenum not in (select WCC_PAGE_NUM FROM WCC_DOCS_MIGRATION where WCC_TOC_ID =TOC.tocid) and TOC.tocid=DOC.tocid "
            Else 'reviewrs
                cmdstr += " FROM TOC, propval as propTable, WCC_DOCS_MIGRATION WHERE etype <> 0 AND propTable.tocid = TOC.tocid " & _
                            "AND TOC.tocid=WCC_TOC_ID AND WCC_STATUS=2 "
            End If

            If txtCPRNumber.Text <> "" Then
                propIdToFilter &= "14,"
                valuesToCompare &= " str_val='" & txtCPRNumber.Text.Trim & "' OR"
            End If

            If txtMilitaryNumber.Text <> "" Then
                propIdToFilter &= "27,"
                valuesToCompare &= " str_val='" & txtMilitaryNumber.Text.Trim & "' OR"
            End If
            If txtEmployeeName.Text <> "" Then
                propIdToFilter &= "13,"
                valuesToCompare &= " str_val like N'%" & txtEmployeeName.Text.Trim & "%' OR"
            End If
            If Not IsDBNull(cmbDocType.SelectedValue) AndAlso cmbDocType.SelectedIndex <> -1 Then
                propIdToFilter &= getPropIdFromSetCombo() & ","
                valuesToCompare &= " str_val like N'%" & cmbDocType.SelectedValue.Trim & "%' OR"
            End If

            propIdToFilter = propIdToFilter.Substring(0, propIdToFilter.Length - 1)
            valuesToCompare = valuesToCompare.Substring(0, valuesToCompare.Length - 2)

            cmdstr += "AND prop_id in (" & propIdToFilter & ") AND (" & valuesToCompare & ")"
        End If

        'Doc Set
        If cmbDocSet.SelectedIndex <> -1 Then cmdstr &= " AND pset_id=" & cmbDocSet.SelectedValue
        cmdstr &= " AND created > CONVERT(datetime,'" & HideDateGlobal & "',103)"
        If UserType <> 1 Then cmdstr += " group by TOC.tocid,parentid,pagecount "

getDataSELECT_COUNT:

Dim cmdstr As String = "SELECT Top " & recoedsCountsTxt.Value & " tocid,parentid,pagecount"

        If UserType = 1 Then 'normal user
            cmdstr += ",(SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID =tocid) as WCC_PAGES_NUM  FROM toc WHERE etype <> 0 AND pagecount > (SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID =tocid)"
        Else 'reviewrs
            cmdstr += " FROM toc as tocTable, WCC_DOCS_MIGRATION WHERE etype <> 0 AND tocid=WCC_TOC_ID AND WCC_STATUS=2 "
        End If


        'If only the Doc Type selected from the filter
        If Not IsDBNull(cmbDocType.SelectedValue) AndAlso cmbDocType.SelectedIndex <> -1 Then
            cmdstr = "SELECT distinct Top " & recoedsCountsTxt.Value & " tocTable.tocid, parentid,pagecount " '
            If UserType = 1 Then 'normal user
                cmdstr += ",(SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID =tocTable.tocid) as WCC_PAGES_NUM " & _
                            "FROM toc as tocTable, propval as propTable WHERE etype <> 0 AND propTable.tocid = tocTable.tocid AND pagecount > (SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID =tocTable.tocid) "
            Else 'reviewrs
                cmdstr += "FROM toc as tocTable, propval as propTable, WCC_DOCS_MIGRATION WHERE etype <> 0 AND propTable.tocid = tocTable.tocid " & _
                            "AND tocTable.tocid=WCC_TOC_ID AND WCC_STATUS=2 "
            End If
            cmdstr &= " AND prop_id= " & getPropIdFromSetCombo() & " AND str_val like N'%" & cmbDocType.SelectedValue.Trim & "%' "
        End If


        'Advanced Filters
        If txtCPRNumber.Text <> "" Or txtMilitaryNumber.Text <> "" Or txtEmployeeName.Text <> "" Then 'Or (cmbDocType.SelectedIndex <> -1 And Not IsDBNull(cmbDocType.SelectedValue))
            Dim propIdToFilter As String = ""
            Dim valuesToCompare As String = ""

            cmdstr = "SELECT distinct Top " & recoedsCountsTxt.Value & " tocTable.tocid, parentid,pagecount " '
            If UserType = 1 Then 'normal user
                cmdstr += ",(SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID =tocTable.tocid) as WCC_PAGES_NUM " & _
                            "FROM toc as tocTable, propval as propTable WHERE etype <> 0 AND propTable.tocid = tocTable.tocid AND pagecount > (SELECT COUNT(*) FROM WCC_DOCS_MIGRATION WHERE WCC_TOC_ID =tocTable.tocid) "
            Else 'reviewrs
                cmdstr += "FROM toc as tocTable, propval as propTable, WCC_DOCS_MIGRATION WHERE etype <> 0 AND propTable.tocid = tocTable.tocid " & _
                            "AND tocTable.tocid=WCC_TOC_ID AND WCC_STATUS=2 "
            End If

            If txtCPRNumber.Text <> "" Then
                propIdToFilter &= "14,"
                valuesToCompare &= " str_val='" & txtCPRNumber.Text.Trim & "' OR"
            End If

            If txtMilitaryNumber.Text <> "" Then
                propIdToFilter &= "27,"
                valuesToCompare &= " str_val='" & txtMilitaryNumber.Text.Trim & "' OR"
            End If
            If txtEmployeeName.Text <> "" Then
                propIdToFilter &= "13,"
                valuesToCompare &= " str_val like N'%" & txtEmployeeName.Text.Trim & "%' OR"
            End If
            If Not IsDBNull(cmbDocType.SelectedValue) AndAlso cmbDocType.SelectedIndex <> -1 Then
                propIdToFilter &= getPropIdFromSetCombo() & ","
                valuesToCompare &= " str_val like N'%" & cmbDocType.SelectedValue.Trim & "%' OR"
            End If

            propIdToFilter = propIdToFilter.Substring(0, propIdToFilter.Length - 1)
            valuesToCompare = valuesToCompare.Substring(0, valuesToCompare.Length - 2)

            cmdstr += "AND prop_id in (" & propIdToFilter & ") AND (" & valuesToCompare & ")"
        End If

        'Doc Set
        If cmbDocSet.SelectedIndex <> -1 Then cmdstr &= " AND pset_id=" & cmbDocSet.SelectedValue
        cmdstr &= " AND created > CONVERT(datetime,'" & HideDateGlobal & "',103)"
        If UserType <> 1 Then cmdstr += " group by tocTable.tocid,parentid,pagecount "


DocumentInfo

assignMainData:

Case 1 'General
Dim commandSetType As SqlCommand = New SqlCommand( _
"SELECT TOP 1 " & _
"(SELECT str_val FROM propval WHERE prop_id =1 AND tocid = " & tocId & ") as document " & _
" FROM propval", _
sqlConnection)
Dim reader As SqlDataReader = commandSetType.ExecuteReader()
If reader.Read Then
If Not IsDBNull(reader("document")) Then docName = reader("document")
End If
reader.Close()
'New Meta Data
dDocTitle = tocName
xReferenceNumber = docName


Case 2 'النموذج الرئيسي
Dim commandSetType As SqlCommand = New SqlCommand( _
"SELECT TOP 1 " & _
"(SELECT str_val FROM propval WHERE prop_id =13 AND tocid = " & tocId & ") as name, " & _
"(SELECT str_val FROM propval WHERE prop_id =14 AND tocid = " & tocId & ") as CPR, " & _
"(SELECT str_val FROM propval WHERE prop_id =15 AND tocid = " & tocId & ") as doc_loc, " & _
"(SELECT str_val FROM propval WHERE prop_id =16 AND tocid = " & tocId & ") as doc_type " & _
" FROM propval", _
sqlConnection)
Dim reader As SqlDataReader = commandSetType.ExecuteReader()
If reader.Read Then
If Not IsDBNull(reader("name")) Then empName = reader("name")
If Not IsDBNull(reader("CPR")) Then cprNum = reader("CPR")
If Not IsDBNull(reader("doc_loc")) Then docLoc = reader("doc_loc")
If Not IsDBNull(reader("doc_type")) Then docType = reader("doc_type")
End If
reader.Close()
'New Meta Data
xCPRNumber = cprNum 'bilal throw log error if cprNum and docName not the same
dDocTitle = empName 'bilal empName could be null.. wt to do?


Case 3, 6 'مستند الدفع + مستند دفع2
Dim tmpDocDatePropId As String
Dim tmpAmountPropId As String
If psetId = 3 Then
tmpDocDatePropId = "18"
tmpAmountPropId = "20"
Else
tmpDocDatePropId = "28"
tmpAmountPropId = "29"
End If

Dim commandSetType As SqlCommand = New SqlCommand( _
"SELECT TOP 1 " & _
"(SELECT num_val FROM propval WHERE prop_id =22 AND tocid = " & tocId & ") as payment_num, " & _
"(SELECT str_val FROM propval WHERE prop_id =13 AND tocid = " & tocId & ") as emp_name, " & _
"(SELECT str_val FROM propval WHERE prop_id =14 AND tocid = " & tocId & ") as crp_num, " & _
"(SELECT str_val FROM propval WHERE prop_id =21 AND tocid = " & tocId & ") as doc_type, " & _
"(SELECT str_val FROM propval WHERE prop_id =23 AND tocid = " & tocId & ") as doc_loc, " & _
"(SELECT str_val FROM propval WHERE prop_id =" & tmpDocDatePropId & " AND tocid = " & tocId & ") as doc_date, " & _
"(SELECT str_val FROM propval WHERE prop_id =" & tmpAmountPropId & " AND tocid = " & tocId & ") as amount " & _
" FROM propval", _
sqlConnection)
'(22 numval رقم مستند الدفع 4462.00000 MAND,13 empName !MAND,14 cpr MAND,21 docType 1 null,23 location) ,18,28 date null , 20,29 price null
Dim reader As SqlDataReader = commandSetType.ExecuteReader()
If reader.Read Then
If Not IsDBNull(reader("payment_num")) Then paymentNum = reader("payment_num").ToString
If Not IsDBNull(reader("emp_name")) Then empName = reader("emp_name")
If Not IsDBNull(reader("crp_num")) Then cprNum = reader("crp_num")
If Not IsDBNull(reader("doc_type")) Then docType = reader("doc_type")
If Not IsDBNull(reader("doc_loc")) Then docLoc = reader("doc_loc")
If Not IsDBNull(reader("doc_date")) Then xDocumentDate = reader("doc_date")
If Not IsDBNull(reader("amount")) Then xAmount = reader("amount")
End If
reader.Close()
'New Meta Data
xCPRNumber = cprNum
dDocTitle = empName 'bilal empName could be null.. wt to do?
xPaymentNumber = paymentNum


Case 4 'الكشوف
Dim commandSetType As SqlCommand = New SqlCommand( _
"SELECT TOP 1 " & _
"(SELECT str_val FROM propval WHERE prop_id =17 AND tocid = " & tocId & ") as doc_name, " & _
"(SELECT str_val FROM propval WHERE prop_id =18 AND tocid = " & tocId & ") as doc_date, " & _
"(SELECT str_val FROM propval WHERE prop_id =19 AND tocid = " & tocId & ") as party " & _
" FROM propval", _
sqlConnection)
Dim reader As SqlDataReader = commandSetType.ExecuteReader()
If reader.Read Then
If Not IsDBNull(reader("doc_name")) Then docName = reader("doc_name")
If Not IsDBNull(reader("doc_date")) Then xDocumentDate = reader("doc_date")
If Not IsDBNull(reader("party")) Then party = reader("party")
End If
reader.Close()
'New Meta Data
dDocTitle = docName


Case 7 'PFC
Dim commandSetType As SqlCommand = New SqlCommand( _
"SELECT TOP 1 " & _
"(SELECT str_val FROM propval WHERE prop_id =26 AND tocid = " & tocId & ") as name, " & _
"(SELECT str_val FROM propval WHERE prop_id =27 AND tocid = " & tocId & ") as mil_number " & _
" FROM propval", _
sqlConnection)
Dim reader As SqlDataReader = commandSetType.ExecuteReader()
If reader.Read Then
If Not IsDBNull(reader("name")) Then empName = reader("name")
If Not IsDBNull(reader("mil_number")) Then xMilitaryNumber = reader("mil_number")
End If
reader.Close()
'New Meta Data
dDocTitle = empName


Case 8 'Payments
Dim commandSetType As SqlCommand = New SqlCommand( _
"SELECT TOP 1 " & _
"(SELECT str_val FROM propval WHERE prop_id =32 AND tocid = " & tocId & ") as doc_num, " & _
"(SELECT str_val FROM propval WHERE prop_id =30 AND tocid = " & tocId & ") as doc_type, " & _
"(SELECT str_val FROM propval WHERE prop_id =31 AND tocid = " & tocId & ") as doc_date, " & _
"(SELECT str_val FROM propval WHERE prop_id =33 AND tocid = " & tocId & ") as amount " & _
" FROM propval", _
sqlConnection)
'doc_num could be payment or ref???
Dim reader As SqlDataReader = commandSetType.ExecuteReader()
If reader.Read Then
If Not IsDBNull(reader("doc_num")) Then paymentNum = reader("doc_num")
If Not IsDBNull(reader("doc_type")) Then docType = reader("doc_type")
If Not IsDBNull(reader("doc_date")) Then xDocumentDate = reader("doc_date")
If Not IsDBNull(reader("amount")) Then xAmount = reader("amount")
End If
reader.Close()
'New Meta Data


Case 9 'Service Extention
Dim commandSetType As SqlCommand = New SqlCommand( _
"SELECT TOP 1 " & _
"(SELECT str_val FROM propval WHERE prop_id =14 AND tocid = " & tocId & ") as CR_NUMBER, " & _
"(SELECT str_val FROM propval WHERE prop_id =35 AND tocid = " & tocId & ") as ref_num " & _
" FROM propval", _
sqlConnection)
'doc_num could be payment or ref???
Dim reader As SqlDataReader = commandSetType.ExecuteReader()
If reader.Read Then
If Not IsDBNull(reader("CR_NUMBER")) Then cprNum = reader("CR_NUMBER")
If Not IsDBNull(reader("ref_num")) Then referenceNumber = reader("ref_num")
End If
reader.Close()
'New Meta Data
xCPRNumber = cprNum
xReferenceNumber = referenceNumber

mapFields

Dim sqlStmt As String = "SELECT WCC_MAPPING_dDocType, WCC_MAPPING_xClassification, WCC_MAPPING_xServiceType " & _ "FROM WCC_DOC_TYPES_MAPPING WHERE WCC_MAPPING_SET_ID=" & psetId
        If docType <> "" Then sqlStmt += " AND WCC_MAPPING_Type like N'" & docType & "' "
        If logicalPathStr <> "" Then sqlStmt += " AND WCC_MAPPING_PATH like N'" & logicalPathStr & "' "

generatePhysicalPath

Dim sqlQuery As String = "SELECT storeid,pagenum FROM doc WHERE tocid =" & tocId
        If UserType = 1 Then
            sqlQuery += " AND pagenum not in (SELECT WCC_PAGE_NUM from WCC_DOCS_MIGRATION WHERE WCC_TOC_ID=tocid)"
        Else
            sqlQuery += " AND pagenum in (SELECT WCC_PAGE_NUM from WCC_DOCS_MIGRATION WHERE WCC_TOC_ID=tocid AND WCC_STATUS=2)"
        End If

AWS EC2 - SSH locked with UFW

Need to update the instance's user data: 1. Stop the instance 2. Right click (windows) or ctrl + click (Mac) on the instance to open a c...