Beispiel #1
0
 public string DeleteUser(string PriUserId)
 {
     try
     {
         AppLog.WriteErrorLog("Function (POST) : User/DeleteUser");
         bool IsAdd = false; string ReturnVal = Validation.UnsuccessDeleteUser;
         if (!string.IsNullOrEmpty(PriUserId))
         {
             IsAdd = QueryBuilder.UpdateDB("IsActive = 0", "tblusers", "Where id = '" + PriUserId + "'");
         }
         if (IsAdd)
         {
             ReturnVal = Validation.SuccessDeleteUser;
         }
         return(ReturnVal);
     }
     catch
     {
         return(Validation.ErrorComman);
     }
     finally
     {
     }
 }
Beispiel #2
0
 public string DeleteRole(string RoleId)
 {
     try
     {
         AppLog.WriteErrorLog("Function (POST) : Role/DeleteRole");
         bool IsAdd = false; string ReturnVal = Validation.UnsuccessDeleteRole;
         if (!string.IsNullOrEmpty(RoleId))
         {
             IsAdd = QueryBuilder.UpdateDB("IsActive = 0", "mtblroles", "Where id = '" + RoleId + "'");
         }
         if (IsAdd)
         {
             ReturnVal = Validation.SuccessDeleteRole;
         }
         return(ReturnVal);
     }
     catch
     {
         return(Validation.ErrorComman);
     }
     finally
     {
     }
 }
Beispiel #3
0
 public string UpdateUser(string PriUserId, string FirstName, string MiddleName, string LastName, string UserId, string Password, string RoleId, string EmailId, string Phone, string IsActive, string ModifiedDate, string ModifiedBy, string PasswordModifiedDate)
 {
     try
     {
         AppLog.WriteErrorLog("Function (POST) : User/UpdateUser");
         if (!Validation.DuplicateUpdateUserId(UserId, PriUserId).Equals("1"))
         {
             return(Validation.ValidDuplicateUserId);
         }
         if (!Validation.DuplicateUpdateEmailId(EmailId, PriUserId).Equals("1"))
         {
             return(Validation.ValidDuplicateEmailId);
         }
         if (!Validation.DuplicateUpdatePhone(Phone, PriUserId).Equals("1"))
         {
             return(Validation.ValidDuplicatePhone);
         }
         string UserName = QueryBuilder.GetStr("UserId", "tblusers", "Where id = '" + PriUserId + "'");
         bool   IsAdd = false; string ReturnVal = Validation.UnsuccessUpdateUser; string ColumnsValues = string.Empty;
         if (!string.IsNullOrEmpty(FirstName))
         {
             ColumnsValues = "FirstName = '" + FirstName + "'";
         }
         if (!string.IsNullOrEmpty(MiddleName))
         {
             ColumnsValues = ColumnsValues + ",MiddleName = '" + MiddleName + "'";
         }
         if (!string.IsNullOrEmpty(LastName))
         {
             ColumnsValues = ColumnsValues + ",LastName = '" + LastName + "'";
         }
         if (!string.IsNullOrEmpty(UserId))
         {
             ColumnsValues = ColumnsValues + ",UserId = '" + UserId + "'";
         }
         if (!string.IsNullOrEmpty(Password))
         {
             ColumnsValues = ColumnsValues + ",Password = '******'";
         }
         if (!string.IsNullOrEmpty(EmailId))
         {
             ColumnsValues = ColumnsValues + ",EmailId = '" + EmailId + "'";
         }
         if (!string.IsNullOrEmpty(Phone))
         {
             ColumnsValues = ColumnsValues + ",Phone = '" + Phone + "'";
         }
         if (!string.IsNullOrEmpty(IsActive))
         {
             ColumnsValues = ColumnsValues + ",IsActive = '" + IsActive + "'";
         }
         if (!string.IsNullOrEmpty(ModifiedDate))
         {
             ColumnsValues = ColumnsValues + ",ModifiedDate = '" + ModifiedDate + "'";
         }
         if (!string.IsNullOrEmpty(ModifiedBy))
         {
             ColumnsValues = ColumnsValues + ",ModifiedBy = '" + ModifiedBy + "'";
         }
         if (!string.IsNullOrEmpty(PasswordModifiedDate))
         {
             ColumnsValues = ColumnsValues + ",PasswordModifiedDate = '" + PasswordModifiedDate + "'";
         }
         if (!string.IsNullOrEmpty(ColumnsValues))
         {
             IsAdd = QueryBuilder.UpdateDB(ColumnsValues, "tblusers", "Where id = '" + PriUserId + "'");
         }
         if (IsAdd)
         {
             string ColumnsValues1 = string.Empty;
             if (!string.IsNullOrEmpty(RoleId))
             {
                 ColumnsValues1 = "RoleId = '" + RoleId + "'";
             }
             if (!string.IsNullOrEmpty(UserId))
             {
                 ColumnsValues1 = ColumnsValues1 + ",UserId = '" + UserId + "'";
             }
             if (!string.IsNullOrEmpty(ColumnsValues1))
             {
                 QueryBuilder.UpdateDB(ColumnsValues1, "tbluserroles", "Where UserId = '" + UserName + "'");
             }
             ReturnVal = Validation.SuccessUpdateUser;
         }
         return(ReturnVal);
     }
     catch
     {
         return(Validation.ErrorComman);
     }
     finally
     {
     }
 }
Beispiel #4
0
        public string AddUser(string FirstName, string MiddleName, string LastName, string UserId, string Password, string RoleId, string EmailId, string Phone, string IsActive, string CreatedDate, string CreatedBy)
        {
            try
            {
                AppLog.WriteErrorLog("Function (POST) : User/AddUser");

                if (!Validation.DuplicateUserId(UserId).Equals("1"))
                {
                    return(Validation.ValidDuplicateUserId);
                }
                if (!Validation.DuplicateEmailId(EmailId).Equals("1"))
                {
                    return(Validation.ValidDuplicateEmailId);
                }
                if (!Validation.DuplicatePhone(Phone).Equals("1"))
                {
                    return(Validation.ValidDuplicatePhone);
                }

                bool IsAdd = false; string ReturnVal = Validation.UnsuccessAddUser; string Columns = string.Empty; string Values = string.Empty;
                if (!string.IsNullOrEmpty(FirstName))
                {
                    Columns = "FirstName"; Values = "'" + FirstName + "'";
                }
                else
                {
                    return(Validation.ValidFirstName);
                }
                if (!string.IsNullOrEmpty(MiddleName))
                {
                    Columns = Columns + ",MiddleName"; Values = Values + ",'" + MiddleName + "'";
                }
                if (!string.IsNullOrEmpty(LastName))
                {
                    Columns = Columns + ",LastName"; Values = Values + ",'" + LastName + "'";
                }
                if (!string.IsNullOrEmpty(UserId))
                {
                    Columns = Columns + ",UserId"; Values = Values + ",'" + UserId + "'";
                }
                else
                {
                    return(Validation.ValidUserId);
                }
                if (string.IsNullOrEmpty(RoleId))
                {
                    return(Validation.ValidRoleId);
                }
                if (!string.IsNullOrEmpty(Password))
                {
                    Columns = Columns + ",Password"; Values = Values + ",'" + Password + "'";
                }
                else
                {
                    return(Validation.ValidPassword);
                }
                if (!string.IsNullOrEmpty(EmailId))
                {
                    Columns = Columns + ",EmailId"; Values = Values + ",'" + EmailId + "'";
                }
                else
                {
                    return(Validation.ValidEmail);
                }
                if (!string.IsNullOrEmpty(Phone))
                {
                    Columns = Columns + ",Phone"; Values = Values + ",'" + Phone + "'";
                }
                if (!string.IsNullOrEmpty(IsActive))
                {
                    Columns = Columns + ",IsActive"; Values = Values + ",'" + IsActive + "'";
                }
                if (!string.IsNullOrEmpty(CreatedDate))
                {
                    Columns = Columns + ",CreatedDate"; Values = Values + ",'" + CreatedDate + "'";
                }
                if (!string.IsNullOrEmpty(CreatedBy))
                {
                    Columns = Columns + ",CreatedBy"; Values = Values + ",'" + CreatedBy + "'";
                }

                if (!string.IsNullOrEmpty(Columns) && !string.IsNullOrEmpty(Values))
                {
                    IsAdd = QueryBuilder.InsertInDB("tblusers", Columns, Values);
                    if (IsAdd)
                    {
                        string Columns1 = string.Empty; string Values1 = string.Empty; string AuthToken = Guid.NewGuid().ToString().Substring(0, 8);
                        if (!string.IsNullOrEmpty(UserId))
                        {
                            Columns1 = "UserId"; Values1 = "'" + UserId + "'";
                        }
                        else
                        {
                            return(Validation.ValidUserId);
                        }
                        if (!string.IsNullOrEmpty(AuthToken))
                        {
                            Columns1 = Columns1 + ",AuthToken"; Values1 = Values1 + ",'" + AuthToken + "'";
                        }
                        if (!string.IsNullOrEmpty(IsActive))
                        {
                            Columns1 = Columns1 + ",IsActive"; Values1 = Values1 + ",'" + IsActive + "'";
                        }
                        if (!string.IsNullOrEmpty(CreatedDate))
                        {
                            Columns1 = Columns1 + ",CreatedDate"; Values1 = Values1 + ",'" + CreatedDate + "'";
                        }
                        if (!string.IsNullOrEmpty(CreatedBy))
                        {
                            Columns1 = Columns1 + ",CreatedBy"; Values1 = Values1 + ",'" + CreatedBy + "'";
                        }
                        if (!string.IsNullOrEmpty(Columns1) && !string.IsNullOrEmpty(Values1))
                        {
                            QueryBuilder.InsertInDB("tbluserauthtokens", Columns1, Values1);
                        }
                    }
                    if (IsAdd)
                    {
                        string Columns2 = string.Empty; string Values2 = string.Empty;
                        if (!string.IsNullOrEmpty(UserId))
                        {
                            Columns2 = "UserId"; Values2 = "'" + UserId + "'";
                        }
                        else
                        {
                            return(Validation.ValidUserId);
                        }
                        if (!string.IsNullOrEmpty(RoleId))
                        {
                            Columns2 = Columns2 + ",RoleId"; Values2 = Values2 + ",'" + RoleId + "'";
                        }
                        if (!string.IsNullOrEmpty(IsActive))
                        {
                            Columns2 = Columns2 + ",IsActive"; Values2 = Values2 + ",'" + IsActive + "'";
                        }
                        if (!string.IsNullOrEmpty(CreatedDate))
                        {
                            Columns2 = Columns2 + ",CreatedDate"; Values2 = Values2 + ",'" + CreatedDate + "'";
                        }
                        if (!string.IsNullOrEmpty(CreatedBy))
                        {
                            Columns2 = Columns2 + ",CreatedBy"; Values2 = Values2 + ",'" + CreatedBy + "'";
                        }
                        if (!string.IsNullOrEmpty(Columns2) && !string.IsNullOrEmpty(Values2))
                        {
                            QueryBuilder.InsertInDB("tbluserroles", Columns2, Values2);
                        }
                    }
                }
                if (IsAdd)
                {
                    ReturnVal = Validation.SuccessAddUser;
                }
                return(ReturnVal);
            }
            catch
            {
                return(Validation.ErrorComman);
            }
            finally
            {
            }
        }
        public string SetActivityLog(string DeviceNo, string HType, string UserId, string Value1, string Value2, string Value3)
        {
            string IsSet = Validation.UnsuccessActivity;

            try
            {
                if (string.IsNullOrEmpty(Value1))
                {
                    Value1 = "NULL";
                }
                if (string.IsNullOrEmpty(Value2))
                {
                    Value2 = "NULL";
                }
                if (string.IsNullOrEmpty(Value3))
                {
                    Value3 = "NULL";
                }

                AppLog.WriteErrorLog("Function : ActivityLog/SetActivityLog  | DeviceNo : " + DeviceNo + " | HType : " + HType + " | UserId : " + UserId + " | Value1 : " + Value1 + " | Value2 : " + Value2 + " | Value3 : " + Value3);
                string DeviceMasterId = DeviceNo;

                if (HType == "Set RTC")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Set RTC", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Set Lat Long")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Set Lat Long", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Phase switch")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Phase switch", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Lamp control")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Lamp control", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "4 CH Lamp control")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "4 CH Lamp control", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Get Time")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Get Time", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Smart Scheduling")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Smart Scheduling", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Set Astro Schedule")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Set Astro Schedule", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Device Connected")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Device Connected", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }
                if (HType == "Device Disconneced")
                {
                    string Date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    SetActivityLogg(DeviceMasterId.ToString(), "Device Disconneced", UserId, Date, Value1, Value2, Value3);
                    IsSet = Validation.SuccessActivity;
                }

                return(IsSet);
            }
            catch (Exception ex) { return(IsSet); }
            finally { }
        }
Beispiel #6
0
        public string SetDevice(string DeviceName, string DeviceNo, string UserId)
        {
            string IsSet = Validation.UnsuccessDeviceProfile;

            try
            {
                AppLog.WriteErrorLog("Function (POST) : DeviceProfile/SetDevice");
                DataTable dt = QueryBuilder.GetDataTable("DeviceMastreId", "gdt_device", "Where DeviceNo = '" + DeviceNo + "'");


                if (dt.Rows.Count > 0)
                {
                    bool   IsSet1 = false;
                    string Date   = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                    IsSet1 = QueryBuilder.UpdateDB("DeviceName = '" + DeviceName + "', HDate = '" + Date + "'", "gdt_device", " Where DeviceNo = '" + DeviceNo + "'");

                    if (IsSet1 == true)
                    {
                        IsSet = Validation.SuccessDeviceProfile;

                        DataTable dt1 = QueryBuilder.GetDataTable("Id", "gdt_deviceprofile",
                                                                  " Where (select DeviceNo from gdt_device where DeviceId = DeviceMastreId LIMIT 1) = '" + DeviceNo + "' AND UserId = '" + UserId + "'");

                        if (dt1.Rows.Count > 0)
                        {
                        }
                        else
                        {
                            bool   IsSet2         = false;
                            string Date1          = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                            Int32  DeviceMasterId = QueryBuilder.GetInt("DeviceMastreId", "gdt_device", " Where DeviceNo = '" + DeviceNo + "' LIMIT 1");
                            IsSet2 = QueryBuilder.InsertInDB("gdt_deviceprofile", "DeviceId,UserId,DeviceDateTime,HDate",
                                                             "'" + DeviceMasterId.ToString() + "','" + UserId + "','" + Date1 + "','" + Date1 + "'");
                            if (IsSet2 == true)
                            {
                                IsSet = Validation.SuccessDeviceProfile;
                                SetActivityLog(DeviceMasterId.ToString(), "Profile Created", UserId, Date);
                            }
                        }
                    }
                }
                else
                {
                    bool   IsSet1 = false;
                    string Date   = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;

                    IsSet1 = QueryBuilder.InsertInDB("gdt_device", "DeviceName,DeviceNo,Date,HDate",
                                                     "'" + DeviceName + "','" + DeviceNo + "','" + Date + "','" + Date + "'");
                    if (IsSet1 == true)
                    {
                        IsSet = Validation.SuccessDeviceProfile;
                        Int32 DeviceMasterId = QueryBuilder.GetInt("DeviceMastreId", "gdt_device", " Where DeviceNo = '" + DeviceNo + "' LIMIT 1");
                        SetActivityLog(DeviceMasterId.ToString(), "Device Created", UserId, Date);

                        DataTable dt1 = QueryBuilder.GetDataTable("Id", "gdt_deviceprofile",
                                                                  " Where (select DeviceNo from gdt_device where DeviceId = DeviceMastreId LIMIT 1) = '" + DeviceNo + "' AND UserId = '" + UserId + "'");

                        if (dt1.Rows.Count > 0)
                        {
                        }
                        else
                        {
                            bool   IsSet2          = false;
                            string Date1           = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
                            Int32  DeviceMasterId1 = QueryBuilder.GetInt("DeviceMastreId", "gdt_device", " Where DeviceNo = '" + DeviceNo + "' LIMIT 1");
                            IsSet2 = QueryBuilder.InsertInDB("gdt_deviceprofile", "DeviceId,UserId,DeviceDateTime,HDate",
                                                             "'" + DeviceMasterId1.ToString() + "','" + UserId + "','" + Date1 + "','" + Date1 + "'");
                            if (IsSet2 == true)
                            {
                                IsSet = Validation.SuccessDeviceProfile;

                                SetActivityLog(DeviceMasterId1.ToString(), "Profile Created", UserId, Date);
                            }
                        }
                    }
                }
                return(IsSet);
            }
            catch (Exception ex)
            {
                return(Validation.ErrorComman);
            }
            finally
            {// return IsSet; }
            }
        }
Beispiel #7
0
        public string AddToken(string UserId, string DeviceId, string IsActive, string CreatedDate, string CreatedBy)
        {
            try
            {
                AppLog.WriteErrorLog("Function (POST) : Token/AddToken");
                string AuthToken = Guid.NewGuid().ToString().Substring(0, 8);
                if (!Validation.DuplicateAuthToken(UserId, AuthToken, DeviceId).Equals("1"))
                {
                    return(Validation.ValidDuplicateAuthToken);
                }
                bool IsAdd = false; string ReturnVal = Validation.UnsuccessAddToken; string Columns = string.Empty; string Values = string.Empty;
                if (!string.IsNullOrEmpty(UserId))
                {
                    Columns = "UserId"; Values = "'" + UserId + "'";
                }
                else
                {
                    return(Validation.ValidDuplicateUserId);
                }
                if (!string.IsNullOrEmpty(AuthToken))
                {
                    Columns = Columns + ",AuthToken"; Values = Values + ",'" + AuthToken + "'";
                }
                else
                {
                    return(Validation.ValidDuplicateAuthToken);
                }
                if (!string.IsNullOrEmpty(DeviceId))
                {
                    Columns = Columns + ",DeviceId"; Values = Values + ",'" + DeviceId + "'";
                }
                else
                {
                    return(Validation.ValidDuplicateDeviceId);
                }
                if (!string.IsNullOrEmpty(UserId))
                {
                    Columns = Columns + ",UserId"; Values = Values + ",'" + UserId + "'";
                }
                if (!string.IsNullOrEmpty(IsActive))
                {
                    Columns = Columns + ",IsActive"; Values = Values + ",'" + IsActive + "'";
                }
                if (!string.IsNullOrEmpty(CreatedDate))
                {
                    Columns = Columns + ",CreatedDate"; Values = Values + ",'" + CreatedDate + "'";
                }
                if (!string.IsNullOrEmpty(CreatedBy))
                {
                    Columns = Columns + ",CreatedBy"; Values = Values + ",'" + CreatedBy + "'";
                }

                if (!string.IsNullOrEmpty(Columns) && !string.IsNullOrEmpty(Values))
                {
                    IsAdd = QueryBuilder.InsertInDB("tbluserauthtokens", Columns, Values);
                }
                if (IsAdd)
                {
                    ReturnVal = Validation.SuccessAddToken;
                }
                return(ReturnVal);
            }
            catch
            {
                return(Validation.ErrorComman);
            }
            finally
            {
            }
        }