private static List <DeltoneCRM_DAL.CompanyDAL.CompanyView> GetEventListCompany(string month, string yearV)
        {
            var listCompany  = new List <DeltoneCRM_DAL.CompanyDAL.CompanyView>();
            var conn         = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var reminderList = new CalendarEventDAL(conn).GetAllCAllBackEvents();
            var monthtype    = month;
            var year         = yearV;

            reminderList = GetAllCurrentMonthValid(reminderList, monthtype, year);
            if (reminderList.Count() > 0)
            {
                foreach (var item in reminderList)
                {
                    if (item.companyId != "0")
                    {
                        var comView = new DeltoneCRM_DAL.CompanyDAL.CompanyView();
                        comView.CompanyID = Convert.ToInt32(item.companyId);

                        listCompany.Add(comView);
                    }
                }
            }

            return(listCompany);
        }
        private List <DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent> GetLeadEventList(int userId, string sear)
        {
            var    eventsList  = new List <DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent>();
            string cs          = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var    leadComList = new CompanyDAL(cs).GetLeadCompanyNOExpires(userId);

            var callBackEvents = new CalendarEventDAL(cs).GetAllCAllBackEvents();

            callBackEvents = callBackEvents.OrderByDescending(x => x.start).ToList();
            foreach (var com in leadComList)
            {
                var eve = (from cl in callBackEvents where cl.companyId == com.CompanyId select cl).ToList();
                if (eve.Count > 0)
                {
                    eventsList.Add(eve[0]);
                }
            }

            if (!string.IsNullOrEmpty(sear))
            {
                eventsList = (from ec in eventsList
                              where ec.description.Contains(sear) ||
                              ec.title.Contains(sear)
                              select ec).ToList();
            }

            return(eventsList);
        }
Beispiel #3
0
        private string EventSelectedByCompanyEventId(int eveID)
        {
            var    dateEventstarted = "";
            string cs          = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var    selectedEve = new CalendarEventDAL(cs).getEvents(eveID);

            if (selectedEve.Count() > 0)
            {
                var contactStr = "";
                var comId      = Convert.ToInt32(selectedEve[0].companyId.ToString());
                if (comId > 0)
                {
                    var conId = GetContacts(comId.ToString());
                    contactStr = PopulateContact(conId);
                }
                var desc = Regex.Replace(selectedEve[0].description.Trim(), @"\t|\n|\r", "");

                dateEventstarted = selectedEve[0].id.ToString() + "#rr#"
                                   + selectedEve[0].title.Trim() + "#rr#"
                                   + desc + "#rr#"
                                   + selectedEve[0].start + "#rr#"
                                   + selectedEve[0].end + "#rr#"
                                   + selectedEve[0].allDay + "#rr#"
                                   + selectedEve[0].color + "#rr#"
                                   + selectedEve[0].url + "#rr#"
                                   + selectedEve[0].createdDate + "#rr#"
                                   + selectedEve[0].modifiedDate + "#rr#"
                                   + selectedEve[0].start.ToString("yyyy-MM-dd") + "#rr#"
                                   + comId + "," + contactStr;
            }

            return(dateEventstarted);
        }
Beispiel #4
0
        protected string GetEventReminderByRep()
        {
            var    message        = "";
            string cs             = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var    eventsList     = new List <DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent>();
            var    eventsList12Am = new List <DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent>();
            var    rep            = Convert.ToInt32(Session["LoggedUserID"].ToString());

            eventsList = new CalendarEventDAL(cs).getReminderEvents(rep);
            var currentDateTime = DateTime.Now;
            var datetimeStart   = DateTime.Now.AddMinutes(-2);
            var datetimeEnd     = DateTime.Now.AddMinutes(3);
            var currentDate     = datetimeStart.Date;
            var filteredList    = (from res in eventsList where res.start.Date == currentDate select res).ToList();

            if (currentDateTime.Hour == 10 || currentDateTime.Hour == 11)
            {
                if (currentDateTime.Minute < 2)
                {
                    eventsList12Am = (from res in filteredList where res.start.Hour == 0 select res).ToList();
                }
            }
            filteredList = (from re in filteredList where re.start >= datetimeStart && re.start <= datetimeEnd select re).ToList();
            filteredList.AddRange(eventsList12Am);
            List <int> ids = new List <int>();

            //if (Session["idsEvents"] != null)
            //   ids = Session["idsEvents"] as List<int>;


            foreach (var item in filteredList)
            {
                // if (!ids.Contains(item.id))
                // {
                if (message == "")
                {
                    message = item.title + "--" + item.description;
                }
                else
                {
                    message = message + "," + item.title + "--" + item.description;
                }

                // ids.Add(item.id);
                //  }
            }
            //  Session["idsEvents"] = ids;
            return(message);
        }
        protected string GetCAllBackEvents(string monthtype, string year)
        {
            String strOutput = "{\"aaData\":[";

            using (SqlConnection conn = new SqlConnection())
            {
                var connStr = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

                var reminderList = new CalendarEventDAL(connStr).GetAllCAllBackEvents();
                reminderList = GetAllCurrentMonthValid(reminderList, monthtype, year);
                if (reminderList.Count() > 0)
                {
                    foreach (var item in reminderList)
                    {
                        if (item.companyId != "0")
                        {
                            var viewCom     = "<img src='../Images/Edit.png' onclick='ViewCom(" + item.companyId + ")'/>";
                            var comId       = item.companyId;
                            var fillCom     = FillCompanyContactObj(comId);
                            var CoName      = fillCom.CoName;
                            var contactName = fillCom.contactName;
                            var telephone   = fillCom.telephone;
                            var mobile      = fillCom.mobile;
                            var view        = item.url;
                            var dexc        = Regex.Replace(item.description.ToString(), @"\t|\n|\r", "");
                            dexc = dexc.Replace(@"\", "-");
                            dexc = dexc.Replace("\"", "");
                            var message = item.start.Date.ToShortDateString() + " --> " + dexc;
                            strOutput = strOutput + "[\"" + comId + "\"," + "\"" + CoName + "\","
                                        + "\"" + contactName + "\","
                                        + "\"" + telephone + "\","
                                        + "\"" + mobile + "\","
                                        + "\"" + message + "\","
                                        + "\"" + viewCom + "\"],";
                        }
                    }
                    int Length = strOutput.Length;
                    strOutput = strOutput.Substring(0, (Length - 1));
                }
                strOutput = strOutput + "]}";
            }
            return(strOutput);
        }
Beispiel #6
0
        public static int addEvent(DeltoneCRM.DataHandlers.DisplayEventHandler.ImproperCalendarEvent improperEvent)
        {
            string cs = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;

            DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent cevent = new DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent()
            {
                title       = improperEvent.title,
                description = improperEvent.description,
                start       = Convert.ToDateTime(improperEvent.start),
                end         = Convert.ToDateTime(improperEvent.end),
                allDay      = improperEvent.allDay,
                color       = improperEvent.color,
                isreminder  = improperEvent.isreminder
            };
            cevent.url = "";

            // if (CheckAlphaNumeric(cevent.title) && CheckAlphaNumeric(cevent.description))
            // {
            var userId = 0;

            if (HttpContext.Current.Session["LoggedUserID"] != null)
            {
                userId = Convert.ToInt32(HttpContext.Current.Session["LoggedUserID"].ToString());
            }
            int key = new CalendarEventDAL(cs).addEvent(cevent, 0, userId);

            List <int> idList = (List <int>)System.Web.HttpContext.Current.Session["idList"];

            if (idList != null)
            {
                idList.Add(key);
            }

            return(key); //return the primary key of the added cevent object

            // }

            return(-1); //return a negative number just to signify nothing has been added
        }
Beispiel #7
0
        public static int addEvent(DeltoneCRM.DataHandlers.DisplayEventHandler.ImproperCalendarEvent improperEvent)
        {
            string cs        = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var    startDate = Convert.ToDateTime(improperEvent.start);
            //   var endateObj = Convert.ToDateTime(improperEvent.end);
            var endDate = startDate.AddHours(1);
            //if (startDate != endateObj)
            // endDate = endateObj;


            var isAllDay = false;

            DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent cevent = new DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent()
            {
                title       = improperEvent.title,
                description = improperEvent.description,
                start       = startDate,
                end         = endDate,
                allDay      = isAllDay,
                color       = improperEvent.color
            };

            var comId = 0;

            if (HttpContext.Current.Session["companyId"] != null)
            {
                comId = Convert.ToInt32(HttpContext.Current.Session["companyId"].ToString());
            }

            cevent.url = string.Format(UrlCompany, comId);

            var userId = 0;

            if (HttpContext.Current.Session["LoggedUserID"] != null)
            {
                userId = Convert.ToInt32(HttpContext.Current.Session["LoggedUserID"].ToString());
            }
            int key = new CalendarEventDAL(cs).addEvent(cevent, comId, userId);

            //List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"];

            //if (idList != null)
            //{
            //    idList.Add(key);
            //}


            var           connectionstring = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            SqlConnection conn             = new SqlConnection();

            conn.ConnectionString = connectionstring;

            var columnName  = "CalendarEvent all columns Order";
            var talbeName   = "CalendarEvent";
            var ActionType  = "Event Created";
            int primaryKey  = key;
            var companyName = new DeltoneCRM_DAL.CompanyDAL(connectionstring).getCompanyNameByID(comId.ToString());
            var lastString  = "Event Scheduled for company " + companyName + ": " + cevent.title;

            new DeltoneCRM_DAL.CompanyDAL(connectionstring).CreateActionONAuditLog("", lastString, userId, conn, 0,
                                                                                   columnName, talbeName, ActionType, primaryKey, comId);


            return(key); //return the primary key of the added cevent object



            return(-1); //return a negative number just to signify nothing has been added
        }
        public void ProcessRequest(HttpContext context)
        {
            DateTime   start  = Convert.ToDateTime(context.Request.QueryString["start"]);
            DateTime   end    = Convert.ToDateTime(context.Request.QueryString["end"]);
            string     cs     = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            List <int> idList = new List <int>();
            List <ImproperCalendarEvent> tasksList = new List <ImproperCalendarEvent>();
            var userId       = 0;
            var searchString = "";

            if (context.Request.QueryString["qqq"] != null)
            {
                searchString = context.Request.QueryString["qqq"].ToString();
            }
            if (context.Session["LoggedUserID"] != null)
            {
                userId = Convert.ToInt32(context.Session["LoggedUserID"].ToString());
            }
            var eventsList = new List <DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent>();

            if (!string.IsNullOrEmpty(searchString))
            {
                eventsList = new CalendarEventDAL(cs).getSearchEvents(searchString, userId);
            }
            else
            {
                eventsList = new CalendarEventDAL(cs).getEvents(start, end, userId);
            }

            var callList = GetLeadEventList(userId, searchString);

            eventsList.AddRange(callList);
            eventsList = eventsList.OrderBy(x => x.start).ToList();


            foreach (DeltoneCRM_DAL.CalendarEventDAL.CalendarEvent cevent in eventsList)
            {
                var comId = Convert.ToInt32(cevent.companyId);

                var imObj = new ImproperCalendarEvent
                {
                    id           = cevent.id,
                    title        = cevent.title,
                    start        = String.Format("{0:s}", cevent.start),
                    end          = String.Format("{0:s}", cevent.end),
                    color        = cevent.color,
                    description  = cevent.description + " : " + cevent.createdDate,
                    allDay       = cevent.allDay,
                    url          = cevent.url,
                    createdDate  = cevent.createdDate,
                    modifiedDate = cevent.modifiedDate,
                    companyId    = comId,
                    isreminder   = cevent.isreminder,
                    IsQuoteEvent = cevent.isquoteevent
                };
                if (!string.IsNullOrEmpty(imObj.url))
                {
                    var QuoteIdFromUrl = GetQuoteIdFromUrl(imObj.url);
                    if (!string.IsNullOrEmpty(QuoteIdFromUrl))
                    {
                        var notesQuote = getQuoteNotes(Convert.ToInt32(QuoteIdFromUrl));
                        // imObj.description = imObj.description + notesQuote;
                    }
                }
                if (comId > 0)
                {
                    imObj = SetContactDetails(comId, imObj);
                }

                tasksList.Add(imObj);

                idList.Add(cevent.id);
            }


            //Generate JSON serializable events
            context.Session["idList"] = idList;

            //Serialize events to string
            System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string sJSON = oSerializer.Serialize(tasksList);

            //Write JSON to response object
            context.Response.Write(sJSON);
        }