public string GetLogString(UDT.MeetingRoom each) { StringBuilder log = new StringBuilder(); try { log.AppendLine(string.Format("場地名稱「{0}」所屬大樓「{1}」", each.Name, each.Building)); if (!string.IsNullOrEmpty(each.Picture)) { log.AppendLine(string.Format("照片URL「{0}」", each.Picture)); } if (!string.IsNullOrEmpty("" + each.Capacity)) { log.AppendLine(string.Format("容納人數「{0}」", each.Capacity)); } if (!string.IsNullOrEmpty(each.Status)) { log.AppendLine(string.Format("會議室目前狀態「{0}」", each.Status)); } if (!string.IsNullOrEmpty("" + each.RefUnitID)) { if (UnitIDDic.ContainsKey("" + each.RefUnitID)) { log.AppendLine(string.Format("管理單位名稱「{0}」", UnitIDDic["" + each.RefUnitID])); } } if (!string.IsNullOrEmpty("" + each.IsSpecial)) { log.AppendLine(string.Format("是否為特殊場地「{0}」", each.IsSpecial)); } if (!string.IsNullOrEmpty(each.CreateTime.ToShortDateString())) { log.AppendLine(string.Format("建立日期「{0}」", each.CreateTime.ToShortDateString())); } // 建立者帳號 if (!string.IsNullOrEmpty(each.CreatedBy)) { //if (TeacherAccountDic.ContainsKey(each.CreatedBy)) //{ // log.AppendLine(string.Format("建立者「{0}」", GetTeacherName(TeacherAccountDic[each.CreatedBy]))); //} log.AppendLine(string.Format("建立者「{0}」", Actor.Account)); } } catch (Exception ex) { System.Console.WriteLine(ex.Message); } return(log.ToString()); }
/// <summary> /// 此函數的目的是將 Rows 中的每一筆場地設備資料,整理成: /// 1. 要新增的場地 (listRoomInsert ) /// 2. 要修改的場地 (listRoomUpdate ) /// 3. 每個場地的設備清單 (dicEquipment ) /// </summary> /// <param name="Rows"></param> /// <param name="listRoomInsert"></param> /// <param name="listRoomUpdate"></param> /// <param name="dicEquipmentInRoom"></param> private void parseData(List <Campus.DocumentValidator.IRowStream> Rows, List <UDT.MeetingRoom> listRoomInsert, List <UDT.MeetingRoom> listRoomUpdate, Dictionary <string, List <UDT.MeetingRoomEquipment> > dicEquipmentInRoom) { // 對於每一筆場地的設備資料 foreach (IRowStream Row in Rows) { //a. 確認場地是新增或修改 string building = Row.GetValue("所屬大樓名稱"); string roomName = Row.GetValue("會議室名稱"); string equipName = Row.GetValue("設備名稱"); string keyRoom = string.Format("{0}_{1}", roomName, building); // 會議室key if (importBot.GetMeetingRoomDic().ContainsKey(keyRoom)) //更新 { if (importBot.GetMeetingRoomDic()[keyRoom].UID != "") // 確保資料有系統編號 在做更新 { UDT.MeetingRoom room = importBot.GetMeetingRoomDic()[keyRoom]; // ???? if (!Log_Dic.ContainsKey(room.UID)) { ImputLog i_n = new ImputLog(); i_n.lo_MeetingRoom = room.CopyExtension(); Log_Dic.Add(room.UID, i_n); } importBot.FillMeetingRoomData(Row, room); listRoomUpdate.Add(room); } } else { //新增 UDT.MeetingRoom room = new UDT.MeetingRoom(); room.Name = roomName; room.Building = building; importBot.FillMeetingRoomData(Row, room); // 將新增的會議室加入Dic 避免重複新增 importBot.GetMeetingRoomDic().Add(keyRoom, room); listRoomInsert.Add(room); } //b. 確認設備所屬場地 //string keyEquip = string.Format("{0}_{1}", keyRoom, equipName); // 設備key if (!dicEquipmentInRoom.ContainsKey(keyRoom)) { dicEquipmentInRoom.Add(keyRoom, new List <UDT.MeetingRoomEquipment>()); } UDT.MeetingRoomEquipment equip = new UDT.MeetingRoomEquipment(); importBot.FillEquipmentData(Row, equip); dicEquipmentInRoom[keyRoom].Add(equip); } }
/// <summary> /// 把 Row 中的場地資料填入 MeetingRoom 物件。 /// </summary> /// <param name="Row"></param> /// <param name="room"></param> public void FillMeetingRoomData(IRowStream Row, UDT.MeetingRoom room) { room.Name = Row.GetValue("會議室名稱"); room.Picture = Row.GetValue("照片"); room.Building = Row.GetValue("所屬大樓名稱"); int x = 0; if (int.TryParse("" + Row.GetValue("容納人數"), out x)) { room.Capacity = x; } room.Status = Row.GetValue("會議室目前狀態"); room.RefUnitID = int.Parse(CheckUnitName("" + Row.GetValue("管理單位名稱"))); room.IsSpecial = Row.GetValue("是否為特殊場地") == "是" ? true : false; room.CreateTime = DateTime.Now; room.CreatedBy = Actor.Account; }