예제 #1
0
        public string Registration(string username, string password, string pDivID, string pName, string pEmail, string pUserRights, int pRespType, string pOption)
        {
            string lResponse = "";
            string lDT       = "";

            //Nastavitve.LoadLicData();

            int lR = Registration(username, password, pDivID, pName, pEmail, pUserRights, out lDT);

            if (pRespType == 0)
            {
                lResponse = lDT;
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, lR, Splosno.GetTranslateByID(lR), lResponse);
            }
            else if (pRespType == 1)
            {
                if (lDT.Length > 0)
                {
                    DataTable dt = Splosno.DeserializeDataTable_json(lDT);
                    lResponse = Splosno.SerializeDataTable_xml(dt);
                }

                lResponse = Splosno.AddHeadDataToResponseData(pRespType, lR, Splosno.GetTranslateByID(lR), lResponse);
            }

            return(lResponse);
        }
예제 #2
0
        private List <string> Get_UserRolse(string pUR)
        {
            List <string> lRet = new List <string>();

            DataTable lDT = Splosno.DeserializeDataTable_json(pUR);

            foreach (DataRow r in lDT.Rows)
            {
                string lRoleID = Convert.ToString(r["acRoleID"]);
                //string lUN = Convert.ToString(r["acUserName"]);
                lRet.Add(lRoleID.ToString());
            }

            return(lRet);
        }
예제 #3
0
        public static string Delete(int pID, int pRespType, string pOption)
        {
            string lResponse = "";

            Delete(pID);
            if (pRespType == 0)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }

            return(lResponse);
        }
예제 #4
0
        public static string Edit(int id, string pUserName, string pPassword, string pFirstName, string pLastName, bool pActive, bool pAdmin, string pPravice, HttpSessionState s, string pEmail, string pGsm, int pModifUser, int pRespType, string pOption)
        {
            string lResponse = "";

            Edit(id, pUserName, pPassword, pFirstName, pLastName, pActive, pAdmin, pPravice, s, pEmail, pGsm, pModifUser);
            if (pRespType == 0)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }

            return(lResponse);
        }
예제 #5
0
        public static string GetLicData(int pRespType, string pOption)
        {
            string lResponse = "";

            string dt = Convert.ToString(Get("", "LicData"));

            if (pRespType == 0)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", dt);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", dt);
            }

            return(lResponse);
        }
예제 #6
0
        public static string GetLicDataReport(int pRespType, string pOption)
        {
            string lResponse = "";

            string dt = GetLicDataReport();

            if (pRespType == 0)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", dt);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", dt);
            }

            return(lResponse);
        }
예제 #7
0
        public static string SetLicData(int pUserMod, string pLicData, int pRespType, string pOption)
        {
            string lResponse = "";

            SaveLicData(pLicData, pUserMod);
            LoadLicData();

            if (pRespType == 0)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }

            return(lResponse);
        }
예제 #8
0
        public static string Get(int pRespType, string pOption)
        {
            string lResponse = "";

            DataTable dt = Get();

            if (pRespType == 0)
            {
                lResponse = Splosno.SerializeDataTable_json(dt);
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.SerializeDataTable_xml(dt, false);
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }

            return(lResponse);
        }
예제 #9
0
        public static string Add(string pUserName, string pPassword, string pFirstName, string pLastName, bool pActive, string pPravice, string pEmail, string pGsm, bool pAdmin, int pModifUser, int pRespType, string pOption)
        {
            string lResponse = "";

            int lID = Add(pUserName, pPassword, pFirstName, pLastName, pActive, pPravice, pEmail, pGsm, pAdmin, pModifUser);

            if (pRespType == 0)
            {
                lResponse = lID.ToString();
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }
            else if (pRespType == 1)
            {
                lResponse = lID.ToString();
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }

            return(lResponse);
        }
예제 #10
0
        public static string Set(string pGroup, string pKey, int pUserMod, string pKeyValue, int pRespType, string pOption)
        {
            string lResponse = "";

            Set(pGroup, pKey, pUserMod, pKeyValue);
            //SaveLicData(pLicData, pUserMod);
            //LoadLicData();

            if (pRespType == 0)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }

            return(lResponse);
        }
예제 #11
0
        public static string Get(string acShortTitle, string acVATNumber, int pRespType, string pOption)
        {
            string lResponse = "";

            DataTable dt = Get_d(acShortTitle, acVATNumber);

            if (pRespType == 0)
            {
                lResponse = JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented);
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }
            else if (pRespType == 1)
            {
                lResponse = Splosno.SerializeDataTable_xml(dt, true);
                lResponse = Splosno.AddHeadDataToResponseData(pRespType, 0, "", lResponse);
            }

            return(lResponse);
        }
예제 #12
0
        private int login(string username, string password, string pDivID, int pForceLogin, out string pDT)
        {
            int lResponse = -1;

            pDT = "";
            string lUsername, lpassword;

            _DesktopApp = true;

            lUsername = username;
            lpassword = password;

            // Preveri ali se prijavlja servis, ali uporabnik
            if ((lUsername.Length == 0) && (pDivID.Length > 0))
            {
                _DesktopApp = false;
                int lUserID = Uporabniki.Get_UserID(pDivID);
                if (lUserID > 0)
                {
                    Uporabniki.Get_UserLoginData(lUserID, out lUsername, out lpassword);
                }
            }

            string lResp = lSql.ConnectSQL(Splosno.AppSQLName);

            if (lResp.Length > 0)
            {
                throw new Exception(lResp);
            }

            StringBuilder sSQL = new StringBuilder();

            if (String.IsNullOrEmpty(lpassword))
            {
                lpassword = "";
            }
            sSQL.AppendLine(" ");
            sSQL.AppendLine("SELECT * FROM _mrt_Users ");
            sSQL.AppendLine("WHERE  acUserName = @username and acPassword = @password ");
            sSQL.AppendLine(" ");
            sSQL.AppendLine(" ");

            SqlParameter[] sqlParams = new SqlParameter[] {
                new SqlParameter("@username", lUsername),
                new SqlParameter("@password", lpassword)
            };

            string    lErr = "";
            DataTable lDT  = lSql.FillDT(sSQL, sqlParams, out lErr);

            lSql.DisconnectSQL();

            if (lDT.Rows.Count > 0)
            {
                DataRow lrow           = lDT.Rows[0];
                int     lUserID        = Convert.ToInt32(lrow["anUserID"]);
                string  lUserSessionID = (lrow["acSesionID"].ToString());
                bool    lUserActive    = Convert.ToBoolean(lrow["anActive"]);
                bool    lAppLogedIn    = Convert.ToBoolean(lrow["anAppLogedIn"]);
                bool    lLogedIn       = Convert.ToBoolean(lrow["anLogedIn"]);

                pDT = Splosno.SerializeDataTable_json(lDT);

                if (lUserActive == true)
                {
                    int maxLic;
                    //int.TryParse(Nastavitve.Get("", "LicNumber", "0"), out maxLic);
                    int.TryParse(Nastavitve.LicData["LicNumberValue"], out maxLic);
                    int  currLogedUsers  = Uporabniki.Get_LoggedUsers();
                    bool lCheckLicNumber = Convert.ToBoolean(Nastavitve.LicData["LicNumberCheck"]);

                    if ((!lCheckLicNumber) || (maxLic >= (currLogedUsers + 1)))
                    {
                        if ((lAppLogedIn != true && !lLogedIn) || (pForceLogin == 1))
                        {
                            string lNewSessionID = Guid.NewGuid().ToString();

                            // Če je uporabnik prijavljen v drugem sistemu, ohrani sesionID, da ga ne vržemo ven!
                            //if ((lLogedIn) || (lAppLogedIn)) { lNewSessionID = lUserSessionID; }

                            Set_UserUpdate(lUserID, true, lNewSessionID, _DesktopApp);

                            // Ponovno pridobi podatke o userju z novim sessionid-jem
                            DataTable lDT1 = Uporabniki.Get_UserBySession(lUsername, lNewSessionID);
                            pDT = Splosno.SerializeDataTable_json(lDT1);

                            lSql.ConnectSQL(Splosno.AppSQLName);
                            sSQL.Remove(0, sSQL.Length);
                            sSQL.AppendLine("SELECT UR.acRoleID FROM _mrt_UserRoles UR WITH(NOLOCK) ");
                            sSQL.AppendLine("WHERE (UR.acUserName = @UserName) ");

                            sqlParams = null;
                            sqlParams = new SqlParameter[] {
                                new SqlParameter("@UserName", lUsername)
                            };

                            lDT = null;
                            lDT = lSql.FillDT(sSQL, sqlParams, out lErr);
                            lSql.DisconnectSQL();

                            if (lDT.Rows.Count > 0)
                            {
                                _pravice = Splosno.SerializeDataTable_json(lDT);
                            }
                            else
                            {
                                _pravice = "[]";
                            }

                            lrow          = lDT1.Rows[0];
                            _id           = Convert.ToInt32(lrow["anUserID"]);
                            _username     = Convert.ToString(lrow["acUserName"]);
                            _ime          = Convert.ToString(lrow["acFirstName"]);
                            _priimek      = Convert.ToString(lrow["acLastName"]);
                            _ModifiedDate = Convert.ToDateTime(lrow["adTimeMod"]);
                            _active       = Convert.ToBoolean(lrow["anActive"]);
                            _AppLogedIn   = Convert.ToBoolean(lrow["anAppLogedIn"]);
                            _logged_in    = Convert.ToBoolean(lrow["anLogedIn"]);
                            _SessionID    = Convert.ToString(lrow["acSesionID"]);
                            _Email        = Convert.ToString(lrow["acEmail"]);
                            _Gsm          = Convert.ToString(lrow["acGSM"]);
                            _admin        = Convert.ToBoolean(lrow["anAdmin"]);
                            lResponse     = 0;
                        }
                        else
                        {
                            lResponse = 103; //Uporabnik je že prijavljen!
                        }
                    }
                    else
                    {
                        lResponse = 102;
                    }
                }
                else
                {
                    lResponse = 101;
                }
            }
            else
            {
                lResponse = 100;
            }

            return(lResponse);
        }
예제 #13
0
 public static byte[] DecryptAES256(byte[] input, string key)
 {
     return((new AES256(Encoding.Default.GetBytes(Splosno.Truncate(key.PadRight(32, '0'), 32)))).EncryptionFormatter.Decrypt(input));
 }
예제 #14
0
 public static string DecryptAES256(string input, string key)
 {
     return(Encoding.Default.GetString((new AES256(Encoding.Default.GetBytes(Splosno.Truncate(key.PadRight(32, '0'), 32)))).EncryptionFormatter.Decrypt(Convert.FromBase64String(input))));
 }