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

            req.isOGRN = str.Length > 12;
            req.value  = str;
            return(req);
        }
예제 #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);
 }
예제 #5
0
        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);
        }
예제 #6
0
        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
예제 #7
0
 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));
     }
 }
예제 #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();
     }
 }
예제 #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);
        }
예제 #10
0
 public void Clear(INN inn, ApiMethod method)
 {
     File.Delete($"{cacheFolder}/{inn}.{method}");
 }
예제 #11
0
        }  //TODO cache fluency

        public void Update(INN inn, ApiMethod method, XmlDocument doc)
        {
            doc.Save($"{cacheFolder}/{inn}.{method}");
        }
예제 #12
0
 public void Clear(INN inn, ApiMethod method)
 {
     cleared = true;
 }
예제 #13
0
 public void Clear(INN inn, ApiMethod method)
 {
 }
예제 #14
0
 public void Update(INN inn, ApiMethod method, XmlDocument doc)
 {
 }
예제 #15
0
 public bool TryGetXml(INN inn, ApiMethod method, out XmlDocument document)
 {
     document = new XmlDocument();
     return(!availableMethods.Contains(method));
 }
예제 #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));
 }