private string UpdateLabSheetAcceptedOrRejectedByForOtherServerLabSheetID()
        {
            int    OtherServerLabSheetID = -1;
            string AcceptedOrRejectedBy  = "";
            string RejectReason          = "";

            int.TryParse(Request.Params["OtherServerLabSheetID"], out OtherServerLabSheetID);
            if (OtherServerLabSheetID == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "OtherServerLabSheetID"));
            }

            if (string.IsNullOrWhiteSpace(Request.Params["AcceptedOrRejectedBy"]))
            {
                return(string.Format(LabSheetViewRes._IsRequired, "AcceptedOrRejectedBy"));
            }

            AcceptedOrRejectedBy = Request.Params["AcceptedOrRejectedBy"];

            if (string.IsNullOrWhiteSpace(Request.Params["RejectReason"]))
            {
                return(string.Format(LabSheetViewRes._IsRequired, "RejectReason"));
            }

            RejectReason = Request.Params["RejectReason"];

            using (CSSPEntities db = new CSSPEntities())
            {
                LabSheet labSheet = (from c in db.LabSheets
                                     where c.OtherServerLabSheetID == OtherServerLabSheetID
                                     select c).FirstOrDefault();

                if (labSheet == null)
                {
                    return("NO");
                }
                else
                {
                    labSheet.AcceptedOrRejectedBy         = AcceptedOrRejectedBy;
                    labSheet.AcceptedOrRejectedDate_Local = DateTime.Now;
                    labSheet.RejectReason = RejectReason;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        return(ex.Message + " ---- " + (ex.InnerException == null ? "" : ex.InnerException.Message));
                    }
                }
            }

            return("");
        }
Beispiel #2
0
        private string UpdateLabSheetStatusForOtherServerLabSheetID()
        {
            int OtherServerLabSheetID = -1;
            int TempInt = -10;
            LabSheetStatusEnum LabSheetStatus = LabSheetStatusEnum.Error;

            int.TryParse(Request.Params["OtherServerLabSheetID"], out OtherServerLabSheetID);
            if (OtherServerLabSheetID == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "OtherServerLabSheetID"));
            }

            int.TryParse(Request.Params["LabSheetStatus"], out TempInt);
            if (TempInt == -10)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "LabSheetStatus"));
            }

            LabSheetStatus = (LabSheetStatusEnum)TempInt;

            using (CSSPEntities db = new CSSPEntities())
            {
                LabSheet labSheet = (from c in db.LabSheets
                                     where c.OtherServerLabSheetID == OtherServerLabSheetID
                                     select c).FirstOrDefault();

                if (labSheet == null)
                {
                    return("NO");
                }
                else
                {
                    labSheet.LabSheetStatus = (int)LabSheetStatus;
                }

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(ex.Message + " ---- " + (ex.InnerException == null ? "" : ex.InnerException.Message));
                }
            }

            return("");
        }
Beispiel #3
0
        private string GetNextAvailableLabSheet()
        {
            StringBuilder sb = new StringBuilder();

            using (CSSPEntities db = new CSSPEntities())
            {
                LabSheet labSheet = (from c in db.LabSheets
                                     where c.LabSheetStatus == (int)LabSheetStatusEnum.Created
                                     orderby c.FileLastModifiedDate_Local
                                     select c).FirstOrDefault();

                if (labSheet != null)
                {
                    sb.AppendLine("OtherServerLabSheetID|||||[" + labSheet.OtherServerLabSheetID + "]");
                    sb.AppendLine("SamplingPlanName|||||[" + labSheet.SamplingPlanName + "]");
                    sb.AppendLine("Year|||||[" + labSheet.Year + "]");
                    sb.AppendLine("Month|||||[" + labSheet.Month + "]");
                    sb.AppendLine("Day|||||[" + labSheet.Day + "]");
                    sb.AppendLine("RunNumber|||||[" + labSheet.RunNumber + "]");
                    sb.AppendLine("SubsectorTVItemID|||||[" + labSheet.SubsectorTVItemID + "]");
                    sb.AppendLine("SamplingPlanType|||||[" + labSheet.SamplingPlanType + "]");
                    sb.AppendLine("SampleType|||||[" + labSheet.SampleType + "]");
                    sb.AppendLine("LabSheetType|||||[" + labSheet.LabSheetType + "]");
                    sb.AppendLine("LabSheetStatus|||||[" + labSheet.LabSheetStatus + "]");
                    sb.AppendLine("FileName|||||[" + labSheet.FileName + "]");
                    sb.AppendLine("FileLastModifiedDate_Local|||||["
                                  + labSheet.FileLastModifiedDate_Local.Year + ","
                                  + labSheet.FileLastModifiedDate_Local.Month + ","
                                  + labSheet.FileLastModifiedDate_Local.Day + ","
                                  + labSheet.FileLastModifiedDate_Local.Hour + ","
                                  + labSheet.FileLastModifiedDate_Local.Minute + ","
                                  + labSheet.FileLastModifiedDate_Local.Second + ","
                                  + "]");
                    sb.AppendLine("FileContent|||||[" + labSheet.FileContent + "]");
                }
            }

            return(sb.ToString());
        }
Beispiel #4
0
        private string DoesLabSheetExist()
        {
            int                  tempInt          = -1;
            string               SamplingPlanName = "";
            int                  Year             = -1;
            int                  Month            = -1;
            int                  Day                        = -1;
            int                  RunNumber                  = -1;
            int                  SubsectorTVItemID          = -1;
            DateTime             SampleDate_Local           = new DateTime(2050, 1, 1);
            SamplingPlanTypeEnum SamplingPlanType           = SamplingPlanTypeEnum.Error;
            SampleTypeEnum       SampleType                 = SampleTypeEnum.Error;
            LabSheetTypeEnum     LabSheetType               = LabSheetTypeEnum.Error;
            DateTime             FileLastModifiedDate_Local = new DateTime(2050, 1, 1);

            SamplingPlanName = Request.Params["SamplingPlanName"];
            if (string.IsNullOrWhiteSpace(SamplingPlanName))
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SamplingPlanName"));
            }

            int.TryParse(Request.Params["Year"], out Year);
            if (Year == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Year"));
            }

            int.TryParse(Request.Params["Month"], out Month);
            if (Month == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Month"));
            }

            int.TryParse(Request.Params["Day"], out Day);
            if (Day == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Day"));
            }

            int.TryParse(Request.Params["RunNumber"], out RunNumber);
            if (RunNumber == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "RunNumber"));
            }

            int.TryParse(Request.Params["SubsectorTVItemID"], out SubsectorTVItemID);
            if (SubsectorTVItemID == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SubsectorTVItemID"));
            }

            int.TryParse(Request.Params["SamplingPlanType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SamplingPlanType"));
            }
            SamplingPlanType = (SamplingPlanTypeEnum)tempInt;

            int.TryParse(Request.Params["SampleType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SampleType"));
            }
            SampleType = (SampleTypeEnum)tempInt;

            int.TryParse(Request.Params["LabSheetType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "LabSheetType"));
            }
            LabSheetType = (LabSheetTypeEnum)tempInt;

            using (CSSPEntities db = new CSSPEntities())
            {
                LabSheet labSheet = (from c in db.LabSheets
                                     where c.SamplingPlanName == SamplingPlanName &&
                                     c.Year == Year &&
                                     c.Month == Month &&
                                     c.Day == Day &&
                                     c.RunNumber == RunNumber &&
                                     c.SubsectorTVItemID == SubsectorTVItemID &&
                                     c.SamplingPlanType == (int)SamplingPlanType &&
                                     c.SampleType == (int)SampleType &&
                                     c.LabSheetType == (int)LabSheetType
                                     select c).FirstOrDefault();

                if (labSheet == null)
                {
                    return("[" + ((int)LabSheetStatusEnum.Error).ToString() + "]");
                }
                else
                {
                    return("[" + labSheet.LabSheetStatus.ToString() + "]");
                }
            }
        }
Beispiel #5
0
        private string GetterLabSheetAcceptedOrRejectedBy()
        {
            int                  tempInt          = -1;
            string               SamplingPlanName = "";
            int                  Year             = -1;
            int                  Month            = -1;
            int                  Day                        = -1;
            int                  RunNumber                  = -1;
            int                  SubsectorTVItemID          = -1;
            DateTime             SampleDate_Local           = new DateTime(2050, 1, 1);
            SamplingPlanTypeEnum SamplingPlanType           = SamplingPlanTypeEnum.Error;
            SampleTypeEnum       SampleType                 = SampleTypeEnum.Error;
            LabSheetTypeEnum     LabSheetType               = LabSheetTypeEnum.Error;
            DateTime             FileLastModifiedDate_Local = new DateTime(2050, 1, 1);
            StringBuilder        sb = new StringBuilder();

            SamplingPlanName = Request.Params["SamplingPlanName"];
            if (string.IsNullOrWhiteSpace(SamplingPlanName))
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SamplingPlanName"));
            }

            int.TryParse(Request.Params["Year"], out Year);
            if (Year == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Year"));
            }

            int.TryParse(Request.Params["Month"], out Month);
            if (Month == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Month"));
            }

            int.TryParse(Request.Params["Day"], out Day);
            if (Day == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Day"));
            }

            int.TryParse(Request.Params["RunNumber"], out RunNumber);
            if (RunNumber == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "RunNumber"));
            }

            int.TryParse(Request.Params["SubsectorTVItemID"], out SubsectorTVItemID);
            if (SubsectorTVItemID == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SubsectorTVItemID"));
            }

            int.TryParse(Request.Params["SamplingPlanType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SamplingPlanType"));
            }
            SamplingPlanType = (SamplingPlanTypeEnum)tempInt;

            int.TryParse(Request.Params["SampleType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SampleType"));
            }
            SampleType = (SampleTypeEnum)tempInt;

            int.TryParse(Request.Params["LabSheetType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "LabSheetType"));
            }
            LabSheetType = (LabSheetTypeEnum)tempInt;

            using (CSSPEntities db = new CSSPEntities())
            {
                LabSheet labSheet = (from c in db.LabSheets
                                     where c.SamplingPlanName == SamplingPlanName &&
                                     c.Year == Year &&
                                     c.Month == Month &&
                                     c.Day == Day &&
                                     c.RunNumber == RunNumber &&
                                     c.SubsectorTVItemID == SubsectorTVItemID &&
                                     c.SamplingPlanType == (int)SamplingPlanType &&
                                     c.SampleType == (int)SampleType &&
                                     c.LabSheetType == (int)LabSheetType
                                     select c).FirstOrDefault();

                if (labSheet != null)
                {
                    sb.AppendLine("OtherServerLabSheetID|||||[" + labSheet.OtherServerLabSheetID + "]");
                    sb.AppendLine("AcceptedOrRejectedBy|||||[" + labSheet.AcceptedOrRejectedBy + "]");
                    sb.AppendLine("Year|||||[" + labSheet.AcceptedOrRejectedDate_Local.Value.Year + "]");
                    sb.AppendLine("Month|||||[" + labSheet.AcceptedOrRejectedDate_Local.Value.Month + "]");
                    sb.AppendLine("Day|||||[" + labSheet.AcceptedOrRejectedDate_Local.Value.Day + "]");
                    sb.AppendLine("Hour|||||[" + labSheet.AcceptedOrRejectedDate_Local.Value.Hour + "]");
                    sb.AppendLine("Minute|||||[" + labSheet.AcceptedOrRejectedDate_Local.Value.Minute + "]");
                    sb.AppendLine("RejectReason|||||[" + labSheet.RejectReason + "]");
                }
            }
            return(sb.ToString());
        }
        private string FillLabSheet()
        {
            int    tempInt          = -1;
            string SamplingPlanName = "";
            int    Year             = -1;
            int    Month            = -1;
            int    Day               = -1;
            int    RunNumber         = -1;
            int    SubsectorTVItemID = -1;
            SamplingPlanTypeEnum SamplingPlanType = SamplingPlanTypeEnum.Error;
            SampleTypeEnum       SampleType       = SampleTypeEnum.Error;
            LabSheetTypeEnum     LabSheetType     = LabSheetTypeEnum.Error;
            string   FileName = "";
            string   FileLastModifiedDate_LocalText = "";
            DateTime FileLastModifiedDate_Local     = new DateTime(2050, 1, 1);
            string   FileContent = "";

            SamplingPlanName = Request.Params["SamplingPlanName"];
            if (string.IsNullOrWhiteSpace(SamplingPlanName))
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SamplingPlanName"));
            }

            int.TryParse(Request.Params["Year"], out Year);
            if (Year == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Year"));
            }

            int.TryParse(Request.Params["Month"], out Month);
            if (Month == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Month"));
            }

            int.TryParse(Request.Params["Day"], out Day);
            if (Day == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "Day"));
            }

            int.TryParse(Request.Params["RunNumber"], out RunNumber);
            if (RunNumber == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "RunNumber"));
            }

            int.TryParse(Request.Params["SubsectorTVItemID"], out SubsectorTVItemID);
            if (SubsectorTVItemID == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SubsectorTVItemID"));
            }

            int.TryParse(Request.Params["SamplingPlanType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SamplingPlanType"));
            }
            SamplingPlanType = (SamplingPlanTypeEnum)tempInt;

            int.TryParse(Request.Params["SampleType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "SampleType"));
            }
            SampleType = (SampleTypeEnum)tempInt;

            int.TryParse(Request.Params["LabSheetType"], out tempInt);
            if (tempInt == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "LabSheetType"));
            }
            LabSheetType = (LabSheetTypeEnum)tempInt;

            FileName = Request.Params["FileName"];
            if (string.IsNullOrWhiteSpace(FileName))
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileName"));
            }

            if (FileName.EndsWith("_S.txt"))
            {
                return(LabSheetViewRes.OnlyLabSheetEndingWithStxtIsAllowed);
            }

            FileLastModifiedDate_LocalText = Request.Params["FileLastModifiedDate_Local"];
            List <string> stringList = FileLastModifiedDate_LocalText.Split(",".ToCharArray(), StringSplitOptions.None).ToList();
            int           FileYear   = -1;

            int.TryParse(stringList[0], out FileYear);
            if (FileYear == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileLastModifiedDate_Local Year not valid"));
            }

            int FileMonth = -1;

            int.TryParse(stringList[1], out FileMonth);
            if (FileMonth == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileLastModifiedDate_Local Month not valid"));
            }

            int FileDay = -1;

            int.TryParse(stringList[2], out FileDay);
            if (FileDay == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileLastModifiedDate_Local Day not valid"));
            }

            int FileHour = -1;

            int.TryParse(stringList[3], out FileHour);
            if (FileHour == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileLastModifiedDate_Local Hour not valid"));
            }

            int FileMinute = -1;

            int.TryParse(stringList[4], out FileMinute);
            if (FileMinute == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileLastModifiedDate_Local Minute not valid"));
            }

            int FileSecond = -1;

            int.TryParse(stringList[5], out FileSecond);
            if (FileSecond == -1)
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileLastModifiedDate_Local Second not valid"));
            }

            FileLastModifiedDate_Local = new DateTime(FileYear, FileMonth, FileDay, FileHour, FileMinute, FileSecond);

            FileContent = Request.Params["FileContent"];
            if (string.IsNullOrWhiteSpace(FileContent))
            {
                return(string.Format(LabSheetViewRes._IsRequired, "FileContent"));
            }

            using (CSSPEntities db = new CSSPEntities())
            {
                LabSheet labSheet = (from c in db.LabSheets
                                     where c.SamplingPlanName == SamplingPlanName &&
                                     c.Year == Year &&
                                     c.Month == Month &&
                                     c.Day == Day &&
                                     c.RunNumber == RunNumber &&
                                     c.SubsectorTVItemID == SubsectorTVItemID &&
                                     c.SamplingPlanType == (int)SamplingPlanType &&
                                     c.SampleType == (int)SampleType &&
                                     c.LabSheetType == (int)LabSheetType &&
                                     c.FileName == FileName
                                     select c).FirstOrDefault();

                if (labSheet == null)
                {
                    labSheet = new LabSheet()
                    {
                        SamplingPlanName = SamplingPlanName,
                        Year             = Year,
                        Month            = Month,
                        Day               = Day,
                        RunNumber         = RunNumber,
                        SubsectorTVItemID = SubsectorTVItemID,
                        SamplingPlanType  = (int)SamplingPlanType,
                        SampleType        = (int)SampleType,
                        LabSheetType      = (int)LabSheetType,
                        FileName          = FileName,
                    };

                    db.LabSheets.Add(labSheet);
                }

                labSheet.LabSheetStatus             = (int)LabSheetStatusEnum.Created;
                labSheet.FileLastModifiedDate_Local = FileLastModifiedDate_Local;
                labSheet.FileContent               = FileContent;
                labSheet.LastUpdateDate_UTC        = DateTime.UtcNow;
                labSheet.LastUpdateContactTVItemID = 2;

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
                }
            }

            return("");
        }