public void Update(INN inn, ApiMethod method, XmlDocument doc)
 {
     cleared     = false;
     Inn         = inn;
     this.method = method;
     document    = doc;
 }
Beispiel #2
0
 public void Clear(INN inn, ApiMethod method)
 {
     foreach (var cache in caches)
     {
         cache.Clear(inn, method);
     }
 }
Beispiel #3
0
        public static INN CreateUnsafe(string str)
        {
            var req = new INN();

            req.isOGRN = str.Length > 12;
            req.value  = str;
            return(req);
        }
Beispiel #4
0
 public static bool TryParse(string str, out INN req)
 {
     req = new INN();
     if (!InnCheckSum(str))
     {
         return(false);
     }
     req.isOGRN = str.Length > 12;
     req.value  = str;
     return(true);
 }
        public bool TryGetXml(INN inn, ApiMethod method, out XmlDocument document)
        {
            if (!cleared && Inn == inn && method == this.method)
            {
                document = this.document;
                return(true);
            }

            document = new XmlDocument();
            return(false);
        }
        public bool TryGetXml(INN inn, ApiMethod method, out XmlDocument document)
        {
            document = new XmlDocument();
            var path = $"{cacheFolder}/{inn}.{method}";

            if (!File.Exists(path))
            {
                return(false);
            }
            document.Load(path);
            return(true);
        }  //TODO cache fluency
 public Company CreateFromInn(INN inn)
 {
     try
     {
         Exception = null;
         return(new Company(inn, paramDict, manager, enableScore));
     }
     catch (Exception e)
     {
         Exception = e;//TODO make better message system
         return(new Company(inn, paramDict, manager, false));
     }
 }
Beispiel #8
0
 internal Company(INN inn, Dictionary <string, CompanyParameter> paramDict, FocusKeyManager manager = null, bool scoringNeeded = true)
 {    //TODO remove singleton
     manager        = manager ?? Settings.DefaultManager;
     access         = manager.Access;
     scorer         = manager.Scorer;
     Inn            = inn;
     this.paramDict = paramDict;
     Score          = -1;
     if (scoringNeeded)
     {
         MakeScore();
     }
 }
Beispiel #9
0
        public bool TryGetXml(INN inn, ApiMethod method, out XmlDocument document)
        {
            for (int i = 0; i < caches.Count; i++)
            {
                if (caches[i].TryGetXml(inn, method, out document))
                {
                    for (int j = 0; j < i; j++)
                    {
                        caches[j].Update(inn, method, document);
                    }
                    return(true);
                }
            }

            if (!source.TryGetXml(inn, method, out document))
            {
                return(false);
            }
            foreach (var cache in caches)
            {
                cache.Update(inn, method, document);
            }
            return(true);
        }
 public void Clear(INN inn, ApiMethod method)
 {
     File.Delete($"{cacheFolder}/{inn}.{method}");
 }
        }  //TODO cache fluency

        public void Update(INN inn, ApiMethod method, XmlDocument doc)
        {
            doc.Save($"{cacheFolder}/{inn}.{method}");
        }
 public void Clear(INN inn, ApiMethod method)
 {
     cleared = true;
 }
Beispiel #13
0
 public void Clear(INN inn, ApiMethod method)
 {
 }
Beispiel #14
0
 public void Update(INN inn, ApiMethod method, XmlDocument doc)
 {
 }
Beispiel #15
0
 public bool TryGetXml(INN inn, ApiMethod method, out XmlDocument document)
 {
     document = new XmlDocument();
     return(!availableMethods.Contains(method));
 }
Beispiel #16
0
 public bool TryGetXml(INN inn, ApiMethod method, out XmlDocument document)
 {
     return(TryGetXml(
                $"https://focus-api.kontur.ru/api3/{GetMethodName(method)}?key={focusKey}&{inn.URL()}&xml",
                out document));
 }