Exemple #1
0
 private static int[] _ParseDateDefault(string src, int[] dt)
 {
     int[] dtx = CoCSeason._ParseDate(src);
     dt[0] = (((dt[0] == 0) && (dtx[0] > 0)) ? dtx[0] : dt[0]);
     dt[1] = (((dt[1] == 0) && (dtx[1] > 0)) ? dtx[1] : dt[1]);
     return(dt);
 }
Exemple #2
0
 public static string[] GetSeasonDateString()
 {
     int[] dt = CoCSeason._GetSeasonDate();
     return(new string[] {
         dt[0].ToString(),
         dt[1].ToString()
     });
 }
Exemple #3
0
 public static string GetSeasonDateDB(int idx, string[] cmd)
 {
     int[] dt = CoCSeason._GetDate(idx, cmd);
     return(string.Format(
                Properties.Settings.Default.DBWhereDate,
                dt[0],
                dt[1]
                ));
 }
Exemple #4
0
 private static void _ParseDateContains(string src, char contains, ref int[] dt)
 {
     string[] digits = src.Split(contains);
     if (digits.Length > 0)
     {
         for (int i = 0; i < digits.Length; i++)
         {
             if (digits[i].All(char.IsDigit))
             {
                 dt = CoCSeason._ParseDateDefault(digits[i], dt);
             }
         }
     }
 }
Exemple #5
0
            private static int[] _GetDate(int idx, string[] cmd)
            {
                int[] dt = { 0, 0 };

                if ((cmd.Length - 1) > idx)
                {
                    int max = ((cmd.Length > (idx + 2)) ? (idx + 2) : (idx + 1));
                    for (int i = max; i > idx; i--)
                    {
                        if (string.IsNullOrWhiteSpace(cmd[i]))
                        {
                            continue;
                        }
                        if (cmd[i].All(char.IsDigit))
                        {
                            dt = CoCSeason._ParseDateDefault(cmd[i], dt);
                        }
                        else if (cmd[i].Contains("-"))
                        {
                            CoCSeason._ParseDateContains(cmd[i], '-', ref dt);
                        }
                        else if (cmd[i].Contains("."))
                        {
                            CoCSeason._ParseDateContains(cmd[i], '.', ref dt);
                        }
                        if ((dt[0] > 0) && (dt[1] > 0))
                        {
                            break;
                        }
                    }
                }
                if ((dt[0] == 0) || (dt[1] == 0))
                {
                    int[] dtc = CoCSeason._GetSeasonDate();
                    dt[0] = ((dt[0] > 0) ? dt[0] : dtc[0]);
                    dt[1] = ((dt[1] > 0) ? dt[1] : dtc[1]);
                }
                return(dt);
            }
Exemple #6
0
            /// <summary>
            /// Get Sqlite DB Query string
            /// </summary>
            /// <param name="cmd">array Query string</param>
            /// <param name="cReq">enum ClanTypeReq</param>
            /// <param name="LogError">Log Error <code>Action{string}</code></param>
            /// <returns>DB query syting</returns>
            public static string _GetQueryString(
                string[] cmd,
                ref stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq cReq,
                StringCollection hide,
                Action <string> LogError
                )
            {
                cReq = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.None;
                string query    = String.Empty,
                       playerId = "";

                switch (cmd.Length)
                {
                default:
                case 0:
                case 1:
                {
                    throw new CoCDBException(
                              stCoCAPI.CoCAPI.CoCEnum.ClanFmtReq.fmtClanHelp,
                              string.Format(
                                  Properties.Resources.CoCDBExceptionLength,
                                  "QueryString->begin"
                                  )
                              );
                }

                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                {
                    int idx = 1;
                    if (cmd[1].Equals("setup"))
                    {
                        cReq = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.ServerSetup;
                        return(String.Empty);
                    }
                    else if (cmd[1].Equals("notify"))
                    {
                        cReq = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.None;
                        throw new CoCDBException(
                                  stCoCAPI.CoCAPI.CoCEnum.ClanFmtReq.fmtNone,
                                  CoCDB.thisClass
                                  );
                    }
                    else if ((cmd[1].Equals("info")) || (cmd[1].Equals("clan")))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.Info;
                        query = Properties.Settings.Default.DBSelectClanInfo;
                    }
                    else if (cmd[1].Equals("war"))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.War;
                        query = Properties.Settings.Default.DBSelectClanInfo;
                    }
                    else if (cmd[1].Equals("stat"))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.Statistic;
                        query = Properties.Settings.Default.DBSelectClanInfo;
                    }
                    else if (cmd[1].Equals("desc"))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.Description;
                        query = Properties.Settings.Default.DBSelectClanInfo;
                    }
                    else if (cmd[1].Equals("warlog"))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.WarLog;
                        query = Properties.Settings.Default.DBSelectWarClan;
                    }
                    else if (cmd[1].Equals("warlast"))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.WarLast;
                        query = CreateString.Build(
                            new string[] {
                                Properties.Settings.Default.DBSelectWarClan,
                                Properties.Settings.Default.DBSelectWarLast
                            }, " ",
                            LogError);
                    }
                    else if (cmd[1].Equals("list"))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.List;
                        query = CreateString.Build(
                            new string[] {
                                string.Format(
                                    Properties.Settings.Default.DBSelectMember, 1
                                    ),
                                CoCSeason.GetSeasonDateDB(idx, cmd),
                                CoCDB._GetHideTagSelect(hide),
                                Properties.Settings.Default.DBSelectMemberListOrder
                            }, " ",
                            LogError);
                    }
                    else if (cmd[1].Equals("random"))
                    {
                        cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.Player;
                        query = CreateString.Build(
                            new string[] {
                                string.Format(
                                    Properties.Settings.Default.DBSelectMember, 1
                                    ),
                                CoCSeason.GetSeasonDateDB(idx, cmd),
                                CoCDB._GetHideTagSelect(hide),
                                Properties.Settings.Default.DBSelectMemberRand
                            }, " ",
                            LogError);
                    }
                    else if ((cmd[1].Equals("player")) || (cmd[1].Equals("member")))
                    {
                        if (cmd.Length == 2)
                        {
                            throw new CoCDBException(
                                      stCoCAPI.CoCAPI.CoCEnum.ClanFmtReq.fmtClanPlayerHelp,
                                      string.Format(
                                          Properties.Resources.CoCDBExceptionLength,
                                          "QueryString->player"
                                          )
                                      );
                        }
                        idx++;
                        cReq     = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.Player;
                        playerId = ((cmd[2].StartsWith("#")) ? cmd[2].Substring(1) : cmd[2]);
                        query    = CreateString.Build(
                            new string[] {
                                string.Format(
                                    Properties.Settings.Default.DBSelectMember, 1
                                    ),
                                CoCSeason.GetSeasonDateDB(idx, cmd),
                                CoCDB._GetHideTagSelect(hide),
                                // add
                                string.Format(
                                    Properties.Settings.Default.DBSelectMemberTag,
                                    playerId
                                    )
                            }, " ",
                            LogError);
                    }
                    else if (cmd[1].Equals("donation"))
                    {
                        if (cmd.Length > 2)
                        {
                            if (cmd[2].Equals("send"))
                            {
                                cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.DonationSend;
                                query = CreateString.Build(
                                    new string[] {
                                        Properties.Settings.Default.DBSelectDonation,
                                        CoCSeason.GetSeasonDateDB(idx, cmd),
                                        CoCDB._GetHideTagSelect(hide),
                                        Properties.Settings.Default.DBSelectDonationSendOrder
                                    }, " ",
                                    LogError);
                                idx++;
                            }
                            else if (cmd[2].Equals("receive"))
                            {
                                cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.DonationReceive;
                                query = CreateString.Build(
                                    new string[] {
                                        Properties.Settings.Default.DBSelectDonation,
                                        CoCSeason.GetSeasonDateDB(idx, cmd),
                                        CoCDB._GetHideTagSelect(hide),
                                        Properties.Settings.Default.DBSelectDonationReceiveOrder
                                    }, " ",
                                    LogError);
                                idx++;
                            }
                            else if ((cmd[2].Equals("ratio")) || (cmd[2].Equals("rate")))
                            {
                                cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.DonationRatio;
                                query = CreateString.Build(
                                    new string[] {
                                        Properties.Settings.Default.DBSelectDonation,
                                        Properties.Settings.Default.DBSelectDonationRatio,
                                        CoCSeason.GetSeasonDateDB(idx, cmd),
                                        CoCDB._GetHideTagSelect(hide),
                                        Properties.Settings.Default.DBSelectDonationRatioOrder
                                    }, " ",
                                    LogError);
                                idx++;
                            }
                            else if (cmd[2].Equals("total"))
                            {
                                cReq  = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.DonationTotal;
                                query = CreateString.Build(
                                    new string[] {
                                        Properties.Settings.Default.DBSelectDonationTotal,
                                        CoCSeason.GetSeasonDateDB(idx, cmd)
                                    }, " ",
                                    LogError);
                                idx++;
                            }
                        }
                        else
                        {
                            cReq = stCoCAPI.CoCAPI.CoCEnum.ClanTypeReq.DonationSend;
                            throw new CoCDBException(
                                      stCoCAPI.CoCAPI.CoCEnum.ClanFmtReq.fmtDonation,
                                      CoCDB.thisClass
                                      );
                        }
                    }
                    else
                    {
                        return(String.Empty);
                    }
                    return(query);
                }
                }
            }
Exemple #7
0
 public static int[] GetSeasonDateInt()
 {
     return(CoCSeason._GetSeasonDate());
 }