Sunday, July 31, 2022

Different Ogranaization

 Phone No used to register in Multiple organizations.


SELECT distinct l.PhoneNo FROM MemberPortal_Bulk l

INNER JOIN(

SELECT OrgID, PhoneNo,count(*) Noof 

FROM MemberPortal_Bulk group by OrgID, PhoneNo

having count(*)>1) noof on l.PhoneNo=noof.PhoneNo

where l.OrgID!=noof.OrgID

express js

 express js 



Passport.js

Tuesday, July 26, 2022

Git Commands

 


Add a new file in git local repo as stagged

#########################################

$ git add.


Check stagged status

####################

$ git status --short


Committing changes

#################

$ git commit -a -m "YOUR_COMMENT"



Pull/Update/Latest to git repo

##############################

$ git pull


Push to git repo

#################

$ git push



Scheduler using worker Service

 Dot Net CORE Worker Services. 

.NET Core 3.0 - The New Way to Create Services

Download Source Code


Video

Thursday, July 21, 2022

Bulk insert in a table From Different Server C# code

 C# Code for data collection from different servers.

it will get a list of server credentials from a table. This table contains the source server login credentials.




in c# asp.net there will be a foreach loop and it will execute the operations.


 foreach (var v in List_Members)

                {

                     

                    string connectionString = @"Data Source=" + v.ServerIP + ";Initial Catalog=" + v.DatabaseName + ";User ID=" + v.User + ";Password=" + v.Password  ;

 

                    var ServerIP = @"192.192.192.188\MSSQLSERVER2016";

                    var DatabaseName = "gBankerSMSDb";

                    var User = "gBanker6";

                    var Password = "gBanker6";


                    string csDest = @"Data Source=" + ServerIP + ";Initial Catalog=" + DatabaseName + ";User ID=" + User + ";Password=" + Password;



                    // Create source connection

                    SqlConnection source = new SqlConnection(connectionString);

                    // Create destination connection

                    SqlConnection destination = new SqlConnection(csDest);


                    // Clean up destination table. Your destination database must have the

                    // table with schema which you are copying data to.

                    // Before executing this code, you must create a table BulkDataTable

                    // in your database where you are trying to copy data to.


                    //SqlCommand cmd = new SqlCommand("DELETE FROM MemberPortal_Bulk", destination);

                    SqlCommand cmd = new SqlCommand("SELECT 1 ", destination);

                    // Open source and destination connections.

                    source.Open();

                    destination.Open();

                    cmd.ExecuteNonQuery();

                    // Select data from Products table

                    cmd = new SqlCommand(@"SELECT TOP 5000 * FROM MemberPortal", source);

                    // Execute reader

                    SqlDataReader reader = cmd.ExecuteReader();

                    // Create SqlBulkCopy

                    SqlBulkCopy bulkData = new SqlBulkCopy(destination);

                    // Set destination table name

                    bulkData.DestinationTableName = "MemberPortal_Bulk";

                    // Write data

                    bulkData.WriteToServer(reader);

                    // Close objects

                    bulkData.Close();

                    destination.Close();

                    source.Close();

                }


This code will keep adding data in 192.192.192.188\MSSQLSERVER2016 server. Keep adding data in MemberPortal_Bulk Table database gBankerSMSDb

Tuesday, July 19, 2022

Access in Different Database

 Collect Data from different databases. 



-- use gBankerSMSDb



DECLARE @Counter INT , @MaxId INT

Declare @db table(DataBaseID int,DBNAME varchar(50))

Insert into @db

SELECT dbid  DataBaseID,DB_NAME(dbid) DBNAME

FROM

    sys.sysprocesses

WHERE 

    dbid > 0

and DB_NAME(dbid) not in('master','msdb','tempdb','model','distribution')

and left(DB_NAME(dbid),1)<>'R'

group by dbid;


SELECT  @Counter = min(DataBaseID) , @MaxId = max(DataBaseID) 

FROM @db

WHILE(@Counter IS NOT NULL

      AND @Counter <= @MaxId)

BEGIn

Declare @vDataBaseName varchar(60), @MaxMemberId bigint;



select @vDataBaseName=DBNAME from @db where DataBaseID=@Counter


 exec ('insert into MemberPortal([MemberID], [MemberCode], [MemberName], [RefereeName], [PhoneNo], [SmartCard], [OtherID], [NationalID], [OrgID], [UnionCode], [BirthDate], [CreateUser], [CreateDate], [DBID]

)

select [MemberID], [MemberCode],FirstName [MemberName], [RefereeName], [PhoneNo], [SmartCard],OtherIdNo [OtherID], [NationalID], [OrgID], [UnionCode], [BirthDate], [CreateUser], [CreateDate],'+@Counter+' [DBID]

 from '+ @vDataBaseName +'.dbo.member'

 )

 exec ('SELECT'+ @MaxMemberId + '= MAX(MemberId) FROM'+  @vDataBaseName +'.dbo.member')


 IF Exists( SELECT 1 FROM MemberPortalMaxID WHERE OrgName = @vDataBaseName )

 BEGIN

UPDATE MemberPortalMaxID SET MaximumMemberId = @MaxMemberId WHERE OrgName = @vDataBaseName

 END 

 ELSE

 BEGIN

INSERT INTO MemberPortalMaxID 

( [MaximumMemberId]

      ,[OrgName]

      ,[isActive]

      ,[UpdateDate]

  ) VALUES (@MaxMemberId, @vDataBaseName, 1, GETDATE());


 END


SET @Counter  = @Counter  + 1        

END



--select * from DemographicRegion

Tuesday, July 5, 2022

None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'

 


Need to register forcefully. In App_Start folder file Bootstrapper register the new created service forcefully.

Add this line.

  builder.RegisterType<UltimateReportServiceMemberPortal>().As<IUltimateReportServiceMemberPortal>().InstancePerRequest();




 

Screen Record

 Windows Screen Record WindowsKey+ Alt + R Recording Starts.