filter attribute that checks whether current connection is secured

using APS.net Core to mark all website pages working with https protocol
we will do this using IAuthorizationFilter.
and here is an example how we can do it.
/// <summary>
    /// Represents a filter attribute that checks whether current connection is secured and properly redirect if necessary
    /// </summary>
    public class HttpsRequirementAttribute : TypeFilterAttribute
    {
        #region Fields

        private readonly SslRequirement _sslRequirement;

        #endregion

        #region Ctor

        /// <summary>
        /// Create instance of the filter attribute
        /// </summary>
        /// <param name="sslRequirement">Whether the page should be secured</param>
        public HttpsRequirementAttribute(SslRequirement sslRequirement) : base(typeof(HttpsRequirementFilter))
        {
            this._sslRequirement = sslRequirement;
            this.Arguments = new object[] { sslRequirement };
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets a value indicating whether the page should be secured
        /// </summary>
        public SslRequirement SslRequirement => _sslRequirement;

        #endregion

        #region Nested filter

        /// <summary>
        /// Represents a filter confirming that checks whether current connection is secured and properly redirect if necessary
        /// </summary>
        private class HttpsRequirementFilter : IAuthorizationFilter
        {
            #region Fields

            private SslRequirement _sslRequirement;
            private readonly WebsiteSettings _websiteSettings;
            private readonly IWebHelper _webHelper;
            private readonly SecuritySettings _securitySettings;

            #endregion

            #region Ctor

            public HttpsRequirementFilter(SslRequirement sslRequirement,
                WebsiteSettings websiteSettings,
                IWebHelper webHelper,
                SecuritySettings securitySettings)
            {
                this._sslRequirement = sslRequirement;
                this._websiteSettings = websiteSettings;
                this._webHelper = webHelper;
                this._securitySettings = securitySettings;
            }

            #endregion

            #region Utilities

            /// <summary>
            /// Check whether current connection is secured and properly redirect if necessary
            /// </summary>
            /// <param name="filterContext">Authorization filter context</param>
            /// <param name="useSsl">Whether the page should be secured</param>
            protected void RedirectRequest(AuthorizationFilterContext filterContext, bool useSsl)
            {
                //whether current connection is secured
                var currentConnectionSecured = _webHelper.IsCurrentConnectionSecured();

                //page should be secured, so redirect (permanent) to HTTPS version of page
                if (useSsl && !currentConnectionSecured && _websiteSettings.SslEnabled)
                    filterContext.Result = new RedirectResult(_webHelper.GetThisPageUrl(true, true), true);

                //page shouldn't be secured, so redirect (permanent) to HTTP version of page
                if (!useSsl && currentConnectionSecured)
                    filterContext.Result = new RedirectResult(_webHelper.GetThisPageUrl(true, false), true);
            }

            #endregion

            #region Methods

            /// <summary>
            /// Called early in the filter pipeline to confirm request is authorized
            /// </summary>
            /// <param name="filterContext">Authorization filter context</param>
            public void OnAuthorization(AuthorizationFilterContext filterContext)
            {
                if (filterContext == null)
                    throw new ArgumentNullException(nameof(filterContext));

                if (filterContext.HttpContext.Request == null)
                    return;

                //only in GET requests, otherwise the browser might not propagate the verb and request body correctly
                if (!filterContext.HttpContext.Request.Method.Equals(WebRequestMethods.Http.Get, StringComparison.InvariantCultureIgnoreCase))
                    return;

                if (!DataSettingsManager.DatabaseIsInstalled)
                    return;

                //check whether this filter has been overridden for the Action
                var actionFilter = filterContext.ActionDescriptor.FilterDescriptors
                    .Where(filterDescriptor => filterDescriptor.Scope == FilterScope.Action)
                    .Select(filterDescriptor => filterDescriptor.Filter).OfType<HttpsRequirementAttribute>().FirstOrDefault();

                var sslRequirement = actionFilter?.SslRequirement ?? _sslRequirement;

                //whether all pages will be forced to use SSL no matter of the passed value
                if (_securitySettings.ForceSslForAllPages)
                    sslRequirement = SslRequirement.Yes;

                switch (sslRequirement)
                {
                    case SslRequirement.Yes:
                        //redirect to HTTPS page
                        RedirectRequest(filterContext, true);
                        break;
                    case SslRequirement.No:
                        //redirect to HTTP page
                        RedirectRequest(filterContext, false);
                        break;
                    case SslRequirement.NoMatter:
                        //do nothing
                        break;
                    default:
                        throw new PasException("Not supported SslRequirement parameter");
                }
            }

            #endregion
        }

        #endregion
    }
this will do it.

Create, bind and register as service the specified configuration parameters

supposed you have a json file with a specific parameter and you want to fill a class with the specified properties.

and then register this object to the asp.net core service  collection
here is an example how to do it.
/// Create, bind and register as service the specified configuration parameters
        /// </summary>
        /// <typeparam name="TConfig">Configuration parameters</typeparam>
        /// <param name="services">Collection of service descriptors</param>
        /// <param name="configuration">Set of key/value application configuration properties</param>
        /// <returns>Instance of configuration parameters</returns>
        public static TConfig ConfigureStartupConfig<TConfig>(this IServiceCollection services, IConfiguration configuration) where TConfig : class, new()
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            //create instance of config
            TConfig config = new TConfig();

            //bind it to the appropriate section of configuration
            configuration.Bind(config);

            //and register it as a service
            services.AddSingleton(config);

            return config;
        }
this will do it.

Run exe file from console application

To run a .exe file using console application you need to do the following.

Process proc = new Process();
proc.StartInfo.WorkingDirectory = _filePath;
proc.StartInfo.FileName = _fileName;
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();

How to Authenticate from Azure

First you need to create a section in appsettings.json file
  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "Your Domain",
    "TenantId": "Your Tenant Id",
    "ClientId": "Your Client Id",
    "CallbackPath": "/signin-oidc"
  }
then I usually use extension method for the service collection
public static void AddApplicationAuthentication(this IServiceCollection services)
        {
            IConfiguration Configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>();

            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
                .AddAzureAD(options => Configuration.Bind("AzureAd", options));
        }
this should do the trick

How to get months names based on Culture Info

To get the month names using a given Culture Info in a simple select list

var monthOfBirthValues = new List();
monthOfBirthValues.Add(new SelectListItem 


    Text = CultureInfo.GetCultureInfo("ar-KW").DateTimeFormat.GetMonthName(i), 
   Value = i.ToString(CultureInfo.InvariantCulture) 
});

How to make html pre tag responsive

If you have a textbox and you want your user to enter multi-text.
it will work fine if you changed your textbox from input to textarea

but there is a small issue how can i present it on desktop and mobile devices.

I'm using MVC in my presentation layer. 

@Html.Raw("<div class='divpre' style='margin-right: -20px;'><pre class='pre'>" + Html.Encode(@Model.Desc) + "</pre><div>")

now the css
1- desktop
.pre
{
  word-break: break-word;
  white-space: pre-wrap;
  text-align: justify;
  overflow-x: hidden;
 }
2- mobile
@media only screen and (max-width: 600px)
.pre
{
  word-break: break-word!important;
  white-space: pre-line;
  overflow: hidden;
}

Visual Studio Cannot access a disposed object. Object name: 'WorkspaceContext' TFS

problem: I have a simple project hosted on our company TFS. our security policy required the development team change there passwords every 1 month.
after changing my password, I recived this error while check In TFS
Cannot access a disposed object. Object name: 'WorkspaceContext'
solution:
You need to visit this location
%LocalAppData%\Microsoft\Team Foundation\7\Cache
inside this location delete the content of this folder and try to connect again to visual studio.

Stop Visual Studio from debugging method or class

Sometimes you need to step through code, So you use debugging in Visual Studio.
But some other times you visit the same method over and over again for 100 times

if and only if the code is tested.
then you can do decorate your method with this attribute  [DebuggerStepThrough()] and your debugger will never hit this method again


List all files in a dirctory and subdirectory contains substring

Open cmd
go to main directory

type the following command.
dir /b /s "PAS*.cs"
this will list all files begin with PAS (uper or lower) case and any set of characters and ends with .cs

visual studio 2017 search and replace regular expressions group

Sometimes you write some codes and then you find your self want to change a suffix or prefix in your codes or classes names or namespaces

I will show with an example how to do it.

 let us supposed we need to change the following "Manager" sub-string into the class name
public interface IParticipantImageManager
in visual studio click on ctrl + shift + H use any website to test your regular expression, personally I use regex101 to write the right expression and the replace it.


to find the string
IParticipantImage(\w+)
and to replace the sting
IParticipantImage$1

Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'

I already posted another post today about solving Visual Studio 2018 Stuck at 'preparing solution'  
If you follow the same solution you will be able to build your solution.

Visual Studio 2018 Stuck at 'preparing solution'

Visual Studio 2018  stuck after lunching specific solution. after spending sometime on the internet,
I found the problem and the fix.

I used Community Edition for visual studio 2018.

1- Close all running instances of Visual Studio 2017
2- Launch the Visual Studio 2017 Developer Command Prompt as Admin
3- Type the following commands (replace Community with your edition, either Enterprise or Professional , or adjust the path accordingly):

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Engine.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Conversion.Core.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Utilities.Core.dll"

Entityframework Oracle.ManagedDataAccess.Client.OracleException: 'ORA-01950: no privileges on tablespace 'USERS''

I used EF to connect to Oracle database and  I received the following error
Oracle.ManagedDataAccess.Client.OracleException: 'ORA-01950: no privileges on tablespace 'USERS''
In my case the connection string has invalid value.
the user password was typed wrong.


EntityFramework Oracle.ManagedDataAccess.Client.OracleException: 'ORA-01918: user 'dbo' does not exist'

While trying to use code first approach to connect to Oracle database using ASP NET C#.
I received the following exception
Oracle.ManagedDataAccess.Client.OracleException: 'ORA-01918: user 'dbo' does not exist'
My current User Is IT_USER
The Reason for the error is that Oracle tried to create my tables which are in my first migration into dbo schema as SQL Server do, but in Oracle it is a User.

So you need to till Entity Framework where is my Table Should be
You have two solutions

First is to use DbModelBuilder.HasDefaultSchema
This will make all of your tables in this schema.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.HasDefaultSchema("IT_USER"); 
    base.OnModelCreating(modelBuilder);
}

Second is to use System.ComponentModel.DataAnnotations.Schema.Table
This will give you the ability to change the schema when ever you want
[Table("STD_FA_VALIDATION", Schema ="IT_USER")] 
public class STD_FA_VALIDATION
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    public int SGBSTDN_PIDM { get; set; }
    public string NAT_CHANGE_IND { get; set; }
    public string WORK_IND { get; set; }
    public DateTime NAT_PROC_DATE { get; set; }
    public DateTime WORK_PROC_DATE { get; set; }
 }

Remote Desktop Error terminal server has exceeded the maximum number of allowed connections

I already posted a script to connect throw Cisco VPN Client using patch file.
and the patch connected direct to a remote desktop connection.

some times the connection failed with this error.
"Remote Desktop Error terminal server has exceeded the maximum number of allowed connections"
you need to change
mstsc /v:192.168.80.145
to
mstsc /admin /v:192.168.80.145

Remove duplicates from javascript array

To remove duplicates from JavaScript array.
you can use the following javaScript function, you need JQuery to be able to run this function

distinct: function (anArray) {
        var result = [];
        $.each(anArray, function (i, v) {
            if ($.inArray(v, result) === -1) result.push(v);
        });
        return result;
    }

Remove duplicate options from HTML Select

Some times you get the options from database by ajax duplicated.
The following JavaScript function should do the trick.
You need JQuery to make it work.

dropdown_remove_repeated: function () {
        var $selects = $('select');
        $selects.each(function () {
            var $select = $(this);

            var $options = $select.find('option');

            $options.each(function () {
                var $option = $(this);
                $option.siblings().each(function () {
                    var $this = $(this);
                    if ($this.text().trim() === $option.text().trim()) {
                        $this.remove();
                    }
                });
            });
        });
    }

How to call webservice from PLSQL

The object of this article is to show how to call webservice from PLSQL
and thanks for Oracle to provide such a thing

I'm using a local webservice
http://localhost/PAAET.asmx
I have a collection of functions inside this webservice. one of them is GetStudentInfo
when we request the service function on the web browser
http://localhost/PAAET.asmx?op=GetStudentInfo
we will use the service response and request over SOAP 1.2
Request:
<soap12:envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap12:body>
    <getstudentinfo xmlns="http://127.0.0.1:8080/">
      <wvcivno>string</wvcivno>
    </getstudentinfo>
  </soap12:body>
</soap12:envelope>

Response : 
<soap12:envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap12:body>
    <GetStudentInfoResponse xmlns="http://127.0.0.1:8080/">
      <GetStudentInfoResult>
        <pv_arab_name_1>string</pv_arab_name_1>
      </getstudentinforesult>
    </getstudentinforesponse>
  </soap12:body>
</soap12:envelope>
Now let's take about what you will do inside the PLSQL

  1. login to DB as sysdba this is a must.

  2. /* Formatted on 9/26/2018 1:26:58 AM (QP5 v5.163.1008.3004) */ BEGIN DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (ACL => 'paci.xml',
     DESCRIPTION => 'Test Sample ACL',
     PRINCIPAL => 'IT_REG_DBA',  -- user to access the service it must be capital letters
     IS_GRANT => TRUE,
     PRIVILEGE => 'connect');

     DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE (ACL => 'paci.xml',
     PRINCIPAL => 'IT_REG_DBA', IS_GRANT => TRUE,
     PRIVILEGE => 'resolve');

     DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (ACL => 'paci.xml',
     HOST => '127.0.0.1'); -- ip address of the service
    END;

    COMMIT;
  3. make sure the file has been added to the database
    SELECT any_path FROM resource_view WHERE any_path like '%.xml';
  4. Grant Execution for the user
    GRANT EXECUTE ON UTL_HTTP TO IT_REG_DBA;
  5. Now execute this PLSQL Code
    /* Formatted on 9/26/2018 1:46:49 AM (QP5 v5.163.1008.3004) */
    DECLARE
       L_HTTP_REQUEST          UTL_HTTP.REQ;

       L_HTTP_RESPONSE         UTL_HTTP.RESP;

       L_BUFFER_SIZE           NUMBER (10) := 512;

       L_LINE_SIZE             NUMBER (10) := 50;

       L_LINES_COUNT           NUMBER (10) := 20;

       L_STRING_REQUEST        VARCHAR2 (512);

       L_LINE                  VARCHAR2 (128);

       L_SUBSTRING_MSG         VARCHAR2 (512);

       L_RAW_DATA              RAW (512);

       L_CLOB_RESPONSE         CLOB;

       L_HOST_NAME             VARCHAR2 (128) := 'http://localhost'; -- the service url

       L_CIVILID               VARCHAR2 (12) := '283030306556'; -- the service parameter

       L_RESP_XML              XMLTYPE;

       L_RESULT_XML_NODE       VARCHAR2 (128);

       L_NAMESPACE_SOAP        VARCHAR2 (128)
          := 'xmlns="http://www.w3.org/2003/05/soap-envelope"';

       L_RESPONSE_FIRSTNAME    VARCHAR2 (128);                       -- first name

       L_RESPONSE_SECONDNAME   VARCHAR2 (128);                      -- second name

       L_RESPONSE_THIRDNAME    VARCHAR2 (128);                       -- third name

       L_RESPONSE_LASTNAME     VARCHAR2 (128);                        -- last name
    BEGIN
       L_STRING_REQUEST :=
          '<?xml version="1.0" encoding="utf-8"?>

    <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">

    <soap12:Body>

    <GetStudentInfo xmlns="http://127.0.0.1:8080/">

    <WVCIVNO>'
          || L_CIVILID
          || '</WVCIVNO>

    </GetStudentInfo>

    </soap12:Body>

    </soap12:Envelope>';

       UTL_HTTP.SET_TRANSFER_TIMEOUT (10);

       L_HTTP_REQUEST :=
          UTL_HTTP.BEGIN_REQUEST (URL => 'http://localhost/PAAET.asmx' -- COMPLETE SERVICE URL
                                                                      , METHOD => 'POST', HTTP_VERSION => 'HTTP/1.1');

       UTL_HTTP.SET_HEADER (L_HTTP_REQUEST, 'User-Agent', 'Mozilla/4.0');

       UTL_HTTP.SET_HEADER (L_HTTP_REQUEST, 'Connection', 'close');

       UTL_HTTP.SET_HEADER (L_HTTP_REQUEST,
                            'Content-Type',
                            'application/soap+xml; charset=utf-8');

       UTL_HTTP.SET_HEADER (L_HTTP_REQUEST,
                            'Content-Length',
                            LENGTH (L_STRING_REQUEST));

      <<REQUEST_LOOP>>
       FOR I IN 0 .. CEIL (LENGTH (L_STRING_REQUEST) / L_BUFFER_SIZE) - 1
       LOOP
          L_SUBSTRING_MSG :=
             SUBSTR (L_STRING_REQUEST, I * L_BUFFER_SIZE + 1, L_BUFFER_SIZE);

          BEGIN
             L_RAW_DATA := UTL_RAW.CAST_TO_RAW (L_SUBSTRING_MSG);

             UTL_HTTP.WRITE_RAW (R => L_HTTP_REQUEST, DATA => L_RAW_DATA);
          EXCEPTION
             WHEN NO_DATA_FOUND
             THEN
                EXIT REQUEST_LOOP;
          END;
       END LOOP REQUEST_LOOP;

       L_HTTP_RESPONSE := UTL_HTTP.GET_RESPONSE (L_HTTP_REQUEST);

       DBMS_OUTPUT.PUT_LINE (
          'Response> status_code: "' || L_HTTP_RESPONSE.STATUS_CODE || '"');

       DBMS_OUTPUT.PUT_LINE (
          'Response> reason_phrase: "' || L_HTTP_RESPONSE.REASON_PHRASE || '"');

       DBMS_OUTPUT.PUT_LINE (
          'Response> http_version: "' || L_HTTP_RESPONSE.HTTP_VERSION || '"');

       BEGIN
         <<RESPONSE_LOOP>>
          LOOP
             UTL_HTTP.READ_RAW (L_HTTP_RESPONSE, L_RAW_DATA, L_BUFFER_SIZE);

             L_CLOB_RESPONSE :=
                L_CLOB_RESPONSE || UTL_RAW.CAST_TO_VARCHAR2 (L_RAW_DATA);
          END LOOP RESPONSE_LOOP;
       EXCEPTION
          WHEN UTL_HTTP.END_OF_BODY
          THEN
             UTL_HTTP.END_RESPONSE (L_HTTP_RESPONSE);
       END;

       IF (L_HTTP_RESPONSE.STATUS_CODE = 200)
       THEN
          -- Create XML type from response text

          L_RESP_XML := XMLTYPE.CREATEXML (L_CLOB_RESPONSE);

          -- Clean SOAP header

          SELECT EXTRACT (L_RESP_XML, 'Envelope/Body/node()', L_NAMESPACE_SOAP)
            INTO L_RESP_XML
            FROM DUAL;

          -- Extract Culture Info value

          DBMS_OUTPUT.PUT_LINE ('Response from PACI webservices:');

          L_RESULT_XML_NODE :=
             '/GetStudentInfoResponse/GetStudentInfoResult/PV_ARAB_NAME_1';

          SELECT EXTRACTVALUE (L_RESP_XML,
                               L_RESULT_XML_NODE,
                               'xmlns="http://127.0.0.1:8080/"')
            INTO L_RESPONSE_FIRSTNAME
            FROM DUAL;
       END IF;

       DBMS_OUTPUT.PUT_LINE ('Civil Id > ' || L_CIVILID);

       DBMS_OUTPUT.PUT_LINE (
             'Full Name > '
          || L_RESPONSE_FIRSTNAME);

       IF L_HTTP_REQUEST.PRIVATE_HNDL IS NOT NULL
       THEN
          UTL_HTTP.END_REQUEST (L_HTTP_REQUEST);
       END IF;

       IF L_HTTP_RESPONSE.PRIVATE_HNDL IS NOT NULL
       THEN
          UTL_HTTP.END_RESPONSE (L_HTTP_RESPONSE);
       END IF;

       COMMIT;
    END;
Now the result of the service will print the first name of the given ssn number  into the screen 

Connect to Cisco VPN Client Using batch file

To connect to the CISCO VPN client throw batch file you need to define the location of the exe file
and then use the connect command on vpnclient.exe

I also connected to my remote server in the same patch file.

@echo off
@echo VPN Connection
set myPATH="C:\Program Files (x86)\Cisco Systems\VPN Client"
cd %myPATH%
vpnclient.exe connect paaet user vpn_username pwd vpn_password
mstsc /v:192.168.80.145
@echo off
@echo VPN if you want to disconnect just hit enter
vpnclient.exe disconnect
@echo off
@echo the vpn disconnected exit

Removing Watermark from Amazing Carousel Version (4.1)

Someone asked me how to remove the Amazing Carousel Version (4.1) water mark from the free edition

Please just download this File and replace it with your old one.

Remove Amazing Slider Watermark (Version 6.7)

Many of you asked about the latest version of Amazing Slider Version 6.7
Just replace amazingslider.js inside sliderengine folder with my file.

Download File

How to create OWA_COOKIE PLSQL

The Oracle Web Agent (OWA) provide the web users with an easy way to send and get cookies throw the browser header using OWA_COOKIE package.
there is two types can be used for OWA_COOKIE
  1. type vc_arr is table of varchar2(4000) index by binary_integer.
  2. type cookie is record (name varchar2(4000),vals vc_arr,num_vals integer); 
  1. Open Header
  2. Send Cookie 
  3. Close Header 
  4. Redirect to another page. 
don't forget to close the header. 

if for some reason you find the cookie value printed into the screen then your document header maybe was opened  and closed before your cookie code. 

BEGIN
OWA_UTIL.MIME_HEADER ('text/html', FALSE);
OWA_COOKIE.SEND (NAME    => 'REGIND',VALUE   => TWBKBSSF.F_ENCODE ('N'));
OWA_UTIL.HTTP_HEADER_CLOSE;
OWA_UTIL.REDIRECT_URL ('xwskstrg.P_RegsAddCrse');
END;
make sure that you encrypt the value of the cookie if it will contain a sensitive data.

Modify AWR Automatic Snapshot Settings

DBA_HIST_WR_CONTROL table shows the AWR snapshot settings.
In this example the retention period is specified as 1 month (43200 minutes) and the interval between each snapshot is 30 minutes.

BEGIN
DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS (INTERVAL => 30,RETENTION => 43200);
END

SELECT * FROM DBA_HIST_WR_CONTROL

After executing  DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS  procedure you can get the AWR Report for each 30 min the hole year.

Unable to create a constant value of type ‘’. Only primitive types or enumeration types are supported in this context.

the problem appears because you are using contains method in non primitive type
here is an example
Audit audit = new Audit();
List<int> ints = userReports.Select(y => y.ReportId).ToList();
List<ReportUserVisit> userReportLastMonthVisit = audit.GetAudit(userId, AuditType.Report)
                .Where(x => ints.Contains((int)x.ObjectId))
                .Select(x=> x.ObjectId)
                .GroupBy(x=>x.Value)
                .Select(x=>new ReportUserVisit { ReportId = x.Key, LastMonthVisitCount= x.Count() })
                .ToList();

note ints object, this will solve the problem.
because ints collection is list of int it can use contains method inside entity framework


How to Get Browser Type

// Opera 8.0+
 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
 // Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// At least Safari 3+: "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
 // Internet Explorer 6-11
 var isIE = /*@cc_on!@*/false || !!document.documentMode;
 // Edge 20+
 var isEdge = !isIE && !!window.StyleMedia;
 // Chrome 1+
 var isChrome = !!window.chrome && !!window.chrome.webstore;
 // Blink engine detection
 var isBlink = (isChrome || isOpera) && !!window.CSS;
 var output = 'Detecting browsers by ducktyping:

'; output += 'isFirefox: ' + isFirefox + '
'; output += 'isChrome: ' + isChrome + '
'; output += 'isSafari: ' + isSafari + '
'; output += 'isOpera: ' + isOpera + '
'; output += 'isIE: ' + isIE + '
'; output += 'isEdge: ' + isEdge + '
'; output += 'isBlink: ' + isBlink + '
'; document.body.innerHTML = output;


Telerik RadGrid layout problem with Visual Studio 2013 'EnableBrowserLink'

While working with Visual Studio 2013 and Telerik RadGrid Control, I saw something so strange,
the RadGrid rendered in a wrong way.
I know my css, I used it before and there was nothing on it wrong. the only different is that I used VS2013 instead of VS2012,
So I searched about this problem.
and here is my search result.
there is some tag can be placed inside the web.config file
-- add this to the web.config file.
<add key="vs:EnableBrowserLink" value="false" />
this will fix the problem.
and here is a complete article about it.
The new Browser Link feature in VS 2013 is causing an error when DetailTable of Hierarchy RadGrid is expanded.

it looks like VS2013 problem, hope Microsoft solve it sooner.

How to remove the watermark from Amazing Slider JQuery lib.

Please find the latest version 6.7 article Here

when I saw it, I said wow, it is awesome, but after using it, there was a watermark on the images,
which make everything looks bad. so i told my self I had to share this with the world. it cost $249

 inside sliderengine folder open amazingslider.js file with any editor and search for this 

text-decoration:none;font:12px Arial,Tahoma,Helvetica,sans-serif;color:#333

 when you find it search for this part

this.options.fvm

on the second time you find it, replace it with '' 
and then save your file. and then reload your html page. there will be no watermark

update :
some of the people are complaining that, this trick is not working for them,
if you already found this part


text-decoration:none;font:12px Arial,Tahoma,Helvetica,sans-serif;color:#333
change it to

text-decoration:none;font:12px Arial,Tahoma,Helvetica,sans-serif;color:#333;display:none;




update for version 5.3:
search for

visibility:visible !important;z-index:999999 !important;



you should locate one, then before this look for wposcss change the display to none

update for version 6.3:
first you need to search for this pattern 
{style:mkdiv.attr("style")+"display:block!important;visibility:visible!important;font-size:12px!important;"}
and then change it with this one  
{style:mkdiv.attr("style")+""}

then search for this pattern 
from the beginning of the js file 
display:block !important;position:absolute;top:6px;left:6px;visibility:visible !important;z-index:999999
and change it to this 
display:none !important;position:absolute;top:6px;left:6px;visibility:visible !important;z-index:999999

save the file and run the html screen 
it should work :) 

How to create Extension method C#

sometimes you need to change an object to another value or to do some calculations on this object.
for example, you had a simple asp.net dropdownlist control and it contains a value for id, and these id's is integers.
so to get the value you need to do something like this
int id = Convert.ToInt32(ddl.SelectedValue);
but what if the SelectedValue was not integer, this will through an .net exception, so you need to write more code, to make sure that the selected value is not empty string. and so on.

so here comes the Extension methods.

the class must be static and the method also must be static and you need to decide which object the method will work on. it can be int, string or even object the parent class for every other classes on .net,

so, I'm gonna stick with the dropdownlist example right now.
namespace Demo
{
    public static class Extension
    {
        public static int ToInt(this string val)
        {
            int d = 0;

            if (!string.IsNullOrEmpty(val.Trim()))
                int.TryParse(val.Trim(), out d);

            return d;
        }
    }
}
as you can see here the namespace is Demo, the class is static and also the method is static.
now how to use it.
using Demo;

string str = "34";
int convertedNum = str.ToInt();
just like this, and the default value will be there, also if there was any error it will be zero.

How to Disable weekends for AjaxToolKit Calendar extender

if you want to disable the weekends for an ajax toolkit calendar
here is the way.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
            Enabled="True" TargetControlID="TextBox1" OnClientShown="DisableWeekends">
        </asp:CalendarExtender>
javascript method
           for (var i = 0; i &lt; 6; i++) {
                var row = sender._days.children[0].childNodes[1].children[i];
                for (var j = 0; j &lt; 7; j++) {
                    var cell = row.children[j].firstChild;

                    if (cell.id == sender._id + "_day_" + i + "_" + "5") {
                        cell.style.display = "none";
                    }
                    if (cell.id == sender._id + "_day_" + i + "_" + "6") {
                        cell.style.display = "none";
                    }
                }
            }

Jquery FadeOut table row not working with Internet Explorer

JQuery is write less and do more, we all know that
I have a simple table row and I want to use the fadeOut effect on this row, it is working over all the browsers  except the Internet Explorer "for sure :)"

so I try to find out the problem and whats wrong with Internet Explorer
till I understand this
I have to effect on each child 'cells' of the row before the row it self


var $tr = $(this).parent().parent();

$tr.parent().children().each(function () {
                                $(this).fadeOut('slow');
                            }).fadeOut('slow');

Reset Identity column in SQL Server

If you need for some reason to reset the identity column of the sql server
this will do it

DBCC CHECKIDENT('tableName', RESEED, 0)

zero here means the count will begin from 1 

Resolving the error: "The terminal server has exceeded the maximum number of allowed connections"

I try to log in to a server and there was a message
here is how to work around this message



To do this, simply type the following in a Start -> Run or Command Prompt.


mstsc /v:00.00.00.00 /admin 


Replace 00.00.00.00 with your server's IP Address.

Getting Mime types and file extensions from registry using C#

If you have a mime type and you want to find the default extension for this mime type, you can get this from the following registry key
HKEY_CLASSES_ROOT\MIME\Database\Content Type\<mime type>

public static string GetDefaultExtension(string mimeType)
{
  string result;
  RegistryKey key;
  object value;
  key = Registry.ClassesRoot.OpenSubKey("MIME\Database\Content Type\" + mimeType, false);
  value = key != null ? key.GetValue("Extension", null) : null;
  result = value != null ? value.ToString() : string.Empty;
  return result;
}

on the other hand, if you have the file extension and you want the mime type of this extension
HKEY_CLASSES ROOT\<extension>

public static string GetMimeTypeFromExtension(string extension)
{
  string result;
  RegistryKey key;
  object value;
  if (!extension.StartsWith("."))
    extension = "." + extension;
  key = Registry.ClassesRoot.OpenSubKey(extension, false);
  value = key != null ? key.GetValue("Content Type", null) : null;
  result = value != null ? value.ToString() : string.Empty;
  return result;
}

and this is all :) 

filter attribute that checks whether current connection is secured

using APS.net Core to mark all website pages working with https protocol we will do this using IAuthorizationFilter. and here is an exampl...