public string GetValidLogin(string Username, string Password)
        {
            try
            {
                AppLog.WriteErrorLog("Function (GET) : User/GetValidLogin");
                string ReturnValue = Validation.ValidLogin;
                // dynamic json = JsonConvert.DeserializeObject(ReturnValue);
                string AuthToken = Guid.NewGuid().ToString().Substring(0, 8);
                bool   IsUpdate  = QueryBuilder.UpdateDB("AuthToken = '" + AuthToken + "'", "tbluserauthtokens", "Where UserId = '" + Username + "'");
                if (IsUpdate)
                {
                    DataTable dt = QueryBuilder.GetDataTable("tbluserauthtokens.AuthToken", "tblusers inner join tbluserauthtokens on tbluserauthtokens.userid = tblusers.userid ", "Where tblusers.UserId = '" + Username + "' AND tblusers.Password = '******'");


                    if (dt.Rows.Count > 0)
                    {
                        string AuthToken1 = dt.Rows[0]["AuthToken"].ToString();

                        if (!string.IsNullOrEmpty(AuthToken1))
                        {
                            ReturnValue = AuthToken1;
                        }
                    }
                }

                return(ReturnValue);
            }
            catch
            {
                return(null);
            }
            finally
            {
            }
        }
 public DataTable GetActivity(string UserId)
 {
     try
     {
         AppLog.WriteErrorLog("Function : ActivityLog/GetActivity");
         DataTable dt = QueryBuilder.GetDataTable("*", "gdt_activitylog", "Where UserId = '" + UserId + "'");
         return(dt);
     }
     catch
     {
         return(null);
     }
     finally
     {
     }
 }
 public DataTable GetUser(string UserId)
 {
     try
     {
         AppLog.WriteErrorLog("Function (GET) : User/GetUser");
         DataTable dt = QueryBuilder.GetDataTable("*", "tblusers inner join tbluserroles on tbluserroles.UserId = tblusers.UserId Inner Join mtblroles on tbluserroles.RoleId = mtblroles.id", "Where tblusers.UserId = '" + UserId + "'");
         return(dt);
     }
     catch
     {
         return(null);
     }
     finally
     {
     }
 }
 public DataTable GetActivityList()
 {
     try
     {
         AppLog.WriteErrorLog("Function : ActivityLog/GetActivityList");
         DataTable dt = QueryBuilder.GetDataTable("*", "gdt_activitylog", string.Empty);
         return(dt);
     }
     catch
     {
         return(null);
     }
     finally
     {
     }
 }
 public DataTable GetRole(string RoleId)
 {
     try
     {
         AppLog.WriteErrorLog("Function (GET) : Role/GetRole");
         DataTable dt = QueryBuilder.GetDataTable("*", "mtblroles", "Where id = '" + RoleId + "'");
         return(dt);
     }
     catch
     {
         return(null);
     }
     finally
     {
     }
 }
 public DataTable GetRoleList()
 {
     try
     {
         AppLog.WriteErrorLog("Function (GET) : Role/GetRoleList");
         DataTable dt = QueryBuilder.GetDataTable("*", "mtblroles", string.Empty);
         return(dt);
     }
     catch
     {
         return(null);
     }
     finally
     {
     }
 }
 public DataTable GetToken(string UserId)
 {
     try
     {
         AppLog.WriteErrorLog("Function (GET) : Token/GetToken");
         DataTable dt = QueryBuilder.GetDataTable("*", "tbluserauthtokens", "Where UserId = '" + UserId + "'");
         return(dt);
     }
     catch
     {
         return(null);
     }
     finally
     {
     }
 }
Exemple #8
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; }
            }
        }