Example #1
0
 // ログ構造体を初期化する
 private void structInitialize(ref MainteLogStruct LogStruct)
 {
     LogStruct.LogType = 0;
     LogStruct.TimeStr = "";
     LogStruct.DateStr = "";
     LogStruct.Unit = 0;
     LogStruct.WorkIDType = 0;
     LogStruct.WorkID = 0;
     LogStruct.OldValue = "";
     LogStruct.NewValue = "";
     LogStruct.Comment = "";
 }
Example #2
0
        /// <summary>
        /// ログの一覧を取得する
        /// </summary>
        /// <returns></returns>
        public MainteLogStruct[] GetRecords()
        {
            MainteLogStruct[] recordarr = new MainteLogStruct[0];

            // ロードチェック
            if (!initFlag) return recordarr;

            // XMLファイルを読み出す
            var nodes = from n in xmlAccessor.document.Elements("maintelog").Elements("record")
                        orderby n.Attribute("date").Value, n.Attribute("time").Value descending
                        select n;

            // 配列を確保する
            int count = nodes.Count();
            Array.Resize(ref recordarr, count);

            // 配列を構造体にいれる
            int i = 0;
            foreach (var record in nodes)
            {
                structInitialize(ref recordarr[i]);
                recordarr[i].LogType = Int32.Parse(record.Attribute("type").Value);
                recordarr[i].DateStr = record.Attribute("date").Value;
                recordarr[i].TimeStr = record.Attribute("time").Value;
                recordarr[i].Unit = Int32.Parse(record.Element("unit").Attribute("code").Value);

                switch (recordarr[i].LogType)
                {
                    case SystemConstants.MAINTELOG_RECORD_TYPE_WORKID:
                        recordarr[i].WorkIDType = Int32.Parse(record.Element("value_change").Attribute("workidtype").Value);
                        recordarr[i].WorkID = Int32.Parse(record.Element("value_change").Attribute("workid").Value.Remove(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                        recordarr[i].OldValue = record.Element("value_change").Attribute("old").Value;
                        recordarr[i].NewValue = record.Element("value_change").Attribute("new").Value;
                        break;
                    case SystemConstants.MAINTELOG_RECORD_TYPE_COMMENT:
                        recordarr[i].Comment = record.Element("maintenance").Attribute("comment").Value;
                        break;
                }

                i++;
            }
            return recordarr;
        }