Esempio n. 1
0
        /// <summary>
        /// returns json object of all available params with all distinct values
        /// </summary>
        /// <returns></returns>
        public static string GetAvailableParams()
        {
            string ret = "{ ";

            var zz = PredictiveProcessData.ParseProcessData(PredictiveProcessData.LoadEnergyProcessDataFromXml(GetCccXmlHttpResponse("GET", String.Format(cccxml_get, JsonConvert.SerializeObject(new int[] { 33000 })))).First(), 5, 0);

            foreach (ProcessDataParam param in zz.Params)
            {
                string val = "";
                if (param.NumValue != null)
                {
                    val = param.NumValue.ToString();
                }
                else if (param.DateValue != null)
                {
                    val = param.DateValue.ToString();
                }
                else
                {
                    val = param.StrValue;
                }
                ret += "\"" + param.Name + "\" : \"" + val + "\", ";
            }
            return(ret.Substring(0, ret.Length - 2) + " }");
        }
Esempio n. 2
0
        /// <summary>
        /// general GET method for process data
        /// </summary>
        /// <param name="processIds"></param>
        /// <param name="precision"></param>
        /// <param name="links"></param>
        /// <returns></returns>
        public static IEnumerable <PredictiveProcessData> GetProcessFromWS(int[] processIds, decimal precision = 0m, int links = 5)
        {
            List <PredictiveProcessData> ret = new List <PredictiveProcessData>();

            foreach (XElement ent in PredictiveProcessData.LoadEnergyProcessDataFromXml(GetCccXmlHttpResponse("GET", String.Format(cccxml_get, JsonConvert.SerializeObject(processIds)))))
            {
                ret.Add(PredictiveProcessData.ParseProcessData(ent, links, precision));
            }
            return(ret);
        }
Esempio n. 3
0
        /// <summary>
        /// save new process directly from xml
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static bool InsertProcess(FileStream xml)
        {
            string env = "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" > " +
                         "<Body xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" > " +
                         "<CCCXML_INSERT xmlns=\"services.wsdl\" > " +
                         "<process_xml xmlns=\"services.wsdl\" type=\"http://www.w3.org/2001/XMLSchema:string\">" +
                         "<![CDATA[<Data>{0}</Data>]]>" +
                         "</process_xml></CCCXML_INSERT></Body></Envelope>";

            foreach (XElement ent in PredictiveProcessData.LoadEnergyProcessDataFromXml(xml))
            {
                string result = GetCccXmlHttpResponse("INSERT", String.Format(env, ent.ToString()));
                if (!result.Contains("Non unique primary key") && !result.Contains("inserted"))
                {
                    xml.Close();
                    return(false);
                }
            }
            xml.Close();
            return(true);
        }