Пример #1
0
        private void SaveGsmConfigClick(object sender, RoutedEventArgs e)
        {
            try
            {
                sconnSite toSave = sconnDataShare.getSite(_siteId);

                //load data to save
                for (int i = 0; i < ipcDefines.RAM_SMS_RECP_NO; i++)
                {
                    TextBox  inputname = (TextBox)_editViewControls["Recipient" + i];
                    CheckBox chkbx     = (CheckBox)_editViewControls["RecipientEn" + i];
                    //TODO
                    //toSave.siteCfg.gsmRcpts[i].NumberE164 = inputname.Text;
                    //toSave.siteCfg.gsmRcpts[i].Enabled = (bool)chkbx.IsChecked;
                }

                if (_configManager.WriteSiteGsmCfg(toSave))  //try uploading changed device
                {
                    sconnDataSrc filesrc = new sconnDataSrc();
                    filesrc.SaveConfig(DataSourceType.xml);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public ChangePasswordWnd(int site)
 {
     InitializeComponent();
     _siteId = site;
     InputPasswordTb.MaxLength = ipcDefines.PasswordMaxChars;
     InputConfirmTb.MaxLength  = ipcDefines.PasswordMaxChars;
     _cfgMan       = new sconnCfgMngr();
     _configSource = new sconnDataSrc();
 }
Пример #3
0
        private void SaveGlobalConfigClick(object sender, RoutedEventArgs e)
        {
            try
            {
                sconnSite toSave = sconnDataShare.getSite(_siteId);

                GbxConfigureSiteNames gnames = (GbxConfigureSiteNames)_editViewControls["GlobalNames"];
                toSave.siteCfg.GlobalNameConfig = gnames.Serialize();


                if (_configManager.WriteGlobalNamesCfg(toSave) && _configManager.WriteGlobalCfg(toSave))    //try uploading changed device
                {
                    sconnDataSrc filesrc = new sconnDataSrc();
                    filesrc.SaveConfig(DataSourceType.xml);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #4
0
        private void SaveDeviceConfigClick(object sender, RoutedEventArgs e, int devId)
        {
            //load data to save
            sconnSite toSave     = sconnDataShare.getSite(_siteId);
            TextBox   devicename = (TextBox)_editViewControls["Device" + devId.ToString()];
            string    dname      = devicename.Text;


            toSave.siteCfg.deviceConfigs[devId].SetDeviceNameAt(0, dname);

            int inputsNo  = toSave.siteCfg.deviceConfigs[devId].memCFG[ipcDefines.mAdrInputsNO];
            int outputsNo = toSave.siteCfg.deviceConfigs[devId].memCFG[ipcDefines.mAdrOutputsNO];
            int relayNo   = toSave.siteCfg.deviceConfigs[devId].memCFG[ipcDefines.mAdrRelayNO];
            int schedNo   = ipcDefines.RAM_DEV_SCHED_NO;

            GbxConfigureInputsGroup gbxInputConfig = (GbxConfigureInputsGroup)_editViewControls["Input_Cfg" + devId];

            for (int i = 0; i < inputsNo; i++)
            {
                TextBox inputname = (TextBox)_editViewControls["Input" + devId + "." + i];
                string  inname    = inputname.Text;
                toSave.siteCfg.deviceConfigs[devId].SetDeviceNameAt(i + ipcDefines.mAddr_NAMES_Inputs_Pos, inname);

                toSave.siteCfg.deviceConfigs[devId].memCFG[ipcDefines.mAdrInput + i * ipcDefines.mAdrInputMemSize + ipcDefines.mAdrInputType] = gbxInputConfig.GetInputTypeAt(i);
                toSave.siteCfg.deviceConfigs[devId].memCFG[ipcDefines.mAdrInput + i * ipcDefines.mAdrInputMemSize + ipcDefines.mAdrInputAG]   = gbxInputConfig.GetInputAgAt(i);
            }

            GbxConfigureOutputsGroup gbxOutputConfig = (GbxConfigureOutputsGroup)_editViewControls["Output_Cfg" + devId];

            for (int i = 0; i < outputsNo; i++)
            {
                TextBox inputname = (TextBox)_editViewControls["Output" + devId + "." + i];
                string  inname    = inputname.Text;
                toSave.siteCfg.deviceConfigs[devId].SetDeviceNameAt(i + ipcDefines.mAddr_NAMES_Outputs_Pos, inname);
                toSave.siteCfg.deviceConfigs[devId].memCFG[ipcDefines.mAdrOutput + i * ipcDefines.mAdrOutputMemSize + ipcDefines.mAdrOutputType] = gbxOutputConfig.GetOutputTypeAt(i);
            }

            //GbxConfigureOutputsGroup GbxOutputConfig = (GbxConfigureOutputsGroup)EditViewControls["Relay_Cfg" + devId + "." + i];
            for (int i = 0; i < relayNo; i++)
            {
                TextBox inputname = (TextBox)_editViewControls["Relay" + devId];
                string  inname    = inputname.Text;
                toSave.siteCfg.deviceConfigs[devId].SetDeviceNameAt(i + ipcDefines.mAddr_NAMES_Relays_Pos, inname);
            }

            //load schedules
            GbxConfigureSchedulesGroup gbxScheduleConfig = (GbxConfigureSchedulesGroup)_editViewControls["Sched_Cfg" + devId];

            for (int i = 0; i < schedNo; i++)
            {
                toSave.siteCfg.deviceConfigs[devId].ScheduleCFG[i][ipcDefines.SCHED_TYPE_POS]        = (byte)gbxScheduleConfig.GetScheduleTypeAt(i);
                toSave.siteCfg.deviceConfigs[devId].ScheduleCFG[i][ipcDefines.SCHED_ACTION_TYPE_POS] = (byte)gbxScheduleConfig.GetScheduleActionAt(i);
                byte[] frombytes = gbxScheduleConfig.GetDateTimeConfig(DateTimeType.FromDate, (byte)i);
                for (int j = 0; j < ipcDefines.RAM_DEV_SCHED_DATETIME_SIZE; j++)
                {
                    toSave.siteCfg.deviceConfigs[devId].ScheduleCFG[i][ipcDefines.SCHED_TIME_FROM_POS + j] = frombytes[j];
                }
                byte[] tobytes = gbxScheduleConfig.GetDateTimeConfig(DateTimeType.ToDate, (byte)i);
                for (int k = 0; k < ipcDefines.RAM_DEV_SCHED_DATETIME_SIZE; k++)
                {
                    toSave.siteCfg.deviceConfigs[devId].ScheduleCFG[i][ipcDefines.SCHED_TIME_TO_POS + k] = frombytes[k];
                }
            }

            //load net cfg
            DeviceNetworkConfig networkConfigPanel = (DeviceNetworkConfig)_editViewControls["Net_Cfg" + devId];

            toSave.siteCfg.deviceConfigs[devId].NetworkConfig = networkConfigPanel.GetNetworkConfig();


            //load dev auth cfg
            GbxConfigureAuthDevicesGroup dauthcfg = (GbxConfigureAuthDevicesGroup)_editViewControls["Device authorization " + devId];

            toSave.siteCfg.deviceConfigs[devId].AuthDevicesCFG = dauthcfg.Serialize();


            try
            {
                //TODO upload net cfg only on change
                bool netwrite   = _configManager.WriteDeviceNetCfg(toSave, devId);
                bool devwrite   = _configManager.WriteDeviceCfgSingle(toSave, devId);
                bool namewrite  = _configManager.WriteDeviceNamesCfgSingle(toSave, devId);
                bool schedwrite = _configManager.WriteDeviceSchedulesCfgSingle(toSave, devId);
                bool dauthwrite = _configManager.WriteDeviceDevAuthCfgSingle(toSave, devId);

                if (devwrite || namewrite || schedwrite || schedwrite)  //try uploading changed device
                {
                    sconnDataSrc filesrc = new sconnDataSrc();
                    filesrc.SaveConfig(DataSourceType.xml);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }