IEnumerator Start()
    {
        Debug.Log("Started");
        //send this guy the location when ready so we can retrieve information about that area from open weather map
        dataRetrieve = GetComponent <DataRetrieve>();

        // First, check if user has location service enabled
        if (!Input.location.isEnabledByUser)
        {
            Debug.Log("LocationService not enabled");
            yield break;
        }


        // Start service before querying location
        Input.location.Start(500);

        // Wait until service initializes
        int maxWait = 20;

        while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
        {
            yield return(new WaitForSeconds(1));

            maxWait--;
        }

        // Service didn't initialize in 20 seconds
        if (maxWait < 1)
        {
            print("Timed out");
            yield break;
        }

        // Connection has failed
        if (Input.location.status == LocationServiceStatus.Failed)
        {
            print("Unable to determine device location");
            yield break;
        }
        else
        {
            // Access granted and location value could be retrieved
            print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
            dataRetrieve.StartConnecting(Input.location.lastData.latitude, Input.location.lastData.longitude);
        }

        // Stop service if there is no need to query location updates continuously
        Input.location.Stop();
    }
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Form.CheckForIllegalCrossThreadCalls = false;
            this.progressBar1.Value   = 0;
            this.progressBar1.Maximum = lstObjects.Items.Count;
            //this.timer1.Interval = 100;
            //this.timer1.Enabled = true;

            List <Entity>  entity;
            List <GetType> entityType;
            string         apiCode        = "";
            string         bllCode        = "";
            string         getDataRow     = "";
            string         contractCode   = "";
            string         dataAceeCode   = "";
            string         serviceCode    = "";
            string         procedueCode   = "";
            string         viewModelCode  = "";
            string         validationCode = "";

            sPath = lblPath.Text;
            DirectoryInfo info = new DirectoryInfo(sPath);

            DirectoryInfo[] arr = info.GetDirectories();
            for (int i = 0; i < arr.Length; i++)
            {
                Directory.Delete(arr[i].FullName);
            }

            if (this.lstObjects.CheckedItems.Count == 0)
            {
                MessageBox.Show("Không có table để tạo", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                foreach (int item in this.lstObjects.CheckedIndices)
                {
                    this.progressBar1.Value += 1;
                    entity     = DataRetrieve.GetMsSqlTableInfo(lstObjects.Items[item].ToString(), connectionData, false);
                    entityType = DataRetrieve.GetMsSqlTableDataTypeInfo(lstObjects.Items[item].ToString(), connectionData, false);
                    Code.File f = new GenerationClass.Code.File();
                    apiCode      = Code.Generation.GenerateCode(entity, entityType, GetNameSpace(), GetClassModifiers(), lstObjects.Items[item].ToString());
                    bllCode      = Code.Generation.GenerateCodeBLL(entity, entityType, GetNameSpace(), GetClassModifiers(), lstObjects.Items[item].ToString());
                    dataAceeCode = Code.Generation.GenerateCodeDataAccess(entity, entityType, GetNameSpace(), GetClassModifiers(), lstObjects.Items[item].ToString());
                    procedueCode = Code.Generation.GenerateStoreProceduce(entity, entityType, GetNameSpace(), GetClassModifiers(), lstObjects.Items[item].ToString());
                    getDataRow   = Code.Generation.GeneralMethodGetObjectFromDataRow(entity, entityType, GetNameSpace(), GetClassModifiers(), lstObjects.Items[item].ToString());

                    f.Save(lstObjects.Items[item] + "Public", sPath, "Public", apiCode, "cs");
                    f.Save(lstObjects.Items[item] + "BUS", sPath, "BUS", bllCode, "cs");
                    f.Save(lstObjects.Items[item] + "DAL", sPath, "DAL", dataAceeCode, "cs");
                    f.Save(lstObjects.Items[item] + "DataRow", sPath, "ROW", getDataRow, "cs");

                    f.Save(lstObjects.Items[item] + "StoreProceduce", sPath, "StoreProceduce", procedueCode, "sql");
                    // f.Save(lstObjects.Items[item].ToString() + "Validation", sPath, "Validation", validationCode, "cs");
                }
                //Copy database.cs
                FileInfo f1 = new FileInfo(Application.StartupPath + @"\Database.cs");
                f1.CopyTo(sPath + @"\DAL\Database.cs", true);
                this.Text = "Bạn đã tạo được " + lstObjects.CheckedIndices.Count + " table";
                //  MessageBox.Show("Bạn đã tạo được " + lstObjects.CheckedIndices.Count + " table", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 3
0
        private void GetInforTableIntoGridview()
        {
            List <EntityTable> entityTable;

            entityTable = DataRetrieve.GetMsSqlTableOneInfo(tableNameDetail, connectionData, false);
        }