示例#1
0
        private void button_visit_Click(object sender, EventArgs e)
        {
            try
            {
                var url            = this.textBox_url.Text;
                var gnssOptionText = this.richTextBoxControl_postParams.Text;

                if (String.IsNullOrWhiteSpace(gnssOptionText))
                {
                    MessageBox.Show("请输入配置文件再试!");
                    return;
                }

                try
                {
                    OptionManager manager = new OptionManager();
                    var           opt     = manager.Read(gnssOptionText, "nameOfOpt");
                    if (opt.ObsFiles == null || opt.ObsFiles.Count == 0)
                    {
                        MessageBox.Show("必须指定观测文件网址!O文件,D文件或O.Z都可以。");
                        return;
                    }
                    foreach (var item in opt.ObsFiles)
                    {
                        if (item.Contains(@":\"))
                        {
                            MessageBox.Show("请采用Internet的 FTP 或 网址,不要采用本地地址!O文件,D文件或O.Z都可以。\n" + item);
                            return;
                        }
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show("配置文件不合法,请仔细检查后再试!" + ex.Message);
                    return;
                }

                ShowInfo("即将发出计算服务请求,请耐心等待。。。。");

                Encoding encoding = Encoding.GetEncoding("utf-8");
                IDictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("gnssOptionText", gnssOptionText);
                HttpWebResponse response     = HttpWebRequestUtil.CreatePostHttpResponse(url, parameters, null, null, encoding, null);
                string          cookieString = response.Headers["Set-Cookie"];

                Stream       responseStream = response.GetResponseStream();
                StreamReader reader         = new System.IO.StreamReader(responseStream, Encoding.GetEncoding("UTF-8"));
                string       srcString      = reader.ReadToEnd();
                //返回值赋值
                reader.Close();

                ShowInfo("计算完毕,返回结果。");

                ShowInfo(srcString);
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void button_visit_Click(object sender, EventArgs e)
        {
            try
            {
                var url      = this.textBox_url.Text;
                var obsFiles = this.richTextBoxControl_obsUrls.Lines;

                if (obsFiles.Length == 0)
                {
                    MessageBox.Show("请输入配置文件再试!");
                    return;
                }
                StringBuilder sb = new StringBuilder();
                int           i  = 0;
                foreach (var item in obsFiles)
                {
                    if (item.Contains(@":\"))
                    {
                        MessageBox.Show("请采用Internet的 FTP 或 网址,不要采用本地地址!O文件,D文件或O.Z都可以。\n" + item);
                        return;
                    }
                    if (i != 0)
                    {
                        sb.Append(";");
                    }

                    sb.Append(item);
                    i++;
                }

                ShowInfo("即将发出计算服务请求,请耐心等待。。。。");

                Encoding encoding = Encoding.GetEncoding("utf-8");
                IDictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("obsUrls", sb.ToString());
                HttpWebResponse response     = HttpWebRequestUtil.CreatePostHttpResponse(url, parameters, null, null, encoding, null);
                string          cookieString = response.Headers["Set-Cookie"];

                Stream       responseStream = response.GetResponseStream();
                StreamReader reader         = new System.IO.StreamReader(responseStream, Encoding.GetEncoding("UTF-8"));
                string       srcString      = reader.ReadToEnd();
                //返回值赋值
                reader.Close();

                ShowInfo("计算完毕,返回结果。");

                ShowInfo(srcString);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 检查是否登录
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private OperatorVo CheckLogin(AuthorizationFilterContext context)
        {
            OperatorVo operatorVo = SessionUtils.Get <OperatorVo>(SESSION_LOGIN_USER);

            if (operatorVo != null)
            {
                return(operatorVo);
            }
            string           sessionId        = SessionUtils.GetSessionId("session_token");
            CookieCollection cookieCollection = new CookieCollection();

            foreach (var item in context.HttpContext.Request.Cookies)
            {
                cookieCollection.Add(new Cookie(item.Key, item.Value));
            }
            cookieCollection.Add(new Cookie("session_token", sessionId));
            HttpWebRequestUtil.ProcessCookies(cookieCollection);
            operatorVo = loginSdk.GetCurrentOperator();
            if (operatorVo != null)
            {
                SessionUtils.Set(SESSION_LOGIN_USER, operatorVo);
            }
            return(operatorVo);
        }