Esempio n. 1
0
        public static int createDERGroup(
            [MarshalAs(UnmanagedType.LPTStr)] String path,
            [MarshalAs(UnmanagedType.LPTStr)] String mrid,
            [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = _arraySize)] String[] names,
            [MarshalAs(UnmanagedType.LPTStr)] ref String xml)
        {
            DERResult     result   = new DERResult();
            List <String> nameList = new List <string>();

            try
            {
                /*
                 * the String[] names is terminated when we find
                 * a value = null. This is due to marshalling in
                 * c#. We build a list and then pass a normal string
                 * array to the createDerGroup
                 */
                for (int i = 0; i < _arraySize; i++)
                {
                    if (names[i] == null)
                    {
                        break;
                    }
                    nameList.Add(names[i]);
                }

                Console.WriteLine("DER file : " + path);
                Console.WriteLine("DERGroupName : " + mrid);
                String SOAPMessage  = null;
                String SOAPResponse = null;
                int    rvalue       = CIM.CreateDERGroup(path, mrid, nameList.ToArray <String>(), ref SOAPMessage, ref SOAPResponse);
                result.SOAPMessage  = SOAPMessage;
                result.SOAPResponse = SOAPResponse;
                result.Returncode   = 0;
            }
            catch (Exception e)
            {
                result.Returncode   = 1;
                result.ErrorMessage = e.ToString();
                Console.WriteLine("DERConfigureException: {0}", e);
            }

            XmlSerializer ser    = new XmlSerializer(typeof(DERResult));
            StringWriter  writer = new StringWriter();

            ser.Serialize(writer, result);
            xml = writer.ToString();

            return(result.Returncode);
        }
Esempio n. 2
0
        public static int getDERGroupStatus(
            [MarshalAs(UnmanagedType.LPTStr)] String path,
            [MarshalAs(UnmanagedType.LPTStr)] String mrid,
            [MarshalAs(UnmanagedType.LPTStr)] String q,
            [MarshalAs(UnmanagedType.LPTStr)] ref String xml)
        {
            DERResult     result   = new DERResult();
            List <String> nameList = new List <string>();

            try
            {
                quantity qtype = (quantity)Enum.Parse(typeof(DERMSInterface.quantity), q);

                Console.WriteLine("DER file : " + path);
                Console.WriteLine("DERGroupName : " + mrid);
                String            SOAPMessage  = null;
                String            SOAPResponse = null;
                CIMData.DERStatus status       = CIM.getDERGroupStatus(path, mrid, qtype, ref SOAPMessage, ref SOAPResponse);
                int rvalue = CIM.CreateDERGroup(path, mrid, nameList.ToArray <String>(), ref SOAPMessage, ref SOAPResponse);
                result.Status       = status;
                result.SOAPMessage  = SOAPMessage;
                result.SOAPResponse = SOAPResponse;
                result.Returncode   = 0;
            }
            catch (Exception e)
            {
                result.Returncode   = 1;
                result.ErrorMessage = e.ToString();
                Console.WriteLine("DERConfigureException: {0}", e);
            }

            XmlSerializer ser    = new XmlSerializer(typeof(DERResult));
            StringWriter  writer = new StringWriter();

            ser.Serialize(writer, result);
            xml = writer.ToString();

            return(result.Returncode);
        }