// -----------------------------------------------------------------------------------
    // Main functions for fingerprint recognition management
    // -----------------------------------------------------------------------------------

    // Initializes GrFinger ActiveX and all necessary utilities.
    public int InitializeGrFinger(AxGrFingerXLib.AxGrFingerXCtrl grfingerx)
    {
        GRConstants result;

        _grfingerx = grfingerx;
        //Check DataBase Class.
        if (_DB == null)
        {
            _DB = new DBClass();
        }
        //Open DataBase
        if (_DB.openDB() == false)
        {
            return(ERR_CANT_OPEN_BD);
        }

        //Create a new Template
        if (_tpt == null)
        {
            _tpt = new TTemplate();
        }

        //Create a new raw image
        _raw = new TRawImage();

        //Initialize library
        result = (GRConstants)_grfingerx.Initialize();
        if (result < 0)
        {
            return((int)result);
        }
        return((int)_grfingerx.CapInitialize());
    }
 // Open connection
 public bool openDB()
 {
     _connection = new OleDbConnection();
     _connection.ConnectionString = CONNECTION_STRING;
     try{
         _connection.Open();
     }
     catch {
         return(false);
     }
     tptBlob = new TTemplate();
     return(true);
 }    //END
예제 #3
0
        /// <summary>
        /// The create sections.
        /// </summary>
        /// <param name="tree">
        /// The tree.
        /// </param>
        /// <param name="template">
        /// The template.
        /// </param>
        private static void CreateSections(TTree tree, TTemplate template)
        {
            foreach (TSection section in template)
              {
            Item item = tree.Database.GetItem(section.ID);

            if (item == null)
            {
              tree.Database.CreateItem(section.ID, section.Name, new TemplateID(TemplateIDs.TemplateSection), template.ID);
            }

            CreateFields(tree, section);
              }
        }
예제 #4
0
        public void WriteXlsxTest()
        {
            string    file  = AppDomain.CurrentDomain.BaseDirectory + "/ExcelTests/t2.xlsx";
            IExcel    excel = ExcelFactory.CreateDefault();
            DataTable dt    = excel.Read(file, 0, 2);

            DataSet ds = new DataSet();

            ds.Tables.Add(dt);

            TTemplate template = new TTemplate();
            TRow      R1       = new TRow();
            TCell     A        = new TCell("A", "A", 0, 0); A.ColSpan = 2;
            TCell     B        = new TCell("", "B", 0, 2);
            TCell     C        = new TCell("C", "C", 0, 3); C.RowSpan = 2;
            TCell     D        = new TCell("D", "D", 0, 4); D.RowSpan = 2;
            TCell     E        = new TCell("", "E", 0, 5); E.ColSpan = 2;

            R1.Cells.Add(A);
            R1.Cells.Add(B);
            R1.Cells.Add(C);
            R1.Cells.Add(D);
            R1.Cells.Add(E);

            TRow  R2 = new TRow();
            TCell A1 = new TCell("A1", "A1", 1, 0);
            TCell A2 = new TCell("A2", "A2", 1, 1);
            TCell B1 = new TCell("B1", "B1", 1, 2);
            TCell E1 = new TCell("E1", "E1", 1, 5);
            TCell E2 = new TCell("E2", "E2", 1, 6);

            R2.Cells.Add(A1);
            R2.Cells.Add(A2);
            R2.Cells.Add(B1);
            R2.Cells.Add(E1);
            R2.Cells.Add(E2);
            TSheet tsheet = new TSheet();

            tsheet.Name  = "Sheet1";
            tsheet.Title = "表格O";
            tsheet.Head.Rows.Add(R1);
            tsheet.Head.Rows.Add(R2);
            template.Sheets.Add(tsheet);

            string outputFilePath = AppDomain.CurrentDomain.BaseDirectory + "/ExcelTests/out2.xlsx";
            bool   result         = excel.WriteFile(outputFilePath, ds, template);

            Assert.IsTrue(result);
        }
예제 #5
0
        /// <summary>
        /// The create template.
        /// </summary>
        /// <param name="tree">
        /// The tree.
        /// </param>
        /// <param name="template">
        /// The template.
        /// </param>
        /// <param name="parentId">
        /// The parent id.
        /// </param>
        public static void CreateTemplate(TTree tree, TTemplate template, ID parentId)
        {
            Assert.ArgumentNotNull(tree, "database");
              Assert.ArgumentNotNull(template, "template");
              Assert.ArgumentNotNull(parentId, "parentId");

              Item item = tree.Database.GetItem(template.ID);

              if (item == null)
              {
            tree.Database.CreateItem(template.ID, template.Name, new TemplateID(TemplateIDs.Template), parentId);
              }

              CreateSections(tree, template);

              tree.Database.Engines.TemplateEngine.Reset();
        }
    // Add template to database. Returns added template ID.
    public bool addTemplate(TTemplate tpt, ref int id)
    {
        OleDbCommand   cmdInsert     = null;
        OleDbParameter dbParamInsert = null;
        OleDbCommand   cmdSelect     = null;

        try{
            // Create SQL command containing ? parameter for BLOB.
            cmdInsert = new OleDbCommand("INSERT INTO enroll(template) values(?) ", _connection);
            // Create parameter for ? contained in the SQL statement.
            System.Byte [] temp = new System.Byte[tpt._size + 1];
            System.Array.Copy(tpt._tpt, 0, temp, 0, tpt._size);

            dbParamInsert = new OleDbParameter("@template", OleDbType.VarBinary, tpt._size,
                                               ParameterDirection.Input, false, 0, 0, "ID",
                                               DataRowVersion.Current, temp);
            cmdInsert.Parameters.Add(dbParamInsert);

            //execute query
            if (_connection.State == ConnectionState.Open)
            {
                cmdInsert.ExecuteNonQuery();
            }
        }
        catch {
            return(false);
        }

        try{
            // Create SQL command containing ? parameter for BLOB.
            cmdSelect = new OleDbCommand("SELECT top 1 ID FROM enroll ORDER BY ID DESC", _connection);

            id = System.Convert.ToInt32(cmdSelect.ExecuteScalar());
        }
        catch {
            return(false);
        }

        return(true);
    }
예제 #7
0
        /****************************************************************************/
        private TToken CreateToken(CompiledTransform transform, string name, JToken child)
        {
            var t = child.GetType().ToString();

            if (child is JValue val)
            {
                if (name.StartsWith("#include"))
                {
                    transform.LoadInclude(val.Value.ToString());
                    return(null);
                }

                if (name.StartsWith("#break"))
                {
                    return(new TBreak());
                }

                if (name.StartsWith("#variable"))
                {
                    return(new TVariable(name, val));
                }

                if (name.StartsWith("#message"))
                {
                    return(new TMessage(val));
                }

                if (name.StartsWith("#throw"))
                {
                    return(new TThrow(name, val));
                }

                var sval = val.ToString();

                if (name.StartsWith("#arrayitem"))
                {
                    return(new TSimpleArrayItem(val));
                }

                if (sval.StartsWith("#copyof"))
                {
                    return(new TCopyOf(name, sval));
                }

                return(new TProperty(name, val));
            }

            if (child is JObject obj)
            {
                if (name.StartsWith("#template"))
                {
                    var template = new TTemplate(name, obj);

                    this.Templates.Add(template.Name, template);
                    return(null);
                }

                if (name.StartsWith("#function"))
                {
                    var function = new TFunction(name, obj);

                    this.Functions.Add(function.Name, function);
                    return(null);
                }

                if (name.StartsWith("#variable"))
                {
                    return(new TVariableObject(name, obj));
                }

                if (name.StartsWith("#calltemplate"))
                {
                    return(new TCallTemplate(name, obj));
                }

                if (name.StartsWith("#bind"))
                {
                    return(new TBind(name, obj));
                }

                if (name.StartsWith("#foreachgroup"))
                {
                    return(new TForEachGroup(name, obj));
                }

                if (name.StartsWith("#foreach"))
                {
                    return(new TForEach(name, obj));
                }

                if (name.StartsWith("#arrayitem"))
                {
                    return(new TObject(name, obj));
                }

                if (name.StartsWith("#array"))
                {
                    return(new TArray(name, obj));
                }

                if (name.StartsWith("#if"))
                {
                    return(new TIf(name, obj));
                }

                if (name.StartsWith("#try"))
                {
                    return(new TTry(obj));
                }

                if (name.StartsWith("#catch"))
                {
                    if (_previous is TTry || _previous is TCatch)
                    {
                        return(new TCatch(name, obj));
                    }

                    throw new Transformer.SyntaxException("#catch must follow a #try or another #catch");
                }

                if (name.StartsWith("#if"))
                {
                    return(new TIf(name, obj));
                }

                if (name.StartsWith("#elseif"))
                {
                    if (_previous is TIf || _previous is TElseIf)
                    {
                        return(new TElseIf(name, obj));
                    }

                    throw new Transformer.SyntaxException("#elseif must follow an #if or another #elseif");
                }

                if (name.StartsWith("#else"))
                {
                    if (_previous is TIf || _previous is TElseIf)
                    {
                        return(new TElse(name, obj));
                    }

                    throw new Transformer.SyntaxException("#elseif must follow an #if or an #elseif");
                }

                return(new TObject(name, obj));
            }

            if (child is JArray array)
            {
                return(new TExplicitArray(name, array));
            }

            return(null);
        }
예제 #8
0
파일: TItemBase.cs 프로젝트: zigor/phantom-
 /// <summary>
 /// Initializes a new instance of the <see cref="TItemBase"/> class.
 /// </summary>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="id">
 /// The id.
 /// </param>
 /// <param name="template">
 /// The template.
 /// </param>
 public TItemBase(string name, ID id, TTemplate template)
     : this(name, id, new TemplateID(template.ID))
 {
 }
예제 #9
0
파일: TItemBase.cs 프로젝트: zigor/phantom-
 /// <summary>
 /// Initializes a new instance of the <see cref="TItemBase"/> class.
 /// </summary>
 /// <param name="id">
 /// The id.
 /// </param>
 /// <param name="template">
 /// The template.
 /// </param>
 public TItemBase(ID id, TTemplate template)
     : this("TItem", id, template)
 {
 }
예제 #10
0
파일: TItemBase.cs 프로젝트: zigor/phantom-
 /// <summary>
 /// Initializes a new instance of the <see cref="TItemBase"/> class.
 /// </summary>
 /// <param name="template">
 /// The template.
 /// </param>
 public TItemBase(TTemplate template)
     : this(ID.NewID, template)
 {
 }
예제 #11
0
파일: TItemBase.cs 프로젝트: zigor/phantom-
 /// <summary>
 /// Initializes a new instance of the <see cref="TItemBase"/> class.
 /// </summary>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="template">
 /// The template.
 /// </param>
 public TItemBase(string name, TTemplate template)
     : this(name, ID.NewID, template)
 {
 }
예제 #12
0
        public ActionResult Export(int payId)
        {
            PaymentManager pm      = new PaymentManager();
            Payment        payment = pm.LoadPayment(payId);

            #region 动态模板
            TTemplate template = new TTemplate();
            TRow      R1       = new TRow();
            TRow      R2       = new TRow();
            int       index1   = 3;
            int       index2   = 3;
            TCell     A        = new TCell("PersonId", "ID", 0, 0); A.RowSpan = 2; A.Width = 1;
            TCell     B        = new TCell("PersonName", "姓名", 0, 1); B.RowSpan = 2;
            TCell     C        = new TCell("PersonCode", "身份证", 0, 2); C.RowSpan = 2;
            R1.Cells.Add(A);
            R1.Cells.Add(B);
            R1.Cells.Add(C);
            foreach (PayItemDO item in payment.Items)
            {
                TCell cell = new TCell();
                cell.Name    = item.ItemName;
                cell.Caption = item.ItemCaption;
                if (item.IsLeaf == true)
                {
                    //cell.Width = 50;
                }
                if (item.ParentId == 0)
                {
                    cell.RowIndex    = 0;
                    cell.ColumnIndex = index1;
                    int colspan = 1;
                    foreach (PayItemDO pi in payment.Items)
                    {
                        if (pi.ParentId == item.ItemId)
                        {
                            colspan++;
                        }
                    }
                    if (colspan == 1)
                    {
                        cell.RowSpan = 2;
                        index1++;
                        index2++;
                    }
                    else
                    {
                        cell.ColSpan = colspan - 1;
                        index1       = index1 + cell.ColSpan;
                    }
                    R1.Cells.Add(cell);
                }
                else
                {
                    cell.RowIndex    = 1;
                    cell.ColumnIndex = index2;
                    index2           = index2 + 1;
                    R2.Cells.Add(cell);
                }
            }

            TSheet tsheet = new TSheet();
            tsheet.Name  = "Sheet1";
            tsheet.Title = "Sheet1";
            tsheet.Head.Rows.Add(R1);
            tsheet.Head.Rows.Add(R2);
            template.Sheets.Add(tsheet);
            #endregion

            IExcel  excel = ExcelFactory.CreateDefault();
            DataSet ds    = new DataSet();
            payment.DataSource.TableName = "Sheet1";
            ds.Tables.Add(payment.DataSource);
            POIStream stream = new POIStream();
            stream.AllowClose = false;
            excel.Write(stream, template, ds, ExcelExtendType.XLSX);
            stream.AllowClose = true;
            byte[] buffer = new byte[stream.Length];
            stream.Position = 0;
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            HttpResponse context = System.Web.HttpContext.Current.Response;
            try
            {
                context.ContentType = "application/ms-excel";
                context.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", HttpUtility.UrlEncode(payment.PayTitle, System.Text.Encoding.UTF8)));
                context.BinaryWrite(buffer);
                context.Flush();
                context.End();
            }
            catch (Exception ex)
            {
                context.ContentType = "text/plain";
                context.Write(ex.Message);
            }
            return(null);
        }