public void CheckSubDeviceStatus(ENT.PlantMasterSUB Plant)
        {
            BAL.SmsManagement objBalSms = new Josheph.Framework.BusinessLayer.SmsManagement();

            List <ENT.SubDeviceMasterSUB> subDevices = new List <Josheph.Framework.Entity.SubDeviceMasterSUB>();

            subDevices = lstSubDevices.FindAll(x => x.PlantID == Plant.PlantId);

            foreach (ENT.SubDeviceMasterSUB el in subDevices)
            {
                var intResult = objSubDevice.GetLastStatus(el.SubDeviceId);

                if (intResult == 512 || intResult == 4 || intResult == 768 || intResult == 72406)
                {
                    List <ENT.PlantDeviceLastStatus> deviceStatus = objLastStatus.GetByDevice(el.SubDeviceId, 2);

                    if (deviceStatus.Count > 0)
                    {
                        if (deviceStatus[0].laststatus_status != intResult)
                        {
                            string status = string.Empty;

                            if (intResult == 512 || intResult == 4)
                            {
                                status = "On grid";
                            }
                            if (intResult == 2 || intResult == 3)
                            {
                                status = "Irradiation Detecting";
                            }
                            if (intResult == 40960 || intResult == 1)
                            {
                                status = "No Irradiation";
                            }
                            if (intResult == 768 || intResult == 72406)
                            {
                                status = "Shutdown: Abnormal Grid Voltage";
                            }

                            String message = "ALERT-" + Environment.NewLine + Plant.PlantName + Environment.NewLine + el.SubDeviceName + " STATUS = " + status;

                            // sub device status changed send message
                            objBalSms.SendMessage("9426666404,8320399766", message);

                            // change plan status to offline
                            ENT.PlantDeviceLastStatus laststs = deviceStatus[0];
                            laststs.laststatus_status = intResult;
                            objLastStatus.Update(laststs);
                        }
                    }
                    else
                    {
                        objLastStatus.Entity.laststatus_deviceid = el.SubDeviceId;
                        objLastStatus.Entity.laststatus_type     = 2;
                        objLastStatus.Entity.laststatus_status   = intResult;
                        objLastStatus.Insert(objLastStatus.Entity);
                    }
                }
            }
        }
Example #2
0
        private List <string> ValidationEntry(object obj)
        {
            strvalidationResult.Clear();
            double n; double Lo, La;

            Entity = (ENT.PlantMasterSUB)obj;
            if (string.IsNullOrWhiteSpace(Entity.PlantName))
            {
                strvalidationResult.Add("Plant Name Required!");
            }
            if (string.IsNullOrWhiteSpace(Entity.ContactPerson))
            {
                strvalidationResult.Add("ContactPerson Name Required!");
            }
            if (!double.TryParse(Entity.Mobile, out n))
            {
                strvalidationResult.Add("Invalid Mobile Number!");
            }
            if (!double.TryParse(Entity.Logitude, out Lo))
            {
                strvalidationResult.Add("Invalid Logitude Number!");
            }
            if (!double.TryParse(Entity.Latitude, out La))
            {
                strvalidationResult.Add("Invalid Latitude Number!");
            }

            if (string.IsNullOrWhiteSpace(Entity.EmailId))
            {
                strvalidationResult.Add("Email Id  Required!");
            }
            else
            {
                bool isValidEmailid = COM.ExtendedMethods.ValidEmail(Entity.EmailId);
                if (isValidEmailid == false)
                {
                    strvalidationResult.Add("Invalid Email Id");
                }
            };

            //if (string.IsNullOrWhiteSpace(Entity.StateID)) { strvalidationResult.Add("State Name Required!"); }
            //if (string.IsNullOrWhiteSpace(Entity.CityID)) { strvalidationResult.Add("City Name Required!"); }
            if (string.IsNullOrWhiteSpace(Entity.Password))
            {
                strvalidationResult.Add("Password Required!");
            }
            if (string.IsNullOrWhiteSpace(Entity.InstllationAngle))
            {
                strvalidationResult.Add("InstllationAngle Required!");
            }
            if (string.IsNullOrWhiteSpace(Entity.InstllationAzimuth))
            {
                strvalidationResult.Add("InstllationAzimuth Required!");
            }
            if (string.IsNullOrWhiteSpace(Entity.plantDate))
            {
                strvalidationResult.Add("Plant Date Required!");
            }
            return(strvalidationResult);
        }
Example #3
0
 public ActionResult GetPlantReport(string id)
 {
     Model         = new Josheph.Framework.Entity.PlantMasterSUB();
     Model.PlantId = Guid.Parse(id);
     Model         = (ENT.PlantMasterSUB)objBAL.GetByPrimaryKey(Model);
     return(View(Model));
 }
Example #4
0
        [Authorize]//Update Status
        public JsonResult UpdateStatus(string id)
        {
            GlobalVarible.Clear();
            try
            {
                if (id != null)
                {
                    Model         = new Josheph.Framework.Entity.PlantMasterSUB();
                    Model.PlantId = new Guid(id);
                    Model         = (ENT.PlantMasterSUB)objBAL.GetByPrimaryKey(Model);
                    if (Model.Status == COM.MyEnumration.MyStatus.Active)
                    {
                        if (!objBAL.UpdateStatus(Model.PlantId, COM.MyEnumration.MyStatus.DeActive))
                        {
                            throw new Exception("Internal Server Error in status update.");
                        }
                    }

                    if (Model.Status == COM.MyEnumration.MyStatus.DeActive)
                    {
                        if (!objBAL.UpdateStatus(Model.PlantId, COM.MyEnumration.MyStatus.Active))
                        {
                            throw new Exception("Internal Server Error in status update.");
                        }
                    }
                    GlobalVarible.AddMessage("Status Update Successfully.");
                }
            }
            catch (Exception ex) { GlobalVarible.AddError(ex.Message); }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
Example #5
0
 [Authorize]//Edit Record
 public JsonResult EditRecord(string id)
 {
     if (id != null)
     {
         Model = new Josheph.Framework.Entity.PlantMasterSUB();
         Model.UpdatedDateTime = DateTime.Now;
         Model.PlantId         = new Guid(id);
         Model = (ENT.PlantMasterSUB)objBAL.GetByPrimaryKey(Model);
     }
     return(Json(new { Model = Model }, JsonRequestBehavior.AllowGet));
 }
Example #6
0
        public object GetByPrimaryKey(ENT.PlantMasterSUB Entity)
        {
            object objResult = null;

            try
            {
                DAL.CRUDOperation tt = new DAL.CRUDOperation();
                objResult = tt.GetEntityByPrimartKey(Entity);
            }
            catch (Exception)
            {
                throw;
            }
            return(objResult);
        }
Example #7
0
        public object GetByLoginID(ENT.PlantMasterSUB Entity)
        {
            object objResult = null;

            try
            {
                DAL.CRUDOperation tt = new DAL.CRUDOperation();
                Dictionary <string, COM.MyEnumration.Operation> fields = new Dictionary <string, COM.MyEnumration.Operation>();
                fields.Add("AspNetUserID", COM.MyEnumration.Operation.WHERE);
                objResult = tt.GetEntityByPerameters(Entity, fields);
            }
            catch (Exception)
            {
                throw;
            }
            return(objResult);
        }
Example #8
0
 [Authorize]//Delete Entry
 public JsonResult DeleteEntry(string id)
 {
     GlobalVarible.Clear();
     if (id != null)
     {
         Model         = new Josheph.Framework.Entity.PlantMasterSUB();
         Model.PlantId = new Guid(id);
         if (objBAL.Delete(Model))
         {
             GlobalVarible.AddMessage("Record Delete Successfully.");
         }
         else
         {
             GlobalVarible.AddError("Internal Server Error Please Try Again");
         }
     }
     MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
     return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
 }
Example #9
0
        [Authorize]//Save Entry
        public JsonResult SaveEntry(ENT.PlantMasterSUB model, string PlantId)
        {
            try
            {
                List <Guid> dctDuplication = new List <Guid>();
                if (model.InstallationSize.ToString() == "0")
                {
                    throw new Exception("Please Select Installation Size.");
                }
                if (model.InstallationType.ToString() == "0")
                {
                    throw new Exception("Please Select Installation Type.");
                }
                //if (model.CountryID.ToString() == "00000000-0000-0000-0000-000000000000") { throw new Exception("Please Select Country."); }
                //if (model.StateID.ToString() == "00000000-0000-0000-0000-000000000000") { throw new Exception("Please Select State."); }
                if (model.CityID.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    throw new Exception("Please Select City.");
                }
                if (model.EntryMode == COM.MyEnumration.EntryMode.ADD)
                {
                    model.Status = COM.MyEnumration.MyStatus.Active;
                    List <ENT.PlantMasterSUB> lstResult = new BAL.PlantMasterBAL().CheckDuplicateCombination(dctDuplication, COM.MyEnumration.MasterType.PlantMaster, model.PlantName, model.ContactPerson, model.Mobile, model.EmailId);
                    if (lstResult.Count > 0)
                    {
                        throw new Exception("Plant Name Already Exists.");
                    }
                    List <ENT.PlantMasterSUB> lstResult2 = new BAL.PlantMasterBAL().CheckDuplicateMobile(dctDuplication, COM.MyEnumration.MasterType.PlantMaster, model.PlantName, model.ContactPerson, model.Mobile, model.EmailId);
                    if (lstResult2.Count > 0)
                    {
                        throw new Exception("Mobile No Already Exists.!");
                    }
                    List <ENT.PlantMasterSUB> lstResult3 = new BAL.PlantMasterBAL().CheckDuplicateEmail(dctDuplication, COM.MyEnumration.MasterType.PlantMaster, model.PlantName, model.ContactPerson, model.Mobile, model.EmailId);
                    if (lstResult3.Count > 0)
                    {
                        GlobalVarible.AddError("Email Id Already Exists.!");
                    }

                    var user = new ApplicationUser {
                        UserName = model.EmailId, Email = model.EmailId
                    };
                    IdentityResult result = UserManager.Create(user, model.Password);
                    if (result.Succeeded)
                    {
                        this.UserManager.AddToRoleAsync(user.Id, "Client");
                        model.CreatedBy    = User.GetLogged_Userid();
                        model.AspNetUserID = Guid.Parse(user.Id);
                        if (objBAL.Insert(model))
                        {
                            GlobalVarible.AddMessage("Record Save Successfully");
                        }
                    }
                    else
                    {
                        foreach (var e in result.Errors)
                        {
                            GlobalVarible.AddError(e);
                        }
                    }
                }
                else
                {
                    model.CreatedDateTime = DateTime.Now;
                    model.PlantId         = new Guid(PlantId.Replace("/", ""));
                    if (objBAL.Update(model))
                    {
                        GlobalVarible.AddMessage("Record Update Successfully");
                    }
                }
            }
            catch (Exception ex)
            { GlobalVarible.AddError(ex.Message); }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }