[DataMember(Name = "g7")] public DateTime DateEffectiveIn { get { if (Environment.MachineName != StationCreatedAt && _readCount == 0) { RegenerateServerDate(); //calling the function here _readCount++; } return _dateEffectiveIn; } set { _dateEffectiveIn = value; } } public void RegenerateServerDate() { if (ServerDateTimeSource != string.Empty) { string connetionString = ConfigurationManager.ConnectionStrings["abcString"].ConnectionString; SqlConnection connection ; SqlCommand command ; connection = new SqlConnection(connetionString); connection.Open(); command = new SqlCommand("usp_GetUTCDate_Select", connection); command.CommandType = CommandType.StoredProcedure; DateTime DateUtc = command.ExecuteScalar(); //only one data returned command.Dispose(); connection.Close(); this.DateEffectiveIn = DateUtc; this.DateCreated = DateUtc; this.DateLastModified = DateUtc; } else { DateTime dateTime = DateHelper.ConvertToUtc(DateTime.Now); this.DateEffectiveIn = dateTime; this.DateCreated = dateTime; this.DateLastModified = dateTime; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)