public void LoadSubCatalogs(string fileName)
        {
            try
            {
                string path;
                if (!Catalogs.ContainsKey(fileName))
                {
                    path = @"Catalog\SubCat\Empty.xml";
                }
                else
                {
                    path = string.Format(@"Catalog\SubCat\{0}.xml", fileName.Replace(" ", string.Empty));
                }
                if (path == "Catalog\\SubCat\\Всеобъявления.xml")
                {
                    path = @"Catalog\SubCat\Empty.xml";
                }

                FileStream    FS       = new FileStream(path, FileMode.Open);
                XmlSerializer XMLDeser = new XmlSerializer(typeof(UserCollection <string, string>));
                SubCatalogs = (UserCollection <string, string>)XMLDeser.Deserialize(FS);
                FS.Close();
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        public Catalog Get([CanBeNull] CultureInfo culture = null)
        {
            culture ??= DefaultCulture;

            if (!Catalogs.ContainsKey(culture))
            {
                Catalogs[culture] = Load(culture);
            }

            return(Catalogs[culture]);
        }
Exemple #3
0
        public CatalogData GetOrGenerateCatalog(Market market)
        {
            if (!Catalogs.ContainsKey(market.Id))
            {
                Catalogs.Add(market.Id, market.Catalog.Generate().Compress());
            }
            else if (!market.IsActive(Catalogs[market.Id].GeneratedAt))
            {
                Catalogs[market.Id] = market.Catalog.Generate().Compress();
            }

            return(Catalogs[market.Id]);
        }
Exemple #4
0
        public void OnCatalogReceived(Catalog obj)
        {
            if (!Catalogs.ContainsKey(obj.DeviceID))
            {
                Catalogs.Add(obj.DeviceID, obj);
                logger.Debug("OnCatalogReceived: " + JsonConvert.SerializeObject(obj));
            }
            if (GBSIPTransactions.ContainsKey(obj.DeviceID))
            {
                SIPTransaction _SIPTransaction = GBSIPTransactions[obj.DeviceID];
                obj.DeviceList.Items.FindAll(item => item != null).ForEach(catalogItem =>
                {
                    var devCata = DevType.GetCataType(catalogItem.DeviceID);
                    if (devCata == DevCataType.Device)
                    {
                        _SIPTransaction.TransactionRequestFrom.URI.User = catalogItem.DeviceID;
                        string gbname = "GB_" + catalogItem.Name;
                        //string gbname = "gb" + _SIPTransaction.TransactionRequest.RemoteSIPEndPoint.Address.ToString();
                        if (!string.IsNullOrEmpty(catalogItem.ParentID) && !obj.DeviceID.Equals(catalogItem.DeviceID))
                        {
                            gbname = "GB_" + catalogItem.Name;
                        }
                        logger.Debug("OnCatalogReceived.DeviceDmsRegister: catalogItem=" + JsonConvert.SerializeObject(catalogItem));

                        //query device info from db
                        string edit = IsDeviceExisted(catalogItem.DeviceID) ? "updated" : "added";

                        //Device Dms Register
                        DeviceDmsRegister(_SIPTransaction, gbname);

                        //Device Edit Event
                        DeviceEditEvent(catalogItem.DeviceID, edit);
                    }
                });
            }
        }