public static void Run(DatumNodeService datumnode, string cfs_id, out System.Collections.Generic.List <Cfs> result) { if (cfs_id == null) { throw new Exception("cfs_id is empty"); } Func <Cfs, bool> isClosed = x => { var now = DateTime.Now; return(now < x.Begin || x.End != null && now > x.End); }; result = new List <Cfs>(); try { var resultGetCfs = datumnode.ExecuteQuery("*.*.oss.sri.cfs.get", new Dictionary <string, object>() { { "cfs_id", Decimal.Parse(cfs_id) }, { "descendants", 1 } }); var sourceCfs = resultGetCfs.Elements.Where(x => x.Name == "Entity").Select(x => new Cfs() { Id = (Decimal?)x.Element("cfs_id"), ExtId = (String)x.Element("cfs_public_id"), ServiceName = (String)x.Element("service_name"), Begin = (DateTime?)x.Element("cfs_begin"), End = (DateTime?)x.Element("cfs_end"), ParentId = (Decimal?)x.Element("cfs_parent_id"), CfsParentsStr = (String)x.Element("cfs_parents_str"), PublicResource = (String)x.Element("public_resource"), PublicResourceType = (String)x.Element("public_resource_type") }).ToList(); if (!sourceCfs.Any()) { return; } var extIds = sourceCfs.Select(x => x.ExtId).ToArray(); var resultCheckSbms = datumnode.Execute("*.*.oss_api.sri.action_api.check_sbms_exists", new Dictionary <string, object>() { { "cfs_public_ids", String.Join(";", extIds) } }); var notExistIdsSrc = resultCheckSbms["not_existed_ids"] as string; if (notExistIdsSrc == null) { notExistIdsSrc = string.Empty; } var notExistIds = new HashSet <string>(notExistIdsSrc.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries)); foreach (var item in sourceCfs) { item.SBMSStatus = notExistIds.Contains(item.ExtId) ? "Нет" : "Да"; item.Status = !isClosed(item) ? "Открыт" : "Закрыт"; item.ItemPath = GetPath(sourceCfs, item.Id); } result = sourceCfs.OrderBy(x => x.ItemPath).ToList(); } catch (Exception e) { throw new Exception(e.Message); } }
public static void Run(DatumNodeService datumnode, string equipment_serial, string equipment_prov_method, out System.Collections.Generic.List <Parameter> result) { if (equipment_serial == null) { throw new Exception("equipment_serial is empty"); } result = new List <Parameter>(); try { var resultGetCpe = datumnode.ExecuteQuery("*.*.gs_api.store_api.Api.get_cpe", new Dictionary <string, object>() { { "sn", equipment_serial } }); int?resultId = Int32.Parse(resultGetCpe["result"].ToString()); var result_text = resultGetCpe["result_text"] as string; if (resultId.HasValue == false || resultId.HasValue == true && resultId.Value < 1) { throw new Exception(result_text); } int?cpeId = Int32.Parse(resultGetCpe["result_num"].ToString()); var cpeInfoSet = datumnode.ExecuteQuery("*.*.gs_api.store_api.Api.get_cpe_info", new Dictionary <string, object>() { { "sn", equipment_serial }, { "comm_id", cpeId } }); resultId = Int32.Parse(cpeInfoSet["result"].ToString()); result_text = cpeInfoSet["result_text"] as string; if (resultId.HasValue == false || resultId.HasValue == true && resultId.Value < 1) { throw new Exception(result_text); } var xDocXml = cpeInfoSet["xml"] as string; var xDoc = XDocument.Parse(xDocXml); var cpe = xDoc.Descendants("cpe").First(); const string cpeTypeNameTag = "TYPDEVICE_NAME"; const string cpeModelTag = "MARKACOMM_NAME"; const string cpeVendorTag = "VENDOR_NAME"; const string cpeMacAddressTag = "MAC_ADDRESS"; const string cpePonSerialTag = "PON_SERIAL"; const string cpeConditionTag = "DEV_CONDITION_NAME"; const string cpeTransferConditionTag = "TRANSFER_CONDITION_NAME"; const string cpeExploitStatusTag = "EXPLOIT_STATUS_NAME"; if (cpe == null) { return; } if (cpe.Element(cpeTypeNameTag) != null) { result.Add(new Parameter("Тип оборудования", (string)cpe.Element(cpeTypeNameTag))); } if (cpe.Element(cpeModelTag) != null) { result.Add(new Parameter("Модель оборудования", (string)cpe.Element(cpeModelTag))); } if (cpe.Element(cpeVendorTag) != null) { result.Add(new Parameter("Производитель", (string)cpe.Element(cpeVendorTag))); } if (cpe.Element(cpeMacAddressTag) != null) { result.Add(new Parameter("MAC-адрес", (string)cpe.Element(cpeMacAddressTag))); } if (cpe.Element(cpePonSerialTag) != null) { result.Add(new Parameter("PON Номер", (string)cpe.Element(cpePonSerialTag))); } if (cpe.Element(cpeConditionTag) != null) { result.Add(new Parameter("Состояние", (string)cpe.Element(cpeConditionTag))); } if (cpe.Element(cpeExploitStatusTag) != null) { result.Add(new Parameter("Статус", (string)cpe.Element(cpeExploitStatusTag))); } if (!string.IsNullOrEmpty(equipment_prov_method)) { var cpeTransferResult = datumnode.Execute("*.*.oss.external.sri.getTag", new Dictionary <string, object>() { { "synonimTag", equipment_prov_method }, { "tagGroupSyn", "equipmentProvidingMethod" }, { "extSystem", "COMB2B" }, }); var cpeTransferCondition = cpeTransferResult["result"] as string; if (!string.IsNullOrEmpty(cpeTransferCondition)) { result.Add(new Parameter("Условие передачи", cpeTransferCondition)); } else if (cpe.Element(cpeTransferConditionTag) != null) { result.Add(new Parameter("Условие передачи", (string)cpe.Element(cpeTransferConditionTag))); } } else { if (cpe.Element(cpeTransferConditionTag) != null) { result.Add(new Parameter("Условие передачи", (string)cpe.Element(cpeTransferConditionTag))); } } var cpeInfo = new Parameter("Идентификатор в Склад CPE", cpeId.Value.ToString()); result.Add(cpeInfo); } catch (Exception e) { throw new Exception(e.Message); } }