상속: System.Data.Objects.DataClasses.EntityObject
예제 #1
0
        /// <summary>
        /// Create a new iis_log_entry object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        /// <param name="datetime">Initial value of the datetime property.</param>
        /// <param name="server">Initial value of the server property.</param>
        /// <param name="verb">Initial value of the verb property.</param>
        /// <param name="url">Initial value of the url property.</param>
        /// <param name="ip">Initial value of the ip property.</param>
        /// <param name="status">Initial value of the status property.</param>
        /// <param name="sent_bytes">Initial value of the sent_bytes property.</param>
        /// <param name="recv_bytes">Initial value of the recv_bytes property.</param>
        /// <param name="time_taken">Initial value of the time_taken property.</param>
        public static iis_log_entry Createiis_log_entry(global::System.Int32 id, global::System.DateTime datetime, global::System.String server, global::System.String verb, global::System.String url, global::System.String ip, global::System.Int32 status, global::System.Int32 sent_bytes, global::System.Int32 recv_bytes, global::System.Int32 time_taken)
        {
            iis_log_entry iis_log_entry = new iis_log_entry();

            iis_log_entry.ID         = id;
            iis_log_entry.datetime   = datetime;
            iis_log_entry.server     = server;
            iis_log_entry.verb       = verb;
            iis_log_entry.url        = url;
            iis_log_entry.ip         = ip;
            iis_log_entry.status     = status;
            iis_log_entry.sent_bytes = sent_bytes;
            iis_log_entry.recv_bytes = recv_bytes;
            iis_log_entry.time_taken = time_taken;
            return(iis_log_entry);
        }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the iis_log_entry EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToiis_log_entry(iis_log_entry iis_log_entry)
 {
     base.AddObject("iis_log_entry", iis_log_entry);
 }
예제 #3
0
 /// <summary>
 /// Create a new iis_log_entry object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="datetime">Initial value of the datetime property.</param>
 /// <param name="server">Initial value of the server property.</param>
 /// <param name="verb">Initial value of the verb property.</param>
 /// <param name="url">Initial value of the url property.</param>
 /// <param name="ip">Initial value of the ip property.</param>
 /// <param name="status">Initial value of the status property.</param>
 /// <param name="sent_bytes">Initial value of the sent_bytes property.</param>
 /// <param name="recv_bytes">Initial value of the recv_bytes property.</param>
 /// <param name="time_taken">Initial value of the time_taken property.</param>
 public static iis_log_entry Createiis_log_entry(global::System.Int32 id, global::System.DateTime datetime, global::System.String server, global::System.String verb, global::System.String url, global::System.String ip, global::System.Int32 status, global::System.Int32 sent_bytes, global::System.Int32 recv_bytes, global::System.Int32 time_taken)
 {
     iis_log_entry iis_log_entry = new iis_log_entry();
     iis_log_entry.ID = id;
     iis_log_entry.datetime = datetime;
     iis_log_entry.server = server;
     iis_log_entry.verb = verb;
     iis_log_entry.url = url;
     iis_log_entry.ip = ip;
     iis_log_entry.status = status;
     iis_log_entry.sent_bytes = sent_bytes;
     iis_log_entry.recv_bytes = recv_bytes;
     iis_log_entry.time_taken = time_taken;
     return iis_log_entry;
 }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the iis_log_entry EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToiis_log_entry(iis_log_entry iis_log_entry)
 {
     base.AddObject("iis_log_entry", iis_log_entry);
 }
예제 #5
0
        public static void TransferToSqlAzure()
        {
            GenUtils.LogMsg("info", "IIS_Logs.TransferToSqlAzure", null);
            var bs = BlobStorage.MakeDefaultBlobStorage();
            var containername = "wad-iis-logfiles";
            var req_dicts = (List<Dictionary<string, string>>)bs.ListBlobs(containername).response;
            var req_blobs = req_dicts.Select(blob => blob["Name"]);

            var model_name = "iis_log_entry";
            var conn_str = GenUtils.MakeEntityConnectionString(model_name);
            var entities = new iis_log_entry_entities(conn_str);

            foreach (var blobname in req_blobs)
            {
                var response = bs.GetBlob(containername, blobname).HttpResponse;
                var log_str = response.DataAsString();
                var lines = log_str.Split('\n').ToList();
                var comments = lines.FindAll(line => line.StartsWith("#"));
                var empty_or_truncated = lines.FindAll(line => line.Length < 10);
                lines = lines.Except(comments).Except(empty_or_truncated).ToList();
                foreach (var line in lines)
                {
                    iis_log_entry iis_log_entry = default(iis_log_entry);
                    int db_result = -1;
                    try
                    {
                        iis_log_entry = new iis_log_entry();
                        var tmpline = GenUtils.RegexReplace(line, " +", "\t");
                        var fields = tmpline.Split('\t');
                        iis_log_entry.datetime = DateTime.Parse(fields[0] + "T" + fields[1] + ".000Z"); // datetime
                        iis_log_entry.server = fields[3]; // server
                        iis_log_entry.verb = fields[5]; // verb
                        iis_log_entry.url = fields[7] != "-" ? fields[6] + "?" + fields[7] : fields[6]; // url
                        iis_log_entry.ip = fields[10]; // ip
                        iis_log_entry.http_version = fields[11]; // http ver
                        iis_log_entry.user_agent = fields[12]; // user agent
                        iis_log_entry.referrer = fields[14]; // referrer
                        iis_log_entry.status = Convert.ToInt16(fields[16]); // status
                        iis_log_entry.w32_status = Convert.ToInt32(fields[18]); // w32 status
                        iis_log_entry.sent_bytes = Convert.ToInt32(fields[19]); // sent bytes
                        iis_log_entry.recv_bytes = Convert.ToInt32(fields[20]); // recv bytes
                        iis_log_entry.time_taken = Convert.ToInt32(fields[21]); // time taken
                    }
                    catch (Exception ex_log)
                    {
                        GenUtils.PriorityLogMsg("exception", "IIS_Logs.TransferToSqlAzure: " + line, ex_log.Message + ex_log.InnerException.Message);
                    }

                    try
                    {
                        entities.AddObject(entitySetName: model_name, entity: iis_log_entry);
                        db_result = entities.SaveChanges();
                        if (db_result != 1)
                            GenUtils.PriorityLogMsg("warning", "IIS_Logs.TransferToSqlAzure expected 1 but got " + db_result.ToString(), null);
                    }
                    catch (Exception ex_db)
                    {
                        GenUtils.PriorityLogMsg("exception", "IIS_Logs.TransferToSqlAzure SaveChanges", ex_db.Message + ex_db.InnerException.Message + ex_db.StackTrace);
                    }
                }

                try
                {
                    var bs_result = bs.DeleteBlob(containername, blobname);
                    var bs_status = bs_result.HttpResponse.status;
                    if (bs_status != System.Net.HttpStatusCode.Accepted)
                        GenUtils.LogMsg("warning", "IIS_Logs.TransferToSqlAzure expected Accepted but got " + bs_status.ToString(), null);
                }
                catch (Exception bs_db)
                {
                    GenUtils.PriorityLogMsg("exception", "IIS_Logs.TransferToSqlAzure DeleteBlob", bs_db.Message + bs_db.StackTrace);
                }
            }
        }