Beispiel #1
0
        private void btnExecuteServerRequest_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> serverrequests = new Dictionary <string, string>();

            serverrequests.Add("Async", "3");
            serverrequests.Add("Single_All", "1");
            serverrequests.Add("Single_RowNumber", "2");
            serverrequests.Add("Select_Server_Option", "");
            string requestType = serverrequests[cboxServerRequestType.Text];



            string  insurername = ConfigurationManager.AppSettings["insurerName"].ToString();
            DataSet ds          = new DataSet();

            ds.Tables.Add(currentProcessingTable.Copy());
            string    filename        = "XPathMapper.xlsx";
            string    fileExt         = ".xlsx";
            DataTable datatableMapper = ReadExcelSheet(filename, fileExt, "Sheet2$");

            foreach (DataRow dr in datatableMapper.Rows)
            {
                if (dr["InputOutputType"].ToString() == "Output")
                {
                    dr["XPath"] = dr["XPath"].ToString().Replace("Comparer/", "Comparer/" + insurername + "/" + insurername);
                }
            }
            datatableMapper.TableName = "MapperTable";
            ds.Tables.Add(datatableMapper);
            if (requestType == "2")
            {
                SingleRequestWindow singleRequestWindow = new SingleRequestWindow(ds, currentProcessingTable.TableName, datatableMapper.TableName, requestType, txtRowNumber.Text);
                singleRequestWindow.ProcessSingleInputData();
                singleRequestWindow.Show();
                return;
            }
            DCTAsyncReuestHandling.RequestAddResponse rq = new DCTAsyncReuestHandling.RequestAddResponse(ds, currentProcessingTable.TableName, datatableMapper.TableName, requestType, txtRowNumber.Text);
            rq.ProcessAllInputData();
            if (ConfigurationManager.AppSettings["WriteToExcel"].ToString() == "1")
            {
                ReadWriteExcelSheet readWriteExcelSheet = new ReadWriteExcelSheet();
                readWriteExcelSheet.WriteToExcel(ds.Tables[currentProcessingTable.TableName], DateTime.Now.ToString("yyyyMMdd_HHmmssfff_") + currentProcessingTable.TableName + ".xlsx");
            }
            ds.Dispose();
            GC.Collect();
            MessageBox.Show("Request Processing Completed");
        }
        private void btnSavetoExcelSheet_Click(object sender, RoutedEventArgs e)
        {
            if (dataTable != null)
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName   = "Book1";                          // Default file name
                dlg.DefaultExt = ".xlsx";                          // Default file extension
                dlg.Filter     = "Excel documents (.xlsx)|*.xlsx"; // Filter files by extension

                // Show save file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process save file dialog box results
                if (result == true)
                {
                    string filename = dlg.FileName;
                    ReadWriteExcelSheet readWriteExcelSheet = new ReadWriteExcelSheet();
                    readWriteExcelSheet.WriteToExcel(dataTable, filename);
                }
            }
        }