Пример #1
0
    public static void Update_Data(string user = "", string psswd = "", bool load = true, bool save = false, Action On_Success = null, Action OnFailure = null)
    {
        Scroll_Updater.User_Loaded = 0;

        if (user == "")
        {
            user  = User_Info.Username;
            psswd = Psswd;
        }

        string[] field_names  = { "REQUEST_TYPE", "username", "psswd" };
        string[] field_values = { "get_user_data", user, psswd };
        Psswd = psswd;

        Http_Client.Send_Post(
            field_names,
            field_values,
            (string response, Handler_Type type) =>
        {
            Scroll_Updater.User_Loaded = 2;
            Parse_User_Data(response, load, save);
        },
            Handler_Type.none,
            false
            );

        On_Success_temp = On_Success;
        OnFailure_temp  = OnFailure;
    }
Пример #2
0
 public void Update_App()
 {
     string[] field_names  = { "REQUEST_TYPE" };
     string[] field_values = { "get_version" };
     Http_Client.Send_Post(field_names, field_values, Handle_Version_Response);
     Loading_Screen.Set_Active(true);
 }
Пример #3
0
    protected virtual void Initialize()
    {
        Title.text = news_entry.Title;
        string month = news_entry.Creation_time.ToString("MMMM").ToUpper().Substring(0, 3);

        Creation_time.text = month + " " + news_entry.Creation_time.Day.ToString() + " de " + news_entry.Creation_time.Year;
        Detail.text        = news_entry.Details;

        if (news_entry.Imgs.Count > 0 && news_entry.Imgs[0] != "empty")
        {
            foreach (string image in news_entry.Imgs)
            {
                Http_Client.Download_Image(image, transform, Handle_Img_Response);
            }
        }

        Canvas.ForceUpdateCanvases();
        GetComponentInChildren <VerticalLayoutGroup>().SetLayoutVertical();

        if (!news_entry.Seen)
        {
            string[] field_names  = { "REQUEST_TYPE", "news_id", "id" };
            string[] field_values = { "set_news_seen", news_entry.Id.ToString(), User.User_Info.Id.ToString() };
            Http_Client.Send_Post(field_names, field_values, (string response, Handler_Type type) => { }, Handler_Type.none);
            news_entry.Seen = true;
            User.User_Info.News_Data.Add(news_entry.Id);
            Database_Handler.Update_Unread(Handler_Type.news);
        }
    }
Пример #4
0
    public void Save_Rhythm()
    {
        User.User_Info.Username = "******";
        User.Psswd = "1234567891011121";

        Rhythm_Data rhythm = Rhythms[0];

        string[] field_names = { "REQUEST_TYPE",
                                 "rhythm_id",
                                 "rhythm_name",
                                 "rhythm_details",
                                 "rhythm_ppm",
                                 "rhythm_date_update",
                                 "rhythm_date_creation",
                                 "rhythm_author_id",
                                 "rhythm_data" };

        string[] field_values = { "set_rhythms",
                                  rhythm.Id.ToString(),
                                  rhythm.Name,
                                  rhythm.Description,
                                  rhythm.PPM.ToString(),
                                  Utils.Get_String_SQL(rhythm.Last_Update),
                                  Utils.Get_String_SQL(rhythm.Creation),
                                  rhythm.Author_id.ToString(),
                                  rhythm.Get_Sounds_Json() };

        Http_Client.Send_Post(field_names, field_values, Handle_Save_Response);
    }
Пример #5
0
    // ______________________________________
    //
    // 5. RHYTHM LOADING / SAVING.
    // ______________________________________
    //


    public void Load_Rhythm()
    {
        User.User_Info.Username = "******";
        User.Psswd = "1234567891011121";

        string[] field_names  = { "REQUEST_TYPE" };
        string[] field_values = { "get_rhythms" };
        Http_Client.Send_Post(field_names, field_values, Handle_Data_Response);
    }
Пример #6
0
    public void Delete()
    {
        string[] field_names = { "REQUEST_TYPE", "data_id" };
        string[] field_values;

        if (Data.GetType().Equals(typeof(Poll)))
        {
            field_values = new string[] { "delete_poll", Data.Id.ToString() }
        }
        ;

        else if (Data.GetType().Equals(typeof(Calendar_Event)))
        {
            field_values = new string[] { "delete_event", Data.Id.ToString() }
        }
        ;

        else if (Data.GetType().Equals(typeof(News_Entry)))
        {
            field_values = new string[] { "delete_news", Data.Id.ToString() }
        }
        ;

        else
        {
            return;
        }


        Notification_UI_Pop.Show_Message(
            "Confirmar eliminación",
            "Seguro que quieres eliminar este archivo?",
            () =>
        {
            Type type = Data.Database_Handler_Type();
            List <Data_struct> data_list = Database_Handler.Data_List_Get(type);
            data_list.Remove(data_list.Find(a => a.Id == Data.Id));
            Database_Handler.Data_List_Set(type, data_list);

            Http_Client.Send_Post(
                field_names,
                field_values,
                Handle_Delete_Response
                );

            Menu.Singleton.Load_Scene_Menu_Item(Prev);
        },
            "Eliminar",
            "Cancelar");
    }
Пример #7
0
    // ______________________________________
    //
    // VOTE ON EVENTS.
    // ______________________________________
    //


    /// <summary>
    /// Updates user's choice of vote locally on the device and remotely on the server.
    /// </summary>
    public void Vote(int vote_type)
    {
        if (!initialized)
        {
            return;
        }

        temp_vote = vote_type;

        string[] field_names  = { "REQUEST_TYPE", "event_id", "event_response" };
        string[] field_values = { "set_event_vote", calendar_event.Id.ToString(), vote_type.ToString() };
        Http_Client.Send_Post(field_names, field_values, Handle_Event_Response);

        Set_Interactable(false);
    }
 /// <summary>
 /// Loads a database from the server.
 /// </summary>
 /// <param name="type">The child class type of Database_Handler that should load and parse the server's database.</param>
 public static void Load_Data_Server(Handler_Type type)
 {
     string[] field_names  = { "REQUEST_TYPE" };
     string[] field_values = { "get_" + type.ToString() };
     Http_Client.Send_Post(field_names, field_values, Handle_Data_Response, type);
 }
Пример #9
0
    public void Save()
    {
        List <string> field_names = new List <string>()
        {
            "REQUEST_TYPE",
        };

        List <string> field_values = new List <string>()
        {
            "",
            Data.Id.ToString(),
            Encryption.Encrypt(Data.Title),
            Encryption.Encrypt(Data.Details),
            Data.Author_Id.ToString(),
            Data.Privacy.ToString()
        };

        if (Data.GetType().Equals(typeof(Poll)))
        {
            Poll data = (Poll)Data;
            field_names.AddRange(new List <string>()
            {
                "poll_id",
                "poll_name",
                "poll_details",
                "poll_author_id",
                "poll_privacy",
                "poll_date_creation",
                "poll_date_deadline",
                "poll_options"
            });

            field_values[0] = "set_poll";
            field_values.AddRange(new List <string>()
            {
                Utils.Get_String_SQL(data.Creation_Time),
                Utils.Get_String_SQL(data.Date_Deadline),
                Utils.List_To_String(data.Vote_Types)
            });
        }

        else if (Data.GetType().Equals(typeof(Calendar_Event)))
        {
            Calendar_Event data = (Calendar_Event)Data;
            field_names.AddRange(new List <string>()
            {
                "event_id",
                "event_name",
                "event_details",
                "event_author_id",
                "event_privacy",
                "event_location_event",
                "event_location_meeting",
                "event_date_event",
                "event_date_meeting",
                "event_date_deadline",
                "event_transportation",
                "event_cash",
                "event_food"
            });

            field_values[0] = "set_event";
            field_values.AddRange(new List <string>()
            {
                Encryption.Encrypt(data.Location_Event),
                Encryption.Encrypt(data.Location_Meeting),
                Utils.Get_String_SQL(data.Date_Event),
                Utils.Get_String_SQL(data.Date_Meeting),
                Utils.Get_String_SQL(data.Date_Deadline),
                Encryption.Encrypt(data.Transportation),
                Encryption.Encrypt(data.Cash),
                Encryption.Encrypt(data.Food)
            });
        }

        else if (Data.GetType().Equals(typeof(News_Entry)))
        {
            News_Entry data = (News_Entry)Data;
            field_names.AddRange(new List <string>()
            {
                "news_id",
                "news_name",
                "news_details",
                "news_author_id",
                "news_privacy",
                "news_date_creation",
                "news_images"
            });

            field_values[0] = "set_news";
            field_values.AddRange(new List <string>()
            {
                Utils.Get_String_SQL(data.Creation_time),
                Encryption.Encrypt(Utils.List_To_String(data.Imgs))
            });
        }

        else
        {
            return;
        }

        Database_Handler.Selected_Data = Data;

        if (Data.Id == 0)
        {
            Database_Handler.Data_List_Add(Data.Database_Handler_Type(), Data);
        }

        Http_Client.Send_Post(
            field_names.ToArray(),
            field_values.ToArray(),
            Handle_Save_Response
            );

        Save_Button.interactable = false;
    }