Beispiel #1
0
    public IEnumerator DownloadCatalogue(CatalogueList list)
    {
        WWW catalogueDownload = new WWW("http://www.appatier.xyz/php/Catalogue/CATALOGUE.json");

        yield return(catalogueDownload);

        string json = catalogueDownload.text;

        if (catalogueDownload.error != null)
        {
            Debug.LogError("ERROR FROM SERVER :: " + catalogueDownload.error);
            DestroyImmediate(GameObject.Find("Downloading"));
        }
        else
        {
            //then if the retrieval was successful, validate its content to ensure the level file integrity is intact
            if (catalogueDownload.text != null || catalogueDownload.text != "")
            {
                if (catalogueDownload.text.Contains("itemList"))
                {
                    Debug.Log("Successfully Downloaded the file -- Attempting to deserialize to json");
                    AddDownloadedItems(catalogueDownload.text, list);
                    DestroyImmediate(GameObject.Find("Downloading"));
                }
            }
        }
    }
Beispiel #2
0
    public static void SaveAllItems(CatalogueList list)
    {
        if (!File.Exists(FilePath))
        {
            Debug.LogWarning("There is no file here so we should create one");
            StreamWriter sw = File.CreateText(FilePath);
            sw.Close();
        }

        text = String.Empty;
        text = JsonUtility.ToJson(list, true);
        Debug.Log("Uploaded Json :: " + text);
        //Debug.Log(text);
        // Check to see if the file exists

        StreamWriter nsw = new StreamWriter(FilePath);

        nsw.Write(text);
        nsw.Close();
        GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        sphere.name = "Uploading";
        sphere.AddComponent <FileHandler>();
        sphere.GetComponent <FileHandler>().StartCoroutine(sphere.GetComponent <FileHandler>().UploadCatalogue(text));
    }
Beispiel #3
0
    public static CatalogueList Create()
    {
        CatalogueList asset = ScriptableObject.CreateInstance <CatalogueList>();

        AssetDatabase.CreateAsset(asset, "Assets/CatalogueItem.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
 void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         inventoryItemList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(CatalogueList)) as CatalogueList;
     }
 }
Beispiel #5
0
    public static void DownloadFile(CatalogueList list)
    {
        GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        sphere.name = "Downloading";
        sphere.AddComponent <FileHandler>();
        sphere.GetComponent <FileHandler>().StartCoroutine(sphere.GetComponent <FileHandler>().DownloadCatalogue(list));
    }
 void CreateNewItemList()
 {
     // There is no overwrite protection here!
     // There is No "Are you sure you want to overwrite your existing object?" if it exists.
     // This should probably get a string from the user to create a new name and pass it ...
     viewIndex         = 1;
     inventoryItemList = CreateCatalogueITemList.Create();
     if (inventoryItemList)
     {
         inventoryItemList.itemList = new List <CatalogueItem>();
         string relPath = AssetDatabase.GetAssetPath(inventoryItemList);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
    void OpenCatalogueList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Inventory Item List", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            inventoryItemList = AssetDatabase.LoadAssetAtPath(relPath, typeof(CatalogueList)) as CatalogueList;
            if (inventoryItemList.itemList == null)
            {
                inventoryItemList.itemList = new List <CatalogueItem>();
            }
            if (inventoryItemList)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
Beispiel #8
0
 protected void btnGetCatalogueList_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Show_ID))
     {
         divCatalogueList.Visible      = true;
         CatalogueListByRingNumberList = CatalogueList.GetCatalogueListData(_connString, Show_ID);
         if (CatalogueListByRingNumberList != null && CatalogueListByRingNumberList.Count > 0)
         {
             short ring_No = 0;
             List <CatalogueList> displayList = new List <CatalogueList>();
             CatalogueList        displayItem = new CatalogueList(_connString);
             foreach (CatalogueList row in CatalogueListByRingNumberList)
             {
                 if (row.Ring_No != ring_No && ring_No != 0)
                 {
                     //new ring number
                     CreateDisplayItem(displayItem);
                     displayList.Add(displayItem);
                     displayItem = new CatalogueList(_connString);
                 }
                 //existing ring number
                 displayItem.Ring_No = row.Ring_No;
                 displayItem.Owners.Add(row.Owner);
                 displayItem.Addresses.Add(row.Address);
                 displayItem.Dog_KC_Name           = row.Dog_KC_Name;
                 displayItem.Dog_Breed_Description = row.Dog_Breed_Description;
                 displayItem.Dog_Gender            = row.Dog_Gender;
                 displayItem.Date_Of_Birth         = row.Date_Of_Birth;
                 displayItem.Breeders.Add(row.Breeder);
                 displayItem.Sire = row.Sire;
                 displayItem.Dam  = row.Dam;
                 displayItem.Class_NameList.Add(row.Class_Name);
                 displayItem.BreederIsOwner = row.BreederIsOwner;
                 displayItem.Catalogue      = row.Catalogue;
                 ring_No = row.Ring_No;
             }
             CreateDisplayItem(displayItem);
             displayList.Add(displayItem);
         }
     }
 }
Beispiel #9
0
        protected void CatalogData()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<html><head><style>\r\n");
            sb.Append(".CellBold { font-weight:bold; }\r\n");
            sb.Append(".CellRightBold { text-align:right; font-weight:bold; }\r\n");
            sb.Append("table.CatalogueList td { border-style:none; font-size:60%; vertical-align:top; }\r\n");
            sb.Append(".tableCellWidth1 { width: 6%; }");
            sb.Append(".tableCellWidth2 { width: 41%; }");
            sb.Append(".tableCellWidth3 { width: 28%; }");
            sb.Append(".tableCellWidth4 { width: 8%; }");
            sb.Append(".tableCellWidth5 { width: 17%; }");
            sb.Append("</style></head><body>");
            sb.Append("<div id='divCatalogueList' runat='server'>");
            sb.Append("<h5>ALPHABETICAL LIST OF ALL COMPETITORS FOLLOWS:</h5>");
            CatalogueListByRingNumberList = CatalogueList.GetCatalogueListData(_connString, _showID.ToString());
            if (CatalogueListByRingNumberList != null && CatalogueListByRingNumberList.Count > 0)
            {
                tblCatalogueTable.CssClass = "CatalogueList";
                TableRow  r  = new TableRow();
                TableCell c1 = new TableCell();
                c1.CssClass = "tableCellWidth1";
                r.Cells.Add(c1);
                TableCell c2 = new TableCell();
                c2.CssClass = "tableCellWidth2";
                r.Cells.Add(c2);
                TableCell c3 = new TableCell();
                c3.CssClass = "tableCellWidth3";
                r.Cells.Add(c3);
                TableCell c4 = new TableCell();
                c4.CssClass = "tableCellWidth4";
                r.Cells.Add(c4);
                TableCell c5 = new TableCell();
                c5.CssClass = "tableCellWidth5";
                r.Cells.Add(c5);
                //TableCell c6 = new TableCell();
                //c6.CssClass = "tableCellWidth6";
                //r.Cells.Add(c6);
                //TableCell c7 = new TableCell();
                //c7.CssClass = "tableCellWidth7";
                //r.Cells.Add(c7);
                tblCatalogueTable.Rows.Add(r);
                short ring_No = 0;
                List <CatalogueList> displayList = new List <CatalogueList>();
                CatalogueList        displayItem = new CatalogueList(_connString);
                foreach (CatalogueList row in CatalogueListByRingNumberList)
                {
                    if (row.Ring_No != ring_No && ring_No != 0)
                    {
                        //new ring number
                        CreateDisplayItem(displayItem);
                        displayList.Add(displayItem);
                        displayItem = new CatalogueList(_connString);
                    }
                    //existing ring number
                    displayItem.Ring_No = row.Ring_No;
                    displayItem.Owners.Add(row.Owner);
                    displayItem.Addresses.Add(row.Address);
                    displayItem.Dog_KC_Name           = row.Dog_KC_Name;
                    displayItem.Dog_Breed_Description = row.Dog_Breed_Description;
                    displayItem.Dog_Gender            = row.Dog_Gender;
                    displayItem.Date_Of_Birth         = row.Date_Of_Birth;
                    displayItem.Class_NameList.Add(row.Class_Name);
                    displayItem.Catalogue = row.Catalogue;
                    ring_No = row.Ring_No;
                }
                CreateDisplayItem(displayItem);
                displayList.Add(displayItem);
            }
            StringWriter stringWriter = new StringWriter();

            using (var htmlWriter = new HtmlTextWriter(stringWriter))
            {
                tblCatalogueTable.RenderControl(htmlWriter);
                sb.Append(stringWriter.ToString());
            }
            sb.Append("</div></body></html>");
            wb.DocumentText = sb.ToString();
        }
Beispiel #10
0
        private void CreateDisplayItem(CatalogueList displayItem)
        {
            TableRow  r1   = new TableRow();
            TableCell r1c1 = new TableCell();

            r1c1.CssClass = "CellBold";
            if (displayItem.Catalogue)
            {
                r1c1.Text = "*";
            }
            else
            {
                r1c1.Text = string.Empty;
            }
            r1.Cells.Add(r1c1);
            string ownerList = string.Empty;

            foreach (string owner in displayItem.Owners)
            {
                if (ownerList.IndexOf(owner) == -1)
                {
                    ownerList = string.Format("{0}{1}", ownerList, " & " + owner);
                }
            }
            TableCell r1c2 = new TableCell();

            r1c2.CssClass = "CellBold";
            r1c2.Text     = ownerList.Substring(3);
            r1.Cells.Add(r1c2);
            TableCell r1c3 = new TableCell();

            r1c3.ColumnSpan = 3;
            r1c3.Text       = displayItem.Addresses[0];
            r1.Cells.Add(r1c3);
            if (displayItem.Owners[0] != PreviousOwner)
            {
                tblCatalogueTable.Rows.Add(r1);
            }
            PreviousOwner = displayItem.Owners[0];

            TableRow  r2   = new TableRow();
            TableCell r2c1 = new TableCell();

            r2c1.CssClass = "CellBold";
            r2c1.Text     = displayItem.Ring_No.ToString();
            r2.Cells.Add(r2c1);
            TableCell r2c2 = new TableCell();

            r2c2.CssClass = "CellBold";
            r2c2.Text     = displayItem.Dog_KC_Name;
            r2.Cells.Add(r2c2);
            TableCell r2c3 = new TableCell();

            r2c3.Text = displayItem.Dog_Breed_Description;
            r2.Cells.Add(r2c3);
            TableCell r2c4 = new TableCell();

            r2c4.Text = displayItem.Dog_Gender;
            r2.Cells.Add(r2c4);
            TableCell r2c5 = new TableCell();

            r2c5.Width = 5;
            r2c5.Text  = displayItem.Date_Of_Birth;
            r2.Cells.Add(r2c5);
            tblCatalogueTable.Rows.Add(r2);


            string classList = string.Empty;

            foreach (string className in displayItem.Class_NameList)
            {
                if (!string.IsNullOrEmpty(className))
                {
                    if (classList.IndexOf(className) == -1)
                    {
                        classList = string.Format("{0}{1}", classList, " & " + className);
                        TableRow  r3   = new TableRow();
                        TableCell r3c1 = new TableCell();
                        r3c1.ColumnSpan = 5;
                        r3c1.CssClass   = "CellRightBold";
                        r3c1.Text       = className;
                        r3.Cells.Add(r3c1);
                        tblCatalogueTable.Rows.Add(r3);
                    }
                }
            }
        }
Beispiel #11
0
 void AddDownloadedItems(string text, CatalogueList list)
 {
     JsonUtility.FromJsonOverwrite(text, list);
 }
Beispiel #12
0
    private void CreateDisplayItem(CatalogueList displayItem)
    {
        //TableRow r0 = new TableRow();
        //TableCell r0c0 = new TableCell();
        //r0c0.Text = string.Empty;
        //r0c0.CssClass = "tableCellWidth1";
        //r0.Cells.Add(r0c0);
        //TableCell r0c2 = new TableCell();
        //r0c2.Text = string.Empty;
        //r0c2.CssClass = "tableCellWidth2";
        //r0.Cells.Add(r0c2);
        //TableCell r0c3 = new TableCell();
        //r0c3.Text = string.Empty;
        //r0c3.CssClass = "tableCellWidth3";
        //r0.Cells.Add(r0c3);
        //TableCell r0c4 = new TableCell();
        //r0c4.Text = string.Empty;
        //r0c4.CssClass = "tableCellWidth4";
        //r0.Cells.Add(r0c4);
        //TableCell r0c5 = new TableCell();
        //r0c5.Text = string.Empty;
        //r0c5.CssClass = "tableCellWidth5";
        //r0.Cells.Add(r0c5);
        //TableCell r0c6 = new TableCell();
        //r0c6.Text = string.Empty;
        //r0c6.CssClass = "tableCellWidth6";
        //r0.Cells.Add(r0c6);
        //TableCell r0c7 = new TableCell();
        //r0c7.Text = string.Empty;
        //r0c7.CssClass = "tableCellWidth7";
        //r0.Cells.Add(r0c7);
        //TableCell r0c8 = new TableCell();
        //r0c8.Text = string.Empty;
        ////r0c8.CssClass = "tableCellWidth8";
        //r0.Cells.Add(r0c8);
        //tblCatalogueTable.Rows.Add(r0);

        TableRow  r1   = new TableRow();
        TableCell r1c1 = new TableCell();

        r1c1.CssClass = "CellBold";
        if (displayItem.Catalogue)
        {
            r1c1.Text = "*";
        }
        else
        {
            r1c1.Text = string.Empty;
        }
        r1.Cells.Add(r1c1);
        string ownerList = string.Empty;

        foreach (string owner in displayItem.Owners)
        {
            if (ownerList.IndexOf(owner) == -1)
            {
                ownerList = string.Format("{0}{1}", ownerList, " & " + owner);
            }
        }
        TableCell r1c2 = new TableCell();

        r1c2.ColumnSpan = 2;
        r1c2.CssClass   = "CellBold";
        r1c2.Text       = ownerList.Substring(3);
        r1.Cells.Add(r1c2);
        TableCell r1c3 = new TableCell();

        r1c3.ColumnSpan = 5;
        r1c3.Text       = displayItem.Addresses[0];
        r1.Cells.Add(r1c3);
        if (displayItem.Owners[0] != PreviousOwner)
        {
            tblCatalogueTable.Rows.Add(r1);
        }
        PreviousOwner = displayItem.Owners[0];

        TableRow  r2   = new TableRow();
        TableCell r2c1 = new TableCell();

        r2c1.CssClass = "CellBold";
        r2c1.Text     = displayItem.Ring_No.ToString();
        r2.Cells.Add(r2c1);
        TableCell r2c2 = new TableCell();

        r2c2.CssClass = "CellBold";
        r2c2.Text     = displayItem.Dog_KC_Name;
        r2.Cells.Add(r2c2);
        TableCell r2c3 = new TableCell();

        r2c3.Text = displayItem.Dog_Breed_Description;
        r2.Cells.Add(r2c3);
        TableCell r2c4 = new TableCell();

        r2c4.Text = displayItem.Dog_Gender;
        r2.Cells.Add(r2c4);
        TableCell r2c5 = new TableCell();

        r2c5.Width = 5;
        r2c5.Text  = displayItem.Date_Of_Birth;
        r2.Cells.Add(r2c5);
        string breederList = string.Empty;

        foreach (string breeder in displayItem.Breeders)
        {
            if (breederList.IndexOf(breeder) == -1)
            {
                breederList = string.Format("{0}{1}", breederList, " & " + breeder);
            }
        }
        TableCell r2c6 = new TableCell();

        if (displayItem.BreederIsOwner)
        {
            r2c6.Text = "Owner";
        }
        else
        {
            r2c6.Text = breederList.Substring(3);
        }
        r2.Cells.Add(r2c6);
        TableCell r2c7 = new TableCell();

        r2c7.Text = displayItem.Sire;
        r2.Cells.Add(r2c7);
        TableCell r2c8 = new TableCell();

        r2c8.Text = displayItem.Dam;
        r2.Cells.Add(r2c8);
        tblCatalogueTable.Rows.Add(r2);


        string classList = string.Empty;

        foreach (string className in displayItem.Class_NameList)
        {
            if (!string.IsNullOrEmpty(className))
            {
                if (classList.IndexOf(className) == -1)
                {
                    classList = string.Format("{0}{1}", classList, " & " + className);
                    TableRow  r3   = new TableRow();
                    TableCell r3c1 = new TableCell();
                    r3c1.ColumnSpan = 8;
                    r3c1.CssClass   = "CellRightBold";
                    r3c1.Text       = className;
                    r3.Cells.Add(r3c1);
                    tblCatalogueTable.Rows.Add(r3);
                }
            }
        }
    }