Example #1
0
        private static string UploadFile(Stream fs)
        {
            var req = new HttpRequest("http://api-fotki.yandex.ru");

            req.ContentType = "image/jpeg";
            req.AddHeader("Authorization", string.Format("OAuth {0}", token));
            var result = req.Post(string.Format("/api/users/{0}/photos/", login), fs);

            if (req.Status != 200)
            {
                DConsole.WriteLine(req.Error);
                return(null);
            }

            var doc = new XmlDocument();

            doc.LoadXml(result);

            var nodes = doc.DocumentElement.ChildNodes;

            foreach (XmlNode node in nodes)
            {
                if (node.Name.Equals("link"))
                {
                    if (node.Attributes["rel"].Value.Equals("self"))
                    {
                        return(node.Attributes["href"].Value);
                    }
                }
            }

            return(null); //smth is going wrong...
        }
Example #2
0
        public static void Init()
        {
            doc = new XmlDocument();
            doc.Load(Application.GetResourceStream("BusinessProcess.BusinessProcess.xml"));

            var firstStepName = doc.DocumentElement.ChildNodes[0].ChildNodes[0].Attributes["Name"].Value;

            MoveTo(firstStepName);
        }
Example #3
0
        public static void Init()
        {
            if (!_initialized)
            {
                ApplicationContext.Current.Settings.ReadSettings();
            }
            var settings = DBHelper.GetSettings();

            if (_settings == null)
            {
                _settings = new Dictionary <string, object>();
            }

            while (settings.Next())
            {
                var dictionary = new Dictionary <string, object>(2)
                {
                    { Parameters.LogicValue, settings[Parameters.LogicValue] },
                    { Parameters.NumericValue, settings[Parameters.NumericValue] }
                };

                _settings[(string)settings["Description"]] = dictionary;
            }

#if DEBUG
            DConsole.WriteLine(Parameters.Splitter);
            DConsole.WriteLine($"Настройки в БД.{Environment.NewLine}");
            foreach (var item in _settings)
            {
                var element = (Dictionary <string, object>)item.Value;
                DConsole.WriteLine($"Description: {item.Key} LogicValue: {(bool)element[Parameters.LogicValue]}" +
                                   $" NumericValue: {(int)element[Parameters.NumericValue]}");
            }
            DConsole.WriteLine($"{Parameters.Splitter}{Environment.NewLine}");
#endif
            XmlNode serverNode;
            XmlNode solutionPathNode;

            Stream stream = Stream.Null;
            try
            {
                try
                {
                    stream = Application.GetResourceStream("customSettings.xml");
                }
                catch
                {
                    stream = Application.GetResourceStream("settings.xml");
                }

                var xmlDocument = new XmlDocument();
                xmlDocument.Load(stream);
                serverNode = xmlDocument.SelectSingleNode("/configuration/server/host");
                DConsole.WriteLine("Настройки из XML");
                DConsole.WriteLine($"{serverNode?.Name}:{serverNode?.Attributes?["url"]?.Value}");
                solutionPathNode = xmlDocument.SelectSingleNode("/configuration/server/solutionPath");
                DConsole.WriteLine($"{solutionPathNode?.Name}:{solutionPathNode?.Attributes?["url"]?.Value}");
            }
            finally
            {
                stream?.Close();
            }

            Host = serverNode?.Attributes?["url"]?.Value ?? "http://nt0420.bt";
            var server = Host + (solutionPathNode?.Attributes?["url"]?.Value ?? "/bitmobile/testsolution");

            Server      = server + "/device";
            ImageServer = server + "/";
            AuthUrl     = Server + @"/GetUserId";
            SolutionUrl = server;
            GPSSyncUrl  = server;

            DConsole.WriteLine($"Host = {Host}");
            DConsole.WriteLine($"Server = {Server}");

            PushServer = server;

            try
            {
                _enablePush = UserDetailedInfo.EnablePush;
            }
            catch (Exception e)
            {
                Utils.TraceMessage($"{e.Message} {Environment.NewLine}" +
                                   $"{e.StackTrace}");
                _enablePush = true;
            }

            _initialized = true;

            GpsTrackingInit();

            CheckAllProperty();
        }