Tuesday 24 December 2013

ASP Membership


To add asp membership DB to your DB

  1. Go to .net framework version on your windows directory (C:\Windows\Microsoft.NET\Framework64\v4.0.30319)
  2. Double click on (aspnet_regsql.exe), choose (Configure SQL for application services) and press next, type the server name and select your DB or type new DB name. finish
  3. Copy the following code and past it in your site web.config file 


<configuration>
  <connectionStrings>
    <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=ApplicationManagmentDB;" />
  </connectionStrings>
  <system.web>
    <authentication mode="Forms" >
    
    </authentication>
    <authorization>
      <deny users="?" />
      <allow roles="Administrators" />
      <deny users="*" />
    </authorization>
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
      <providers>
        <add
          name="SqlProvider"
          type="System.Web.Security.SqlMembershipProvider"
          connectionStringName="SqlServices"
          enablePasswordRetrieval="false"
          enablePasswordReset="false"
          requiresQuestionAndAnswer="false"
          passwordFormat="Hashed"
          applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="SqlProvider"
      enabled="true"
      cacheRolesInCookie="true"
      cookieName=".ASPROLES"
      cookieTimeout="30"
      cookiePath="/"
      cookieRequireSSL="true"
      cookieSlidingExpiration="true"
      cookieProtection="All" >
      <providers>
        <add
          name="SqlProvider"
          type="System.Web.Security.SqlRoleProvider"
          connectionStringName="SqlServices"
          applicationName="/" />
      </providers>
    </roleManager>
  </system.web>
</configuration>


Thursday 7 November 2013

Setting up the GlassFish and Oracle Maps

Installing GlassFish 

To install Oracle Map Viewer version 11.1.1.7, you have to download the archive from Oracle Website.
- The archived contains GlassFish Sever.
- To download the MapViewer you have to download MapViewer Demo.
- Extract the compressed files
- Go to the config directory "...\glassfish3\glassfish\config" and edit "asenv.bat" and add

      "REM set AS_JAVA=C:\Program Files\Java\jdk1.6.0_04\jre/..
       set AS_JAVA=D:\Java\jdk1.7.0_13"

   at the end of the file.

Hint: this to point to JDK dir

- run the "runMeFirst" patch file which placed in "mapviewer11g_qs"    folder.

 Note: the default user name is "admin" and the password is "welcome1", you can change the password          by visiting the admin page of the GlassFish Server
** GlassFish now should be running, to create service for the domain, loot for my previous posts
** Mvdemo is now running but you need to set up mvdemo DB

Installing Mvdemo DB and configure it
- Make sure you have installed Oracle DB
- Create mvdemo2 DB user and set passowrd
- Download "mvdemo_naturalearth" data
- Download "mvdemo_stormdata" data
- Log into the target database as DBA, then create a DIRECTORY
        object that points to the folder where this dump file is
        located.
- SQL> grant connect, resource, create view to mvdemo2 identified by mvdemo2;
- SQL> create directory dumpdir as 'D:\SW\GIS\mvdemo_naturalearth';
- SQL> grant read, write on DIRECTORY dumpdir to mvdemo2;

- From command line, run the following impdp command:
   
impdp mvdemo2/mvdemo2 remap_schema=nedata:mvdemo2 directory=dumpdir dumpfile=mvdemo_naturalearth.dmp full=y

** You may see some error messages regarding grants and roles. They can be
ignored.

- After the import is complete, log into user mvdemo2, then run these SQL statements:
       
        SQL> insert into user_sdo_styles select * from styles;
        SQL> insert into user_sdo_themes select * from themes;
        SQL> insert into user_sdo_maps select * from basemaps;
        SQL> insert into user_sdo_cached_maps select * from tilelayers;
        SQL> commit;

- Go to bin folder in glassfish directory and run asadmin.bat
- type: "create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname oracle.jdbc.pool.OracleDataSource --property "user=storm:password=storm:url=jdbc\:oracle\:thin\:@127.0.0.1\:1521\:orcl" storm-pool"
- type: create-jdbc-resource --connectionpoolid storm-pool jdbc/storm

- Go to http://localhost:8080/mapviewer/    in your browser, press on Admin which in the top corner of the page, type GlassFish user name and password
press on configurations tab, and create the connection, or copy and past the following script and change the db connection to fit your configurations


 <?xml version="1.0" ?>  

  <MapperConfig>
   <logging log_level="info" log_thread_name="false"
        log_time="true">
     <log_output name="System.err" />
     <log_output name="../log/mapviewer.log" />
   </logging>
   <graphics_config>
     <default_dpi>96</default_dpi>
   </graphics_config>
  <security_config>
   <disable_direct_info_request> false </disable_direct_info_request>
   <proxy_enabled_hosts>
   </proxy_enabled_hosts>
  </security_config>  
   <spatial_data_cache  max_cache_size="64"
              report_stats="false"  
   />
  <ns_data_provider
   id="defaultNSDP"  
   class="oracle.sdovis.NSDataProviderDefault"  
  />
  <s_data_provider
   id="shapefileSDP"  
   class="oracle.sdovis.ShapefileDataProvider"  
   >
   <parameters>
    <parameter name="datadir" value="/temp/data" />
   </parameters>
  </s_data_provider>
    <map_tile_server>
     <tile_storage default_root_path="/tilecache/"/>
   </map_tile_server>
  <map_data_source name="mvdemo"
           jdbc_host="localhost"
           jdbc_sid="orcl"
           jdbc_port="1521"
           jdbc_user="mvdemo2"
           jdbc_password="QJtCtefPmSgV/Yf2V3fTMu6C/54HyL60"  
           jdbc_mode="thin"
           number_of_mappers="3"
           allow_jdbc_theme_based_foi="false"
   />
 <map_data_source name="mvdemo"
           container_ds="jdbc/mvdemo2"
           number_of_mappers="8"
           allow_jdbc_theme_based_foi="false"
           editable="false"
   />
 <map_data_source name="storm"
           jdbc_host="localhost"
           jdbc_sid="orcl"
           jdbc_port="1521"
           jdbc_user="storm"
           jdbc_password="KS66/tDP4taqvV96P8u8LGxv/mU+/gly"  
           jdbc_mode="thin"
           number_of_mappers="3"
           allow_jdbc_theme_based_foi="false"
   />
 <map_data_source name="storm"
           container_ds="jdbc/storm"
           number_of_mappers="8"
           allow_jdbc_theme_based_foi="false"
           editable="false"
   />
 </MapperConfig>


- Press on save and restart button which is at the end of the config
- go to http://localhost:8080/mvdemo/ and you will done!




Monday 23 September 2013

How to read write NTS external storage files format on MAC


Download the trial version of this application tuxera-ntfs-for-mac
And use one of the following product key to activate it

J0M1H-37VYL-YEVNK-VFVM5

visit this site to check new keys 

Wednesday 4 September 2013

android GridView inside ScrollView

Use the following class and enjoy :)

package com.alameentech.android.apps.tv_guide;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.GridView;

//public class NestedGridView extends GridView implements OnTouchListener, OnScrollListener  {

public class NestedGridView extends GridView {
boolean expanded = true;

public NestedGridView(Context context) {
super(context);
}

public NestedGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public NestedGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public boolean isExpanded() {
return expanded;
}

@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// HACK! TAKE THAT ANDROID!
if (isExpanded()) {
// Calculate entire height by providing a very large height hint.
// View.MEASURED_SIZE_MASK represents the largest height possible.
int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);

ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

public void setIsExpanded(boolean expanded) {
this.expanded = expanded;
}


}

android ListView inside ScrollView

Use this class 


package com.alameentech.android.apps.tv_guide;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.view.View.OnTouchListener;
import android.widget.AbsListView.OnScrollListener;;

public class NestedListView extends ListView implements OnTouchListener, OnScrollListener {

    private int listViewTouchAction;
    private static final int MAXIMUM_LIST_ITEMS_VIEWABLE = 99;

    public NestedListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        listViewTouchAction = -1;
        setOnScrollListener(this);
        setOnTouchListener(this);
    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {
        if (getAdapter() != null && getAdapter().getCount() > MAXIMUM_LIST_ITEMS_VIEWABLE) {
            if (listViewTouchAction == MotionEvent.ACTION_MOVE) {
                scrollBy(0, -1);
            }
        }
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int newHeight = 0;
        final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
        int heightSize = MeasureSpec.getSize(heightMeasureSpec);
        if (heightMode != MeasureSpec.EXACTLY) {
            ListAdapter listAdapter = getAdapter();
            if (listAdapter != null && !listAdapter.isEmpty()) {
                int listPosition = 0;
                for (listPosition = 0; listPosition < listAdapter.getCount()
                        && listPosition < MAXIMUM_LIST_ITEMS_VIEWABLE; listPosition++) {
                    View listItem = listAdapter.getView(listPosition, null, this);
                    //now it will not throw a NPE if listItem is a ViewGroup instance
                    if (listItem instanceof ViewGroup) {
                        listItem.setLayoutParams(new LayoutParams(
                                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
                    }
                    listItem.measure(widthMeasureSpec, heightMeasureSpec);
                    newHeight += listItem.getMeasuredHeight();
                }
                newHeight += getDividerHeight() * listPosition;
            }
            if ((heightMode == MeasureSpec.AT_MOST) && (newHeight > heightSize)) {
                if (newHeight > heightSize) {
                    newHeight = heightSize;
                }
            }
        } else {
            newHeight = getMeasuredHeight();
        }
        setMeasuredDimension(getMeasuredWidth(), newHeight);
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (getAdapter() != null && getAdapter().getCount() > MAXIMUM_LIST_ITEMS_VIEWABLE) {
            if (listViewTouchAction == MotionEvent.ACTION_MOVE) {
                scrollBy(0, 1);
            }
        }
        return false;
    }

}



  <com.alameentech.android.apps.tv_guide.NestedListView
                    android:id="@+id/lv_channels"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:cacheColorHint="#00000000"
                    android:divider="@drawable/line_sparator_0"
                    android:scrollbars="none"
                    android:dividerHeight="2dp" >
  </com.alameentech.android.apps.tv_guide.NestedListView>



Monday 2 September 2013

Shrink Database Log File

USE [MeAndCultureDB]
GO

-- Truncate the log by changing the database recovery model to SIMPLE.

ALTER DATABASE [MeAndCultureDB]
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE ('WhoWantsToBeMillionaireQs_log' , 100)
GO
-- Reset the database recovery model.
ALTER DATABASE [MeAndCultureDB]
SET RECOVERY FULL;
GO

Thursday 2 May 2013

Display divs side by side in asp and css


Just change the float property to right or left for the child div and display property to inline-block for the parent div, see the example below


<div style="width: 960px; position: relative; display: inline-block;">
        <div style="width: 320px; float: right; background-color: #00FFFF;">
            <br />
            Mohammad
            <br />
        </div>
        <div style="width: 320px; float: right; background-color: #C0C0C0;">
            <br />
            Mohammad
            <br />
        </div>
        <div style="width: 320px; float: right; background-color: #008080;">
            <br />
            Mohammad
            <br />
        </div>
    </div>


Wednesday 24 April 2013

HTML Horizontal Scroll List

<div>
  <ul style="width: 900px; display: block; white-space: nowrap; overflow: auto; list-style-type: none;">
     <li style="display: inline-block;">
       <asp:LinkButton runat="server" ID="linkBtn1" Text="Link Button "></asp:LinkButton>
     </li>
     <li style="display: inline-block;">
       <asp:LinkButton runat="server" ID="linkBtn1" Text="Link Button "></asp:LinkButton>
     </li>

     <li style="display: inline-block;">
       <asp:LinkButton runat="server" ID="linkBtn1" Text="Link Button "></asp:LinkButton>
     </li>

     

               
  </ul>
</div>


Monday 1 April 2013

Sunday 31 March 2013

android: View Html and JavaScript in WebView


WebView htmlWebView = (WebView) findViewById(R.id.webView1);     

try {
     htmlWebView.getSettings().setPluginState(PluginState.ON);
   //presentationWebView.getSettings().setPluginsEnabled(true);
     htmlWebView.getSettings().setJavaScriptEnabled(true);
     htmlWebView.getSettings().setLoadWithOverviewMode(true);
     htmlWebView.getSettings().setAllowFileAccess(true);      
     htmlWebView.loadUrl("file:///android_asset/htmldatat/index.html");  
     htmlWebView.setWebViewClient(new WebViewClient(){
              @Override                public boolean shouldOverrideUrlLoading(WebView view, String url)      

             {
                return false;
                    }
           });
    htmlWebView.getSettings().setBuiltInZoomControls(true);                         

} catch (Exception e) {
     e.printStackTrace();
}

Thursday 21 March 2013

Android ems

It is the width of the letter M in a given english font size. So 2em is twice the width of the letter M in this given font. In font differ from english it is the width of the widest letter in this font, this width is different size in pixels then the width size of the M in the english font but it is still 1em. So if I use text with 12sp in english font 1em is relative to this 12sp english font, using Italian font with 12sp gives 1em that is differ in pixels width then the english one.

Monday 18 March 2013