/// <summary>
 /// 讀取已被選擇的資料表
 /// </summary>
 private void ReadCheckList()
 {
     CheckList.Clear();
     foreach (DataGridViewRow row in dgvTableSchema.Rows)
     {
         bool   _bSelectTable   = (row.Cells[3].Value == null) ? false : ((bool)row.Cells[3].Value) ? true : false;
         string _CheckTableName = row.Cells[1].Value.ToString().Trim().ToLower();
         if (_bSelectTable)
         {
             CheckList.Add(_CheckTableName);
         }
     }
 }
 public void PasswordTestAndScan(object obj, EventArgs args)
 {
     if (password.Text.ToString() != "")
     {
         CheckList.Remove(CheckList.Find(x => x.Equals(false)));
         CheckList.Add(true);
     }
     else
     {
         CheckList.Remove(CheckList.Find(x => x.Equals(true)));
         CheckList.Add(false);
     }
     Scan(this.commit);
 }
        private void Continue()
        {
            Log.Write("Continue button was clicked");
            int count          = 0;
            var checklistModel = SetCheckList();

            Log.Write("SetCheckList() was Done");

            if (checklistModel == null)
            {
                return;
            }

            if (WorkItem == null || WorkItem == String.Empty || WorkItem.Length != 6)
            {
                MessageBox.Show("Please enter correct (6 digits) workItem Id!");
                return;
            }

            var checklistCopy = new List <CheckModel>(CheckList);

            CheckList.Clear();

            checklistModel.ForEach(check =>
            {
                check.GroupNameDone       = "GroupNameDone" + count;
                check.GroupNameNoRelevant = "GroupNameNoRelevant" + count;
                var existCheck            = checklistCopy.FirstOrDefault(c => c.CheckDescription.Equals(check.CheckDescription));
                check.IsDoneCheckBox      = (existCheck != null) ? existCheck.IsDoneCheckBox : false;
                count++;
                CheckList.Add(check);
            });

            FormHeight = 460;

            CanContinue = false;
        }
        public JobDetailViewModel(INavigation navigation, Models.MyBookingModel bookingListTap) : base(navigation)
        {
            if (Xamarin.Forms.Application.Current.Properties.ContainsKey("AppLocale") && !string.IsNullOrEmpty(Xamarin.Forms.Application.Current.Properties["AppLocale"].ToString()))
            {
                languageculture = Xamarin.Forms.Application.Current.Properties["AppLocale"].ToString();
            }
            else
            {
                languageculture = "en-US";
            }

            //IsRatingPopup = false;
            MyBooking = bookingListTap;

            switch (languageculture)
            {
            case "en-US":
                MyBooking.Category.Name    = MyBooking.Category.Name;
                MyBooking.SubCategory.Name = MyBooking.SubCategory.Name;
                break;

            case "fr-FR":
                MyBooking.Category.Name    = MyBooking.Category.Name_French;
                MyBooking.SubCategory.Name = MyBooking.SubCategory.Name_French;
                break;

            case "he-IL":
                MyBooking.Category.Name    = MyBooking.Category.Name_Hebrew;
                MyBooking.SubCategory.Name = MyBooking.SubCategory.Name_Hebrew;
                break;

            case "ru-RU":
                MyBooking.Category.Name    = MyBooking.Category.Name_Russian;
                MyBooking.SubCategory.Name = MyBooking.SubCategory.Name_Russian;
                break;
            }


            //MyBooking.ServiceProviderProfilePic = IsImagesValid(MyBooking.ServiceProviderProfilePic, ApiHelpers.ApiImageBaseUrl);
            if (MyBooking.SubSubCategories != null && MyBooking.SubSubCategories.Count > 0)
            {
                IsSubsubCategoryVisible = true;
                foreach (var item in MyBooking.SubSubCategories)
                {
                    switch (languageculture)
                    {
                    case "en-US":
                        item.Name = item.Name;
                        break;

                    case "fr-FR":
                        item.Name = item.Name_French;
                        break;

                    case "he-IL":
                        item.Name = item.Name_Hebrew;
                        break;

                    case "ru-RU":
                        item.Name = item.Name_Russian;
                        break;
                    }
                    SubSubCategoryList.Add(item);
                }
                SubSubCategoryHeight = SubSubCategoryList.Count * 70;
            }
            else
            {
                IsSubsubCategoryVisible = false;
            }

            if ((string.IsNullOrEmpty(MyBooking.Description) || string.IsNullOrWhiteSpace(MyBooking.Description)) && (MyBooking.ReferenceImages == null || MyBooking.ReferenceImages.Count == 0))
            {
                IsRefDescriptionVisible = false;
            }
            else
            {
                IsRefDescriptionVisible = true;
                if (MyBooking.ReferenceImages != null && MyBooking.ReferenceImages.Count > 0)
                {
                    IsRefImagesVisible = true;
                    foreach (var item in MyBooking.ReferenceImages)
                    {
                        ReferenceImagesList.Add(new ReferenceImagesModel()
                        {
                            ReferenceImages = IsImagesValid(item, ApiHelpers.ReferenceImageBaseUrl)
                        });
                    }
                }
                else
                {
                    IsRefImagesVisible = false;
                }

                if (string.IsNullOrEmpty(MyBooking.Description) || string.IsNullOrWhiteSpace(MyBooking.Description))
                {
                    IsJobDescriptionVisible = false;
                }
                else
                {
                    IsJobDescriptionVisible = true;
                }
            }


            if (MyBooking.JobStatus == Convert.ToInt32(RequestStatus.Completed))
            {
                if (MyBooking.UserJobRating != null && MyBooking.UserRating != null && MyBooking.UserJobRating.Value != 0 && MyBooking.UserRating.Value != 0)
                {
                    JobRatingIcon = string.Empty;
                }
                else
                {
                    JobRatingIcon = "ic_customer_rating.png";
                }

                //if(MyBooking.PaymentMethod == Convert.ToInt32(PaymentMethod.ByCreditCard))
                //{
                //    IsPaymentBtnVisible = true;
                //    if(MyBooking.IsPaymentDone != null && MyBooking.IsPaymentDone.Value)
                //    {
                //        PaymentBtnText = AppResource.PaymentBtn1;
                //        PaymentBgColor = Color.FromHex(StaticHelpers.GrayColor);
                //        IsPaymentBtnEnable = false;
                //    }
                //    else
                //    {
                //        PaymentBtnText = AppResource.PaymentBtn;
                //        PaymentBgColor = Color.FromHex(StaticHelpers.BlueColor);
                //        IsPaymentBtnEnable = true;
                //    }
                //}
                //else
                //{
                //    IsPaymentBtnVisible = false;
                //}
                IsPaymentBtnVisible = true;
                if (MyBooking.IsPaymentDone != null && MyBooking.IsPaymentDone.Value)
                {
                    PaymentBtnText     = AppResource.PaymentBtn1;
                    PaymentBgColor     = Color.FromHex(StaticHelpers.GrayColor);
                    IsPaymentBtnEnable = false;
                }
                else
                {
                    PaymentBtnText     = AppResource.PaymentBtn;
                    PaymentBgColor     = Color.FromHex(StaticHelpers.BlueColor);
                    IsPaymentBtnEnable = true;
                }
            }
            else
            {
                JobRatingIcon = string.Empty;
            }

            if (MyBooking.CheckList != null && MyBooking.CheckList.Count > 0)
            {
                IsCheckList = true;
                foreach (var item in MyBooking.CheckList)
                {
                    CheckList.Add(new CheckListModel()
                    {
                        CheckListValue = item.TaskDetail,
                        CheckListCheck = item.IsDone.HasValue && item.IsDone.Value == true ? "ic_register_check.png" : "ic_uncheked.png",
                    });
                    CheckListHeight = (50 * CheckList.Count) + 10;
                }
            }
            else
            {
                IsCheckList = false;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Method to add "item" to list
 /// </summary>
 /// <param name="item"></param>
 public void AddToList(string item)
 {
     CheckList.Add(item);
 }
Esempio n. 6
0
        public void Init(object me, int[] counts, int[] values, int max_rounds, LogDelegate log)
        {
            m_counts = counts;
            m_values = values;
            m_rounds = max_rounds * 2;
            m_log    = log;

            m_maxIncome = 0;
            int count = 0;

            for (int i = 0; i < counts.Length; i++)
            {
                m_maxIncome += m_counts[i] * values[i];
                count       += m_counts[i];
            }

            Generator generator = new Generator(m_counts, 1, count, m_maxIncome);

            int currentSet    = -1;
            int currentValues = -1;

            for (int i = 0; i < generator.Combinations.Count; i++)
            {
                if (Utils.ArrayEquals(m_counts, generator.Combinations[i].Item1))
                {
                    currentSet = i;

                    for (int j = 0; j < generator.Combinations[i].Item2.Length; j++)
                    {
                        if (Utils.ArrayEquals(generator.Combinations[i].Item2[j], m_values))
                        {
                            currentValues = j;
                            break;
                        }
                    }

                    break;
                }
            }

            if (currentSet == -1 || currentValues == -1)
            {
                throw new HaggleException("Data and values not found in generated sets!");
            }

            m_allValues     = generator.Combinations[currentSet].Item2;
            m_myValuesIndex = currentValues;

            m_rejectedOffers = new CheckList <string>();
            m_excludedValues = new CheckList <int>();
            m_excludedValues.Add(currentValues);

            m_offers = AnalyzerEngine.FindBestOffers(m_counts, m_allValues, m_excludedValues, m_myValuesIndex);

            m_log(Utils.Format("I'm analyzer player {0}, {1}", AcceptThreshold, RejectThreshold));

#if LOG_OFFERS
            m_log("Initial list of offers");

            for (int i = 0; i < m_offers.Length; i++)
            {
                m_log(Utils.Format("{0}: valid: {1}", m_offers[i], ValidOffer(m_offers[i], false)));
            }
#endif

#if DEBUG_RIG
            PrintStats();
#endif
        }
Esempio n. 7
0
        public OfferHolder MakeOffer(int turnsLeft)
        {
            OfferHolder selectedOffer = null;

            for (int i = 0; i < m_offers.Length; i++)
            {
                if (ValidOffer(m_offers[i], false))
                {
                    selectedOffer = m_offers[i];
                    break;
                }
            }

            if (m_greed)                   // greed guy does not want to make last offer
            {
                if (selectedOffer == null) // no offers left, stick with last one
                {
                    selectedOffer = m_lastOffer;
                }
            }
            else
            {
                if (turnsLeft <= 2)
                {
                    this.m_log("Making last offer!");

                    selectedOffer = null;

                    for (var i = 0; i < this.m_offers.Length; i++)
                    {
                        if (this.m_offers[i].EnemyMedian > 0 && this.m_offers[i].EnemyAverage >= this.m_maxIncome * LastOfferThreshold && this.m_offers[i].MyIncome > 0)
                        {
                            return(this.m_offers[i]);
                        }
                    }
                }

                if (selectedOffer == null) // no offers left, try relaxed list
                {
                    m_log("No meaninful offers left!");

                    for (int i = 0; i < m_offers.Length; i++)
                    {
                        if (this.m_offers[i].EnemyMedian > 0 && m_offers[i].EnemyAverage >= MinOfferThreshold * m_maxIncome && m_offers[i].MyIncome > 0 && !m_rejectedOffers.Contains(m_offers[i].OfferCode)) // relaxed check: not fairest option, but still good
                        {
                            selectedOffer = m_offers[i];
                            break;
                        }
                    }

                    if (selectedOffer == null) // no offers left, stick with last one
                    {
                        m_log("No offers left and no relaxed found!");
                        selectedOffer = m_lastOffer;
                    }
                }
            }
            m_rejectedOffers.Add(selectedOffer.OfferCode);

            m_lastOffer = selectedOffer;

            // if enemy rejected my offer, that means that his total for this offer never reached 9 or 10
            bool changed = false;

            for (int i = 0; i < m_allValues.Length; i++)
            {
                if (m_excludedValues.Contains(i))
                {
                    continue;
                }

                int income = AnalyzerEngine.CalculateIncomeForOffer(m_counts, m_allValues[i], m_lastOffer.Offer, true);

                if (income >= m_maxIncome * RejectThreshold)
                {
                    m_excludedValues.Add(i);
                    changed = true;
                }
            }

            if (changed)
            {
                m_offers = AnalyzerEngine.FindBestOffers(m_counts, m_allValues, m_excludedValues, m_myValuesIndex);

#if DEBUG_RIG
                PrintStats();
#endif
#if LOG_OFFERS
                m_log("Revised list of offers (for next move)");

                for (int i = 0; i < m_offers.Length; i++)
                {
                    m_log(Utils.Format("{0}: valid: {1}", m_offers[i], ValidOffer(m_offers[i], false)));
                }
#endif
            }

            return(selectedOffer);
        }