예제 #1
0
        public static void Write(string filename, string content)
        {
            try
            {
                if (!Configs.GetDumpFile())
                {
                    return;
                }

                var dumpDir = Path.Combine(App.WorkingDir, "DumpJson");
                if (!Directory.Exists(dumpDir))
                {
                    Directory.CreateDirectory(dumpDir);
                }

                var dumpFile = Path.Combine(dumpDir, filename);
                File.WriteAllText(dumpFile, content);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #2
0
        public static async Task <GetMyInfo> Login()
        {
            try
            {
                var _username = Configs.GetUsername();
                var _password = Configs.GetPassword();

                if (string.IsNullOrWhiteSpace(_username) || string.IsNullOrWhiteSpace(_password))
                {
                    throw new Exception("Please fill the Username & Password!");
                }

                var request = RequestBuilder("user/login", Method.POST);
                request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
                request.AddParameter("application/x-www-form-urlencoded", $"remember=true&username={_username}&password={_password}", ParameterType.RequestBody);
                var content = await ClientExecute(request);

                DumpFile.Write("Login.json", content);

                if (!isJsonFormat(content))
                {
                    throw new Exception("Response: not json format!");
                }

                return(JsonConvert.DeserializeObject <GetMyInfo>(content));
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR : " + ex.Message);
                return(new GetMyInfo()
                {
                    errno = -100,
                    msg = ex.Message
                });
            }
        }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();

            Title = string.Format("{0} v{1}", Title, App.GetBuildVersion());

            var lastHeight = Configs.GetHeight();

            if (SystemParameters.PrimaryScreenHeight > lastHeight)
            {
                var diff = lastHeight - Height;
                Height             = lastHeight;
                listBox.MinHeight += diff;
            }

            var top  = Configs.GetWindowTop();
            var left = Configs.GetWindowLeft();

            if (top != 0 || left != 0)
            {
                Top  = top;
                Left = left;
            }
        }