Exemple #1
0
        /// <summary>
        /// method to get azure table storage object instance
        /// </summary>
        /// <param name="TableName"></param>
        /// <returns>Azure Table Instance</returns>
        public static CloudTable GetAzureTableInstance(String TableName)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                // Retrieve the storage account from the connection string.
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["GenericMobileStorageConnectionString"]);
                // Create the table client.
                CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
                // set retry for the connection for transient failures
                tableClient.DefaultRequestOptions = new TableRequestOptions
                {
                    RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(5), 3)
                };
                // Create the CloudTable object that represents the table.
                CloudTable table = tableClient.GetTableReference(TableName);
                return(table);
            }

            catch (Exception innerexception)
            {
                InsightLogger.Exception(innerexception.Message, innerexception, "Retrieveentity");
                throw new DataAccessException(innerexception.Message, innerexception.InnerException);
            }
        }
        /// <summary>
        /// method to caliculate physical size of request object
        /// </summary>
        /// <param name="backendrequest">takes request as input</param>
        /// <returns>returns size of request object</returns>
        public int CalculateRequestSize(BackendRequest backendrequest)
        {
            //Get Caller Method name
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //converting object to stream
                using (Stream stream = new MemoryStream())
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    //converting stream to binary formatter to get size
                    formatter.Serialize(stream, backendrequest);
                    return(Convert.ToInt32(stream.Length));;
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                //write exception into application insights
                InsightLogger.Exception(exception.Message + " - Error in BL while caliculating request size", exception, callerMethodName);
                throw new BusinessLogicException();
            }
        }
Exemple #3
0
        public static void AddEntities <T>(string tablename, List <T> entitieslist) where T : ITableEntity, new()
        {
            //Get Caller Method name
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //get's azure table instance
                CloudTable          ArchivalTable  = GetAzureTableInstance(tablename);
                TableBatchOperation batchOperation = new TableBatchOperation();
                //insert list of entities into batch operation
                foreach (T entity in entitieslist)
                {
                    batchOperation.InsertOrReplace(entity);
                    if (batchOperation.Count == 100)
                    {
                        ArchivalTable.ExecuteBatch(batchOperation);
                        batchOperation = new TableBatchOperation();
                    }
                }
                if (batchOperation.Count > 0)
                {
                    ArchivalTable.ExecuteBatch(batchOperation);
                }
            }
            catch (Exception exception)
            {
                //write exception into application insights
                InsightLogger.Exception(exception.Message + " - Error in DataProver while adding entities to " + tablename, exception, callerMethodName);
                throw new Exception();
            }
        }
Exemple #4
0
        public static void RemoveEntities <T>(string tablename, List <T> entitieslist) where T : ITableEntity, new()
        {
            //Get Caller Method name
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //get's azure table instance
                CloudTable          transactionTable = GetAzureTableInstance(tablename);
                TableBatchOperation batchOperation   = new TableBatchOperation();
                //insert list of entities into batch operation
                foreach (T entity in entitieslist)
                {
                    batchOperation.Add(TableOperation.Delete(entity));
                }
                transactionTable.ExecuteBatch(batchOperation);
            }
            catch (Exception exception)
            {
                //write exception into application insights
                InsightLogger.Exception(exception.Message + " - Error in DataProver while removing entity from " + tablename, exception, callerMethodName);
                throw new Exception();
            }
        }
Exemple #5
0
        /// <summary>
        /// method to get single userdevice
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <param name="userDeviceID">takes user device id as input</param>
        /// <returns>returns user device with id associated to user in the form of personalization response</returns>
        public PersonalizationResponseDTO <UserDeviceDTO> GetUserDevice(string userID, string userDeviceID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserDeviceDAL    userdevicedal    = new UserDeviceDAL();
                UserDeviceEntity userdeviceentity = userdevicedal.GetUserDevice(userID, userDeviceID);
                //converting userdevice entity to Response data transfer object
                var ResponseUserDevice = new PersonalizationResponseDTO <UserDeviceDTO>();
                if (userdeviceentity != null)
                {
                    UserDeviceDTO userdevicedto = UserDeviceEntityDTOMapper(userdeviceentity);
                    ResponseUserDevice.result = userdevicedto;
                }
                else
                {
                    ResponseUserDevice.result = null;
                }
                return(ResponseUserDevice);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while retreiving single userdevice: "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #6
0
        /// <summary>
        /// method to get requests per userbackend
        /// </summary>
        /// <param name="UserID">takes userid as input</param>
        /// <param name="backendID">takes backendid as input</param>
        /// <returns>returns list of requets associated userbackend</returns>
        public List <RequestEntity> GetUserBackendRequests(string UserID, string backendID, string requeststatus)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                string partitionkeyfilter = TableQuery.GenerateFilterCondition(CoreConstants.AzureTables.PartitionKey, QueryComparisons.Equal, string.Concat(CoreConstants.AzureTables.RequestsPK, UserID));
                string backendfilter      = TableQuery.GenerateFilterCondition(CoreConstants.AzureTables.BackendId, QueryComparisons.Equal, backendID);
                //combine partionkey filter with backend filter
                string combinefilter = TableQuery.CombineFilters(partitionkeyfilter, TableOperators.And, backendfilter);
                //request status filter
                string statusfilter = TableQuery.GenerateFilterCondition(CoreConstants.AzureTables.Status, QueryComparisons.Equal, requeststatus);
                //final filter to get requests based on partitionkey, backendid, request status
                string finalfilter = TableQuery.CombineFilters(combinefilter, TableOperators.And, statusfilter);
                //generate query to get all user associated requests
                TableQuery <RequestEntity> query = new TableQuery <RequestEntity>().Where(combinefilter);
                //call dataprovider method to get entities from azure table
                List <RequestEntity> allrequests = DataProvider.GetEntitiesList <RequestEntity>(CoreConstants.AzureTables.RequestTransactions, query);
                return(allrequests);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error while retrieving requests per userbackend from RequestTransactions azure table in DAL : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new DataAccessException();
            }
        }
Exemple #7
0
        /// <summary>
        /// method to get fields for request
        /// </summary>
        /// <param name="requestID">takes requestid as input</param>
        /// <returns>returns list of fields</returns>
        public List <FieldDTO> GetFields(string requestID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                SynchDAL synchDAL = new SynchDAL();
                //calling data access layer method
                List <FieldEntity> fieldsentitylist = synchDAL.GetFields(requestID);
                List <FieldDTO>    fileds           = new List <FieldDTO>();
                //loop through fields list entity to convert to fields dto
                foreach (FieldEntity field in fieldsentitylist)
                {
                    FieldDTO fielddto = DataProvider.ResponseObjectMapper <FieldDTO, FieldEntity>(field);
                    fileds.Add(fielddto);
                }
                return(fileds);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting fields per request : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #8
0
        /// <summary>
        /// method to check user availability
        /// </summary>
        /// <param name="UserID">takes userid as input</param>
        /// <returns>returns true if user exists else false</returns>
        public Boolean CheckUser(string UserID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                PersonalizationDAL personalizationdal = new PersonalizationDAL();
                //calling data access layer method
                UserEntity user = personalizationdal.GetUser(UserID);
                //if user exists return true
                if (user != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while checking user existance : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #9
0
        /// <summary>
        /// method to delete single userbackend
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <param name="userBackendID">takes user backend id as input</param>
        /// <returns>returns deleted user backend entity</returns>
        public UserBackendEntity DeleteUserBackend(string userID, string userBackendID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserBackendDAL userbackenddal = new UserBackendDAL();
                //calling data access layer method
                UserBackendEntity userbackendentity = userbackenddal.DeleteUserBackend(userID, userBackendID);
                return(userbackendentity);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while deleting single userbackend : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #10
0
        /// <summary>
        ///method to remove userbackends
        /// </summary>
        /// <param name="UserID">takes userid as input</param>
        public void RemoveBackends(string UserID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserBackendDAL userbackenddal = new UserBackendDAL();
                //to get all backends associated to user
                List <UserBackendEntity> alluserbackends = userbackenddal.GetUserAllBackends(UserID);
                if (alluserbackends != null && alluserbackends.Count > 0)
                {
                    //calling data access layer method to remove user backends
                    userbackenddal.RemoveBackends(alluserbackends);
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while removing userbackends : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #11
0
        /// <summary>
        /// Update next collecting time for each backend
        /// </summary>
        public void UpdateNextCollectingTime(bool IsFirstTime)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //get's azure table instance
                CloudTable UserDeviceConfigurationTable = DataProvider.GetAzureTableInstance(azureTableUserDeviceConfiguration);
                //Get all backends
                List <BackendEntity> lstbackends  = objdal.GetBackends();
                DateTime             curTimestamp = DateTime.Now;
                //for each backend get minimum update frequency for all the userbackend's associated
                //foreach(BackendEntity backend in lstbackends)
                Parallel.ForEach <BackendEntity>(lstbackends, backend =>
                {
                    InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: set next collecting time (Rule R1) :: start() , Response :: Backend Name : " + backend.BackendID);
                    string backendID = backend.RowKey;
                    //Get all the userbackends associated with the backend
                    TableQuery <UserBackendEntity> tquery    = new TableQuery <UserBackendEntity>().Where(TableQuery.GenerateFilterCondition(CoreConstants.AzureTables.RowKey, QueryComparisons.Equal, backend.RowKey));
                    List <UserBackendEntity> allUserBackends = UserDeviceConfigurationTable.ExecuteQuery(tquery).ToList();
                    int minUpdateFrequency = 0;
                    if (allUserBackends != null && allUserBackends.Count > 0)
                    {
                        minUpdateFrequency = allUserBackends.Min(r => r.DefaultUpdateFrequency);
                    }
                    //get minimum update frequency from User Backend list

                    //InsightLogger.TrackEvent("UpdateTriggering, Action :: Collecting the minimum Default Update Frequency of all the userbackends under the backend :" + backendID + " , Response :: Minimum Update Frquency :" + minUpdateFrequency );
                    //Get next collecting hours based on update Triggering Rule :: R1
                    int nextCollectingTimeInMinutes;
                    if (minUpdateFrequency < defaultMinUpdateFrequency)
                    {
                        nextCollectingTimeInMinutes = defaultMinUpdateFrequency;
                    }
                    else
                    {
                        nextCollectingTimeInMinutes = minUpdateFrequency / nextCollectingTimeDividend;
                    }
                    //update backend next collecting time in refernecedata table
                    this.InsertorUpdateBackendNextCollectingTime(backendID, nextCollectingTimeInMinutes, backend.AverageAllRequestsLatency, backend.LastAllRequestsLatency, IsFirstTime, curTimestamp);
                    InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: Set next collecting time (Rule R1) :: End() , Response :: Success, Backend Name : " + backend.BackendID);
                    // this.objdal.CollectUsersNeedUpdateByBackend(backendID);
                });
            }
            catch (BusinessLogicException balexception)
            {
                throw balexception;
            }
            catch (DataAccessException dalexception)
            {
                throw dalexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                throw new DataAccessException(exception.Message, exception.InnerException);
            }
        }
Exemple #12
0
        /// <summary>
        /// update regular Next CollectingTime of the backend
        /// </summary>
        /// <param name="backendID"></param>
        /// <param name="minimumUpdateFrequency"></param>
        /// <param name="LastCollectingTime"></param>
        public void UpdateBackendRegularNextCollectingTime(string backendID, int minimumUpdateFrequency, DateTime LastCollectingTime)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                // Create a retrieve operation that takes a NextUserCollectingTime Entity.
                NextUserCollectingTimeEntity ObjUpdateNextCollectingTime = DataProvider.RetrieveEntity <NextUserCollectingTimeEntity>(azureTableReference, CoreConstants.AzureTables.UpdateTriggerNextCollectingTime, backendID);
                if (ObjUpdateNextCollectingTime != null)
                {
                    //update the existing entity
                    DateTime nextCollectingTime = LastCollectingTime.AddMinutes(minimumUpdateFrequency);
                    //update  lastCollectingTime  with previous NextCollectingTime
                    ObjUpdateNextCollectingTime.RegularUpdateLastCollectingTime = LastCollectingTime;
                    //update  NextCollectingTime value based on new MinimumUpdateFrequency,last collecting Time
                    ObjUpdateNextCollectingTime.RegularUpdateNextCollectingTime = nextCollectingTime;
                    // Execute update operation.
                    DataProvider.UpdateEntity <NextUserCollectingTimeEntity>(azureTableReference, ObjUpdateNextCollectingTime);
                    InsightLogger.TrackEvent("UpdateTriggering, Action :: Set next collecting time , Response :: Success, backend :[ " + backendID + " ]");
                }
            }
            catch (DataAccessException dalexception)
            {
                throw dalexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                throw new DataAccessException(exception.Message, exception.InnerException);
            }
        }
Exemple #13
0
        /// <summary>
        /// method to get list of backends associated to user
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <returns>returns list of userbackends</returns>
        public List <UserBackendEntity> GetUserBackendsList(string userID, List <string> userbackends)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //if userbackendid's not provided get all associated backends to user by default
                if (userbackends != null)
                {
                    SynchDAL synchdDAL = new SynchDAL();
                    //calling data access layer method
                    return(synchdDAL.GetUserAllBackends(userID, userbackends));
                }
                else
                {
                    UserBackendDAL userbackenddal = new UserBackendDAL();
                    return(userbackenddal.GetUserAllBackends(userID));
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting userbackend list per user : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #14
0
        public void RemoveExistingFields(string requestid)
        {
            //Get Caller Method name
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //generate query to retrive existing fileds
                TableQuery <FieldEntity> query = new TableQuery <FieldEntity>().Where(TableQuery.GenerateFilterCondition(CoreConstants.AzureTables.PartitionKey, QueryComparisons.Equal, string.Concat(CoreConstants.AzureTables.FieldPK, requestid)));
                //call dataprovider method to get entities from azure table
                List <FieldEntity> existingfields = DataProvider.GetEntitiesList <FieldEntity>(CoreConstants.AzureTables.RequestTransactions, query);
                //call dataprovider method to remove entities from azure table
                if (existingfields != null && existingfields.Count > 0)
                {
                    DataProvider.RemoveEntities(CoreConstants.AzureTables.RequestTransactions, existingfields);
                }
            }
            catch (Exception exception)
            {
                //write exception into application insights
                InsightLogger.Exception(exception.Message + " - Error while removing existing fields into requestTransactions azure table in DAL", exception, callerMethodName);
                throw new DataAccessException();
            }
        }
Exemple #15
0
        public static void UpdateNextCollectingTime()
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                ////Create object for NextUserCollectingTime class
                bool IsFirstTime = true;
                NextUserCollectingTimeDAL objdal = new NextUserCollectingTimeDAL();
                //call the UpdateNextCollectingTime method which will update the Next Collecting Time of the each backend
                objdal.UpdateNextCollectingTime(IsFirstTime);
            }
            catch (DataAccessException dalexception)
            {
                //write data layer exception into application insights
                InsightLogger.Exception(dalexception.Message, dalexception, callerMethodName);
            }
            catch (Exception exception)
            {
                //write exception into application insights
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
            }
        }
Exemple #16
0
        /// <summary>
        /// method to delete user details
        /// </summary>
        /// <param name="UserID">takes userid as input</param>
        /// <returns>returns deleted user entity</returns>
        public UserEntity DeleteUser(string UserID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                PersonalizationDAL personalizationdal = new PersonalizationDAL();
                //calling data access layer method
                UserEntity deleteuser = personalizationdal.DeleteUser(UserID);
                return(deleteuser);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while deleting user : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #17
0
        /// <summary>
        /// This method updates all the backends next collecting time in Azure Referencedata table
        /// This method triggered based on given time interval(i.e MyDailyScheduleForUpdateNextCollectingTime)
        /// it is scheduled by every hour
        /// </summary>
        public static void ForEachBackendSetNextCollectingTime([TimerTrigger(typeof(MyDailyScheduleForUpdateNextCollectingTime))] TimerInfo timerInfo, TextWriter log)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                bool IsFirstTime = false;
                ////Create object for NextUserCollectingTime class
                NextUserCollectingTimeDAL objdal = new NextUserCollectingTimeDAL();
                //call the UpdateNextCollectingTime method which will update the Next Collecting Time of the each backend
                objdal.UpdateNextCollectingTime(IsFirstTime);
                // InsightLogger.TrackEndEvent(callerMethodName);
            }
            catch (DataAccessException dalexception)
            {
                //write exception message to web job dashboard logs
                //log.WriteLine(dalexception.Message);
                //write data layer exception into application insights
                InsightLogger.Exception(dalexception.Message, dalexception, callerMethodName);
            }
            catch (Exception exception)
            {
                //log.WriteLine("Error in adidas.clb.job.UpdateTriggering :: Functions :: UpdateNextCollectingTimeForAllBackends() :: Exception Message=" + exception.Message);
                //write exception into application insights
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
            }
        }
Exemple #18
0
        /// <summary>
        /// This method generates time intervals based on given minutes time span
        /// </summary>
        /// <param name="minutesTimespan"></param>
        /// <returns></returns>
        public static string[] GetTimeIntervals(int minutesTimespan)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //InsightLogger.TrackStartEvent(callerMethodName);
                List <string> lsttimeIntervals = new List <string>();
                int           j = 0;
                for (int i = 0; i <= CoreConstants.TimeIntervals.TotalHours; i++) //hours
                {
                    while (j <= CoreConstants.TimeIntervals.TotalMinutes)         //minutes
                    {
                        lsttimeIntervals.Add(getTimeformat(i, j));
                        j = j + minutesTimespan;
                    }
                    j = 0;
                }
                //InsightLogger.TrackEndEvent(callerMethodName);
                return(lsttimeIntervals.ToArray());
            }
            catch (BusinessLogicException balexception)
            {
                //write  Data Access Exception into application insights
                InsightLogger.Exception(balexception.Message, balexception, callerMethodName);
                throw balexception;
            }
        }
Exemple #19
0
        /// <summary>
        ///  This method create a folder for azcopy.exe in Environment.CurrentDirectory(i.e dubug/ release)
        /// </summary>
        /// <returns></returns>
        public static string GetaZCopypath()
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                string aZCopy             = string.Empty;
                string executableLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string functionsPath      = Path.Combine(executableLocation, "PDFFiles");
                if (!Directory.Exists(functionsPath))
                {
                    Directory.CreateDirectory(functionsPath);
                }
                aZCopy = Path.Combine(functionsPath, "azCopyExePath");
                if (!Directory.Exists(aZCopy))
                {
                    Directory.CreateDirectory(aZCopy);
                }
                //write aZCopy directory path into application insights
                //   InsightLogger.TrackEvent("AzCopy.exe File Path" + aZCopy);
                return(aZCopy);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                throw new BusinessLogicException(exception.Message, exception.InnerException);
            }
        }
Exemple #20
0
        /// <summary>
        /// This method create a folder for image in Environment.CurrentDirectory(i.e dubug/ release)
        /// </summary>
        /// <returns></returns>
        public static string GetImagePath()
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                string imagepath     = string.Empty;
                string functionsPath = Path.Combine(Environment.CurrentDirectory, "PDFFiles");
                if (!Directory.Exists(functionsPath))
                {
                    Directory.CreateDirectory(functionsPath);
                }
                imagepath = Path.Combine(functionsPath, "Images");
                if (!Directory.Exists(imagepath))
                {
                    Directory.CreateDirectory(imagepath);
                }
                //write aZCopy directory path into application insights
                // InsightLogger.TrackEvent("AzCopy.exe File Path" + imagepath);
                return(imagepath);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                throw new BusinessLogicException(exception.Message, exception.InnerException);
            }
        }
Exemple #21
0
        /// <summary>
        /// method to add Request PDF uri to Request entity
        /// </summary>
        /// <param name="urivalue">takes temp blob uri as input</param>
        public void AddPDFUriToRequest(Uri urivalue, string userID, string RequestID)
        {
            //Get Caller Method name
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //call dataprovider method to get entities from azure table
                RequsetEntity updateEntity = DataProvider.Retrieveentity <RequsetEntity>(CoreConstants.AzureTables.RequestTransactions, string.Concat(CoreConstants.AzureTables.RequestsPK, userID), RequestID);
                //check for null
                if (updateEntity != null)
                {
                    // Add the PDFUri.
                    updateEntity.PDFUri = urivalue.ToString();
                    //call dataprovider method to update entity to azure table
                    DataProvider.UpdateEntity <RequsetEntity>(CoreConstants.AzureTables.RequestTransactions, updateEntity);
                }
            }
            catch (Exception exception)
            {
                //write exception into application insights
                InsightLogger.Exception(exception.Message + " - Error while updating request update PDF uri into request entitty in DAL", exception, callerMethodName);
                throw new DataAccessException();
            }
        }
Exemple #22
0
        /// <summary>
        /// method to get count of urgent approvals per userbackend
        /// </summary>
        /// <param name="userid">takes userid as input</param>
        /// <param name="backendid">takes backendid as input</param>
        /// <returns>returns count of urgent approvals per user backend</returns>
        public int GetUrgentApprovalsCount(string userid, string backendid)
        {
            //Get Caller Method name
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //adding filters to get count of open approvals
                string partitionFilter = TableQuery.GenerateFilterCondition(CoreConstants.AzureTables.PartitionKey, QueryComparisons.Equal, string.Concat(CoreConstants.AzureTables.ApprovalPK, userid));
                string rowfilter       = TableQuery.GenerateFilterCondition(CoreConstants.AzureTables.BackendId, QueryComparisons.Equal, backendid);
                string statusfilter    = TableQuery.GenerateFilterConditionForDate(CoreConstants.AzureTables.DueDate, QueryComparisons.LessThanOrEqual, DateTime.Today);
                string finalFilter     = TableQuery.CombineFilters(TableQuery.CombineFilters(partitionFilter, TableOperators.And, rowfilter), TableOperators.And, statusfilter);
                //selecting only few columnas as we are just caliculating count of urgent approvals
                TableQuery <ApprovalEntity> query = new TableQuery <ApprovalEntity>()
                {
                    SelectColumns = new List <string>()
                    {
                        CoreConstants.AzureTables.PartitionKey, CoreConstants.AzureTables.BackendId
                    }
                }.Where(finalFilter);
                //call dataprovider method to get entities from azure table
                List <ApprovalEntity> urgentaprovals = DataProvider.GetEntitiesList <ApprovalEntity>(CoreConstants.AzureTables.RequestTransactions, query);
                return(urgentaprovals.Count);
            }
            catch (Exception exception)
            {
                //write exception into application insights
                InsightLogger.Exception(exception.Message + " - Error while getting urgent approvals count in DAL", exception, callerMethodName);
                throw new DataAccessException();
            }
        }
Exemple #23
0
        public void TestCallerInformation()
        {
            string tracelog = new CallerInformation().ReturnCallerInformation();

            Assert.AreEqual(tracelog.Length > 0, true);
            Assert.AreEqual(tracelog, @"TestCallerInformation - C:\deepak\CSDemo\CSTry\CSTryTest\CSTryTest\CsTry_5Test.cs - 21");
        }
Exemple #24
0
        private void UpdateStack()
        {
            _callLocations.Clear();

            // Add instruction pointer first
            DocumentLocation currentLoc = _debugger.GetAddressLocation(_debugger.CPU.PC);

            _callLocations.Add(new DocumentLocation(currentLoc.FileName, currentLoc.LineNumber - 1));

            callStackView.Rows.Clear();
            var dataGridViewRows = new List <DataGridViewRow>();

            foreach (var call in _debugger.CallStack.Reverse())
            {
                var row = new DataGridViewRow();

                CallerInformation callerInformation = call.CallerInformation;
                string            callType          = callerInformation.Command + " " + callerInformation.Condition;
                row.CreateCells(callStackView, callType, callerInformation.CallName);
                dataGridViewRows.Add(row);

                currentLoc = call.CallerInformation.DocumentLocation;
                _callLocations.Add(new DocumentLocation(currentLoc.FileName, currentLoc.LineNumber - 1));
            }

            // We added an extra location for the instruction pointer, so add an extra row for the top level call
            var appRow = new DataGridViewRow();

            appRow.CreateCells(callStackView, "Top level", "OS");
            dataGridViewRows.Add(appRow);
            callStackView.Rows.AddRange(dataGridViewRows.ToArray());
        }
Exemple #25
0
        /// <summary>
        /// This method creates the queue client
        /// </summary>
        /// <returns></returns>
        public static CloudQueueClient GetQueueClient()
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                // Parse the connection string and return a reference to the storage account
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["UpdateTriggerAzureQueues"]);

                // Create the queue client.
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
                // set retry for the connection for transient failures
                queueClient.DefaultRequestOptions = new QueueRequestOptions
                {
                    RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(5), 3)
                };
                return(queueClient);
            }
            catch (Exception innerexception)
            {
                InsightLogger.Exception(innerexception.Message, innerexception, "Retrieveentity");
                throw new DataAccessException(innerexception.Message, innerexception.InnerException);
            }
        }
Exemple #26
0
        /// <summary>
        /// method to get all approvals of user
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <returns>reurns list of requests for user</returns>
        public List <ApprovalEntity> GetUserApprovalsForCount(string userID, string approvalstatus)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //if requeststatus is null, get requests with defaultstatus inprogress.
                if (string.IsNullOrEmpty(approvalstatus))
                {
                    approvalstatus = CoreConstants.AzureTables.Waiting;
                }
                SynchDAL synchDAL = new SynchDAL();
                //calling data access layer method
                return(synchDAL.GetUserApprovalsForCount(userID, approvalstatus));
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting all approvals count per user  : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
    public static void Trace(this ILog log, CallerInformation callerInformation, string format, params object[] args)
    {
        Assert.IsNotNull(log, nameof(log));
        Assert.IsNotNull(callerInformation, nameof(callerInformation));
        var message = string.Format(format, args);

        log.Trace(callerInformation, message);
    }
    public static void Trace(this ILog log, CallerInformation callerInformation, string format, params object[] args)
    {
        ArgumentNullException.ThrowIfNull(log, nameof(log));
        ArgumentNullException.ThrowIfNull(callerInformation, nameof(callerInformation));
        var message = string.Format(format, args);

        log.Trace(callerInformation, message);
    }
Exemple #29
0
        /// <summary>
        /// This method triggered based on given time interval(i.e MyDailyScheduleForMissingUpdates)
        /// This method will verifies whether any userbackend(s)/Request(s) missed update or not
        /// if any user(s)/Request(s) misses update then keep the messages into update trigger input queue in UpdateTriggerMsg Format.
        /// </summary>
        public static void CollectMissingUpdates([TimerTrigger(typeof(MyDailyScheduleForMissingUpdates))] TimerInfo timerInfo, TextWriter log)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                // InsightLogger.TrackStartEvent(callerMethodName);
                //foreach backend
                NextUserCollectingTimeDAL objnextcollectingTime = new NextUserCollectingTimeDAL();
                //get all the userbackends needs to update
                List <NextUserCollectingTimeEntity> lstbackends = objnextcollectingTime.GetBackendsNeedsUpdate();

                DateTime currentTimestampForMissedUpdates = DateTime.Now;
                Parallel.ForEach <NextUserCollectingTimeEntity>(lstbackends, backend =>
                {
                    InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect missing updates : start() , Response :: Backend Name : " + backend.BackendID);
                    //getting minutes difference between currenttime and Missing Update Next CollectingTime
                    TimeSpan tspan     = backend.MissingUpdateNextCollectingTime.Subtract(currentTimestampForMissedUpdates);
                    int waitingMinutes = tspan.Minutes;
                    //if minutes difference is with in RegularChecksWaitingTimeInMinutes(>=-8 and <=0) then invoke MissedUpdatesWaitingTimeInMinutes method()
                    if (waitingMinutes >= -(Convert.ToInt32(ConfigurationManager.AppSettings["MissedUpdatesWaitingTimeInMinutes"])) && waitingMinutes <= 0)
                    {
                        UserBackendDAL objUserBackendDAL = new UserBackendDAL();
                        //collects the missed update userbackends,Requests and convert into update trigger message format and put into UT input queue
                        objUserBackendDAL.CollectUsersMissedUpdatesByBackend(backend.BackendID, currentTimestampForMissedUpdates);
                        //update the backend entity with new missing update collecting time[i.e MissingUpdateLastCollectingTime= MissingUpdateNextCollectingTime and MissingUpdateNextCollectingTime=Max(]
                        objnextcollectingTime.UpdateMisseduserBackendNextCollectingTime(backend.BackendID, backend.MissingUpdateNextCollectingTime, DateTime.Now);
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect missing updates : End() , Response :: Success, Backend Name : " + backend.BackendID);
                    }
                    else
                    {
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect missing updates : End(), Response ::  next missing update collecting time of the backend [ " + backend.BackendID + " ] is greater-than to current time.");
                    }
                });
            }
            catch (BusinessLogicException balexception)
            {
                //write exception message to web job dashboard logs
                //log.WriteLine(balexception.Message);
                //write Business Logic Exception into application insights
                InsightLogger.Exception(balexception.Message, balexception, callerMethodName);
            }
            catch (DataAccessException dalexception)
            {
                //write exception message to web job dashboard logs
                //log.WriteLine(dalexception.Message);
                //write Data layer logic Exception into application insights
                InsightLogger.Exception(dalexception.Message, dalexception, callerMethodName);
            }
            catch (Exception exception)
            {
                // log.WriteLine("Error in adidas.clb.job.UpdateTriggering :: Functions :: RegularChecksforUserbackendLostsUpdate() :: Exception Message=" + exception.Message);
                //write  Exception into application insights
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
            }
        }
Exemple #30
0
        /// <summary>
        /// This method triggered based on given time interval(i.e MyDailyScheduleForRegularUpdates)
        /// This method will verifies whether the userbackends needs update or not based on UT RUle ,if it requires update then it will update the userbackend
        /// if any user needs update then  keep the messages into update trigger input queue in UpdateTriggerMsg Format.
        /// </summary>
        public static void CollectUsersNeedsUpdate([TimerTrigger(typeof(MyDailyScheduleForRegularUpdates))] TimerInfo timerInfo, TextWriter log)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();

                NextUserCollectingTimeDAL objnextcollentingTime = new NextUserCollectingTimeDAL();
                //get all the userbackends needs to update
                List <NextUserCollectingTimeEntity> lstbackends = objnextcollentingTime.GetBackendsNeedsUpdate();
                //foreach backend
                DateTime currentTimestamp = DateTime.Now;
                Parallel.ForEach <NextUserCollectingTimeEntity>(lstbackends, backend =>
                {
                    InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect users needing update : start(), Response :: Backend Name : " + backend.BackendID);
                    //getting minutes difference between currenttime and Regular Update Next CollectingTime
                    TimeSpan span = backend.RegularUpdateNextCollectingTime.Subtract(currentTimestamp);
                    int minutes   = span.Minutes;
                    //if minutes difference is with in RegularChecksWaitingTimeInMinutes(>=-5 and <=0) then invoke CollectUsersNeedUpdateByBackend method()
                    if (minutes >= -(Convert.ToInt32(ConfigurationManager.AppSettings["RegularChecksWaitingTimeInMinutes"])) && minutes <= 0)
                    {
                        UserBackendDAL objdal = new UserBackendDAL();
                        //collect the users needing update and keep the messages in update trigger input queue
                        objdal.CollectUsersNeedUpdateByBackend(backend.BackendID, currentTimestamp);
                        //update the backend entity with new collecting time[i.e LastCollectingTime= NextCollectingTime and NextCollectingTime=NextCollectingTime+(Backend MinimumusersUpdateFrequency)/2 ]
                        objnextcollentingTime.UpdateBackendRegularNextCollectingTime(backend.BackendID, backend.MinimumUpdateFrequency, backend.RegularUpdateNextCollectingTime);
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect users needing update : End(), Response :: Success,  Backend Name : " + backend.BackendID);
                    }
                    else
                    {
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect users needing update : End(), Response :: next collecting time of the backend [ " + backend.BackendID + " ] is greater-than to current time.");
                    }
                });
            }
            catch (BusinessLogicException balexception)
            {
                //write exception message to web job dashboard logs
                // log.WriteLine(balexception.Message);
                //write (Business Logic Exception into application insights
                InsightLogger.Exception(balexception.Message, balexception, callerMethodName);
            }
            catch (DataAccessException dalexception)
            {
                //write exception message to web job dashboard logs
                //log.WriteLine(dalexception.Message);
                //write Data Access Exception into application insights
                InsightLogger.Exception(dalexception.Message, dalexception, callerMethodName);
            }
            catch (Exception exception)
            {
                //  log.WriteLine("Error in adidas.clb.job.UpdateTriggering :: Functions :: RegularChecksforBackendNeedsUpdate() :: Exception Message=" + exception.Message);
                //write exception into application insights
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
            }
        }