Example #1
0
        public static Core.Model.mdlSetDeviceID SetUserConfig(Core.Model.mdlSetDeviceIDParam param)
        {
            if (param.Uid == null)
            {
                param.Uid = "";
            }


            DataTable dt = new DataTable();
            List<SqlParameter> sp = new List<SqlParameter>()
            {
                new SqlParameter() {ParameterName = "@Uid", SqlDbType = SqlDbType.NVarChar, Value = param.Uid },
                new SqlParameter() {ParameterName = "@deviceID", SqlDbType = SqlDbType.NVarChar, Value = param.deviceID },
            };

            dt = DataFacade.DTSQLCommand(@"SELECT * FROM UserConfig WHERE Uid = @Uid  OR deviceID = @deviceID", sp);

            var mdlUserConfig = new Model.mdlSetDeviceID();
            foreach (DataRow row in dt.Rows)
            {

                mdlUserConfig.EmployeeID = row["EmployeeID"].ToString();
                mdlUserConfig.BranchID = row["BranchID"].ToString();
                mdlUserConfig.BranchName = row["BranchName"].ToString();
                mdlUserConfig.VehicleNumber = row["VehicleNumber"].ToString();
                mdlUserConfig.IpLocal = row["IpLocal"].ToString();
                mdlUserConfig.PortLocal = row["PortLocal"].ToString();
                mdlUserConfig.IpPublic = row["IpPublic"].ToString();
                mdlUserConfig.PortPublic = row["PortPublic"].ToString();
                mdlUserConfig.IpAlternative = row["IpAlternative"].ToString();
                mdlUserConfig.PortAlternative = row["PortAlternative"].ToString();
                mdlUserConfig.Password = row["Password"].ToString();
                mdlUserConfig.Uid = row["Uid"].ToString();
            }



            if (mdlUserConfig.EmployeeID == "" | mdlUserConfig.EmployeeID == null)
            {
                mdlUserConfig.Result = "0";
                mdlUserConfig.Role = "";
            }
            else
            {
                mdlUserConfig.Result = "1";
                mdlUserConfig.Role = getUserRole(mdlUserConfig.EmployeeID);
            }
            return mdlUserConfig;

        }
Example #2
0
        public static Model.mdlResultSV SetUserConfig(Core.Model.mdlSetDeviceIDParam param)
        {
            var mdlResult = new Model.mdlResultSV();

            mdlResult.Title = "Set User Config";
            var mdlUserConfig = new Model.mdlSetDeviceID();

            mdlUserConfig = UserConfigFacade.SetUserConfig(param);
            if (mdlUserConfig.EmployeeID == null || mdlUserConfig.Uid == "")
            {
                UserConfigFacade.UploadUid(param);
                mdlUserConfig = UserConfigFacade.SetUserConfig(param);
            }

            if (mdlUserConfig.EmployeeID == null || mdlUserConfig.EmployeeID == "")
            {
                mdlUserConfig.EmployeeID      = "";
                mdlUserConfig.BranchID        = "";
                mdlUserConfig.BranchName      = "";
                mdlUserConfig.VehicleNumber   = "";
                mdlUserConfig.IpLocal         = "";
                mdlUserConfig.PortLocal       = "";
                mdlUserConfig.IpPublic        = "";
                mdlUserConfig.PortPublic      = "";
                mdlUserConfig.IpAlternative   = "";
                mdlUserConfig.PortAlternative = "";
                mdlUserConfig.Password        = "";
                mdlUserConfig.EmployeeName    = "";
                mdlUserConfig.Version         = "";

                mdlResult.StatusCode    = "00";
                mdlResult.StatusMessage = "User Config Not Found";
                mdlResult.Value         = mdlUserConfig;

                //string json = Services.RestPublisher.Serialize(mdlResult);
                //var result = Services.RestPublisher.Deserialize<Model.mdlResultSV>(json);
                //return result;
            }
            else
            {
                var mdlparamAndroidKey = new Model.mdlSaveAndroidKeyParam();
                mdlparamAndroidKey.AndroidKey = param.token;
                mdlparamAndroidKey.EmployeeID = mdlUserConfig.EmployeeID;
                mdlparamAndroidKey.BranchID   = mdlUserConfig.BranchID;
                //var mobileConfig = MobileConfigFacade.GetMobileConfigbyID(mdlUserConfig.BranchID);

                var paramNew = new Model.mdlParam();
                paramNew.BranchID   = mdlUserConfig.BranchID;
                paramNew.EmployeeID = mdlUserConfig.EmployeeID;

                var mobileConfig        = MobileConfigFacade.LoadMobileConfig(paramNew);
                var mobileConfigVersion = mobileConfig.FirstOrDefault(fld => fld.ID.Equals("VERSION"));
                if (mobileConfigVersion != null)
                {
                    mdlUserConfig.Version = mobileConfigVersion.Value;
                }
                //FERNANDES-PasswordResetUpdate
                var mobileConfigPasswordReset = mobileConfig.FirstOrDefault(fld => fld.ID.Equals("PASSWORDRESET"));
                if (mobileConfigPasswordReset != null)
                {
                    mdlUserConfig.PasswordReset = mobileConfigPasswordReset.Value;
                }

                var employee = EmployeeFacade.GetEmployeeByID(mdlUserConfig.EmployeeID);
                if (employee != null)
                {
                    mdlUserConfig.EmployeeName = employee.EmployeeName;
                }

                string res           = string.Empty;
                var    checkEmployee = AndroidKeyFacade.CheckEmployee(mdlparamAndroidKey);
                if (checkEmployee.EmployeeID == null || checkEmployee.EmployeeID == "")
                {
                    res = Manager.AndroidKeyFacade.InsertAndroidKey(mdlparamAndroidKey);
                }
                else
                {
                    res = Manager.AndroidKeyFacade.UpdateAndroidKey(mdlparamAndroidKey);
                }

                mdlResult.StatusCode    = "01";
                mdlResult.StatusMessage = "Set User Config Success";
                mdlResult.Value         = mdlUserConfig;
            }

            string json   = Services.RestPublisher.Serialize(mdlResult);
            var    result = Services.RestPublisher.Deserialize <Model.mdlResultSV>(json);

            return(mdlResult);
        }
Example #3
0
        public static void UploadUid(Core.Model.mdlSetDeviceIDParam param)
        {
            List<SqlParameter> sp = new List<SqlParameter>()
            {
                 new SqlParameter() {ParameterName = "@DeviceID", SqlDbType = SqlDbType.NVarChar, Value = param.deviceID},
                 new SqlParameter() {ParameterName = "@Uid", SqlDbType = SqlDbType.NVarChar, Value = param.Uid}
            };

            String query = @"BEGIN TRAN
                                   UPDATE USERCONFIG 
                                        SET 
                                        Uid = @Uid,
                                        LastUpdateBy = @DeviceID,
                                        LastUpdateDate = GetDate()
                                   WHERE DeviceID = @DeviceID 

                                   IF @@rowcount = 0
                                   BEGIN
                                      INSERT INTO USERCONFIG 
                                            (DeviceID,
                                                EmployeeID,
                                                BranchID,
                                                BranchName,
                                                VehicleNumber,
                                                IpLocal,
                                                PortLocal,
                                                IpPublic,
                                                PortPublic,
                                                IpAlternative,
                                                PortAlternative,
                                                Password,
                                                CreatedBy,
                                                LastUpdateBy,
                                                CreatedDate,
                                                LastUpdateDate,
                                                Uid,
                                                isActive
                                                ) 
                                            VALUES 
                                            (@DeviceID,
                                                '',
                                                '',
                                                '',
                                                '',
                                                '',
                                                '',
                                                '',
                                                '',
                                                '',
                                                '',
                                                '',
                                                @DeviceID,
                                                @DeviceID,
                                                GetDate(),
                                                GetDate(),
                                                @Uid,
                                                '0'
                                                )
                                   END
                                COMMIT TRAN";
            string res = Manager.DataFacade.DTSQLVoidCommand(query, sp);
        }
Example #4
0
 public Core.Model.mdlResultSV SetUserConfig(Core.Model.mdlSetDeviceIDParam param)
 {
     return(JsonFacade.SetUserConfig(param));
 }