Exemple #1
0
    void MappingPABX(int id, ref objADCConfig obj)
    {
        string brand = "";
        string model = "";

        //
        DataRow[] dr = DTPABXBrand.Select("brand_id=" + id);
        if (dr.Length > 0)
        {
            brand = dr[0][0].ToString().Split(':')[0].Trim();
            model = dr[0][0].ToString().Split(':')[1].Trim();
        }
        //
        obj.ADC_PABX_Name  = brand;
        obj.ADC_PABX_Model = model;
    }
Exemple #2
0
    objADCConfig MappingToObject(DataRow drSetting)
    {
        objADCConfig _objADCConfig = new objADCConfig();

        try
        {
            _objADCConfig.ADC_DataCenterIP       = "";
            _objADCConfig.ADC_DataCenterPassword = "";
            _objADCConfig.ADC_DataCenterUserName = "";
            //
            _objADCConfig.ADC_ID         = drSetting["adc_name"].ToString();
            _objADCConfig.ADC_Serial     = drSetting["adc_serial"].ToString();
            _objADCConfig.ADCPort1Config = GetPortType(Convert.ToInt16(drSetting["adc_port_1"]), 1);
            _objADCConfig.ADCPort2Config = GetPortType(Convert.ToInt16(drSetting["adc_port_2"]), 2);
            //
            _objADCConfig.ADC_IP         = drSetting["adc_ipadress"].ToString();
            _objADCConfig.ADC_Subnetmask = drSetting["adc_netmask"].ToString();
            _objADCConfig.ADC_Gateway    = drSetting["adc_gateway"].ToString();
            //
            MappingPABX(Convert.ToInt16(drSetting["adc_pabx_brand"]), ref _objADCConfig);
            //
            _objADCConfig.ADC_DragoIP    = drSetting["adc_water_ipaddress"].ToString();
            _objADCConfig.ADC_DragoPort  = Convert.ToInt16(drSetting["adc_water_port"]);
            _objADCConfig.E_Meter_AMR    = drSetting["adc_auto_e_meter_every_time"].ToString();
            _objADCConfig.W_Meter_AMR    = drSetting["adc_auto_w_meter_every_time"].ToString();
            _objADCConfig.PABX_AMR       = drSetting["adc_auto_p_meter_every_time"].ToString();
            _objADCConfig.E_Meter_Period = ConvertToSecond(drSetting["adc_auto_e_meter_every_at_min"].ToString()).ToString();
            _objADCConfig.W_Meter_Period = ConvertToSecond(drSetting["adc_auto_w_meter_every_at_min"].ToString()).ToString();
            //

            return(_objADCConfig);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message.ToString());
        }
    }
Exemple #3
0
 public DataTable GetConfigFromADC(objADCConfig _objADCConfig)
 {
     return(MappingToDataTable(_objADCConfig));
 }
Exemple #4
0
    DataTable MappingToDataTable(objADCConfig _objADCConfig)
    {
        DataTable AdcDTSetting = new DataTable();

        #region DeClare Column Type of Data Table
        AdcDTSetting.Columns.Add("adc_name", typeof(string));
        AdcDTSetting.Columns.Add("adc_serial", typeof(string));
        AdcDTSetting.Columns.Add("adc_mac_address", typeof(string));
        AdcDTSetting.Columns.Add("adc_port_use_defualt", typeof(bool));
        AdcDTSetting.Columns.Add("adc_port_1", typeof(int));
        AdcDTSetting.Columns.Add("adc_port_2", typeof(int));
        AdcDTSetting.Columns.Add("adc_network_config_type", typeof(int));
        AdcDTSetting.Columns.Add("adc_ipadress", typeof(string));
        AdcDTSetting.Columns.Add("adc_netmask", typeof(string));
        AdcDTSetting.Columns.Add("adc_gateway", typeof(string));
        AdcDTSetting.Columns.Add("adc_pabx_connect", typeof(bool));
        AdcDTSetting.Columns.Add("adc_pabx_brand", typeof(int));
        AdcDTSetting.Columns.Add("adc_pabx_boud", typeof(int));
        AdcDTSetting.Columns.Add("adc_pabx_use_default", typeof(bool));
        AdcDTSetting.Columns.Add("adc_water_connect", typeof(bool));
        AdcDTSetting.Columns.Add("adc_water_brand", typeof(string));
        AdcDTSetting.Columns.Add("adc_water_ipaddress", typeof(string));
        AdcDTSetting.Columns.Add("adc_water_port", typeof(string));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every_at", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every_at", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_p_meter_every_at", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every_time", typeof(TimeSpan));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every_time", typeof(TimeSpan));
        AdcDTSetting.Columns.Add("adc_auto_p_meter_every_time", typeof(TimeSpan));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every_at_min", typeof(int));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every_at_min", typeof(int));
        #endregion
        try
        {
            //
            AdcDTSetting.Rows.Add(
                _objADCConfig.ADC_ID,
                _objADCConfig.ADC_Serial,
                "",   //macaddress
                null, //default port check
                GetPortTypeID(_objADCConfig.ADCPort1Config.ADC_PortDeviceType, _objADCConfig.ADCPort1Config.ADC_PortType),
                GetPortTypeID(_objADCConfig.ADCPort2Config.ADC_PortDeviceType, _objADCConfig.ADCPort2Config.ADC_PortType),
                0,//radioGroupNetworkConfig.SelectedIndex
                _objADCConfig.ADC_IP,
                _objADCConfig.ADC_Subnetmask,
                _objADCConfig.ADC_Gateway,
                false,                                   //checkEditConnectPABX.Checked
                Convert.ToInt16(GetPABXID(_objADCConfig.ADC_PABX_Name, _objADCConfig.ADC_PABX_Model)),
                0,                                       //PABXBaudrate
                false,                                   //checkEditPABXDefault
                false,                                   //checkEditConnectWater
                _objADCConfig.ADC_DragoIP != "" ? 1 : 0, //water meter brand
                _objADCConfig.ADC_DragoIP,
                _objADCConfig.ADC_DragoPort,
                _objADCConfig.E_Meter_AMR.Trim() != "0",
                _objADCConfig.W_Meter_AMR.Trim() != "0",
                _objADCConfig.PABX_AMR.Trim() != "0",
                GetTimeSpan(_objADCConfig.E_Meter_AMR),
                GetTimeSpan(_objADCConfig.W_Meter_AMR),
                GetTimeSpan(_objADCConfig.PABX_AMR),
                _objADCConfig.E_Meter_Period != "0",
                _objADCConfig.W_Meter_Period != "0",
                ConvertToMinute(_objADCConfig.E_Meter_Period),
                ConvertToMinute(_objADCConfig.W_Meter_Period)
                );
        }
        catch (Exception ex) {
        }
        //
        return(AdcDTSetting);
    }
    objADCConfig MappingToObject(DataRow drSetting)
    {
        objADCConfig _objADCConfig = new objADCConfig();
        try
        {
            _objADCConfig.ADC_DataCenterIP = "";
            _objADCConfig.ADC_DataCenterPassword = "";
            _objADCConfig.ADC_DataCenterUserName = "";
            //
            _objADCConfig.ADC_ID = drSetting["adc_name"].ToString();
            _objADCConfig.ADC_Serial = drSetting["adc_serial"].ToString();
            _objADCConfig.ADCPort1Config = GetPortType(Convert.ToInt16(drSetting["adc_port_1"]), 1);
            _objADCConfig.ADCPort2Config = GetPortType(Convert.ToInt16(drSetting["adc_port_2"]), 2);
            //
            _objADCConfig.ADC_IP = drSetting["adc_ipadress"].ToString();
            _objADCConfig.ADC_Subnetmask = drSetting["adc_netmask"].ToString();
            _objADCConfig.ADC_Gateway = drSetting["adc_gateway"].ToString();
            //
            MappingPABX(Convert.ToInt16(drSetting["adc_pabx_brand"]), ref _objADCConfig);
            //
            _objADCConfig.ADC_DragoIP = drSetting["adc_water_ipaddress"].ToString();
            _objADCConfig.ADC_DragoPort = Convert.ToInt16(drSetting["adc_water_port"]);
            _objADCConfig.E_Meter_AMR = drSetting["adc_auto_e_meter_every_time"].ToString();
            _objADCConfig.W_Meter_AMR = drSetting["adc_auto_w_meter_every_time"].ToString();
            _objADCConfig.PABX_AMR = drSetting["adc_auto_p_meter_every_time"].ToString();
            _objADCConfig.E_Meter_Period = ConvertToSecond(drSetting["adc_auto_e_meter_every_at_min"].ToString()).ToString();
            _objADCConfig.W_Meter_Period = ConvertToSecond(drSetting["adc_auto_w_meter_every_at_min"].ToString()).ToString();
            //

            return _objADCConfig;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message.ToString());
        }
    }
    DataTable MappingToDataTable(objADCConfig _objADCConfig)
    {
        DataTable AdcDTSetting = new DataTable();

        #region DeClare Column Type of Data Table
        AdcDTSetting.Columns.Add("adc_name", typeof(string));
        AdcDTSetting.Columns.Add("adc_serial", typeof(string));
        AdcDTSetting.Columns.Add("adc_mac_address", typeof(string));
        AdcDTSetting.Columns.Add("adc_port_use_defualt", typeof(bool));
        AdcDTSetting.Columns.Add("adc_port_1", typeof(int));
        AdcDTSetting.Columns.Add("adc_port_2", typeof(int));
        AdcDTSetting.Columns.Add("adc_network_config_type", typeof(int));
        AdcDTSetting.Columns.Add("adc_ipadress", typeof(string));
        AdcDTSetting.Columns.Add("adc_netmask", typeof(string));
        AdcDTSetting.Columns.Add("adc_gateway", typeof(string));
        AdcDTSetting.Columns.Add("adc_pabx_connect", typeof(bool));
        AdcDTSetting.Columns.Add("adc_pabx_brand", typeof(int));
        AdcDTSetting.Columns.Add("adc_pabx_boud", typeof(int));
        AdcDTSetting.Columns.Add("adc_pabx_use_default", typeof(bool));
        AdcDTSetting.Columns.Add("adc_water_connect", typeof(bool));
        AdcDTSetting.Columns.Add("adc_water_brand", typeof(string));
        AdcDTSetting.Columns.Add("adc_water_ipaddress", typeof(string));
        AdcDTSetting.Columns.Add("adc_water_port", typeof(string));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every_at", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every_at", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_p_meter_every_at", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every_time", typeof(TimeSpan));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every_time", typeof(TimeSpan));
        AdcDTSetting.Columns.Add("adc_auto_p_meter_every_time", typeof(TimeSpan));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every", typeof(bool));
        AdcDTSetting.Columns.Add("adc_auto_e_meter_every_at_min", typeof(int));
        AdcDTSetting.Columns.Add("adc_auto_w_meter_every_at_min", typeof(int));
        #endregion
        try
        {
            //
            AdcDTSetting.Rows.Add(
                _objADCConfig.ADC_ID,
                _objADCConfig.ADC_Serial,
                "",//macaddress
                null,//default port check
                GetPortTypeID(_objADCConfig.ADCPort1Config.ADC_PortDeviceType, _objADCConfig.ADCPort1Config.ADC_PortType),
                GetPortTypeID(_objADCConfig.ADCPort2Config.ADC_PortDeviceType, _objADCConfig.ADCPort2Config.ADC_PortType),
                0,//radioGroupNetworkConfig.SelectedIndex
                _objADCConfig.ADC_IP,
                _objADCConfig.ADC_Subnetmask,
                _objADCConfig.ADC_Gateway,
                false,//checkEditConnectPABX.Checked
                Convert.ToInt16(GetPABXID(_objADCConfig.ADC_PABX_Name, _objADCConfig.ADC_PABX_Model)),
                0,//PABXBaudrate
                false,//checkEditPABXDefault
                false,//checkEditConnectWater
                _objADCConfig.ADC_DragoIP != "" ? 1 : 0,//water meter brand
                _objADCConfig.ADC_DragoIP,
                _objADCConfig.ADC_DragoPort,
                _objADCConfig.E_Meter_AMR.Trim() != "0",
                _objADCConfig.W_Meter_AMR.Trim() != "0",
                _objADCConfig.PABX_AMR.Trim() != "0",
                GetTimeSpan(_objADCConfig.E_Meter_AMR),
                GetTimeSpan(_objADCConfig.W_Meter_AMR),
                GetTimeSpan(_objADCConfig.PABX_AMR),
                _objADCConfig.E_Meter_Period != "0",
                _objADCConfig.W_Meter_Period != "0",
                ConvertToMinute(_objADCConfig.E_Meter_Period),
                ConvertToMinute(_objADCConfig.W_Meter_Period)
            );
        }
        catch (Exception ex) {

        }
        //
        return AdcDTSetting;
    }
 void MappingPABX(int id, ref objADCConfig obj)
 {
     string brand = "";
     string model = "";
     //
     DataRow[] dr = DTPABXBrand.Select("brand_id=" + id);
     if (dr.Length > 0)
     {
         brand = dr[0][0].ToString().Split(':')[0].Trim();
         model = dr[0][0].ToString().Split(':')[1].Trim();
     }
     //
     obj.ADC_PABX_Name = brand;
     obj.ADC_PABX_Model = model;
 }
 public DataTable GetConfigFromADC(objADCConfig _objADCConfig)
 {
     return MappingToDataTable(_objADCConfig);
 }