示例#1
0
        private void Hire(CafeInfo cafe)
        {
            try
            {
                SetMessageLn("开始雇员...");

                if (cafe.Employees.Count >= Task.MaxEmployees)
                {
                    SetMessage(string.Format("已有{0}位员工,跳过", cafe.Employees.Count));
                    return;
                }

                int count = cafe.Employees.Count;

                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_myemployees.php?verify={0}&cafeid={1}&uid={2}&start=0&rand=0.7985394787974656", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, CurrentAccount.UserId));
                string content2 = "";
                int num;                
                bool bneeds = false;
                bool bhired = false;

                if (JsonHelper.GetMid(content, "<role>emptyemp", "</role>") == null)
                    content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_myemployees.php?verify={0}&cafeid={1}&uid={2}&start=6&rand=0.7985394787974656", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, CurrentAccount.UserId));

                for (string pos = JsonHelper.GetMid(content, "<role>emptyemp", "</role>", out num); pos != null; pos = JsonHelper.GetMid(content, "<role>emptyemp", "</role>", out num))
                {
                    bneeds = true;
                    bhired = false;
                    //先去雇佣白名单中的好友
                    SetMessageLn("先雇佣白名单中的好友:");
                    int num2 = 0;
                    foreach (int uid in Operation.HireWhiteList)
                    {
                        try
                        {
                            SetMessageLn(string.Format("#{0}{1}", ++num2, base.GetFriendNameById(uid)) + "=>");

                            if (Operation.HireBlackList.Contains(uid))
                            {
                                SetMessage(base.GetFriendNameById(uid) + "在雇佣黑名单中,跳过");
                                continue;
                            }

                            content2 = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_employ.php?verify={0}&cafeid={1}&touid={2}&rand=0.6188818383961916", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, uid));
                            if (GetHireFeedback(content2))
                            {
                                count++;
                                Operation.HireWhiteList.Remove(uid);
                                bhired = true;
                                break;
                            }
                        }
                        catch (ThreadAbortException)
                        {
                            throw;
                        }
                        catch (ThreadInterruptedException)
                        {
                            throw;
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Write("GameCafe.Hire(HireWhiteList)", GetFriendNameById(uid), ex, LogSeverity.Error);
                            continue;
                        }
                    }

                    if (count >= Task.MaxEmployees)
                    {
                        SetMessageLn(string.Format("已有{0}位员工,停止雇佣", count));
                        return;
                    }

                    if (Operation.HireAll && !bhired)
                    {
                        if (this._hirableFriendsList == null || this._hirableFriendsList.Count == 0)
                            ReadHirableFriends(cafe, false);

                        //其他好友
                        num2 = 0;
                        SetMessageLn("开始去雇佣其他好友:");
                        foreach (FriendInfo friend in this._hirableFriendsList)
                        {
                            try
                            {
                                if (Operation.HireWhiteList.Contains(friend.Id) || friend.Id.ToString() == CurrentAccount.UserId)
                                    continue;

                                SetMessageLn(string.Format("#{0}{1}", ++num2, friend.Name + "=>"));
                                if (Operation.HireBlackList.Contains(friend.Id))
                                {
                                    SetMessage(friend.Name + "在雇佣黑名单中,跳过");
                                    continue;
                                }

                                content2 = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_employ.php?verify={0}&cafeid={1}&touid={2}&rand=0.6188818383961916", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, friend.Id));
                                if (GetHireFeedback(content2))
                                {
                                    count++;
                                    this._hirableFriendsList.Remove(friend);
                                    break;
                                }
                            }
                            catch (ThreadAbortException)
                            {
                                throw;
                            }
                            catch (ThreadInterruptedException)
                            {
                                throw;
                            }
                            catch (Exception ex)
                            {
                                LogHelper.Write("GameCafe.Hire(HireAll)", friend.Name, ex, LogSeverity.Error);
                                continue;
                            }
                        }
                    }
                    if (count >= Task.MaxEmployees)
                    {
                        SetMessageLn(string.Format("已有{0}位员工,停止雇佣", count));
                        return;
                    }
                    content = content.Substring(num);
                }
                if (bneeds == false)
                    SetMessage("不需要雇员");
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameCafe.Hire", ex, LogSeverity.Error);
                SetMessage("雇员失败!错误:" + ex.Message);
            }
        }
示例#2
0
        private void BoxCleanCook(string uid, CafeInfo cafe)
        {
            try
            {
                SetMessageLn("开始烹饪...");

                _tomatoexchangable = true;
                _medlarexchangable = true;
                _crabexchangable = true;
                _pineappleexchangable = true;

                int num = 0;
                foreach (CookingInfo cooking in cafe.Cookings)
                {
                    if (!(cooking.Stage == 2 || cooking.Stage == -1 || cooking.Stage == -98 || cooking.Stage == 0 || cooking.Stage == -2 || cooking.Stage == -3))
                        continue;

                    SetMessageLn(string.Format("第{0}个炉子:{1}", ++num, cooking.Name));

                    if (cooking.Stage == 2)
                    {
                        SetMessage(" 可以装盘:");

                        if (Task.BoxClean)
                        {
                            if (IsChefAvailable(cafe))
                            {
                                HH.DelayedTime = Constants.DELAY_1SECONDS;
                                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dish2counter.php?verify={0}&cafeid={1}&uid={2}&orderid={3}&auto=1&rand=0.48554128454998136", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, uid, cooking.OrderId));
                                if (GetCleanFeedback(content))
                                {
                                    content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_stoveclean.php?verify={0}&cafeid={1}&orderid={2}&rand=0.9596593934111297", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, cooking.OrderId));
                                    if (GetCleanFeedback(content))
                                    {
                                        cooking.Stage = -98;
                                        cafe.ChefMana--;
                                    }
                                }
                            }
                            else
                            {
                                HH.DelayedTime = Constants.DELAY_4SECONDS;
                                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dish2counter.php?verify={0}&cafeid={1}&orderid={2}&rand=0.06428298819810152", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, cooking.OrderId));
                                if (GetCleanFeedback(content))
                                {
                                    cooking.Stage = -1;
                                }
                            }
                        }
                    }
                    //<stage>-3</stage> 徐振亚</font> 看到莲藕炖排骨快腐坏了,帮你移至了餐台
                    //<stage>-2</stage> <dirttips><font color='#336699'>庄荣-johnny</font> 看到莲藕炖排骨快腐坏了,给你1320元收购了食物</dirttips> 
                    if (cooking.Stage == -1 || cooking.Stage == -2 || cooking.Stage == -3)
                    {
                        SetMessage(" 需要清洁:");

                        if (Task.BoxClean)
                        {
                            if (IsChefAvailable(cafe))
                            {
                                HH.DelayedTime = Constants.DELAY_1SECONDS;
                                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_stoveclean.php?verify={0}&cafeid={1}&orderid={2}&rand=0.9596593934111297", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, cooking.OrderId));
                                if (GetCleanFeedback(content))
                                {
                                    cooking.Stage = -98;
                                    cafe.ChefMana--;
                                }
                            }
                            else
                            {
                                HH.DelayedTime = Constants.DELAY_4SECONDS;
                                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_stoveclean.php?verify={0}&cafeid={1}&orderid={2}&rand=0.9596593934111297", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, cooking.OrderId));
                                if (GetCleanFeedback(content))
                                    cooking.Stage = -98;
                            }
                        }
                    }

                    if (cooking.Stage == -98 || cooking.Stage == 0)
                    {
                        SetMessage(" 可以炒菜:");
                        if (!Task.Cook)
                            continue;

                        if (Task.CookTomatoFirst && _tomatoexchangable)
                        {
                            SetMessage(" 菜肴:番茄炒蛋 兑换:");
                            //http://www.kaixin001.com/cafe/api_dishmaterials.php?verify=6209093_1136_6209093_1266493649_87f00011aa9971038dfd4df615ec809d&dishid=1
                            HH.DelayedTime = Constants.DELAY_1SECONDS;
                            HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dishmaterials.php?verify={0}&dishid=1", DataConvert.GetEncodeData(this._verifyCode)));
                            if (CookTheDish(cafe, cooking, 1))
                                continue;
                        }

                        if (Task.CookMedlarFirst && _medlarexchangable)
                        {
                            SetMessage(" 菜肴:枸杞银耳羹 兑换:");
                            HH.DelayedTime = Constants.DELAY_1SECONDS;
                            HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dishmaterials.php?verify={0}&dishid=60", DataConvert.GetEncodeData(this._verifyCode)));
                            if (CookTheDish(cafe, cooking, 60))
                                continue;
                        }

                        if (Task.CookCrabFirst && _crabexchangable)
                        {
                            SetMessage(" 菜肴:清蒸大闸蟹 兑换:");
                            HH.DelayedTime = Constants.DELAY_1SECONDS;
                            HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dishmaterials.php?verify={0}&dishid=61", DataConvert.GetEncodeData(this._verifyCode)));
                            if (CookTheDish(cafe, cooking, 61))
                                continue;
                        }

                        if (Task.CookPineappleFirst && _pineappleexchangable && cafe.Grade >= 19)
                        {
                            SetMessage(" 菜肴:菠萝古老肉 兑换:");
                            //http://www.kaixin001.com/cafe/api_dishmaterials.php?verify=6209093_1136_6209093_1266493649_87f00011aa9971038dfd4df615ec809d&dishid=1
                            HH.DelayedTime = Constants.DELAY_1SECONDS;
                            HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dishmaterials.php?verify={0}&dishid=15", DataConvert.GetEncodeData(this._verifyCode)));
                            if (CookTheDish(cafe, cooking, 15))
                                continue;
                        }

                        if (IsChefAvailable(cafe))
                            SetMessage(string.Format(" 菜肴:{0} ", GetDishNameById(Task.CookDishId)));
                        else
                            SetMessage(string.Format(" 菜肴:{0} 步骤{1}->", GetDishNameById(Task.CookDishId), cooking.Step));

                        if (Task.CookLowCash)
                        {
                            if (cafe.Cash < Task.CookLowCashLimit)
                            {
                                SetMessage(string.Format("现金{0}已低于{1},停止炒菜。", cafe.Cash, Task.CookLowCashLimit));
                                continue;
                            }
                        }

                        CookTheDish(cafe, cooking, Task.CookDishId);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameCafe.BoxCleanCook", ex, LogSeverity.Error);
                SetMessage("烹饪失败!错误:" + ex.Message);
            }
        }
示例#3
0
        private bool CookTheDish(CafeInfo cafe, CookingInfo cooking, int dishid)
        {
            int currentstep = 0;
            int totalsteps = 0;
            string content = "";

            if (IsChefAvailable(cafe))
            {
                HH.DelayedTime = Constants.DELAY_2SECONDS;
                content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_cooking.php?verify={0}&auto=1&cafeid={1}&orderid={2}&cafepp=2092500&dishid={3}&flashid={4}&rand=0.6033724816516042", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, cooking.OrderId, dishid, this._flashid));
                if (GetCookFeedback(content, ref currentstep, ref totalsteps))
                {
                    cooking.Stage = 1;
                    cafe.ChefMana--;
                    return true;
                }                
            }
            else
            {
                HH.DelayedTime = Constants.DELAY_2SECONDS;
                content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_cooking.php?verify={0}&cafeid={1}&orderid={2}&dishid={3}&rand=0.36006107507273555", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, cooking.OrderId, dishid));
                if (GetCookFeedback(content, ref currentstep, ref totalsteps))
                {
                    for (int ix = currentstep; ix < totalsteps; ix++)
                    {
                        SetMessage(string.Format("步骤{0}->", ix + 1));
                        HH.DelayedTime = Constants.DELAY_2SECONDS;
                        content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_cooking.php?verify={0}&cafeid={1}&orderid={2}&dishid={3}&rand=0.36006107507273555", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, cooking.OrderId, dishid));
                        int currentstep2 = 0;
                        int totalsteps2 = 0;
                        if (!GetCookFeedback(content, ref currentstep2, ref totalsteps2))
                        {
                            cooking.Stage = 0;
                            return true;
                        }
                    }
                    cooking.Stage = 1;
                    return true;
                }                
            }

            if (content.Contains("你目前的级别不能烹饪这道菜") || content.Contains("兑换失败"))
            {
                if (dishid == 1)
                    this._tomatoexchangable = false;
                if (dishid == 60)
                    this._medlarexchangable = false;
                if (dishid == 61)
                    this._crabexchangable = false;
                if (dishid == 15)
                    this._pineappleexchangable = false;
            }

            return false;
        }
示例#4
0
        private void Majia(CafeInfo cafe)
        {
            try
            {
                SetMessageLn("开始马甲...");
                //<?xml version="1.0" encoding="UTF-8" ?>
                //<data><ret>succ</ret><err>0</err><x>3</x><y>10</y><direct>1</direct><ui>decor.stove0</ui><directional>0</directional><tkey>stove</tkey><account><cash>82161</cash></account><addcash>-600</addcash><orderid>851729733</orderid><msg>璐拱鐗╁搧鎴愬姛</msg></data>

                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_buygoods.php?verify={0}&cafeid={1}&goodsid=256&x=3&y=10&direct=1&r=0.5628602504730225", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId));
                SetMessageLn(JsonHelper.FiltrateHtmlTags(JsonHelper.GetMid(content, "<msg>", "</msg>")));
                //SetMessageLn(content);

                content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_buygoods.php?verify={0}&cafeid={1}&goodsid=256&x=5&y=10&direct=1&r=0.5628602504730225", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId));
                SetMessageLn(JsonHelper.FiltrateHtmlTags(JsonHelper.GetMid(content, "<msg>", "</msg>")));
                //SetMessageLn(content);

                content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_buygoods.php?verify={0}&cafeid={1}&goodsid=256&x=7&y=10&direct=1&r=0.5628602504730225", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId));
                SetMessageLn(JsonHelper.FiltrateHtmlTags(JsonHelper.GetMid(content, "<msg>", "</msg>")));
                //SetMessageLn(content);

                content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_buygoods.php?verify={0}&cafeid={1}&goodsid=256&x=2&y=9&direct=1&r=0.5628602504730225", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId));
                SetMessageLn(JsonHelper.FiltrateHtmlTags(JsonHelper.GetMid(content, "<msg>", "</msg>")));
                //SetMessageLn(content);
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameCafe.Majia", ex, LogSeverity.Error);
                SetMessage("马甲失败!错误:" + ex.Message);
            }
        }
示例#5
0
 private bool IsChefAvailable(CafeInfo cafe)
 {
     //法国大厨
     if (cafe.Chef && cafe.ChefMana > 0 && !string.IsNullOrEmpty(this._flashid))
         return true;
     else
         return false;
 }
示例#6
0
        public void ReadHirableFriends(CafeInfo cafe, bool printMessage)
        {
            if (printMessage)
                SetMessage("读取可以雇佣的好友信息...");
            this._hirableFriendsList.Clear();
            string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_notemployees.php?verify={0}&cafeid={1}&start=0&text=&rand=0.7530548870563507", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId));
            this._hirableFriendsList = ConfigCtrl.GetEmptyEmployees(content);
            if (this._hirableFriendsList == null || this._hirableFriendsList.Count == 0)
                return;
            int totalcount = JsonHelper.GetMidInteger(content, "<data><total>", "</total>");
            int offset = JsonHelper.GetMidInteger(content, "</start><num>", "</num>");
            int page = offset;
            do
            {
                HH.DelayedTime = Constants.DELAY_1SECONDS;
                content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_notemployees.php?verify={0}&cafeid={1}&start={2}&text=&rand=0.7530548870563507", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, page));
                Collection<FriendInfo> employees = new Collection<FriendInfo>();
                employees = ConfigCtrl.GetEmptyEmployees(content);
                if (employees == null || employees.Count == 0)
                    break;
                else
                {
                    foreach (FriendInfo item in employees)
                    {
                        FriendInfo employee = new FriendInfo();
                        employee.Clone(item);
                        this._hirableFriendsList.Add(employee);
                    }
                    page += offset;
                }
            }
            while (true);
            this._hirableFriendsList = SortEmployeeByPower(this._hirableFriendsList);
            if (printMessage)
            {
                foreach (FriendInfo friend in this._hirableFriendsList)
                {
                    SetMessageLn(friend.Name + "(" + friend.Power.ToString() + ")");
                }
            }

            if (printMessage)
                SetMessageLn("完成读取!");
        }
示例#7
0
        private void SellFood(string uid, CafeInfo cafe)
        {
            try
            {
                SetMessageLn("开始出售食物...");

                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_mygranary.php?verify={0}&page=0&type=dish&cafeid={1}&r=0.25149386934936047", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId));

                if (content.IndexOf("<goods>") <= -1)
                {
                    SetMessage("仓库里没有任何食物,无需出售");
                    return;
                }

                content = JsonHelper.GetMid(content, "<goods>", "</goods>");
                int index = 0;
                int num;
                int id = 0;
                int count = 0;
                int type = 0;
                string name = "";
                decimal currentprice = 0;
                string content2 = "";
                DishInfo dish;
                for (string pos = JsonHelper.GetMid(content, "<item>", "</item>", out num); pos != null; pos = JsonHelper.GetMid(content, "<item>", "</item>", out num))
                {
                    content = content.Substring(num);
                    id = JsonHelper.GetMidInteger(pos, "<id>", "</id>");
                    count = JsonHelper.GetMidInteger(pos, "<num>", "</num>");
                    name = JsonHelper.GetMid(pos, "<name>", "</name>");
                    type = JsonHelper.GetMidInteger(pos, "<type>", "</type>");

                    SetMessageLn(string.Format("#{0} {1} 数量:{2} ", ++index, name, count));
                    if (Task.SellFoodByRefPrice)
                    {
                        dish = GetTransactionDishById(id);
                        if (dish == null)
                        {
                            SetMessage("在交易表中没有找到该菜肴,跳过");
                            continue;
                        }
                        HH.DelayedTime = Constants.DELAY_1SECONDS;
                        content2 = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_tradeinfo.php?verify={0}&cafeid={1}&uid={2}&dishid={3}&type={4}&r=0.3238336769863963", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, uid, id, type));
                        currentprice = DataConvert.GetDecimal(JsonHelper.GetMidLast(content2, "<item><price>", "</price><dtime>"));
                        if (currentprice >= dish.SellPrice)
                        {
                            SetMessage(string.Format("当前价格{0}>=出售价格{1},尝试出售...", currentprice, dish.SellPrice));
                            content2 = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_salegoods.php?verify={0}&id={1}&type={2}&num={3}&r=0.6677296073175967", DataConvert.GetEncodeData(this._verifyCode), id, type, count));
                            GetSellFeedback(content2);
                        }
                        else
                        {
                            SetMessage(string.Format("当前价格{0}<出售价格{1},跳过", currentprice, dish.SellPrice));                            
                        }
                    }
                    else
                    {
                        SetMessage("忽略当前价格,尝试出售...");
                        content2 = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_salegoods.php?verify={0}&id={1}&type={2}&num={3}&r=0.6677296073175967", DataConvert.GetEncodeData(this._verifyCode), id, type, count));
                        GetSellFeedback(content2);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameCafe.PresentFood", ex, LogSeverity.Error);
                SetMessage("赠送食物失败!错误:" + ex.Message);
            }
        }
示例#8
0
        private void PurchaseFood(CafeInfo cafe)
        {
            try
            {
                SetMessageLn("开始收购食物...");

                if (cafe.Grade < 30)
                {
                    SetMessage("等级未到30级,无法收购。");
                    return;
                }
                _purchaseblocked = false;

                //先去收购白名单中的好友
                SetMessageLn("先收购白名单中好友的食物:");
                int num = 0;
                foreach (int uid in Operation.PurchaseWhiteList)
                {
                    try
                    {
                        SetMessageLn(string.Format("#{0}{1}", ++num, base.GetFriendNameById(uid)) + "=>");

                        if (Operation.PurchaseBlackList.Contains(uid))
                        {
                            SetMessage(base.GetFriendNameById(uid) + "在收购黑名单中,跳过");
                            continue;
                        }

                        PurchaseTheCafe(uid.ToString());
                        if (_purchaseblocked)
                            break;
                    }
                    catch (ThreadAbortException)
                    {
                        throw;
                    }
                    catch (ThreadInterruptedException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Write("GameCafe.PurchaseFood(PurchaseWhiteList)", GetFriendNameById(uid), ex, LogSeverity.Error);
                        continue;
                    }
                }

                if (Operation.PurchaseAll)
                {
                    //其他好友
                    num = 0;
                    SetMessageLn("开始去收购其他好友的食物:");
                    foreach (FriendInfo friend in this._allCafeFriendsList)
                    {
                        try
                        {
                            if (friend.Food == false)
                                continue;

                            if (Operation.PurchaseWhiteList.Contains(friend.Id) || friend.Id.ToString() == CurrentAccount.UserId)
                                continue;

                            SetMessageLn(string.Format("#{0}{1}", ++num, friend.Name + "=>"));
                            if (Operation.PurchaseBlackList.Contains(friend.Id))
                            {
                                SetMessage(friend.Name + "在收购黑名单中,跳过");
                                continue;
                            }
                            PurchaseTheCafe(friend.Id.ToString());
                            if (_purchaseblocked)
                                break;
                        }
                        catch (ThreadAbortException)
                        {
                            throw;
                        }
                        catch (ThreadInterruptedException)
                        {
                            throw;
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Write("GameCafe.PurchaseFood(PurchaseAll)", friend.Name, ex, LogSeverity.Error);
                            continue;
                        }
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameCafe.PurchaseFood", ex, LogSeverity.Error);
                SetMessage("收购食物失败!错误:" + ex.Message);
            }
        }
示例#9
0
        private void PresentFood(string uid, CafeInfo cafe)
        {
            try
            {
                SetMessageLn("开始赠送食物...");

                if (Operation.PresentFoodId == 0)
                {
                    SetMessage("没有设定赠送的对象,无法赠送");
                    return;
                }
                if (!IsAlreadyMyFriend(DataConvert.GetString(Operation.PresentFoodId)))
                {
                    SetMessage(DataConvert.GetString(Operation.PresentFoodId) + "不是你的好友,无法赠送");
                    return;
                }

                if (Task.PresentLowCash)
                {
                    if (cafe.Cash < Task.PresentLowCashLimit)
                    {
                        SetMessage(string.Format("现金{0}已低于{1},停止赠送。", cafe.Cash, Task.PresentLowCashLimit));
                        return;
                    }
                }

                if (Task.PresentFoodLowCount)
                {
                    int foodcount = GetFoodCount(cafe.DinnerTables);
                    if (foodcount < Task.PresentFoodLowCountLimit)
                    {
                        SetMessage(string.Format("餐台上的食物种类数{0}已低于{1},停止赠送。", foodcount, Task.PresentFoodLowCountLimit));
                        return;
                    }
                }

                if (Task.PresentFoodByCount)
                {
                    cafe.DinnerTables = SortDinnerTableByNum(cafe.DinnerTables);
                    foreach (DinnerTableInfo dinnertable in cafe.DinnerTables)
                    {
                        if (Task.PresentForbiddenFoodList.Contains(dinnertable.DishId))
                        {
                            SetMessageLn(string.Format("{0}在禁止赠送列表中,跳过 ", dinnertable.Name));
                            continue;
                        }

                        if (dinnertable.Num > 0)
                        {
                            long presentcount = dinnertable.Num * Task.PresentFoodRatio / 100;
                            if (presentcount > 0)
                            {
                                SetMessageLn(string.Format("尝试向{0}赠送{1}*{2}%={3}盘{4}...", base.GetFriendNameById(Operation.PresentFoodId),dinnertable.Num, Task.PresentFoodRatio, presentcount, dinnertable.Name));
                                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dishact.php?verify={0}&cafeid={1}&orderid={2}&touid={3}&num={4}&msg={5}&anony=0&r=0.5074032391421497", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, dinnertable.OrderId, Operation.PresentFoodId, presentcount, DataConvert.GetEncodeData(Task.PresentFoodMessage)));
                                if (GetPresentFeedback(content))
                                    break;
                            }
                        }
                    }
                }
                else
                {
                    foreach (DinnerTableInfo dinnertable in cafe.DinnerTables)
                    {
                        if (dinnertable.Num > 0 && dinnertable.DishId == Task.PresentFoodDishId)
                        {
                            long presentcount = dinnertable.Num * Task.PresentFoodRatio / 100;
                            if (presentcount > 0)
                            {
                                SetMessageLn(string.Format("尝试向{0}赠送{1}*{2}%={3}盘{4}...", base.GetFriendNameById(Operation.PresentFoodId), dinnertable.Num, Task.PresentFoodRatio, presentcount, dinnertable.Name));
                                string content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dishact.php?verify={0}&cafeid={1}&orderid={2}&touid={3}&num={4}&msg={5}&anony=0&r=0.5074032391421497", DataConvert.GetEncodeData(this._verifyCode), cafe.CafeId, dinnertable.OrderId, Operation.PresentFoodId, presentcount, DataConvert.GetEncodeData(Task.PresentFoodMessage)));
                                if (GetPresentFeedback(content))
                                    break;
                            }
                            break;
                        }
                    }
                }

            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameCafe.PresentFood", ex, LogSeverity.Error);
                SetMessage("赠送食物失败!错误:" + ex.Message);
            }
        }
示例#10
0
        public static CafeInfo GetCafe(string strxml)
        {
            try
            {
                if (String.IsNullOrEmpty(strxml))
                    return null;

                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);
                if (objXmlDoc == null)
                    return null;

                CafeInfo cafe = new CafeInfo();

                //cafe
                XmlNode objNode = objXmlDoc.SelectSingleNode("data/account");
                if (objNode == null)
                    return null;

                cafe.Grade = DataConvert.GetInt32(objNode.SelectSingleNode("grade/item/grade").InnerText);
                cafe.GradeLabel = objNode.SelectSingleNode("grade/item/label").InnerText;
                cafe.Name = objNode.SelectSingleNode("real_name").InnerText;
                cafe.Cash = DataConvert.GetInt64(objNode.SelectSingleNode("cash").InnerText);
                cafe.GoldNum = DataConvert.GetInt32(objNode.SelectSingleNode("goldnum").InnerText);
                cafe.Evalue = DataConvert.GetInt32(objNode.SelectSingleNode("evalue").InnerText);

                objNode = objXmlDoc.SelectSingleNode("data/cafe");
                if (objNode == null)
                    return null;
                cafe.CafeName = objNode.SelectSingleNode("cafename").InnerText;
                cafe.CafeId = DataConvert.GetInt32(objNode.SelectSingleNode("cafeid").InnerText);

                //cooking
                DataView dv = GetData(objXmlDoc, "data/cooking");

                Collection<CookingInfo> cookings = new Collection<CookingInfo>();

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    try
                    {
                        CookingInfo cooking = new CookingInfo();
                        cooking.OrderId = DataConvert.GetInt32(dv.Table.Rows[ix]["orderid"]);
                        if (dv.Table.Columns.Contains("stage"))
                            cooking.Stage = DataConvert.GetInt32(dv.Table.Rows[ix]["stage"]);
                        else
                            cooking.Stage = -98;
                        if (dv.Table.Columns.Contains("stage") && cooking.Stage != -1)
                        {                            
                            cooking.DishId = DataConvert.GetInt32(dv.Table.Rows[ix]["dishid"]);
                            cooking.Name = DataConvert.GetString(dv.Table.Rows[ix]["name"]);
                            cooking.FoodNum = DataConvert.GetInt32(dv.Table.Rows[ix]["foodnum"]);
                            cooking.Step = DataConvert.GetInt32(dv.Table.Rows[ix]["step"]);
                            cooking.Resver = DataConvert.GetInt32(dv.Table.Rows[ix]["resver"]);
                        }
                        cookings.Add(cooking);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Write("ConfigCtrl.GetCafe(Get CookingInfo)", strxml, ex, LogSeverity.Warn);
                        continue;
                    }
                }
                cafe.Cookings = cookings;

                //Employees
                //dv = GetData(objXmlDoc, "data/employees");

                //Collection<EmployeeInfo> employees = new Collection<EmployeeInfo>();

                //for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                //{
                //    try
                //    {
                //        EmployeeInfo employee = new EmployeeInfo();
                //        employee.UId = DataConvert.GetInt32(dv.Table.Rows[ix]["uid"]);
                //        employee.Name = DataConvert.GetString(dv.Table.Rows[ix]["real_name"]);
                //        employees.Add(employee);
                //    }
                //    catch (Exception ex)
                //    {
                //        LogHelper.Write("ConfigCtrl.GetCafe(Get EmployeeInfo)", strxml, ex, LogSeverity.Error);
                //        continue;
                //    }
                //}
                //cafe.Employees = employees;
                XmlNodeList nodes = objXmlDoc.SelectNodes("data/employees/item");
                Collection<FriendInfo> employees = new Collection<FriendInfo>();

                foreach (XmlNode node in nodes)
                {
                    try
                    {
                        FriendInfo employee = new FriendInfo();
                        employee.Id = DataConvert.GetInt32(node.SelectSingleNode("uid").InnerText);
                        employee.Name = node.SelectSingleNode("real_name").InnerText;
                        employees.Add(employee);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Write("ConfigCtrl.GetCafe(Get EmployeeInfo)", strxml, ex, LogSeverity.Error);
                        continue;
                    }
                }
                cafe.Employees = employees;
                

                //Foods
                dv = GetData(objXmlDoc, "data/dish");

                Collection<DinnerTableInfo> dinnertables = new Collection<DinnerTableInfo>();

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    try
                    {
                        DinnerTableInfo dinnertable = new DinnerTableInfo();
                        dinnertable.OrderId = DataConvert.GetInt64(dv.Table.Rows[ix]["orderid"]);
                        if (dv.Table.Columns.Contains("name"))
                            dinnertable.Name = DataConvert.GetString(dv.Table.Rows[ix]["name"]);
                        if (dv.Table.Columns.Contains("foodnum"))
                            dinnertable.FoodNum = DataConvert.GetInt32(dv.Table.Rows[ix]["foodnum"]);
                        if (dv.Table.Columns.Contains("dishid"))
                            dinnertable.DishId = DataConvert.GetInt32(dv.Table.Rows[ix]["dishid"]);
                        if (dv.Table.Columns.Contains("num"))
                            dinnertable.Num = DataConvert.GetInt32(dv.Table.Rows[ix]["num"]);
                        if (dv.Table.Columns.Contains("resver"))
                            dinnertable.Resver = DataConvert.GetInt32(dv.Table.Rows[ix]["resver"]);
                        dinnertables.Add(dinnertable);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Write("ConfigCtrl.GetCafe(Get DishInfo)", strxml, ex, LogSeverity.Warn);
                        continue;
                    }
                }
                cafe.DinnerTables = dinnertables;

                //equipments
                dv = GetData(objXmlDoc, "data/equipments");
                if (dv.Table.Rows.Count > 0)
                {
                    string tkey = "";
                    for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                    {
                        try
                        {
                            tkey = DataConvert.GetString(dv.Table.Rows[ix]["tkey"]);
                            if (tkey == "autochef")
                                cafe.Chef = true;
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Write("ConfigCtrl.GetCafe(Get DishInfo)", strxml, ex, LogSeverity.Warn);
                            continue;
                        }
                    }
                }
                return cafe;
            }
            catch (Exception ex)
            {
                LogHelper.Write("ConfigCtrl.GetCafe", strxml, ex, LogSeverity.Error);
                return null;
            }
        }