コード例 #1
0
ファイル: Notify.cs プロジェクト: jikars/SystimeCore
        private void Onchange(object sender, SqlNotificationEventArgs e)
        {
            if (EventSupportFromQuery.Contains(e.Info) && e.Source == SqlNotificationSource.Data)
            {
                Task.Factory.StartNew(() => {
                    DateTime dateTime = DateTime.Now;
                    List <DynamicQueryParam> lisparams = new SchemaCondition().GetParamsDynamicTableDataEventQuery(JsonConvert.DeserializeObject <SqlNotificationEventArgs>(JsonConvert.SerializeObject(e)), ConectionString, QueryPostNotification, Connection, FillterValidatePostScript, TableEvnet, ColumsNotify, dateTime);
                    if (lisparams != null)
                    {
                        NotifierClient notifierClient = new NotifierClient(ConectionString, lisparams, RecipientType, NotificationName);
                        notifierClient.SendNotifcations();
                    }
                });
            }

            SqlDependency sqlDependecy = (SqlDependency)sender;

            sqlDependecy.OnChange -= new OnChangeEventHandler(Onchange);
            StartServiceQueryDependecy();
        }
コード例 #2
0
ファイル: Notify.cs プロジェクト: jikars/SystimeCore
        public void StartNotifycation(string conectionString, string tableEvent, String notificationName, List <string> columNotify, List <EvnetFillterDataBase> eventDatabase, List <RecipientType> recipientsType, String fillterValidation, String queryPostNotificaiton, Boolean isNnotificationFromTable, int?delayNotification)
        {
            NotificationName          = notificationName;
            RecipientType             = recipientsType;
            ConectionString           = conectionString;
            TableEvnet                = tableEvent;
            FillterValidatePostScript = fillterValidation;
            NoficationFromTable       = isNnotificationFromTable;
            QueryPostNotification     = queryPostNotificaiton;
            if (delayNotification.HasValue)
            {
                DelayNotification = delayNotification.Value;
            }


            if (!NoficationFromTable)
            {
                String where = "";

                int countColum = 0;
                columNotify.ForEach(c => {
                    if (countColum == 0)
                    {
                        ColumsNotify += c;
                    }
                    else
                    {
                        ColumsNotify += "," + c;
                    }
                    countColum++;
                });

                int countFillger = 0;
                eventDatabase.ForEach(t => {
                    if (!where.ToUpper().Contains(t.FillterDatabsase.ToUpper()))
                    {
                        if (countFillger == 0)
                        {
                            where += "(" + t.FillterDatabsase + ")";
                        }
                        else
                        {
                            where += " OR " + "(" + t.FillterDatabsase + ")";
                        }
                    }
                    countFillger++;
                });


                eventDatabase.ForEach(e => { EventSupportFromQuery.Add(CastEventFromQuery(e.EventDatabse)); });

                Fillter = String.Format("Select {0} from dbo.{1} Where {2}", ColumsNotify, tableEvent, where);

                if (String.IsNullOrEmpty(where))
                {
                    Fillter = Fillter.Replace("Where", "");
                }

                StartServiceQueryDependecy();
            }
            else
            {
                eventDatabase.ForEach(e => { EventSupportFromTable.Add(CastEventFromTable(e.EventDatabse)); });
                StartServiceTableDependecy(ConectionString, EventSupportFromTable);
            }
        }