コード例 #1
0
ファイル: SaveDataController.cs プロジェクト: hoonsyh/penrose
    public void LoadDecryptTest()
    {
        string filepath = Application.persistentDataPath + "/encTest.xml";

        xmlDoc.Load(filepath);
        XmlElement elmRoot = xmlDoc.DocumentElement;
        string     data    = DataEncryptDecrypt.Decrypt(elmRoot.InnerText);

        elmRoot.InnerXml = data;

        MemoryStream xmlStream = new MemoryStream();

        xmlDoc.Save(xmlStream);
        xmlStream.Flush();//Adjust this if you want read your data
        xmlStream.Position = 0;

        List <ArrayList> temp       = new List <ArrayList>();
        List <ArrayList> loadedData = new List <ArrayList>();
        var serializer = new XmlSerializer(typeof(List <ArrayList>));

        using (var stream = xmlStream)
        {
            var other = (List <ArrayList>)(serializer.Deserialize(stream));
            temp.Clear();
            temp.AddRange(other);
        }
        loadedData = temp;
    }
コード例 #2
0
ファイル: SaveDataController.cs プロジェクト: hoonsyh/penrose
    public void SaveEncryptTest()
    {
        string filepath = Application.persistentDataPath + "/encTest.xml";

        //경로에 있는 파일을 xmlDoc로 불러오기
        xmlDoc.Load(filepath);
        XmlElement elmRoot = xmlDoc.DocumentElement;

        string data = DataEncryptDecrypt.encryData(elmRoot.InnerXml);

        elmRoot.RemoveAll();
        elmRoot.InnerText = data;
        //xmlDoc에 있는 데이터를 경로에 저장
        xmlDoc.Save(filepath);
    }
コード例 #3
0
ファイル: SaveDataController.cs プロジェクト: hoonsyh/penrose
    //public ArrayList LoadFromResourcesProgress

    public ArrayList LoadArrayList(string filename)
    {
        //#if (UNITY_ANDROID && !UNITY_EDITOR)

        //#else
        string filepath = Application.persistentDataPath + "/dat/" + filename + ".xml";

        xmlDoc.Load(filepath);
        XmlElement elmRoot = xmlDoc.DocumentElement;
        string     data    = DataEncryptDecrypt.Decrypt(elmRoot.InnerText);

        elmRoot.InnerXml = data;

        MemoryStream xmlStream = new MemoryStream();

        xmlDoc.Save(xmlStream);
        xmlStream.Flush();//Adjust this if you want read your data
        xmlStream.Position = 0;

        ArrayList temp       = new ArrayList();
        ArrayList loadedData = new ArrayList();
        var       serializer = new XmlSerializer(typeof(ArrayList));

        using (var stream = xmlStream)
        {
            var other = (ArrayList)(serializer.Deserialize(stream));
            temp.Clear();
            temp.AddRange(other);
        }
        loadedData = temp;
        return(loadedData);


        //File.OpenRead(Application.persistentDataPath + "/" + filename + ".xml") <- 수정하기 전의 경로

        //#endif

        /*
         * using (var stream = File.OpenRead(Application.persistentDataPath + "/progress.xml"))
         * {
         *  var other = (ArrayList)(serializer.Deserialize(stream));
         *  temp.Clear();
         *  temp.AddRange(other);
         * }
         */
    }
コード例 #4
0
        public string UpateLoginUserPassword(User objUpdateUser)
        {
            string resultmsg = string.Empty;

            objencrypt    = new DataEncryptDecrypt();
            objpwdencrypt = new PasswordEncryptDecrypt();
            string resultMsg  = string.Empty;
            string encryptKey = string.Empty;

            try
            {
                string resultkey = getEncryptdata(objUpdateUser.UserCode);
                string pwd       = objpwdencrypt.Encrypt(objUpdateUser.Password, resultkey); //objUpdateUser.Password;//
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_UpateLoginUserPassword", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@UserID", objUpdateUser.UserID);
                        sqlcmd_obj.Parameters.AddWithValue("@PASSWORD", pwd);
                        sqlcmd_obj.Parameters.AddWithValue("@UpdatedBy", objUpdateUser.UserID);
                        sqlconn_obj.Open();
                        int resultcount = sqlcmd_obj.ExecuteNonQuery();
                        if (resultcount > 0)
                        {
                            resultmsg = "Success";
                        }
                        else
                        {
                            resultmsg = "Fail";
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_UpateLoginUserPassword", "UpateLoginUserPassword");
                throw;
            }
            return(resultmsg);
        }
コード例 #5
0
        public string GetUserDeviceLoginStatus(UserLogin objUser)
        {
            string resultmsg = string.Empty;

            objencrypt    = new DataEncryptDecrypt();
            objpwdencrypt = new PasswordEncryptDecrypt();
            string resultMsg  = string.Empty;
            string encryptKey = string.Empty;

            try
            {
                string resultkey = getEncryptdata(objUser.UserName);
                string pwd       = objpwdencrypt.Encrypt(objUser.Password, resultkey);
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_GetUserDeviceLoginStatus", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@UserName", objUser.UserName);
                        sqlcmd_obj.Parameters.AddWithValue("@Password", pwd);
                        sqlcmd_obj.Parameters.AddWithValue("@LoginDeviceID", objUser.LoginDeviceID);
                        sqlconn_obj.Open();
                        SqlDataAdapter sqldap   = new SqlDataAdapter(sqlcmd_obj);
                        DataTable      resultdt = new DataTable();
                        sqldap.Fill(resultdt);
                        if (resultdt.Rows.Count > 0)
                        {
                            resultmsg = "Please check user already logged in another device";
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_GetUserDeviceLoginStatus", "GetUserDeviceLoginStatus");
                throw;
            }
            return(resultmsg);
        }
コード例 #6
0
ファイル: SaveDataController.cs プロジェクト: hoonsyh/penrose
    public void SaveCharacterData(List <ArrayList> AllCharData)
    {
        var serializer = new XmlSerializer(typeof(List <ArrayList>));

        using (StreamWriter stream = new StreamWriter(new FileStream(Application.persistentDataPath + "/characterDataTemp.xml", FileMode.Create), Encoding.UTF8))
        {
            serializer.Serialize(stream, AllCharData);
        }

        string filepath = Application.persistentDataPath + "/characterDataTemp.xml";

        //경로에 있는 파일을 xmlDoc로 불러오기
        xmlDoc.Load(filepath);
        XmlElement elmRoot = xmlDoc.DocumentElement;

        string data = DataEncryptDecrypt.encryData(elmRoot.InnerXml);

        elmRoot.RemoveAll();
        elmRoot.InnerText = data;
        //xmlDoc에 있는 데이터를 경로에 저장
        string filepath2 = Application.persistentDataPath + "/characterData.xml";

        xmlDoc.Save(filepath2);
    }
コード例 #7
0
        public User GetLoginUserDetails(UserLogin objUser)
        {
            User objOutPutuser = new User();

            objencrypt    = new DataEncryptDecrypt();
            objpwdencrypt = new PasswordEncryptDecrypt();
            string resultMsg  = string.Empty;
            string encryptKey = string.Empty;

            try
            {
                string resultkey = getEncryptdata(objUser.UserName);
                string pwd       = objpwdencrypt.Encrypt(objUser.Password, resultkey);
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_LoginVerification", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@USERNAME", objUser.UserName);
                        sqlcmd_obj.Parameters.AddWithValue("@PASSWORD", pwd);
                        sqlcmd_obj.Parameters.AddWithValue("@Lattitude", objUser.Latitude);
                        sqlcmd_obj.Parameters.AddWithValue("@Longitude", objUser.Longitude);
                        sqlconn_obj.Open();
                        SqlDataAdapter sqldap   = new SqlDataAdapter(sqlcmd_obj);
                        DataTable      resultdt = new DataTable();
                        sqldap.Fill(resultdt);
                        if (resultdt.Rows.Count > 0)
                        {
                            objOutPutuser.UserName = Convert.ToString(resultdt.Rows[0]["USERNAME"]);
                            objOutPutuser.UserCode = Convert.ToString(resultdt.Rows[0]["UserCode"]);
                            objOutPutuser.UserID   = resultdt.Rows[0]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["UserID"]);
                            objOutPutuser.UserTypeID.UserTypeID = resultdt.Rows[0]["UserTypeID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["UserTypeID"]);
                            objOutPutuser.LocationParkingLotID.LocationParkingLotID    = resultdt.Rows[0]["LocationParkingLotID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["LocationParkingLotID"]);
                            objOutPutuser.LocationParkingLotID.LocationParkingLotName  = Convert.ToString(resultdt.Rows[0]["LocationParkingLotName"]);
                            objOutPutuser.LocationParkingLotID.LocationParkingLotCode  = Convert.ToString(resultdt.Rows[0]["LocationParkingLotCode"]);
                            objOutPutuser.LocationParkingLotID.LocationID.LocationID   = resultdt.Rows[0]["LocationID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["LocationID"]);
                            objOutPutuser.LocationParkingLotID.LocationID.LocationName = Convert.ToString(resultdt.Rows[0]["LocationName"]);
                            objOutPutuser.UserTypeID.UserTypeName        = Convert.ToString(resultdt.Rows[0]["UserTypeName"]);
                            objOutPutuser.LocationParkingLotID.Lattitude = Convert.ToDecimal(objUser.Latitude);
                            objOutPutuser.LocationParkingLotID.Longitude = Convert.ToDecimal(objUser.Longitude);
                            objOutPutuser.PhoneNumber   = Convert.ToString(resultdt.Rows[0]["PhoneNumber"]);
                            objOutPutuser.LoginTime     = DateTime.Now;
                            objOutPutuser.LoginDeviceID = objUser.LoginDeviceID;
                            objOutPutuser.Photo         = resultdt.Rows[0]["Photo"] == DBNull.Value ? null : (byte[])resultdt.Rows[0]["Photo"];
                            List <LocationParkingLot> lstLocationParkingLots = GetLoginUserAllocatedLocationLots(objOutPutuser);
                            if (lstLocationParkingLots.Count > 0)
                            {
                                LocationParkingLot userlot = lstLocationParkingLots[0];
                                objOutPutuser.LocationParkingLotID.LotCloseTime = userlot.LotCloseTime;
                                objOutPutuser.LocationParkingLotID.LotOpenTime  = userlot.LotOpenTime;
                                if (resultdt.Rows[0]["LocationParkingLotID"] == DBNull.Value)
                                {
                                    objOutPutuser.LocationParkingLotID.LocationParkingLotID    = userlot.LocationParkingLotID;
                                    objOutPutuser.LocationParkingLotID.LocationParkingLotName  = userlot.LocationParkingLotName;
                                    objOutPutuser.LocationParkingLotID.LocationID.LocationID   = userlot.LocationID.LocationID;
                                    objOutPutuser.LocationParkingLotID.LocationID.LocationName = userlot.LocationID.LocationName;
                                }
                                DALLocationLot dalLocation    = new DALLocationLot();
                                var            lotavilability = dalLocation.GetLocationLotVehicleAvailabilityDetails(userlot.LocationID.LocationID, userlot.LocationParkingLotID);
                                objOutPutuser.LocationParkingLotID.LotVehicleAvailabilityName = lotavilability.LotVehicleAvailabilityName;
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_LoginVerification", "GetLoginUserDetails");
                throw;
            }
            return(objOutPutuser);
        }