private void BtnPurge_Click(object sender, EventArgs e)
        {
            SAPDocumentList DocList = new SAPDocumentList();

            if (webAPIconnect == null || !webAPIconnect.isLoggedOn())
            {
                TraceBox.Text += "Not logged on. Could not fetch document parameters.\r\n";
                return;
            }

            if (!(!TxtFolderId.Text.Equals(string.Empty) ^ !TxtDocId.Text.Equals(string.Empty)))
            {
                TraceBox.Text += "Please choose either Document or Folder for export\r\n";
                return;
            }

            if (!Rbtn_webi41.Checked && !Rbtn_webi4x.Checked)
            {
                TraceBox.Text += "Please select Webi version to continue...\r\n";
                return;
            }

            TraceBox.Text += "Attempting HTTP Request...\r\n";

            if (!TxtFolderId.Text.Equals(string.Empty))
            {
                try
                {
                    if (Rbtn_webi4x.Checked)
                    {
                        DocList = docOperation.GetDocumentList(TxtFolderId.Text);
                    }
                    else
                    {
                        DocList = docOperation.GetDocumentListInfostore(TxtFolderId.Text);
                    }
                }
                catch (Exception exc)
                {
                    Debug.WriteLine(exc.Message);
                    Debug.Flush();
                    TraceBox.Text += "Error in Document List Fetch...\r\n";
                    TraceBox.Text += "Cannot get Document or Folder ...\r\n";
                    return;
                }
            }
            else
            {
                DocList.entries.Add(docOperation.GetDocumentInfo(TxtDocId.Text));
            }

            try
            {
                Debug.WriteLine("Number of Documents to purge:" + DocList.entries.Count.ToString());
                TraceBox.Text += "Number of Documents to purge:" + DocList.entries.Count.ToString() + "\r\n";
                foreach (SAPDocument doc in DocList)
                {
                    foreach (SAPDataProvider dp in doc.DataProviderList)
                    {
                        docOperation.PurgeDataProviders(doc.SI_ID, dp.ID, true);

                        if (webAPIconnect.responseContent.Contains("success"))
                        {
                            TraceBox.Text += "Success... \r\n";
                        }
                    }
                }
                TraceBox.Text += "Closing HTTP Request...\r\n";
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
                Debug.Flush();
                MessageBox.Show("Error in Document Purge... \r\n" + "Error Code:" + exc.Message);
                return;
            }
        }
        private void BtnExport_Click(object sender, EventArgs e)
        {
            SAPDocumentList DocList = new SAPDocumentList();

            if (webAPIconnect == null || !webAPIconnect.isLoggedOn())
            {
                TraceBox.Text += "Not logged on. Could not fetch document parameters.\r\n";
                return;
            }

            if (!(!TxtFolderId.Text.Equals(string.Empty) ^ !TxtDocId.Text.Equals(string.Empty)))
            {
                TraceBox.Text += "Please choose either Document or Folder for export\r\n";
                return;
            }

            if (!Rbtn_webi41.Checked && !Rbtn_webi4x.Checked)
            {
                TraceBox.Text += "Please select Webi version to continue...\r\n";
                return;
            }

            TraceBox.Text += "Attempting HTTP Request...\r\n";

            if (!TxtFolderId.Text.Equals(string.Empty))
            {
                try
                {
                    if (Rbtn_webi4x.Checked)
                    {
                        DocList = docOperation.GetDocumentList(TxtFolderId.Text);
                    }
                    else
                    {
                        DocList = docOperation.GetDocumentListInfostore(TxtFolderId.Text);
                    }
                }
                catch (Exception exc)
                {
                    Debug.WriteLine(exc.Message);
                    Debug.Flush();
                    TraceBox.Text += "Error in Document List Fetch...\r\n";
                    TraceBox.Text += "Cannot get Document or Folder ...\r\n";
                    return;
                }
            }
            else
            {
                DocList.entries.Add(docOperation.GetDocumentInfo(TxtDocId.Text));
            }



            try
            {
                Debug.WriteLine("Number of Documents to export:" + DocList.entries.Count.ToString());
                Debug.Flush();
                ExcelExport xlsx = new ExcelExport(DocList);
                xlsx.GenerateExcel(TxtFilename.Text);
                TraceBox.Text += "Closing HTTP Request...\r\n";
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
                Debug.Flush();
                TraceBox.Text += "Excel creation failed...\r\n";
                TraceBox.Text += "Attempting CSV...\r\n";
                try
                {
                    CSVExport csv = new CSVExport(DocList);
                    csv.ExportReportList(TxtFilename.Text.Replace("xlsx", "csv"));
                }
                catch (Exception CSVexc)
                {
                    Debug.WriteLine(CSVexc.Message);
                    Debug.Flush();
                    TraceBox.Text += "CSV creation failed...\r\n";
                    return;
                }
            }

            try {
                FHSQLExport fhsql = new FHSQLExport(DocList);
                fhsql.ExportFHSQL(TxtFilename.Text.Replace("xlsx", "fhsql"));
                TraceBox.Text += "Closing HTTP Request...\r\n";
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
                Debug.Flush();
                MessageBox.Show("Error in FHSQL save... \r\n" + "Error Code:" + exc.Message);
                return;
            }
        }
Exemplo n.º 3
0
 public ExcelExport(SAPDocumentList docList)
 {
     DocList = docList;
 }
Exemplo n.º 4
0
 public CSVExport(SAPDocumentList docList)
 {
     DocList = docList;
 }
Exemplo n.º 5
0
        //It is better to use the Infostore solution with Serializers for the response XML...
        // Working for 4.1 and above
        public SAPDocumentList GetDocumentListInfostore(string FolderId)
        {
            Debug.WriteLine("In GetDocumentListInfostore  for folder:" + FolderId);
            Debug.Flush();
            SAPDocumentList docList     = new SAPDocumentList();
            string          send        = string.Empty;
            string          recv        = string.Empty;
            XmlDocument     XmlResponse = new XmlDocument();

            try
            {
                Debug.WriteLine("Try...");
                Debug.Flush();
                webAPIconnect.Send("GET", "/biprws/infostore/" + FolderId + "/children?pageSize=200", send, "application/xml", "application/xml");
                TextReader    reader              = new StringReader(webAPIconnect.responseContent);
                XmlSerializer serializer          = new XmlSerializer(typeof(feed));
                feed          deserializedEntries = serializer.Deserialize(reader) as feed;
                if (deserializedEntries.entry == null)
                {
                    Debug.WriteLine("Null deserialized Entries");
                    Debug.Flush();
                }
                else
                {
                    Debug.WriteLine("Deserialized Entries:" + deserializedEntries.entry.Length);
                    Debug.Flush();
                    foreach (var entry in deserializedEntries.entry)
                    {
                        SAPDocument doc         = new SAPDocument();
                        string      cuid        = string.Empty;
                        string      name        = string.Empty;
                        string      description = string.Empty;
                        string      id          = string.Empty;
                        string      type        = string.Empty;

                        foreach (var attr in entry.content.attrs)
                        {
                            switch (attr.name)
                            {
                            case "type":
                                type = attr.Value;
                                break;

                            case "name":
                                name = attr.Value;
                                break;

                            case "description":
                                description = attr.Value;
                                break;

                            case "id":
                                id = attr.Value;
                                break;

                            case "cuid":
                                cuid = attr.Value;
                                break;

                            default:
                                break;
                            }
                        }

                        if (type.Equals("Webi"))
                        {
                            docList.entries.Add(GetDocument(id));
                            Debug.WriteLine("Doc ID:" + id);
                            Debug.Flush();
                        }
                        else if (type.Equals("Folder"))
                        {
                            SAPDocumentList docListInner = GetDocumentListInfostore(id);
                            Debug.WriteLine("Folder ID:" + id);
                            Debug.WriteLine("Inner list size:" + docListInner.entries.Count.ToString());
                            Debug.Flush();
                            docList.entries.AddRange(docListInner.entries);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error in document fetch from Infostore:" + e.StackTrace);
                Debug.WriteLine("Response:" + webAPIconnect.responseContent);
                Debug.WriteLine(e.Message);
                Debug.Flush();
            }
            return(docList);
        }
Exemplo n.º 6
0
 public FHSQLExport(SAPDocumentList docList)
 {
     DocList = docList;
 }