public async Task <ActionResult> DeleteConfirmed(int id)
        {
            COUNT cOUNT = await db.COUNT.FindAsync(id);

            db.COUNT.Remove(cOUNT);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public string getApplyServiceId(int materialId, int count)
        {
            materials material    = _entities.materials.Find(materialId);
            COUNT     c           = _entities.COUNT.Find(count);
            decimal?  resultPrice = material.price * c.COUNT_VALUE * c.PRICE;
            decimal   res         = Decimal.Round((decimal)resultPrice, 2);

            return("" + res);
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,ITEM_TYPE_ID,COUNT_VALUE,PRICE")] COUNT cOUNT)
        {
            if (ModelState.IsValid)
            {
                db.Entry(cOUNT).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ITEM_TYPE_ID = new SelectList(db.ITEM_TYPE, "Id", "NAME", cOUNT.ITEM_TYPE_ID);
            return(View(cOUNT));
        }
        // GET: COUNTs/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            COUNT cOUNT = await db.COUNT.FindAsync(id);

            if (cOUNT == null)
            {
                return(HttpNotFound());
            }
            return(View(cOUNT));
        }
        // GET: COUNTs/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            COUNT cOUNT = await db.COUNT.FindAsync(id);

            if (cOUNT == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ITEM_TYPE_ID = new SelectList(db.ITEM_TYPE, "Id", "NAME", cOUNT.ITEM_TYPE_ID);
            return(View(cOUNT));
        }
Example #6
0
        public static ModelInput RecreateRealModel(ModelInput origin)
        {
            if (origin.type == ModelData.DURATION.TYPE)
            {
                return(DURATION.CopyValues(origin));
            }
            if (origin.type == ModelData.APPEAR.TYPE)
            {
                return(APPEAR.CopyValues(origin));
            }
            if (origin.type == ModelData.SIZE.TYPE)
            {
                return(SIZE.CopyValues(origin));
            }
            if (origin.type == ModelData.SPEED.TYPE)
            {
                return(SPEED.CopyValues(origin));
            }
            if (origin.type == ModelData.POSITION.TYPE)
            {
                return(POSITION.CopyValues(origin));
            }
            if (origin.type == ModelData.ROTATION.TYPE)
            {
                return(ROTATION.CopyValues(origin));
            }
            if (origin.type == ModelData.EVENT.TYPE)
            {
                return(EVENT.CopyValues(origin));
            }
            if (origin.type == ModelData.COUNT.TYPE)
            {
                return(COUNT.CopyValues(origin));
            }
            if (origin.type == ModelData.SHAPE.TYPE)
            {
                return(SHAPE.CopyValues(origin));
            }
            if (origin.type == ModelData.PROJECTILE.TYPE)
            {
                return(PROJECTILE.CopyValues(origin));
            }

            return(null);
        }
Example #7
0
        public DocumentCollector AddAggregateFunction(AggregateFunctionType type, IEvaluable field)
        {
            if (_aggregations == null)
            {
                _aggregations = new List <DocumentCollector>();
            }
            IAggregation function;

            switch (type)
            {
            case AggregateFunctionType.AVG:
                function = new AVG();
                break;

            case AggregateFunctionType.COUNT:
                function = new COUNT();
                break;

            case AggregateFunctionType.MAX:
                function = new MAX();
                break;

            case AggregateFunctionType.MIN:
                function = new MIN();
                break;

            case AggregateFunctionType.SUM:
                function = new SUM();
                break;

            //case AggregateFunctionType.FIRST:
            //    function = new FIRST(field);
            //    break;
            //case AggregateFunctionType.LAST:
            //    function = new LAST(field);
            //    break;
            default:
                throw new QuerySystemException(ErrorCodes.Query.AGGREGATION_INVALID_FUNCTION);
            }
            var aggregator = new DocumentCollector(function, field);

            _aggregations.Add(aggregator);
            return(aggregator);
        }
Example #8
0
        public async Task <StatisticsResponse> NewSum(businessType bt, string start, string end)
        {
            try
            {
                var startd = DateTime.Now;
                if (string.IsNullOrEmpty(start) || !DateTime.TryParse(start, out startd))
                {
                    return(new StatisticsResponse
                    {
                        status = (int)sixerrors.invalidstarttime
                    });
                }
                var endd = DateTime.Now;
                if (string.IsNullOrEmpty(end) || !DateTime.TryParse(end, out endd))
                {
                    return(new StatisticsResponse
                    {
                        status = (int)sixerrors.invalidendtime
                    });
                }
                if (bt == businessType.unknown)
                {
                    return(new StatisticsResponse
                    {
                        status = (int)sixerrors.businesstypeerror
                    });
                }
                var today     = DateTime.Now;
                var yesterday = today.AddDays(-1);
                var todaydb   = _db1.COUNT.FirstOrDefault(c => c.TIME.CompareTo(today) <= 0 && c.TIME.CompareTo(yesterday) > 0);
                Log.InfoFormat("today={0},yesteday={1}", 11, 22);
                if (todaydb == null)
                {
                    todaydb = new COUNT
                    {
                        PAGEVIEW                 = 0,
                        APPLICATION              = 0,
                        PAGEVIEWDAY              = 0,
                        APPLICATIONDAY           = 0,
                        STARTLEARNINGVOLUME      = 0,
                        STARTLEARNINGVOLUMETODAY = 0,
                        KAIFAQU  = 0,
                        ZHIFUQU  = 0,
                        FUSHANQU = 0,

                        MUPINGQU  = 0,
                        LAISHANQU = 0,
                        LONGKOU   = 0,
                        ZHAOYUAN  = 0,
                        QIXIA     = 0,

                        LAIZHOU  = 0,
                        CHANGDAO = 0,
                        HAIYANG  = 0,
                        LAIYANG  = 0,
                        PENGLAI  = 0,

                        OTHER    = 0,
                        GAOXINQU = 0,
                    };
                }
                var startoftoday = DateTime.Parse(string.Format("{0}-{1}-{2}", today.Year, today.Month, today.Day));
                var todaynum     = new statistics
                {
                    PAGEVIEW    = todaydb.PAGEVIEWDAY,
                    APPLICATION = todaydb.APPLICATIONDAY,
                    KAIFAQU     = todaydb.KAIFAQU,
                    ZHIFUQU     = todaydb.ZHIFUQU,
                    FUSHANQU    = todaydb.FUSHANQU,

                    MUPINGQU  = todaydb.MUPINGQU,
                    LAISHANQU = todaydb.LAISHANQU,
                    LONGKOU   = todaydb.LONGKOU,
                    ZHAOYUAN  = todaydb.ZHAOYUAN,
                    QIXIA     = todaydb.QIXIA,

                    LAIZHOU         = todaydb.LAIZHOU,
                    CHANGDAO        = todaydb.CHANGDAO,
                    HAIYANG         = todaydb.HAIYANG,
                    LAIYANG         = todaydb.LAIYANG,
                    PENGLAI         = todaydb.PENGLAI,
                    InspectedVolume = _db1.HISTORY.Where(c => c.PROCESSED == "1" && c.OVERTIME.CompareTo(startoftoday) >= 0).Count(),
                    LearningVolume  = todaydb.STARTLEARNINGVOLUMETODAY,
                    OTHER           = todaydb.OTHER,
                    GAOXINQU        = todaydb.GAOXINQU,
                };
                //    var totaldb = _db1.COUNT.Sum(c => c.KAIFAQU);
                var totalnum = new statistics
                {
                    PAGEVIEW    = todaydb.PAGEVIEW,
                    APPLICATION = todaydb.APPLICATION,
                    KAIFAQU     = _db1.COUNT.Sum(c => c.KAIFAQU),
                    ZHIFUQU     = _db1.COUNT.Sum(c => c.ZHIFUQU),
                    FUSHANQU    = _db1.COUNT.Sum(c => c.FUSHANQU),

                    MUPINGQU  = _db1.COUNT.Sum(c => c.MUPINGQU),
                    LAISHANQU = _db1.COUNT.Sum(c => c.LAISHANQU),
                    LONGKOU   = _db1.COUNT.Sum(c => c.LONGKOU),
                    ZHAOYUAN  = _db1.COUNT.Sum(c => c.ZHAOYUAN),
                    QIXIA     = _db1.COUNT.Sum(c => c.QIXIA),

                    LAIZHOU         = _db1.COUNT.Sum(c => c.LAIZHOU),
                    CHANGDAO        = _db1.COUNT.Sum(c => c.CHANGDAO),
                    HAIYANG         = _db1.COUNT.Sum(c => c.HAIYANG),
                    LAIYANG         = _db1.COUNT.Sum(c => c.LAIYANG),
                    PENGLAI         = _db1.COUNT.Sum(c => c.PENGLAI),
                    InspectedVolume = _db1.HISTORY.Where(c => c.PROCESSED == "1").Count(),
                    LearningVolume  = todaydb.STARTLEARNINGVOLUME,
                    OTHER           = _db1.COUNT.Sum(c => c.OTHER),
                    GAOXINQU        = _db1.COUNT.Sum(c => c.GAOXINQU),
                };
                return(new StatisticsResponse
                {
                    status = 0,
                    today = todaynum,
                    total = totalnum
                });
            }
            catch (Exception ex)
            {
                Log.Error("Statistics,", ex);
                return(new StatisticsResponse
                {
                    status = (int)sixerrors.processerror
                });
            }
        }
Example #9
0
        private void BellFailDebug_Click(object sender, RoutedEventArgs e)
        {
            const int COUNT = 25;


            // The problem that this method illustrates is that rand.nextdouble() is thought of as x, but it's really % along arc length of the curve
            // And because there are two curves, it's some hacked up hybrid
            //
            // The original intent was to get the y coord at some fixed x.  But there's no one single calculation that would get that.  Samples would
            // need to be taken to figure out which percent along curve to use to get the desired x, and corresponding y



            try
            {
                double midX = trkBellFailPeak.Value;

                BezierSegment3D[] bezier = BezierUtil.GetBezierSegments(new[] { new Point3D(0, 0, 0), new Point3D(midX, 1, 0), new Point3D(1, 0, 0) }, trkBellFailPinch.Value);

                // Add a control point so the curve will be attracted to the x axis at the two end points
                double run;
                if (trkBellFailLeftZero.Value > 0)
                {
                    run       = (bezier[0].EndPoint1.X - bezier[0].EndPoint0.X) * trkBellFailLeftZero.Value;
                    bezier[0] = new BezierSegment3D(bezier[0].EndIndex0, bezier[0].EndIndex1, new[] { new Point3D(run, 0, 0), bezier[0].ControlPoints[0] }, bezier[0].AllEndPoints);
                }

                if (trkBellFailRightZero.Value > 0)
                {
                    run       = (bezier[1].EndPoint1.X - bezier[1].EndPoint0.X) * trkBellFailRightZero.Value;
                    bezier[1] = new BezierSegment3D(bezier[1].EndIndex0, bezier[1].EndIndex1, new[] { bezier[1].ControlPoints[0], new Point3D(bezier[1].EndPoint1.X - run, 0, 0), }, bezier[1].AllEndPoints);
                }



                //bezier[0] = new BezierSegment3D(bezier[0].EndIndex0, bezier[0].EndIndex1, new Point3D[0], bezier[0].AllEndPoints);
                //bezier[1] = new BezierSegment3D(bezier[1].EndIndex0, bezier[1].EndIndex1, new Point3D[0], bezier[1].AllEndPoints);



                var samples = Enumerable.Range(0, COUNT).
                              Select(o =>
                {
                    double percentOrig = o.ToDouble() / COUNT.ToDouble();

                    int index;
                    double percent;
                    if (percentOrig < midX)
                    {
                        index   = 0;
                        percent = percentOrig / midX;
                    }
                    else
                    {
                        index   = 1;
                        percent = (percentOrig - midX) / (1d - midX);
                    }

                    Point3D point = BezierUtil.GetPoint(percent, bezier[index]);

                    //if (retVal < 0) retVal = 0;
                    //else if (retVal > 1) retVal = 1;

                    return(new
                    {
                        PercentOrig = percentOrig,
                        PercentSub = percent,
                        Index = index,
                        Point = point,
                    });
                }).
                              ToArray();



                Clear();

                Rect bounds = GetBounds();

                // Grid
                AddLine(bounds.BottomLeft, bounds.TopRight, _brushVeryLight);                         // diagonal

                AddLine(bounds.TopLeft, bounds.TopRight, _brushVeryLight);                            // 1
                double y = bounds.Bottom - (bounds.Height * .75);
                AddLine(new Point(bounds.Left, y), new Point(bounds.Right, y), _brushVeryLight);      // .75
                y = bounds.Bottom - (bounds.Height * .5);
                AddLine(new Point(bounds.Left, y), new Point(bounds.Right, y), _brushVeryLight);      // .5
                y = bounds.Bottom - (bounds.Height * .25);
                AddLine(new Point(bounds.Left, y), new Point(bounds.Right, y), _brushVeryLight);      // .25

                AddLine(new[] { bounds.TopLeft, bounds.BottomLeft, bounds.BottomRight }, _brushDark); // axiis

                // Samples
                foreach (var sample in samples)
                {
                    AddLine(new Point(bounds.Left + (sample.PercentOrig * bounds.Width), bounds.Bottom), new Point(bounds.Left + (sample.Point.X * bounds.Width), bounds.Bottom - (sample.Point.Y * bounds.Height)), Brushes.Black);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #10
0
        //Method that takes the tuples from the inqueue and processes them.
        public void process_inQueue()
        {
            FILTER filter = new FILTER();
            CUSTOM custom = new CUSTOM();
            UNIQ   uniq   = new UNIQ();
            DUP    dup    = new DUP();
            COUNT  count  = new COUNT();

            while (true)
            {
                Monitor.Enter(tLock);
                try
                {
                    if (in_queue.Count > 0)
                    {
                        string[] words = op_spec.Split(',');

                        remoting_interfaces.Tuple outTuple;

                        if (in_queue[0].getID() != 0)
                        {
                            Console.WriteLine("   ");
                            Console.WriteLine("ID: " + in_queue[0].getID());
                            Console.WriteLine("User: "******"URL: " + in_queue[0].getURL());
                        }

                        if (words[0] == "FILTER")
                        {
                            //get the tuple after computation of Filter
                            outTuple = filter.doTweeters(in_queue[0], Int32.Parse(words[1]), words[2], words[3]);
                            out_queue.Add(outTuple);
                            in_queue.Remove(in_queue[0]);
                            Console.WriteLine("Output from Operator:");
                            Console.WriteLine(outTuple.getID());
                            Console.WriteLine(outTuple.getUser());
                            Console.WriteLine(outTuple.getURL());
                        }
                        if (words[0] == "CUSTOM")
                        {
                            List <string> Followers = new List <string>();

                            //get the list of followers
                            Followers = custom.getoutput(words[1], words[3], in_queue[0]);
                            foreach (string follower in Followers)
                            {
                                Console.WriteLine("follower: " + follower);
                                remoting_interfaces.Tuple Tuple = new remoting_interfaces.Tuple(0, follower, "");
                                out_queue.Add(Tuple);
                            }

                            in_queue.Remove(in_queue[0]);
                        }
                        if (words[0] == "UNIQ")
                        {
                            outTuple = uniq.uniqTuple(in_queue[0], Int32.Parse(words[1]));
                            //only put the tuple in the out_queue if don't exists another equal to that tuple
                            if (outTuple.getUser() != "")
                            {
                                out_queue.Add(outTuple);
                                Console.WriteLine("Output from Operator:");
                                Console.WriteLine(outTuple.getUser());
                            }
                            in_queue.Remove(in_queue[0]);
                        }
                        if (words[0] == "DUP")
                        {
                            List <remoting_interfaces.Tuple> duplicatedTuple = dup.duplicate(in_queue[0]);

                            foreach (remoting_interfaces.Tuple tuplo in duplicatedTuple)
                            {
                                out_queue.Add(tuplo);
                                Console.WriteLine("Output from Operator:");
                                Console.WriteLine(tuplo.getID());
                                Console.WriteLine(tuplo.getUser());
                                Console.WriteLine(tuplo.getURL());
                            }
                            duplicatedTuple.Remove(in_queue[0]);
                            duplicatedTuple.Remove(in_queue[0]);

                            in_queue.Remove(in_queue[0]);
                        }
                        if (words[0] == "COUNT")
                        {
                            outTuple = count.countMethod(in_queue[0]);
                            out_queue.Add(outTuple);

                            Console.WriteLine("Output from Operator:");
                            Console.WriteLine(outTuple.getUser());
                            Console.WriteLine("Tuples count until now: " + count.getCount());
                            Console.WriteLine("      ");

                            in_queue.Remove(in_queue[0]);
                        }
                    }
                }
                finally
                {
                    Monitor.Exit(tLock);
                }
            }
        }