Example #1
0
        public object ExcluirRelatorioAcompanhamentoDiario([FromBody] JObject data)
        {
            Resposta resposta = new Resposta();

            try
            {
                AFElement afElement = data.ToObject <AFElement>();

                string path = @"\\" + PISystemName + @"\" + DatabaseName;
                // Verify if Database exists
                if (!PIWebAPIAccess.GetDatabase(BaseUrl, path))
                {
                    throw new Exception(string.Format("Database {0} does not existis!", DatabaseName));
                }

                path = path + @"\" + MasterReportElementName;
                // Verify if element "Reports" exists
                if (!PIWebAPIAccess.GetElement(BaseUrl, path))
                {
                    throw new Exception(string.Format("Element {0} does not existis!", MasterReportElementName));
                }

                path = path + @"\" + afElement.Name;

                PIWebAPIAccess.DeleteElement(BaseUrl, path);

                resposta.Status = true;
            }
            catch (Exception ex)
            {
                resposta.Status   = false;
                resposta.Mensagem = ex.Message;
            }
            return(resposta);
        }
Example #2
0
        public object SalvarRelatorioAcompanhamentoDiario([FromBody] JObject data)
        {
            Resposta resposta = new Resposta();

            try
            {
                AFElement afElement = data.ToObject <AFElement>();

                string path = @"\\" + PISystemName + @"\" + DatabaseName;

                // Verify if Database exists
                if (!PIWebAPIAccess.GetDatabase(BaseUrl, path))
                {
                    throw new Exception(string.Format("Database {0} does not existis!", DatabaseName));
                }

                path = path + @"\" + MasterReportElementName;
                // Verify if element "Reports" exists
                if (!PIWebAPIAccess.GetElement(BaseUrl, path))
                {
                    throw new Exception(string.Format("Element {0} does not existis!", MasterReportElementName));
                }

                path = @"\\" + PISystemName + @"\" + DatabaseName + @"\" + MasterReportElementName + @"\" + afElement.Name;
                // Verify if current "Relatorio de Acompanhameto Diario" exists
                if (PIWebAPIAccess.GetElementByWebId(BaseUrl, afElement.WebId))
                {
                    PIWebAPIAccess.DeleteElementByWebId(BaseUrl, afElement.WebId);
                }

                path = @"\\" + PISystemName + @"\" + DatabaseName + @"\" + MasterReportElementName;
                // Create current "Relatorio de Acompanhameto Diario" element
                PIWebAPIAccess.CreateElement(BaseUrl, path, ref afElement);

                // Create each attribute for the "Relatorio de Acompanhameto Diario" element
                foreach (var item in afElement.Attributes)
                {
                    PIWebAPIAccess.CreateAttribute(BaseUrl, afElement.Path, item.Name, item.Value);
                }


                resposta.Dados  = afElement;
                resposta.Status = true;
            }
            catch (Exception ex)
            {
                resposta.Status   = false;
                resposta.Mensagem = ex.Message;
            }
            return(resposta);
        }
Example #3
0
        public object RecuperarRelatorioAcompanhamentoDiario()
        {
            Resposta resposta = new Resposta();

            try
            {
                string path = @"\\" + PISystemName + @"\" + DatabaseName;

                // Verify if Database exists
                if (!PIWebAPIAccess.GetDatabase(BaseUrl, path))
                {
                    path = @"\\" + PISystemName;
                    PIWebAPIAccess.CreateDatabase(BaseUrl, path, DatabaseName);
                    path = @"\\" + PISystemName + @"\" + DatabaseName;
                }

                path = path + @"\" + MasterReportElementName;
                // Verify if element "Reports" exists
                if (!PIWebAPIAccess.GetElement(BaseUrl, path))
                {
                    path = @"\\" + PISystemName + @"\" + DatabaseName;
                    PIWebAPIAccess.CreateMasterElement(BaseUrl, path, MasterReportElementName);
                    path = path + @"\" + MasterReportElementName;
                }

                List <AFElement> afElements = new List <AFElement>();

                // Get all elements childs
                afElements = PIWebAPIAccess.GetChildsElements(BaseUrl, path);

                // Get all Attributes childs
                foreach (var item in afElements)
                {
                    item.Attributes = PIWebAPIAccess.GetAttributes(BaseUrl, item.Path);
                }

                resposta.Dados  = afElements;
                resposta.Status = true;
            }
            catch (Exception ex)
            {
                resposta.Status   = false;
                resposta.Mensagem = ex.Message;
            }
            return(resposta);
        }