Example #1
0
 public void SetActionResponseCallBack(ActionResponse actionResponse)
 {
     ActionResponseCallback(actionResponse);
 }
Example #2
0
        private bool DataDownloadAction(string downloadQuery, string dir, string logfilename)
        {
            ActionResponse actionresponse;

            foreach (KeyValuePair <string, string> item in listBoxAllDataTypes.SelectedItems)
            {
                actionresponse = new ActionResponse();
                string query = downloadQuery;


                string datatype     = item.Key.ToString();
                string datatypeName = item.Value.ToString();
                query = query.Replace("@DataType", datatype);
                query = query.Replace("@DownloadDate", DateTime.Today.ToString("yyyy-MM-dd"));
                byte[] result = ClientLoginForm.aventServiceClient.DataDownloadAction(query);

                string results = Helper.DecompressData(result);
                if (results == null)
                {
                    MessageBox.Show("No Results Returned");
                    return(true);
                }
                DataSet ds = new DataSet();

                StringReader  sr  = new StringReader(results);
                XmlTextReader xtr = new XmlTextReader(sr);

                ds.ReadXml(xtr);
                ds.Merge(ds, true);
                if (ds.Tables.Count > 0)
                {
                    string filename = dir + string.Format(@"\{0}.csv", datatypeName);
                    actionresponse.Message = string.Format("{0} Record(s) returned", ds.Tables[0].Rows.Count);
                    if (DataTableToCsv(ds.Tables[0], filename))
                    {
                        actionresponse.Message = string.Format("{0} Record(s) written to file:{1}",
                                                               ds.Tables[0].Rows.Count, filename);
                        ActionResponseCallback(actionresponse);
                    }
                    else
                    {
                        actionresponse.Message = string.Format(" Error writing records to file:{0}", filename);
                        ActionResponseCallback(actionresponse);
                    }


                    /*
                     *  lblrow.Text =
                     *  SetGridStructure();
                     *  dataGridView1.DataSource = ds.Tables[0];
                     *  dataGridView1.Refresh();
                     */
                }
                else
                {
                    lblrow.Text = string.Format("{0} Record(s) returned", 0);
                }
            }
            ExportGridViewToCsv(logfilename, dataGridView2);
            return(false);
        }