当前位置: 首页>>代码示例>>C#>>正文


C# Snapshot.Process方法代码示例

本文整理汇总了C#中Snapshot.Process方法的典型用法代码示例。如果您正苦于以下问题:C# Snapshot.Process方法的具体用法?C# Snapshot.Process怎么用?C# Snapshot.Process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Snapshot的用法示例。


在下文中一共展示了Snapshot.Process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SnapshotPost

        /// <summary>
        /// This request takes snapshot data, and processes it into the stats database
        /// </summary>
        /// <param name="Client">The HttpClient who made the request</param>
        /// <param name="Driver">The Stats Database Driver. Connection errors are handled in the calling object</param>
        public SnapshotPost(HttpClient Client, StatsDatabase Driver)
        {
            // First and foremost. Make sure that we are authorized to be here!
            IPEndPoint RemoteIP = Client.RemoteEndPoint;
            if (!Client.Request.IsLocal)
            {
                // Setup local vars
                bool IsValid = false;
                IPAddress Ip;

                // Loop through all Config allowed game hosts, and determine if the remote host is allowed
                // to post snapshots here
                if (!String.IsNullOrWhiteSpace(MainForm.Config.ASP_GameHosts))
                {
                    string[] Hosts = MainForm.Config.ASP_GameHosts.Split(',');
                    foreach (string Host in Hosts)
                    {
                        if (IPAddress.TryParse(Host, out Ip) && Ip.Equals(RemoteIP.Address))
                        {
                            IsValid = true;
                            break;
                        }
                    }
                }

                // If we are not on the GameHost list, too bad sucka!
                if (!IsValid)
                {
                    // Notify User
                    Notify.Show("Snapshot Denied!", "Invalid Server IP: " + RemoteIP.Address.ToString(), AlertType.Warning);
                    if (Client.Request.UserAgent == "GameSpyHTTP/1.0")
                    {
                        Client.Response.WriteResponseStart(false);
                        Client.Response.WriteHeaderLine("response");
                        Client.Response.WriteDataLine("Unauthorised Gameserver");
                    }
                    else
                        Client.Response.StatusCode = (int)HttpStatusCode.Forbidden;

                    Client.Response.Send();
                    return;
                }
            }

            // Make sure we have post data
            if (!Client.Request.HasEntityBody)
            {
                // No Post Data
                if (Client.Request.UserAgent == "GameSpyHTTP/1.0")
                {
                    Client.Response.WriteResponseStart(false);
                    Client.Response.WriteHeaderLine("response");
                    Client.Response.WriteDataLine("SNAPSHOT Data NOT found!");
                }
                else
                    Client.Response.StatusCode = (int)HttpStatusCode.BadRequest;

                Client.Response.Send();
                return;
            }

            // Create our snapshot object and filename
            string SnapshotData;
            Snapshot Snapshot;
            string FileName = String.Empty;
            bool BackupCreated = false;

            // Create snapshot backup file if the snapshot is valid
            try
            {
                // Read Snapshot
                using (StreamReader Reader = new StreamReader(Client.Request.InputStream))
                    SnapshotData = Reader.ReadToEnd();

                // Create the Snapshot Object
                Snapshot = new Snapshot(SnapshotData, DateTime.UtcNow, Driver);

                // Make sure data is valid!
                if (!Snapshot.IsValid)
                {
                    Notify.Show("Error Processing Snapshot!", "Snapshot Data NOT Complete or Invalid!", AlertType.Warning);
                    Client.Response.WriteResponseStart(false);
                    Client.Response.WriteHeaderLine("response");
                    Client.Response.WriteDataLine("SNAPSHOT Data NOT complete or invalid!");
                    Client.Response.Send();
                    return;
                }
            }
            catch (Exception E)
            {
                ASPServer.Log("ERROR: [SnapshotPreProcess] " + E.Message + " @ " + E.TargetSite);
                Client.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
                Client.Response.Send();
                return;
            }
//.........这里部分代码省略.........
开发者ID:roguesupport,项目名称:ControlCenter,代码行数:101,代码来源:SnapshotPost.cs


注:本文中的Snapshot.Process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。