Example #1
0
        public static int requestDERGroupMembers([MarshalAs(UnmanagedType.LPTStr)] String path,
                                                 [MarshalAs(UnmanagedType.LPTStr)] String mrid,
                                                 [MarshalAs(UnmanagedType.LPTStr)] ref String xml)
        {
            DERResult result = new DERResult();

            try
            {
                Console.WriteLine("DER file : " + path);
                Console.WriteLine("MRID : " + mrid);
                String   SOAPMessage  = null;
                String   SOAPResponse = null;
                String[] rvalue       = CIM.requestDERGroupMembers(path, mrid, ref SOAPMessage, ref SOAPResponse);

                result.Members      = rvalue;
                result.SOAPMessage  = SOAPMessage;
                result.SOAPResponse = SOAPResponse;
                result.Returncode   = 0;
            }
            catch (Exception e)
            {
                result.Returncode   = 1;
                result.ErrorMessage = e.ToString();
                Console.Write("Exception thrown by requestDERGroupMembers : ", e);
            }

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

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

            return(result.Returncode);
        }
Example #2
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);
        }
Example #3
0
        public static int dispatchDERGroup(
            [MarshalAs(UnmanagedType.LPTStr)] String path,
            [MarshalAs(UnmanagedType.LPTStr)] String mrid,
            [MarshalAs(UnmanagedType.LPTStr)] String q,
            [MarshalAs(UnmanagedType.LPTStr)] ref String xml,
            [MarshalAs(UnmanagedType.Bool)] bool isOverride,
            [MarshalAs(UnmanagedType.R8)] double overrideValue)
        {
            DERResult result = new DERResult();

            try
            {
                quantity qtype = (quantity)Enum.Parse(typeof(DERMSInterface.quantity), q);
                Console.WriteLine("DER file : " + path);
                Console.WriteLine("DERGroupName : " + mrid);
                Console.WriteLine("Override : " + isOverride);
                Console.WriteLine("Override value : " + overrideValue);
                String SOAPMessage  = null;
                String SOAPResponse = null;
                int    rvalue       = CIM.DispatchDERGroup(path, mrid, qtype, ref SOAPMessage, ref SOAPResponse, isOverride, overrideValue);

                result.SOAPMessage  = SOAPMessage;
                result.SOAPResponse = SOAPResponse;
                result.Returncode   = 0;
            }
            catch (Exception e)
            {
                result.Returncode   = 1;
                result.ErrorMessage = e.ToString();
                Console.WriteLine("Exception: {0}", e);
            }

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

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

            return(result.Returncode);
        }
Example #4
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);
        }