Esempio n. 1
0
 public Tariff(string name, string operatorname, double payroll, CallPrices callPrices, double smsprice, Parameters parameters)
 {
     this.name          = name;
     this.operator_name = operatorname;
     this.payroll       = payroll;
     this.call_Prices   = callPrices;
     this.sms_price     = smsprice;
     this.paremeters    = parameters;
 }
Esempio n. 2
0
        /*Метод, возвращающий цены тарифа */
        private CallPrices buildCallPrices(XmlNode xmlN)
        {
            CallPrices callPrices = new CallPrices();

            foreach (XmlNode cnode in xmlN.ChildNodes)
            {
                if (cnode.Name == "inside_network")
                {
                    callPrices.setInsideNetwork(Convert.ToDouble(cnode.InnerText));
                }
                if (cnode.Name == "outside_network")
                {
                    callPrices.setOutsideNetwork(Convert.ToDouble(cnode.InnerText));
                }
                if (cnode.Name == "fixed_phone")
                {
                    callPrices.setFixed_Phone(Convert.ToDouble(cnode.InnerText));
                }
            }
            return(callPrices);
        }
Esempio n. 3
0
 public void setCallPrices(CallPrices call)
 {
     this.call_Prices = call;
 }
Esempio n. 4
0
        /*Метод, который парсит Xml-файл */
        public List <Tariff> Read_XML()
        {
            List <Tariff> tariffs = new List <Tariff>();

            XSDValidation = true;
            XmlReaderSettings xmlSettings = new XmlReaderSettings();

            xmlSettings.Schemas.Add("http://www.example.com/students", xsdPath);
            xmlSettings.ValidationType          = ValidationType.Schema;
            xmlSettings.ValidationEventHandler += new ValidationEventHandler(booksSettingsValidationEventHandler);
            Tariff     tariff     = new Tariff();
            CallPrices callPrices = new CallPrices();
            Parameters parameters = new Parameters();

            using (XmlReader tarr = XmlReader.Create(xmlPath, xmlSettings))
            {
                try {
                    while (tarr.Read())
                    {
                        if (tarr.HasAttributes)
                        {
                            // получение атрибутов
                            while (tarr.MoveToNextAttribute())
                            {
                                if (tarr.Name == "name")
                                {
                                    tariff.setName(tarr.Value);
                                }
                                if (tarr.Name == "operator_name")
                                {
                                    tariff.setOperatorName(tarr.Value);
                                }
                            }
                        }
                        // получение значений элементов Xml-файла
                        switch (tarr.NodeType)
                        {
                        case XmlNodeType.Element:
                            switch (tarr.Name)
                            {
                            case "payroll":
                                tarr.Read();
                                tariff.setPayroll(Convert.ToDouble(tarr.Value));
                                break;

                            case "call_prices":
                                tarr.Read();
                                tariff.setCallPrices(callPrices);
                                break;

                            case "inside_network":
                                tarr.Read();
                                tariff.getCallPrices().setInsideNetwork(Convert.ToDouble(tarr.Value));
                                break;

                            case "outside_network":
                                tarr.Read();
                                tariff.getCallPrices().setOutsideNetwork(Convert.ToDouble(tarr.Value));
                                break;

                            case "fixed_phone":
                                tarr.Read();
                                tariff.getCallPrices().setFixed_Phone(Convert.ToDouble(tarr.Value));
                                break;

                            case "sms_price":
                                tarr.Read();
                                tariff.setSmsPrice(Convert.ToDouble(tarr.Value));
                                break;

                            case "parameters":
                                tarr.Read();
                                tariff.setParameters(parameters);
                                break;

                            case "favorite_number":
                                tarr.Read();
                                tariff.getParameters().setFavouriteNumber(Convert.ToInt64(tarr.Value));
                                break;

                            case "tariffication":
                                tarr.Read();
                                tariff.getParameters().setTarifficaton(tarr.Value);
                                break;

                            case "connection_fee":
                                tarr.Read();
                                tariff.getParameters().setConnection_Fee(Convert.ToDouble(tarr.Value));
                                break;
                            }
                            break;

                        // добавление в список законченного объекта
                        case XmlNodeType.EndElement:
                            if (tarr.Name == "tariff")
                            {
                                tariffs.Add(tariff);
                                // "обнуление" переменных
                                tariff     = new Tariff();
                                parameters = new Parameters();
                                callPrices = new CallPrices();
                            }
                            break;
                        }
                    }
                } catch (Exception)
                {
                    XSDValidation = false;
                }
            }
            // вернуть список тарифов
            return(tariffs);
        }