Example #1
1
        static void Main(string[] args)
        {
            var names = Regex.Split(Console.ReadLine(), "\\s+").ToList();
            var predicates = new Dictionary<string, Func<string, string, bool>>
            {
                { "StartsWith", (name, substring) => name.StartsWith(substring) },
                { "EndsWith", (name, substring) => name.EndsWith(substring) },
                { "Length", (name, length) => name.Length.ToString().Equals(length) }
            };

            string command;
            while ((command = Console.ReadLine()) != "Party!")
            {
                if (names.Count == 0)
                {
                    break;
                }

                var parameters = Regex.Split(command, "\\s+");

                var action = parameters[0];
                var condition = parameters[1];
                var conditionOperator = parameters[2];

                var filteredNames = new List<string>();
                foreach (string name in names)
                {
                    if (predicates[condition](name, conditionOperator))
                    {
                        switch (action)
                        {
                            case "Double":
                                filteredNames.Add(name);
                                filteredNames.Add(name);
                                break;
                            case "Remove":
                                // Not adding jack.
                                break;
                            default:
                                throw new NotImplementedException();
                        }
                    }
                    else
                    {
                        filteredNames.Add(name);
                    }
                }

                names = filteredNames.ToList();
            }

            if (names.Count != 0)
            {
                Console.WriteLine($"{string.Join(", ", names)} are going to the party!");
            }
            else
            {
                Console.WriteLine("Nobody is going to the party!");
            }
        }
Example #2
0
 public static List<List<TimeSpan>> GenerateListOfTimeSpan(List<List<TimeSpan>> MyEncasingList)
 {
     //Trying To Spread out arrray
     List<List<TimeSpan>> ListOfList = new List<List<TimeSpan>>();
     List<List<TimeSpan>> ListOfListCopy = ListOfList.ToList();
     int i = 0;
     for (i = 0; i < MyEncasingList.Count; i++)
     {
         ListOfListCopy = ListOfList.ToList();
         List<List<TimeSpan>> UpdatedListOfList = new List<List<TimeSpan>>();
         foreach (TimeSpan MyTimeSpan in MyEncasingList[i])//ListOfList.CopyTo(MyOtherArray);
         {
             //Console.WriteLine("other {0}\n", MyNumber);
             if (ListOfListCopy.Count == 0)
             {
                 UpdatedListOfList.Add(CreateNewListAndAppend(MyTimeSpan, new List<TimeSpan>()));
             }
             foreach (List<TimeSpan> MyUpdatedSingleList in ListOfListCopy)
             {
                 UpdatedListOfList.Add(CreateNewListAndAppend(MyTimeSpan, MyUpdatedSingleList));
             }
         }
         ListOfList = UpdatedListOfList;
     }
     return ListOfList;
 }
Example #3
0
        public static List<List<SubCalendarEvent>> GenerateListOfSubCalendarEvent(List<List<SubCalendarEvent>> MyEncasingList)
        {
            //Trying To Spread out arrray
            List<List<SubCalendarEvent>> ListOfList = new List<List<SubCalendarEvent>>();
            List<List<SubCalendarEvent>> ListOfListCopy = ListOfList.ToList();
            int i = 0;
            for (i = 0; i < MyEncasingList.Count; i++)
            {
                ListOfListCopy = ListOfList.ToList();
                List<List<SubCalendarEvent>> UpdatedListOfList = new List<List<SubCalendarEvent>>();
                foreach (SubCalendarEvent MySubCalendarEvent in MyEncasingList[i])//ListOfList.CopyTo(MyOtherArray);
                {
                    //Console.WriteLine("other {0}\n", MyNumber);
                    if (ListOfListCopy.Count == 0)
                    {
                        UpdatedListOfList.Add(CreateNewListAndAppend(MySubCalendarEvent, new List<SubCalendarEvent>()));
                    }
                    foreach (List<SubCalendarEvent> MyUpdatedSingleList in ListOfListCopy)
                    {
                        if (!isSubCalendarEventAlreadyInList(MySubCalendarEvent, MyUpdatedSingleList))
                        {
                            UpdatedListOfList.Add(CreateNewListAndAppend(MySubCalendarEvent, MyUpdatedSingleList));
                        }

                    }
                }
                ListOfList = UpdatedListOfList;
            }
            return ListOfList;
        }
Example #4
0
        static void Test1()
        {
            FleckLog.Level = LogLevel.Debug;
            var allSockets = new List<IWebSocketConnection>();
            var server = new WebSocketServer("ws://localhost:8181");
            server.Start(socket =>
                {
                    socket.OnOpen = () =>
                        {
                            Console.WriteLine("Open!");
                            allSockets.Add(socket);
                        };
                    socket.OnClose = () =>
                        {
                            Console.WriteLine("Close!");
                            allSockets.Remove(socket);
                        };
                    socket.OnMessage = message =>
                        {
                            Console.WriteLine(message);
                            allSockets.ToList().ForEach(s => s.Send("Echo: " + message));
                        };
                });

            var input = Console.ReadLine();
            while (input != "exit")
            {
                foreach (var socket in allSockets.ToList())
                {
                    socket.Send(input);
                }
                input = Console.ReadLine();
            }
        }
Example #5
0
        public void Start()
        {
            List<IWebSocketConnection> sockets = new List<IWebSocketConnection>();
            Fleck.WebSocketServer server = new Fleck.WebSocketServer("ws://127.0.0.1:8181");

            server.Start(socket =>
                {
                    socket.OnOpen = () =>
                        {
                            Console.WriteLine("Connection open.");
                            sockets.Add(socket);
                        };
                    socket.OnClose = () =>
                        {
                            Console.WriteLine("Connection closed.");
                            sockets.Remove(socket);
                        };
                    socket.OnMessage = message =>
                        {
                            Console.WriteLine("Client says: " + message);
                            sockets.ToList().ForEach(s => s.Send(" client says:" + message));
                        };

                });

            string input = Console.ReadLine();
            while (input != "exit")
            {
                sockets.ToList().ForEach(s => s.Send(input));
                input = Console.ReadLine();
            }
        }
        public IList<Flight> ParseFlights(HtmlNode documentNode)
        {
            var element = documentNode.SelectNodes("//table[@class='resultTable dealsResults']/tbody//tr[position()>1]");

            IEnumerable<Flight> flights = new List<Flight>();

            if (element == null)
                return flights.ToList();

            flights = from row in element
                      where row.HasChildNodes
                      let departureAirport = row.ChildNodes[1].InnerText
                      let destination = row.ChildNodes[3].InnerText
                      let departureDate = row.ChildNodes[5].SelectSingleNode("ul/li").InnerText
                      let returnDate = row.ChildNodes[5].SelectSingleNode("ul/li[position()>1]").InnerText
                      let departFlightTime = row.ChildNodes[7].SelectSingleNode("ul/li/ul/li").InnerText
                      let returnFlightTime = row.ChildNodes[7].SelectSingleNode("ul/li[position()>1]/ul/li").InnerText
                      let noOfNights = row.ChildNodes[9].InnerText
                      let departureAirportCode = row.ChildNodes[13].SelectSingleNode("fieldset/input[@id='depAP']").GetAttributeValue("value", "N/a")
                      let arrivalAirportCode = row.ChildNodes[13].SelectSingleNode("fieldset/input[@id='retAP']").GetAttributeValue("value", "N/a")
                      let seats = row.SelectSingleNode("td[@class='seatsLeft']").ChildNodes.Count > 2 ? row.SelectSingleNode("td[@class='seatsLeft']/div").InnerText : "0"
                      select new Flight
                          {
                              DepartureAirport = new Airport { Code = departureAirportCode, Name = departureAirport },
                              ArrivalAirport = new Airport { Code = arrivalAirportCode, Name = destination },
                              ArrivalDate = (departureDate + " " + departFlightTime + ":00").ToFormattedDateString(),
                              SeatsLeft = seats.ToInt32(),
                              DepartureDate =(returnDate + " " + returnFlightTime + ":00").ToFormattedDateString(),
                              NoOfNights = noOfNights.ToInt32()
                          };

            return flights.ToList();
        }
        public CollectionQuerySimplification(List<object> coll)
        {
            var x = coll.Select(element => element as object).Any(element => element != null);  // Noncompliant use OfType
            x = coll.Select((element) => ((element as object))).Any(element => (element != null) && CheckCondition(element) && true);  // Noncompliant use OfType
            var y = coll.Where(element => element is object).Select(element => element as object); // Noncompliant use OfType
            var y = coll.Where(element => element is object).Select(element => element as object[]);
            y = coll.Where(element => element is object).Select(element => (object)element); // Noncompliant use OfType
            x = coll.Where(element => element == null).Any();  // Noncompliant use Any([expression])
            var z = coll.Where(element => element == null).Count();  // Noncompliant use Count([expression])
            z = Enumerable.Count(coll.Where(element => element == null));  // Noncompliant
            z = Enumerable.Count(Enumerable.Where(coll, element => element == null));  // Noncompliant
            y = coll.Select(element => element as object);
            y = coll.ToList().Select(element => element as object); // Noncompliant
            y = coll
                .ToList()  // Noncompliant
                .ToArray() // Noncompliant
                .Select(element => element as object);

            var z = coll
                .Select(element => element as object)
                .ToList();

            var c = coll.Count(); //Noncompliant
            c = coll.OfType<object>().Count();

            x = Enumerable.Select(coll, element => element as object).Any(element => element != null); //Noncompliant
            x = Enumerable.Any(Enumerable.Select(coll, element => element as object), element => element != null); //Noncompliant
        }
Example #8
0
 private static void gener(int num, int len)
 {
     StringBuilder k1 = new StringBuilder();
     for (int a = 0; a < len; a++)
     {
         k1.Append(num.ToString());
     }
     List<int> lst1 = new List<int>();
     List<List<int>> depo = new List<List<int>>();
     for (int a = 0; a < num; a++)
     {
         lst1.Add(a);
     }
     long k = long.Parse(k1.ToString());
     for (int a = 0; a < k; a++)
     {
         List<int> lst = new List<int>();
         for (int z = 0; z < a.ToString().Length; z++)
         {
             lst.Add(int.Parse(a.ToString().ToCharArray()[z].ToString()));
         }
         lst.Sort();
         bool ok = true;
         if (lst.ToList().Distinct().Count() == lst.ToList().Count())
         {
             for (int b = 0; b < lst.Count; b++)
             {
                 if (!lst1.Contains(lst[b]))
                 {
                     ok = false;
                 }
             }
             if (ok)
             {
                 bool ko = true;
                 for (int c = 0; c < depo.Count; c++)
                 {
                     if (lst == (depo[c]))
                     {
                         ko = false;
                     }
                 }
                 if (ko)
                 {
                     depo.Add(lst);
                 }
             }
         }
     }
     List<List<int>> depo1 = new List<List<int>>(depo.Distinct().ToList());
     for (int a = 0; a < depo1.Count; a++)
     {
         for (int b = 0; b < depo1[a].Count; b++)
         {
             Console.Write("{0} ", depo1[a][b]);
         }
         Console.WriteLine();
     }
 }
	public void WhenAddingParams_ThenAddsToList()
	{
		ICollection<int> ints = new List<int>(new[] { 1, 2, 3 });

		ints.AddRange(4, 5);

		Assert.Equal(4, ints.ToList()[3]);
		Assert.Equal(5, ints.ToList()[4]);
	}
Example #10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json; charset=utf-8";

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

            NFMT.User.BLL.CorporationBLL bll = new NFMT.User.BLL.CorporationBLL();
            result = bll.LoadAuthSelfCorp(user);

            List<NFMT.User.Model.Corporation> corps = new List<NFMT.User.Model.Corporation>();

            if (result.ResultStatus == 0)
            {
                corps = result.ReturnValue as List<NFMT.User.Model.Corporation>;
            }

            //合约过滤
            int contractId = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["ContractId"]))
                int.TryParse(context.Request.QueryString["ContractId"], out contractId);

            //合约抬头过滤
            IEnumerable<NFMT.User.Model.Corporation> ecs = new List<NFMT.User.Model.Corporation>();
            if (contractId > 0)
            {
                NFMT.Contract.BLL.ContractCorporationDetailBLL corpBLL = new NFMT.Contract.BLL.ContractCorporationDetailBLL();
                result = corpBLL.LoadCorpListByContractId(user, contractId,true);
                if (result.ResultStatus != 0)
                    context.Response.End();

                List<NFMT.Contract.Model.ContractCorporationDetail> contractCorps = result.ReturnValue as List<NFMT.Contract.Model.ContractCorporationDetail>;
                var corpIds = contractCorps.Select(c => c.CorpId).ToList();
                ecs = corps.Where(c => corpIds.Contains(c.CorpId));
                corps = ecs.ToList();
            }

            int subId = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["SubId"]))
                int.TryParse(context.Request.QueryString["SubId"], out subId);
            if (subId > 0)
            {
                NFMT.Contract.BLL.SubCorporationDetailBLL subCorpBLL = new NFMT.Contract.BLL.SubCorporationDetailBLL();
                result = subCorpBLL.Load(user, subId, true);
                if (result.ResultStatus != 0)
                    context.Response.End();

                List<NFMT.Contract.Model.SubCorporationDetail> subCorps = result.ReturnValue as List<NFMT.Contract.Model.SubCorporationDetail>;
                var corpIds = subCorps.Select(c => c.CorpId).ToList();
                ecs = corps.Where(c => corpIds.Contains(c.CorpId));
                corps = ecs.ToList();
            }

            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(corps);
            context.Response.Write(jsonStr);
        }
Example #11
0
        static void Main(string[] args)
        {
            FleckLog.Level = LogLevel.Info;
            var allsockets = new List<IWebSocketConnection>();
            var server = new WebSocketServer("ws://localhost:8181");

            server.Start(socket =>
            {
                socket.OnOpen = () =>
                    {   //See socket.ConnectionInfo.* for additional informations
                        Console.WriteLine(String.Empty);
                        Console.WriteLine("[NEW CLIENT CONNECTION]======================");
                        Console.WriteLine("GUID: " + socket.ConnectionInfo.Id);
                        Console.WriteLine("IP: " + socket.ConnectionInfo.ClientIpAddress);
                        Console.WriteLine("Port: " + socket.ConnectionInfo.ClientPort);
                        Console.WriteLine("=============================================");
                        Console.WriteLine(String.Empty);
                        allsockets.Add(socket);

                    };

                socket.OnClose = () =>
                {
                        Console.WriteLine(String.Empty);
                        Console.WriteLine("[DISCONNECTED CLIENT]=======================");
                        Console.WriteLine("GUID: " + socket.ConnectionInfo.Id);
                        Console.WriteLine("IP: " + socket.ConnectionInfo.ClientIpAddress);
                        Console.WriteLine("Port: " + socket.ConnectionInfo.ClientPort);
                        Console.WriteLine("=============================================");
                        Console.WriteLine(String.Empty);
                        allsockets.Remove(socket);
                    };

                socket.OnMessage = (message) =>
                {
                    //TODO: Json.Net Deserialize
                    Console.WriteLine("[JSON MESSAGE] " + message);
                    allsockets.ToList().ForEach(s => s.Send(message));
                };
            });

            var input = Console.ReadLine();
            while (input != "exit")
            {
                foreach (var socket in allsockets.ToList())
                {
                    socket.Send(input);
                }

                input = Console.ReadLine();
            }
        }
Example #12
0
        public int LoadFromCsv(string fileName, int tickerCode)
        {
            var storeThread = new DBStoreThread(true);
            var candles = new List<CandleData>();
            var totalStored = 0;

            using (var sr = new StreamReader(fileName, Encoding.GetEncoding(1252)))
            {
                while (!sr.EndOfStream)
                {
                    var line = sr.ReadLine();
                    if (string.IsNullOrEmpty(line)) continue;
                    var parts = line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
                    // date - time - o-h-l-c
                    if (parts.Length < 6) continue;
                    DateTime time;
                    if (!DateTime.TryParseExact(parts[0] + " " + parts[1],
                                                "yyyy.MM.dd HH:mm", CultureProvider.Common, DateTimeStyles.AssumeLocal,
                                                out time))
                        continue;
                    var open = parts[2].ToFloatUniformSafe() ?? 0;
                    var high = parts[3].ToFloatUniformSafe() ?? 0;
                    var low = parts[4].ToFloatUniformSafe() ?? 0;
                    var close = parts[5].ToFloatUniformSafe() ?? 0;

                    if (open == 0 || high == 0 || low == 0 || close == 0) continue;
                    candles.Add(new CandleData(open, high, low, close, time, time.AddMinutes(1)));
                    if (candles.Count > BufferSize)
                    {
                        storeThread.PushQuotes(new Dictionary<int, List<CandleData>>
                            { { tickerCode, candles.ToList() } });
                        totalStored += candles.Count;
                        candles.Clear();
                    }
                }
                totalStored += candles.Count;
                if (candles.Count > 0)
                    storeThread.PushQuotes(new Dictionary<int, List<CandleData>>
                        { {tickerCode, candles.ToList()} });
            }

            while (storeThread.CandlesLeftInQueue > 0)
            {
                Thread.Sleep(200);
            }
            storeThread.Stop();

            return totalStored;
        }
 public void Initialise(IEnumerable<IRiakNode> nodes)
 {
     _nodes = nodes.ToList();
     var list = _nodes.ToList();
     _generator = () => list;
     _roundRobin = new ConcurrentEnumerable<IRiakNode>(RoundRobin()).GetEnumerator();
 }
        static void Main(string[] args)
        {
            Console.Write("Write a sequence of numbers, separated by spaces: ");
            string input = Console.ReadLine();
            List<int> listOfNums = new List<int>();

            try
            {
                listOfNums = (new List<string>(Regex.Split(input, @"\s+"))).Select(s => int.Parse(s)).ToList();
            }
            catch (FormatException)
            {
                Console.WriteLine("The input must contain at least 1 number.");
                return;
            }

            List<int> outputListOfNums = listOfNums.ToList();

            foreach (int num in listOfNums)
            {
                int count = listOfNums.Where(x => x.Equals(num)).Count();

                if (count % 2 != 0)
                {
                    outputListOfNums.RemoveAll(x => x == num);
                }
            }

            Console.WriteLine(string.Join(" ", outputListOfNums));
        }
Example #15
0
        public IEnumerable<Navbar> navbarItems()
        {
            var menu = new List<Navbar>();
            //menu.Add(new Navbar { Id = 1, nameOption = "Home Page", controller = "Home", action = "Index", imageClass = "fa fa-institution", status = true, isParent = false, parentId = 0 });
            //menu.Add(new Navbar { Id = 2, nameOption = "Analytic Tools", imageClass = "glyphicon glyphicon-leaf", status = true, isParent = true, parentId = 0 });
            //menu.Add(new Navbar { Id = 3, nameOption = "Biological Index", controller = "Home", action = "FlotCharts", status = true, isParent = false, parentId = 2 });
            //menu.Add(new Navbar { Id = 4, nameOption = "Oceanographic Parameters", controller = "Home", action = "MorrisCharts", status = true, isParent = false, parentId = 2 });
            //menu.Add(new Navbar { Id = 4, nameOption = "Upwelling Index", controller = "Home", action = "UpwellingIndex", status = true, isParent = false, parentId = 2 });
            //menu.Add(new Navbar { Id = 5, nameOption = "Elevation Profile Tool", controller = "Home", action = "Tables", imageClass = "fa fa-line-chart fa-1", status = true, isParent = false, parentId = 0 });
            //menu.Add(new Navbar { Id = 6, nameOption = "Comparative Tool", controller = "Home", action = "Forms", imageClass = "glyphicon glyphicon-resize-horizontal", status = true, isParent = false, parentId = 0 });
            //menu.Add(new Navbar { Id = 7, nameOption = "UI Elements", imageClass = "fa fa-wrench fa-fw", status = true, isParent = true, parentId = 0 });
            //menu.Add(new Navbar { Id = 8, nameOption = "Panels and Wells", controller = "Home", action = "Panels", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 9, nameOption = "Buttons", controller = "Home", action = "Buttons", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 10, nameOption = "Notifications", controller = "Home", action = "Notifications", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 11, nameOption = "Typography", controller = "Home", action = "Typography", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 12, nameOption = "Icons", controller = "Home", action = "Icons", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 13, nameOption = "Grid", controller = "Home", action = "Grid", status = true, isParent = false, parentId = 7 });

            menu.Add(new Navbar { Id = 1, nameOption = "Home Page", controller = "Home", action = "Index", imageClass = "fa fa-institution", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 2, nameOption = "Bathymetry  GIS mapping and transects", controller = "Home", action = "BathymetricTransects", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 3, nameOption = "CCLME Upwelling index", controller = "Home", action = "UpwellingIndex", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 4, nameOption = "Precipitation and river discharges", controller = "Home", action = "PrecipitationDischarges", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 5, nameOption = "Tide gauge graphs", controller = "Home", action = "TideGauge", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 6, nameOption = "Argo Profiles (3D)", controller = "Home", action = "Argo3D", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 7, nameOption = "GIS SST and Chl data and anomaly analysis", controller = "Home", action = "OceanographicAnomalies", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 8, nameOption = "Spatio-temporal data Viewer: SST, Chl, PSU", controller = "Home", action = "SpatioTemporalViewer", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 9, nameOption = "Oceanographic transects", controller = "Home", action = "OceanographicTransects", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 10, nameOption = "Biological data: abundance, distribution, species richness", controller = "Home", action = "BiologicalData", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 11, nameOption = "Using my own data", controller = "Home", action = "UsingOwnData", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 12, nameOption = "Interpolation tools for GIS", controller = "Home", action = "InterpolationTools", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 13, nameOption = "Time series analysis", controller = "Home", action = "TimeSeries", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 14, nameOption = "Reports", controller = "Home", action = "Tables", status = true, isParent = false, parentId = 0 });
            return menu.ToList();
        }
Example #16
0
        internal static MethodInvoker Create(MethodInfo method, object target)
        {

            var args = new List<Type>(method.GetParameters().Select(p => p.ParameterType));
            Type delegateType;

            var returnMethodInvoker = new MethodInvoker
            {
                ParameterTypeList = args.ToList(),
                ParameterCount = args.Count,
                ReturnType = method.ReturnType,
                MethodName = method.Name
            };


            if (method.ReturnType == typeof(void))
            {
                delegateType = Expression.GetActionType(args.ToArray());
            }
            else
            {
                args.Add(method.ReturnType);
                delegateType = Expression.GetFuncType(args.ToArray());
            }

            returnMethodInvoker.MethodDelegate = method.CreateDelegate(delegateType, target);

            return returnMethodInvoker;

        }
        public MainPage()
        {
            InitializeComponent();

            var strings = new List<string>
                    {
                        "Hello",
                        "Hello world",
                        "Hello world Hello world",
                        "Hello world Hello world Hello world",
                        "Hello world Hello world Hello world \nHello world",
                        "Hello world Hello world Hello world \nHello world Hello world",
                        "Hello world Hello world Hello world \nHello world Hello world \nHello world",
                    };

            for (var i = 0; i < 3; i++)
            {
                strings.AddRange(strings);
            }

            Items = strings.ToList();

            GroupedItems = Items.GroupBy(d => "Group 1").Union(Items.GroupBy(d => "Group 2")).ToList();

            DataContext = this;
        }
Example #18
0
 // GET: /Reports/
 public ActionResult Index()
 {
     List<SalaryPeriodEntity>lstSalaryPeriod=new List<SalaryPeriodEntity>();
     lstSalaryPeriod=DAFacade.GetSalaryPeriodForDropDown(string.Empty);
     ViewBag.SalaryPeriod=lstSalaryPeriod.ToList();
     return View();
 }
Example #19
0
        void cargarDetalleOrden(int idPreOrden)
        {
            List<OrdenDTO> listaOrdenes = new List<OrdenDTO>();
            OrdenBL obj = new OrdenBL();
            List<ItemOrdenDTO> lstItem = new List<ItemOrdenDTO>();
            ClienteDTO cliente = new ClienteDTO();
            cliente.nombre = Context.User.Identity.Name;
            cliente.nombreUsuario = Context.User.Identity.Name;
            cliente.correoElectronico = Context.User.Identity.Name;

            listaOrdenes = obj.ConsultarOrdenesUsuario(idPreOrden, cliente, "");

            lblTituloDetalle.Text = "Detalle Orden " + idPreOrden.ToString();

            lblNombreUsuario.Text = listaOrdenes[0].usuarioOrden.correoElectronico;
            lblTipoDocumento.Text = listaOrdenes[0].usuarioOrden.tipoDocumento;
            lblNumeroDocumento.Text = listaOrdenes[0].usuarioOrden.numeroDocumento;

            lblDireccion.Text = listaOrdenes[0].usuarioOrden.ubicacionCliente.numeroDireccion;
            lblCiudad.Text = listaOrdenes[0].usuarioOrden.ubicacionCliente.nombreCiudad;
            lblDepartamento.Text = listaOrdenes[0].usuarioOrden.ubicacionCliente.nombreDepartamento;
            lblTelefono.Text = listaOrdenes[0].usuarioOrden.telefono;

            foreach (var orden in listaOrdenes)
            {
                lstItem = orden.listaItemsOrden.ToList();
            }

            grvDetalleOrden.DataSource = lstItem.ToList();
            grvDetalleOrden.DataBind();

        }
Example #20
0
        public static List<DateTime> GetDatesHeadersFromDataSet(OleDbCommand cmd, int takeNumber)
        {
            var columnNames = new List<DateTime>();
            DataSet ds;
            using (var adptr = new OleDbDataAdapter(cmd))
            {
                ds = new DataSet();

                adptr.Fill(ds);
            }
            for (int i = takeNumber + 1; i < ds.Tables[0].Columns.Count; i++)
            {
                var columnName = ds.Tables[0].Columns[i].ColumnName;
                DateTime date;

                if (DateTime.TryParse(columnName, out date))
                {
                    columnNames.Add(new DateTime(date.Year,date.Month, 1));
                }
                else
                {
                    throw new Exception(String.Format("Could not parse {0} as date.", date));
                }
            }

            return columnNames.ToList();
        }
        /// <summary>
        /// Constructor initializes necessary variables and reads in saved constraints from text file.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            string fileName = @"Stored_Constraints.txt";
            Debug.WriteLine(DateTime.Now.ToString());
            filePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), fileName);
            dateTimesForConstraints = new Dictionary<string, string>();

            backgroundListener = new SpeechRecognizer();
            constraints = new List<string>();
            BLResultGenerated = new TypedEventHandler<SpeechContinuousRecognitionSession, SpeechContinuousRecognitionResultGeneratedEventArgs>(blResultGenerated);
            backgroundListener.ContinuousRecognitionSession.ResultGenerated += BLResultGenerated;

            constraints = readInConstraintsFromFile();
            currentlyStoredConstraints = constraints.ToList();
            updateConstraintsWindow(constraints);

            this.Closing += OnAppClosing;

            var waitOn = loadOnStart();
            while (waitOn.Status != AsyncStatus.Completed) { }
            var ff = backgroundListener.ContinuousRecognitionSession.StartAsync();

            notifyIcon = new NotifyIcon();
            notifyIcon.Icon = new System.Drawing.Icon("trayImage.ico");
            notifyIcon.Visible = true;
            notifyIcon.DoubleClick +=
                delegate (object sender, EventArgs args)
                {
                    this.Show();
                    this.WindowState = WindowState.Normal;
                };
        }
Example #22
0
 public ActionResult Index()
 {
     List<StructureTypeEntity> lstStructureType = new List<StructureTypeEntity>();
     lstStructureType = DAFacade.GetStructureTypeListByFilter(string.Format("ScaleYear='2009'"));
     ViewBag.StructureType = lstStructureType.ToList();
     return View();
 }
        public JsonResult AddQuestion(string questionData, string answerData, string User_Id)
        {
            var flag = false;
            //|4, |1,3,4, |dfdsf,
            //处理重复值
            questionData = questionData.TrimEnd(',');
            string[] qq = questionData.Split(',');
            string[] aa = answerData.Split('|');
            List<string> allList = new List<string>(qq);
            List<string> qllList = new List<string>(aa);
            allList = allList.Distinct().ToList();
            qllList = qllList.ToList();
            if (allList.Count > 0)
            {
                for (int i = 0; i < allList.Count; i++)
                {
                    //插入提交答案
                    QItemAnswer qitemanswer = new QItemAnswer();
                    //for (int j = 0; j < qllList.Count; j++)
                    //{
                    qitemanswer.SetQuestionID = Convert.ToInt32(allList[i]);
                    qitemanswer.Answer = "," + qllList[i + 1];
                    qitemanswer.AddDate = DateTime.Now;
                    qitemanswer.UserId = Convert.ToInt32(User_Id);
                    //break;
                    //}
                    QItemAnswerRepository.Add(qitemanswer);
                    QItemAnswerRepository.Context.Commit();
                    flag = true; ;
                }
            }

            return Json(new { flag = flag }, JsonRequestBehavior.AllowGet);
        }
 public AwardExperience(IEnumerable<string> parameter, List<Kerbal> kerbals, int experience, bool awardImmediately)
 {
     this.parameter = parameter.ToList();
     this.kerbals = kerbals.ToList();
     this.experience = experience;
     this.awardImmediately = awardImmediately;
 }
        public async Task<ActionResult> Index()
        {
            if (Session["User"] != null)
            {
                if (Session["Paid_User"].ToString() == "Unpaid")
                {
                    return RedirectToAction("Billing", "PersonalSetting");
                }
                else
                {
                    User objUser = (User)Session["User"];
                    string selectedgroupid = Session["group"].ToString();
                    IEnumerable<Domain.Socioboard.Domain.Groupmembers> lstGroupMembers = new List<Domain.Socioboard.Domain.Groupmembers>();
                    HttpResponseMessage response = await WebApiReq.GetReq("api/ApiGroupMembers/GetAcceptedGroupMembers?GroupId=" + selectedgroupid, "Bearer", Session["access_token"].ToString());
                    if (response.IsSuccessStatusCode)
                    {
                        lstGroupMembers = await response.Content.ReadAsAsync<IEnumerable<Domain.Socioboard.Domain.Groupmembers>>();
                    }

                    return View("Index", lstGroupMembers.ToList());
                }
            }
            else
            {
                return RedirectToAction("Index", "Index");
            }
            
        }
Example #26
0
 void Start()
 {
     var spawnPoints = new List<GameObject>();
     foreach (Transform t in spawnPointParent.transform) { spawnPoints.Add(t.gameObject); }
     remainingSpawnPoints = spawnPoints.ToList();
     SpawnInitialStations();
 }
    static void Main()
    {
        Console.WriteLine("Enter a list of integers on a single line separated by a space:");
        string input = Console.ReadLine();
        int[] numbers = Array.ConvertAll(input.Split(), int.Parse);

        int mask = (1 << numbers.Length) - 1;
        int maxLength = 0;
        List<int> longestSubsequence = new List<int>();

        for (int i = mask; i >= 1; i--)
        {
            char[] indexesToTake = Convert.ToString(i, 2).PadLeft(numbers.Length, '0').ToCharArray();

            List<int> currentSubsequence = new List<int>();

            for (int j = 0; j < numbers.Length; j++)
            {
                if (indexesToTake[j] == '1')
                {
                    currentSubsequence.Add(numbers[j]);
                }   
            }

            if (NonDecreasing(currentSubsequence) && currentSubsequence.Count > maxLength)
            {
                maxLength = currentSubsequence.Count;
                longestSubsequence.Clear();
                longestSubsequence = currentSubsequence.ToList();
            }
        }

        PrintList(longestSubsequence);
    }
        private void AddResourcesToProject()
        {
            PublishedProject publishedProject = null;
            DraftProject draftProject;
            LV_Projects.InvokeIfRequired(s => publishedProject = s.SelectedItems[0].Tag as PublishedProject);

            List<EnterpriseResource> resourceList = new List<EnterpriseResource>();

            LV_EnterpiseResources.InvokeIfRequired(s =>
            {
                ListView.SelectedListViewItemCollection selectedItems = s.SelectedItems;
                resourceList.AddRange(selectedItems.Cast<ListViewItem>().Select(selectedItem => (EnterpriseResource)selectedItem.Tag));
            });

            if (resourceList.Any())
            {
                draftProject = publishedProject.IsCheckedOut ? publishedProject.Draft : publishedProject.CheckOut();

                resourceList.ToList().ForEach(r =>
                    {
                        Log.WriteVerbose(new SourceInfo(), TB_Status, "Adding Resource:{0} to Project:{1}.", r.Name, publishedProject.Draft.Name);
                        draftProject.ProjectResources.AddEnterpriseResource(r);
                    });

                QueueJob queueJob = draftProject.Update();
                Log.WriteVerbose(new SourceInfo(), TB_Status, _bgeAddResourcesToProject, "Waiting for the Project Update job to complete.");
                CsomHelper.ExecuteAndWait(queueJob, TB_Status);
            }
            Log.WriteVerbose(new SourceInfo(), TB_Status, _bgeAddResourcesToProject, "Refreshing Project resources.");
            GetDraftTeamForSelectedProject();
        }
        public RespuestaBusquedaSolicitudesVob BuscarSolicitudes(SolicitudBusquedaSolicitudesVob solicitud)
        {
            List<SolicitudVob> lista = new List<SolicitudVob>();
            var solicitudrepositorio = new GNTSolicitudRepositorio();

            lista = solicitudrepositorio.BuscarSolicitudes();

            
            if (solicitud.SolicitudFilter.Codigo_Solicitud != null)
            {
                if (solicitud.SolicitudFilter.Codigo_Solicitud > 0)
                {
                    lista = lista.Where(x => x.Codigo_Solicitud == solicitud.SolicitudFilter.Codigo_Solicitud).ToList();
                }
            }

  
            if (solicitud.SolicitudFilter.FechaInicio != null && solicitud.SolicitudFilter.FechaFin != null)
            {
                lista = lista.Where(x => x.FechaSolicitud >= solicitud.SolicitudFilter.FechaInicio && x.FechaSolicitud <= solicitud.SolicitudFilter.FechaFin).ToList();
            }

            lista = lista.OrderByDescending(x => x.FechaSolicitud).ToList();

            int total = lista.Count();

            return new RespuestaBusquedaSolicitudesVob
            {
                listasolicitudes = lista.ToList(),
                totalelementos = total
            };

        }
        private ActionResult All()
        {
            var userNameInfo = UserName;
            var settings = UserSettings;

            var changelists = (from item in db.ChangeLists.AsNoTracking()
                                where (item.UserName == userNameInfo.fullUserName ||
                                        item.UserName == userNameInfo.userName ||
                                        item.ReviewerAlias == userNameInfo.reviewerAlias) &&
                                        item.Stage != (int)ChangeListStatus.Deleted
                                select item).OrderByDescending(x => x.TimeStamp);

            var model = new List<ChangeListDisplayItem>();
            foreach (var item in changelists)
            {
                model.Add(new ChangeListDisplayItem(item));
            }

            if (model.Count == 0)
            {
                return RedirectToAction("Index", "SubmitReview");
            }

            var js = new JavaScriptSerializer();
            var data = model.ToList();

            ViewBag.ChangeListDisplayItems = js.Serialize(data);
            ViewBag.Message = "Code Reviewer";
            ViewBag.UserSettings = js.Serialize(ReviewUtil.GenerateUserContext(0, userNameInfo.userName, "settings", settings));

            return View(data);
        }