Ejemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            //Setting defaults
            cbFonts.DropDownItems.FindAndClick((ri) =>
            {
                return(string.CompareOrdinal((((KeyValuePair <FontFamily, FontStyle>)ri.Tag).Key).Name,
                                             SettingsTable.Get(Strings.VScan_DefaultFontFamily, "Arial")) == 0);
            });

            btnForeColor.PerformClick();

            lstColors.Buttons.FindAndClick((ri) =>
            {
                return(((Color)ri.Tag) == SettingsTable.Get(Strings.VScan_DefaultForeColor, Color.Black));
            });

            btnBackColor.PerformClick();

            lstColors.Buttons.FindAndClick((ri) =>
            {
                return(((Color)ri.Tag) == SettingsTable.Get(Strings.VScan_DefaultBackColor, Color.Black));
            });

            cbFondSize.DropDownItems.FindAndClick((ri) =>
            {
                return(ri.Tag.Cast <int>() == SettingsTable.Get(Strings.VScan_DefaultFontSize, 10));
            });

            btnLineSize.DropDownItems.FindAndClick((ri) =>
            {
                return(ri.Tag.Cast <int>() == SettingsTable.Get(Strings.VScan_DefaultLineSize, 3));
            });

            base.OnLoad(e);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Used to find and cover the cardcode by using the barcode location
        /// </summary>
        /// <returns></returns>
        public static VoucherProcessDelegate CreateHideCardDetailsDelegateByBarcode()
        {
            var method = new VoucherProcessDelegate((Voucher data, StateObj state) =>
            {
                var distanceToHiddenArea = SettingsTable.Get <Point>(Strings.VScan_DistanceFromBarcodeBottomLeftToHiddenArea, Point.Empty);
                if (distanceToHiddenArea == Point.Empty)
                {
                    var ex = new ApplicationException("Cannot find chunk configuration.");
                    ex.AddNext(new MethodInvoker(() =>
                    {
                        string id    = Strings.VScan_EditItem.Uniqueue();
                        data.Message = ex.Message;
                        DataSlot.Set(id, data);
                        WinMsg.SendText(state.Scan, state.Main, id);
                    }));
                    throw ex;
                }

                Size hideAreaSize        = SettingsTable.Get <Size>(Strings.VScan_HiddenAreaSize, Size.Empty);
                Point hiddenAreaLocation = new Point(data.BarCodeArea.Left, data.BarCodeArea.Bottom);

                hiddenAreaLocation.Offset(distanceToHiddenArea);
                Rectangle hiddenArea = new Rectangle(hiddenAreaLocation, hideAreaSize);

                var hiddenAreaDraw = SettingsTable.Get <HiddenAreaDrawingCfg>(Strings.VScan_HiddenAreaDrawingCfg, HiddenAreaDrawingCfg.Default);

                using (var g = Graphics.FromImage(data.VoucherImage))
                    g.FillRectangleHatch(hiddenArea, hiddenAreaDraw.ForeColor, hiddenAreaDraw.BackColor, hiddenAreaDraw.Style);
            });

            return(method);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Used to find and cover the card code by a mark on the voucher image
        /// </summary>
        /// <returns></returns>
        public static VoucherProcessDelegate CreateHideCardDetailsDelegateByMark()
        {
            var method = new VoucherProcessDelegate((Voucher data, StateObj state) =>
            {
                var markArea = SettingsTable.Get <MarkAreaCfg>(Strings.VScan_MarkAreaConfiguration, MarkAreaCfg.Empty);

                if (markArea.Equals(MarkAreaCfg.Empty))
                {
                    var ex = new ApplicationException("Cannot find 'hide area' configuration.");
                    ex.AddNext(new MethodInvoker(() =>
                    {
                        string id    = Strings.VScan_EditItem.Uniqueue();
                        data.Message = ex.Message;
                        DataSlot.Set(id, data);
                        WinMsg.SendText(state.Scan, state.Main, id);
                    }));
                    throw ex;
                }

                Rectangle hiddenArea;

                using (var bmp2 = data.VoucherImage.ToBlackWhite(markArea.BlackWhiteThreshold))
                    hiddenArea = bmp2.FindRectangle(Point.Empty, markArea.BackColor, markArea.MinAreaSize, markArea.MaxAreaSize, markArea.Threshold);

                var hiddenAreaDraw = SettingsTable.Get <HiddenAreaDrawingCfg>(Strings.VScan_DistanceFromBarcodeBottomLeftToHiddenArea, HiddenAreaDrawingCfg.Default);

                using (var g = Graphics.FromImage(data.VoucherImage))
                    g.FillRectangleHatch(hiddenArea, hiddenAreaDraw.ForeColor, hiddenAreaDraw.BackColor, hiddenAreaDraw.Style);
            });

            return(method);
        }
Ejemplo n.º 4
0
        private void PreparePrinterComboBox()
        {
            string defaultPrinterName = PrintManager.GetDefaultPrinterName();
            string applicationPrinter = SettingsTable.Get(Strings.VScan_ApplicationPrinterName, defaultPrinterName);

            this.cbPrinters.SelectedIndexChanged -= new System.EventHandler(this.Printers_SelectedIndexChanged);

            this.cbPrinters.Clear();

            foreach (string printer in PrintManager.GetInstalledPrinters())
            {
                int index = cbPrinters.Items.Add(printer);

                if (string.Equals(printer, applicationPrinter) && string.Equals(printer, defaultPrinterName))
                {
                    cbPrinters.SelectedIndex = index;
                    cbPrinters.SetItemColor(index, Color.Green);
                }
                else if (string.Equals(printer, applicationPrinter))
                {
                    //Application Printer
                    cbPrinters.SelectedIndex = index;
                    cbPrinters.SetItemColor(index, Color.Blue);
                }
                else if (string.Equals(printer, defaultPrinterName))
                {
                    //Default printer
                    cbPrinters.SetItemColor(index, Color.Red);
                }
            }

            this.cbPrinters.SelectedIndexChanged += new System.EventHandler(this.Printers_SelectedIndexChanged);
        }
Ejemplo n.º 5
0
        protected override void OnLoad(EventArgs e)
        {
            string url = SettingsTable.Get <string>(Strings.VScan_TRS_UrlAddress, Strings.VScan_TRS_UrlAddressDefault);

            this.webBrowser1.Url = new System.Uri(url, System.UriKind.Absolute);
            base.OnLoad(e);
        }
Ejemplo n.º 6
0
 public void Save()
 {
     SettingsTable.Set(Strings.VScan_ConnectionString, builder.ConnectionString);
     SettingsTable.Set(Strings.VScan_TranfSendInterval, int.Parse(ptbSendInterval.Text));
     SettingsTable.Set(Strings.All_CentralServerUrl, ptbRemoteSrvURL.Text);
     SettingsTable.Set(Strings.VScan_AutoInstallService, vcbAutoInstallService.Checked);
 }
Ejemplo n.º 7
0
        private void LoadAllSettings()
        {
            this.drawingSettings = LoadSettings <SettingsDrawing>(localPath.FindFullPathFromXml("PathDrawing"));
            if (this.drawingSettings == null)
            {
                this.drawingSettings = SettingsDrawing.Default;
            }

            this.userSettings = LoadSettings <SettingsLand>(localPath.FindFullPathFromXml("PathUsers"));
            if (this.userSettings == null)
            {
                this.userSettings = SettingsLand.Default;
            }

            this.formSettings = LoadSettings <SettingsFormLand>(localPath.FindFullPathFromXml("PathFormLand"));
            if (this.formSettings == null)
            {
                this.formSettings = new SettingsFormLand();
            }

            this.tableSettings = LoadSettings <SettingsTable>(localPath.FindFullPathFromXml("PathTables"));
            if (this.formSettings == null)
            {
                this.tableSettings = SettingsTable.Default;
            }

            this.frameDrawingSettings = LoadSettings <SettingsLand>(localPath.FindFullPathFromXml("PathFrameDrawing"));
            if (this.formSettings == null)
            {
                this.frameDrawingSettings = SettingsLand.Default;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// reload
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ReloadServer_Click(object sender, EventArgs e)
        {
            var url      = SettingsTable.Get <string>(Strings.All_CentralServerUrl, Strings.All_CentralServerUrlPathDefault);
            var authUser = SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject);

            DataServiceClient.CallSendCmd("reload");
        }
Ejemplo n.º 9
0
        /// <summary>
        /// enable_client
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EnableClient_Click(object sender, EventArgs e)
        {
            var url      = SettingsTable.Get <string>(Strings.All_CentralServerUrl, Strings.All_CentralServerUrlPathDefault);
            var authUser = SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject);

            DataServiceClient.CallSendCmd("enable_client", new object[] { 1, false });
        }
Ejemplo n.º 10
0
        public ScanForm(IntPtr mainForm)
        {
            this.components = new System.ComponentModel.Container();
            InitializeComponent();
            ms_Current = this;
            this.Text  = Application.ProductName.concat("-Scanner");

            bool defaultScanner         = SettingsTable.Get <bool>(Strings.VScan_TWAINUseDefaultScanner, false);
            bool defaultScannerSettings = SettingsTable.Get <bool>(Strings.VScan_TWAINUseDefaultScannerSettings, false);

            this.ShowIcon      = true;
            this.ShowInTaskbar = true;

            m_MainFormHandler = mainForm;

            m_twain          = new Twain();
            m_twain.MainForm = mainForm;
            m_twain.ScanForm = this.Handle;
            m_twain.Form     = this;
            m_twain.Init(this.Handle);

            if (defaultScanner)
            {
                var name = SettingsTable.Get <string>(Strings.VScan_ScannerName, Strings.VScan_DefaultScannerName);
                m_twain.Select(name);
            }

            AcquireVoucher(defaultScannerSettings);
        }
Ejemplo n.º 11
0
        public void EqualsShouldReturnTrueWhenReferencesAreEqual()
        {
            var table      = new SettingsTable <string, string>();
            var otherTable = table;

            Assert.True(table.Equals(otherTable));
        }
Ejemplo n.º 12
0
        public RoleCommand(SettingsTable settingsTable)
        {
            var settings = settingsTable;

            _uniqueRoleNames       = settings.Get("uniques").Split(',');
            _sharedUniqueRoleNames = settings.Get("sharedUniques").Split(',');
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Used to print over the voucher image
        /// </summary>
        /// <returns></returns>
        public static VoucherProcessDelegate CreatePrintOnImageDelegate()
        {
            var method = new VoucherProcessDelegate((Voucher data, StateObj state) =>
            {
                var printLocation = SettingsTable.Get <Point>(Strings.VScan_PrintAreaLocation, Point.Empty);
                if (printLocation == Point.Empty)
                {
                    var ex = new ApplicationException("Cannot find 'print on image' configuration.");
                    ex.AddNext(new MethodInvoker(() =>
                    {
                        string id    = Strings.VScan_EditItem.Uniqueue();
                        data.Message = ex.Message;
                        DataSlot.Set(id, data);
                        WinMsg.SendText(state.Scan, state.Main, id);
                    }));
                    throw ex;
                }

                var aliases           = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
                aliases["[DATE]"]     = new Func <string>(() => DateTime.Now.ToString());
                aliases["[OPERATOR]"] = new Func <string>(() => SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject, UserAuth.Default).Name);
                aliases["[PCNAME]"]   = new Func <string>(() => PTFUtils.GetMachine());
                aliases["[SITEID]"]   = new Func <string>(() => data.SiteCode);
                aliases["[NUMBER]"]   = new Func <string>(() => Convert.ToString(SettingsTable.Get <int>(Strings.VScan_ScanCount, 0)));

                string voucherTemplate = SettingsTable.Get <string>(Strings.VScan_ImPrinterTemplate, Strings.VScan_ImPrinterTemplateDefault);
                string voucherText     = voucherTemplate.format(aliases);

                using (var g = Graphics.FromImage(data.VoucherImage))
                    g.DrawString(voucherText, SystemFonts.CaptionFont, Brushes.Red, printLocation);
            });

            return(method);
        }
Ejemplo n.º 14
0
        internal static T GetSettingValue <T>(string settingName, SettingsTable settingTableName = SettingsTable.Settings)
        {
            if (settingTableName == SettingsTable.MigrationTableSettings)
            {
                return(GetMappingSettingValue <T>(settingName));
            }

            using (var cInstance = new OleDbConnectionInstance(ConnectionString))
            {
                var command = new OleDbCommand($"SELECT `{settingName}` FROM `{GetTableName(settingTableName)}` WHERE `Id` = 1", cInstance.GetConnection());
                command.Connection.Open();
                try
                {
                    var key = command.ExecuteScalar();
                    if (key == null || key == DBNull.Value)
                    {
                        return(default(T));
                    }
                    var conv = TypeDescriptor.GetConverter(typeof(T));
                    return((T)conv.ConvertFrom(key));
                }
                catch (Exception e)
                {
                    Logger.Instance.Error($"An error occurred while retrieving the {settingName}: {e.Message}");
                }
                finally
                {
                    command.Connection.Close();
                    cInstance.CloseConnection();
                }
            }

            return(default(T));
        }
Ejemplo n.º 15
0
 public ProgramDatabase(
     ConnectionFactory connectionFactory,
     ILogger <ProgramDatabase> logger)
     :
     base(connectionFactory, logger)
 {
     SettingsTable = new SettingsTable(connectionFactory);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Queries all site codes for user's country or for selected by Id country
        /// </summary>
        /// <param name="countryId"></param>
        /// <returns></returns>
        public static string[] QueryCountryCodes(int?countryId)
        {
            UserAuth auth  = SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject, UserAuth.Default);
            var      url   = SettingsTable.Get <string>(Strings.All_CentralServerUrl, Strings.All_CentralServerUrlPathDefault);
            var      codes = DataServiceClient.CallQueryContries(auth).ConvertAll <CountryData, string>(c => c.ShortName).ToArray();

            return(codes);
        }
Ejemplo n.º 17
0
 internal static void Initialise()
 {
     if (!SettingsTable.Exists())
     {
         ProgramLog.Admin.Log("Common settings table does not exist and will now be created");
         SettingsTable.Create();
     }
 }
Ejemplo n.º 18
0
 static ScanForm()
 {
     ms_Aliases["[DATE]"]     = new Func <string>(() => DateTime.Now.ToString());
     ms_Aliases["[OPERATOR]"] = new Func <string>(() => SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject, UserAuth.Default).Name);
     ms_Aliases["[PCNAME]"]   = new Func <string>(() => PTFUtils.GetMachine());
     ms_Aliases["[SITEID]"]   = new Func <string>(() => { Debug.Assert(ms_Current != null && ms_Current.VoucherData != null); return(ms_Current.VoucherData.SiteCode); });
     ms_Aliases["[NUMBER]"]   = new Func <string>(() => Convert.ToString(SettingsTable.Get <int>(Strings.VScan_ScanCount, 0)));
 }
Ejemplo n.º 19
0
 private PasswordForm()
 {
     InitializeComponent();
     ShowCountries           = false;
     CountryID               = SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject, UserAuth.Default).CountryID;
     tbUserName.TextChanged += new EventHandler(TextBox_TextChanged);
     tbPassword.TextChanged += new EventHandler(TextBox_TextChanged);
 }
Ejemplo n.º 20
0
 private void Cultures_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.ShowQuestion("You are about to change current culture.\r\n Are you sure?", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         CultureInfo ci = (CultureInfo)cbCultures.SelectedItem;
         ChangeFormCulture.ChangeAllForms(ci);
         SettingsTable.Set(Strings.Transferring_CurrentUICultureInfo, ci);
     }
 }
Ejemplo n.º 21
0
        private void Scanners_SelectedIndexChanged(object sender, EventArgs e)
        {
            var scanner = cbPrinters.SelectedItem.ToStringSf();

            if (!string.IsNullOrEmpty(scanner))
            {
                SettingsTable.Set(Strings.VScan_ScannerName, scanner);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates SelectAuditIds reloading delegate
        /// </summary>
        /// <returns></returns>
        public static Delegate CreateAuditIdReloadDelegate()
        {
            var method = new Action(() =>
            {
                int minimumAuditIdsInCache = SettingsTable.Get <int>(Strings.VScan_MinimumAuditIDsInCache, Program.ITEMS_IN_CACHE);
                AuditIDSTable.AddRange(ClientDataAccess.SelectAvailableSiteCodeIDs(minimumAuditIdsInCache), minimumAuditIdsInCache);
            });

            return(method);
        }
Ejemplo n.º 23
0
        public void GetHashCodeShouldReturnHashCodeOfAllVersions()
        {
            var table = new SettingsTable <string, string>();

            table.AddVersion(new SettingsTableVersion <string, string>());

            int versionsHashCode = table.Versions.GetHashCode();

            Assert.Equal(versionsHashCode, table.GetHashCode());
        }
Ejemplo n.º 24
0
        private bool ChangePasswordInternal(Form owner)
        {
            var authUser = new UserAuth(CountryID, UserName, Password, IsInAdminContext);

            //Validate on TRS server
            DataServiceClient.CallValidateUser(authUser.CountryID, authUser.Name, authUser.Password);
            SettingsTable.Set(Strings.Transferring_AuthObject, authUser);
            SettingsTable.Get <UniqueList <UserAuth> >(Strings.Transferring_AuthObjectList).Add(authUser);
            return(true);
        }
Ejemplo n.º 25
0
 private void Group3_Click(object sender, EventArgs e)
 {
     if (sender == btnNew3)
     {
         New();
     }
     else if (sender == btnOpen3)
     {
         ActiveChild.Open();
     }
     else if (sender == btnSave3)
     {
         ActiveChild.Save();
     }
     else if (sender == btnSaveAs3)
     {
         ActiveChild.SaveAs();
     }
     else if (sender == btnPrepare3)
     {
         new AppInfoException("Prepare not completed yet").ThrowAndForget();
     }
     else if (sender == btnPublish3)
     {
         new AppInfoException("Publish not completed yet").ThrowAndForget();
     }
     else if (sender == btnSend3)
     {
         string to      = SettingsTable.Get <string>(Strings.VScan_Email_To, "*****@*****.**");
         string subject = SettingsTable.Get <string>(Strings.VScan_Email_Subject, "VScan issue");
         string body    = SettingsTable.Get <string>(Strings.VScan_Email_Body, "Dear Support");
         Process.Start(new ProcessStartInfo(string.Format("mailto:{0}?subject={1}&body={2}", to, subject, body)));
     }
     else if (sender == btnClose3)
     {
         Close();
     }
     else if (sender == btnQuickPrint3)//print
     {
         ActiveChild.Print();
     }
     else if (sender == btnAdvancePrint3)// set printer
     {
         ActiveChild.SetupAndPrint();
     }
     else if (sender == btnPrintPreview3)//preview
     {
         ActiveChild.PrintPreview();
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 /// <exception cref="QueueIsEmptyException"></exception>
 public static Voucher FillFromScanContext(Voucher data)
 {
     lock (data)
     {
         var currentScan = ScanAppContext.Default.CurrentScan;
         data.SiteCode         = AuditIDSTable.SelectRemoveFirstOrEmpty().ThrowIfDefault <string, NoDataIdException>();
         data.Comment          = currentScan.Comment;
         data.CompressionLevel = SettingsTable.Get <long>(Strings.VScan_CompressionLevel, Consts.DEFAULTCOMPRESSIONLEVEL);
         return(data);
     }
 }
Ejemplo n.º 27
0
        private void PopulateCountiesComboBox()
        {
            var countries = SettingsTable.Get <DbCountry[]>(Strings.VScan_SelectDbCountries, null);

            cbCountries.DataSource            = countries;
            cbCountries.SelectedIndexChanged += new EventHandler(Countries_SelectedIndexChanged);
            if (cbCountries.Items.Count > 0)
            {
                cbCountries.SelectedIndex = 0;
            }
        }
Ejemplo n.º 28
0
        private void BindSettingsComboBox()
        {
            var settings = SettingsTable.Default.GetSettingNames();

            cbAvailableSettings.Items.Clear();
            cbAvailableSettings.Items.AddRange(settings.ToArray());
            cbAvailableSettings.SelectedItem = SettingsTable.Get <string>(Strings.VScan_DefaultSettingsName);
            int index = cbAvailableSettings.SelectedIndex;

            cbAvailableSettings.SetItemColor(index, Color.Green);
        }
Ejemplo n.º 29
0
 public static void Set(string key, string value)
 {
     if (SettingsTable.Exists(key))
     {
         SettingsTable.Update(key, value);
     }
     else
     {
         SettingsTable.Insert(key, value);
     }
 }
Ejemplo n.º 30
0
 private void SettingsButton_Click(object sender, EventArgs e)
 {
     if (sender == vbtnAddSettings)
     {
         string text = ptbAddSettingsName.Text.TrimSafe();
         if (string.IsNullOrEmpty(text))
         {
             this.ShowWarning("Settings name could not be empty space.");
         }
         else if (SettingsTable.Default.ActiveTable.ContainsKey(text))
         {
             this.ShowWarning("The key already exists");
         }
         else
         {
             SettingsTable.Default.CopyTable(text, SettingsTable.SettingsKeys);
             var settings = SettingsTable.Default.GetSettingNames();
             settings.Add(text);
             BindSettingsComboBox();
         }
     }
     else if (sender == vbtnRemoveSettings)
     {
         if (cbAvailableSettings.SelectedItem == null)
         {
             this.ShowWarning("No settings is selected.");
         }
         else
         {
             string text = Convert.ToString(cbAvailableSettings.SelectedItem);
             SettingsTable.Default.DataTable.Remove(text);
             BindSettingsComboBox();
         }
     }
     else if (sender == vbtnSetDefault)
     {
         if (cbAvailableSettings.SelectedItem == null)
         {
             this.ShowWarning("No settings is selected.");
         }
         else
         {
             string text = Convert.ToString(cbAvailableSettings.SelectedItem);
             SettingsTable.Default.LoadTable(text);
             SettingsTable.Set(Strings.VScan_DefaultSettingsName, text);
             this.FindForm().Close();
         }
     }
     else
     {
         throw new NotImplementedException();
     }
 }