Пример #1
0
 public ActionResult addStationAtmosphericComposition(string StationNum,
  string StationBuildDate,
  string StationName,
  int StoragesInfoID,
  int transportManageType,
  string StationType,
  string StationManufacturer,
  string StationLongitude,
  string StationLatitude,
  string StationAltitude,
  string Operator)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             AtmosphericCompositionStation result = context.AtmosphericCompositionStations.Where(c => c.StationNum.Equals(StationNum)).FirstOrDefault();
             if (result == null)
             {
                 AtmosphericCompositionStation newstation = new AtmosphericCompositionStation();
                 newstation.StationNum = StationNum;
                 newstation.StationBuildDate = DateTime.ParseExact(StationBuildDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                 newstation.StationName = StationName;
                 newstation.StoragesInfoID = StoragesInfoID;
                 newstation.transportManageType = transportManageType;
                 newstation.StationType = StationType;
                 newstation.StationManufacturer = StationManufacturer;
                 newstation.StationLongitude = StationLongitude;
                 newstation.StationLatitude = StationLatitude;
                 newstation.StationAltitude = StationAltitude;
                 newstation.Operator = Operator;
                 context.AtmosphericCompositionStations.Add(newstation);
             }
             else
             {
                 result.StationName = StationName;
                 result.transportManageType = transportManageType;
                 result.StationType = StationType;
                 result.StationManufacturer = StationManufacturer;
                 result.StationLongitude = StationLongitude;
                 result.StationLatitude = StationLatitude;
                 result.StationAltitude = StationAltitude;
                 result.Operator = Operator;
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
Пример #2
0
 public ActionResult AjaxDellUpRequest(int UpRequestID)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             UpRequest stations123 = context.UpRequests.Where(c => c.UpRequestID.Equals(UpRequestID)).FirstOrDefault();
             if (stations123 != null)
             {
                 context.UpRequests.Remove(stations123);
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxVideoConferenceMaintenanceRemove(int VideoConferenceMaintenanceID)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             VideoConferenceMaintenance result = context.VideoConferenceMaintenances.Find(VideoConferenceMaintenanceID);
             if (result != null)
             {
                 context.VideoConferenceMaintenances.Remove(result);
                 context.SaveChanges();
             }
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxUploadImgs(string FileType, string flag, int StationEquipmentsRepairID, string SparePartsCode)
 {
     HttpPostedFileBase upload = Request.Files["upLoadFile"];
     if (upload != null && FileType != null)
     {
         if (upload.ContentLength > 0)
         {
             using (InfoManageDataContext context = new InfoManageDataContext())
             {
                 try
                 {
                     SqlParameter[] parames = new SqlParameter[1];
                     SqlParameter filetype = new SqlParameter();
                     filetype.ParameterName = "@FileType";
                     filetype.SqlDbType = System.Data.SqlDbType.VarChar;
                     filetype.Size = 25;
                     filetype.Value = FileType;
                     parames[0] = filetype;
                     AllUNCPath result = context.Database.SqlQuery<AllUNCPath>("EXEC [dbo].[sp_SYS_GetUNCPath] @FileType", parames).FirstOrDefault();
                     string extname = System.IO.Path.GetExtension(upload.FileName);
                     string picName = SparePartsCode + flag + StationEquipmentsRepairID + extname;
                     string filePath = Path.Combine(result.UNCPath, picName);
                     FileInfo tmp = new FileInfo(filePath);
                     if (tmp.Exists)
                         tmp.Delete();
                     upload.SaveAs(filePath);
                     switch (flag)
                     {
                         case "故障图片":
                             StationEquipmentsRepair repair = context.StationEquipmentsRepairs.Where(c => c.StationEquipmentsRepairID.Equals(StationEquipmentsRepairID)).FirstOrDefault();
                             repair.PhenomenalImage = picName;
                             break;
                     }
                     context.SaveChanges();
                     return Json("OK", JsonRequestBehavior.AllowGet);
                 }
                 catch
                 {
                     return Json("NO", JsonRequestBehavior.AllowGet);
                 }
             }
         }
     }
     return Json("NO", JsonRequestBehavior.AllowGet);
 }
 public ActionResult AjaxSystemRepairAdd(string SystemName, string Reportor, string ReportDate, string RepairDescription, string Repairer, string RepairDate)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             SystemRepair newSystemRepair = new SystemRepair();
             newSystemRepair.SystemName = SystemName;
             newSystemRepair.RepairDescription = RepairDescription;
             newSystemRepair.Repairer = Repairer;
             newSystemRepair.RepairDate = DateTime.ParseExact(RepairDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newSystemRepair.Reportor = Reportor;
             newSystemRepair.ReportDate = DateTime.ParseExact(ReportDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             SystemRepair result = context.SystemRepairs.Where(c => c.SystemName.Equals(newSystemRepair.SystemName) && c.RepairDate.Equals(newSystemRepair.RepairDate)).FirstOrDefault();
             if (result == null)
                 context.SystemRepairs.Add(newSystemRepair);
             else
             {
                 result.RepairDescription = newSystemRepair.RepairDescription;
                 result.Repairer = newSystemRepair.Repairer;
                 result.ReportDate = newSystemRepair.ReportDate;
                 result.Reportor = newSystemRepair.Reportor;
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxStationEquipmentsMaintenanceAdd(string RegionName, int StoragesInfoID, string StationNum, string StationClass, string StationType, string StationManufacturer, string MaintenanceDescription, string Maintenner, string MaintenanceDate, bool powerSta, bool communicationSta, bool samplingSta, bool senserSta, bool cleaningSta, bool stableSta, string Reportor, string ReportDate, string MaintenanceCommants)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             DateTime MaintenanceDatetmp = DateTime.ParseExact(MaintenanceDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             StationEquipmentsMaintenance newStationEquipmentsMaintenance = new StationEquipmentsMaintenance();
             newStationEquipmentsMaintenance.RegionName = RegionName;
             newStationEquipmentsMaintenance.StoragesInfoID = StoragesInfoID;
             newStationEquipmentsMaintenance.StationNum = StationNum;
             newStationEquipmentsMaintenance.MaintenanceDescription = MaintenanceDescription;
             newStationEquipmentsMaintenance.Maintenner = Maintenner;
             newStationEquipmentsMaintenance.MaintenanceDate = DateTime.ParseExact(MaintenanceDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newStationEquipmentsMaintenance.powerSta = powerSta;
             newStationEquipmentsMaintenance.communicationSta = communicationSta;
             newStationEquipmentsMaintenance.samplingSta = samplingSta;
             newStationEquipmentsMaintenance.senserSta = senserSta;
             newStationEquipmentsMaintenance.cleaningSta = cleaningSta;
             newStationEquipmentsMaintenance.stableSta = stableSta;
             newStationEquipmentsMaintenance.Reportor = Reportor;
             newStationEquipmentsMaintenance.ReportDate = DateTime.ParseExact(ReportDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newStationEquipmentsMaintenance.MaintenanceCommants = MaintenanceCommants;
             StationEquipmentsMaintenance result = context.StationEquipmentsMaintenances.Where(c => c.StationNum.Equals(StationNum) && c.MaintenanceDate.Equals(MaintenanceDatetmp)).FirstOrDefault();
             if (result == null)
                 context.StationEquipmentsMaintenances.Add(newStationEquipmentsMaintenance);
             else
             {
                 result.MaintenanceDescription = newStationEquipmentsMaintenance.MaintenanceDescription;
                 result.MaintenanceCommants = newStationEquipmentsMaintenance.MaintenanceCommants;
                 result.powerSta = newStationEquipmentsMaintenance.powerSta;
                 result.communicationSta = newStationEquipmentsMaintenance.communicationSta;
                 result.samplingSta = newStationEquipmentsMaintenance.samplingSta;
                 result.senserSta = newStationEquipmentsMaintenance.senserSta;
                 result.cleaningSta = newStationEquipmentsMaintenance.cleaningSta;
                 result.stableSta = newStationEquipmentsMaintenance.stableSta;
                 result.MaintenanceDate = newStationEquipmentsMaintenance.MaintenanceDate;
                 result.ReportDate = newStationEquipmentsMaintenance.ReportDate;
                 result.Maintenner = newStationEquipmentsMaintenance.Maintenner;
                 result.Reportor = newStationEquipmentsMaintenance.Reportor;
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxNetWorkMaintanceAdd(string NetworkEquipmentCode, string Reportor, string ReportDate, string MaintenanceDescription, string Maintenner, string MaintenanceDate)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             NetWorkMaintance newStationEquipmentsMaintenance = new NetWorkMaintance();
             newStationEquipmentsMaintenance.NetworkEquipmentCode = NetworkEquipmentCode;
             newStationEquipmentsMaintenance.MaintenanceDescription = MaintenanceDescription;
             newStationEquipmentsMaintenance.Maintenner = Maintenner;
             newStationEquipmentsMaintenance.MaintenanceDate = DateTime.ParseExact(MaintenanceDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newStationEquipmentsMaintenance.Reportor = Reportor;
             newStationEquipmentsMaintenance.ReportDate = DateTime.ParseExact(ReportDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             NetWorkMaintance result = context.NetWorkMaintances.Where(c => c.NetworkEquipmentCode.Equals(NetworkEquipmentCode) && c.MaintenanceDate.Equals(newStationEquipmentsMaintenance.MaintenanceDate)).FirstOrDefault();
             if (result == null)
                 context.NetWorkMaintances.Add(newStationEquipmentsMaintenance);
             else
             {
                 result.MaintenanceDescription = newStationEquipmentsMaintenance.MaintenanceDescription;
                 result.MaintenanceDate = newStationEquipmentsMaintenance.MaintenanceDate;
                 result.Maintenner = newStationEquipmentsMaintenance.Maintenner;
                 result.ReportDate = newStationEquipmentsMaintenance.ReportDate;
                 result.Reportor = newStationEquipmentsMaintenance.Reportor;
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
Пример #8
0
        public ActionResult AjaxUploadExcel()
        {
            HttpPostedFileBase upload = Request.Files["upLoadFile"];
            try
            {
                if (Request.Cookies["User"] != null)
                {
                    HttpCookie aCookie = Request.Cookies["User"];
                    string realname = Server.UrlDecode(aCookie["RealName"]);
                    int colnum = 0, totalnum = 0;
                    if (upload != null && upload.ContentLength > 0)
                    {
                        string filePath = @"D:\temp\InfoManage.xlsx";
                        upload.SaveAs(filePath);

                        using (InfoManageDataContext context = new InfoManageDataContext())
                        {
                            #region EquipmentsStorage
                            string InfoManageConnectionStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0;HDR=YES\"";
                            DataSet EquipmentsStorageDS = new DataSet();
                            using (OleDbConnection EquipmentsStorageConn = new OleDbConnection(InfoManageConnectionStr))
                            {
                                string strCom = "SELECT * FROM [Sheet1$]";
                                EquipmentsStorageConn.Open();
                                OleDbDataAdapter WeatherPhenomenonCommand = new OleDbDataAdapter(strCom, EquipmentsStorageConn);
                                WeatherPhenomenonCommand.Fill(EquipmentsStorageDS, "[Sheet1]");
                                EquipmentsStorageConn.Close();
                            }
                            DataTable StationsDSDataTable = EquipmentsStorageDS.Tables[0];
                            foreach (DataRow row in StationsDSDataTable.Rows)
                            {
                                string storname = row.ItemArray[6].ToString().Trim();
                                StoragesInfo stor = context.StoragesInfos.Where(c => c.StoragesInfoName.Equals(storname)).FirstOrDefault();
                                if (stor != null)
                                {
                                    EquipmentsStorage station = new EquipmentsStorage();
                                    station.SparePartsCode = row.ItemArray[0].ToString().Trim();
                                    station.SparePartsType = row.ItemArray[2].ToString().Trim();
                                    station.ApplicableModels = row.ItemArray[3].ToString().Trim();
                                    station.SparePartsManufacturer = row.ItemArray[4].ToString().Trim();
                                    station.Operator = row.ItemArray[5].ToString().Trim();
                                    station.SparePartsBelongingStatus = stor.StoragesInfoID;
                                    station.TurnInDate = DateTime.ParseExact(row.ItemArray[7].ToString().Trim() + " 10:30", AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                    station.CheckDate = DateTime.ParseExact(row.ItemArray[8].ToString().Trim() + " 10:30", AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);

                                    station.SparePartsPic = "   ";
                                    station.SparePartsCertificatePic = "   ";
                                    station.SparePartsStatus = 1;
                                    station.MaxError = "   ";

                                    station.LastModifier = AllConsts.adminName;
                                    station.LastModifyDate = DateTime.Now;

                                    string tmp123 = row.ItemArray[1].ToString().Trim();
                                    Element ele = context.Elements.Where(c => c.SparePartsName.Equals(tmp123)).FirstOrDefault();
                                    if (ele != null)
                                    {
                                        station.ElementID = ele.ElementID;
                                        if (ele.ElementID.Equals(12) && ele.isHelper.Equals(false))
                                        {
                                            station.VaildDate = station.CheckDate.AddYears(1);
                                        }
                                        if ((!ele.ElementID.Equals(12)) && ele.isHelper.Equals(false))
                                        {
                                            station.VaildDate = station.CheckDate.AddYears(2);
                                        }
                                        if (ele.isHelper.Equals(true))
                                        {
                                            station.VaildDate = DateTime.ParseExact(AllConsts.MAX_DATE_HOUR_MINUTE, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                        }
                                        EquipmentsStorage newequip = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(station.SparePartsCode)).FirstOrDefault();
                                        if (newequip == null)
                                        {
                                            context.EquipmentsStorages.Add(station);
                                            colnum++;
                                        }
                                        //else
                                        //{
                                        //    newequip.SparePartsCode = row.ItemArray[0].ToString().Trim();
                                        //    newequip.SparePartsType = row.ItemArray[2].ToString().Trim();
                                        //    newequip.ApplicableModels = row.ItemArray[3].ToString().Trim();
                                        //    newequip.SparePartsManufacturer = row.ItemArray[4].ToString().Trim();
                                        //    newequip.Operator = row.ItemArray[5].ToString().Trim();
                                        //    //newequip.SparePartsBelongingStatus = stor.StoragesInfoID;
                                        //    newequip.TurnInDate = DateTime.ParseExact(row.ItemArray[7].ToString().Trim() + " 10:30", AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                        //    newequip.CheckDate = DateTime.ParseExact(row.ItemArray[8].ToString().Trim() + " 10:30", AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                        //    newequip.ElementID = ele.ElementID;
                                        //    if (ele.ElementID.Equals(12) && ele.isHelper.Equals(false))
                                        //    {
                                        //        newequip.VaildDate = newequip.CheckDate.AddYears(1);
                                        //    }
                                        //    if ((!ele.ElementID.Equals(12)) && ele.isHelper.Equals(false))
                                        //    {
                                        //        newequip.VaildDate = newequip.CheckDate.AddYears(2);
                                        //    }
                                        //    if (ele.isHelper.Equals(true))
                                        //    {
                                        //        newequip.VaildDate = DateTime.ParseExact(AllConsts.MAX_DATE_HOUR_MINUTE, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                        //    }
                                        //    newequip.LastModifier = AllConsts.adminName;
                                        //    newequip.LastModifyDate = DateTime.Now;
                                        //}
                                        context.SaveChanges();
                                        totalnum++;
                                    }
                                    //else
                                    //{
                                    //    int elcount = context.Elements.Count();
                                    //    Element neweles = new Element();
                                    //    neweles.ElementID = elcount + 1;
                                    //    neweles.ElementName = row.ItemArray[1].ToString().Trim();
                                    //    neweles.ElementENName = row.ItemArray[1].ToString().Trim(); ;
                                    //    neweles.isHelper = false;
                                    //    neweles.SparePartsName = row.ItemArray[1].ToString().Trim(); ;
                                    //    context.Elements.Add(neweles);
                                    //    context.SaveChanges();

                                    //    string tmpname = row.ItemArray[1].ToString().Trim();
                                    //    Element eletmp = context.Elements.Where(c => c.SparePartsName.Equals(tmpname)).FirstOrDefault();
                                    //    if (eletmp != null)
                                    //    {
                                    //        station.ElementID = eletmp.ElementID;
                                    //        if (station.ElementID.Equals(12) && eletmp.isHelper.Equals(false))
                                    //        {
                                    //            station.VaildDate = station.CheckDate.AddYears(1);
                                    //        }
                                    //        if ((!station.ElementID.Equals(12)) && eletmp.isHelper.Equals(false))
                                    //        {
                                    //            station.VaildDate = station.CheckDate.AddYears(2);
                                    //        }
                                    //        EquipmentsStorage newequip = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(station.SparePartsCode)).FirstOrDefault();
                                    //        if (newequip != null)
                                    //        {
                                    //            newequip.SparePartsCode = row.ItemArray[0].ToString().Trim();
                                    //            newequip.SparePartsType = row.ItemArray[2].ToString().Trim();
                                    //            newequip.ApplicableModels = row.ItemArray[3].ToString().Trim();
                                    //            newequip.SparePartsManufacturer = row.ItemArray[4].ToString().Trim();
                                    //            newequip.Operator = row.ItemArray[5].ToString().Trim();
                                    //            newequip.SparePartsBelongingStatus = stor.StoragesInfoID;
                                    //            newequip.TurnInDate = DateTime.ParseExact(row.ItemArray[7].ToString().Trim() + " 10:30", AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                    //            newequip.CheckDate = DateTime.ParseExact(row.ItemArray[8].ToString().Trim() + " 10:30", AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                    //            newequip.VaildDate = DateTime.ParseExact(AllConsts.MAX_DATE_HOUR_MINUTE, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                    //            newequip.LastModifier = AllConsts.adminName;
                                    //            newequip.LastModifyDate = DateTime.Now;
                                    //        }
                                    //        else
                                    //            context.EquipmentsStorages.Add(station);
                                    //        context.SaveChanges();
                                    //        colnum++;
                                    //    }
                                    //}
                                }
                            }
                            #endregion
                            if (System.IO.File.Exists(filePath))
                            {
                                System.IO.File.Delete(filePath);
                            }
                        }
                    }
                    return Json("总" + totalnum + "记录,导入成功" + colnum + "记录", JsonRequestBehavior.AllowGet);
                }
                return Json(-1, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json(-2, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult addEquipmentCheckRain(string SparePartsCode
        , string StationNum
        , string StandardEquipmentSparePartsCode
        , int SparePartsBelongingStatus
        , string EnvironmentalT
        , string EnvironmentalRH
        , string EnvironmentalWS
        , bool AppearanceCheck
        , string Unit
        , string Rainfall1
        , string Rainfall1_Intensity1
        , string Rainfall1_Intensity2
        , string Rainfall1_Intensity1_Standard
        , string Rainfall1_Intensity2_Standard
        , string Rainfall1_Intensity1_Check1
        , string Rainfall1_Intensity1_Check2
        , string Rainfall1_Intensity1_Check3
        , string Rainfall1_Intensity2_Check1
        , string Rainfall1_Intensity2_Check2
        , string Rainfall1_Intensity2_Check3
        , string Rainfall1_Intensity1_Average
        , string Rainfall1_Intensity2_Average
        , string Rainfall1_Intensity1_IndicatingError
        , string Rainfall1_Intensity2_IndicatingError
        , string Rainfall1_Intensity1_AbsoluteError
        , string Rainfall1_Intensity2_AbsoluteError
        , string CheckAccordings
        , bool CheckedResult
        , string Checker
        , string reChecker
        , bool isPassed
        , string StartDate
        , string EndDate)
        {
            try
            {
                using (InfoManageDataContext context = new InfoManageDataContext())
                {
                    EquipmentsStorage equip = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
                    if (equip != null)
                    {
                        EquipmentCheckRain newequipment = new EquipmentCheckRain();
                        newequipment.SparePartsCode = SparePartsCode;
                        newequipment.StationNum = StationNum;
                        newequipment.StandardEquipmentSparePartsCode = StandardEquipmentSparePartsCode;
                        newequipment.SparePartsBelongingStatus = equip.SparePartsBelongingStatus;
                        newequipment.EnvironmentalT = EnvironmentalT;
                        newequipment.EnvironmentalRH = EnvironmentalRH;
                        newequipment.EnvironmentalWS = EnvironmentalWS;
                        newequipment.AppearanceCheck = AppearanceCheck;
                        newequipment.Unit = Unit;
                        newequipment.Rainfall1 = Rainfall1;
                        newequipment.Rainfall1_Intensity1 = Rainfall1_Intensity1;
                        newequipment.Rainfall1_Intensity2 = Rainfall1_Intensity2;
                        newequipment.Rainfall1_Intensity1_Standard = Rainfall1_Intensity1_Standard;
                        newequipment.Rainfall1_Intensity2_Standard = Rainfall1_Intensity2_Standard;
                        newequipment.Rainfall1_Intensity1_Check1 = Rainfall1_Intensity1_Check1;
                        newequipment.Rainfall1_Intensity1_Check2 = Rainfall1_Intensity1_Check2;
                        newequipment.Rainfall1_Intensity1_Check3 = Rainfall1_Intensity1_Check3;
                        newequipment.Rainfall1_Intensity2_Check1 = Rainfall1_Intensity2_Check1;
                        newequipment.Rainfall1_Intensity2_Check2 = Rainfall1_Intensity2_Check2;
                        newequipment.Rainfall1_Intensity2_Check3 = Rainfall1_Intensity2_Check3;
                        newequipment.Rainfall1_Intensity1_Average = Rainfall1_Intensity1_Average;
                        newequipment.Rainfall1_Intensity2_Average = Rainfall1_Intensity2_Average;
                        newequipment.Rainfall1_Intensity1_IndicatingError = Rainfall1_Intensity1_IndicatingError;
                        newequipment.Rainfall1_Intensity2_IndicatingError = Rainfall1_Intensity2_IndicatingError;
                        newequipment.Rainfall1_Intensity1_AbsoluteError = Rainfall1_Intensity1_AbsoluteError;
                        newequipment.Rainfall1_Intensity2_AbsoluteError = Rainfall1_Intensity2_AbsoluteError;
                        newequipment.CheckAccordings = CheckAccordings;
                        newequipment.CheckedResult = CheckedResult;
                        newequipment.Checker = Checker;
                        newequipment.reChecker = reChecker;
                        newequipment.isPassed = isPassed;
                        newequipment.StartDate = DateTime.ParseExact(StartDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                        newequipment.EndDate = DateTime.ParseExact(EndDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                        newequipment.LastModifier = Checker;
                        newequipment.LastModifyDate = DateTime.Now;
                        if (Request.Cookies["User"] != null)
                        {
                            HttpCookie aCookie = Request.Cookies["User"];
                            newequipment.LastModifier = Server.UrlDecode(aCookie["RealName"]);
                        }
                        EquipmentCheckRain equipment = context.EquipmentCheckRains.Where(c => c.SparePartsCode.Equals(newequipment.SparePartsCode) && c.StartDate.Equals(newequipment.StartDate)).FirstOrDefault();
                        if (null == equipment)
                        {
                            context.EquipmentCheckRains.Add(newequipment);
                        }
                        else
                        {
                            equipment.EnvironmentalT = newequipment.EnvironmentalT;
                            equipment.EnvironmentalRH = newequipment.EnvironmentalRH;
                            equipment.EnvironmentalWS = newequipment.EnvironmentalWS;
                            equipment.AppearanceCheck = newequipment.AppearanceCheck;
                            equipment.Rainfall1 = newequipment.Rainfall1;
                            equipment.Rainfall1_Intensity1 = newequipment.Rainfall1_Intensity1;
                            equipment.Rainfall1_Intensity2 = newequipment.Rainfall1_Intensity2;
                            equipment.Rainfall1_Intensity1_Standard = newequipment.Rainfall1_Intensity1_Standard;
                            equipment.Rainfall1_Intensity2_Standard = newequipment.Rainfall1_Intensity2_Standard;
                            equipment.Rainfall1_Intensity1_Check1 = newequipment.Rainfall1_Intensity1_Check1;
                            equipment.Rainfall1_Intensity1_Check2 = newequipment.Rainfall1_Intensity1_Check2;
                            equipment.Rainfall1_Intensity1_Check3 = newequipment.Rainfall1_Intensity1_Check3;
                            equipment.Rainfall1_Intensity2_Check1 = newequipment.Rainfall1_Intensity2_Check1;
                            equipment.Rainfall1_Intensity2_Check2 = newequipment.Rainfall1_Intensity2_Check2;
                            equipment.Rainfall1_Intensity2_Check3 = newequipment.Rainfall1_Intensity2_Check3;
                            equipment.Rainfall1_Intensity1_Average = newequipment.Rainfall1_Intensity1_Average;
                            equipment.Rainfall1_Intensity2_Average = newequipment.Rainfall1_Intensity2_Average;
                            equipment.Rainfall1_Intensity1_IndicatingError = newequipment.Rainfall1_Intensity1_IndicatingError;
                            equipment.Rainfall1_Intensity2_IndicatingError = newequipment.Rainfall1_Intensity2_IndicatingError;
                            equipment.Rainfall1_Intensity1_AbsoluteError = newequipment.Rainfall1_Intensity1_AbsoluteError;
                            equipment.Rainfall1_Intensity2_AbsoluteError = newequipment.Rainfall1_Intensity2_AbsoluteError;
                            equipment.CheckedResult = newequipment.CheckedResult;
                            equipment.Checker = newequipment.Checker;
                            equipment.reChecker = newequipment.reChecker;
                            equipment.isPassed = newequipment.isPassed;
                            equipment.EndDate = newequipment.EndDate;
                            equipment.LastModifier = newequipment.LastModifier;
                            equipment.LastModifyDate = newequipment.LastModifyDate;
                        }

                        equip.CheckDate = newequipment.EndDate;
                        if (equip.ElementID.Equals(12))
                            equip.VaildDate = newequipment.EndDate.AddYears(1);
                        else
                            equip.VaildDate = newequipment.EndDate.AddYears(2);

                        context.SaveChanges();
                        return Json("OK", JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        return Json("NO", JsonRequestBehavior.AllowGet);
                    }
                }
            }
            catch
            {
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
        }
 public ActionResult AjaxRemoveStandardEquipment(string SparePartsCode)
 {
     using (InfoManageDataContext context = new InfoManageDataContext())
     {
         StandardEquipment quipment = context.StandardEquipments.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
         if (quipment != null)
         {
             context.StandardEquipments.Remove(quipment);
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxRemoveNetworkEquipmentList(string NetworkEquipmentCode)
 {
     using (InfoManageDataContext context = new InfoManageDataContext())
     {
         NetworkEquipment quipment = context.NetworkEquipments.Where(c => c.NetworkEquipmentCode.Equals(NetworkEquipmentCode)).FirstOrDefault();
         if (quipment != null)
         {
             context.NetworkEquipments.Remove(quipment);
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxDiscardOnlineEquipment(string SparePartsCode, string Operator, string DiscardDate, string DiscardResonance)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             StationEquipmentsOnline onlines = context.StationEquipmentsOnlines.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
             if (onlines != null)
             {
                 EquipmentsDiscardStorage newTurnInStorage = new EquipmentsDiscardStorage();
                 newTurnInStorage.SparePartsCode = SparePartsCode;
                 newTurnInStorage.DiscardResonance = DiscardResonance;
                 newTurnInStorage.DiscardDate = DateTime.ParseExact(DiscardDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                 newTurnInStorage.Operator = Operator;
                 EquipmentsStorage equipment = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(newTurnInStorage.SparePartsCode)).FirstOrDefault();
                 if (equipment != null)
                 {
                     equipment.SparePartsStatus = (int)AllConsts.SparePartsStatus.Discard;
                     context.EquipmentsDiscardStorages.Add(newTurnInStorage);
                     context.StationEquipmentsOnlines.Remove(onlines);
                 }
                 context.SaveChanges();
                 return Json("OK", JsonRequestBehavior.AllowGet);
             }
             return Json("NO", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxDellEquipmentStorageCheckWS(int EquipmentStorageCheckWSID)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             EquipmentStorageCheckWS equipmentcheck_ws = context.EquipmentStorageCheckWSes.Where(c => c.EquipmentStorageCheckWSID.Equals(EquipmentStorageCheckWSID)).FirstOrDefault();
             if (equipmentcheck_ws != null)
             {
                 context.EquipmentStorageCheckWSes.Remove(equipmentcheck_ws);
                 context.SaveChanges();
             }
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
        public ActionResult AjaxAddNewStation(
            string StationNum,
            string StationBuildDate,
            string StationName,
            string StationAdrass,
            int StoragesInfoID,
            int transportManageType,
            int StationClass,
            int ElementsNum,
            int samplingMod,
            string windDirectorHigh,
            string windSpeederHigh,
            string StationLetterCode,
            string StationType,
            string StationManufacturer,
            string StationLongitude,
            string StationLatitude,
            string StationAltitude,
            string SIM,
            string IP,
            int powerSupplyMod,
            string BatteryStartDate,
            string SIMRenewFeeDate,
            string Operator)
        {
            try
            {
                if (Request.Cookies["User"] != null)
                {
                    HttpCookie aCookie = Request.Cookies["User"];
                    ViewBag.RealName = Server.UrlDecode(aCookie["RealName"]);
                    int id = Convert.ToInt32(Server.UrlDecode(aCookie["ID"]));

                    using (MemberShipDataContext context = new MemberShipDataContext())
                    {
                        UserProfile usr = context.UserProfiles.Find(id);
                        if (null != usr)
                        {
                            using (InfoManageDataContext InfoManageContext = new InfoManageDataContext())
                            {
                                Station newStation = new Station();
                                newStation.StationNum = StationNum.Trim();
                                newStation.StationBuildDate = DateTime.ParseExact(StationBuildDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                newStation.StationName = StationName;
                                newStation.StationAdrass = StationAdrass;
                                newStation.StoragesInfoID = StoragesInfoID;
                                newStation.transportManageType = transportManageType;
                                newStation.StationClass = StationClass;
                                newStation.StationLetterCode = StationLetterCode;
                                newStation.StationType = StationType;
                                newStation.StationManufacturer = StationManufacturer;
                                newStation.StationLongitude = StationLongitude;
                                newStation.StationLatitude = StationLatitude;
                                newStation.StationAltitude = StationAltitude;
                                newStation.ElementsNum = ElementsNum;
                                newStation.samplingMod = samplingMod;
                                newStation.windDirectorHigh = windDirectorHigh;
                                newStation.windSpeederHigh = windSpeederHigh;
                                newStation.SIM = SIM;
                                newStation.IP = IP;
                                newStation.powerSupplyMod = powerSupplyMod;
                                newStation.Operator = Operator;
                                newStation.LastModifier = newStation.Operator;
                                newStation.LastModifyDate = DateTime.Now;
                                if (newStation.powerSupplyMod == (int)AllConsts.powerSupplyMod.SolarEnergy)
                                    newStation.BatteryStartDate = DateTime.ParseExact(BatteryStartDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                else
                                    newStation.BatteryStartDate = DateTime.ParseExact(AllConsts.MAX_DATE_HOUR_MINUTE, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                if (newStation.SIM.Trim() != "")
                                    newStation.SIMRenewFeeDate = DateTime.ParseExact(SIMRenewFeeDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                else
                                    newStation.SIMRenewFeeDate = DateTime.ParseExact(AllConsts.MAX_DATE_HOUR_MINUTE, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                Station oldstation = InfoManageContext.Stations.Where(c => c.StationNum.Equals(newStation.StationNum)).FirstOrDefault();
                                if (oldstation == null)
                                    InfoManageContext.Stations.Add(newStation);
                                else
                                {
                                    oldstation.StationBuildDate = newStation.StationBuildDate;
                                    oldstation.StationName = newStation.StationName;
                                    oldstation.StationAdrass = newStation.StationAdrass;
                                    oldstation.transportManageType = newStation.transportManageType;
                                    oldstation.StationClass = newStation.StationClass;
                                    oldstation.StationLetterCode = newStation.StationLetterCode;
                                    oldstation.StationType = newStation.StationType;
                                    oldstation.StationManufacturer = newStation.StationManufacturer;
                                    oldstation.StationLongitude = newStation.StationLongitude;
                                    oldstation.StationLatitude = newStation.StationLatitude;
                                    oldstation.StationAltitude = newStation.StationAltitude;
                                    oldstation.ElementsNum = newStation.ElementsNum;
                                    oldstation.samplingMod = newStation.samplingMod;
                                    oldstation.windDirectorHigh = newStation.windDirectorHigh;
                                    oldstation.windSpeederHigh = newStation.windSpeederHigh;
                                    oldstation.SIM = newStation.SIM;
                                    oldstation.IP = newStation.IP;
                                    oldstation.powerSupplyMod = newStation.powerSupplyMod;
                                    oldstation.Operator = newStation.Operator;
                                    oldstation.BatteryStartDate = newStation.BatteryStartDate;
                                    oldstation.SIMRenewFeeDate = newStation.SIMRenewFeeDate;
                                    oldstation.StoragesInfoID = StoragesInfoID;
                                    oldstation.LastModifier = oldstation.Operator;
                                    oldstation.LastModifyDate = DateTime.Now;
                                }

                                UserAction newaction = new UserAction();
                                newaction.ID = usr.ID;
                                newaction.RealName = usr.RealName;
                                newaction.ActionName = "AjaxSetTurnInStorageList";
                                newaction.CreateTime = DateTime.Now;
                                newaction.LastModifyTime = newaction.CreateTime;
                                InfoManageContext.UserActions.Add(newaction);

                                InfoManageContext.SaveChanges();
                                return Json("OK", JsonRequestBehavior.AllowGet);
                            }
                        }
                    }
                }
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
        }
Пример #15
0
 public ActionResult AjaxDellCheckRain(int EquipmentCheckRainID)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             OtherIndustriesStationCheckRain equipmentcheck_ws = context.OtherIndustriesStationCheckRains.Where(c => c.EquipmentCheckRainID.Equals(EquipmentCheckRainID)).FirstOrDefault();
             if (equipmentcheck_ws != null)
             {
                 context.OtherIndustriesStationCheckRains.Remove(equipmentcheck_ws);
                 context.SaveChanges();
             }
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
        public ActionResult addEquipmentStorageCheckWS(string SparePartsCode
        , string StandardEquipmentSparePartsCode
        , int SparePartsBelongingStatus
        , string EnvironmentalT
        , string EnvironmentalRH
        , string EnvironmentalWS
        , bool AppearanceCheck
        , string Unit
        , string CheckPoint1
        , string StandardValue1
        , string CheckedValue1
        , string IndicatingError1
        , string AbsoluteError1
        , string CheckAccordings
        , bool CheckedResult
        , string Checker
        , string reChecker
        , bool isPassed
        , string StartDate
        , string EndDate)
        {
            try
            {
                using (InfoManageDataContext context = new InfoManageDataContext())
                {
                    EquipmentsStorage equip = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
                    if (equip != null)
                    {
                        EquipmentStorageCheckWS newequipment = new EquipmentStorageCheckWS();
                        newequipment.SparePartsCode = SparePartsCode;
                        newequipment.StandardEquipmentSparePartsCode = StandardEquipmentSparePartsCode;
                        newequipment.SparePartsBelongingStatus = equip.SparePartsBelongingStatus;
                        newequipment.EnvironmentalT = EnvironmentalT;
                        newequipment.EnvironmentalRH = EnvironmentalRH;
                        newequipment.EnvironmentalWS = EnvironmentalWS;
                        newequipment.AppearanceCheck = AppearanceCheck;
                        newequipment.Unit = Unit;
                        newequipment.CheckPoint1 = CheckPoint1;
                        newequipment.StandardValue1 = StandardValue1;
                        newequipment.CheckedValue1 = CheckedValue1;
                        newequipment.IndicatingError1 = IndicatingError1;
                        newequipment.AbsoluteError1 = AbsoluteError1;
                        newequipment.CheckAccordings = CheckAccordings;
                        newequipment.CheckedResult = CheckedResult;
                        newequipment.Checker = Checker;
                        newequipment.reChecker = reChecker;
                        newequipment.isPassed = isPassed;
                        newequipment.StartDate = DateTime.ParseExact(StartDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                        newequipment.EndDate = DateTime.ParseExact(EndDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                        EquipmentStorageCheckWS equipment = context.EquipmentStorageCheckWSes.Where(c => c.SparePartsCode.Equals(newequipment.SparePartsCode) && c.StartDate.Equals(newequipment.StartDate)).FirstOrDefault();
                        if (null == equipment)
                        {
                            context.EquipmentStorageCheckWSes.Add(newequipment);
                        }
                        else
                        {
                            equipment.EnvironmentalT = newequipment.EnvironmentalT;
                            equipment.EnvironmentalRH = newequipment.EnvironmentalRH;
                            equipment.EnvironmentalWS = newequipment.EnvironmentalWS;
                            equipment.AppearanceCheck = newequipment.AppearanceCheck;
                            equipment.CheckPoint1 = newequipment.CheckPoint1;
                            equipment.StandardValue1 = newequipment.StandardValue1;
                            equipment.CheckedValue1 = newequipment.CheckedValue1;
                            equipment.IndicatingError1 = newequipment.IndicatingError1;
                            equipment.AbsoluteError1 = newequipment.AbsoluteError1;
                            equipment.CheckedResult = newequipment.CheckedResult;
                            equipment.Checker = newequipment.Checker;
                            equipment.reChecker = newequipment.reChecker;
                            equipment.CheckedResult = newequipment.CheckedResult;
                            equipment.isPassed = newequipment.isPassed;
                            equipment.EndDate = newequipment.EndDate;
                        }

                        equip.CheckDate = newequipment.EndDate;
                        if (equip.ElementID.Equals(12))
                            equip.VaildDate = newequipment.EndDate.AddYears(1);
                        else
                            equip.VaildDate = newequipment.EndDate.AddYears(2);
                    }
                    else
                    {
                        return Json("NO", JsonRequestBehavior.AllowGet);
                    }
                    context.SaveChanges();
                    return Json("OK", JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
        }
Пример #17
0
 public ActionResult AjaxRemoveStation(string StationNum)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             Station sta = context.Stations.Where(c => c.StationNum.Equals(StationNum)).FirstOrDefault();
             if (sta != null)
             {
                 context.Stations.Remove(sta);
                 context.SaveChanges();
                 return Json("OK", JsonRequestBehavior.AllowGet);
             }
             return Json("NO", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxSetBackStorage(string SparePartsCode)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             StationEquipmentsOnline onlines = context.StationEquipmentsOnlines.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
             if (onlines != null)
             {
                 EquipmentsStorage equip = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(onlines.SparePartsCode)).FirstOrDefault();
                 if (equip != null)
                 {
                     context.StationEquipmentsOnlines.Remove(onlines);
                     equip.SparePartsStatus = (int)AllConsts.SparePartsStatus.Redady;
                 }
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
Пример #19
0
        public ActionResult AjaxUploadStaionUpdateExcel()
        {
            HttpPostedFileBase upload = Request.Files["upLoadFile"];
            try
            {
                if (Request.Cookies["User"] != null)
                {
                    HttpCookie aCookie = Request.Cookies["User"];
                    string realname = Server.UrlDecode(aCookie["RealName"]);
                    int colnum = 0, totalnum = 0;
                    if (upload != null && upload.ContentLength > 0)
                    {
                        string filePath = @"D:\temp\Station.xlsx";
                        upload.SaveAs(filePath);

                        using (InfoManageDataContext context = new InfoManageDataContext())
                        {
                            #region EquipmentsStorage
                            string InfoManageConnectionStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0;HDR=YES\"";
                            DataSet StationsDS = new DataSet();
                            using (OleDbConnection StationsConn = new OleDbConnection(InfoManageConnectionStr))
                            {
                                string strCom = "SELECT * FROM [Sheet1$]";
                                StationsConn.Open();
                                OleDbDataAdapter WeatherPhenomenonCommand = new OleDbDataAdapter(strCom, StationsConn);
                                WeatherPhenomenonCommand.Fill(StationsDS, "[Sheet1]");
                                StationsConn.Close();
                            }

                            DataTable StationsDSDataTable = StationsDS.Tables[0];
                            foreach (DataRow row in StationsDSDataTable.Rows)
                            {
                                string storagename = row.ItemArray[4].ToString().Trim();
                                StoragesInfo sinfo = context.StoragesInfos.Where(c => c.BelongingName.Equals(storagename)).FirstOrDefault();
                                if (sinfo != null)
                                {
                                    string oldstationnum = row.ItemArray[0].ToString().Trim();
                                    Station oldstation = context.Stations.Where(c => c.StationNum.Equals(oldstationnum)).FirstOrDefault();
                                    if (oldstation == null)
                                    {
                                        //string tmp = row.ItemArray[1].ToString().Trim();
                                        Station station = new Station();
                                        station.StationNum = row.ItemArray[0].ToString().Trim();
                                        station.StationBuildDate = DateTime.ParseExact(row.ItemArray[1].ToString().Trim(), AllConsts.HOUR_MINUTE_SHORT, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                        station.StationName = row.ItemArray[2].ToString().Trim();
                                        station.StationAdrass = row.ItemArray[3].ToString().Trim();
                                        station.StoragesInfoID = sinfo.StoragesInfoID;
                                        station.transportManageType = Convert.ToInt32(row.ItemArray[5].ToString().Trim());
                                        station.StationClass = Convert.ToInt32(row.ItemArray[6].ToString().Trim());
                                        station.StationLetterCode = row.ItemArray[7].ToString().Trim();
                                        station.StationType = row.ItemArray[8].ToString().Trim();
                                        station.StationManufacturer = row.ItemArray[9].ToString().Trim();
                                        station.StationLongitude = row.ItemArray[10].ToString().Trim();
                                        station.StationLatitude = row.ItemArray[11].ToString().Trim();
                                        station.StationAltitude = row.ItemArray[12].ToString().Trim();
                                        station.ElementsNum = Convert.ToInt32(row.ItemArray[13].ToString().Trim());
                                        station.samplingMod = Convert.ToInt32(row.ItemArray[14].ToString().Trim());
                                        station.windDirectorHigh = row.ItemArray[15].ToString().Trim();
                                        station.windSpeederHigh = row.ItemArray[16].ToString().Trim();
                                        station.SIM = row.ItemArray[17].ToString().Trim();
                                        station.IP = row.ItemArray[18].ToString().Trim();
                                        station.frontPhoto = row.ItemArray[19].ToString().Trim();
                                        station.overallView = row.ItemArray[20].ToString().Trim();
                                        station.powerSupplyMod = Convert.ToInt32(row.ItemArray[21].ToString().Trim());
                                        station.Operator = row.ItemArray[22].ToString().Trim();
                                        station.LastModifier = AllConsts.adminName;
                                        station.LastModifyDate = DateTime.Now;
                                        station.BatteryStartDate = station.StationBuildDate;
                                        station.SIMRenewFeeDate = station.StationBuildDate;
                                        context.Stations.Add(station);
                                        colnum++;
                                    }
                                    else
                                    {
                                        oldstation.StationBuildDate = DateTime.ParseExact(row.ItemArray[1].ToString().Trim(), AllConsts.HOUR_MINUTE_SHORT, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                        oldstation.StationName = row.ItemArray[2].ToString().Trim();
                                        oldstation.StationAdrass = row.ItemArray[3].ToString().Trim();
                                        oldstation.StoragesInfoID = sinfo.StoragesInfoID;
                                        oldstation.transportManageType = Convert.ToInt32(row.ItemArray[5].ToString().Trim());
                                        oldstation.StationClass = Convert.ToInt32(row.ItemArray[6].ToString().Trim());
                                        oldstation.StationLetterCode = row.ItemArray[7].ToString().Trim();
                                        oldstation.StationType = row.ItemArray[8].ToString().Trim();
                                        oldstation.StationManufacturer = row.ItemArray[9].ToString().Trim();
                                        oldstation.StationLongitude = row.ItemArray[10].ToString().Trim();
                                        oldstation.StationLatitude = row.ItemArray[11].ToString().Trim();
                                        oldstation.StationAltitude = row.ItemArray[12].ToString().Trim();
                                        oldstation.ElementsNum = Convert.ToInt32(row.ItemArray[13].ToString().Trim());
                                        oldstation.samplingMod = Convert.ToInt32(row.ItemArray[14].ToString().Trim());
                                        oldstation.windDirectorHigh = row.ItemArray[15].ToString().Trim();
                                        oldstation.windSpeederHigh = row.ItemArray[16].ToString().Trim();
                                        oldstation.SIM = row.ItemArray[17].ToString().Trim();
                                        oldstation.IP = row.ItemArray[18].ToString().Trim();
                                        oldstation.frontPhoto = row.ItemArray[19].ToString().Trim();
                                        oldstation.overallView = row.ItemArray[20].ToString().Trim();
                                        oldstation.powerSupplyMod = Convert.ToInt32(row.ItemArray[21].ToString().Trim());
                                        oldstation.Operator = row.ItemArray[22].ToString().Trim();
                                        oldstation.LastModifier = AllConsts.adminName;
                                        oldstation.LastModifyDate = DateTime.Now;
                                        colnum++;
                                    }
                                    context.SaveChanges();
                                    totalnum++;
                                }
                            }
                            #endregion
                            if (System.IO.File.Exists(filePath))
                            {
                                System.IO.File.Delete(filePath);
                            }
                        }
                    }
                    return Json("总" + totalnum + "记录,导入成功" + colnum + "记录", JsonRequestBehavior.AllowGet);
                }
                return Json(-1, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json(-2, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult AjaxSetExchangeStorageList(string SparePartsCode, string Operator, string ExchangeDate, int Destination)
        {
            try
            {

                using (InfoManageDataContext context = new InfoManageDataContext())
                {
                    EquipmentsExchangeStorage newTurnInStorage = new EquipmentsExchangeStorage();
                    newTurnInStorage.SparePartsCode = SparePartsCode;
                    newTurnInStorage.Destination = Destination;
                    newTurnInStorage.ExchangeDate = DateTime.ParseExact(ExchangeDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo); ;
                    newTurnInStorage.Operator = Operator;
                    EquipmentsStorage equipment = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(newTurnInStorage.SparePartsCode) && c.SparePartsStatus.Equals((int)AllConsts.SparePartsStatus.Redady)).FirstOrDefault();
                    if (equipment != null)
                    {
                        newTurnInStorage.Source = equipment.SparePartsBelongingStatus;
                        context.EquipmentsExchangeStorages.Add(newTurnInStorage);
                        equipment.SparePartsBelongingStatus = newTurnInStorage.Destination;
                        context.SaveChanges();
                        return Json("OK", JsonRequestBehavior.AllowGet);
                    }
                    return Json("NO", JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
        }
 public ActionResult AjaxNetWorkRepairAdd(string NetworkEquipmentCode, string NetWorkDeviceUsage, string NetworkEquipmentType, string NetworkEquipmentManufacturer, string FaultStartDate, string FaultEndDate, string PhenomenalDescription, string Resonance, string HandlingVResults, string Reportor, string ReportDate, bool UpRepair, string Repairer)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             NetWorkRepair newStationEquipmentsMaintenance = new NetWorkRepair();
             newStationEquipmentsMaintenance.NetworkEquipmentCode = NetworkEquipmentCode;
             newStationEquipmentsMaintenance.FaultStartDate = DateTime.ParseExact(FaultStartDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newStationEquipmentsMaintenance.FaultEndDate = DateTime.ParseExact(FaultEndDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newStationEquipmentsMaintenance.Resonance = Resonance;
             newStationEquipmentsMaintenance.PhenomenalDescription = PhenomenalDescription;
             newStationEquipmentsMaintenance.HandlingVResults = HandlingVResults;
             newStationEquipmentsMaintenance.Reportor = Reportor;
             newStationEquipmentsMaintenance.Repairer = Repairer;
             newStationEquipmentsMaintenance.ReportDate = DateTime.ParseExact(ReportDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newStationEquipmentsMaintenance.UpRepair = UpRepair;
             NetWorkRepair result = context.NetWorkRepairs.Where(c => c.NetworkEquipmentCode.Equals(newStationEquipmentsMaintenance.NetworkEquipmentCode) && c.ReportDate.Equals(newStationEquipmentsMaintenance.ReportDate)).FirstOrDefault();
             if (result == null)
                 context.NetWorkRepairs.Add(newStationEquipmentsMaintenance);
             else
             {
                 result.Resonance = newStationEquipmentsMaintenance.Resonance;
                 result.PhenomenalDescription = newStationEquipmentsMaintenance.PhenomenalDescription;
                 result.HandlingVResults = newStationEquipmentsMaintenance.HandlingVResults;
                 result.FaultStartDate = newStationEquipmentsMaintenance.FaultStartDate;
                 result.FaultEndDate = newStationEquipmentsMaintenance.FaultEndDate;
                 result.Reportor = newStationEquipmentsMaintenance.Reportor;
                 result.Repairer = newStationEquipmentsMaintenance.Repairer;
                 result.UpRepair = newStationEquipmentsMaintenance.UpRepair;
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxSetNetworkEquipmentList(string NetWorkDeviceUsage,
     string NetworkEquipmentCode, string NetworkEquipmentName, string NetworkEquipmentType, string Operator,
     string StartUsingDate, int NetworkEquipmentCategory, string NetworkEquipmentManufacturer, string VaildDate,
     string IP, string MAC, bool isMonitor, string FeeDate, bool isFeeMonitor, string BandWidth)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             NetworkEquipment newequipment = new NetworkEquipment();
             newequipment.NetworkEquipmentCode = NetworkEquipmentCode;
             newequipment.NetworkEquipmentName = NetworkEquipmentName;
             newequipment.NetworkEquipmentType = NetworkEquipmentType;
             newequipment.Operator = Operator;
             newequipment.NetWorkDeviceUsage = NetWorkDeviceUsage;
             newequipment.StartUsingDate = DateTime.ParseExact(StartUsingDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newequipment.NetworkEquipmentCategory = NetworkEquipmentCategory;
             newequipment.NetworkEquipmentManufacturer = NetworkEquipmentManufacturer;
             newequipment.VaildDate = DateTime.ParseExact(VaildDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newequipment.IP = IP;
             newequipment.MAC = MAC;
             newequipment.isMonitor = isMonitor;
             newequipment.isConnected = true;
             newequipment.FeeDate = DateTime.ParseExact(FeeDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo); ;
             newequipment.isFeeMonitor = isFeeMonitor;
             newequipment.BandWidth = BandWidth;
             newequipment.LastConnectedDate = DateTime.ParseExact(AllConsts.MIN_DATE_HOUR_MINUTE, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo); ;
             NetworkEquipment equipment = context.NetworkEquipments.Where(c => c.NetworkEquipmentCode.Equals(NetworkEquipmentCode)).FirstOrDefault();
             if (null == equipment)
             {
                 context.NetworkEquipments.Add(newequipment);
             }
             else
             {
                 equipment.NetworkEquipmentName = newequipment.NetworkEquipmentName;
                 equipment.NetworkEquipmentType = newequipment.NetworkEquipmentType;
                 equipment.Operator = newequipment.Operator;
                 equipment.StartUsingDate = newequipment.StartUsingDate;
                 equipment.NetworkEquipmentCategory = newequipment.NetworkEquipmentCategory;
                 equipment.NetworkEquipmentManufacturer = newequipment.NetworkEquipmentManufacturer;
                 equipment.VaildDate = newequipment.VaildDate;
                 equipment.IP = newequipment.IP;
                 equipment.MAC = newequipment.MAC;
                 equipment.isMonitor = newequipment.isMonitor;
                 equipment.NetWorkDeviceUsage = newequipment.NetWorkDeviceUsage;
                 equipment.FeeDate = newequipment.FeeDate;
                 equipment.isFeeMonitor = newequipment.isFeeMonitor;
                 equipment.BandWidth = newequipment.BandWidth;
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxStationEquipmentsRepairAdd(int StoragesInfoID, string StationNum, string SparePartsCode, string Resonance, string PhenomenalDescription, string HandlingVResults, bool UpRepair, string Reportor, string Repairer, string ReportDate, string FaultStartDate, string FaultEndDate)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             if (FaultEndDate == AllConsts.MAX_DATE_HOUR_MINUTE && UpRepair == false)
                 return Json("结束时间空!", JsonRequestBehavior.AllowGet);
             StationEquipmentsRepair newStationEquipmentsMaintenance = new StationEquipmentsRepair();
             newStationEquipmentsMaintenance.StoragesInfoID = StoragesInfoID;
             newStationEquipmentsMaintenance.StationNum = StationNum;
             newStationEquipmentsMaintenance.SparePartsCode = SparePartsCode;
             newStationEquipmentsMaintenance.FaultStartDate = DateTime.ParseExact(FaultStartDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             if (FaultEndDate == AllConsts.MAX_DATE_HOUR_MINUTE)
                 newStationEquipmentsMaintenance.FaultEndDate = DateTime.ParseExact(AllConsts.MAX_DATE_HOUR_MINUTE, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             else
                 newStationEquipmentsMaintenance.FaultEndDate = DateTime.ParseExact(FaultEndDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newStationEquipmentsMaintenance.Resonance = Resonance;
             newStationEquipmentsMaintenance.PhenomenalDescription = PhenomenalDescription;
             newStationEquipmentsMaintenance.HandlingVResults = HandlingVResults;
             newStationEquipmentsMaintenance.UpRepair = UpRepair;
             newStationEquipmentsMaintenance.Reportor = Reportor;
             newStationEquipmentsMaintenance.Repairer = Repairer;
             newStationEquipmentsMaintenance.ReportDate = DateTime.Now;
             if (newStationEquipmentsMaintenance.FaultEndDate < newStationEquipmentsMaintenance.FaultStartDate)
                 return Json("开始时间不能大于结束时间!", JsonRequestBehavior.AllowGet);
             StationEquipmentsRepair result = context.StationEquipmentsRepairs.Where(c => c.StationNum.Equals(StationNum) && c.ReportDate.Year.Equals(newStationEquipmentsMaintenance.ReportDate.Year) && c.ReportDate.Month.Equals(newStationEquipmentsMaintenance.ReportDate.Month) && c.ReportDate.Day.Equals(newStationEquipmentsMaintenance.ReportDate.Day)).FirstOrDefault();
             if (result == null)
             {
                 context.StationEquipmentsRepairs.Add(newStationEquipmentsMaintenance);
                 if (newStationEquipmentsMaintenance.UpRepair)
                 {
                     StoragesInfo storage = context.StoragesInfos.Where(c => c.StoragesInfoID.Equals(StoragesInfoID)).FirstOrDefault();
                     UpRequest newRequest = new UpRequest();
                     newRequest.IsBack = false;
                     newRequest.BackIsRead = false;
                     newRequest.Requester = newStationEquipmentsMaintenance.Reportor;
                     newRequest.RequestText = storage.StoragesInfoName + "," + StationNum + ",<code>设备</code>编号:" + SparePartsCode + ",请求维修!";
                     newRequest.RequestDate = DateTime.Now;
                     newRequest.RebackDate = newRequest.RequestDate;
                     newRequest.ToUnit = (int)AllConsts.BAOZHANG_UNIT_NUM;
                     context.UpRequests.Add(newRequest);
                 }
                 context.SaveChanges();
             }
             else
             {
                 result.Resonance = newStationEquipmentsMaintenance.Resonance;
                 result.PhenomenalDescription = newStationEquipmentsMaintenance.PhenomenalDescription;
                 result.HandlingVResults = newStationEquipmentsMaintenance.HandlingVResults;
                 result.UpRepair = newStationEquipmentsMaintenance.UpRepair;
                 result.FaultStartDate = newStationEquipmentsMaintenance.FaultStartDate;
                 result.FaultEndDate = newStationEquipmentsMaintenance.FaultEndDate;
                 result.ReportDate = newStationEquipmentsMaintenance.ReportDate;
                 result.Reportor = newStationEquipmentsMaintenance.Reportor;
                 result.Repairer = newStationEquipmentsMaintenance.Repairer;
                 if (newStationEquipmentsMaintenance.UpRepair)
                 {
                     StoragesInfo storage = context.StoragesInfos.Where(c => c.StoragesInfoID.Equals(StoragesInfoID)).FirstOrDefault();
                     UpRequest newRequest = new UpRequest();
                     newRequest.IsBack = false;
                     newRequest.BackIsRead = false;
                     newRequest.Requester = newStationEquipmentsMaintenance.Reportor;
                     newRequest.RequestText = storage.StoragesInfoName + "," + StationNum + ",<code>设备</code>编号:" + SparePartsCode + ",请求维修!";
                     newRequest.RequestDate = DateTime.Now;
                     newRequest.RebackDate = newRequest.RequestDate;
                     newRequest.ToUnit = (int)AllConsts.BAOZHANG_UNIT_NUM;
                     context.UpRequests.Add(newRequest);
                 }
                 context.SaveChanges();
             }
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxSetRepairStorageList(string SparePartsCode, string Operator, string RepairDate, string RepairResonance)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             EquipmentsRepairStorage newTurnInStorage = new EquipmentsRepairStorage();
             newTurnInStorage.SparePartsCode = SparePartsCode;
             newTurnInStorage.RepairResonance = RepairResonance;
             newTurnInStorage.RepairDate = DateTime.ParseExact(RepairDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newTurnInStorage.RepairedDate = DateTime.ParseExact(RepairDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
             newTurnInStorage.Operator = Operator;
             newTurnInStorage.RepairStatus = (int)AllConsts.SparePartsRepairStatus.Repairing;
             EquipmentsStorage equipment = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(newTurnInStorage.SparePartsCode) && c.SparePartsStatus.Equals((int)AllConsts.SparePartsStatus.Redady)).FirstOrDefault();
             if (equipment != null)
             {
                 equipment.SparePartsStatus = (int)AllConsts.SparePartsStatus.Repair;
                 context.EquipmentsRepairStorages.Add(newTurnInStorage);
             }
             context.SaveChanges();
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxSystemRepairRemove(int SystemRepairID)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             SystemRepair result = context.SystemRepairs.Find(SystemRepairID);
             if (result != null)
             {
                 context.SystemRepairs.Remove(result);
                 context.SaveChanges();
             }
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxSetStationEquipmentsOnline(string StationNum)
 {
     try
     {
         using (InfoManageDataContext context = new InfoManageDataContext())
         {
             List<Element> elements = context.Elements.ToList<Element>();
             foreach (Element ele in elements)
             {
                 string ElementENName = Request.Form[ele.ElementENName];
                 if (ElementENName != null)
                 {
                     if (ElementENName.ToString() != "0")
                     {
                         EquipmentsStorage storage = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(ElementENName) && c.SparePartsStatus.Equals((int)AllConsts.SparePartsStatus.Redady)).FirstOrDefault();
                         if (storage != null)
                         {
                             StationEquipmentsOnline online = context.StationEquipmentsOnlines.Where(c => c.StationNum.Equals(StationNum) && c.SparePartsCode.Equals(storage.SparePartsCode)).FirstOrDefault();
                             if (online == null)
                             {
                                 StationEquipmentsOnline eqipOnli = new StationEquipmentsOnline();
                                 eqipOnli.StationNum = StationNum;
                                 eqipOnli.SparePartsCode = storage.SparePartsCode;
                                 eqipOnli.ElementID = ele.ElementID;
                                 eqipOnli.ElementName = ele.ElementName;
                                 eqipOnli.StartUsingDate = DateTime.Now;
                                 eqipOnli.VaildDate = DateTime.Now.AddYears(1);
                                 context.StationEquipmentsOnlines.Add(eqipOnli);
                                 storage.SparePartsStatus = (int)AllConsts.SparePartsStatus.Online;
                             }
                             else
                             {
                                 //return Json("NO", JsonRequestBehavior.AllowGet);
                             }
                         }
                         context.SaveChanges();
                     }
                 }
             }
             return Json("OK", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("NO", JsonRequestBehavior.AllowGet);
     }
 }
        public ActionResult AjaxVideoConferenceMaintenanceAdd(string ConferenceName, string ConferencePosition, string ConferenceStatement, string Organizer, string ConferenceDate, string JoinUnits, string ConferenceMaintener, string Reportor, string ReportDate, string MaintenanceCommants)
        {
            try
            {
                using (InfoManageDataContext context = new InfoManageDataContext())
                {
                    VideoConferenceMaintenance newSystemRepair = new VideoConferenceMaintenance();
                    newSystemRepair.ConferenceName = ConferenceName;
                    newSystemRepair.ConferencePosition = ConferencePosition;
                    newSystemRepair.ConferenceStatement = ConferenceStatement;
                    newSystemRepair.Organizer = Organizer;
                    newSystemRepair.ConferenceDate = DateTime.ParseExact(ConferenceDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                    newSystemRepair.JoinUnits = JoinUnits;
                    newSystemRepair.ConferenceMaintener = ConferenceMaintener;
                    newSystemRepair.Reportor = Reportor;
                    newSystemRepair.MaintenanceCommants = MaintenanceCommants;
                    newSystemRepair.ReportDate = DateTime.ParseExact(ReportDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);

                    VideoConferenceMaintenance result = context.VideoConferenceMaintenances.Where(c => c.ConferenceName.Equals(newSystemRepair.ConferenceName)).FirstOrDefault();
                    if (result == null)
                        context.VideoConferenceMaintenances.Add(newSystemRepair);
                    else
                    {
                        result.ConferencePosition = newSystemRepair.ConferencePosition;
                        result.ConferenceStatement = newSystemRepair.ConferenceStatement;
                        result.Organizer = newSystemRepair.Organizer;
                        result.ConferenceDate = newSystemRepair.ConferenceDate;
                        result.JoinUnits = newSystemRepair.JoinUnits;
                        result.ConferenceMaintener = newSystemRepair.ConferenceMaintener;
                        result.Reportor = newSystemRepair.Reportor;
                        result.MaintenanceCommants = newSystemRepair.MaintenanceCommants;
                        result.ReportDate = newSystemRepair.ReportDate;

                    }
                    context.SaveChanges();
                    return Json("OK", JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult AjaxSetTurnInStorageList(
            int ElementID, string SparePartsType, string ApplicableModels,
            string SparePartsCode, string Operator, string TurnInDate, int SparePartsStatus,
            int SparePartsBelongingStatus, string SparePartsManufacturer, string CheckDate, string VaildDate)
        {
            try
            {
                if (Request.Cookies["User"] != null)
                {
                    HttpCookie aCookie = Request.Cookies["User"];
                    ViewBag.RealName = Server.UrlDecode(aCookie["RealName"]);
                    int id = Convert.ToInt32(Server.UrlDecode(aCookie["ID"]));

                    using (MemberShipDataContext context = new MemberShipDataContext())
                    {
                        UserProfile usr = context.UserProfiles.Find(id);
                        if (null != usr)
                        {
                            using (InfoManageDataContext InfoManageContext = new InfoManageDataContext())
                            {
                                EquipmentsStorage newTurnInStorage = new EquipmentsStorage();
                                newTurnInStorage.SparePartsType = SparePartsType;
                                newTurnInStorage.ApplicableModels = ApplicableModels;
                                newTurnInStorage.SparePartsCode = SparePartsCode.Trim();
                                newTurnInStorage.TurnInDate = DateTime.ParseExact(TurnInDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                newTurnInStorage.Operator = Operator;
                                newTurnInStorage.SparePartsStatus = SparePartsStatus;
                                newTurnInStorage.SparePartsBelongingStatus = SparePartsBelongingStatus;
                                newTurnInStorage.CheckDate = DateTime.ParseExact(CheckDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                newTurnInStorage.VaildDate = DateTime.ParseExact(VaildDate, AllConsts.HOUR_MINUTE, System.Globalization.DateTimeFormatInfo.CurrentInfo);
                                newTurnInStorage.SparePartsManufacturer = SparePartsManufacturer;
                                newTurnInStorage.ElementID = ElementID;
                                newTurnInStorage.LastModifyDate = DateTime.Now;
                                newTurnInStorage.LastModifier = Operator;
                                EquipmentsStorage result = InfoManageContext.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
                                if (null == result)
                                {
                                    InfoManageContext.EquipmentsStorages.Add(newTurnInStorage);
                                }
                                else
                                {
                                    result.SparePartsType = newTurnInStorage.SparePartsType;
                                    result.ApplicableModels = newTurnInStorage.ApplicableModels;
                                    result.TurnInDate = newTurnInStorage.TurnInDate;
                                    result.Operator = newTurnInStorage.Operator;
                                    result.CheckDate = newTurnInStorage.CheckDate;
                                    result.VaildDate = newTurnInStorage.VaildDate;
                                    result.SparePartsManufacturer = newTurnInStorage.SparePartsManufacturer;
                                    result.ElementID = newTurnInStorage.ElementID;
                                    result.SparePartsBelongingStatus = SparePartsBelongingStatus;
                                    result.LastModifyDate = DateTime.Now;
                                    result.LastModifier = Operator;
                                }

                                UserAction newaction = new UserAction();
                                newaction.ID = usr.ID;
                                newaction.RealName = usr.RealName;
                                newaction.ActionName = "AjaxSetTurnInStorageList";
                                newaction.CreateTime = DateTime.Now;
                                newaction.LastModifyTime = newaction.CreateTime;
                                InfoManageContext.UserActions.Add(newaction);

                                InfoManageContext.SaveChanges();
                                return Json("OK", JsonRequestBehavior.AllowGet);
                            }
                        }
                    }
                }
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json("NO", JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult Front()
        {
            try
            {
                if (Request.Cookies["User"] != null)
                {
                    HttpCookie aCookie = Request.Cookies["User"];
                    ViewBag.RealName = Server.UrlDecode(aCookie["RealName"]);
                    int id = Convert.ToInt32(Server.UrlDecode(aCookie["ID"]));
                    int UnitNum = Convert.ToInt32(Server.UrlDecode(aCookie["UnitNum"]));
                    ViewBag.UnitName = Server.UrlDecode(aCookie["UnitName"]);

                    using (MemberShipDataContext context = new MemberShipDataContext())
                    {
                        UserProfile usr = context.UserProfiles.Find(id);
                        if (null != usr)
                        {
                            using (InfoManageDataContext onlinecontext = new InfoManageDataContext())
                            {
                                UserAction newaction = new UserAction();
                                newaction.ID = usr.ID;
                                newaction.RealName = usr.RealName;
                                newaction.ActionName = "EquipmentManagement";
                                newaction.CreateTime = DateTime.Now;
                                newaction.LastModifyTime = newaction.CreateTime;
                                onlinecontext.UserActions.Add(newaction);
                                onlinecontext.SaveChanges();
                            }
                        }
                    }

                    ViewBag.Title = "维修维护管理";
                    ViewBag.UnitNum = UnitNum;
                    return View(UnitNum);
                }
                else
                {
                    WebSecurity.Logout();
                    return RedirectToAction("Login", "Admin");
                }
            }
            catch
            {
                WebSecurity.Logout();
                return RedirectToAction("Login", "Admin");
            }
        }
        public ActionResult AjaxUploadImgs(string FileType, string flag, string SparePartsCode)
        {
            HttpPostedFileBase upload = Request.Files["upLoadFile"];
            if (upload != null && FileType != null)
            {
                if (upload.ContentLength > 0)
                {
                    using (InfoManageDataContext context = new InfoManageDataContext())
                    {
                        try
                        {
                            //SqlParameter[] parames = new SqlParameter[1];
                            //SqlParameter filetype = new SqlParameter();
                            //filetype.ParameterName = "@FileType";
                            //filetype.SqlDbType = System.Data.SqlDbType.VarChar;
                            //filetype.Size = 25;
                            //filetype.Value = FileType;
                            //parames[0] = filetype;
                            //AllUNCPath result = context.Database.SqlQuery<AllUNCPath>("EXEC [dbo].[sp_SYS_GetUNCPath] @FileType", parames).FirstOrDefault();
                            //string extname = System.IO.Path.GetExtension(upload.FileName);
                            //string picName = Path.Combine(result.UNCPath, SparePartsCode + flag + extname);
                            //FileInfo tmp = new FileInfo(picName);
                            //if (tmp.Exists)
                            //    tmp.Delete();
                            //upload.SaveAs(picName);

                            //byte[] img = (byte[])shape.Range.EnhMetaFileBits;
                            Bitmap bmp = new Bitmap(upload.InputStream);
                            MemoryStream ms = new MemoryStream();
                            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                            byte[] arr = new byte[ms.Length];
                            ms.Position = 0;
                            ms.Read(arr, 0, (int)ms.Length);
                            switch (flag)
                            {
                                case "设备图片":
                                    EquipmentsStorage equipmentshebei = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
                                    equipmentshebei.SparePartsPic = Convert.ToBase64String(arr);
                                    break;
                                case "合格证":
                                    EquipmentsStorage equipmenthege = context.EquipmentsStorages.Where(c => c.SparePartsCode.Equals(SparePartsCode)).FirstOrDefault();
                                    equipmenthege.SparePartsCertificatePic = Convert.ToBase64String(arr);
                                    break;
                            }
                            ms.Close();
                            context.SaveChanges();
                            return Json("OK", JsonRequestBehavior.AllowGet);
                        }
                        catch
                        {
                            return Json("NO", JsonRequestBehavior.AllowGet);
                        }
                    }
                }
            }
            return Json("NO", JsonRequestBehavior.AllowGet);
        }