Example #1
0
        /// <summary>
        /// Method Name     : GetAlertList
        /// Author          : Vivek Bhavsar
        /// Creation Date   : 29 Dec 2017
        /// Purpose         : Method to get list of alerts from database
        /// Revision        :
        /// </summary>
        /// <param name="customerID"></param>
        /// <param name="startDate"></param>
        /// <returns>List of Alert DTO</returns>
        public ServiceResponse <List <DTO.Alert> > GetAlertList(string customerID, string startDate = null)
        {
            string        retriveFieldList, customerGUID;
            StringBuilder filterString = new StringBuilder();
            Dictionary <string, string> customerResponse, alertResponse;

            try
            {
                //Get customer GUID
                customerResponse = crmCustomerDetails.GetCustomerGUID(customerID);
                customerGUID     = crmUtilities.GetSpecificAttributeFromResponse(customerResponse, resourceManager.GetString("crm_contact_customerId"));

                retriveFieldList = resourceManager.GetString("activityGetAlertListFields");
                filterString.Append(resourceManager.GetString("crm_activity_regardingobjectidvalue") + " eq " + customerGUID);
                if (Validations.IsValid(startDate))
                {
                    DateTime.TryParse(startDate, new CultureInfo("en-US"), DateTimeStyles.None, out DateTime returnValue);
                    filterString.Append(" and " + resourceManager.GetString("crm_activity_actualstart") + " ge " + returnValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
                }

                alertResponse = crmUtilities.ExecuteGetRequest(activityEntityName, retriveFieldList, filterString.ToString());
                return(ValidateAndGenerateResponse(alertResponse));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message.ToString());
                return(new ServiceResponse <List <DTO.Alert> > {
                    Message = resourceManager.GetString("msgServiceUnavailable")
                });
            }
        }
Example #2
0
        /// <summary>
        /// Method Name      : ExecutePostAlertList
        /// Author           : Pratik Soni
        /// Creation Date    : 05 Feb 2018
        /// Purpose          : Executes the CRM post service for each Alert from the list
        /// Revision         :
        /// </summary>
        /// <param name="requestObject"/>
        /// <param name="customerID"/>
        /// <returns></returns>
        private string ExecutePostAlertList(DTO.Alert requestObject, string customerID)
        {
            ServiceResponse <Alert>     crmResponse;
            Dictionary <string, string> customerResponse;

            try
            {
                if (!crmCustomerDetails.CheckCustomerRegistered(customerID))
                {
                    logger.Error(resourceManager.GetString("msgInvalidCustomer"));
                    return(GenerateServiceResponse <ServiceResponse <Alert> >(BADREQUEST, resourceManager.GetString("msgInvalidCustomer")));
                }

                customerResponse         = crmCustomerDetails.GetCustomerGUID(customerID);
                requestObject.CustomerID = General.GetSpecificAttributeFromCRMResponse(customerResponse, "contactid");
                crmResponse = crmAlertDetails.PostAlertDetails(customerID, General.ConvertToJson <Alert>(requestObject));

                if (!Validations.IsValid(crmResponse.Information))
                {
                    logger.Error(resourceManager.GetString("msgErrorInInsertingNewAlert") + requestObject.AlertTitle);
                    return(General.ConvertToJson <ServiceResponse <Alert> >(crmResponse));
                }

                logger.Info(resourceManager.GetString("msgSavedSuccessfully"));
                return(General.ConvertToJson <ServiceResponse <Alert> >(new ServiceResponse <Alert> {
                }));
            }
            catch (Exception ex)
            {
                logger.Error(resourceManager.GetString("msgFailToSave"), ex);
                return(GenerateServiceResponse <DTO.Alert>(MESSAGE, resourceManager.GetString("msgFailToSave")));
            }
        }