Exemple #1
0
        public static List <EmailResult> SendMailTemplate(List <string> toMails, string templateName, List <merge_var> mergeVars, string subject)
        {
            try
            {
                var api = new MandrillApi(_mandrillApiKey);

                var email = new EmailMessage
                {
                    from_email = _senderEmail,
                    subject    = subject
                };

                var to = toMails.Select(mailTo => new EmailAddress(mailTo)).ToList();

                email.to = to;
                foreach (merge_var item in mergeVars)
                {
                    email.AddGlobalVariable(item.name, item.content);
                }

                var result = api.SendMessageAsync(email, templateName, null);
                return(result.Result);
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                return(null);
                //ManagementBLL.LogError("SendMailMandrill", ex.Message, "EmailHelper", string.Empty);
            }
        }
Exemple #2
0
        private void GetHostByNameSink(IAsyncResult result)
        {
            IPHostEntry e;

            try
            {
                e = Dns.EndGetHostEntry(result);
            }
            catch (Exception ex)
            {
                // Could not resolve?
                EventLogger.Log(ex);
                return;
            }

            object[] Args     = (object[])result.AsyncState;
            Uri      Resource = (Uri)Args[0];
            object   Tag      = Args[1];

            ContinueRequest(
                new IPEndPoint(e.AddressList[0], Resource.Port),
                HTTPMessage.UnEscapeString(Resource.PathAndQuery),
                Tag,
                null);
        }
Exemple #3
0
        private void CreateFailedSink(HTTPSession ss)
        {
            lock (TagQueue)
            {
                while (TagQueue.Count > 0)
                {
                    StateData sd = (StateData)TagQueue.Dequeue();
                    EventLogger.Log(this, EventLogEntryType.Error, "Connection Attempt to [" + sd.Dest + "] Refused/Failed");

                    object Tag = sd.Tag;
                    if (sd.HeaderCB != null)
                    {
                        sd.HeaderCB(this, ss, null, null, Tag);
                    }
                    else
                    {
                        if (OnResponse != null)
                        {
                            OnResponse(this, null, Tag);
                        }
                    }
                }
                s = null;
            }
        }
Exemple #4
0
 public void AddMembership(IPEndPoint local, IPAddress MulticastAddress)
 {
     try
     {
         this.MainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastLoopback, 1);
     }
     catch (Exception)
     {
     }
     try
     {
         this.MainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(MulticastAddress));
     }
     catch (Exception)
     {
         EventLogger.Log(this, EventLogEntryType.Error, "Cannot AddMembership to IPAddress: " + MulticastAddress.ToString());
     }
     try
     {
         this.MainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, (int)local.Address.Address);
     }
     catch (Exception)
     {
         EventLogger.Log(this, EventLogEntryType.Error, "Cannot Set Multicast Interface to IPAddress: " + local.Address.ToString());
     }
 }
Exemple #5
0
        private void Awake()
        {
            if (transform.parent == null)
            {
                if (rootNetworkScene == null)
                {
                    rootNetworkScene = this;
                    DontDestroyOnLoad(gameObject);
                    Extensions.MonoBehaviourExtensions.DontDestroyOnLoadGameObjects.Add(gameObject);
                }
                else // Only one networkscene can exist at the top level of the hierarchy
                {
                    gameObject.SetActive(false); // Deactivate the branch to avoid Start() being called until the branch is destroyed
                    Destroy(gameObject);
                }
            }
            else // the network scene is in a forest
            {
                foreach (var item in GetComponents <NetworkScene>())
                {
                    if (item != this)
                    {
                        Destroy(item);
                    }
                }
            }

            events = new ComponentEventLogger(this);
            events.Log("Awake", Id, SystemInfo.deviceName, SystemInfo.deviceModel, SystemInfo.deviceUniqueIdentifier);
        }
Exemple #6
0
        private bool CallWebAPI(string sWebAPICall, enuCallbackType eCallbackType = enuCallbackType.None)
        {
            bool bCalled = false;

            try
            {
                if (sWebAPICall != "")
                {
                    WebRequest      oRequest  = WebRequest.Create(sWebAPICall);
                    HttpWebResponse oResponse = (HttpWebResponse)oRequest.GetResponse();
                    if (oResponse.StatusCode == HttpStatusCode.OK)
                    {
                        Stream       oStream   = oResponse.GetResponseStream();
                        StreamReader oReader   = new StreamReader(oStream);
                        string       sResponse = oReader.ReadToEnd();
                        oReader.Close();
                        oStream.Close();
                        oResponse.Close();
                        PlaceComponent(eCallbackType, sResponse);
                    }
                    bCalled = true;
                }
            }
            catch (Exception ex)
            {
                EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "CallWebAPI", ex));
            }

            return(bCalled);
        }
        public ActionResult GenerarVentasPorMaxikiosco(ReporteVentasFiltrosModel reporteVentasFiltrosModel)
        {
            try
            {
                DateTime?hasta = reporteVentasFiltrosModel.Hasta == null
                                    ? (DateTime?)null
                                    : reporteVentasFiltrosModel.Hasta.GetValueOrDefault().AddDays(1);

                var ventasPorMaxikiosoDataSource =
                    Uow.Reportes.VentasPorMaxikiosco(reporteVentasFiltrosModel.Desde,
                                                     hasta,
                                                     UsuarioActual.CuentaId);

                var reporteFactory = new ReporteFactory();

                reporteFactory
                .SetParametro("Desde", reporteVentasFiltrosModel.Desde.ToShortDateString())
                .SetParametro("Hasta", reporteVentasFiltrosModel.Hasta.ToShortDateString())
                .SetPathCompleto(Server.MapPath("~/Reportes/VentasPorMaxikiosco.rdl"))
                .SetDataSource("VentasPorMaxikioscoDataSet", ventasPorMaxikiosoDataSource);

                byte[] archivo = reporteFactory.Renderizar(reporteVentasFiltrosModel.ReporteTipo);

                return(File(archivo, reporteFactory.MimeType));
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                return(null);
            }
        }
        //---------------------------------------------------------------------
        private static void Initialize()
        {
            string   dsn      = null;
            Database database = null;

            try
            {
                // create the converters
                m_raceConverter = ConverterFactory.Create(ConverterFactory.SCHEMA_RACE);
                m_punyConverter = ConverterFactory.Create(ConverterFactory.SCHEMA_PUNYCODE);

                // Load the tld cache
                dsn      = ConfigurationSettings.AppSettings["dsn"];
                database = new Database(dsn);

                // load the tld cache.
                m_tldCache = database.GetTldCache();
            }
            catch (SqlException e)
            {
                // sql exception, load cache from local file
                LoadLocalCache();
                EventLogger.Log(EVENT_SOURCE, EventLogger.LogType.Error, "Load tld Cache from database failed\r\n" + e.ToString());
            }
        }
        //---------------------------------------------------------------------
        // Private methods.
        //---------------------------------------------------------------------
        private static void LoadLocalCache()
        {
            string       cacheFile = null;
            string       line      = null;
            StreamReader reader    = null;

            // Initialize
            m_tldCache = new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer());
            cacheFile  = ConfigurationSettings.AppSettings["cache"];

            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (reader = new StreamReader(cacheFile))
                {
                    // Read lines from the file until the end of
                    // the file is reached.
                    while ((line = reader.ReadLine()) != null)
                    {
                        line.Trim();
                        m_tldCache.Add(line, true);
                    }
                }
            }
            catch (Exception e)
            {
                EventLogger.Log(EVENT_SOURCE, EventLogger.LogType.Error, "Load Local Cache Failed\r\n" + e.ToString());
            }

            // Done.
            return;
        }
Exemple #10
0
        public static List <string> GetFirstRow(DbConnection conn, EmDbType dbType, CommandType cmdType, string cmdText,
                                                params DbParameter[] commandParameters)
        {
            if (conn == null)
            {
                throw new ArgumentNullException("conn");
            }
            if (string.IsNullOrEmpty(cmdText))
            {
                throw new ArgumentNullException("cmdText");
            }

            try
            {
                List <string> result = new List <string>();
                DataSet       ds     = GetDataSet(conn, dbType, cmdType, cmdText, commandParameters);
                if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                    {
                        result.Add(dr[i].ToString());
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                EventLogger.Log("SqlHelper.GetFirstRow 【" + cmdText + "】", ex);
                OpenConnection(dbType, conn);  //重新连接
                return(null);
            }
        }
Exemple #11
0
        public static List <string> GetFirstRow(EmDbType dbType, string connString, CommandType cmdType, string cmdText,
                                                params DbParameter[] commandParameters)
        {
            if (string.IsNullOrEmpty(connString))
            {
                throw new ArgumentNullException("connString");
            }
            if (string.IsNullOrEmpty(cmdText))
            {
                throw new ArgumentNullException("cmdText");
            }

            try
            {
                var conn = DBFactory.NewConnection(dbType, connString);
                conn.Open();

                return(GetFirstRow(conn, dbType, cmdType, cmdText, commandParameters));
            }
            catch (Exception ex)
            {
                EventLogger.Log("SqlHelper.GetFirstRow 【" + cmdText + "】", ex);
                OpenConnection(dbType, connString);  //重新刷新
                return(null);
            }
        }
Exemple #12
0
        /// <summary>
        /// 执行带参数的SQL语句
        /// </summary>
        /// <param name="dbType"></param>
        /// <param name="connString"></param>
        /// <param name="cmdType"></param>
        /// <param name="cmdText"></param>
        /// <param name="commandParameters"></param>
        /// <returns></returns>
        public static string ExecuteNonQuery(EmDbType dbType, string connString, CommandType cmdType, string cmdText,
                                             params DbParameter[] commandParameters)
        {
            if (string.IsNullOrEmpty(connString))
            {
                throw new ArgumentNullException("connString");
            }
            if (string.IsNullOrEmpty(cmdText))
            {
                throw new ArgumentNullException("cmdText");
            }

            try
            {
                DbConnection conn = DBFactory.NewConnection(dbType, connString);

                return(ExecuteNonQuery(conn, dbType, cmdType, cmdText, commandParameters));
            }
            catch (Exception ex)
            {
                EventLogger.Log($"SqlServerHelper.ExecuteNonQuery SQL[{cmdText}] 错误.", ex);
                OpenConnection(dbType, connString);  //重新连接
                return(ex.Message);
            }
        }
Exemple #13
0
        public void dispose()
        {
            // SWC Testing
            MethodBase method
                = MethodBase.GetCurrentMethod();

            if (method.DeclaringType != null)
            {
                EventLogger.Log(
                    this,
                    EventLogEntryType.Information,
                    String.Format(
                        "Debug {0}" +
                        "{1} disposed",
                        Environment.NewLine,
                        method.DeclaringType.Name));
            }

            // SWC 20130122 Set lock because event handler is still callable
            lock (RegLock)
            {
                if (handle != null)
                {
                    handle.Unregister(null);
                    handle = null;
                }
                // SWC 20130227 Close event
                if (mre != null)
                {
                    mre.Close();
                    mre = null;
                }
            }
        }
        public void OnReceiveSink(IAsyncResult ar)
        {
            IPEndPoint ep     = null;
            UdpClient  client = (UdpClient)ar.AsyncState;

            try
            {
                byte[] buf = client.EndReceive(ar, ref ep);
                if (buf != null)
                {
                    OnReceiveSink2(buf, ep, (IPEndPoint)client.Client.LocalEndPoint);
                    client.BeginReceive(OnReceiveSink, client);
                    return;
                }
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
            }
            try
            {
                IPEndPoint local = (IPEndPoint)client.Client.LocalEndPoint;
                SSDPSessions.Remove(local.Address);
            }
            catch (Exception x)
            {
                var k = x;
            }
        }
Exemple #15
0
 private void PollInterface(LifeTimeMonitor sender, object obj)
 {
     try
     {
         ArrayList list         = new ArrayList(Dns.GetHostByName(this.HostName).AddressList);
         ArrayList addressTable = this.AddressTable;
         this.AddressTable = list;
         if (!this.AddressTable.Contains(IPAddress.Loopback))
         {
             this.AddressTable.Add(IPAddress.Loopback);
         }
         foreach (IPAddress address in list)
         {
             if (!addressTable.Contains(address))
             {
                 this.OnNewInterfaceEvent.Fire(this, address);
             }
         }
         foreach (IPAddress address2 in addressTable)
         {
             if (!list.Contains(address2))
             {
                 this.OnInterfaceDisabledEvent.Fire(this, address2);
             }
         }
     }
     catch (Exception exception)
     {
         EventLogger.Log(exception);
     }
     this.InterfacePoller.Add(this, NetworkPollSeconds);
 }
Exemple #16
0
        public string NativeToPunycode(string domain)
        {
            string       sld       = null;
            string       tld       = null;
            string       converted = null;
            DomainParser parser    = null;

            if (null == domain)
            {
                return(null);
            }

            try
            {
                parser = new DomainParser(m_tldCache);

                // parse the domain.
                this.Parse(parser, domain, ref sld, ref tld);

                // convert it
                converted = m_punyConverter.Encode(sld);
                if (null != tld)
                {
                    converted += "." + tld;
                }
            }
            catch (Exception e)
            {
                converted = null;
                EventLogger.Log(EVENT_SOURCE, EventLogger.LogType.Error, e.ToString());
            }

            // Done.
            return(converted);
        }
Exemple #17
0
        private bool PlaceComponent(enuCallbackType eCallbackType, ovrs.Models.Component oComponent)
        {
            bool bResult = false;

            try
            {
                switch (eCallbackType)
                {
                case enuCallbackType.PlacePilot:
                    EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "PlaceComponent", "Placing Pilot on map"));
                    Pilot   = oComponent;
                    bResult = true;
                    break;

                case enuCallbackType.PlaceDrone:
                    EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "PlaceComponent", "Placing Drone on map"));
                    Drone   = oComponent;
                    bResult = true;
                    break;
                }
            }
            catch (Exception ex)
            {
                EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "PlaceComponent", ex));
            }

            return(bResult);
        }
Exemple #18
0
        /// <summary>
        /// Метод конвертации коллекции в строку формата JSON
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="project"></param>
        /// <param name="logger"></param>
        /// <returns></returns>
        public static string ConvertToString <T>(this Project <T> project, EventLogger <IEmployee <IComputer> > logger = null) where T : IEmployee <IComputer>
        {
            var wrapper = new ProjectWrapper <T>(project);

            logger.Log("Converted to string");
            return(JsonConvert.SerializeObject(wrapper, Formatting.Indented));
        }
 private void DeviceFactoryCreationSink(UPnPDeviceFactory sender, UPnPDevice device, Uri locationURL)
 {
     if (!this.deviceTable.Contains(device.UniqueDeviceName))
     {
         EventLogger.Log(this, EventLogEntryType.Error, "UPnPDevice[" + device.FriendlyName + "]@" + device.LocationURL + " advertised UDN[" + device.UniqueDeviceName + "] in xml but not in SSDP");
     }
     else
     {
         lock (this.deviceTableLock)
         {
             DeviceInfo info2 = (DeviceInfo)this.deviceTable[device.UniqueDeviceName];
             if (info2.Device != null)
             {
                 EventLogger.Log(this, EventLogEntryType.Information, "Unexpected UPnP Device Creation: " + device.FriendlyName + "@" + device.LocationURL);
                 return;
             }
             DeviceInfo info = (DeviceInfo)this.deviceTable[device.UniqueDeviceName];
             info.Device = device;
             this.deviceTable[device.UniqueDeviceName] = info;
             this.deviceLifeTimeClock.Add(device.UniqueDeviceName, device.ExpirationTimeout);
             this.activeDeviceList.Add(device);
         }
         this.OnAddedDeviceEvent.Fire(this, device);
     }
 }
Exemple #20
0
        public async Task <bool> SendEmail(string emailAddress, string subject, string message)
        {
            try
            {
                var msg = SendGrid.Helpers.Mail.MailHelper.CreateSingleEmail(
                    new SendGrid.Helpers.Mail.EmailAddress(VoatSettings.Instance.EmailAddress, VoatSettings.Instance.SiteName),
                    new SendGrid.Helpers.Mail.EmailAddress(emailAddress),
                    subject,
                    null,
                    message);

                var trackingSettings = new SendGrid.Helpers.Mail.TrackingSettings();
                trackingSettings.ClickTracking = new SendGrid.Helpers.Mail.ClickTracking();
                trackingSettings.OpenTracking  = new SendGrid.Helpers.Mail.OpenTracking();

                trackingSettings.ClickTracking.Enable = false;
                trackingSettings.OpenTracking.Enable  = false;

                msg.TrackingSettings = trackingSettings;

                var sendGridClient = new SendGrid.SendGridClient(_connectionString);

                var response = await sendGridClient.SendEmailAsync(msg);

                return(response.StatusCode == System.Net.HttpStatusCode.Accepted);
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex, VoatSettings.Instance.Origin);
                return(false);
            }
        }
Exemple #21
0
 protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
 {
     if (!HttpContext.Current.User.Identity.IsAuthenticated)
     {
         EventLogger.Log("APIVoucherUpdate.PostAPIVoucherUpdateControl", "PostAPIVoucherUpdateControl", EventLogger.Event.START, "Authorization has been denied for this request. :");
         //create custom response
         actionContext.Response = actionContext.Request.CreateResponse(
             HttpStatusCode.Unauthorized,
             new AuthResponseStatus()
         {
             status = "401", message = "Authorization has been denied for this request."
         }
             );
     }
     else
     {
         EventLogger.Log("APIVoucherUpdate.PostAPIVoucherUpdateControl", "PostAPIVoucherUpdateControl", EventLogger.Event.START, "Forbidden :");
         actionContext.Response = actionContext.Request.CreateResponse(
             HttpStatusCode.Forbidden,
             new AuthResponseStatus()
         {
             status = "403", message = "Forbidden"
         }
             );
     }
 }
Exemple #22
0
        private void GetRequestAsyncCallback(IAsyncResult ar)
        {
            // Get the request
            RequestState r = (RequestState)ar.AsyncState;
            Stream       s;

            try
            {
                s = r.request.EndGetRequestStream(ar);
                s.Write(r.postdata, 0, r.postdata.Length);
                s.Close();
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                s = null;
            }
            if (s == null)
            {
                PendingRequests--;
                if (OnRequestCompleted != null)
                {
                    OnRequestCompleted(this, false, r.tag, r.url, null);
                }
                return;
            }
            r.request.BeginGetResponse(GetResponseAsyncCallback, r);
        }
Exemple #23
0
        /// <summary>
        /// Join a multicast group
        /// </summary>
        /// <param name="local">Interface to use</param>
        /// <param name="MulticastAddress">MulticastAddress to join</param>
        public void AddMembership(IPEndPoint local, IPAddress MulticastAddress)
        {
            try
            {
                MainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastLoopback, 1);
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                // This will only fail if the network stack does not support this
                // Which means you are probably running Win9x
            }

            try
            {
                MainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(MulticastAddress));
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                EventLogger.Log(this, EventLogEntryType.Error, "Cannot AddMembership to IPAddress: " + MulticastAddress);
            }
            try
            {
                MainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, local.Address.GetAddressBytes());
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                EventLogger.Log(this, EventLogEntryType.Error, "Cannot Set Multicast Interface to IPAddress: " + local.Address);
            }
        }
Exemple #24
0
        private void OnReceiveSink(IAsyncResult result)
        {
            byte[]     buffer;
            IPEndPoint ep = null;

            object[]   args    = (object[])result.AsyncState;
            UdpClient  session = (UdpClient)args[0];
            IPEndPoint local   = (IPEndPoint)args[1];

            try
            {
                buffer = session.EndReceive(result, ref ep);
                try
                {
                    HTTPMessage Packet = HTTPMessage.ParseByteArray(buffer, 0, buffer.Length);
                    if (Packet != null)
                    {
                        Packet.LocalEndPoint  = local;
                        Packet.RemoteEndPoint = ep;
                        ProcessPacket(Packet, Packet.RemoteEndPoint, local);
                    }
                }
                catch (Exception ex)
                {
                    EventLogger.Log(ex);
                }
                session.BeginReceive(OnReceiveSink, args);
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                sessions.Remove(local.Address);
            }
        }
        private static void Reload(string fullFilePath)
        {
            if (File.Exists(fullFilePath))
            {
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(fullFilePath);
                    XmlNodeList nodes = doc.SelectNodes("/configuration/appSettings/add");

                    foreach (XmlNode node in nodes)
                    {
                        string key = node.Attributes["key"].Value;
                        //add condition for RuntimeState as it has it's own handler
                        if (String.Equals(key, CONFIGURATION.RuntimeState, StringComparison.OrdinalIgnoreCase))
                        {
                            RuntimeState.Refresh(node.Attributes["value"].Value);
                        }
                        else
                        {
                            SetValueIfPresent <bool>(node.Attributes["key"].Value, node.Attributes["value"].Value, true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    EventLogger.Log(ex);
                }
            }
        }
Exemple #26
0
 public void Done()
 {
     foreach (var item in GetComponentsInChildren <Slider>())
     {
         results.Log("Answer", item.name, item.value);
     }
 }
Exemple #27
0
 private void RequestAnsweredSink(HTTPSession ss)
 {
     lock (TagQueue)
     {
         if (!ReceivedFirstResponse)
         {
             ReceivedFirstResponse = true;
             IEnumerator en = TagQueue.GetEnumerator();
             while (en.MoveNext())
             {
                 StateData sd = (StateData)en.Current;
                 try
                 {
                     if (ProxySetting == null)
                     {
                         ss.Send(sd.Request);
                     }
                     else
                     {
                         HTTPMessage pr = (HTTPMessage)sd.Request.Clone();
                         pr.DirectiveObj = "http://" + sd.Dest + pr.DirectiveObj;
                         pr.Version      = "1.0";
                         ss.Send(pr);
                     }
                 }
                 catch (Exception ex)
                 {
                     EventLogger.Log(ex);
                 }
             }
         }
     }
 }
Exemple #28
0
        public void ConnectMasterOPCServer()
        {
            if (IsConnect)
            {
                EventLogger.Log("OPC服务器已连接");
                //NLogHelper.Error("生产线OPC服务器已连接");
            }
            else
            {
                string errorMsg = string.Empty;
                this.MasterServer = OPCConnector.ConnectOPCServer(0, "localhost", "RSLinx OPC Server", ref errorMsg);

                if (!string.IsNullOrEmpty(errorMsg))
                {
                    EventLogger.Log(errorMsg);
                    //NLogHelper.Error(errorMsg);
                    return;
                }

                IsConnect = this.MasterServer != null;
                if (!IsConnect)
                {
                    EventLogger.Log("OPC服务器通讯失败");
                    //NLogHelper.Error("OPC服务器通讯失败");
                }
                EventLogger.Log("OPC服务器通讯成功。");
            }
        }
        public void OnLeave()
        {
            if (m_currentState == null)
            {
                return;
            }

            if (m_sentactorEvents == null)
            {
                return;
            }

            for (int i = 0; i < m_sentactorEvents.Length; i++)
            {
                if (m_sentactorEvents[i] == false)
                {
                    if (m_currentState.EventList.Count > i && m_currentState.EventList[i] != null)
                    {
                        AnimationEventInfo animationEventInfo = m_currentState.EventList[i];
                        if (animationEventInfo.EventOnExit)
                        {
                            m_sentactorEvents[i] = true;
                        }
                        m_animationEventHandler.OnAnimationEvent(animationEventInfo.FunctionName,
                                                                 animationEventInfo.attribute);
                        EventLogger.Log(EventLogType.AnimEvent_State,
                                        string.Format("OnLeave ActorName : {0} Event : {1}_{2}, NorTime {3} ",
                                                      m_animationEventHandler.HandlerName, animationEventInfo.FunctionName,
                                                      animationEventInfo.NomalizeTime, animationEventInfo.attribute));
                    }
                }
            }
            m_currentState = null;
            m_animationEventHandler.OnAnimationEvent(AnimationEventUtil.Exit, null);
        }
Exemple #30
0
        public LevelGameplay(XmlDocument levelXml, FashionLevel level, FashionNpcMediator modelFactory)
        {
            if (levelXml == null)
            {
                throw new ArgumentNullException("levelXml");
            }
            mLevelXml = levelXml;

            if (level == null)
            {
                throw new ArgumentNullException("level");
            }
            mLevel = level;

            mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            XmlNode timeBetweenWaves = mLevelXml.SelectSingleNode("Level/Waves/@timeBetweenWaves");

            if (timeBetweenWaves == null)
            {
                throw new Exception("Unable to load level (" + mLevel.Name + "), no Level/Waves/@timeBetweenWaves node found.");
            }
            mTimeBetweenWaves = float.Parse(timeBetweenWaves.InnerText);

            XmlNode perfectLevelBonusNode = mLevelXml.SelectSingleNode("Level/PerfectLevelBonus/@value");

            if (perfectLevelBonusNode != null)
            {
                mPerfectLevelBonus = uint.Parse(perfectLevelBonusNode.InnerText);
            }
            else
            {
                mPerfectLevelBonus = 0;
            }

            XmlNode closeSaveDistanceNode = mLevelXml.SelectSingleNode("Level/CloseSaveDistance/@value");

            if (closeSaveDistanceNode == null)
            {
                throw new Exception("Cannot load level (" + mLevel.Name + "), no Level/@path attribute found.");
            }
            mCloseSaveDistance = float.Parse(closeSaveDistanceNode.InnerText);

            if (modelFactory == null)
            {
                throw new ArgumentNullException("modelFactory");
            }
            mModelFactory = modelFactory;

            mLevel.Gui.BuildTopGui(delegate()
            {
                if (Time.time - mNextWaveTime > mAvoidDuplicateWavesThreshold)
                {
                    mNextWaveButtonPressed = true;

                    EventLogger.Log(LogGlobals.CATEGORY_FASHION_MINIGAME, LogGlobals.GAMEPLAY_BEHAVIOR, "NextWaveButtonPress", mLevel.Name);
                }
            });
        }