Пример #1
0
        private IEnumerable <T> GetSelectedItemsFromDropdown <T>(MultiSelectDropdown subList, T[] items)
        {
            List <T> ret = new List <T>();

            foreach (int i in subList.value)
            {
                ret.Add(items[i - 1]);
            }
            return(ret);
        }
Пример #2
0
    protected override void ProcessInitialization()
    {
        NotificationSystem.Instance.NotifyProgress(DataMessages.ACTIVITY_LOADING);

        DropBrands    = this.FindAndResolveComponent <Dropdown> ("Brands<Drop>", DisplayObject);
        DropAgency    = this.FindAndResolveComponent <Dropdown> ("Agency<Drop>", DisplayObject);
        DropTipo      = this.FindAndResolveComponent <MultiSelectDropdown> ("TypeActiv<Drop>", DisplayObject);
        DropRegiones  = this.FindAndResolveComponent <MultiSelectDropdown> ("Region<Drop>", DisplayObject);
        DropPlazas    = this.FindAndResolveComponent <MultiSelectDropdown> ("Mall<Drop>", DisplayObject);
        DropCdc       = this.FindAndResolveComponent <MultiSelectDropdown> ("CDC<Drop>", DisplayObject);
        DropCancel    = this.FindAndResolveComponent <Dropdown> ("CancelActiv<Drop>", DisplayObject);
        DropTypeSale  = this.FindAndResolveComponent <Dropdown> ("TypeSale<Drop>", DisplayObject);
        parentProject = this.Find("Assignment<Wrapper>", DisplayObject);
        AssignmentGO  = this.Find("Item 4", DisplayObject);

        projectName = this.FindAndResolveComponent <Text>("ValueName<Text>", DisplayObject);
        dateIni     = this.FindAndResolveComponent <Text>("ValueDateIni<Text>", DisplayObject);
        dateFin     = this.FindAndResolveComponent <Text>("ValueDateEnd<Text>", DisplayObject);
        projectDesc = this.FindAndResolveComponent <Text>("ValueDesc<Text>", DisplayObject);
        totalActiv  = this.FindAndResolveComponent <Text>("ValueTotalActiv<Text>", DisplayObject);
        totalSale   = this.FindAndResolveComponent <Text>("ValueTotalSale<Text>", DisplayObject);
        impact      = this.FindAndResolveComponent <Text>("ValueImpact<Text>", DisplayObject);
        tasting     = this.FindAndResolveComponent <Text>("ValueTasting<Text>", DisplayObject);
        MaxActiv    = this.FindAndResolveComponent <Text>("ValueMaxActiv<Text>", DisplayObject);
        Error       = this.Find("Error<Text>", DisplayObject);
        Error.SetActive(false);

        GenerateRegion = this.FindAndResolveComponent <Button> ("GenerateRegion<Button>", DisplayObject);
        GeneratePlaza  = this.FindAndResolveComponent <Button> ("GeneratePlaza<Button>", DisplayObject);
        GenerateCDC    = this.FindAndResolveComponent <Button> ("GenerateCDC<Button>", DisplayObject);
        SaveButton     = this.FindAndResolveComponent <Button> ("Save<Button>", DisplayObject);

        DropCancel.AddOptions(CancelList);
        DropTypeSale.AddOptions(TipoVentaList);

        AssignmentLayout = AssignmentGO.GetComponent <LayoutElement>();

        String api_url = DataPaths.WS_NEW_PROJECT_FORM_URL;

        Debug.Log(api_url);
        NetClient.OnWebRequestDoneDelegate onWebRequestDone = delegate(string webResponse) {
            NotificationSystem.Instance.Terminate();
            Debug.Log(webResponse);

            try
            {
                JsonData rawData = JsonMapper.ToObject(webResponse);

                if ((string)rawData["status"] == "ok")
                {
                    BrandList.Clear();
                    BrandKeys.Clear();
                    BrandList.Add("-- Selecciona --");
                    BrandKeys.Add("0");
                    foreach (JsonData elem in rawData["data"]["marcas"])
                    {
                        int brandId = (int)elem["id"];
                        BrandList.Add((string)elem["nombre"]);
                        BrandKeys.Add(brandId.ToString());
                    }
                    DropBrands.ClearOptions();
                    DropBrands.RefreshShownValue();
                    DropBrands.AddOptions(BrandList);

                    AgencyList.Clear();
                    AgencyKeys.Clear();
                    AgencyList.Add("-- Selecciona --");
                    AgencyKeys.Add("0");
                    foreach (JsonData elem in rawData["data"]["agencias"])
                    {
                        int AgencyId = (int)elem["id"];
                        AgencyList.Add((string)elem["nombre"]);
                        AgencyKeys.Add(AgencyId.ToString());
                    }
                    DropAgency.ClearOptions();
                    DropAgency.RefreshShownValue();
                    DropAgency.AddOptions(AgencyList);

                    TipoActivList.Clear();
                    TipoActivKeys.Clear();
                    foreach (JsonData elem in rawData["data"]["tipo_activacion"])
                    {
                        int TipoId = (int)elem["id"];
                        TipoActivList.Add(new MultiSelectDropdown.OptionData((string)elem["nombre"]));
                        TipoActivKeys.Add(TipoId);
                    }

                    /*DropTipo.ClearOptions();
                     *                  DropTipo.RefreshShownValue();*/
                    DropTipo.options = (TipoActivList);

                    RegionesList.Clear();
                    RegionesKeys.Clear();
                    foreach (JsonData elem in rawData["data"]["regiones"])
                    {
                        region_id = (int)elem["id"];
                        RegionesList.Add(new MultiSelectDropdown.OptionData((string)elem["nombre"]));
                        RegionesKeys.Add(region_id);
                    }

                    /*DropRegiones.ClearOptions();
                     * DropRegiones.RefreshShownValue();*/
                    DropRegiones.options = (RegionesList);

                    // lleno listas para campos dinámicos
                    foreach (JsonData elem in rawData["data"]["regiones"])
                    {
                        int id = (int)elem["id"];
                        GralRegionesList.Add((string)elem["nombre"]);
                        GralRegionesKeys.Add(id.ToString());
                    }

                    foreach (JsonData elem in rawData["data"]["plazas"])
                    {
                        int id = (int)elem["id"];
                        GralPlazasList.Add((string)elem["nombre"]);
                        GralPlazasKeys.Add(id.ToString());
                    }
                    foreach (JsonData elem in rawData["data"]["cdc"])
                    {
                        int id = (int)elem["id"];
                        if (elem.Keys.Contains("plaza"))
                        {
                            GralCdcList.Add((string)elem["nombre"] + " @ " + (string)elem["plaza"]["nombre"]);
                        }
                        else
                        {
                            GralCdcList.Add((string)elem["nombre"]);
                        }
                        GralCdcKeys.Add(id.ToString());
                    }
                }
                else
                {
                    NotificationSystem.Instance.NotifyMessage(DataMessages.SERVER_LOGIN_FAIL);
                }
            }catch (JsonException e) {
                Debug.LogError("JSON Exception: " + e.Message + "\n" + e.StackTrace);
                throw e;
            }
        };

        NetClient.OnWebRequestFailDelegate onWebRequestFail = delegate
        {
            NotificationSystem.Instance.PromptAction(DataMessages.SERVER_RESPONSE_FAIL, delegate {  }, delegate { NotificationSystem.Instance.Terminate(); });
        };

        //REVISA WEBSERVICE;

        StartCoroutine(NetClient.Instance.MakeWebRequest(api_url, null, onWebRequestDone, onWebRequestFail));

        DropRegiones.onValueChanged.AddListener(delegate {
            NotificationSystem.Instance.NotifyProgress(DataMessages.ACTIVITY_LOADING);

            Debug.Log("Mando ID de región: " + region_id);
            getPlazas(getRegionSelected());
        });

        //Botones para generar asignaciones

        GenerateRegion.onClick.AddListener(delegate {
            NotificationSystem.Instance.NotifyProgress(DataMessages.ACTIVITY_LOADING);
            generateType("region");
            getHeightExpanded(AssignRegList.Count < 1 ? true : false);
            AssignmentLayout.preferredHeight = heightExpanded + 200;
        });
        GeneratePlaza.onClick.AddListener(delegate {
            NotificationSystem.Instance.NotifyProgress(DataMessages.ACTIVITY_LOADING);
            generateType("plaza");
            getHeightExpanded(AssignPlzList.Count < 1 ? true : false);
            AssignmentLayout.preferredHeight = heightExpanded + 200;
        });
        GenerateCDC.onClick.AddListener(delegate {
            NotificationSystem.Instance.NotifyProgress(DataMessages.ACTIVITY_LOADING);
            generateType("cdc");
            getHeightExpanded(AssignCdcList.Count < 1 ? true : false);
            AssignmentLayout.preferredHeight = heightExpanded + 200;
        });
        SaveButton.onClick.AddListener(delegate {
            NotificationSystem.Instance.NotifyProgress(DataMessages.ACTIVITY_LOADING);
            sendFormWS();
        });
    }