public void Report_UnLike()
        {
            try
            {
                List<string> Follower = new List<string>();

                DataSet ds = DataBaseHandler.SelectQuery("select * from tbl_AccountReport where ModuleName ='" + "PhotoUnlikeModule" + "' and Status='" + "Unliked" + "'", "tbl_AccountReport");

                foreach (DataRow ds_item in ds.Tables[0].Rows)
                {
                    string Photo_Id = ds_item.ItemArray[3].ToString();
                    Follower.Add(Photo_Id);
                    Follower = Follower.Distinct().ToList();
                }
                int sum = ds.Tables[0].Rows.Count;
                DataTable dt = ds.Tables[0];
                Dispatcher.Invoke(new Action(delegate
                {
                    if (Follower.Count != 0)
                    {
                        Success_UnLike_Done.Foreground = Brushes.Green;
                    }
                    Success_UnLike_Done.Content = Follower.Count;
                }));


            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error:" + ex.StackTrace);
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            // lisataan comboBoxiin kaikki maat

            List<string> KaikkiMaat = new List<string>();
            List<string> Maat = new List<string>();

            KaikkiMaat.Add("Kaikki");

            XmlDocument doc = new XmlDocument();

            doc.Load(Properties.Settings.Default.ViiniXML);
 
            XmlNodeList nodes = doc.SelectNodes("viinikellari/wine/maa/text()");

            foreach (XmlNode node in nodes)
            {
                KaikkiMaat.Add(node.Value);
            }
            
            Maat = KaikkiMaat.Distinct().ToList();
            
            comboBox.ItemsSource = Maat;
        }
        public void FnvLoadpopup(string host, string modulname, List<string> Participants)
        {
            try
            {
                tblHost.Text = "";
                tblModule.Text = "";
                tblParticipants.Text = "";
                tblHost.Text = "You are invited by " + host;
                tblModule.Text = modulname;
               
                var distpart = Participants.Distinct();
                string[] part = distpart.ToArray<string>();
                tblParticipants.Text = part[0];
                for (int i = 1; i<part.Count(); i++)
                {
                    tblParticipants.Text = tblParticipants.Text + "," + part[i];
                }
                this.Left = Convert.ToInt64(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Right) - 300;
                this.Top = Convert.ToInt64(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Bottom) - 180;
               // ShowWindow();
                objsb.Begin(this);
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "FnvLoadpopup1()", "wndVMuktiPopup.xaml.cs");

            }
        }
 public BranchDetails()
 {
     DataTable dt = new DataTable();
     using (var connection = DatabaseService.GetAccessConnection())
     {
         connection.Open();
         dt = DatabaseService.GetDataTable("CityList");
         connection.Close();
     }
     InitializeComponent();
     List<string> cities = new List<string>();
     foreach (DataRow row in dt.Rows)
     {
         cities.Add(row["City"].ToString());
     }
     cities.Distinct().ToList().ForEach(x => cbCity.Items.Add(x));   
 }
        public void ChangeAttributeColor(Models.Users users, string AttributeName, string value, double baseRate)
        {
            List<int> list = new List<int>();
            foreach (var item in comunities.Where(n => n.UserIds != null))
            {
                list.AddRange(item.UserIds);
            }

            var rate = users.GetRate(AttributeName, value, list.Distinct());

            if (rate != double.NaN)
            {
                var r = rate / baseRate;
                if (r > 1.2)
                {
                    NewBrush(Color.FromArgb(255, 231, 159, 190), 0.5);
                }
                else if (r < 0.8)
                {
                    NewBrush(Color.FromArgb(255, 175,238, 238), 0.5);

                }
                else
                {
                    NewBrush(Colors.White, 0.5);

                }
            }
            else
            {
                NewBrush(Colors.White, 0.5);

            }
        }
        private void btnCompare_Click(object sender, RoutedEventArgs e)
        {
            Diffs = new List<XmlDifferences>();

            var pathOld = string.Empty;
            var pathNew = string.Empty;

            if (SelectedFolders.IsFile)
            {

                pathOld = SelectedFolders.FolderOld;
                pathNew = SelectedFolders.FolderNew;

                CompareFiles(pathOld, pathNew);
            }
            else if (SelectedFolders.IsFolder)
            {
                if (SelectedFolders.IncludeSubFolders)
                {
                    pathOld = SelectedFolders.FolderOld;
                    pathNew = SelectedFolders.FolderNew;

                    CompareFolderStructure(pathOld, pathNew, CompareAction.remove);
                    CompareFolderStructure(pathNew, pathOld, CompareAction.add);
                }
                else
                {
                    pathOld = SelectedFolders.FolderOld;
                    pathNew = SelectedFolders.FolderNew;

                    AddOrRemoveFile(pathOld, pathNew, CompareAction.remove);
                    AddOrRemoveFile(pathNew, pathOld, CompareAction.add);

                    CompareFolderFiles(pathOld, pathNew);
                }
            }

            grid.ItemsSource = null;
            Diffs = Diffs.Distinct().OrderBy(i => i.Component).ToList();
            grid.ItemsSource = Diffs;
        }
Beispiel #7
0
        private List<Product> tryTakeProducts(string url, int Zaderzhka)
        {
            string page = "";

            using (System.Net.WebClient web = new System.Net.WebClient())
            {

                web.Encoding = UTF8Encoding.Default;
                string str1 = web.DownloadString(url);

                str1 = System.Web.HttpUtility.HtmlDecode(str1);
                var numArr = Regex.Matches(str1, @"itemsCount"":([0-9]{1,5}),")
                .Cast<Match>()
                .Select(m => m.Groups[1].Value)
                .Distinct()
                .ToArray();

                int num = Int32.Parse(numArr[0]);

                while (num >= 0)
                {
                    num = num - 10;

                    string zagotovka = "http://vk.com/al_market.php?al=1&id=-$2&load=1&offset=" + num +
                    "&price_from=&price_to=&q=&sort=0";
                    _url = Regex.Replace(url, @"(http://vk.com/market-)(.+)", zagotovka);

                    string str = web.DownloadString(_url);
                    str = System.Web.HttpUtility.HtmlDecode(str);

                    page = page + str; //doc.DocumentNode.InnerHtml
                    Thread.Sleep(Zaderzhka);
                }
                //<div id="market_item24046" class="market_row">
                //File.WriteAllText("C:\\Users\\Maxs\\Desktop\\www1.txt", page);
                //div[@class='market_row_inner_cont']
                List<Product> listProducts = new List<Product>();

                var tempUrlToItems = Regex.Matches(page, @"name""><a href=""(/market-[0-9]{2,20}\?w=product-[0-9_]{2,35})")
                .Cast<Match>()
                .Select(m => m.Groups[1].Value)
                .ToArray();

                var tempIdToItems = Regex.Matches(page, @"<div id=""market_item([0-9]{1,9})"" class=""market_row"">")
                .Cast<Match>()
                .Select(m => m.Groups[1].Value)
                .ToArray();

                var tempNameToItems = Regex.Matches(page, @"<div class=""market_row_name""><a.*?>(.*?)</a")
                .Cast<Match>()
                .Select(m => m.Groups[1].Value)
                .ToArray();

                var tempPriceToItems = Regex.Matches(page, @"<div class=""market_row_price"">(.*?)</div>")
                .Cast<Match>()
                .Select(m => m.Groups[1].Value)
                .ToArray();

                Product product;
                for (int i = 0; i < tempUrlToItems.Length; i++)
                {
                    product = new Product();
                    product.Url = Regex.Replace(tempUrlToItems[i], @"/(market-[0-9]{2,20})\?w=(product-[0-9_]{2,35})",
                        "http://vk.com/wkview.php?act=show&al=1&loc=$1&w=$2");
                    product.Name = tempNameToItems[i];
                    product.Id = tempIdToItems[i];
                    //<div class="market_row_price">2<span class="num_delim"> </span>230 руб.</div>
                    product.Price = Regex.Replace(tempPriceToItems[i], @"(<div class=""market_row_price"".*?)([7-9]{1,7} руб.)(</div>)",
                        "$2");

                    listProducts.Add(product);
                }

                listProducts = listProducts.Distinct(new ProductComparer()).ToList();


                str1 = System.Web.HttpUtility.HtmlDecode(str1);

                //3<span class="num_delim"> </span>990 руб.
                //</div> <div class="market_item_controls unshown">
                foreach (var prod in listProducts)
                {
                    prod.Price = Regex.Replace(prod.Price, @"<span class=""num_delim"">\s*?</span>",
                        " ");
                    string desc = web.DownloadString(prod.Url);
                    desc = System.Web.HttpUtility.HtmlDecode(desc);
                    prod.Desc = Regex.Replace(desc, @".*?<div class=""market_item_description"">[\n]*?\s+(.*?)</div>(.*?)<div class=""market_item_controls unshown"">.*",
                        "$1", RegexOptions.Singleline);
                    prod.Desc = Regex.Replace(prod.Desc, @"<.*?>", " ", RegexOptions.Singleline);
                    prod.Desc = Regex.Replace(prod.Desc, @"Показать полностью\.\.", "", RegexOptions.Singleline);
                    prod.Desc = Regex.Replace(prod.Desc, @"\s+", " ", RegexOptions.Singleline);
                    Thread.Sleep(Zaderzhka);
                }
                return listProducts;
            }
            
        }
 private static List<string> FindImages(string pageContent)
 {
     HtmlDocument doc = new HtmlDocument();
     doc.LoadHtml(pageContent);
     var listOfImageSources = new List<string>();
     foreach (var node in doc.DocumentNode.SelectNodes("//img"))
     {
         var src = node.Attributes.FirstOrDefault(a => a.Name.ToLower() == "src");
         if (src != null && !string.IsNullOrEmpty(src.Value))
         {
             listOfImageSources.Add(src.Value.ToLower());
         }
     }
     return listOfImageSources.Distinct().ToList();
 }
      public void report_status()
        {
          try
          {
          List<string> lst_Unfollow = new List<string>();
          DataSet ds = DataBaseHandler.SelectQuery("select * from tbl_AccountReport where ModuleName ='" + "UnfollowModule" + "' and Status='" + "Success" + "'", "tbl_AccountReport");
               
               foreach (DataRow ds_item in ds.Tables[0].Rows)
               {
                   string Photo_Id = ds_item.ItemArray[5].ToString();
                   lst_Unfollow.Add(Photo_Id);
                   lst_Unfollow = lst_Unfollow.Distinct().ToList();
               }
               int sum = ds.Tables[0].Rows.Count;
               DataTable dt = ds.Tables[0];
               Dispatcher.Invoke(new Action(delegate
               {
                   if (lst_Unfollow.Count != 0)
                   {
                       User_Unfollow_success.Foreground = Brushes.Green;
                   }
                   User_Unfollow_success.Content = lst_Unfollow.Count;
               }));

               
           }
           catch (Exception ex)
           {
               GlobusLogHelper.log.Error("Error:" + ex.StackTrace);
           }
        }
Beispiel #10
0
        public string Rawler2XAML(RawlerBase rawler)
        {
            StringBuilder xaml = new StringBuilder(System.Xaml.XamlServices.Save(rawler));
            xaml = xaml.Replace("\"{x:Null}\"", "Null").Replace(" Enable=\"True\"","").Replace(" Comment=\"\"","");

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\w*=Null");
            List<string> list = new List<string>();
            foreach (System.Text.RegularExpressions.Match item in regex.Matches(xaml.ToString()))
            {
                list.Add(item.Value);
            }

            foreach (var item in list.Distinct())
            {
                xaml = xaml.Replace(" " + item, string.Empty);
            }

            return xaml.ToString();
        }
Beispiel #11
0
        private void load()
        {
            cmbStoreId.Items.Clear();
            foreach (var r in Factory.Instance.i.Project.StoreInfo)
                cmbStoreId.Items.Add(r.Id);

            cmbExistAction.Items.Clear();
            foreach (string s in Enum.GetNames(typeof(IntelliScraper.Db.saveIfExist)))
                cmbExistAction.Items.Add(s);

          

            if (rule != null)
            {
                txtTableName.Text = rule.tableName;

                chkCheckExist.IsChecked = rule.checkExistBeforeSave;
                txtCheckExistAttrs.Text = rule.checkExistAttributes;
                txtCheckExistSeparator.Text = rule.checkExistAttributesSeparator;

                cmbExistAction.SelectedValue = rule.ifExist.ToString();
                cmbStoreId.SelectedValue = rule.storeId;
                cmbStoreId_SelectionChanged(this, null);

                if (rule.map != null)
                {
                    dataGrid1.Items.Clear();
                    foreach(var m in rule.map)
                        dataGrid1.Items.Add(m);
                }

                cmbMapColName.Items.Clear();
                var store = (from x in Factory.Instance.i.Project.StoreInfo where x.Id == rule.storeId select x).FirstOrDefault();
                if (store != null)
                {
                    if ((store.type == IntelliScraper.Db.intelliScraperProjectStoreInfoType.csv || store.type == IntelliScraper.Db.intelliScraperProjectStoreInfoType.excel) && store.CsvExcelSetting != null)
                    {
                        foreach (string s in store.CsvExcelSetting.csvHeader.Split(store.CsvExcelSetting.csvSeparator.ToCharArray()))
                            cmbMapColName.Items.Add(s);
                    }     
                }

                cmbAttributes.Items.Clear();
                List<string> attrs = new List<string>();
                if (Factory.Instance.i.rules.xpathSingle != null)
                {
                    foreach (var o in Factory.Instance.i.rules.xpathSingle)
                    {
                        foreach (var attr in o.attributes)
                            attrs.Add(attr.id);
                    }
                }
                if (Factory.Instance.i.rules.xpathCollection != null)
                {
                    foreach (var c in Factory.Instance.i.rules.xpathCollection)
                    {
                        if(c.xpathSingle != null)
                        {
                            foreach (var attr in c.xpathSingle.attributes)
                                attrs.Add(attr.id);
                        }
                    }
                }

                attrs.Remove(string.Empty);
                attrs = attrs.Distinct().ToList();
                foreach(string attr in attrs)
                    cmbAttributes.Items.Add(attr);
            }
        }
 //自动提交订单--单击车次
 void chkTicket_Click(object sender, RoutedEventArgs e)
 {
     List<string> lstTickets = new List<string>();
     string strSeatTypes = "";
     foreach (var chkItem in gridTickets.Children)
     {
         if (chkItem is CheckBox)
         {
             CheckBox chkTicket = chkItem as CheckBox;
             if ((bool)chkTicket.IsChecked)
             {
                 lstTickets.Add(chkTicket.Content.ToString());
                 if (lstTickets.Count() < 5)
                 {
                     strSeatTypes += chkTicket.Tag.ToString() + ",";
                 }
             }
         }
     }
     if (lstTickets.Count() > 5)
     {
         MessageBox.Show("选择车次数不能超过5个", "消息");
         CheckBox chkObj = e.Source as CheckBox;
         chkObj.IsChecked = false;
         return;
     }
     var arrSeatType = strSeatTypes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
     Dictionary<string, string> dicSeatTypes = new Dictionary<string, string>();
     List<string> lstSeat = new List<string>();
     for (int i = 0; i < arrSeatType.Count(); i++)
     {
         lstSeat.Add(arrSeatType[i]);
     }
     lstSeat = lstSeat.Distinct().ToList();
     dicSeatTypes.Clear();
     for (int s = 0; s < lstSeat.Count(); s++)
     {
         string seatValue = lstSeat[s] == "商务座" ? "9" : lstSeat[s] == "特等座" ? "P" : lstSeat[s] == "一等座" ? "M" : lstSeat[s] == "二等座" ? "O" : lstSeat[s] == "高级软卧" ? "6" : lstSeat[s] == "软卧" ? "4" : lstSeat[s] == "硬卧" ? "3" : lstSeat[s] == "软座" ? "2" : lstSeat[s] == "硬座" ? "1" : lstSeat[s] == "无座" ? "1" : "1";
         dicSeatTypes.Add(lstSeat[s], seatValue);
     }
     int sRow = (int)Math.Ceiling((double)lstSeat.Count() / 6), sCell = 6;
     while (sRow-- > 0)
     {
         gridSeatTypes.RowDefinitions.Add(new RowDefinition()
         {
             Height = new GridLength(15)
         });
     }
     while (sCell-- > 0)
     {
         gridSeatTypes.ColumnDefinitions.Add(new ColumnDefinition()
         {
             Width = new GridLength()
         });
     }
     gridSeatTypes.Children.Clear();
     int sR = 0, sC = 0, sT = 0;
     foreach (var d in dicSeatTypes)
     {
         CheckBox chkSeatType = new CheckBox()
         {
             Name = "chk" + d.Value,
             Content = d.Key,
             Tag = d.Value
         };
         chkSeatType.Click += chkSeatType_Click;
         gridSeatTypes.Children.Add(chkSeatType);
         if (sT > 0)
         {
             if (sT % 6 == 0)
             {
                 sR += 1;
                 sC = 0;
             }
             else
             {
                 sC++;
             }
         }
         chkSeatType.SetValue(Grid.RowProperty, sR);
         chkSeatType.SetValue(Grid.ColumnProperty, sC);
         sT++;
     }
 }
        private void MainWindow_OnActivated(object sender, EventArgs e)
        {
            if (FirstTimeActivated)
            {
                FirstTimeActivated = false;

                //Try to login with the saved credentials.
                if (!Auth.Login(Config.Instance.Username, Config.Instance.Password).Item1)
                {
                    ShowLoginDialog();
                }
                else
                {
                    OnLogin(Config.Instance.Username);
                }

                var allAssemblies = new List<LeagueSharpAssembly>();
                foreach (var profile in Config.Instance.Profiles)
                {
                    allAssemblies.AddRange(profile.InstalledAssemblies);
                }

                allAssemblies = allAssemblies.Distinct().ToList();

                GitUpdater.ClearUnusedRepos(allAssemblies);
                PrepareAssemblies(allAssemblies, Config.Instance.FirstRun || Config.Instance.UpdateOnLoad, true, true);
                Remoting.Init();
            }

            var text = Clipboard.GetText();
            if (text.StartsWith(LSUriScheme.FullName))
            {
                Clipboard.SetText("");
                LSUriScheme.HandleUrl(text, this);
            }
        }
        private static Tuple<Point3D, Point3D>[] GetUniqueLines(IEnumerable<Tuple<Point3D, Point3D>> allLines)
        {
            List<Tuple<Point3D, Point3D>> intermediate = new List<Tuple<Point3D, Point3D>>();

            //  Put the "smaller" point as item1
            foreach (var line in allLines)
            {
                if (line.Item1.X < line.Item2.X)
                {
                    intermediate.Add(line);
                }
                else if (line.Item1.X == line.Item2.X)
                {
                    if (line.Item1.Y < line.Item2.Y)
                    {
                        intermediate.Add(line);
                    }
                    else
                    {
                        intermediate.Add(Tuple.Create(line.Item2, line.Item1));
                    }
                }
                else
                {
                    intermediate.Add(Tuple.Create(line.Item2, line.Item1));
                }
            }

            return intermediate.Distinct().ToArray();
        }
        private void ShowReconstructTriangles(Point3D[] points)
        {
            //NOTE: This thinking is flawed (trying to reconstruct the triangle definitions based on the centers of the triangles) - I need this when instantiating a
            //camera from dna, the original control points are lost (vertices of the triangles)
            //
            //Instead, I'll go with Voronoi around the original even dist points, which is a much cleaner design all around

            Point3D[] points3D = points;//.Select(o => o.ToPoint()).ToArray();
            Point[] points2D = points3D.Select(o => new Point(o.X, o.Y)).ToArray();

            TriangleIndexed[] triangles = Math2D.GetDelaunayTriangulation(points2D, points3D);

            var quickHull = Math2D.GetConvexHull(points);
            bool[] isPerimiter = Enumerable.Range(0, points.Length).Select(o => quickHull.PerimiterLines.Contains(o)).ToArray();

            var remaining = TriangleIndexed.GetUniqueLines(triangles).ToList();

            #region First Pass

            List<Tuple<int, int>> first = new List<Tuple<int, int>>();

            for (int cntr = 0; cntr < points.Length; cntr++)
            {
                //  Get the lines connected to this point
                var connected = remaining.Where(o => o.Item1 == cntr || o.Item2 == cntr).
                    OrderBy(o => (points[o.Item2] - points[o.Item1]).LengthSquared).
                    ToArray();

                if (connected.Length == 0)
                {
                    continue;
                }

                //  Of these, choose the shortest
                first.Add(connected[0]);
            }


            first = first.Distinct().ToList();
            foreach (var shrt in first)
            {
                remaining.Remove(shrt);
            }

            #endregion
            #region Second Pass

            List<Tuple<int, int>> second = new List<Tuple<int, int>>();

            for (int cntr = 0; cntr < points.Length; cntr++)
            {
                int numConnected = first.Count(o => o.Item1 == cntr || o.Item2 == cntr);

                if (numConnected > 3)
                {
                    int seven = 8;
                }

                if (numConnected == 3)
                {
                    continue;
                }

                if (isPerimiter[cntr] && numConnected == 2)
                {
                    continue;
                }

                //  This still needs connections
                var connected = remaining.Where(o => o.Item1 == cntr || o.Item2 == cntr).
                    OrderBy(o => (points[o.Item2] - points[o.Item1]).LengthSquared).
                    ToArray();

                if (connected.Length == 0)
                {
                    continue;
                }

                //  Of these, choose the shortest
                second.Add(connected[0]);
            }


            second = second.Distinct().ToList();
            foreach (var shrt in second)
            {
                remaining.Remove(shrt);
            }

            #endregion
            #region Third Pass

            List<Tuple<int, int>> third = new List<Tuple<int, int>>();

            for (int cntr = 0; cntr < points.Length; cntr++)
            {
                int numConnected = first.Count(o => o.Item1 == cntr || o.Item2 == cntr);
                numConnected += second.Count(o => o.Item1 == cntr || o.Item2 == cntr);

                if (numConnected > 3)
                {
                    int seven = 8;
                }

                if (numConnected == 3)
                {
                    continue;
                }

                if (isPerimiter[cntr] && numConnected == 2)
                {
                    continue;
                }

                //  This still needs connections
                var connected = remaining.Where(o => o.Item1 == cntr || o.Item2 == cntr).
                    OrderBy(o => (points[o.Item2] - points[o.Item1]).LengthSquared).
                    ToArray();

                if (connected.Length == 0)
                {
                    continue;
                }

                //  Of these, choose the shortest
                third.Add(connected[0]);
            }


            third = third.Distinct().ToList();
            foreach (var shrt in third)
            {
                remaining.Remove(shrt);
            }

            #endregion


            #region First Lines

            ScreenSpaceLines3D lines = new ScreenSpaceLines3D();
            lines.Color = UtilityWPF.ColorFromHex("50F050");
            lines.Thickness = 5d;

            foreach (var line in first)
            {
                lines.AddLine(points3D[line.Item1], points3D[line.Item2]);
            }

            _visuals.Add(lines);
            _viewport.Children.Add(lines);

            #endregion
            #region Second Lines

            lines = new ScreenSpaceLines3D();
            lines.Color = UtilityWPF.ColorFromHex("70E070");
            lines.Thickness = 2d;

            foreach (var line in second)
            {
                lines.AddLine(points3D[line.Item1], points3D[line.Item2]);
            }

            _visuals.Add(lines);
            _viewport.Children.Add(lines);

            #endregion
            #region Third Lines

            lines = new ScreenSpaceLines3D();
            lines.Color = UtilityWPF.ColorFromHex("90D090");
            lines.Thickness = 1d;

            foreach (var line in third)
            {
                lines.AddLine(points3D[line.Item1], points3D[line.Item2]);
            }

            _visuals.Add(lines);
            _viewport.Children.Add(lines);

            #endregion
            #region Longest Lines

            lines = new ScreenSpaceLines3D();
            lines.Color = UtilityWPF.ColorFromHex("D09090");
            lines.Thickness = 1d;

            foreach (var line in remaining)
            {
                lines.AddLine(points3D[line.Item1], points3D[line.Item2]);
            }

            _visuals.Add(lines);
            _viewport.Children.Add(lines);

            #endregion
        }
Beispiel #16
0
        void InitSubmitNoList(bool isAll)
        {
            try
            {

                SubmitCollection.Clear();
                List<string> list = new List<string>();

                if (isAll == false) //只显示未打印的
                {
                    if (hasTable2AdminRight == true)
                    {
                        list =
                          (from s in visaORM.TB_TableSubmit
                           join c in visaORM.Customer
                           on s.FAutoID equals c.FAutoID
                           where c.FSysPrint == false
                           orderby s.FID descending
                           select s.FSubmitNo).ToList();
                    }
                    else
                    {
                        list =
                            (from s in visaORM.TB_TableSubmit
                             join c in visaORM.Customer
                             on s.FAutoID equals c.FAutoID
                             where c.FSysPrint == false && s.FCompany == MainContext.UserCompanyName
                             orderby s.FID descending
                             select s.FSubmitNo).ToList();

                    }
                }
                else //显示所有的
                {
                    if (hasTable2AdminRight == true)
                    {
                        list =
                          (from s in visaORM.TB_TableSubmit
                           join c in visaORM.Customer
                           on s.FAutoID equals c.FAutoID
                           orderby s.FID descending
                           select s.FSubmitNo).ToList();
                    }
                    else
                    {
                        list =
                            (from s in visaORM.TB_TableSubmit
                             join c in visaORM.Customer
                             on s.FAutoID equals c.FAutoID
                             where s.FCompany == MainContext.UserCompanyName
                             orderby s.FID descending
                             select s.FSubmitNo).ToList();

                    }
                }

                foreach (string sString in list.Distinct())
                {
                    SubmitCollection.Add(sString);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.WriteLog.WriteErorrLog(ex);
            }
        }
Beispiel #17
0
        private void btnCheckMissing_Click(object sender, RoutedEventArgs e)
        {
            var lstEpizodeNumbers = new List<int>();
            int max = 0;

            foreach(RadDiagramShape sh in this.diagram.Shapes)
            {
                var ep = sh.Tag as Epizode;
                if (ep.EpizodeNumber < 1000)
                {
                    if (max < ep.EpizodeNumber)
                    {
                        max = ep.EpizodeNumber;
                    }
                    lstEpizodeNumbers.Add(ep.EpizodeNumber);
                }
            }

            lstEpizodeNumbers = lstEpizodeNumbers.OrderBy(a => a).ToList();
            var currentCount = lstEpizodeNumbers.Count;
            var lstNoDupEpizodeNumbers = lstEpizodeNumbers.Distinct().ToList();
            var NoDupCount = lstNoDupEpizodeNumbers.Count;
            if(currentCount != NoDupCount)
            {
                for (int i = 0; i < lstEpizodeNumbers.Count - 1; i ++)
                {
                    if(i + 1 == lstEpizodeNumbers[i + 1])
                    {
                        MessageBox.Show("Check epizode " + i + 1 + " for duplication");
                        break;
                    }
                }
            }

            //look for missing epizodes
            if (lstNoDupEpizodeNumbers.Count < max)
            {
                for (int i = 0; i < lstEpizodeNumbers.Count; i++)
                {
                    if (i+ 1 != lstEpizodeNumbers[i])
                    {
                        MessageBox.Show("Check epizode " + (i + 1) + " for absence");
                        break;
                    }
                }
            }
        }
        /// <summary>
        ///     Main logic behind Champion Select
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="message"></param>
        private void Select_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                #region In Champion Select

                var champDto = message as GameDTO;
                //Sometimes chat doesn't work so spam this until it does
                LatestDto = champDto;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
                {
                    //Allow all champions to be selected (reset our modifications)
                    var championArray = new ListViewItem[ChampionSelectListView.Items.Count];
                    ChampionSelectListView.Items.CopyTo(championArray, 0);
                    foreach (ListViewItem y in championArray)
                    {
                        y.IsHitTestVisible = true;
                        y.Opacity = 1;
                    }

                    //Push all teams into one array to save a foreach call (looks messy)
                    if (champDto == null)
                        return;

                    var allParticipants = new List<Participant>(champDto.TeamOne.ToArray());
                    allParticipants.AddRange(champDto.TeamTwo);

                    int t = 1;

                    if (LatestDto.QueueTypeName == "COUNTER_PICK") //fix for nemesis draft, get your champ from GameDTO
                    {
                        var selectedChamp = champDto.PlayerChampionSelections.Find(item => item.SummonerInternalName == Client.LoginPacket.AllSummonerData.Summoner.InternalName);
                        ChangeSelectedChampionSkins(selectedChamp.ChampionId);
                    }
                    foreach (PlayerParticipant participant in allParticipants.Select(p => p as PlayerParticipant))
                    {
                        if (participant != null)
                        {
                            PlayerParticipant play = participant;
                            //If it is our turn to pick
                            if (play.PickTurn == champDto.PickTurn)
                            {
                                if (play.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId)
                                {
                                    if (Settings.Default.PickBanFocus)
                                        Client.MainWin.Focus();
                                    if (Settings.Default.PickBanFlash)
                                        Client.MainWin.FlashWindow();
                                    //Allows us to instapick any champ we own. 
                                    if (Client.usingInstaPick)
                                    {
                                        bool champbanned = false;
                                        //disallow picking banned champs
                                        try
                                        {
                                            foreach (
                                                BannedChampion x in
                                                    champDto.BannedChampions.Where(
                                                        x => x.ChampionId == Client.SelectChamp))
                                                champbanned = true;

                                            //disallow picking picked champs
                                            foreach (
                                                PlayerChampionSelectionDTO selection in
                                                    champDto.PlayerChampionSelections.Where(
                                                        selection => selection.ChampionId == Client.SelectChamp))
                                                champbanned = true;

                                            var temp = new ListViewItem
                                            {
                                                Tag = Client.SelectChamp
                                            };
                                            if (!champbanned)
                                                ListViewItem_PreviewMouseDown(temp, null);

                                            Client.usingInstaPick = false;
                                        }
                                        catch
                                        {
                                            Client.Log("Something went weird insta-picking a champ", "Error");
                                        }
                                    }

                                    ChampionSelectListView.IsHitTestVisible = true;

                                    ChampionSelectListView.Opacity = 1;
                                    GameStatusLabel.Content = "Your turn to pick!";
                                    break;
                                }
                            }
                            if (string.IsNullOrEmpty(participant.SummonerName))
                            {
                                participant.SummonerName = "Summoner " + t;
                                t++;
                            }
                        }
                        //Otherwise block selection of champions unless in dev mode
                        if (!Client.Dev)
                        {
                            ChampionSelectListView.IsHitTestVisible = false;
                            ChampionSelectListView.Opacity = 0.5;
                        }
                        GameStatusLabel.Content = "Waiting for others to pick...";
                    }

                    allParticipants = allParticipants.Distinct().ToList();

                    //Champion select was cancelled 
                    if (champDto.GameState == "TEAM_SELECT")
                    {
                        if (CountdownTimer != null)
                            CountdownTimer.Stop();

                        Client.FixChampSelect();

                        return;
                    }
                    if (champDto.GameState == "PRE_CHAMP_SELECT")
                    {
                        //Banning phase. Enable banning phase and this will render only champions for ban
                        BanningPhase = true;
                        PurpleBansLabel.Visibility = Visibility.Visible;
                        BlueBansLabel.Visibility = Visibility.Visible;
                        BlueBanListView.Visibility = Visibility.Visible;
                        PurpleBanListView.Visibility = Visibility.Visible;
                        GameStatusLabel.Content = "Bans are on-going";
                        counter = configType.BanTimerDuration - 3;

                        #region Render Bans

                        BlueBanListView.Items.Clear();
                        PurpleBanListView.Items.Clear();
                        foreach (BannedChampion x in champDto.BannedChampions)
                        {
                            var champImage = new Image
                            {
                                Height = 58,
                                Width = 58,
                                Source = champions.GetChampion(x.ChampionId).icon
                            };
                            if (x.TeamId == 100)
                                BlueBanListView.Items.Add(champImage);
                            else
                                PurpleBanListView.Items.Add(champImage);

                            foreach (var y in championArray.Where(y => (int)y.Tag == x.ChampionId))
                            {
                                ChampionSelectListView.Items.Remove(y);
                                //Remove from arrays
                                foreach (
                                    ChampionDTO playerChamps in
                                        ChampList.ToArray()
                                            .Where(playerChamps => x.ChampionId == playerChamps.ChampionId))
                                {
                                    ChampList.Remove(playerChamps);

                                    break;
                                }

                                foreach (
                                    ChampionBanInfoDTO banChamps in
                                        ChampionsForBan.ToArray()
                                            .Where(banChamps => x.ChampionId == banChamps.ChampionId))
                                {
                                    ChampionsForBan.Remove(banChamps);

                                    break;
                                }
                            }
                        }

                        #endregion Render Bans
                    }
                    else if (champDto.GameState == "CHAMP_SELECT")
                    {
                        //Picking has started. If pickturn has changed reset timer
                        LastPickTurn = champDto.PickTurn;
                        BanningPhase = false;
                    }
                    else if (champDto.GameState == "POST_CHAMP_SELECT")
                    {
                        //Post game has started. Allow trading
                        CanTradeWith = await RiotCalls.GetPotentialTraders();
                        HasLockedIn = true;
                        GameStatusLabel.Content = "All players have picked!";
                        if (configType != null)
                            counter = configType.PostPickTimerDuration - 2;
                        else
                            counter = 10;
                    }
                    else if (champDto.GameState == "START_REQUESTED")
                    {
                        GameStatusLabel.Content = "The game is about to start!";
                        DodgeButton.IsEnabled = false; //Cannot dodge past this point!
                        counter = 1;
                    }
                    else if (champDto.GameState == "TERMINATED")
                    {
                        var pop = new NotifyPlayerPopup("Player Dodged", "Player has Dodged Queue.")
                        {
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment = VerticalAlignment.Bottom
                        };
                        Client.CurrentPage = previousPage;
                        Client.HasPopped = false;
                        Client.ReturnButton.Content = "Return to Lobby Page";
                        Client.ReturnButton.Visibility = Visibility.Visible;
                        Client.inQueueTimer.Visibility = Visibility.Visible;
                        Client.NotificationGrid.Children.Add(pop);
                        Client.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived;
                        //Client.OnFixChampSelect -= ChampSelect_OnMessageReceived;
                        Client.GameStatus = "inQueue";
                        Client.SetChatHover();
                        Client.SwitchPage(previousPage);
                        Client.ClearPage(typeof(ChampSelectPage));

                    }

                    #region Display players

                    BlueListView.Items.Clear();
                    PurpleListView.Items.Clear();
                    BlueListView.Items.Refresh();
                    PurpleListView.Items.Refresh();
                    int i = 0;
                    bool purpleSide = false;

                    //Aram hack, view other players champions & names (thanks to Andrew)
                    var otherPlayers = new List<PlayerChampionSelectionDTO>(champDto.PlayerChampionSelections.ToArray());
                    AreWePurpleSide = false;

                    foreach (Participant participant in allParticipants)
                    {
                        Participant tempParticipant = participant;
                        i++;
                        var control = new ChampSelectPlayer();
                        //Cast AramPlayers as PlayerParticipants. This removes reroll data
                        if (tempParticipant is AramPlayerParticipant)
                        {
                            tempParticipant = (PlayerParticipant)tempParticipant;
                        }

                        if (tempParticipant is PlayerParticipant)
                        {
                            var player = tempParticipant as PlayerParticipant;
                            if (!string.IsNullOrEmpty(player.SummonerName))
                            {
                                control.PlayerName.Content = player.SummonerName;
                                control.sumName = player.SummonerName;
                            }
                            else
                            {
                                try
                                {
                                    AllPublicSummonerDataDTO summoner =
                                        await RiotCalls.GetAllPublicSummonerDataByAccount(player.SummonerId);
                                    if (summoner.Summoner != null && !string.IsNullOrEmpty(summoner.Summoner.Name))
                                        control.PlayerName.Content = summoner.Summoner.Name;
                                    else
                                        control.PlayerName.Content = "Unknown Player";
                                }
                                catch
                                {
                                    control.PlayerName.Content = "Unknown Player";
                                }
                            }

                            foreach (PlayerChampionSelectionDTO selection in champDto.PlayerChampionSelections)
                            {
                                #region Disable picking selected champs

                                PlayerChampionSelectionDTO selection1 = selection;
                                foreach (ListViewItem y in championArray.Where(y => (int)y.Tag == selection1.ChampionId))
                                {
                                    y.IsHitTestVisible = true;
                                    y.Opacity = 0.5;
                                    if (configType == null)
                                        continue;

                                    if (!configType.DuplicatePick)
                                        continue;

                                    y.IsHitTestVisible = false;
                                    y.Opacity = 1;
                                }

                                foreach (ListViewItem y in championArray.Where(y => disabledCharacters.Contains((int)y.Tag)))
                                {
                                    y.Opacity = .7;
                                    y.IsHitTestVisible = false;
                                }

                                #endregion Disable picking selected champs

                                if (selection.SummonerInternalName != player.SummonerInternalName)
                                    continue;

                                //Clear our teams champion selection for aram hack
                                otherPlayers.Remove(selection);
                                control = RenderPlayer(selection, player);
                                //If we have locked in render skin select
                                if (!HasLockedIn ||
                                    selection.SummonerInternalName !=
                                    Client.LoginPacket.AllSummonerData.Summoner.InternalName || (Client.Dev && champDto.MapId != 12))
                                    continue;

                                if (purpleSide)
                                    AreWePurpleSide = true;

                                RenderLockInGrid(selection);
                                if (player.PointSummary == null)
                                    continue;

                                LockInButton.Content = string.Format("Reroll ({0}/{1})",
                                    player.PointSummary.CurrentPoints, player.PointSummary.PointsCostToRoll);
                                LockInButton.IsEnabled = player.PointSummary.NumberOfRolls > 0;
                            }
                        }
                        else if (tempParticipant is ObfuscatedParticipant)
                        {
                            control.PlayerName.Content = "Summoner " +
                                                         ((tempParticipant as ObfuscatedParticipant).GameUniqueId -
                                                          ((tempParticipant as ObfuscatedParticipant).GameUniqueId > 5
                                                              ? 5
                                                              : 0));
                        }
                        else if (tempParticipant is BotParticipant)
                        {
                            var bot = tempParticipant as BotParticipant;
                            if (bot.SummonerInternalName.Contains('_'))
                            {
                                string botChamp = bot.SummonerInternalName.Split('_')[1]; //Why is this internal name rito?
                                champions botSelectedChamp = champions.GetChampion(botChamp);
                                var part = new PlayerParticipant();
                                var selection = new PlayerChampionSelectionDTO
                                {
                                    ChampionId = botSelectedChamp.id
                                };
                                part.SummonerName = botSelectedChamp.displayName + " bot";
                                control = RenderPlayer(selection, part);
                            }
                            else
                            {
                                control.PlayerName.Content = "Bot";
                                control.sumName = "Bot";
                            }
                        }
                        else
                            control.PlayerName.Content = "Unknown Summoner";

                        //Display purple side if we have gone through our team
                        if (i > champDto.TeamOne.Count)
                        {
                            i = 0;
                            purpleSide = true;
                        }

                        if (!purpleSide)
                            BlueListView.Items.Add(control);
                        else
                            PurpleListView.Items.Add(control);
                    }

                    //Do aram hack!
                    if (otherPlayers.Count <= 0)
                        return;

                    if (AreWePurpleSide)
                        BlueListView.Items.Clear();
                    else
                        PurpleListView.Items.Clear();

                    foreach (PlayerChampionSelectionDTO hackSelection in otherPlayers)
                    {
                        var player = new PlayerParticipant
                        {
                            SummonerName = hackSelection.SummonerInternalName
                        };
                        ChampSelectPlayer control = RenderPlayer(hackSelection, player);
                        if (AreWePurpleSide)
                            BlueListView.Items.Add(control);
                        else
                            PurpleListView.Items.Add(control);
                    }

                    #endregion Display players
                }));

                #endregion In Champion Select
            }
            else if (message is PlayerCredentialsDto)
            {
                Client.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived;

                #region Launching Game

                var dto = message as PlayerCredentialsDto;
                Client.CurrentGame = dto;

                if (HasLaunchedGame)
                    return;

                HasLaunchedGame = true;


                if (Settings.Default.AutoRecordGames)
                {
                    Dispatcher.InvokeAsync(async () =>
                    {
                        PlatformGameLifecycleDTO n =
                            await
                                RiotCalls.RetrieveInProgressSpectatorGameInfo(
                                    Client.LoginPacket.AllSummonerData.Summoner.Name);
                        if (n.GameName != null)
                        {
                            string ip = n.PlayerCredentials.ObserverServerIp + ":" +
                                        n.PlayerCredentials.ObserverServerPort;
                            string key = n.PlayerCredentials.ObserverEncryptionKey;
                            var gameId = (int)n.PlayerCredentials.GameId;
                            new ReplayRecorder(ip, gameId, Client.Region.InternalName, key);
                        }
                    });
                }
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    if (CountdownTimer != null)
                        CountdownTimer.Stop();

                    InGame();
                    Client.ReturnButton.Visibility = Visibility.Hidden;
                    if (!Settings.Default.DisableClientSound)
                    {
                        Client.AmbientSoundPlayer.Stop();
                    }
                }));

                #endregion Launching Game
            }
            else if (message is TradeContractDTO)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    var tradeDto = message as TradeContractDTO;
                    if (tradeDto == null)
                        return;

                    switch (tradeDto.State)
                    {
                        case "PENDING":
                            {
                                PlayerTradeControl.Visibility = Visibility.Visible;
                                PlayerTradeControl.Tag = tradeDto;
                                PlayerTradeControl.AcceptButton.Visibility = Visibility.Visible;
                                PlayerTradeControl.DeclineButton.Content = "Decline";

                                champions myChampion = champions.GetChampion((int)tradeDto.ResponderChampionId);
                                PlayerTradeControl.MyChampImage.Source = myChampion.icon;
                                PlayerTradeControl.MyChampLabel.Content = myChampion.displayName;
                                champions theirChampion = champions.GetChampion((int)tradeDto.RequesterChampionId);
                                PlayerTradeControl.TheirChampImage.Source = theirChampion.icon;
                                PlayerTradeControl.TheirChampLabel.Content = theirChampion.displayName;
                                PlayerTradeControl.RequestLabel.Content = string.Format("{0} wants to trade!",
                                    tradeDto.RequesterInternalSummonerName);
                            }
                            break;
                        case "BUSY":
                        case "DECLINED":
                        case "CANCELED":
                            {
                                PlayerTradeControl.Visibility = Visibility.Hidden;

                                TextInfo text = new CultureInfo("en-US", false).TextInfo;
                                var pop = new NotificationPopup(ChatSubjects.INVITE_STATUS_CHANGED,
                                    string.Format("{0} has {1} this trade", tradeDto.RequesterInternalSummonerName,
                                        text.ToTitleCase(tradeDto.State)));

                                if (tradeDto.State == "BUSY")
                                    pop.NotificationTextBox.Text = string.Format("{0} is currently busy",
                                        tradeDto.RequesterInternalSummonerName);

                                pop.Height = 200;
                                pop.OkButton.Visibility = Visibility.Visible;
                                pop.HorizontalAlignment = HorizontalAlignment.Right;
                                pop.VerticalAlignment = VerticalAlignment.Bottom;
                                Client.NotificationGrid.Children.Add(pop); //*/
                            }
                            break;
                    }
                }));
            }
        }
        public void report_status_fail()
        {
            try
            {
                List<string> Reqested = new List<string>();
                DataSet dp = DataBaseHandler.SelectQuery("select * from tbl_AccountReport where ModuleName ='" + "FollowModule" + "' and Status='" + "requested" + "'", "tbl_AccountReport");
                foreach (DataRow dp_item in dp.Tables[0].Rows)
                {
                    string Photo_Id = dp_item.ItemArray[5].ToString();
                    Reqested.Add(Photo_Id);
                    Reqested = Reqested.Distinct().ToList();
                }
                int summ = dp.Tables[0].Rows.Count;
                DataTable dt1 = dp.Tables[0];
                Dispatcher.Invoke(new Action(delegate
                {
                    if (Reqested.Count != 0)
                    {
                        No_Follower_Requested_Follow_count.Foreground = Brushes.Green;
                    }
                    No_Follower_Requested_Follow_count.Content = Reqested.Count;
                }));
            }
            catch(Exception ex)
            {

            }
        }
        private void taskText_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (_updating == null)
                {
                    _taskList.Add(new Task(taskText.Text.Trim()));
                }
                else
                {
                    _taskList.Update(_updating, new Task(taskText.Text.Trim()));
                    _updating = null;
                }

                taskText.Text = "";
                FilterAndSort(_currentSort);

                Intellisense.IsOpen = false;
                return;
            }

            if (Intellisense.IsOpen && !IntellisenseList.IsFocused)
            {
                switch (e.Key)
                {
                    case Key.Down:
                        IntellisenseList.Focus();
                        Keyboard.Focus(IntellisenseList);
                        IntellisenseList.SelectedIndex = 0;
                        break;
                    case Key.Escape:
                    case Key.Space:
                        Intellisense.IsOpen = false;
                        break;
                    default:
                        var word = FindIntelliWord();
                        IntellisenseList.Items.Filter = (o) => o.ToString().Contains(word);

                        break;
                }
            }
            else
            {
                switch (e.Key)
                {
                    case Key.Enter:
                        if (_updating == null)
                        {
                            _taskList.Add(new Task(taskText.Text.Trim()));
                        }
                        else
                        {
                            _taskList.Update(_updating, new Task(taskText.Text.Trim()));
                            _updating = null;
                        }

                        taskText.Text = "";
                        FilterAndSort(_currentSort);
                        break;
                    case Key.Escape:
                        _updating = null;
                        taskText.Text = "";
                        this.lbTasks.Focus();
                        break;
                    case Key.OemPlus:
                        List<string> projects = new List<string>();
                        foreach (var task in _taskList.Tasks)
                            projects = projects.Concat(task.Projects).ToList();

                        var pos = taskText.CaretIndex;
                        ShowIntellisense(projects.Distinct().OrderBy(s => s), taskText.GetRectFromCharacterIndex(pos));
                        break;
                    case Key.D2:
                        List<string> contexts = new List<string>();
                        foreach (var task in _taskList.Tasks)
                            contexts = contexts.Concat(task.Contexts).ToList();

                        pos = taskText.CaretIndex;
                        ShowIntellisense(contexts.Distinct().OrderBy(s => s), taskText.GetRectFromCharacterIndex(pos));
                        break;
                }
            }
        }
Beispiel #21
0
        void InitSendCollection(bool isAll)
        {
            try
            {

                SendCollection.Clear();
                List<string> list = new List<string>();

                if (isAll == false) //只显示一周内的
                {

                    DateTime dt = DateTime.Now.AddDays(-7);
                    list = visaORM.SendInfo.Where(s => s.FCreateDate > dt).OrderByDescending(s => s.FID).Select(s => s.FSendNo).ToList();
                }
                else //显示所有的
                {
                    list = visaORM.SendInfo.OrderByDescending(s => s.FID).Select(s => s.FSendNo).ToList();
                }

                foreach (string sString in list.Distinct())
                {
                    SendCollection.Add(sString);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.WriteLog.WriteErorrLog(ex);
            }
        }
        private void loadRoles()
        {
            RoleHelper client = new RoleHelper();
            List<Role> r = client.ViewRole(user, event_).ToList<Role>();
            client.Close();
            List<string> str_r = new List<string>();
            for (int j = 0; j < r.Count; j++)
            {
                str_r.Add(r[j].Post);
            }
            str_r = str_r.Distinct<string>().ToList<string>();
            int[] r_count = new int[str_r.Count];

            for (int k = 0; k < str_r.Count; k++)
            {
                for (int l = 0; l < r.Count; l++)
                {
                    if (str_r[k] == r[l].Post)
                    {
                        r_count[k]++;
                    }
                }
            }

            txtManpowerMsg.Text = "";
            if (str_r.Count > 0)
            {
                for (int i = 0; i < str_r.Count; i++)
                {
                    txtManpowerMsg.Text = r_count[i].ToString() + " " + str_r[i].ToString() + Environment.NewLine + txtManpowerMsg.Text;
                }
            }
            else
            {
                txtManpowerMsg.Text = "No Manpower have been added yet";
            }
        }
        public void SetData(Models.ClusterTable clusterTable)
        {
            this.clusterTable = clusterTable;
            graphManage.Clear();
            nodeDic.Clear();
            categoryDic.Clear();
            useridDic.Clear();
            linkList.Clear();
            relationDataList.Clear();
            isNewGraph = true;

            List<int> userList = new List<int>();
            foreach (var item in clusterTable.Categories)
            {                
                var node = graphManage.CreateNode(item.GetName(viewCategoryCount), new Point(), Colors.Blue);
                node.Node.Size = new Size(20, 20);
                node.CanRemove = false;
                node.Tag = item;
                node.Node.NodeSubText = "("+item.GetCount().ToString() + ")";
                node.Node.SubLabelVisibility = subCountTextVisibility;
                node.NodeMouseDown += new MouseButtonEventHandler(node_NodeMouseDown);
                categoryDic.Add(item.GetName(), item);
                nodeDic.Add(item, node);
                useridDic.Add(item, new List<int>());
                foreach (var item2 in item.Layer)
                {
                    foreach (var item3 in item2.Value.Comunities)
                    {
                        if (item3.Deleted == false && item3.UserIds != null)
                        {
                            useridDic[item].AddRange(item3.UserIds);
                        }
                    }
                }
                useridDic[item] = useridDic[item].Distinct().ToList();
                userList.AddRange(useridDic[item]);
            }
            userList = userList.Distinct().ToList();

            foreach (var item in clusterTable.Categories)
            {
                foreach (var item2 in clusterTable.Categories.SkipWhile(n => n != item).Where(n => n != item))
                {
                    var link = graphManage.CreateLink(nodeDic[item].Node, nodeDic[item2].Node);
                    link.Visibility = Visibility.Collapsed;
                    link.SortKey = MyWpfLib.Graph.Sort.Jaccard(useridDic[item].Intersect(useridDic[item2]).Count(), useridDic[item].Count, useridDic[item2].Count);
                    link.Tag = MyWpfLib.Graph.Sort.信頼度比(useridDic[item].Intersect(useridDic[item2]).Count(), useridDic[item].Count, useridDic[item2].Count, userList.Count);
                    //  link.SortKey = MyWpfLib.Graph.Sort.MutualInformation(useridDic[item].Intersect(useridDic[item2]).Count(), useridDic[item].Count, useridDic[item2].Count,userList.Count);
                    link.TextValue = link.SortKey.ToString("F3");
                    link.TextVisibility = linkTextVisibility;
                    linkList.Add(link);

                    relationDataList.Add(new RelationData()
                    {
                        NameA = nodeDic[item].Node.NodeName,
                        NameB = nodeDic[item2].Node.NodeName,
                        Jaccard = link.SortKey,
                        信頼度比 = MyWpfLib.Graph.Sort.信頼度比(useridDic[item].Intersect(useridDic[item2]).Count(), useridDic[item].Count, useridDic[item2].Count, userList.Count),
                        Parent = this
                    });
                }
            }
            allCount = userList.Count;
            linkList = linkList.OrderByDescending(n => n.SortKey).ToList();
            graphManage.Update();
        }
Beispiel #24
0
		private void taskText_PreviewKeyUp(object sender, KeyEventArgs e)
		{
			if (_taskList == null)
			{
				MessageBox.Show("You don't have a todo.txt file open - please use File\\New or File\\Open",
					"Please open a file", MessageBoxButton.OK, MessageBoxImage.Error);
				e.Handled = true;
				lbTasks.Focus();
				return;
			}

			if (e.Key == Key.Enter)
			{
				if (_updating == null)
				{
					try
					{
						var taskDetail = taskText.Text.Trim();

						if (User.Default.AddCreationDate)
						{
							var tmpTask = new Task(taskDetail);
							var today = DateTime.Today.ToString("yyyy-MM-dd");

							if (string.IsNullOrEmpty(tmpTask.CreationDate))
							{
								if (string.IsNullOrEmpty(tmpTask.Priority))
									taskDetail = today + " " + taskDetail;
								else
									taskDetail = taskDetail.Insert(tmpTask.Priority.Length, " " + today);
							}
						}
						_taskList.Add(new Task(taskDetail));
					}
					catch (TaskException ex)
					{
						MessageBox.Show(ex.Message);
					}
				}
				else
				{
					_taskList.Update(_updating, new Task(taskText.Text.Trim()));
					_updating = null;
				}

				taskText.Text = "";
				FilterAndSort(_currentSort);

				Intellisense.IsOpen = false;
				lbTasks.Focus();

				return;
			}

			if (Intellisense.IsOpen && !IntellisenseList.IsFocused)
			{
				if (taskText.CaretIndex <= _intelliPos) // we've moved behind the symbol, drop out of intellisense
				{
					Intellisense.IsOpen = false;
					return;
				}

				switch (e.Key)
				{
					case Key.Down:
						IntellisenseList.Focus();
						Keyboard.Focus(IntellisenseList);
						IntellisenseList.SelectedIndex = 0;
						break;
					case Key.Escape:
					case Key.Space:
						Intellisense.IsOpen = false;
						break;
					default:
						var word = FindIntelliWord();
						IntellisenseList.Items.Filter = (o) => o.ToString().Contains(word);
						break;
				}
			}
			else
			{
				switch (e.Key)
				{
					case Key.Escape:
						_updating = null;
						taskText.Text = "";
						this.lbTasks.Focus();
						break;
					case Key.OemPlus:
						List<string> projects = new List<string>();
						_taskList.Tasks.Each(task => projects = projects.Concat(task.Projects).ToList());

						_intelliPos = taskText.CaretIndex - 1;
						ShowIntellisense(projects.Distinct().OrderBy(s => s), taskText.GetRectFromCharacterIndex(_intelliPos));
						break;
					case Key.D2:
						List<string> contexts = new List<string>();
						_taskList.Tasks.Each(task => contexts = contexts.Concat(task.Contexts).ToList());

						_intelliPos = taskText.CaretIndex - 1;
						ShowIntellisense(contexts.Distinct().OrderBy(s => s), taskText.GetRectFromCharacterIndex(_intelliPos));
						break;
				}
			}
		}
        /// <summary>
        /// Solve the puzzle and output the found words to the results pane.
        /// </summary>
        private void Solve()
        {
            // Get distinct characters entered into TextBoxes
            HashSet<char> enteredCharacters = new HashSet<char>(_textboxes.SelectMany(textBox => textBox.Text).Distinct());

            // Filter words by the entered characters
            var filteredWords = _allWords.Where(word => word.ToCharArray().Distinct().All(character => enteredCharacters.Contains(character)));
            Trie filteredLexicon = new Trie(filteredWords);

            List<string> foundWords = new List<string>();
            for (int i = 0; i < 16; i++)
            {
                bool[] visited = new bool[16];
                FindWords(i, string.Empty, visited, filteredLexicon, foundWords);
            }

            var words = foundWords.Distinct().OrderByDescending(w => w.Length);
            txtResults.Text = string.Format("Found {0} words:" + Environment.NewLine, words.Count());
            txtResults.Text += string.Join(Environment.NewLine, words);
        }
Beispiel #26
0
        // TODO: Move to API?
        private async Task GetMissingRats(RootObject rescues)
        {
            IEnumerable<string> ratIdsToGet = new List<string>();

            var datas = from d in rescues.data
                select d.rats;
            ratIdsToGet = datas.Aggregate(ratIdsToGet, (current, list) => current.Concat(list));
            ratIdsToGet = ratIdsToGet.Distinct().Except(Rats.Values.Select(x => x._Id));

            foreach (var ratId in ratIdsToGet)
            {
                var response = await apworker.queryAPI("rats", new Dictionary<string, string> { { "_id", ratId }, { "limit", "1" } });
                JObject jsonRepsonse = JObject.Parse(response);
                List<JToken> tokens = jsonRepsonse["data"].Children().ToList();
                var rat = JsonConvert.DeserializeObject<Rat>(tokens[0].ToString());
                Rats.TryAdd(ratId, rat);

                Console.WriteLine("Got name for " + ratId + ": " + rat.CmdrName);
            }
        }
        void _prjClient_GetEmployeeWorkCompleted(object sender, GetEmployeeWorkCompletedEventArgs e)
        {
            DateTime _today = DateTime.Today;
            DateTime _yesterday = DateTime.Today.AddDays(-1);
            List<int> _recentUsedTaskID = new List<int>();
            Dictionary<int, string> _recentUsedComments = new Dictionary<int, string>();
            foreach (WorkUnit u in e.Result.GetEmployeeWorkResult.Return.OrderBy(w => w.StartDateTime))
            {
                _recentUsedTaskID.Add(u.TaskID);
                if (!String.IsNullOrWhiteSpace(u.Description))
                {
                    _recentUsedComments[u.TaskID] = u.Description;
                }

                if (u.StartDateTime.Date == _today) {
                    App.RegistrationViewModel.TodayRegistrations.Add(u);
                }
                if (u.StartDateTime.Date == _yesterday)
                {
                    App.RegistrationViewModel.YesterdayRegistrations.Add(u);
                }

            }

            _RecentTasks.Clear();
            foreach (int taskID in _recentUsedTaskID.Distinct())
            {
                var _task = this._allTasks.FirstOrDefault(t => t.ID == taskID);
                if (_task != null) _RecentTasks.Add(_task);
            }
            using (Database db = new Database())
            {
                if (db.DatabaseExists() == false)
                {
                    // Create the database.
                    db.CreateDatabase();
                }

                foreach (var _usedTask in _RecentTasks) 
                { 
                    var taskInDB = from WPTask t in db.tasksTable where t.ID == _usedTask.ID 
                                   select t;

                    foreach (var t in taskInDB) {
                        t.RecentUsed = true;
                        string _comment;
                        if (_recentUsedComments.TryGetValue(t.ID, out _comment))
                        {
                            t.RecentComment = _comment;
                        }                         
                    }
                }
                db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
            }
            
            IsDataLoaded = true;
            LoadInProgress = false;
        }
Beispiel #28
0
        private void Button32_OnClick(object sender, RoutedEventArgs e)
        {
            var retstr = "";
            var plist = new List<string>();
            var dlist = 用户管理.查询用户<单位用户>(0, 0);
            foreach (var d in dlist)
            {
                if (d.联系方式.手机!=null)
                plist.Add(d.联系方式.手机);
            }
            plist.RemoveAll(o => o.Length < 10 || o.Contains("88888"));
            plist = plist.Distinct().ToList();
            foreach (var p in plist)
            {
                retstr += p + "\r\n";
            }

            textBox1.Text = retstr;
        }
        // Get all items for selected category from Database
        private void ComboBoxLoadMenuItem(object sender, RoutedEventArgs e)
        {
            List<string> data = new List<string>();
            try
            {
                string myConnection = @"provider=microsoft.jet.oledb.4.0;data source=..\..\Database\Menu.mdb";
                OleDbConnection myConn = new OleDbConnection(myConnection);

                // Open connection to database
                myConn.Open();
                string selectedType = this.MenuCategory.SelectedItem.ToString();
                string selectString = "SELECT Item FROM Menu WHERE Type='" + selectedType + "'";
                OleDbCommand createCommand = new OleDbCommand(selectString, myConn);
                createCommand.ExecuteNonQuery();
                OleDbDataAdapter dataAdp = new OleDbDataAdapter(createCommand);
                DataSet myDataSet = new DataSet();
                dataAdp.Fill(myDataSet, "Menu");
                int rowMax = myDataSet.Tables[0].Rows.Count;
                for (int n = 0; n < rowMax; n++)
                {
                    data.Add(myDataSet.Tables[0].Rows[n].ItemArray[0].ToString());
                }

                // Close connection to database
                myConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.MenuItem.ItemsSource = data.Distinct();
            this.MenuItem.SelectedIndex = 0;
        }
 public void report_status_fail()
 {
     try
     {
         List<string> list_photoId_fail = new List<string>();
         DataSet ds = DataBaseHandler.SelectQuery("select * from tbl_AccountReport where ModuleName ='" + "CommentModule" + "' and Status='" + "Fail" + "'", "tbl_AccountReport");
         foreach (DataRow ds_item in ds.Tables[0].Rows)
         {
             string Photo_Id = ds_item.ItemArray[3].ToString();
             list_photoId_fail.Add(Photo_Id);
             list_photoId_fail = list_photoId_fail.Distinct().ToList();
         }
         int sum = ds.Tables[0].Rows.Count;
         DataTable dt = ds.Tables[0];
         Dispatcher.Invoke(new Action(delegate
         {
             Acc_reportcomment_FailcommentPhoto.Content = list_photoId_fail.Count;
         }));
     }
     catch(Exception ex)
     {
         GlobusLogHelper.log.Error("Error:" + ex.StackTrace);
     }
 }