public void set5S(loggedInUser user, int id, string comment, string status)
        {
            var s5 = (from s in context.GetShift5S where s._5SDoneID == id select s).First();

            s5.Performed     = true;
            s5.PerformedBy   = user.currShift.shift;
            s5.PerformedTime = DateTime.Now;
            s5.Comment       = comment;
            s5.Status        = status;
            context.SaveChanges();
        }
 /* Update the tasks done and todo from the user */
 public void update5S(loggedInUser user)
 {
     if (user.maskin != "RVL")
     {
         int shift = rmvLast(user.selShift.shift);
         _5sDone = (from s in context.GetShift5S where s.Machine == user.maskin && s.PerformedBy == user.selShift.shift select s).AsEnumerable().Where(s => rmvLast(s.shift) <= shift && rmvLast(s.Duration) >= shift);
         _5sTodo = (from s in context.GetShift5S where s.Machine == user.maskin && s.Performed == false select s).AsEnumerable().Where(s => rmvLast(s.shift) <= shift && rmvLast(s.Duration) >= shift);
         numDone = _5sDone.Count();
         numTodo = _5sTodo.Count();
         if (user.currShift.shift != user.selShift.shift || user.userlevel == "gast")
         {
             submitClass = "btn btn-default disabled";
             canSubmit   = "disabled";
         }
         else
         {
             submitClass = "btn btn-default";
             canSubmit   = "";
         }
     }
 }
        /* Get Data_uri, convert to image and save to disk */
        public void saveImage(string id, string uri, loggedInUser user)
        {
            string hyperlink;

            uri = uri.Split(',')[1];
            byte[] imageBytes = Convert.FromBase64String(uri);
            using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length)) {
                Image  image    = Image.FromStream(ms, true);
                string partLink = "";
                switch (user.Machno)
                {
                case 1:
                    partLink = links[0];
                    break;

                case 2:
                    partLink = links[1];
                    break;

                case 3:
                    partLink = links[2];
                    break;

                case 4:
                    partLink = links[3];
                    break;

                case 5:
                    partLink = links[4];
                    break;

                case 7:
                    partLink = links[5];
                    break;

                case 9:
                    partLink = links[8];
                    break;

                case 11:
                    partLink = links[6];
                    break;

                case 12:
                    partLink = links[7];
                    break;

                default:
                    break;
                }
                hyperlink = "\\\\s0000291\\archive\\Function\\1-Produktion\\Produktionsteam\\" + partLink + "5S_Säkerhetsrond\\Bilder\\Felaktigheter\\IMG" + id + "_" + DateTime.Now.ToString("yyMMdd") + ".jpg";
                try
                {
                    image.Save(hyperlink, ImageFormat.Jpeg);
                }
                catch (Exception e) {
                    user.errorText = "Error: Could not save Image";
                }
            }
            int nId     = int.Parse(id);
            var _5sTask = (from s in context.GetShift5S where s._5SDoneID == nId select s).First();

            _5sTask.HyperLink = hyperlink;
            context.SaveChanges();
        }
Beispiel #4
0
 public MachineTargetFunctions(dbContext context, loggedInUser user)
 {
     this.context = context;
     this.user    = user;
     prodShift    = (from p in context.ProdShift where p.Machine == user.maskin && p.ShiftNo == user.selShift.shiftno select p).FirstOrDefault();
 }
Beispiel #5
0
        public void addValues(FormCollection form, loggedInUser user)
        {
            double minVal           = double.Parse(form["minVal"]);
            double tarVal           = double.Parse(form["targetVal"]);
            double maxVal           = double.Parse(form["maxVal"]);
            string unit             = form["unitVal"];
            int    artNo            = int.Parse(form["artNo"]);
            int    facingVal        = int.Parse(form["facingVal"]);
            int    matNo            = int.Parse(form["matNo"]);
            int    prodInStapleVal  = int.Parse(form["prodInStapleVal"]);
            int    staplesInBagVal  = int.Parse(form["staplesInBagVal"]);
            int    articleSizeVal   = int.Parse(form["articleSizeVal"]);
            int    numofDepVal      = 0;
            string deviantValueText = form["actionsIfDeviantVal"];

            int[] tempArray = new int[] { artNo, facingVal, matNo, prodInStapleVal, staplesInBagVal, articleSizeVal };
            foreach (int num in tempArray)
            {
                if (num > 0)
                {
                    numofDepVal++;
                }
            }

            string indexoredit = form["setValuesIndex"];

            if (indexoredit != "editValue")
            {
                int index           = int.Parse(indexoredit);
                int machSymbolicId  = choosenSettingMachSettId.Skip(index).FirstOrDefault();
                int DetailSettingId = (from s in context.SettingDetailProcess where s.MachSymbolicId == machSymbolicId select s.DetailSettingId).FirstOrDefault();

                SettingValue settVal = new SettingValue()
                {
                    DetailSettingID       = DetailSettingId,
                    MinValue              = minVal,
                    TargetValue           = tarVal,
                    MaxValue              = maxVal,
                    Unit                  = unit,
                    ValidFrom             = user.currShift.shiftno,
                    ValidTo               = 999999993,
                    LastUpdatedBy         = user.winuser,
                    Deleted               = 0,
                    ArtNo                 = artNo,
                    Facing                = facingVal,
                    MaterialNo            = matNo,
                    ProdsInStaple         = prodInStapleVal,
                    StaplesInBag          = staplesInBagVal,
                    ArticleSize           = articleSizeVal,
                    NumOfDependent        = numofDepVal,
                    ActionsIfDeviantValue = deviantValueText
                };
                context.SettingValue.Add(settVal);
            }
            else
            {
                int          settingID  = int.Parse(form["settingID"]);
                SettingValue theSetting = (from s in context.SettingValue where s.SettingValuesID == settingID select s).FirstOrDefault();
                theSetting.MinValue              = minVal;
                theSetting.TargetValue           = tarVal;
                theSetting.MaxValue              = maxVal;
                theSetting.Unit                  = unit;
                theSetting.ValidFrom             = user.currShift.shiftno;
                theSetting.ValidTo               = 999999993;
                theSetting.LastUpdatedBy         = user.winuser;
                theSetting.Deleted               = 0;
                theSetting.ArtNo                 = artNo;
                theSetting.Facing                = facingVal;
                theSetting.MaterialNo            = matNo;
                theSetting.ProdsInStaple         = prodInStapleVal;
                theSetting.StaplesInBag          = staplesInBagVal;
                theSetting.ArticleSize           = articleSizeVal;
                theSetting.NumOfDependent        = numofDepVal;
                theSetting.ActionsIfDeviantValue = deviantValueText;
            }
            context.SaveChanges();
        }