예제 #1
0
        private void updateFormBasedOnGlobalConfig()
        {
            if (this.storeData.PawnSecData != null &&
                this.storeData.PawnSecData.GlobalConfiguration != null)
            {
                GlobalConfigVO g = this.storeData.PawnSecData.GlobalConfiguration;

                if (!string.IsNullOrEmpty(g.AdobeReaderPath))
                {
                    this.adobeReaderPathTextBox.Text = g.AdobeReaderPath;
                }

                if (!string.IsNullOrEmpty(g.GhostScriptPath))
                {
                    this.ghostScriptPathTextBox.Text = g.GhostScriptPath;
                }

                //Create const string default base path
                const string defaultBasePath = @"c:\Program Files\Phase2App";

                //Set to this default ALWAYS
                this.globalBasePathTextBox.Text = defaultBasePath;

                if (!string.IsNullOrEmpty(g.BaseLogPath))
                {
                    this.globalLogFolder.Text = g.BaseLogPath;
                }
                else
                {
                    this.globalLogFolder.Text = defaultBasePath + @"\logs";
                }

                if (!string.IsNullOrEmpty(g.BaseMediaPath))
                {
                    this.globalMediaFolder.Text = g.BaseMediaPath;
                }
                else
                {
                    this.globalMediaFolder.Text = defaultBasePath + @"\media";
                }

                if (!string.IsNullOrEmpty(g.BaseTemplatePath))
                {
                    this.globalTemplateFolder.Text = g.BaseTemplatePath;
                }
                else
                {
                    this.globalTemplateFolder.Text = defaultBasePath + @"\templates";
                }

                if (!string.IsNullOrEmpty(g.AdobeReaderPath))
                {
                    this.adobeReaderPathTextBox.Text = g.AdobeReaderPath;
                }

                if (!string.IsNullOrEmpty(g.GhostScriptPath))
                {
                    this.ghostScriptPathTextBox.Text = g.GhostScriptPath;
                }

                if (!string.IsNullOrEmpty(g.Version))
                {
                    var curStore = this.pawnSecVo.GetStore();
                    if (curStore != null)
                    {
                        this.appVersionTextBox.Text = curStore.AppVersion.AppVersion;
                    }
                }
            }
        }
예제 #2
0
        private void primaryPawnSecSetupDoneButton_Click(object sender, EventArgs e)
        {
            //Update store configuration
            var pStore = this.getStoreInformation();

            pStore.StoreConfiguration.DayOffset           = (int)this.dayOffsetNumericUpDown.Value;
            pStore.StoreConfiguration.MonthOffset         = (int)this.monthOffsetNumericUpDown.Value;
            pStore.StoreConfiguration.FetchSizeMultiplier = (ulong)this.dataFetchSizeNumericUpDown.Value;
            pStore.StoreConfiguration.MetalsFile          = pmetalFileTextBox.Text;
            pStore.StoreConfiguration.StonesFile          = stonesFileTextBox.Text;

            //pStore.

            //if (!CreatingWorkstation)
            //{
            if (string.IsNullOrEmpty(machineNameComboBox.Text))
            {
                return;
            }
            //Use workstation object matching selected from combo box
            int    firstPerIdx = machineNameComboBox.Text.IndexOf(".");
            string trimmedMachineName;

            if (firstPerIdx >= 1)
            {
                trimmedMachineName = machineNameComboBox.Text.Substring(0, firstPerIdx);
            }
            else
            {
                trimmedMachineName = machineNameComboBox.Text;
            }
            bool newMach = false,
                 newMap  = false;

            var mach =
                this.storeData.PawnSecData.ClientMachines.Find(
                    x => x.Machine.MachineName.Equals(machineNameComboBox.Text, StringComparison.OrdinalIgnoreCase));

            if (mach == null)
            {
                MessageBox.Show("Could not find the machine selected in the combo box.",
                                PawnStoreSetupForm.SETUPALERT_TXT);
                return;
            }
            var machMapping =
                this.storeData.PawnSecData.ClientStoreMapList.Find(
                    x => x.ClientRegistryId == mach.Machine.ClientId);

            if (machMapping == null)
            {
                MessageBox.Show("Could not find the mapping belonging to the machine selected in the combo box.",
                                PawnStoreSetupForm.SETUPALERT_TXT);
                return;
            }


            if (!string.IsNullOrEmpty(this.ipAddressTextBox.Text))
            {
                mach.Machine.IPAddress = this.ipAddressTextBox.Text;
                if (!StringUtilities.ISIPv4Address(mach.Machine.IPAddress))
                {
                    MessageBox.Show(
                        "The IPv4 address entered is not properly formatted.  Must be of the form: XXX.XXX.XXX.XXX " +
                        Environment.NewLine +
                        " (NOTE: The individual IPv4 components need to be between 0 and 255 and can be 1 to 3 digits");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(this.macAddressTextBox.Text))
            {
                mach.Machine.MACAddress = this.macAddressTextBox.Text;
                if (!StringUtilities.IsMACAddress(mach.Machine.MACAddress))
                {
                    MessageBox.Show(
                        "The MAC address entered is not properly formatted. Must be of the form: XX:XX:XX:XX:XX:XX",
                        PawnStoreSetupForm.SETUPALERT_TXT);
                    return;
                }
            }

            if (this.adobeOverrideCheckBox.Checked &&
                !string.IsNullOrEmpty(this.adobeReaderOverrideTextBox.Text))
            {
                mach.Machine.AdobeOverride = this.adobeReaderOverrideTextBox.Text;
            }

            if (this.ghostScriptOverrideCheckBox.Checked &&
                !string.IsNullOrEmpty(this.ghostScriptOverrideTextBox.Text))
            {
                mach.Machine.GhostOverride = this.ghostScriptOverrideTextBox.Text;
            }


            /*ulong uNexId = 0;
             * bool updatedMapping = false;
             * if (mach.Machine.ClientId <= 0)
             * {
             *  this.storeData.PawnSecData.NextIdSet.GetNextIds(
             *          PawnSecVO.PawnSecNextIdVO.SELECTOR.CLIREG_ID, ref uNexId);
             *  updatedMapping = true;
             * }*/
            //mach.Machine.ClientId = (mach.Machine.ClientId <= 0) ? uNexId : mach.Machine.ClientId;
            mach.Machine.IsAllowed           = this.isAllowedCheckBox.Checked;
            mach.StoreMachine.PrintEnabled   = this.printingAllowedCheckBox.Checked;
            mach.StoreMachine.LogLevel       = this.logLevelComboBox.Text;
            mach.StoreMachine.TraceLevel     = (int)this.traceLevelNumericUpDown.Value;
            mach.StoreMachine.TerminalNumber = (int)this.terminalNumberNumericUpDown.Value;
            mach.StoreMachine.WorkstationId  = trimmedMachineName;
            mach.Machine.WorkstationName     = trimmedMachineName;

            #region NOT NEEDED

            /*if (mach.StoreMachine.Id <= 0)
             * {
             *  this.storeData.PawnSecData.NextIdSet.GetNextIds(
             *          PawnSecVO.PawnSecNextIdVO.SELECTOR.STOCLICFG_ID, ref uNexId);
             *  updatedMapping = true;
             * }
             * mach.StoreMachine.Id = (mach.StoreMachine.Id <= 0) ? uNexId : mach.StoreMachine.Id;
             * if (newMach)
             * {
             *  this.storeData.PawnSecData.ClientMachines.Add(mach);
             * }
             * if (updatedMapping)
             * {
             *  var cMapVo = machMapping;
             *  if (newMap)
             *  {
             *      this.storeData.PawnSecData.NextIdSet.GetNextIds(
             *              PawnSecVO.PawnSecNextIdVO.SELECTOR.CLISTOMAP_ID, ref uNexId);
             *      cMapVo.Id = uNexId;
             *  }
             *  cMapVo.StoreNumber = storeNumber;
             *  cMapVo.StoreConfigId = pStore.StoreConfiguration.Id;
             *  cMapVo.StoreClientConfigId = pStore.StoreConfiguration.Id;
             *  cMapVo.StoreSiteId = pStore.StoreSiteId;
             *  cMapVo.ClientRegistryId = mach.Machine.ClientId;
             *
             *  if (newMap)
             *  {
             *      this.storeData.PawnSecData.ClientStoreMapList.Add(cMapVo);
             *  }
             *  this.storeData.PawnSecData.GenerateMaps();
             * }*/
            /*}
             * else
             * {
             *  if (CollectionUtilities.isEmpty(this.storeData.PawnSecData.ClientMachines))
             *  {
             *      MessageBox.Show("Did not properly add machine.  Please click the add button next to the machine name.",
             *                      PawnStoreSetupForm.SETUPALERT_TXT);
             *      return;
             *  }
             *  //Get last workstation object
             *  var lastMach = this.storeData.PawnSecData.ClientMachines[this.storeData.PawnSecData.ClientMachines.Count - 1];
             *  //Ensure this machine matches the test in the combo box
             *  if (lastMach != null && lastMach.Machine.MachineName.Equals(machineNameComboBox.Text))
             *  {
             *      //Use workstation object matching selected from combo box
             *      int firstPerIdx = machineNameComboBox.Text.IndexOf(".");
             *      string trimmedMachineName;
             *      if (firstPerIdx >= 1)
             *      {
             *          trimmedMachineName = machineNameComboBox.Text.Substring(0, firstPerIdx);
             *      }
             *      else
             *      {
             *          trimmedMachineName = machineNameComboBox.Text;
             *      }
             *      if (!string.IsNullOrEmpty(this.ipAddressTextBox.Text))
             *      {
             *          lastMach.Machine.IPAddress = this.ipAddressTextBox.Text;
             *          if (!StringUtilities.ISIPv4Address(lastMach.Machine.IPAddress))
             *          {
             *              MessageBox.Show(
             *                      "The IPv4 address entered is not properly formatted.  Must be of the form: XXX.XXX.XXX.XXX " +
             *                      Environment.NewLine +
             *                      " (NOTE: The individual IPv4 components need to be between 0 and 255 and can be 1 to 3 digits");
             *              return;
             *          }
             *      }
             *
             *      if (!string.IsNullOrEmpty(this.macAddressTextBox.Text))
             *      {
             *          lastMach.Machine.MACAddress = this.macAddressTextBox.Text;
             *          if (!StringUtilities.IsMACAddress(lastMach.Machine.MACAddress))
             *          {
             *              MessageBox.Show(
             *                      "The MAC address entered is not properly formatted. Must be of the form: XX:XX:XX:XX:XX:XX",
             *                      PawnStoreSetupForm.SETUPALERT_TXT);
             *              return;
             *          }
             *      }
             *
             *      if (this.adobeOverrideCheckBox.Checked &&
             *          !string.IsNullOrEmpty(this.adobeReaderOverrideTextBox.Text))
             *      {
             *          lastMach.Machine.AdobeOverride = this.adobeReaderOverrideTextBox.Text;
             *      }
             *
             *      if (this.ghostScriptOverrideCheckBox.Checked &&
             *          !string.IsNullOrEmpty(this.ghostScriptOverrideTextBox.Text))
             *      {
             *          lastMach.Machine.GhostOverride = this.ghostScriptOverrideTextBox.Text;
             *      }*/

            /*bool newMach = false,
             *   newMap = false;
             *
             * var mach = this.storeData.PawnSecData.ClientMachines.Find(
             *              x => x.Machine.MachineName.Equals(trimmedMachineName));
             * if (mach == null)
             * {
             *  mach = new PawnSecVO.ClientPawnSecMachineVO();
             *  newMach = true;
             * }
             *
             * var machMapping =
             *      this.storeData.PawnSecData.ClientStoreMapList.Find(
             *              x => x.ClientRegistryId == mach.Machine.ClientId);
             * if (machMapping == null)
             * {
             *  machMapping = new PawnSecVO.ClientStoreMapVO();
             *  newMap = true;
             * }*/

            /*lastMach.Machine.IsAllowed = this.isAllowedCheckBox.Checked;
             * lastMach.StoreMachine.PrintEnabled = this.printingAllowedCheckBox.Checked;
             * lastMach.StoreMachine.TerminalNumber = (int)this.terminalNumberNumericUpDown.Value;
             * lastMach.StoreMachine.LogLevel = this.logLevelComboBox.Text;
             * lastMach.StoreMachine.TraceLevel = (int)this.traceLevelNumericUpDown.Value;
             * lastMach.StoreMachine.WorkstationId = trimmedMachineName;
             * lastMach.Machine.WorkstationName = trimmedMachineName;*/
            //ulong uNexId = 1;

            /*if (newMach)
             * {
             *  if (lastMach.Machine.ClientId <= 0)
             *  {
             *      this.storeData.PawnSecData.NextIdSet.GetNextIds(
             *              PawnSecVO.PawnSecNextIdVO.SELECTOR.CLIREG_ID, ref uNexId);
             *      lastMach.Machine.ClientId = uNexId;
             *  }
             *  if (lastMach.StoreMachine.Id <= 0)
             *  {
             *      this.storeData.PawnSecData.NextIdSet.GetNextIds(
             *              PawnSecVO.PawnSecNextIdVO.SELECTOR.STOCLICFG_ID, ref uNexId);
             *      lastMach.StoreMachine.Id = uNexId;
             *  }
             * }
             * if (newMap)
             * {
             *  var cMapVo = new PawnSecVO.ClientStoreMapVO();
             *  this.storeData.PawnSecData.NextIdSet.GetNextIds(
             *          PawnSecVO.PawnSecNextIdVO.SELECTOR.CLISTOMAP_ID, ref uNexId);
             *  cMapVo.Id = uNexId;
             *  cMapVo.StoreNumber = storeNumber;
             *  cMapVo.StoreConfigId = pStore.StoreConfiguration.Id;
             *  cMapVo.StoreClientConfigId = pStore.StoreConfiguration.Id;
             *  cMapVo.StoreSiteId = pStore.StoreSiteId;
             *  cMapVo.ClientRegistryId = lastMach.Machine.ClientId;
             *  this.storeData.PawnSecData.ClientStoreMapList.Add(cMapVo);
             * }*/
            //this.storeData.PawnSecData.GenerateMaps();
            //}
            //}
            #endregion

            //Update global configuration
            GlobalConfigVO gCfg = this.storeData.PawnSecData.GlobalConfiguration;
            if (!string.IsNullOrEmpty(this.adobeReaderPathTextBox.Text))
            {
                gCfg.AdobeReaderPath = this.adobeReaderPathTextBox.Text;
            }

            if (!string.IsNullOrEmpty(this.ghostScriptPathTextBox.Text))
            {
                gCfg.GhostScriptPath = this.ghostScriptPathTextBox.Text;
            }

            if (!string.IsNullOrEmpty(this.globalBasePathTextBox.Text))
            {
                //No need for this field
            }

            if (!string.IsNullOrEmpty(this.globalLogFolder.Text))
            {
                gCfg.BaseLogPath = this.globalLogFolder.Text;
            }

            if (!string.IsNullOrEmpty(this.globalMediaFolder.Text))
            {
                gCfg.BaseMediaPath = this.globalMediaFolder.Text;
            }

            if (!string.IsNullOrEmpty(this.globalTemplateFolder.Text))
            {
                gCfg.BaseTemplatePath = this.globalTemplateFolder.Text;
            }

            if (!string.IsNullOrEmpty(this.appVersionTextBox.Text))
            {
                pStore.AppVersion.AppVersion = this.appVersionTextBox.Text;
                gCfg.Version = pStore.AppVersion.AppVersionId;
            }

            Close();
        }