示例#1
0
        //private static void InitErrorLog(Exception ex, string ModuleName) { Logger.LogSYSTEM(LogLevel.ERROR, LanguageManager.Language["STR_LOG_WEB_MODULE_ERROR"], ex, ModuleName); }

        public static bool Add(string WebPath, IRouter Module, string Name = null)
        {
            string name = Name ?? Module.GetType().Name;

            if (!Modules.ContainsKey(WebPath))
            {
                try
                {
                    Module.Attach(Language);
                    Modules.Add(WebPath, Module);
                    Adding?.Invoke(string.Format("[{0}] Router: [{1}] {2} ({3})", Language["STR_SUCCESS"], WebPath, Name, Module.GetType().Name), null);
                    return(true);
                }
                catch (Exception ex)
                {
                    Adding?.Invoke(string.Format("[{0}] Router: [{1}] {2} ({3})", Language["STR_ERROR"], WebPath, Name, Module.GetType().Name), ex);
                    return(false);
                }
            }
            else
            {
                Adding?.Invoke(string.Format("[{0}] Router: [{1}] {2} ({3})", Language["STR_EXIST"], WebPath, Name, Module.GetType().Name), null);
                return(false);
            }

            //if (Modules.ContainsKey(Path)) Modules[Path] = Module;
            //else Modules.Add(Path, Module);
        }
示例#2
0
        public static bool AddByAssembly(params string[] ModulePath)
        {
            if (ModulePath?.Length > 0)
            {
                Adding?.Invoke(Language["STR_LOG_CONTROLLER_INITING"], null);

                try
                {
                    for (int i = 0; i < ModulePath.Length; i++)
                    {
                        //나중에 함수 하나 만들기
                        Assembly asm = Assembly.LoadFrom(ModulePath[i]);

                        Adding?.Invoke(string.Format(Language["STR_LOG_CONTROLLER_LOADING"], ModulePath[i]), null);

                        foreach (Type type in asm.GetTypes())
                        {
                            if (type.IsImplement(ControllerType))
                            {
                                //컨트롤러 초기화
                                ((IController)Activator.CreateInstance(type)).Init(ref Language);
                                Adding?.Invoke($"[{Language["STR_SUCCESS"]}] Controller: {type.Name}", null);
                            }
                        }
                    }
                    Adding?.Invoke(string.Format(Language["STR_LOG_CONTROLLER_INITED"]), null);
                }
                catch (Exception ex) { Adding?.Invoke(Language["STR_LOG_CONTROLLER_ERROR"], ex); return(false); }
            }

            return(true);
        }
示例#3
0
        public void AddingTask(IProduct product, int count)
        {
            Adding helper = new Adding(Storage, product, count);

            helper.Notify += DisplayMessage;
            CommandQueue.Enqueue(helper);
        }
        public ActionResult IncreaseQuantity(int id)
        {
            Adding findAdding = db.Addings.Find(id);

            try
            {
                if (ModelState.IsValid)
                {
                    if (TryUpdateModel(findAdding))
                    {
                        findAdding.Quantity             = findAdding.Quantity + 1;
                        findAdding.TotalPricePerProduct = findAdding.Quantity * findAdding.Product.Price;
                        db.SaveChanges();
                        TempData["message"] = "Cantitatea produsului s-a modificat!";
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["message"] = "Nu s-a putut creste cantitatea!";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    TempData["message"] = "Nu s-a putut creste cantitatea!";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                TempData["message"] = "Nu s-a putut creste cantitatea!";
                return(RedirectToAction("Index"));
            }
        }
示例#5
0
文件: CarPark.cs 项目: 1is0/Nemkovich
 public void Add(int n, int m)
 {
     Console.ForegroundColor = ConsoleColor.DarkRed;
     Adding?.Invoke($"You build {n} places to relax and {m} manholes.");
     Console.ResetColor();
     PlacesToRelax += n;
     Manholes      += m;
 }
示例#6
0
 public AdminController(
     ITestingDbEntityService context) : base(context)
 {
     _lectureHistoryHelper = new LectureHistoryHelper(Context);
     _adding          = new Adding(Context);
     _deleting        = new Deleting(Context);
     _editing         = new Editing(Context);
     _adminPageHelper = new AdminPageHelper(Context);
 }
        public ActionResult DeleteProduct(int id)
        {
            Adding findAdding = db.Addings.Find(id);

            db.Addings.Remove(findAdding);
            db.SaveChanges();
            TempData["message"] = "Produsul a  fost eliminat din cos!";
            return(RedirectToAction("Index"));
        }
示例#8
0
        public static bool AddByAssembly(params string[] ModulePath)
        {
            for (int i = 0; i < ModulePath.Length; i++)
            {
                try
                {
                    if (ModulePath != null && ModulePath.Length > 0)
                    {
                        string path = ModulePath[i];
                        if (!File.Exists(path))
                        {
                            string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                            path = StringUtils.PathMaker(dir, path);
                            if (!File.Exists(path))
                            {
                                continue;
                            }
                        }
                        Adding?.Invoke(string.Format(Language["STR_LOG_WEB_ROUTER_LOADING"], ModulePath[i]), null);

                        Assembly asm = Assembly.LoadFrom(path);

                        /*
                         * IEnumerable<string> result = asm.GetTypes()
                         *  .Where(type =>
                         *  type.Namespace == NameSpace)
                         *  .Select(type => type.Name);
                         */

                        foreach (Type type in asm.GetTypes())
                        {
                            if (type.IsImplement(RouterType))
                            {
                                foreach (var attr in type.GetCustomAttributes(AttributeType))
                                {
                                    if (attr is RouterAttribute module)
                                    {
                                        if (module.AutoRegister)
                                        {
                                            try { Add(module.Path, (IRouter)Activator.CreateInstance(type), module.Name); }
                                            catch (Exception ex) { Adding?.Invoke(string.Format(Language["STR_LOG_WEB_ROUTER_ERROR"], module.Name), ex); return(false); }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    Adding?.Invoke(string.Format(Language["STR_LOG_WEB_ROUTER_LOADED"]), null);
                }
                catch (Exception ex) { Adding?.Invoke(Language["STR_LOG_WEB_ROUTER_ERROR"], ex); return(false); }
            }

            return(true);
        }
示例#9
0
        public static bool AddByAssembly(params string[] ModulePath)
        {
            if (ModulePath != null && ModulePath.Length > 0)
            {
                for (int i = 0; i < ModulePath.Length; i++)
                {
                    try
                    {
                        //나중에 함수 하나 만들기
                        Assembly asm = Assembly.LoadFrom(ModulePath[i]);

                        Adding?.Invoke(string.Format(Language["STR_LOG_WEB_MIDDLEWARE_LOADING"], ModulePath[i]), null);
                        foreach (Type type in asm.GetTypes())
                        {
                            //Console.WriteLine("======");
                            //Console.WriteLine("TYPE: " + type.GetType());
                            //Console.WriteLine("NAME: " + type.Name);

                            if (type.IsImplement(MiddlwareType))
                            {
                                foreach (var attr in type.GetCustomAttributes(AttributeType))
                                {
                                    if (attr is MiddlewareAttribute module)
                                    {
                                        //Console.WriteLine("ATTR_NAME: " + mw.Name);
                                        //Console.WriteLine("ATTR_AUTO: " + mw.AutoRegister);
                                        if (module.AutoRegister)
                                        {
                                            try { Add((IMiddleware)Activator.CreateInstance(type), module.Name, module.Priority); }
                                            catch (Exception ex) { Adding(string.Format(Language["STR_LOG_WEB_MIDDLEWARE_ERROR"], type.Name), ex); return(false); }
                                            break;
                                        }
                                        else
                                        {
                                            Adding(string.Format("[Unload] WebMiddleWare: {{ {0} ({1}) }}, Priority={2}", module.Name, type.Name, module.Priority), null);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex) { Adding(Language["STR_LOG_WEB_MIDDLEWARE_ERROR"], ex); return(false); }
                }

                Adding?.Invoke(string.Format(Language["STR_LOG_WEB_MIDDLEWARE_LOADED"]), null);
            }

            return(true);
        }
        public ActionResult DecreaseQuantity(int id)
        {
            Adding findAdding = db.Addings.Find(id);

            if (findAdding.Quantity > 1) // daca produsul care cantitatea 1, atunci nu se mai poate scade cantitatea
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        if (TryUpdateModel(findAdding))
                        {
                            findAdding.Quantity             = findAdding.Quantity - 1;
                            findAdding.TotalPricePerProduct = findAdding.Quantity * findAdding.Product.Price;
                            db.SaveChanges();
                            TempData["message"] = "Cantitatea produsului s-a modificat!";
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            TempData["message"] = "Nu s-a putut micsora cantitatea!";
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        TempData["message"] = "Nu s-a putut micsora cantitatea!";
                        return(RedirectToAction("Index"));
                    }
                }
                catch (Exception e)
                {
                    TempData["message"] = "Nu s-a putut micsora cantitatea!";
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["message"] = "Pentru a sterge produsul din cos apasati butonul corespunzator!";
                return(RedirectToAction("Index"));
            }
        }
示例#11
0
        public static bool Add(IMiddleware MiddleWare, string Name, MiddlewarePriority Priority = MiddlewarePriority.Normal)
        {
            string name = Name == null?MiddleWare.GetType().Name : Name;

            try
            {
                MiddleWare.Attach(Language);
                if (!Middlewares.ContainsKey(Priority))
                {
                    Middlewares.Add(Priority, new List <IMiddleware>());
                }
                Middlewares[Priority].Add(MiddleWare);

                Adding?.Invoke(string.Format("[{0}] MiddleWare: {{ {1} ({2}) }}, Priority={3} }}", Language["STR_SUCCESS"], name, MiddleWare.GetType().Name, Priority), null);
                return(true);
            }
            catch (Exception ex)
            {
                Adding?.Invoke(string.Format("[{0}] MiddleWare: {{ {1} ({2}) }}, Priority={3} }} ({4})", Language["STR_ERROR"], name, MiddleWare.GetType().Name, Priority, ex.Message), null);
                return(false);
            }
        }
 private void backbt2_Click(object sender, EventArgs e)
 {
     LandingPanel.Show();
     Adding.Hide();
 }
 private void button1_Click_1(object sender, EventArgs e)
 {
     Adding.Show();
     AddingDept.Hide();
 }
 private void addempbut_Click(object sender, EventArgs e)
 {
     WritingPanel.Show();
     Adding.Hide();
 }
 private void WriteButton_Click(object sender, EventArgs e)
 {
     Adding.Show();
     LandingPanel.Hide();
 }
示例#16
0
 public Administrator()
 {
     addBehaviour    = new Adding();
     editBehaviour   = new Editing();
     removeBehaviour = new Removing();
 }
示例#17
0
 protected virtual void OnAdding(EventArgs ea) => Adding?.Invoke(this, ea);
示例#18
0
 public void Add(int n)
 {
     Adding?.Invoke($"Вы добавляете в комнату {n} окон.");
     Windows += n;
 }
        public ActionResult AddToCart(int id)
        {
            if (TempData.ContainsKey("sortare"))
            {
                ViewBag.Sort        = TempData["sortare"].ToString();
                TempData["sortare"] = TempData["sortare"];
            }

            try
            {
                Product product           = db.Products.Find(id);
                var     utilizator_curent = User.Identity.GetUserId();
                var     produse_din_cos   = from produse in db.Addings.Include("Product").Include("ShoppingCart")
                                            where produse.ShoppingCart.UserId == utilizator_curent &&
                                            produse.ShoppingCart.UsedForOrder == false
                                            select produse.ProductId; // id-ul produselor deja existente in cosul user-ului
                if (produse_din_cos.Contains(id))
                {
                    if (ModelState.IsValid)
                    {
                        var addingId = (from adding in db.Addings.Include("Product").Include("ShoppingCart")
                                        where adding.ProductId == id && adding.ShoppingCart.UserId == utilizator_curent &&
                                        adding.ShoppingCart.UsedForOrder == false
                                        select adding.AddingId).FirstOrDefault(); // gasesc in tabelul asociativ id-ul liniei in care
                                                                                  // produsul e produsul care se doreste a fi adaugat din nou
                                                                                  // si cosul de cumparaturi e al utilizatorului curent
                        Adding findProduct = db.Addings.Find(addingId);
                        if (TryUpdateModel(findProduct))
                        {
                            findProduct.Quantity             = findProduct.Quantity + 1;
                            findProduct.TotalPricePerProduct = findProduct.Quantity * findProduct.Product.Price;
                            db.SaveChanges();
                            TempData["message"] = "Produsul a fost adaugat in cos!";
                            return(Redirect("/Products/Index?OrderByString=" + ViewBag.Sort));
                        }
                        else
                        {
                            TempData["message"] = "Adaugarea produsului in cos a esuat! Reincercati!";
                            return(RedirectToAction("Index", "Products"));
                        }
                    }
                    else
                    {
                        TempData["message"] = "Adaugarea produsului in cos a esuat! Reincercati!";
                        return(RedirectToAction("Index", "Products"));
                    }
                }
                else
                {
                    Adding addProduct = new Adding();
                    addProduct.ProductId = product.ProductId;
                    var shopId = from cart in db.ShoppingCarts
                                 where cart.UserId == utilizator_curent && cart.UsedForOrder == false
                                 select cart.ShoppingCartId;
                    addProduct.ShoppingCartId = shopId.FirstOrDefault(); // gasim cosul de cumprataturi al user-ului curent

                    addProduct.Quantity             = 1;
                    addProduct.TotalPricePerProduct = product.Price;
                    if (ModelState.IsValid)
                    {
                        db.Addings.Add(addProduct);
                        db.SaveChanges();
                        TempData["message"] = "Produsul a fost adaugat in cos!";
                        return(Redirect("/Products/Index?OrderByString=" + ViewBag.Sort));
                    }
                    else
                    {
                        TempData["message"] = "Adaugarea produsului in cos a esuat! Reincercati!";
                        return(RedirectToAction("Index", "Products"));
                    }
                }
            }
            catch (Exception e)
            {
                TempData["message"] = "Adaugarea produsului in cos a esuat! Reincercati!";
                return(RedirectToAction("Index", "Products"));
            }
        }
示例#20
0
 public void Put(int sum)
 {
     Adding?.Invoke($"На счёт добавляется {sum}"); //событие имеет те же параметры что и делегат который они представляют
     _sum += sum;
     Added?.Invoke($"На счёт пришло {sum}");
 }
 public void RunAdd5()
 {
     var add5 = new Adding();
     Console.WriteLine(add5.Add5(10));
 }
示例#22
0
        static void Main()
        {
            string locked     = "";
            string directions = "";
            string awards     = "";

            Console.WriteLine("Risoluzione problema scacchi");
            Console.WriteLine();
            Console.WriteLine("Inserire coordinate limiti campo");
            Console.Write("Inserire x e y separando con la virgola -->");
            var limit = Adding.CreateCoordinateByString("(" + Console.ReadLine().Trim() + ")");

            Console.WriteLine();

            Console.WriteLine("Inserire coordinate della posizione di inizio");
            Console.Write("Inserire x e y separando con la virgola -->");
            var start = Adding.CreateCoordinateByString("(" + Console.ReadLine().Trim() + ")");

            Console.WriteLine();

            Console.WriteLine("Inserire coordinate della posizione di arrivo");
            Console.Write("Inserire x e y separando con la virgola -->");
            var arrive = Adding.CreateCoordinateByString("(" + Console.ReadLine().Trim() + ")");

            Console.WriteLine();

            Console.WriteLine("Inserire coordinate celle bloccate");
            do
            {
                Console.Write("Inserire x e y separando con la virgola (! =stop) -->");
                string temp = Console.ReadLine().Trim();
                if (temp[0] != '!')
                {
                    locked += "(" + temp + ")";
                }
                else
                {
                    break;
                }
            } while (true);

            var listLocked = Adding.CreateLockedCells(locked);

            Console.WriteLine();
            Console.WriteLine("Inserire direzioni consentite: seguendo la rosa dei venti");
            Console.WriteLine("Direzioni possibili:(nne)(ene)(ese)(sse)(nno)(ono)(oso)(sso)");
            do
            {
                Console.Write("Inserire direzione (! =stop) -->");
                string temp = Console.ReadLine().Trim();
                if (temp[0] != '!')
                {
                    directions += "(" + temp + ")";
                }
                else
                {
                    break;
                }
            } while (true);

            var listDirections = Adding.CreateDirections(directions);

            Console.WriteLine();
            Console.WriteLine("Inserire coordinate dei premi e penalità, x e y e valore premio separando con la virgola ");
            do
            {
                Console.Write("Inserire premio (! =stop) -->");
                string temp = Console.ReadLine().Trim();
                if (temp[0] != '!')
                {
                    awards += "(" + temp + ")";
                }
                else
                {
                    break;
                }
            } while (true);

            var listAward = Adding.CreateAwards(awards);

            Console.WriteLine();
            Console.WriteLine("Possibili percorsi:");
            Console.WriteLine();


            MyChessBoard chess = new MyChessBoard
                                 (
                start, arrive, limit, listLocked, listDirections
                                 );


            Console.WriteLine();
            foreach (var list in chess)
            {
                List <int> containedAwards = new List <int>();
                string     toprint         = "";
                int        sommaPremi      = 0;
                foreach (var node in list)
                {
                    toprint += node.ToString();
                    foreach (var premio in listAward)
                    {
                        if (node.Equals(premio.Key))
                        {
                            containedAwards.Add(premio.Value);
                        }
                    }
                }
                Console.Write($"{ toprint} =contiene i premi: ");
                if (containedAwards.Count > 0)
                {
                    foreach (var valore in containedAwards)
                    {
                        Console.Write($"{valore}, ");
                        sommaPremi += valore;
                    }
                    Console.WriteLine($" ={sommaPremi}");
                }
                else
                {
                    Console.WriteLine("nessuno");
                }
            }

            Console.ReadLine();
        }
示例#23
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnAdding
 ///
 /// <summary>
 /// Adding イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnAdding(ValueCancelEventArgs <int> e)
 => Adding?.Invoke(this, e);
示例#24
0
 private void button1_Click(object sender, EventArgs e)
 {
     Adding frm = new Adding();
     frm.Show();
 }
示例#25
0
文件: Form1.cs 项目: HaciIsma/Logbook
 private void Form1_Load(object sender, System.EventArgs e)
 {
     Adding.Invoke(this, e);
 }
示例#26
0
        private void button1_Click(object sender, EventArgs e)
        {
            Adding frm = new Adding();

            frm.Show();
        }
示例#27
0
 public void Add(int n, int m)
 {
     Adding?.Invoke($"Вы добавляете в комнату {n} окон и {m} дверей.");
     Windows += n;
     Doors   += m;
 }
示例#28
0
        public MvcApplication()
        {
            var context = new testingDbEntities();

            _adding = new Adding(context);
        }
示例#29
0
文件: CarPark.cs 项目: 1is0/Nemkovich
 public void Add(int n)
 {
     Adding?.Invoke($"You build {n} places to telax.");
     PlacesToRelax += n;
 }
示例#30
0
 public void Subscribe(Adding addMethod, Removing removeMethod)
 {
     AddEntityEvent    += addMethod;
     RemoveEntityEvent += removeMethod;
 }
示例#31
0
 /// <summary>Raises the <see cref="E:Adding"/> event.
 /// </summary>
 /// <param name="args">The <see cref="Dodoni.BasicComponents.Containers.ItemAddingEventArgs"/> instance containing the event data.</param>
 protected virtual void OnAdding(ItemAddingEventArgs args)
 {
     Adding?.Invoke(this, args);
 }
示例#32
0
 // Добавление средств на счёт
 public void Put(int sum)
 {
     Adding?.Invoke(this, new AccountEventArgs($"На счет добовляется: {sum}", sum));
     Sum += sum;
     Added?.Invoke(this, new AccountEventArgs($"На счет поступило: {sum}", sum));
 }