Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        public static void Run(DatumNodeService datumnode, string cfs_id, out System.Collections.Generic.List <DatumNode.CfsBlockItem> result)
        {
            if (cfs_id == null)
            {
                throw new Exception("cfs_id is empty");
            }

            result = new List <DatumNode.CfsBlockItem>();
            try
            {
                var resultAudit = datumnode.ExecuteQuery("*.*.oss.sri.cfs.getAudit", new Dictionary <string, object>()
                {
                    { "cfs_id", cfs_id }
                });

                var auditList = resultAudit.Elements.Where(x => x.Name == "Entity").Select(x =>
                {
                    return(new AuditItem()
                    {
                        cfs_block_begin = (DateTime?)x.Element("cfs_block_begin"),
                        cfs_block_end = (DateTime?)x.Element("cfs_block_end"),
                        cfs_suspend_begin = (DateTime?)x.Element("cfs_suspend_begin"),
                        cfs_suspend_end = (DateTime?)x.Element("cfs_suspend_end"),
                        cfs_fin_block_begin = (DateTime?)x.Element("cfs_fin_block_begin"),
                        cfs_fin_block_end = (DateTime?)x.Element("cfs_fin_block_end"),
                        public_document_group_id = (string)x.Element("public_document_group_id")
                    });
                }).ToList();

                //var auditListFiltered = auditList.Where(x => x.GetType().GetProperties().Where(p => p.PropertyType == typeof(DateTime?)).Select(p => p.GetValue(x)).Any(value => value != null));
                if (!auditList.Any())
                {
                    return;
                }

                var auditBlockArr = auditList.ToArray();

                var finBlockList = new List <DatumNode.CfsBlockItem>();
                var admBlockList = new List <DatumNode.CfsBlockItem>();
                var volBlockList = new List <DatumNode.CfsBlockItem>();
                var t            = new CfsBlockItem();

                for (int i = auditBlockArr.Length - 1; i > 0; i--)
                {
                    if (auditBlockArr[i].cfs_fin_block_begin.HasValue == false && auditBlockArr[i - 1].cfs_fin_block_begin.HasValue == false)
                    {
                        continue;
                    }
                    if (auditBlockArr[i].cfs_fin_block_begin.HasValue == false && auditBlockArr[i - 1].cfs_fin_block_begin.HasValue == true ||
                        auditBlockArr[i].cfs_fin_block_begin.Value != auditBlockArr[i - 1].cfs_fin_block_begin.Value)
                    {
                        t = new CfsBlockItem()
                        {
                            type_block = fin,
                            date_begin = auditBlockArr[i - 1].cfs_fin_block_begin.Value,
                            date_end   = null,
                            id_begin   = auditBlockArr[i - 1].public_document_group_id
                        }
                    }
                    ;
                    if (auditBlockArr[i].cfs_fin_block_begin.HasValue == true && auditBlockArr[i].cfs_fin_block_end.HasValue == false && auditBlockArr[i - 1].cfs_fin_block_end.HasValue == true)
                    {
                        t.date_end = auditBlockArr[i - 1].cfs_fin_block_end;
                        t.id_end   = auditBlockArr[i - 1].public_document_group_id;
                        finBlockList.Add(t);
                        continue;
                    }
                }
                ;
                if (t.date_begin.HasValue == true && t.date_end.HasValue == false)
                {
                    finBlockList.Add(t);
                    t = new CfsBlockItem();
                }

                for (int i = auditBlockArr.Length - 1; i > 0; i--)
                {
                    if (auditBlockArr[i].cfs_block_begin.HasValue == false && auditBlockArr[i - 1].cfs_block_begin.HasValue == false)
                    {
                        continue;
                    }
                    if (auditBlockArr[i].cfs_block_begin.HasValue == false && auditBlockArr[i - 1].cfs_block_begin.HasValue == true ||
                        auditBlockArr[i].cfs_block_begin.Value != auditBlockArr[i - 1].cfs_block_begin.Value)
                    {
                        t = new CfsBlockItem()
                        {
                            type_block = adm,
                            date_begin = auditBlockArr[i - 1].cfs_block_begin.Value,
                            date_end   = null,
                            id_begin   = auditBlockArr[i - 1].public_document_group_id
                        }
                    }
                    ;
                    if (auditBlockArr[i].cfs_block_begin.HasValue == true && auditBlockArr[i].cfs_block_end.HasValue == false && auditBlockArr[i - 1].cfs_block_end.HasValue == true)
                    {
                        t.date_end = auditBlockArr[i - 1].cfs_block_end;
                        t.id_end   = auditBlockArr[i - 1].public_document_group_id;
                        admBlockList.Add(t);
                        continue;
                    }
                }
                ;
                if (t.date_begin.HasValue == true && t.date_end.HasValue == false)
                {
                    admBlockList.Add(t);
                    t = new CfsBlockItem();
                }

                for (int i = auditBlockArr.Length - 1; i > 0; i--)
                {
                    if (auditBlockArr[i].cfs_suspend_begin.HasValue == false && auditBlockArr[i - 1].cfs_suspend_begin.HasValue == false)
                    {
                        continue;
                    }
                    if (auditBlockArr[i].cfs_suspend_begin.HasValue == false && auditBlockArr[i - 1].cfs_suspend_begin.HasValue == true ||
                        auditBlockArr[i].cfs_suspend_begin.Value != auditBlockArr[i - 1].cfs_suspend_begin.Value)
                    {
                        t = new CfsBlockItem()
                        {
                            type_block = vol,
                            date_begin = auditBlockArr[i - 1].cfs_suspend_begin.Value,
                            date_end   = null,
                            id_begin   = auditBlockArr[i - 1].public_document_group_id
                        }
                    }
                    ;
                    if (auditBlockArr[i].cfs_suspend_begin.HasValue == true && auditBlockArr[i].cfs_suspend_end.HasValue == false && auditBlockArr[i - 1].cfs_suspend_end.HasValue == true)
                    {
                        t.date_end = auditBlockArr[i - 1].cfs_suspend_end;
                        t.id_end   = auditBlockArr[i - 1].public_document_group_id;
                        volBlockList.Add(t);
                        continue;
                    }
                }
                ;
                if (t.date_begin.HasValue == true && t.date_end.HasValue == false)
                {
                    volBlockList.Add(t);
                    t = new CfsBlockItem();
                }

                var resultSet = new List <DatumNode.CfsBlockItem>();

                if (finBlockList.Any())
                {
                    resultSet.AddRange(finBlockList);
                }

                if (admBlockList.Any())
                {
                    resultSet.AddRange(admBlockList);
                }

                if (volBlockList.Any())
                {
                    resultSet.AddRange(volBlockList);
                }

                result = resultSet.Any() ? resultSet.OrderByDescending(x => x.date_begin).ThenByDescending(x => x.date_end).ToList(): new List <CfsBlockItem>();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }