Saturday 21 January 2017

create and install window service in c# step by step


Why a Windows Service?

One of the most common requirements of some businesses is long-running scheduled jobs based on some time interval. For example: sending a newsletter everyday afternoon or send an email alert to the customer for every one hour.

So building a Windows Service could be one of the reliable solutions to do the goal that can do the required job in the behind the scenes without interfering others users on the same computer.

it is copy from below link,
please refer for more details


http://www.c-sharpcorner.com/UploadFile/naresh.avari/develop-and-install-a-windows-service-in-C-Sharp/

how to create task scheduler in c#

Console Application Using Windows Scheduler


How to do it
As in the preceding scenario we can have multiple solutions for that:
  1. Create a Windows Service, implement your logic and a set timer.
  2. Create a console application and implement your logic, then create a scheduler and refer action as console application .exe file.
  3. Any third-party scheduler like Quartz scheduler.
Here we will explain use of a console application with the Windows Scheduler.



http://www.c-sharpcorner.com/UploadFile/manas1/console-application-using-windows-scheduler/

VS 2012 can't load project which uses IIS with custom binding host - thinks it's using IIS Express

Opening as an Administrator didn't fix the problem for me. What fixed it for me was opening both the .csproj and csproj.user files and ensuring that both had UseIISExpress set to false.
In my case, the .csproj.user file was overriding the .csproj file event though SaveServerSettingsInUserFile was marked false.
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <UseIISExpress>false</UseIISExpress>
    <!-- ... -->
</Project>

Friday 20 January 2017

StructureMap.StructureMapBuildPlanException: Unable to create a build plan for concrete type

You did not made your constructor parameterless

select option in cell template in angular js

cellTemplate: '<select class="form-control" required ng-options="(item ? \'Create new records in GiftWorks\' : \'Do not create new records in GiftWorks\') for item in [true, false]" ng-model="row.entity.CreateDonor"></select>'
  

Wednesday 11 January 2017

filter in angularjs

$scope.myEmployeeList= $filter('filter')($scope.myEmployeeList, { isActive: true });

It will return only all the active employees

state in angularjs

$state.go('abc', { name: $scope.yourObjerct});

do not forget to mention $state as a dependency

Tuesday 10 January 2017

Unique constraint on multiple columns


ALTER TABLE [dbo].EmpTable
ADD CONSTRAINT ucEmpTable UNIQUE (OrganizationId, ApplicationType, CreatedById)

Wednesday 4 January 2017

Entities in 'Y' participate in the 'FK_Y_X' relationship. 0 related 'X' were found. 1 'X' is expected

I think you did not  make optional relation ship in mapping.
you should make Hasoptional
example

1 -Correct

  HasOptional(t => t.Y)
                .WithMany(t => t.X)
                .Map(a => a.MapKey("YId"));




2-Incorrect


HasRequired(t => t.Y)
                .WithMany(t => t.X)
                .Map(a => a.MapKey("YId"));

drop default constraint in sql

DECLARE @ObjectName NVARCHAR(100)
DECLARE @table_name NVARCHAR(100)
SELECT @ObjectName = default_constraints.name, @table_name = tables.name
FROM
sys.all_columns
    INNER JOIN
sys.tables
    ON all_columns.object_id = tables.object_id
    INNER JOIN
sys.schemas
    ON tables.schema_id = schemas.schema_id
 INNER JOIN
sys.default_constraints
    ON all_columns.default_object_id = default_constraints.object_id
WHERE
schemas.name = 'dbo'
AND tables.name = 'Appeal'
AND all_columns.name = 'AppealGuid'
EXEC ('ALTER TABLE '+@table_name+' DROP CONSTRAINT ' + @ObjectName)

Tuesday 3 January 2017

how to serialize object in c#

 var contactListObj = new ContactList
            {
                Name = emailServicesListDto.Name,
                Status = emailServicesListDto.Status.ToString(),
                CreatedDate = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture),
                ModifiedDate = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture),
                ContactCount = 0
            };
            var contactList = JsonConvert.SerializeObject(contactListObj);//new JavaScriptSerializer().Serialize(contactList);