Example #1
0
        internal static async Task <ResponseBase> GridSendEmailSMS(TeamHttpContext teamHttpContext, GridSendEmailSMS details)
        {
            try
            {
                if (teamHttpContext == null)
                {
                    throw new ArgumentNullException(nameof(teamHttpContext));
                }
                OnScreenClick objOnScreenClick = new OnScreenClick
                {
                    ClickLevel      = details.ClickLevel,
                    ClickedWidgetId = details.ClickedWidgetId,
                    ClickedOnValue  = details.ClickedOnValue,
                    GridInput       = details.GridInput
                };

                List <OnScreenClick> GridData = await GenericService.GetGridDataAsync(teamHttpContext, objOnScreenClick).ConfigureAwait(false);

                if (GridData.Count > 0)
                {
                    if (details.SendType == "Email")
                    {
                        if (details.SendEmailOption == "Send To")
                        {
                            //List<string> emailids = details.RecipientEmails.Split(',').ToList<string>();
                            byte[] specificByteData = HelperMethods.ConvertObjectListToCsv(GridData[0].GridData.ToList(), string.Join(",", GridData[0].GridColumns));
                            CreateDocumentForAttachment(teamHttpContext, details.ClickLevel, specificByteData, details.RecipientEmails);
                        }
                        else
                        {
                            var columnnames = from t in GridData[0].GridColumns.Where(x => x.Equals("email") || x.Equals("Email") || x.Equals("EMAIL") || x.Equals("EMail") || x.Equals("e-Mail") || x.Equals("e-mail") || x.Equals("E-mail") || x.Equals("E-Mail") || x.Contains("E-MAIL")) select t;

                            int indexOfEmail = -1;
                            foreach (var result in columnnames)
                            {
                                indexOfEmail = GridData[0].GridColumns.Select((item, i) => new
                                {
                                    Item     = item,
                                    Position = i
                                }).Where(m => m.Item.Equals(result)).First().Position;
                            }

                            if (indexOfEmail != -1)
                            {
                                List <string> emaillist = new List <string>();

                                foreach (var email in GridData[0].GridData)
                                {
                                    var list1 = email[indexOfEmail];
                                    if (!emaillist.Contains(list1))
                                    {
                                        emaillist.Add(list1);
                                    }
                                }

                                foreach (var emaildata in emaillist)
                                {
                                    var    userdatalist = GridData[0].GridData.Where(x => x.Contains(emaildata)).ToList();
                                    byte[] csvByteData  = HelperMethods.ConvertObjectListToCsv(userdatalist, string.Join(",", GridData[0].GridColumns));

                                    CreateDocumentForAttachment(teamHttpContext, details.ClickLevel, csvByteData, emaildata);
                                }
                            }
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }

                return(GetResponse(teamHttpContext));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
 public async Task <ResponseBase <List <OnScreenClick> > > Dashboardwidgetclick([FromBody] OnScreenClick widgetclick)
 {
     return(await DashboardService.DashboardWidgetClick(new TeamHttpContext(HttpContext), widgetclick).ConfigureAwait(false));
 }
Example #3
0
        internal static async Task <ResponseBase <List <OnScreenClick> > > DashboardWidgetClick(TeamHttpContext teamHttpContext, OnScreenClick details)
        {
            try
            {
                if (teamHttpContext == null)
                {
                    throw new ArgumentNullException(nameof(teamHttpContext));
                }
                List <OnScreenClick> GridData = await GenericService.GetGridDataAsync(teamHttpContext, details).ConfigureAwait(false);

                return(GetTypedResponse(teamHttpContext, GridData));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }