Friday, March 13, 2020

Manually Remove the Dependency DLL

https://stackoverflow.com/questions/34147484/unable-to-restore-remove-update-a-nuget-package-because-the-mentioned-versio
https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform

Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -Version 2.0.1

You can manually remove the dependency by:
  1. Close Visual Studio (not a hard requirement, but helpful)
  2. In text editor, remove dependency from packages.config
  3. Remove package from packages/ directory
  4. In text editor, remove all references to package from .csproj file
  5. Start Visual Studio
  6. Reinstall package through NuGet

Tuesday, December 10, 2019

c# Challenges

https://www.csharpstar.com/csharp-program-to-calculate-factorial/

First Reverse
Description: For this challenge you will be reversing a string.
Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order. For example: if the input string is "Hello World and Coders" then your program should return the string sredoC dna dlroW olleH.
Examples
Input: "coderbyte"
Output: etybredoc

 using System;

class MainClass {
  public static string FirstReverse(string str) {
   
    string reverse = String.Empty;
 
    for (int i = str.Length - 1; i >= 0; i--)
    {
        reverse += str[i];
    }
    return reverse;
         
  }

  static void Main() {
    // keep this function call here
    Console.WriteLine(FirstReverse(Console.ReadLine()));
  }
 
}

Input: "I Love Code"
Output: edoC evoL I


First Factorial
Description: For this challenge you will be determining the factorial for a given number.
Have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it. For example: if num = 4,
then your program should return (4 * 3 * 2 * 1) = 24. For the test cases, the range will be between 1 and 18 and the input will always be an integer.

using System;

class MainClass {
 
  public static int FirstFactorial(int num) {
    var result = 1;
    for(var i = num; i > 1; i--){
        result *= i;
    }
    return result;
  }

  static void Main() {
    // keep this function call here
    Console.WriteLine(FirstFactorial(Console.ReadLine()));
  }
 
}
Input: 4
Output: 24

Longest Word
Description: For this challenge you will be determining the largest word in a string.

Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string.
If there are two or more words that are the same length, return the first word from the string with that length.
Ignore punctuation and assume sen will not be empty.
using System;
using System.Linq;

class MainClass {
  public static string LongestWord(string sen) {

    string[] words = sen.Split(' ');


    return words.OrderByDescending( s => s.Length ).First();;
         
  }

  static void Main() {
    // keep this function call here
    Console.WriteLine(LongestWord(Console.ReadLine()));
  }
 
}
Input: "I love dogs"
Output: love



Simple Adding
Description: For this challenge you will be adding up all the numbers from 1 to a certain argument.
Have the function SimpleAdding(num) add up all the numbers from 1 to num.
 For example: if the input is 4 then your program should return 10 because 1 + 2 + 3 + 4 = 10.
 For the test cases, the parameter num will be any number from 1 to 1000.
 using System;

class MainClass {
  public static int SimpleAdding(int num) {

    // code goes here
 
    int start = 0;
    for (int i = 1; i < num+1;i++){
     
        start = start + i;
    }
 
    num = start;
    return num;
         
  }

  static void Main() {
    // keep this function call here
    Console.WriteLine(SimpleAdding(Console.ReadLine()));
  }
 
}
Input: 12
Output: 78

Letter Capitalize
Description: For this challenge you will be capitalizing certain characters in a string.
using System;
using System.Globalization;

class MainClass {
  public static string LetterCapitalize(string str) {

    TextInfo myTI = new CultureInfo("en-US",false).TextInfo;
    return myTI.ToTitleCase(str);
 
  }

  static void Main() {
    // keep this function call here
    Console.WriteLine(LetterCapitalize(Console.ReadLine()));
  }
 
}

Input: "hello world"
Output: Hello World

Word Count
Description: For this challenge you will be determining how many words a sentence contains.
Have the function WordCount(str) take the str string parameter being passed and return the number of words the string contains (e.g. "Never eat shredded wheat or cake" would return 6). Words will be separated by single spaces.
Examples
Input: "Hello World"
Output: 2

using System;
using System.Collections.Generic;
using System.Linq;

class MainClass {
  public static int WordCount(string str) {

    var inputString = str.Split(' ');
    int WordCount = 0;
    foreach (var s in inputString)
    {
        WordCount++;
    }

    return WordCount;
         
  }

  static void Main() {
    // keep this function call here
    Console.WriteLine(WordCount(Console.ReadLine()));
  }
 
}

Palindrome String
static void Main(string[] args)
{
    string _inputstr, _reversestr = string.Empty;
    Console.Write("Enter a string : ");
    _inputstr = Console.ReadLine();
    if (_inputstr != null)
    {
        for (int i = _inputstr.Length - 1; i >= 0; i--)
        {
            _reversestr += _inputstr[i].ToString();
        }
        if (_reversestr == _inputstr)
        {
            Console.WriteLine("String is Palindrome Input = {0} and Output= {1}", _inputstr, _reversestr);
        }
        else
        {
            Console.WriteLine("String is not Palindrome Input = {0} and Output= {1}", _inputstr, _reversestr);
        }
    }
    Console.ReadLine();
}

Reverse Polish notation / Post-fix notation

image.png
using System;
using System.Collections;
using System.Text.RegularExpressions;

class MainClass
{    
    static void Main()
    {
        string result = Evaluate("2 12 + 7 /");
        Console.WriteLine("Reverse Polish notation output : " + result);
        Console.ReadLine();
    }  

    public static string Evaluate(string postfixExpression)
    {
        Regex _operandRegex = new Regex(@"-?[0-9]+");
        Regex _operatorRegex = new Regex(@"[+\-*\/]");

        var tokens = new Stack();
        string[] rawTokens = postfixExpression.Split(' ');
        foreach (var t in rawTokens)
        {
            if (_operandRegex.IsMatch(t))
                tokens.Push(t);
            else if (_operatorRegex.IsMatch(t))
            {
                var t1 = tokens.Pop().ToString();
                var t2 = tokens.Pop().ToString();
                var op = t;

                var result = EvaluateSingleExpression(t2, t1, op);
                if (result != null)
                    tokens.Push(result);
            }
        }
        if (tokens.Count > 0)
            return tokens.Pop().ToString();

        return "";
    }


    private static string EvaluateSingleExpression(string value1, string value2, string strOperator)
    {
        var operand1 = Convert.ToDouble(value1);
        var operand2 = Convert.ToDouble(value2);

        switch (strOperator)
        {
            case "+":
                var plusRsult = operand1 + operand2;
                return Convert.ToString(plusRsult);
            case "-":
                var minusRsult = operand1 - operand2;
                return Convert.ToString(minusRsult);
            case "/":
                var divisionRsult = operand1 / operand2;
                return Convert.ToString(divisionRsult);
            case "*":
                var multiplicationRsult = operand1 / operand2;
                return Convert.ToString(multiplicationRsult);
            default:
                Console.WriteLine("An unexpected value");
                break;
        }
        return null;
    }

}


Monday, March 11, 2019

.NET Core

https://www.talkingdotnet.com/asp-net-core-interview-questions/.
https://www.youtube.com/watch?v=u2S4TkkACVc



.Net Core
.Net Framework
Library
.Net Core Libraries
.Net Framework Libraries
Replace
appsettings.json
Startup.cs
ConfigurationBuilder


Web.Config
global.asax
ConfigurationManager

Windows Form
Windows Form Application

XAML based Universal Windows apps



Monday, July 2, 2018

Malaysia


 

Mohammad Nazmul Huda Rubol Chowdhury

T2-13A-06-01, icon city, Jalan no.1 , sungai way, petaling jaya, Selangor.
Postal: 47300
Telephone : +60178855673
Rubol30@gmail.com

Wednesday, February 14, 2018

Oracle

Oracle SQL Functions

https://www.tutorialspoint.com/oracle_sql_online_training/index.asp

https://www.youtube.com/user/completeitpro/playlists

Oracle WITH clause

https://www.youtube.com/watch?v=t5P-yS1R3qQ


WITH sample_data AS
(
SELECT 'DEVELOPMENT' A, 1 k, 18 w, 397 c, 0 r FROM dual UNION ALL
SELECT 'HT' A, 43 k, 21 w, 673 c, 0 r FROM dual UNION ALL
SELECT 'LT' A, 83 k, 14 w, 7955 c, 60 r FROM dual 
)
   -- end of sample_data mimicking real table
SELECT t.*, k+w+c+r total FROM sample_data t;

https://stackoverflow.com/questions/35860050/oracle-grand-total-row-and-column-wise
PIVOT
https://community.oracle.com/thread/3950818?start=0&tstart=0


Derived Table
https://www.youtube.com/watch?v=FwcAkH8UyEA&list=PL08903FB7ACA1C2FB&index=48

CTE (common table expressions)

With EmployeeCount (Column names are Optional)



Pivot

Unpivot

Calculating a Grand Total for a Column

https://docs.oracle.com/cd/E57185_01/RAFWU/ch07s07s06s01.html

Oracle DECODE Function
 https://www.youtube.com/watch?v=JzNv8RnEJ3A

Derived tables and common table expressions :
 https://www.youtube.com/watch?v=FwcAkH8UyEA&list=PL08903FB7ACA1C2FB&index=48


Table:
1.       lu_day  2. v_aggr_process_testassy 3. lu_model_mfgid
Relation
select *  FROM       v_aggr_process_testassy v1 INNER JOIN lu_model_mfgid l2
ON v1.mfgid = l2.mfgid  AND v1.deid=l2.deid
INNER JOIN lu_day v2
 ON v1.asmdate = v2.day_id
Keyword
Round :

decode and case:
The Oracle/PLSQL DECODE function has the functionality of an IF-THEN-ELSE statement.
DECODE (expression, search, result [, search, result]... [,default] )
SELECT first_name, country, DECODE(country, 'USA', 'North America', 'UK', 'Europe', 'Other') AS Decode_Result  FROM customers;
SELECT DECODE(NULL, NULL, 1, 0) FROM DUAL;
 CASE statement allows you to perform an IF-THEN-ELSE check within an SQL statement.
SELECT first_name, last_name, country,
CASE
  WHEN country = 'USA' THEN 'North America'
  WHEN country = 'Canada' THEN 'North America'
  WHEN country = 'UK' THEN 'Europe'
  WHEN country = 'France' THEN 'Europe'
  ELSE 'Unknown'
END Continent
FROM customers
ORDER BY first_name, last_name;



Thursday, August 24, 2017

Application SQL

String formatted = String.Format("({0}) {1}-{2}", phoneNo.Substring(0, 3), phoneNo.Substring(3, 3), phoneNo.Substring(6, 4));




public IEnumerable<CcCensusUploadHistory> GetAllCensusUploadHistoryByDataTypeIDAllocation(int allocationNumber, int dataTypeID)
        {
            return base.UnitOfWork.Db.Fetch<CcCensusUploadHistory>(@"SELECT ccCensusUploadHistory.ccStatusID, ccCensusUploadHistory.censusUploadDate , ccCensusUploadHistory.censusfilePath, ccCensusUploadHistory.Version, ccCensusUploadHistory.Category,ccCensusUploadHistory.Description,ccCensusUploadHistory.censusFileName, ccCensusUploadHistory.FinalizedBy, ccStatus.PlanID, ccStatus.[allocationNumber]
  FROM(ccCensusUploadHistory INNER JOIN ccStatus ON ccCensusUploadHistory.ccStatusID = ccStatus.ccStatus_ID)  INNER JOIN AllocationDataRequests ON(ccStatus.allocationNumber = AllocationDataRequests.AllocationNumber) AND(ccStatus.planID = AllocationDataRequests.PlanNumber)
                                                                        WHERE ccStatus.[allocationNumber] = @0
                                                                        AND AllocationDataRequests.[DataTypeID] = @1", allocationNumber , dataTypeID);

        }    




ALTER PROCEDURE [dbo].[Pr_CaseDetails] @CaseId int  
AS

SELECT C.CaseID, P.PlanName
                FROM  tblCase C
LEFT JOIN PlanAccount P on P.PlanNumber =C.PlanNumber
WHERE C.CaseID = @CaseId



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

ALTER PROCEDURE [dbo].[pr_un_project_GetAllocationDataItemList]
-- Add the parameters for the stored procedure here
  @ProjectID int,
  @userName nvarchar(50)
--, @max int

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

IF NOT EXISTS (SELECT * FROM AllocationDataRequests WHERE ProjectID = @ProjectID AND DataTypeID = 1)
BEGIN
INSERT Into AllocationDataRequests (AllocationNumber, PlanNumber, PlanClientNumber, ClientNumber, DataTypeID, DataRequestStatus,
ProjectTypeID, ProjectID, CreatedBy, DateCreated, PlanName, Recordkeeper)
SELECT Project.ProjectID, PlanAccount.PlanNumber, PlanAccount.PlanClientNumber, PlanAccount.ClientNumber, 1 AS DataItem,
Case when PlanAccount.[CensusRequired]=1  then 'Not Requested' else 'Not Required' end AS DataItemStatus, 4 as ProjectTypeID,
Project.ProjectID as ProjectID,
@userName, Getdate(), PlanAccount.PlanName, r.RecordkeeperProduct
FROM PlanAccount INNER JOIN Project ON PlanAccount.PlanNumber = Project.AccountID and Project.ProjectTypeID=4
Inner Join Recordkeeper r On PlanAccount.Recordkeeper=r.RecordkeeperNumber
WHERE Project.ProjectID = @ProjectID
END

Monday, January 30, 2017

Cursor with Function

DECLARE @result INT
     EXEC master.dbo.xp_fileexist '\\sharebear\client_project_folders\453064052\Allocations\Rony.txt', @result OUTPUT
Select @result

USE [TPAManager_be]
GO
/****** Object:  UserDefinedFunction [dbo].[fc_FileExists]    Script Date: 1/30/2017 05:40:20 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fc_FileExists](@path varchar(8000))
RETURNS BIT
AS
BEGIN
     DECLARE @result INT
     EXEC master.dbo.xp_fileexist @path, @result OUTPUT
     RETURN cast(@result as bit)
END;


-----------------------CURSOR---ForEach Loop------------
DECLARE cur_savings CURSOR FOR
Select FilePathID,ProjectID,FilePath  from ProjectFile where AccountID=453064052 and ProjectID=50752 and WebAccess=1

DECLARE @ProjectID int,@AccountID int,@strSql VARCHAR(4000),@Path varchar(200),@cmd varchar(1000)
OPEN cur_savings

FETCH NEXT FROM cur_savings INTO @AccountID,@ProjectID,@Path

WHILE @@FETCH_STATUS = 0
BEGIN

--create table #File(AccountID Int,ProjectID Int,FileExist Bit)

insert #File
Select @AccountID,@ProjectID,dbo.[fc_FileExists] (@Path)

   FETCH NEXT FROM cur_savings  INTO @AccountID,@ProjectID,@Path
END

CLOSE cur_savings
DEALLOCATE cur_savings
GO


Select * from #File where FileExist=0