Пример #1
0
 public ActionResult ResetPassword(ResetPassModel mod)
 {
     using (TimchurDatabaseEntities ent = new TimchurDatabaseEntities())
     {
         bool valid = ent.Users.Where(x => x.IDCardNumber == mod.Id && x.Email == mod.Email).Count() > 0;
         bool exist = false;
         foreach (String s in LoginController.email_key.Keys)
         {
             if (s.CompareTo(mod.Email) == 0)
             {
                 exist = true;
             }
         }
         bool key_email_validation = exist && LoginController.email_key[mod.Email].CompareTo(mod.Key) == 0;
         if (valid && key_email_validation)
         {
             Cache.gen_lock.WaitOne();
             var my_use = ent.Users.Where(x => x.IDCardNumber == mod.Id && x.Email == mod.Email);
             foreach (Users use in my_use)
             {
                 use.Password = mod.NewPass.ToString();
             }
             ent.SaveChanges();
             Cache.gen_lock.ReleaseMutex();
             ModelState.AddModelError("הצליח", "שינוי פרטים הצליח");
             return(View(mod));
         }
         else
         {
             ModelState.AddModelError("שגיאה", "פרטים לא נכונים, אנא וודא את השדות ושלח שוב");
             return(View(mod));
         }
     }
 }
Пример #2
0
 public ActionResult CancelTichur(TCanData can)
 {
     Cache.gen_lock.WaitOne();
     try
     {
         using (TimchurDatabaseEntities ent = new TimchurDatabaseEntities())
         {
             Tichurim tic = ent.Tichurim.Where(x => x.TichurNumber == can.id).FirstOrDefault();
             foreach (SuppliersTichurim sti in tic.SuppliersTichurim)
             {
                 if (sti.Suppliers.SuppliersClusetrs.Where(x2 => x2.ClusetrID == tic.ClusterID).First().LastTimeInList == tic.DateTimeCreated)
                 {
                     sti.Suppliers.SuppliersClusetrs.Where(x2 => x2.ClusetrID == tic.ClusterID).First().LastTimeInList = sti.Suppliers.SuppliersClusetrs.Where(x2 => x2.ClusetrID == tic.ClusterID).First().FormarLastTimeInList;
                 }
             }
             tic.UpdatedUserID   = ent.Users.Where(x => x.IDCardNumber == User.Identity.Name).First().ID;
             tic.DateTimeUpdated = DateTime.Now;
             tic.StatusID        = 2;
             tic.UpdatedComment  = can.comment;
             ent.SaveChanges();
             Cache.gen_lock.ReleaseMutex();
             return(Json("ביטול תיחור הצליח"));
         }
     }
     catch (Exception e)
     {
         Cache.gen_lock.ReleaseMutex();
         return(Json("ביטול תיחור נכשל"));
     }
 }
Пример #3
0
        public void AddAuctionOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    entity.Auctions.Add(((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    string strm = ((Auctions)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).AuctionNumber;
                    id = entity2.Auctions.Where(x => x.AuctionNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,מכרז נוסף למערכת";
            }
            catch (Exception e)
            {
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,הוספת מכרז נכשלה";
            }
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        /// <summary>
        /// Saves the stored update of a unit into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void editUnitOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            UnitFModel mf = null;

            if (SingletonCache.Instance().Storage.ContainsKey(Context.User.Identity.Name))
            {
                mf = ((UnitFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]);
            }
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    var original = entity.Units.Find(mf.unit.ID);


                    if (original != null)
                    {
                        entity.UnitsAuctions.RemoveRange(entity.UnitsAuctions.Where(x => x.UnitID == mf.unit.ID));
                        if (mf.Limitations != null)
                        {
                            foreach (int i in mf.Limitations)
                            {
                                UnitsAuctions ua = new UnitsAuctions();
                                ua.AuctionID = i;
                                ua.UnitID    = mf.unit.ID;
                                entity.UnitsAuctions.Add(ua);
                            }
                        }
                        entity.Entry(original).CurrentValues.SetValues(((UnitFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]).unit);
                        entity.SaveChanges();
                    }
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    int strm = mf.unit.ID;
                    id = entity2.Units.Where(x => x.ID == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, יחידה עודכה במערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, עדכון יחידה נכשל במערכת";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        /// <summary>
        /// Saves the stored update of an auction into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void EditAuctionOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    var original = entity.Auctions.Find(((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]).ID);

                    if (original != null)
                    {
                        Auctions curr = ((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]);

                        entity.Entry(original).CurrentValues.SetValues(((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                        entity.SaveChanges();
                    }

                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    string strm = ((Auctions)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).AuctionNumber;
                    id = entity2.Auctions.Where(x => x.AuctionNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, מכרז עודכן במערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, עדכון מכרז נכשל";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
Пример #6
0
        public void EditClusetrOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    var original = entity.Clusetrs.Find(((Clusetrs)SingletonCache.Instance().Storage[Context.User.Identity.Name]).ID);

                    if (original != null)
                    {
                        entity.Entry(original).CurrentValues.SetValues(((Clusetrs)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                        entity.SaveChanges();
                    }

                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    byte strm = ((Clusetrs)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).DisplayNumber.Value;
                    id = entity2.Clusetrs.Where(x => x.DisplayNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,סל עודכן במערכת";
            }
            catch (Exception e)
            {
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,עדכון סל נכשל";
            }
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        /// <summary>
        /// Saves the stored creation of a unit into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void AddUnitOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            UnitFModel mf = ((UnitFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]);

            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    entity.Units.Add(mf.unit);
                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    string strm = mf.unit.Name;
                    id = entity2.Units.Where(x => x.Name == strm).First().ID;
                    if (mf.Limitations != null)
                    {
                        foreach (int i in mf.Limitations)
                        {
                            UnitsAuctions ua = new UnitsAuctions();
                            ua.AuctionID = i;
                            ua.UnitID    = id;
                            entity2.UnitsAuctions.Add(ua);
                        }
                    }
                    entity2.SaveChanges();
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, יחידה נוספה למערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, הוספת יחידה נכשלה";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        /// <summary>
        /// Saves the stored creation of a cluster into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void AddClusterOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    entity.Clusters.Add(((Clusters)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    byte strm = ((Clusters)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).DisplayNumber.Value;
                    id = entity2.Clusters.Where(x => x.DisplayNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, סל נוסף למערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, הוספת סל נכשלה";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
Пример #9
0
        public ActionResult GetByTichurNumber(TNData data)
        {
            using (TimchurDatabaseEntities ent = new TimchurDatabaseEntities())
            {
                Users  use     = ent.Users.Where(x => x.IDCardNumber == User.Identity.Name).First();
                bool   f       = User.IsInRole("Admin");
                string uni_fin = User.IsInRole("Admin") ? data.unit_field : use.UnitID.ToString();
                int    tem     = 0;
                if (uni_fin != null)
                {
                    tem = Int32.Parse(uni_fin);
                }
                if (tem == 0 || ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && (f || x.StatusID == 1)).Count() == 0)
                {
                    GenModel failRes = new GenModel();
                    failRes.data = new List <string[]>();
                    failRes.data.Add(new string[] { "תיחור אינו קיים בתוך השרת(או תחת היחידה הנתונה של המשתמש או שהוכנסה)" });
                    failRes.Status = "error";
                    return(Json(failRes));
                }

                if (!User.IsInRole("User"))
                {
                    if (data.unit_field == null)
                    {
                        GenModel failRes = new GenModel();
                        failRes.data = new List <string[]>();
                        failRes.data.Add(new string[] { "אנא בחר ערך בשדה יחידה" });
                        failRes.Status = "error";
                        return(Json(failRes));
                    }
                }

                Tichurim tic = ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && (f || x.StatusID == 1)).First();
                if (ent.UnitsAuctions.Where(x => x.UnitID == tem && x.AuctionID == tic.Clusetrs.AuctionID).Count() > 0)
                {
                    if (User.IsInRole("User"))
                    {
                        Cache.gen_lock.WaitOne();
                        ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && x.StatusID == 1).First().DateTimeSelected = DateTime.Now;
                        ent.SaveChanges();
                        Cache.gen_lock.ReleaseMutex();
                    }
                    tic = ent.Tichurim.Where(x => x.UnitID == tem && x.TichurNumber == data.id && (f || x.StatusID == 1)).First();
                    GenModel Res = new GenModel();
                    Res.Status = "K";
                    Res.data   = new List <string[]>();
                    Res.data.Add(new string[] { "מספר שורה", "מס' בתוצאת שליפה", "יחידה", "מס' מכרז", "שם מכרז", "תיחור", "מספר סל", "שם סל", "שם ספק", "ח.פ", "איש קשר", "אימייל", "טלפון", "תאריך ושעה" });
                    int i = 0;
                    foreach (SuppliersTichurim st in tic.SuppliersTichurim)
                    {
                        Suppliers sup = ent.Suppliers.Where(x => x.ID == st.SupplierID).First();
                        i++;
                        Res.data.Add(new string[] { i.ToString(), st.PositionInList.ToString(), tic.Units.Name, tic.Clusetrs.Auctions.AuctionNumber, tic.Clusetrs.Auctions.Name, tic.TichurNumber, tic.Clusetrs.DisplayNumber.Value.ToString(), tic.Clusetrs.Name, sup.Name, sup.CompanyNumber, sup.ContactName, sup.EmailAddress, sup.PhoneNumber, tic.DateTimeCreated.Value.ToString() });
                    }
                    return(Json(Res));
                }
                else
                {
                    GenModel failRes = new GenModel();
                    failRes.data = new List <string[]>();
                    failRes.data.Add(new string[] { "משתמש אינו רשאי לצפות בתיחור" });
                    failRes.Status = "error";
                    return(Json(failRes));
                }
            }
        }
Пример #10
0
        public void editSupplierOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            SupplierFModel mf = ((SupplierFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]);

            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    var original = entity.Suppliers.Find(mf.supliers.ID);


                    if (original != null)
                    {
                        if (mf.Limitions != null)
                        {
                            foreach (int i in mf.Limitions)
                            {
                                SuppliersClusetrs ua = new SuppliersClusetrs();
                                if (entity.SuppliersClusetrs.Where(x => x.ClusetrID == i && x.SupplierID == mf.supliers.ID).Count() > 0)
                                {
                                    entity.SuppliersClusetrs.Where(x => x.ClusetrID == i && x.SupplierID == mf.supliers.ID).First().StatusID = 1;
                                }
                                else
                                {
                                    ua.ClusetrID            = i;
                                    ua.SupplierID           = id;
                                    ua.FormarLastTimeInList = new DateTime(2000, 1, 1);
                                    ua.LastTimeInList       = new DateTime(2000, 1, 1);
                                    ua.StatusID             = 1;
                                    entity.SuppliersClusetrs.Add(ua);
                                }
                            }
                        }
                        foreach (SuppliersClusetrs sc in entity.SuppliersClusetrs.Where(x => !mf.Limitions.Contains(x.ClusetrID) && x.SupplierID == mf.supliers.ID))
                        {
                            sc.StatusID = 2;
                        }
                        if (mf.ActualEmail == null)
                        {
                            mf.supliers.EmailAddress = "";
                        }
                        else
                        {
                            mf.supliers.EmailAddress = mf.ActualEmail;
                        }

                        mf.supliers.PhoneNumber = mf.Prefix + mf.ActualNumber;
                        entity.Entry(original).CurrentValues.SetValues(((SupplierFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]).supliers);
                        entity.SaveChanges();
                    }
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    int strm = mf.supliers.ID;
                    id = entity2.Suppliers.Where(x => x.ID == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,יחידה עודכה במערכת";
            }
            catch (Exception e)
            {
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,הוספת יחידה נכשלה במערכת";
            }
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
Пример #11
0
        public void AddSupplierOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            SupplierFModel mf = ((SupplierFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]);

            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    if (mf.ActualEmail == null)
                    {
                        mf.supliers.EmailAddress = "";
                    }
                    else
                    {
                        mf.supliers.EmailAddress = mf.ActualEmail;
                    }

                    mf.supliers.PhoneNumber = mf.Prefix + mf.ActualNumber;
                    entity.Suppliers.Add(mf.supliers);
                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    string strm = mf.supliers.Name;
                    id = entity2.Suppliers.Where(x => x.Name == strm).First().ID;
                    if (mf.Limitions != null)
                    {
                        foreach (int i in mf.Limitions)
                        {
                            SuppliersClusetrs ua = new SuppliersClusetrs();
                            ua.ClusetrID            = i;
                            ua.SupplierID           = id;
                            ua.FormarLastTimeInList = new DateTime(2000, 1, 1);
                            ua.LastTimeInList       = new DateTime(2000, 1, 1);
                            ua.StatusID             = 1;
                            entity2.SuppliersClusetrs.Add(ua);
                        }
                    }
                    entity2.SaveChanges();
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,ספק נוספה למערכת";
            }
            catch (Exception e)
            {
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,הוספת ספק נכשלה";
            }
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }