예제 #1
0
파일: Engine.cs 프로젝트: windygu/.net-wms
        protected void sst_Elapsed(object sender, ElapsedEventArgs e)
        {
            ScheduledServiceEntity entity = null;

            try
            {
                entity = ((ScheduledServiceTimer)sender).ScheduledServiceEntity;
                if (entity.WaitForRun == true)  // ÏÐÖÃ״̬²Å¿ÉÒÔRun
                {
                    Assembly assembly = Assembly.LoadFrom(entity.AssemblyPath);
                    Type     type     = assembly.GetType(entity.Type);
                    using (ICommand command = (ICommand)Activator.CreateInstance(type))
                    {
                        entity.WaitForRun = false;
                        command.NewTransactionCode();
                        ServiceResult sr = command.Run(RunMethod.Auto);
                        if (sr.Result == false)
                        {
                            EventLog.WriteEntry("Engine.sst_Elapsed", sr.Message + " Transaction Code:" + sr.TransactionCode, EventLogEntryType.Error);
                        }
                        entity.WaitForRun = true;
                    }
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Engine.sst_Elapsed", ex.Message, EventLogEntryType.Error);
                if (entity != null)
                {
                    entity.WaitForRun = true;
                }
            }
        }
예제 #2
0
        internal static List <ScheduledServiceEntity> ScheduledServiceEntities(XmlElement element)
        {
            List <ScheduledServiceEntity> list = new List <ScheduledServiceEntity>();
            XmlNodeList entityList             = element.GetElementsByTagName("ScheduledServiceEntity");

            foreach (XmlNode node in entityList)
            {
                ScheduledServiceEntity entity = Node2ScheduledServiceEntity(node);
                if (list.Find(new Predicate <ScheduledServiceEntity>(delegate(ScheduledServiceEntity sse)
                {
                    if (string.Compare(sse.Key, entity.Key, true) == 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                })) == null)
                {
                    list.Add(entity);
                }
            }
            return(list);
        }
예제 #3
0
파일: Engine.cs 프로젝트: windygu/.net-wms
        private ScheduledServiceTimer CreateScheduledServiceTimer(ScheduledServiceEntity sse)
        {
            ScheduledServiceTimer sst = new ScheduledServiceTimer(C_DAILYINTERVAL);

            sst.AutoReset = true;
            sst.ScheduledServiceEntity = sse;
            sst.Elapsed += new ElapsedEventHandler(sst_Elapsed);
            sst.Enabled  = false;
            return(sst);
        }
예제 #4
0
        private static ScheduledServiceEntity Node2ScheduledServiceEntity(XmlNode node)
        {
            ScheduledServiceEntity entity = new ScheduledServiceEntity();

            entity.m_AssemblyPath = node.Attributes["AssemblyPath"].Value;
            entity.m_Type         = node.Attributes["Type"].Value;
            entity.m_Key          = node.Attributes["Key"].Value;
            entity.m_StartHour    = int.Parse(node.Attributes["StartHour"].Value);
            entity.m_StartMinutes = int.Parse(node.Attributes["StartMinutes"].Value);
            return(entity);
        }
예제 #5
0
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            List <ScheduledServiceEntity> scheduledServiceEntityes = new List <ScheduledServiceEntity>();

            try
            {
                XmlElement element = null;
                element = (XmlElement)section;
                scheduledServiceEntityes = ScheduledServiceEntity.ScheduledServiceEntities(element);
            }
            catch
            {
                throw new System.Configuration.ConfigurationErrorsException("Invalid scheduled service entity configuration");
            }
            return(scheduledServiceEntityes);
        }