예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         StatisticsServiceSoapClient serviceclient = new StatisticsServiceSoapClient();
         PopulateControls(serviceclient.GetStatistics());
     }
 }
예제 #2
0
        /// <summary>
        /// Uploads csv file to the server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (FileUploadControl.HasFile)
            {
                try
                {
                    if (FileUploadControl.PostedFile.ContentType == "application/CSV" || FileUploadControl.PostedFile.ContentType == "application/vnd.ms-excel")
                    {
                        if (FileUploadControl.PostedFile.ContentLength < 102400)
                        {
                            string filename   = Path.GetFileName(FileUploadControl.FileName);
                            string serverPath = Server.MapPath("~/") + filename;

                            FileUploadControl.SaveAs(serverPath);

                            var bytes = File.ReadAllBytes(serverPath);
                            StatisticsServiceSoapClient serviceclient = new StatisticsServiceSoapClient();

                            serviceclient.UploadFile(bytes, filename);
                            lblStatus.Text = "File uploaded!";
                            List <StatisticsServiceRef.Statistics> lst = serviceclient.GetStatistics();

                            PopulateControls(lst);
                        }
                        else
                        {
                            lblStatus.Text = "The file has to be less than 100 kb!";
                        }
                    }
                    else
                    {
                        lblStatus.Text = "Only CSV files are accepted!";
                    }
                }
                catch (Exception ex)
                {
                    lblStatus.Text = "The following error occured: " + ex.Message;
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Gets response from service
        /// </summary>
        private void GetResponse()
        {
            string op = Request.QueryString["op"];
            string no = Request.QueryString["uid"];

            op = (op ?? "0");
            no = (no ?? "0");

            StatisticsServiceSoapClient serviceclient = new StatisticsServiceSoapClient();

            switch (op)
            {
            case "0":
                txtXml.Text = serviceclient.GetStatisticsJSON(no);
                break;

            case "1":
                txtXml.Text = serviceclient.GetStatisticsXML(no);
                break;

            default:
                break;
            }
        }