示例#1
0
        private void UploadFile(string filename)
        {
            try
            {
                String strFile = System.IO.Path.GetFileName(filename);
                LoginUseService.LoginUse srv = new LoginUseService.LoginUse();

                FileInfo fInfo = new FileInfo(filename);

                long numBytes = fInfo.Length;
                double dLen = Convert.ToDouble(fInfo.Length / 1000000);

                if (dLen < 4 && this.SelectedUser != null)
                {
                    FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    BinaryReader br = new BinaryReader(fStream);
                    byte[] data = br.ReadBytes((int)numBytes);
                    br.Close();

                    string data64 = Convert.ToBase64String(data);

                    string sTmp = srv.UploadFile(data64, this.SelectedUser.phoneId);
                    fStream.Close();
                    fStream.Dispose();

                    MessageBox.Show(sTmp);

                }
                else
                {
                    if(dLen >= 4)
                        MessageBox.Show("The file selected exceeds the size limit for uploads.");
                    else
                        MessageBox.Show("Cargar un Valor en el campo PhoneId.");
                }
            }
            catch (Exception ex)
            {
                // display an error message to the user
                MessageBox.Show(ex.Message.ToString());
            }
        }
示例#2
0
        private void find()
        {
            DateTime from = this.dtpFrom.Value;
            DateTime to = this.dtpTo.Value;

            LoginUseService.LoginUse srv = new LoginUseService.LoginUse();

            string base64Data = srv.getCSVData(this.SelectedUser.phoneId, from, to, SelectedProperties);

            if (base64Data != null && base64Data.Length > 0)
                if (this.sfdFile.ShowDialog() == DialogResult.OK)
                    System.IO.File.WriteAllBytes(this.sfdFile.FileName, Convert.FromBase64String(base64Data));
                else
                    MessageBox.Show("File not saved.");
            else
                MessageBox.Show("Response Problem.");
        }