public void SetImageStatus(string imagePath, IMAGE_TYPE imageType)
 {
     imagePath   = Path.GetFileName(imagePath.Replace("/", "\\"));
     _statusText = String.Format("{0}:  {1}", imageType == IMAGE_TYPE.LOCAL_IMAGE ? "Local image": "Web image", imagePath);
     PerformLayout();
     Invalidate();
 }
        public static string Images(IMAGE_TYPE type)
        {
            switch (type)
            {
            case IMAGE_TYPE.DEBUG:
                return(IMAGE_DEBUG);

            case IMAGE_TYPE.ERROR:
                return(IMAGE_ERROR);

            case IMAGE_TYPE.FATAL:
                return(IMAGE_FATAL);

            case IMAGE_TYPE.INFO:
                return(IMAGE_INFO);

            case IMAGE_TYPE.WARN:
                return(IMAGE_WARN);

            case IMAGE_TYPE.CUSTOM:
                return(IMAGE_CUSTOM);

            default:
                return(IMAGE_INFO);
            }
        }
 public void SetImageStatus(string imagePath, IMAGE_TYPE imageType)
 {
     imagePath = Path.GetFileName(imagePath.Replace("/", "\\"));
     _statusText = String.Format("{0}:  {1}", imageType == IMAGE_TYPE.LOCAL_IMAGE ? "Local image": "Web image", imagePath);
     PerformLayout();
     Invalidate();
 }
        public override byte[] GetImage(IMAGE_TYPE imageType, int id)
        {
            String url;
            if (imageType == IMAGE_TYPE.picture)
                url = siteUrl + "kuwaitindex/bio_picture.php?id=";
            else
                url = siteUrl + "kuwaitindex/bio_wsq.php?id=";

            url += id.ToString();

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";

            byte[] bytes = null;
            using (Stream sm = request.GetResponse().GetResponseStream())
            {
                try
                {
                    //List<JsonResult> result = jsonStr.FromJson<List<JsonResult>>(s);

                    //StreamReader sr = new StreamReader(sm);
                    //String str = sr.ReadToEnd();
                    //sr.Close();
                    DataContractJsonSerializer serialiser = new DataContractJsonSerializer(typeof(List<JsonResult>));
                    List<JsonResult> result = serialiser.ReadObject(sm) as List<JsonResult>;
                    if (result.Count != 0)
                    {
                        if (result[0].result != null && result[0].result != "success")
                            throw new Exception(result[0].result);
                        //MessageBox.Show(result[0].result);
                        else
                        {
                            try
                            {
                                if (imageType == IMAGE_TYPE.picture)
                                {
                                    if (result[0].picture != null)
                                        bytes = System.Convert.FromBase64String(result[0].picture);
                                }
                                else
                                {
                                    if (result[0].wsq != null)
                                        bytes = System.Convert.FromBase64String(result[0].wsq);
                                }
                            }
                            catch (Exception ex) { throw new Exception(ex.Message); }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            return bytes;
        }
Exemple #5
0
    public void SetImageSmooth(IMAGE_TYPE type, Sprite sprite, float playTime = 1f)
    {
        Image image = GetImageObject(type);

        if (null == image)
        {
            return;
        }

        if (image.sprite == sprite)
        {
            return;
        }

        switch (type)
        {
        case IMAGE_TYPE.BACKIMAGE:
        {
            DG.Tweening.DOTween.To(() => image.color, x => image.color = x, Color.black, playTime * 0.5f)
            .onComplete = () =>
            {
                image.sprite = sprite;
                DG.Tweening.DOTween.To(() => image.color, x => image.color = x, Color.white, playTime * 0.5f);
            };
        }
        break;

        case IMAGE_TYPE.PORTRAIT_LEFT:
        case IMAGE_TYPE.PORTRAIT_RIGHT:
        {
            Vector3 originPos = Vector3.zero;
            Vector3 targetPos = Vector3.zero;
            float   movePosX  = 200f;

            if (type == IMAGE_TYPE.PORTRAIT_LEFT)
            {
                targetPos = originLeftPortraitPos + new Vector3(-movePosX, 0f);
                originPos = originLeftPortraitPos;
            }
            else
            {
                targetPos = originRightPortraitPos + new Vector3(movePosX, 0f);
                originPos = originRightPortraitPos;
            }

            DG.Tweening.DOTween.To(() => image.rectTransform.localPosition, x => image.rectTransform.localPosition = x, targetPos, playTime * 0.5f)
            .onComplete = () =>
            {
                image.sprite = sprite;
                DG.Tweening.DOTween.To(() => image.rectTransform.localPosition, x => image.rectTransform.localPosition = x, originPos, playTime * 0.5f);
            };
        }
        break;
        }
    }
Exemple #6
0
    private void SetEnable(IMAGE_TYPE type, bool enable)
    {
        Image image = GetImageObject(type);

        if (null == image)
        {
            return;
        }

        image.gameObject.SetActive(enable);
    }
Exemple #7
0
    private Image GetImageObject(IMAGE_TYPE type)
    {
        switch (type)
        {
        case IMAGE_TYPE.BACKIMAGE:
            return(backImage);

        case IMAGE_TYPE.PORTRAIT_LEFT:
            return(portraitL);

        case IMAGE_TYPE.PORTRAIT_RIGHT:
            return(portraitR);
        }
        return(null);
    }
Exemple #8
0
    private void SetImage(IMAGE_TYPE type, Sprite sprite)
    {
        Image image = GetImageObject(type);

        if (null == image)
        {
            return;
        }

        if (image.sprite == sprite)
        {
            return;
        }

        image.sprite = sprite;
    }
 /**
  * @brief   Reads the image id from the json in accordance with the 
  *          received type and the step number
  * @returns string containing the image's id, empty string if not found
  */
 private string getImageID(IMAGE_TYPE type, int stepNum)
 {
     JArray json = new JArray();
     if (type == IMAGE_TYPE.Baseline)
     {
         json = (JArray)this.testJson["expectedAppOutput"];
     }
     else if (type == IMAGE_TYPE.Current)
     {
         json = (JArray)this.testJson["actualAppOutput"];
     }
     try
     {
         return (string)json[stepNum]["image"]["id"];
     }
     catch
     {
         return "";
     }
 }
    public static void SaveTextureToFile(Texture2D texture, string filename, IMAGE_TYPE itype)
    {
        string path = Application.dataPath + "/"+ filename;
        string path2 = Application.persistentDataPath + "/"+ filename;

        if (itype == IMAGE_TYPE.JPG)
        {

        }
        else
        {

        }
        byte[] data;
        switch (itype)
        {

        case IMAGE_TYPE.JPG:
            data = texture.EncodeToJPG();
            Save(path, data);
            break;
        case IMAGE_TYPE.PNG:
            data = texture.EncodeToPNG();
            Save(path, data);
            Logger.Log ("Encoding to PNG");
            break;
        default:
            Logger.Log ("Incorrect IMAGE_TYPE.");
            break;
        }

        #if UNITY_EDITOR
        Logger.Log(path + " : WAS SAVE");
        #else
        Debug.Log (path2 + " : WAS SAVE");
        #endif
    }
        public byte[][] GetImage(IMAGE_TYPE imageType, int id)
        {
            byte[][] buffer = new byte[11][];
            //byte[] buffer = new byte[1];
            //ArrayList fingersCollection = null;

            if (_settings["enroll"] == "db")
            {
                DataSource ds = null;

                if (_settings["dbProvider"] == "dedicatedServer")
                    ds = new DAO.Database(_settings);
                else if (_settings["dbProvider"] == "cloudServer")
                    ds = new DAO.CloudDatabase(_settings);
                else
                    throw new Exception("Wrong database provider settings");

                buffer = ds.GetImage(imageType, Convert.ToInt32(id));

                //if (imageType == IMAGE_TYPE.wsq)
                //{
                //    buffer = ds.GetImage(IMAGE_TYPE.wsq, Convert.ToInt32(id));

                //    //var bioProcessor = new BioProcessor.BioProcessor();
                //    //bioProcessor.processEnrolledData(buffer, out fingersCollection);

                //}
                //else if (imageType == IMAGE_TYPE.picture)
                //{
                //    buffer = ds.GetImage(IMAGE_TYPE.picture, Convert.ToInt32(id));
                //}

            }

            return buffer;
        }
Exemple #12
0
        public byte[] GetImage(IMAGE_TYPE imageType, int id)
        {
            SqlConnection conn   = null;
            SqlCommand    cmd    = null;
            SqlDataReader reader = null;

            byte[] buffer = null;

            try
            {
                string connectionString = GrabImageClient.Helper.getConnectionString();
                conn = new SqlConnection(connectionString);

                conn.Open();

                cmd            = new SqlCommand();
                cmd.Connection = conn;

                if (imageType == IMAGE_TYPE.picture)
                {
                    cmd.CommandText = "SELECT " + dbPictureColumn + " FROM " + dbPictureTable + " WHERE " + dbIdColumn + " = @id";
                }
                else
                {
                    cmd.CommandText = "SELECT " + dbFingerColumn + " FROM " + dbFingerTable + " WHERE " + dbIdColumn + " = @id";
                }

                //cmd.Parameters.Add(new SqlCeParameter("@id", SqlDbType.Int));   // doesn't work
                cmd.Parameters.AddWithValue("@id", id);

                reader = cmd.ExecuteReader();
                //reader.Read();

                //SqlBinary binary;
                //SqlBytes bytes;

                //                if (reader.HasRows)   //Does not work for CE
                if (reader.Read())
                {
                    //if (!reader.IsDBNull(0))
                    //    id = reader.GetInt32(0);
                    if (!reader.IsDBNull(0))
                    {
                        //binary = reader.GetSqlBinary(1);
                        if (imageType == IMAGE_TYPE.picture)
                        {
                            buffer = (byte[])reader[dbPictureColumn]; //(byte[])reader["AppImage"];
                        }
                        else
                        {
                            buffer = (byte[])reader[dbFingerColumn]; //(byte[])reader["AppImage"];
                        }
                        //int maxSize = 200000;
                        //buffer = new byte[maxSize];
                        //reader.GetBytes(1, 0L, buffer, 0, maxSize);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                try
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }

                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }

                    if (conn != null)
                    {
                        conn = null;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }

            return(buffer);
        }
Exemple #13
0
        public void SendImage(IMAGE_TYPE imageType, int id, ref byte[] buffer)
        {
            SqlConnection conn = null;
            SqlCommand    cmd  = null;

            //object incrementId = null;
            try
            {
                //System.Windows.Forms.MessageBox.Show("connect str1: " + getConnectionString());
                //conn = new SqlConnection(getConnectionString());
                string connectionString = GrabImageClient.Helper.getConnectionString();
                conn = new SqlConnection(connectionString);

                conn.Open();

                cmd            = new SqlCommand();
                cmd.Connection = conn;

                string dbImageTable, dbImageColumn;
                if (imageType == IMAGE_TYPE.picture)
                {
                    dbImageTable  = dbPictureTable;
                    dbImageColumn = dbPictureColumn;
                }
                else
                {
                    dbImageTable  = dbFingerTable;
                    dbImageColumn = dbFingerColumn;
                }

                cmd.CommandText = String.Format(@"
                            begin tran
                                update {0} with (serializable) SET {1} = @picture where {2} = @id
                                if @@rowcount = 0 
                                begin
                                    insert into {0} ({2}, {1}) values (@id, @picture) 
                                end
                            commit tran ", dbImageTable, dbImageColumn, dbIdColumn);

                cmd.Parameters.Add("@picture", SqlDbType.VarBinary);
                cmd.Parameters["@picture"].Value = buffer;

                cmd.Parameters.Add("@id", SqlDbType.Int);
                cmd.Parameters["@id"].Value = id;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                try
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }

                    if (conn != null)
                    {
                        conn = null;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Exemple #14
0
        public override void SendImage(IMAGE_TYPE imageType, int id, ref byte[] buffer)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;
            //object incrementId = null;
            try
            {
                //conn = new SqlConnection(getConnectionString());
                conn = new SqlConnection(_connectionString);

                conn.Open();

                cmd = new SqlCommand();
                cmd.Connection = conn;

                string dbImageTable, dbImageColumn;
                if (imageType == IMAGE_TYPE.picture)
                {
                    dbImageTable = dbPictureTable;
                    dbImageColumn = dbPictureColumn;
                }
                else
                {
                    dbImageTable = dbFingerTable;
                    dbImageColumn = dbFingerColumn;
                }

                cmd.CommandText = String.Format(@"
                            begin tran
                                update {0} with (serializable) SET {1} = @image where {2} = @id
                                if @@rowcount = 0
                                begin
                                    insert into {0} ({2}, {1}) values (@id, @image)
                                end
                            commit tran ", dbImageTable, dbImageColumn, dbIdColumn);

                cmd.Parameters.Add("@image", SqlDbType.VarBinary);
                cmd.Parameters["@image"].Value = buffer;

                cmd.Parameters.Add("@id", SqlDbType.Int);
                cmd.Parameters["@id"].Value = id;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                //System.Windows.Forms.MessageBox.Show(ex.Message);
                throw new Exception(ex.Message);
            }
            finally
            {
                try
                {
                    if (conn != null && conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                        conn = null;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Exemple #15
0
        //string dbPictureTable = System.Configuration.ConfigurationManager.AppSettings["dbPictureTable"];
        //string dbFingerTable = System.Configuration.ConfigurationManager.AppSettings["dbFingerTable"];
        //string dbIdColumn = System.Configuration.ConfigurationManager.AppSettings["dbIdColumn"];
        //string dbPictureColumn = System.Configuration.ConfigurationManager.AppSettings["dbPictureColumn"];
        //string dbFingerColumn = System.Configuration.ConfigurationManager.AppSettings["dbFingerColumn"];
        //public override byte[] GetImage(IMAGE_TYPE imageType, int id)
        public override byte[][] GetImage(IMAGE_TYPE imageType, System.Int32 id)
        {
            //throw new Exception(getConnectionString());

            SqlConnection conn = null;
            SqlCommand cmd = null;
            SqlDataReader reader = null;

            byte[][] buffer = new byte[11][];
            //byte[] buffer = new byte[0];

            try
            {
                //conn = buildConnectionString();
                conn = new SqlConnection(_connectionString);
                conn.Open();

                cmd = new SqlCommand();
                cmd.Connection = conn;

                //if (id != 20031448)
                //{
                //    if (IMAGE_TYPE.wsq == imageType)
                //        cmd.CommandText = "SELECT wsq FROM visitors WHERE id = @id";
                //    else
                //        cmd.CommandText = "SELECT picture FROM visitors WHERE id = @id";
                //}
                //else
            /*
                {
                    if (IMAGE_TYPE.wsq == imageType)
                        //cmd.CommandText = "SELECT AppId, AppWsq FROM v_fingerprintverify WHERE ChkId = @id";
                        cmd.CommandText = "SELECT AppWsq FROM T_AppPers WHERE AppId = @id";
                    else
                        //cmd.CommandText = "SELECT AppId, AppImage FROM v_fingerprintverify WHERE ChkId = @id";
                        cmd.CommandText = "SELECT AppImage FROM T_AppPers WHERE AppId = @id";
                }
            */
                if (IMAGE_TYPE.picture == imageType)
                    cmd.CommandText = "SELECT " + dbPictureColumn + " FROM " + dbPictureTable + " WHERE " + dbIdColumn + " = @id";
                else if (IMAGE_TYPE.wsq == imageType)
                    cmd.CommandText = "SELECT " + dbFingerColumn + "," + fingerFields + " FROM " + dbFingerTable + " WHERE " + dbIdColumn + " = @id";
                    //cmd.CommandText = "SELECT " + dbFingerColumn + " FROM " + dbFingerTable + " WHERE " + dbIdColumn + " = @id";
                //else if (IMAGE_TYPE.fingerTemplates == imageType)
                    //cmd.CommandText = "SELECT li,lm,lr,ll,ri,rm,rr,rl,lt,rt FROM " + dbFingerTable + " WHERE " + dbIdColumn + " = @id";
                else
                    throw new Exception("unknown image type");

                //cmd.Parameters.Add(new SqlCeParameter("@id", SqlDbType.Int));   // doesn't work
                cmd.Parameters.AddWithValue("@id", id);

                //cmd.Parameters.Add("@id", SqlDbType.Int);
                //cmd.Parameters[0].Value = id;

                reader = cmd.ExecuteReader();
                //reader.Read();

                //SqlBinary binary;
                //SqlBytes bytes;

                //                if (reader.HasRows)   //Does not work for CE
                if (reader.Read())
                {

                    if (!reader.IsDBNull(0) && ((byte[])reader[0]).Length != 1)
                    {
                        //binary = reader.GetSqlBinary(1);
                        //if (id != 20031448)
                        //{
                        //    if (IMAGE_TYPE.wsq == imageType)
                        //        buffer = (byte[])reader["wsq"];
                        //    //buffer = (byte[])reader["AppWsq"];
                        //    else
                        //        buffer = (byte[])reader["picture"];
                        //}
                        //else
                        /*
                                                {
                                                    if (IMAGE_TYPE.wsq == imageType)
                                                        buffer = (byte[])reader["AppWsq"];
                                                    else
                                                        buffer = (byte[])reader["AppImage"];
                                                }
                        */
                        if (IMAGE_TYPE.wsq == imageType)
                        {
                            buffer[0] = (byte[])reader[dbFingerColumn];  //(byte[])reader["AppWsq"];

                            //string[] result = fingerFields.Split(new char[] { ',' });

                            int i = 1;
                            foreach (string finger in fingerFieldsArray)
                            {
                                FingerListEnum f = (FingerListEnum)Enum.Parse(typeof(FingerListEnum), finger);
                                if (!reader.IsDBNull(i) && ((byte[])reader[finger]).Length > 1)
                                    buffer[(int)f] = (byte[])reader[finger];  //(byte[])reader["li"];
                                else
                                    buffer[(int)f] = new byte[0];

                                i++;
                            }
                        }
                        else
                            buffer[0] = (byte[])reader[dbPictureColumn]; //(byte[])reader["AppImage"];

                        //buffer = (byte[])reader["AppImage"];
                        //int maxSize = 200000;
                        //buffer = new byte[maxSize];
                        //reader.GetBytes(1, 0L, buffer, 0, maxSize);
                    }

                    //if (!reader.IsDBNull(0))
                    //    id = reader.GetInt32(0);
            //                    if (!reader.IsDBNull(0))
            //                    {
                        //binary = reader.GetSqlBinary(1);
                        //if (id != 20031448)
                        //{
                        //    if (IMAGE_TYPE.wsq == imageType)
                        //        buffer = (byte[])reader["wsq"];
                        //    //buffer = (byte[])reader["AppWsq"];
                        //    else
                        //        buffer = (byte[])reader["picture"];
                        //}
                        //else
                        /*
                                                {
                                                    if (IMAGE_TYPE.wsq == imageType)
                                                        buffer = (byte[])reader["AppWsq"];
                                                    else
                                                        buffer = (byte[])reader["AppImage"];
                                                }
                        */

                        //if (IMAGE_TYPE.picture == imageType)
                        //{
                        //    if (!reader.IsDBNull(0))
                        //        buffer = (byte[])reader[dbPictureColumn]; //(byte[])reader["AppImage"];
                        //}
                        //else if (IMAGE_TYPE.wsq == imageType)
                        //{
                        //    if (!reader.IsDBNull(0))
                        //        buffer = (byte[])reader[dbFingerColumn];  //(byte[])reader["AppWsq"];
                        //}
                        //else if (IMAGE_TYPE.fingerTemplates == imageType)
                        //{
                        //    StringBuilder sb = new StringBuilder();
                        //    sb.Append(reader["li"]);
                        //    sb.Append(reader["lm"]);
                        //    sb.Append(reader["lr"]);
                        //    sb.Append(reader["ll"]);
                        //    sb.Append(reader["ri"]);
                        //    sb.Append(reader["rm"]);
                        //    sb.Append(reader["rr"]);
                        //    sb.Append(reader["rl"]);
                        //    sb.Append(reader["lt"]);
                        //    sb.Append(reader["rt"]);
                        //    buffer = System.Text.Encoding.UTF8.GetBytes(sb.ToString());
                        //}

                        ////buffer = (byte[])reader["AppImage"];
                        //int maxSize = 200000;
                        //buffer = new byte[maxSize];
                        //reader.GetBytes(1, 0L, buffer, 0, maxSize);
            //                    }
                    //else
                    //{
                    //    buffer = new byte[1];
                    //}
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                try
                {
                    if (reader != null)
                        reader.Close();

                    if (conn != null && conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                        conn = null;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }

            if (IMAGE_TYPE.picture == imageType && buffer[0] == null)
                buffer[0] = getEmptyBitmap();

            return buffer;
        }
Exemple #16
0
        public void SendImage(IMAGE_TYPE imageType, int id, ref byte[] buffer)
        {
            //String url = siteUrl + sitePicturePath;    // "kuwaitindex/bio_picture.php?id=";
            String url;

            if (imageType == IMAGE_TYPE.picture)
            {
                url = siteUrl + sitePictureTablePath;    // "kuwaitindex/bio_picture.php?id=";
            }
            else
            {
                url = siteUrl + siteFingerTablePath;    // "kuwaitindex/bio_wsq.php?id=";
            }
            List <string> postData = new List <string>();
            //HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://nomad.host22.com/kuwaitindex/bio_picture.php");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method      = "POST";
            request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            postData.Add(HttpUtility.UrlEncode("id") + "=" + HttpUtility.UrlEncode(id.ToString()));

            // Convert the binary input into Base64 UUEncoded output.
            string base64String;

            try
            {
                base64String = System.Convert.ToBase64String(buffer, 0, buffer.Length);
            }
            catch (System.ArgumentNullException ex)
            {
                throw new Exception(ex.ToString());
            }

            if (imageType == IMAGE_TYPE.picture)
            {
                postData.Add(HttpUtility.UrlEncode(dbPictureColumnWebService) + "=" + HttpUtility.UrlEncode(base64String.ToString()));
            }
            else
            {
                postData.Add(HttpUtility.UrlEncode(dbFingerColumnWebService) + "=" + HttpUtility.UrlEncode(base64String.ToString()));
            }

            string queryString = String.Join("&", postData.ToArray());

            byte[] byteArray = Encoding.UTF8.GetBytes(queryString);
            //write to stream
            request.ContentLength = byteArray.Length;
            Stream s = request.GetRequestStream();

            s.Write(byteArray, 0, byteArray.Length);
            s.Close();

            //DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(JsonResult));

            using (Stream sm = request.GetResponse().GetResponseStream())
            {
                //StreamReader sr = new StreamReader(sm);
                //String jsonStr = sr.ReadToEnd();

                //string json = @"{""Name"" : ""My Product""}";
                //MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json));
                try
                {
                    //List<JsonResult> result = jsonStr.FromJson<List<JsonResult>>(s);

                    DataContractJsonSerializer serialiser = new DataContractJsonSerializer(typeof(List <JsonResult>));
                    List <JsonResult>          result     = serialiser.ReadObject(sm) as List <JsonResult>;
                    if (result[0].result != "success")
                    {
                        throw new Exception(result[0].result);
                    }

                    //List<JsonResult> result = JSONHelper.Deserialise<List<JsonResult>>(jsonStr);
                    //JsonResult result = ser.ReadObject(sm) as JsonResult;
                    //MessageBox.Show("Result: " + result.result[0]);
                }
                catch (Exception) { }
            }

            /*
             *          s = request.GetResponse().GetResponseStream();
             *          StreamReader sr = new StreamReader(s);
             *          String str = sr.ReadToEnd();
             *          sr.Close();
             *          s.Close();
             */
        }
Exemple #17
0
/*
 *      internal WebDataService()
 *      {
 *          siteUrl = GrabImageClient.Helper.getAppSetting("siteUrl");
 *          sitePictureTablePath = getAppSetting("sitePictureTablePath");
 *          siteFingerTablePath = getAppSetting("siteFingerTablePath");
 *
 *          dbPictureTableWebService = getAppSetting("dbPictureTableWebService");
 *          dbFingerTableWebService = getAppSetting("dbPictureTableWebService");
 *
 *          dbIdColumnWebService = getAppSetting("dbIdColumnWebService");
 *          dbPictureColumnWebService = getAppSetting("dbPictureColumnWebService");
 *          dbFingerColumnWebService = getAppSetting("dbFingerColumnWebService");
 *
 *      }
 */
        public byte[] GetImage(IMAGE_TYPE imageType, int id)
        {
            //String url = "http://nomad.host22.com/kuwaitindex/bio_picture.php?id=" + id.ToString();
            String url;

            //throw new Exception(siteUrl);

            if (imageType == IMAGE_TYPE.picture)
            {
                url = siteUrl + sitePictureTablePath;    // "kuwaitindex/bio_picture.php?id=";
            }
            else
            {
                url = siteUrl + siteFingerTablePath;    // "kuwaitindex/bio_wsq.php?id=";
            }
            //throw new Exception(url);

            url += "?id=" + id.ToString();


            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method      = "GET";
            request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";

            byte[] bytes = null;
            using (Stream sm = request.GetResponse().GetResponseStream())
            {
                try
                {
                    //List<JsonResult> result = jsonStr.FromJson<List<JsonResult>>(s);

                    //StreamReader sr = new StreamReader(sm);
                    //String str = sr.ReadToEnd();
                    //sr.Close();
                    DataContractJsonSerializer serialiser = new DataContractJsonSerializer(typeof(List <JsonResult>));
                    List <JsonResult>          result     = serialiser.ReadObject(sm) as List <JsonResult>;
                    if (result.Count != 0)
                    {
                        if (result[0].result != null && result[0].result != "success")
                        {
                            throw new Exception(result[0].result);
                        }
                        //MessageBox.Show(result[0].result);
                        else
                        {
                            try
                            {
                                if (imageType == IMAGE_TYPE.picture)
                                {
                                    if (result[0].picture != null)
                                    {
                                        bytes = System.Convert.FromBase64String(result[0].picture);
                                    }
                                }
                                else
                                {
                                    if (result[0].wsq != null)
                                    {
                                        bytes = System.Convert.FromBase64String(result[0].wsq);
                                    }
                                }
                            }
                            catch (Exception ex) { throw new Exception(ex.Message); }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            return(bytes);
        }
Exemple #18
0
 public static BitmapSource Images(IMAGE_TYPE type)
 {
     return _ImageList[type];
 }
Exemple #19
0
 public static extern IntPtr LoadImage(IntPtr hinst, string lpszName, IMAGE_TYPE uType, int cxDesired, int cyDesired, IMAGE_FORMAT_REQUEST fuLoad);
Exemple #20
0
 public abstract void SendImage(IMAGE_TYPE imageType, int id, ref byte[] buffer);
Exemple #21
0
        public byte[] GetImage(IMAGE_TYPE imageType, int id)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;
            SqlDataReader reader = null;

            byte[] buffer = null;

            try
            {
                string connectionString = GrabImageClient.Helper.getConnectionString();
                conn = new SqlConnection(connectionString);

                conn.Open();

                cmd = new SqlCommand();
                cmd.Connection = conn;

                if (imageType == IMAGE_TYPE.picture)
                    cmd.CommandText = "SELECT " + dbPictureColumn + " FROM " + dbPictureTable + " WHERE " + dbIdColumn + " = @id";
                else
                    cmd.CommandText = "SELECT " + dbFingerColumn + " FROM " + dbFingerTable + " WHERE " + dbIdColumn + " = @id";

                //cmd.Parameters.Add(new SqlCeParameter("@id", SqlDbType.Int));   // doesn't work
                cmd.Parameters.AddWithValue("@id", id);

                reader = cmd.ExecuteReader();
                //reader.Read();

                //SqlBinary binary;
                //SqlBytes bytes;

                //                if (reader.HasRows)   //Does not work for CE
                if (reader.Read())
                {
                    //if (!reader.IsDBNull(0))
                    //    id = reader.GetInt32(0);
                    if (!reader.IsDBNull(0))
                    {
                        //binary = reader.GetSqlBinary(1);
                        if (imageType == IMAGE_TYPE.picture)
                            buffer = (byte[])reader[dbPictureColumn]; //(byte[])reader["AppImage"];
                        else
                            buffer = (byte[])reader[dbFingerColumn]; //(byte[])reader["AppImage"];

                        //int maxSize = 200000;
                        //buffer = new byte[maxSize];
                        //reader.GetBytes(1, 0L, buffer, 0, maxSize);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                try
                {
                    if (reader != null)
                        reader.Close();

                    if (conn.State == ConnectionState.Open)
                        conn.Close();

                    if (conn != null)
                        conn = null;
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }

            return buffer;
        }
Exemple #22
0
        //public override byte[] GetImage(IMAGE_TYPE imageType, int id)
        public override byte[] GetImage(IMAGE_TYPE imageType, System.Int32 id)
        {
            //throw new Exception(getConnectionString());

            SqlConnection conn = null;
            SqlCommand cmd = null;
            SqlDataReader reader = null;

            byte[] buffer = new byte[0];

            try
            {
                //conn = buildConnectionString();
                conn = new SqlConnection(getConnectionString());
                conn.Open();

                cmd = new SqlCommand();
                cmd.Connection = conn;

                cmd.CommandText = "SELECT " + dbFingerColumn + " FROM " + dbFingerTable;

                reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    //if (!reader.IsDBNull(0))
                    //    id = reader.GetInt32(0);
                    if (!reader.IsDBNull(0))
                    {
                        //binary = reader.GetSqlBinary(1);
                        //if (id != 20031448)
                        //{
                        //    if (IMAGE_TYPE.wsq == imageType)
                        //        buffer = (byte[])reader["wsq"];
                        //    //buffer = (byte[])reader["AppWsq"];
                        //    else
                        //        buffer = (byte[])reader["picture"];
                        //}
                        //else
                        /*
                                                {
                                                    if (IMAGE_TYPE.wsq == imageType)
                                                        buffer = (byte[])reader["AppWsq"];
                                                    else
                                                        buffer = (byte[])reader["AppImage"];
                                                }
                        */
                        if (IMAGE_TYPE.wsq == imageType)
                            buffer = (byte[])reader[dbFingerColumn];  //(byte[])reader["AppWsq"];
                        else
                            buffer = (byte[])reader[dbPictureColumn]; //(byte[])reader["AppImage"];

                        //buffer = (byte[])reader["AppImage"];
                        //int maxSize = 200000;
                        //buffer = new byte[maxSize];
                        //reader.GetBytes(1, 0L, buffer, 0, maxSize);
                    }
                    //else
                    //{
                    //    buffer = new byte[1];
                    //}
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                try
                {
                    if (reader != null)
                        reader.Close();

                    if (conn != null && conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                        conn = null;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }

            return buffer;
        }
Exemple #23
0
 public static BitmapSource Images(IMAGE_TYPE type)
 {
     return(_ImageList[type]);
 }
Exemple #24
0
        public byte[] GetImage(IMAGE_TYPE imageType, int id)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;
            SqlDataReader reader = null;

            byte[] buffer = null;

            try
            {
                conn = new SqlConnection(getConnectionString());

                conn.Open();

                cmd = new SqlCommand();
                cmd.Connection = conn;

                if (IMAGE_TYPE.wsq == imageType)
                    cmd.CommandText = "SELECT wsq FROM visitors WHERE id = @id";
                else
                    cmd.CommandText = "SELECT picture FROM visitors WHERE id = @id";

                //cmd.Parameters.Add(new SqlCeParameter("@id", SqlDbType.Int));   // doesn't work
                cmd.Parameters.AddWithValue("@id", id);

                reader = cmd.ExecuteReader();
                //reader.Read();

                //SqlBinary binary;
                //SqlBytes bytes;

                //                if (reader.HasRows)   //Does not work for CE
                if (reader.Read())
                {
                    //if (!reader.IsDBNull(0))
                    //    id = reader.GetInt32(0);
                    if (!reader.IsDBNull(0))
                    {
                        //binary = reader.GetSqlBinary(1);
                        if (IMAGE_TYPE.wsq == imageType)
                            buffer = (byte[])reader["wsq"];
                        else
                            buffer = (byte[])reader["picture"];

                        //int maxSize = 200000;
                        //buffer = new byte[maxSize];
                        //reader.GetBytes(1, 0L, buffer, 0, maxSize);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                try
                {
                    if (reader != null)
                        reader.Close();

                    if (conn != null && conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                        conn = null;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }

            return buffer;
        }
Exemple #25
0
        public void SendImage(IMAGE_TYPE imageType, int id, ref byte[] buffer)
        {
            //String url = siteUrl + sitePicturePath;    // "kuwaitindex/bio_picture.php?id=";
            String url;

            if (imageType == IMAGE_TYPE.picture)
                url = siteUrl + sitePictureTablePath;    // "kuwaitindex/bio_picture.php?id=";
            else
                url = siteUrl + siteFingerTablePath;    // "kuwaitindex/bio_wsq.php?id=";

            List<string> postData = new List<string>();
            //HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://nomad.host22.com/kuwaitindex/bio_picture.php");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            postData.Add(HttpUtility.UrlEncode("id") + "=" + HttpUtility.UrlEncode(id.ToString()));

            // Convert the binary input into Base64 UUEncoded output.
            string base64String;
            try
            {
                base64String = System.Convert.ToBase64String(buffer, 0, buffer.Length);
            }
            catch (System.ArgumentNullException ex)
            {
                throw new Exception(ex.ToString());
            }

            if (imageType == IMAGE_TYPE.picture)
                postData.Add(HttpUtility.UrlEncode(dbPictureColumnWebService) + "=" + HttpUtility.UrlEncode(base64String.ToString()));
            else
                postData.Add(HttpUtility.UrlEncode(dbFingerColumnWebService) + "=" + HttpUtility.UrlEncode(base64String.ToString()));

            string queryString = String.Join("&", postData.ToArray());
            byte[] byteArray = Encoding.UTF8.GetBytes(queryString);
            //write to stream
            request.ContentLength = byteArray.Length;
            Stream s = request.GetRequestStream();
            s.Write(byteArray, 0, byteArray.Length);
            s.Close();

            //DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(JsonResult));

            using (Stream sm = request.GetResponse().GetResponseStream())
            {
                //StreamReader sr = new StreamReader(sm);
                //String jsonStr = sr.ReadToEnd();

                //string json = @"{""Name"" : ""My Product""}";
                //MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json));
                try
                {
                    //List<JsonResult> result = jsonStr.FromJson<List<JsonResult>>(s);

                    DataContractJsonSerializer serialiser = new DataContractJsonSerializer(typeof(List<JsonResult>));
                    List<JsonResult> result = serialiser.ReadObject(sm) as List<JsonResult>;
                    if (result[0].result != "success")
                        throw new Exception(result[0].result);

                    //List<JsonResult> result = JSONHelper.Deserialise<List<JsonResult>>(jsonStr);
                    //JsonResult result = ser.ReadObject(sm) as JsonResult;
                    //MessageBox.Show("Result: " + result.result[0]);
                }
                catch (Exception) { }
            }
            /*
                        s = request.GetResponse().GetResponseStream();
                        StreamReader sr = new StreamReader(s);
                        String str = sr.ReadToEnd();
                        sr.Close();
                        s.Close();
            */
        }
Exemple #26
0
 public abstract byte[][] GetImage(IMAGE_TYPE imageType, int id);
Exemple #27
0
 public abstract byte[][] GetImage(IMAGE_TYPE imageType, System.Int32 id);
Exemple #28
0
 public static extern void pdf_converter_pdf_to_image(IntPtr converter, string output_path, IMAGE_TYPE image_type, string input_file, string ranges = "1-N", string password = "");