Exemplo n.º 1
0
        public ArrayList GetWordsListAll(bool WithFlag, bool ReSort)
        {
            if (!this.m_isOpen)
            {
                return(null);
            }
            ArrayList list = new ArrayList();

            for (int i = 0; i < 0x51a5; i++)
            {
                if (this.m_WordsList[i].m_List != null)
                {
                    for (int j = 0; j < this.m_WordsList[i].m_List.Count; j++)
                    {
                        if (WithFlag)
                        {
                            list.Add(((char)(i + 0x4e00)).ToString() + this.m_WordsList[i].m_List[j].ToString());
                        }
                        else
                        {
                            list.Add(this.m_WordsList[i].m_List[j]);
                        }
                    }
                }
            }
            if (ReSort)
            {
                OrderValue comparer = new OrderValue();
                list.Sort(comparer);
            }
            return(list);
        }
 private object ValueObject(OrderValue orderValue)
 {
     if (orderValue.Type == typeof(int).Name)
     {
         int value = 0;
         int.TryParse(orderValue.Value, out value);
         return(value);
     }
     else if (orderValue.Type == typeof(uint).Name)
     {
         uint value = 0;
         uint.TryParse(orderValue.Value, out value);
         return(value);
     }
     else if (orderValue.Type == typeof(double).Name)
     {
         double value = 0.0;
         double.TryParse(orderValue.Value, out value);
         return(value);
     }
     else if (orderValue.Type == typeof(string).Name)
     {
         return(orderValue.Value);
     }
     else if (orderValue.Type == typeof(bool).Name)
     {
         bool value = false;
         bool.TryParse(orderValue.Value, out value);
         return(value);
     }
     return(null);
 }
Exemplo n.º 3
0
            private IEnumerable <Child> ApplyOrderingByProp(OrderValue <Child> orderValue)
            {
                if (orderValue.Descending)
                {
                    return(Data.OrderByDescending(x => orderValue.Prop.GetValue(x)));
                }

                return(Data.OrderBy(x => orderValue.Prop.GetValue(x)));
            }
 public void WriteValues(Dictionary <string, object> values)
 {
     _orderValues.Clear();
     foreach (KeyValuePair <string, object> entry in values)
     {
         OrderValue newOrderValue = new OrderValue();
         newOrderValue.Name  = entry.Key;
         newOrderValue.Type  = entry.Value.GetType().Name;
         newOrderValue.Value = entry.Value.ToString();
         _orderValues.Add(newOrderValue);
     }
 }
        public static OrderedMission LoadNode(ConfigNode node)
        {
            OrderedMission orderedMission = ConfigNode.CreateObjectFromConfig <OrderedMission>(node);

            foreach (ConfigNode orderValueConfig in node.GetNodes("ORDERVALUE"))
            {
                OrderValue orderValue = ConfigNode.CreateObjectFromConfig <OrderValue>(orderValueConfig);
                orderedMission._orderValues.Add(orderValue);
            }

            return(orderedMission);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            using (StoreApplicationContext dbContext = CreateDbContext())
                using (IStoreRepository storeRepository = new StoreRepository(dbContext))
                {
                    while (true)
                    {
                        try
                        {
                            _logger.Info($"Saving");
                            storeRepository.Save();
                        }
                        catch (DbUpdateException ex)
                        {
                            _logger.Error($"Failed to Save");
                            Console.WriteLine(ex.Message);
                        }

                        Console.WriteLine();
                        Console.WriteLine("1:\tDisplay All Names");
                        Console.WriteLine("2:\tSearch By Last Name");
                        Console.WriteLine("3:\tDisplay Order History of each location");
                        Console.WriteLine("4:\tQuit");
                        Console.WriteLine();

                        int                              input = IntValidation(1, 4);
                        string                           input2;
                        var                              count = 0;
                        Customer                         customer;
                        Product                          ProductValue;
                        var                              products  = storeRepository.DisplayProducts();
                        var                              products2 = products.ToList();
                        List <OrderDetails>              orderDetails;
                        IEnumerable <Order>              OrderValue;
                        IEnumerable <Customer>           AllNames;
                        IEnumerable <Inventories>        LocationInventory;
                        IEnumerable <ProductCat>         prodCategories;
                        IEnumerable <Product>            getRecoProduct;
                        IEnumerable <ComponentInventory> componentInventories;
                        List <Product>                   Cart;
                        List <Product>                   ComponentCart;
                        decimal                          Total = 0;
                        int                              tempOrderId;
                        Dictionary <string, int>         HashProducts;
                        HashSet <Product>                HashLoop;
                        int                              inventoryId;
                        switch (input)
                        {
                        case 1:
                            AllNames = storeRepository.GetNames();
                            Console.WriteLine();
                            count = 0;
                            _logger.Info($"Choosing Customer to Order for");
                            foreach (var x in AllNames)
                            {
                                Console.WriteLine($"\t{count}: {x.GetFullName()}");
                                count++;
                            }

                            if (count == 0)
                            {
                                Console.WriteLine("There are 0 Customers");
                                break;
                            }
                            var AllNamesList = AllNames.ToList();

                            Console.WriteLine($"Choose Customer to interact with or Press {AllNames.Count()} to go back");

                            input = IntValidation(0, AllNames.Count());
                            if (input != AllNames.Count())
                            {
                                customer   = AllNames.ElementAt(input);
                                OrderValue = storeRepository.GetOrders(customer);

                                _logger.Info($"Displaying orders for {customer.FName} {customer.LName} {customer.CustomerId}");
                                List <OrderDetails> temp2 = new List <OrderDetails>();
                                while (true)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Do you want to view and sort Customer Order History?");
                                    Console.WriteLine("1:\tYes");
                                    Console.WriteLine("2:\tNo");
                                    Console.WriteLine();
                                    input = IntValidation(1, 2);
                                    if (input == 2)
                                    {
                                        break;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine("What do you want to sort by?");
                                    Console.WriteLine("1:\tEarliest");
                                    Console.WriteLine("2:\tLatest");
                                    Console.WriteLine("3:\tCheapest");
                                    Console.WriteLine("4:\tExpensive");
                                    Console.WriteLine();
                                    input = IntValidation(1, 4);
                                    List <Order> orderList = OrderValue.ToList();
                                    if (input == 1)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Early);
                                    }
                                    else if (input == 2)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Late);
                                    }
                                    else if (input == 3)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Cheap);
                                    }
                                    else if (input == 4)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Expensive);
                                    }
                                    count = 0;
                                    foreach (var x in orderList)
                                    {
                                        Console.WriteLine();
                                        Console.WriteLine($"Order {count}:\tTime:{x.TimeStamp}  \nStore: {x.Location.Name}\tCost: ${x.TotalAmount}");
                                        orderDetails = storeRepository.GetOrderDetails(x).ToList();
                                        temp2.AddRange(orderDetails);
                                        var y = orderDetails;
                                        foreach (var z in y)
                                        {
                                            var i = Order.GetProductName(products.ToList(), z.ProductId);
                                            Console.WriteLine($"\t{i}\tAmount:{z.Quantity} ");
                                        }
                                        count++;
                                    }
                                }
                                Cart = new List <Product>();

                                LocationInventory = storeRepository.GetInventories(customer);
                                List <Inventories> LocationInventoryList = LocationInventory.ToList();
                                Total = 0;
                                while (true)
                                {
                                    count    = 4;
                                    products = storeRepository.DisplayProducts();
                                    Console.WriteLine();
                                    foreach (var x in products)
                                    {
                                        if (count % 3 == 0)
                                        {
                                            Console.WriteLine($"\t{count - 4}: {x.ProductCost}  {x.ProductName}\t\t ");
                                        }
                                        else
                                        {
                                            Console.Write($"\t{count - 4}: {x.ProductCost}  {x.ProductName}\t\t ");
                                        }
                                        count++;
                                    }
                                    _logger.Info($"Get Recommended Items");
                                    Product product = new Product();

                                    List <Product> tempP     = new List <Product>();
                                    List <Order>   orderList = OrderValue.ToList();
                                    foreach (var x in orderList)
                                    {
                                        var y = storeRepository.GetOrderDetails(x).ToList();
                                        foreach (var z in y)
                                        {
                                            foreach (var t in products)
                                            {
                                                if (t.ProductId == z.ProductId)
                                                {
                                                    tempP.Add(t);
                                                }
                                            }
                                        }
                                        count++;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine("Recommended Items:\n");
                                    var getStuff = dbContext.Products.Where(x => x.ProductCategoryId == tempP[tempP.Count - 1].CategoryId).ToList();
                                    count = 0;
                                    foreach (var x in getStuff)
                                    {
                                        if (count > 2)
                                        {
                                            break;
                                        }
                                        Console.Write($"   {x.ProductName}");
                                        count++;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine($"Add Product to cart or Enter {products.Count()} to purchase it\n");
                                    Console.WriteLine($"Purchasing from Default Location: {customer.DefaultLocation.Name}");
                                    Console.WriteLine($"There are {Cart.Count} Items in cart for a total of ${Total}");
                                    input = IntValidation(0, products.Count());
                                    _logger.Info($"Choose item to add to cart");
                                    if (input != products.Count())
                                    {
                                        ProductValue = products.ElementAt(input);
                                        _logger.Info($"Item chosen = {ProductValue.ProductName}");
                                        if (ProductValue.HasComponents)
                                        {
                                            componentInventories = storeRepository.GetComponents(ProductValue);
                                            ComponentCart        = new List <Product>();
                                            foreach (var x in componentInventories)
                                            {
                                                foreach (var y in products2)
                                                {
                                                    if (x.ComponentProductId == y.ProductId)
                                                    {
                                                        ComponentCart.Add(y);
                                                    }
                                                }
                                            }
                                            List <Inventories> tempInv = new List <Inventories>();
                                            tempInv.AddRange(LocationInventoryList);
                                            Decimal        tempTotal = Total;
                                            List <Product> tempCart  = new List <Product>();
                                            tempCart.AddRange(Cart);

                                            foreach (var x in ComponentCart)
                                            {
                                                if (Order.CheckCart(x, LocationInventoryList))
                                                {
                                                    Console.WriteLine($"\t{x.ProductName} has been added to cart");
                                                    Total += x.ProductCost;
                                                    Cart.Add(x);
                                                }
                                                else
                                                {
                                                    LocationInventoryList.Clear();
                                                    LocationInventoryList.AddRange(tempInv);
                                                    Cart.Clear();
                                                    Cart.AddRange(tempCart);
                                                    Total = tempTotal;

                                                    Console.WriteLine();
                                                    Console.WriteLine("Inventory is out");

                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (Order.CheckCart(ProductValue, LocationInventoryList))
                                            {
                                                Console.WriteLine($"\t{ProductValue.ProductName} has been added to cart");
                                                Total += ProductValue.ProductCost;
                                                Cart.Add(ProductValue);
                                            }
                                            else
                                            {
                                                Console.WriteLine();
                                                Console.WriteLine("Inventory is out");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (Cart.Count == 0)
                                        {
                                            Console.WriteLine();
                                            Console.WriteLine("The cart is empty, so nothing was purchased!");
                                            Console.WriteLine();
                                            break;
                                        }
                                        else
                                        {
                                            //SA.Orders(ConsumerId,StoreId,TotalAmount)
                                            Order newOrder = new Order
                                            {
                                                CustomerId  = customer.CustomerId,
                                                StoreId     = customer.DefaultLocation.LocationId,
                                                TotalAmount = Total,
                                                Location    = customer.DefaultLocation,
                                                Customer    = customer,
                                                TimeStamp   = DateTime.Now,
                                            };
                                            storeRepository.AddOrder(newOrder, customer.DefaultLocation, customer);
                                            try
                                            {
                                                _logger.Info($"Saving");
                                                storeRepository.Save();
                                            }
                                            catch (DbUpdateException ex)
                                            {
                                                _logger.Error($"Failed to Save");
                                                Console.WriteLine(ex.Message);
                                            }
                                            Thread.Sleep(50);
                                            tempOrderId  = dbContext.Orders.OrderByDescending(y => y.OrderId).Select(a => a.OrderId).FirstOrDefault();
                                            HashProducts = new Dictionary <string, int>();
                                            HashLoop     = new HashSet <Product>();
                                            foreach (var x in Cart)
                                            {
                                                if (HashProducts.ContainsKey(x.ProductName))
                                                {
                                                    HashProducts[x.ProductName] += 1;
                                                }
                                                else
                                                {
                                                    HashProducts.Add(x.ProductName, 1);
                                                }
                                                HashLoop.Add(x);
                                            }
                                            count = 0;
                                            foreach (var x in HashLoop)
                                            {
                                                count++;
                                                Console.WriteLine(count);
                                                OrderDetails newOrderDetails = new OrderDetails
                                                {
                                                    OrderId   = tempOrderId,
                                                    ProductId = x.ProductId,
                                                    Quantity  = HashProducts[x.ProductName],
                                                };

                                                storeRepository.AddOrderDetails(newOrderDetails, newOrder, x);
                                                try
                                                {
                                                    _logger.Info($"Saving");
                                                    storeRepository.Save();
                                                }
                                                catch (DbUpdateException ex)
                                                {
                                                    _logger.Error($"Failed to Save");
                                                    Console.WriteLine(ex.Message);
                                                }
                                                inventoryId = dbContext.Inventory.Where(y => y.ProductId == x.ProductId && y.StoreId == customer.DefaultLocation.LocationId).Select(a => a.InventoryId).First();
                                                Thread.Sleep(50);
                                                Inventories inventories = new Inventories
                                                {
                                                    Quantity    = Order.getInventory(LocationInventoryList, x.ProductId),
                                                    StoreId     = customer.DefaultLocation.LocationId,
                                                    ProductId   = x.ProductId,
                                                    InventoryId = inventoryId,
                                                };
                                                storeRepository.UpdateInventory(inventories);
                                                try
                                                {
                                                    _logger.Info($"Saving");
                                                    storeRepository.Save();
                                                }
                                                catch (DbUpdateException ex)
                                                {
                                                    _logger.Error($"Failed to Save");
                                                    Console.WriteLine(ex.Message);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                            break;

                        case 2:
                            _logger.Info($"Search for name name");
                            do
                            {
                                Console.WriteLine("Please enter Full/Parital Last Name to search by");
                                input2 = Console.ReadLine();
                                if (input2.Length < 200 && input2.Length > 0)
                                {
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Please enter word with 1 - 199 characters, ");
                                }
                            } while (true);

                            AllNames = storeRepository.GetNames(input2);
                            Console.WriteLine();
                            count = 0;

                            foreach (var x in AllNames)
                            {
                                Console.WriteLine($"\t{count}: {x.GetFullName()}");
                                count++;
                            }
                            if (count == 0)
                            {
                                Console.WriteLine("Your search had 0 results");
                            }
                            break;

                        case 3:
                            _logger.Info($"Display All orders by each location");
                            var n = storeRepository.GetOrders().ToList();
                            var p = n.OrderByDescending(k => k.Location.LocationId);


                            foreach (var a in p)
                            {
                                var    b    = dbContext.Consumer.ToList();
                                var    z    = dbContext.Store.ToList();
                                string name = "John Albert";
                                foreach (var m in z)
                                {
                                    if (m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.ConsumerId).FirstOrDefault() == a.CustomerId)
                                    {
                                        name = m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.Fname).FirstOrDefault() + " " + m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.Lname).FirstOrDefault();
                                    }
                                }
                                Console.WriteLine($"{ a.Location.Name}");
                                Console.WriteLine($"\t{name}\t{a.TimeStamp}\t{a.TotalAmount}");
                                Console.WriteLine();
                            }
                            break;

                        case 4:
                            _logger.Info($"Exiting Application");
                            return;
                        }
                    }
                }
        }
Exemplo n.º 7
0
        public ActionResult StringDCGridPartial(int stationId, string date, string hour)
        {
            SetCultureInfo();

            List <TempDTO> strTagNames = DB.stationString
                                         .Join(DB.Tags, r => r.STRING_ID, ro => ro.ID, (r, ro) => new { r, ro })
                                         .Where(x => x.r.STATION_ID == stationId && x.r.IS_DELETED == false)
                                         .GroupBy(x => x.ro.NAME)
                                         .Select(g => new TempDTO {
                NAME = g.Key, ID = g.FirstOrDefault().ro.ID
            })
                                         .ToList();

            for (int i = 0; i < strTagNames.Count; i++)
            {
                strTagNames[i].INPUT_NO = Convert.ToInt32(strTagNames[i].NAME.Split('_')[3].Replace(".", ""));
                strTagNames[i].INV_NO   = Convert.ToInt32(strTagNames[i].NAME.Split('_')[0].Replace("INV", ""));
            }

            strTagNames = strTagNames.OrderBy(x => x.INV_NO).ThenBy(x => x.INPUT_NO).ToList();

            DataTable dt = new DataTable();

            if (strTagNames == null || strTagNames.Count == 0)
            {
                return(PartialView(dt));
            }


            List <string> sameTag = new List <string>();

            if (strTagNames != null)
            {
                string sck = string.Empty;
                foreach (TempDTO tag in strTagNames)
                {
                    sck = tag.NAME.Split('_')[0];

                    if (!dt.Columns.Contains(sck + " (A)"))
                    {
                        dt.Columns.Add(sck + " (A)");
                        sameTag = strTagNames.Where(x => x.NAME.Split('_')[0] == sck).Select(x => x.NAME).ToList();

                        if (sameTag != null)
                        {
                            for (int i = 0; i <= sameTag.Count - 1; i++)
                            {
                                if (dt.Rows.Count == 0 || dt.Rows.Count < (i + 1))
                                {
                                    DataRow rw = dt.NewRow();
                                    rw[sck + " (A)"] = sameTag[i];
                                    dt.Rows.Add(rw);
                                }
                                else
                                {
                                    dt.Rows[i][sck + " (A)"] = sameTag[i];
                                }
                            }
                        }
                    }
                }
            }

            DateTime curDate = DateTime.Now;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
            List <STR_DTO> values = new List <STR_DTO>();

            if (hour == "")
            {
                values = (from so in DB.StringOzetLive
                          join t in DB.Tags on so.STRING_ID equals t.ID
                          join tct in DB.stationString on t.ID equals tct.STRING_ID
                          where so.STATION_ID == stationId &&
                          tct.STATION_ID == stationId &&
                          tct.IS_DELETED == false &&
                          t.IS_DELETED == false &&
                          tct.IS_DELETED == false
                          select new STR_DTO
                {
                    NAME = t.NAME,
                    ID = t.ID,
                    date = so.INSERT_DATE.Value,
                    VALUE = so.VALUE
                }
                          ).ToList();
                ViewBag.Date = values[0].date;
            }
            else
            {
                DateTime slcDate = DateTime.Parse(date);
                DateTime nowDate = DateTime.Now;

                if (nowDate.Year == slcDate.Year && nowDate.Month == slcDate.Month) //Quarter String
                {
                    string _date = date + " " + hour;
                    ViewBag.Date = _date;
                    string[] hourSplit    = hour.Split(':');
                    var      _convertDate = ConvertNumberFormatDateAndHourQuarter(date, hourSplit[0], hourSplit[1])._begin;
                    values = (from so in DB.StringOzetQuarterHourAVG
                              join t in DB.Tags on so.STRING_ID equals t.ID
                              join tct in DB.stationString on t.ID equals tct.STRING_ID
                              where so.STATION_ID == stationId && tct.STATION_ID == stationId &&
                              tct.IS_DELETED == false &&
                              t.IS_DELETED == false &&
                              so.TARIH_NUMBER == _convertDate
                              select new STR_DTO
                    {
                        NAME = t.NAME,
                        ID = t.ID,
                        VALUE = (float)Math.Round(so.VALUE, 2)
                    }
                              ).ToList();
                }
                else //Hourly String
                {
                    string _date = date + " " + hour;
                    ViewBag.Date = _date;
                    string[] hourSplit    = hour.Split(':');
                    var      _convertDate = ConvertNumberFormatDateAndHour(date, hourSplit[0])._begin;
                    values = (from so in DB.StringOzetAVG
                              join t in DB.Tags on so.STRING_ID equals t.ID
                              join tct in DB.stationString on t.ID equals tct.STRING_ID
                              where so.STATION_ID == stationId && tct.STATION_ID == stationId &&
                              tct.IS_DELETED == false &&
                              t.IS_DELETED == false &&
                              so.TARIH_NUMBER == _convertDate
                              select new STR_DTO
                    {
                        NAME = t.NAME,
                        ID = t.ID,
                        VALUE = (float)Math.Round(so.VALUE, 2)
                    }
                              ).ToList();
                }
            }
            if (values.Count != 0)
            {
                //ViewBag.Date = values[0].date;

                if (dt.Columns.Count > 0 && dt.Rows.Count > 0 && values != null)
                {
                    string cellTagName = string.Empty;
                    foreach (DataRow rw in dt.Rows)
                    {
                        foreach (DataColumn col in dt.Columns)
                        {
                            cellTagName = rw[col].ToString();

                            if (values.Any(x => x.NAME == cellTagName))
                            {
                                rw[col] = values.Where(x => x.NAME == cellTagName).FirstOrDefault().VALUE;
                            }
                            else
                            {
                                rw[col] = "-";
                            }
                        }
                    }
                }
            }
            else
            {
                string cellTagName = string.Empty;
                foreach (DataRow rw in dt.Rows)
                {
                    foreach (DataColumn col in dt.Columns)
                    {
                        cellTagName = rw[col].ToString();
                        rw[col]     = "-";
                    }
                }
            }

            if (values.Count != 0)
            {
                decimal _min;

                List <StringMin> _ListStringMin = new List <StringMin>();

                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    _min = Convert.ToDecimal(dt.Rows[0][j]);

                    StringMin _StringMin = new StringMin();

                    _StringMin.ColumnIndex = j;
                    _StringMin.FieldName   = dt.Columns[j].ColumnName;

                    try
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (i == 11)
                            {
                                var dddd = dt.Rows[i][j];
                            }
                            if (dt.Rows[i][j] != DBNull.Value)
                            {
                                if (dt.Rows[i][j].ToString() != "-")
                                {
                                    if (Convert.ToDecimal(dt.Rows[i][j]) < _min)
                                    {
                                        _min                = Convert.ToDecimal(dt.Rows[i][j].ToString());
                                        _StringMin.Min      = _min;
                                        _StringMin.RowIndex = i;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    _ListStringMin.Add(_StringMin);
                }

                ViewBag.StringMin = _ListStringMin;


                // Max değeri bulma -----------------------------
                decimal _max = 0;

                List <StringDeneme> _ListStringMax = new List <StringDeneme>();

                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    _max = 0;

                    StringDeneme _cStringDeneme = new StringDeneme();

                    _cStringDeneme.ColumnIndex = j;
                    _cStringDeneme.FieldName   = dt.Columns[j].ColumnName;

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i][j] != DBNull.Value)
                        {
                            if (dt.Rows[i][j].ToString() != "-")
                            {
                                if (Convert.ToDecimal(dt.Rows[i][j]) > _max)
                                {
                                    _max = Convert.ToDecimal(dt.Rows[i][j]);
                                    _cStringDeneme.Value    = _max;
                                    _cStringDeneme.RowIndex = i;
                                }
                            }
                        }
                    }

                    // j++;

                    _ListStringMax.Add(_cStringDeneme);
                }

                ViewBag.StringMax = _ListStringMax;


                // max bitti--------

                // Avg değeri bulma ----------------------


                List <StringAvg> ListStringAvg = new List <StringAvg>();

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    decimal count = 0, sum = 0;

                    if (dt.Columns[i].ColumnName.IndexOf("Name") == -1)
                    {
                        for (int j = 0; j < dt.Rows.Count; j++)
                        {
                            decimal _ActiveValue = 0;

                            if (dt.Rows[j][i] != DBNull.Value)
                            {
                                if (dt.Rows[j][i].ToString() != "-")
                                {
                                    _ActiveValue = Decimal.Parse(dt.Rows[j][i].ToString());

                                    if (_ActiveValue > 0)
                                    {
                                        sum += _ActiveValue;

                                        count++;
                                    }
                                }
                            }
                        }

                        StringAvg _StrAvg = new StringAvg();

                        if (count != 0)
                        {
                            _StrAvg.Avg = decimal.Round(sum / count, 2);
                        }
                        else
                        {
                            _StrAvg.Avg = 0;
                        }



                        _StrAvg.FieldName   = dt.Columns[i].ColumnName;
                        _StrAvg.ColumnIndex = i;

                        ListStringAvg.Add(_StrAvg);
                    }
                }
                ViewBag.StringAvg = ListStringAvg;
                //Inverter Toplam
                var invGroup = (from u in ListStringAvg
                                //group u by u.FieldName.Substring(0, 4) into g
                                select new StringInvNameAvg {
                    invName = "Inverter " + u.FieldName, Avg = Math.Round(u.Avg, 2)
                })
                               .ToList();

                ViewBag.ListInvAVG = invGroup;
                // avg bitti-----------------------------------------

                dt.Columns.Add("Tag", typeof(string)).SetOrdinal(0);

                TempDTO mt = strTagNames.AsEnumerable()
                             .GroupBy(r => r.NAME.Split('_')[0])
                             .Select(g => new TempDTO {
                    NAME = g.Key, ID = g.Count()
                })                                                                      //(g => new TempDTO{ NAME = g.OrderByDescending(r => r.NAME.Split('_')[0]  } )
                             .OrderByDescending(x => x.ID).ToList().First();


                List <string> tagTemp = strTagNames.Where(x => x.NAME.StartsWith(mt.NAME + "_")).Select(X => X.NAME).ToList();

                List <OrderValue> _ListOrderValueTemp = new List <OrderValue>();

                for (int i = 0; i < tagTemp.Count; i++)
                {
                    OrderValue _OrderValue = new OrderValue();

                    _OrderValue.InverterNumber = Convert.ToInt32(tagTemp[i].Split('_')[3].Replace(".", ""));
                    _OrderValue.InverterName   = tagTemp[i];

                    _ListOrderValueTemp.Add(_OrderValue);
                }

                List <OrderValue> _ListOrderValue = _ListOrderValueTemp.OrderBy(x => x.InverterNumber).ToList();

                List <string> tagCOl = new List <string>();

                for (int i = 0; i < _ListOrderValue.Count; i++)
                {
                    tagCOl.Add(_ListOrderValue[i].InverterName);
                }

                for (int i = 0; i <= tagCOl.Count - 1; i++)
                {
                    if (dt.Rows.Count < i)
                    {
                        break;
                    }
                    string[] ccc = tagCOl[i].Split('_');

                    if (tagCOl[i].Contains("temp"))
                    {
                        dt.Rows[i]["Tag"] = "Temp.";
                    }
                    else
                    {
                        dt.Rows[i]["Tag"] = ccc[1] + " " + ccc[2] + " " + ccc[3] + " " + ccc[4];
                    }
                }


                //ViewData["columns"] = columns;



                #region ColumnsSums
                DataTable _dtSums = dt.Clone();

                _dtSums.Rows.Clear();

                DataRow _drSums = _dtSums.NewRow();

                for (int i = 1; i < dt.Columns.Count; i++)
                {
                    decimal _sum = 0;

                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        if (dt.Rows[j][i] != DBNull.Value)
                        {
                            if (dt.Rows[j][i].ToString() != "-")
                            {
                                _sum += Convert.ToDecimal(dt.Rows[j][i]);
                            }
                        }
                    }

                    _drSums[i] = _sum;
                }

                _dtSums.Rows.Add(_drSums);
                #endregion

                #region StandardDeviation

                DataTable _dtSD = dt.Clone();
                _dtSD.Rows.Clear();

                DataRow _drSD = _dtSD.NewRow();

                List <StringAvg> _ListStringAvg = ViewBag.StringAvg as List <StringAvg>;

                for (int i = 1; i < dt.Columns.Count; i++)
                {
                    double _value = 0;

                    int n = -1;

                    double _avg = 0;

                    StringAvg _cAvg = _ListStringAvg.Where(x => x.FieldName == dt.Columns[i].ColumnName).FirstOrDefault();

                    if (_cAvg != null)
                    {
                        _avg = Convert.ToDouble(_cAvg.Avg);
                    }

                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        if (dt.Rows[j][i] != DBNull.Value)
                        {
                            if (dt.Rows[j][i].ToString() != "-")
                            {
                                n++;
                                double _value2 = Convert.ToDouble(dt.Rows[j][i]) - _avg;
                                _value2 = _value2 * _value2;
                                _value += _value2;
                            }
                        }
                    }

                    _value   = Math.Sqrt(_value / n);
                    _value   = Math.Round(_value, 2);
                    _drSD[i] = _value;
                }
                _dtSD.Rows.Add(_drSD);

                ViewBag._dtSD = _dtSD;
                #endregion
            }
            return(PartialView(dt));
        }
        private static void LoadTrwSubject(TrwBudgetPeriodDocDeal doc, IObjectSpace os, Dictionary <fmCOrder, OrderValue> rsp, TrwSubject trw_subj)
        {
            TrwSubjectDealSale other_sale = trw_subj.DealsSale.FirstOrDefault(x => x.DealType == TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER);
            TrwSubjectDealBay  other_bay  = trw_subj.DealsBay.FirstOrDefault(x => x.DealType == TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER);

            foreach (fmCSubject fm_subj in trw_subj.Subjects)
            {
                foreach (fmCOrder fm_order in fm_subj.Orders)
                {
                    rsp[fm_order]       = new OrderValue();
                    rsp[fm_order].Order = fm_order;
                    foreach (TrwSubjectDealBay trw_deal_bay in trw_subj.DealsBay)
                    {
                        TrwBudgetPeriodDocDeal.LineDeal line_deal = os.CreateObject <TrwBudgetPeriodDocDeal.LineDeal>();
                        line_deal.TrwSubjectDealBay = trw_deal_bay;
                        rsp[fm_order].DealLines.Add(line_deal);
                        doc.DocDealLines.Add(line_deal);
                        if (trw_deal_bay.DealType == TrwSubjectDealType.TRW_SUBJECT_DEAL_CONS_OTHER)
                        {
                            rsp[fm_order].OtherBayDealLine = line_deal;
                        }
                    }
//                    rsp[fm_order].OtherSaleDeal = other_sale;
//                    rsp[fm_order].OtherBayDeal = other_bay;
                }
                foreach (var deal_info in fm_subj.DealInfos)
                {
                    if (deal_info.Order == null || deal_info.Subject != fm_subj)
                    {
                        continue;
                    }
                    if (deal_info.DealType == DealInfoDealType.DEAL_INFO_PROCEEDS)
                    {
                    }
                    else if (deal_info.DealType == DealInfoDealType.DEAL_INFO_EXPENDITURE &&
                             deal_info.NomType == DealInfoNomType.DEAL_INFO_DELIVERY)
                    {
                        //if (!rsp.ContainsKey(deal_info.Order)) {
                        //    rsp[deal_info.Order] = new OrderValue();
                        //    rsp[deal_info.Order].Order = deal_info.Order;
                        //}
                        TrwSubjectDealBay deal_bay = CheckDealBase <TrwSubjectDealBay>(trw_subj.DealsBay, deal_info.Deal);
                        TrwBudgetPeriodDocDeal.LineDeal line_deal = rsp[deal_info.Order].DealLines.FirstOrDefault(x => x.TrwSubjectDealBay == deal_bay);
                        //if (line_deal == null) {
                        //    line_deal = os.CreateObject<TrwBudgetPeriodDocDeal.LineDeal>();
                        //    line_deal.TrwSubjectDealBay = deal_bay;
                        //    rsp[deal_info.Order].DealLines.Add(line_deal);
                        //    doc.DocDealLines.Add(line_deal);
                        //}
                        if (deal_info.Year == doc.Period.Year)
                        {
                            line_deal[deal_info.Month] += Decimal.Round(CheckSumm(doc.Period, deal_info.Valuta, deal_info.SummCost), 2);
                        }
                        else if (deal_info.Year > doc.Period.Year)
                        {
                            line_deal[13] += deal_info.SummCost;
                        }
                        else if (deal_info.Year < doc.Period.Year)
                        {
                            line_deal[0] += deal_info.SummCost;
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public ActionResult Pay([Bind(Include = "DiscountCode,dateTime,Way,UserAddressId,RestaurantTableCount")] OrderValue orderValue)
        {
            try
            {
                #region Queries
                var OrderList = userAppManager.FindAllOrderList().Where(a => a.UserId == User.Identity.GetUserId() && a.IsPay == false).OrderByDescending(a => a.OrderDate);
                int SumPrice  = 0;
                try
                {
                    var Discountcode_list = userAppManager.FindAllDiscountCode().Single(a => a.Code == orderValue.DiscountCode);
                    #endregion

                    #region Total Price Use Discount Code
                    SumPrice = OrderList.Sum(a => a.Food.Price * a.FoodCount) * (100 - Discountcode_list.Persent) / 100;
                    #endregion
                }
                catch
                {
                    SumPrice = OrderList.Sum(a => a.Food.Price * a.FoodCount);
                }
                #region Create Order
                Order order = new Order()
                {
                    UserId        = User.Identity.GetUserId(),
                    isPay         = true,
                    DiscountCode  = orderValue.DiscountCode,
                    TotalPrice    = SumPrice,
                    OrderStatusId = 1,
                    OrderTypeId   = Convert.ToInt32(orderValue.Way),
                    Date          = DateTime.Parse(orderValue.dateTime),
                    OrderDate     = DateTime.Now
                };
                userAppManager.AddOrder(order);
                #endregion

                #region OrderList => isPay = true
                foreach (var item in OrderList)
                {
                    OrderList orderlist = userAppManager.FindOrderList(item.Id);
                    orderlist.IsPay   = true;
                    orderlist.OrderId = order.Id;
                    userAppManager.EditOrderList(orderlist);
                }
                #endregion

                #region Way
                switch (orderValue.Way)
                {
                    #region Courier || UserAddressId
                case "1":

                    #region Create Courier
                    Courier courier = new Courier()
                    {
                        UserId        = User.Identity.GetUserId(),
                        OrderId       = order.Id,
                        UserAddressId = Convert.ToInt32(orderValue.UserAddressId)
                    };
                    userAppManager.AddCourier(courier);
                    #endregion

                    break;
                    #endregion

                    #region #region Reserve Table || RestaurantTableCount
                case "2":

                    #region Create Restaurant Table
                    RestaurantTable restaurantTable = new RestaurantTable()
                    {
                        UserId  = User.Identity.GetUserId(),
                        OrderId = order.Id,
                        Date    = Convert.ToDateTime(orderValue.dateTime),
                        Count   = Convert.ToInt32(orderValue.RestaurantTableCount),
                    };
                    userAppManager.AddRestaurantTable(restaurantTable);
                    #endregion

                    break;
                    #endregion

                    #region Get In Place
                case "3":

                    #region Create GetInPlace
                    GetInPlace getInPlcae = new GetInPlace()
                    {
                        UserId  = User.Identity.GetUserId(),
                        OrderId = order.Id,
                        Date    = DateTime.Parse(orderValue.dateTime)
                    };
                    userAppManager.AddGetInPlace(getInPlcae);
                    #endregion

                    break;
                    #endregion
                }
                #endregion

                #region Pass Params to Pay View
                ViewBag.Message1 = $"تبریک! پرداخت با موفقیت انجام شد! شماره سفارش شما {order.Id} می باشد.";
                #endregion
            }
            catch (Exception ex)
            {
                #region Pass Params to Pay View
                ViewBag.Message2 = ex.Message;
                #endregion
            }

            return(View());
        }
Exemplo n.º 10
0
 public ArrayList GetWordsListAll(bool WithFlag, bool ReSort)
 {
     if (!this.m_isOpen)
     {
         return null;
     }
     ArrayList list = new ArrayList();
     for (int i = 0; i < 0x51a5; i++)
     {
         if (this.m_WordsList[i].m_List != null)
         {
             for (int j = 0; j < this.m_WordsList[i].m_List.Count; j++)
             {
                 if (WithFlag)
                 {
                     list.Add(((char) (i + 0x4e00)).ToString() + this.m_WordsList[i].m_List[j].ToString());
                 }
                 else
                 {
                     list.Add(this.m_WordsList[i].m_List[j]);
                 }
             }
         }
     }
     if (ReSort)
     {
         OrderValue comparer = new OrderValue();
         list.Sort(comparer);
     }
     return list;
 }