Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext.Current.Response.SuppressFormsAuthenticationRedirect = true;
            //var provider = Request.Form["provider"];
            var provider = GWWebHelper.GetQueryValue(Request, "provider");

            if (provider == null)
            {
                return;
            }
            // Request a redirect to the external login provider
            string redirectUrl = ResolveUrl(String.Format(CultureInfo.InvariantCulture, "~/#?Action=RegisterExternalLogin&{0}={1}&returnUrl={2}", IdentityHelper.ProviderNameKey, provider, ReturnUrl));
            var    properties  = new AuthenticationProperties()
            {
                RedirectUri = redirectUrl
            };

            // Add xsrf verification when linking accounts
            if (Context.User.Identity.IsAuthenticated)
            {
                properties.Dictionary[IdentityHelper.XsrfKey] = Context.User.Identity.GetUserId();
            }
            Context.GetOwinContext().Authentication.Challenge(properties, provider);
            Response.StatusCode = 401;
            Response.End();
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String mNVP_SEQ_ID = GWWebHelper.GetQueryValue(Request, "NVP_SEQ_ID");

            if (!String.IsNullOrEmpty(mNVP_SEQ_ID))
            {
                NVP_SEQ_ID.Value = mNVP_SEQ_ID.ToString();
            }
        }
Ejemplo n.º 3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            string mAction = GWWebHelper.GetQueryValue(Request, "action");

            if (!String.IsNullOrEmpty(mAction))
            {
                m_SecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
            }
        }
Ejemplo n.º 4
0
        public static string GetRandomNumbers(int amountOfNumbers, int maxNumber, int minNumber)
        {
            String mRetVal = String.Empty;

            for (int i = 0; i < amountOfNumbers; i++)
            {
                mRetVal += GWWebHelper.GetRandomNumber(maxNumber, minNumber) + ", ";
            }
            return(mRetVal);
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string mAction = GWWebHelper.GetQueryValue(Request, "action");

            if (!String.IsNullOrEmpty(mAction))
            {
                MFunctionProfile mFunctionProfile = FunctionUtility.GetProfile(mAction);
                MSecurityInfo    mSecurityInfo    = new MSecurityInfo(mFunctionProfile, AccountUtility.CurrentProfile());
                SearchControl.ShowAddLink = mSecurityInfo.MayAdd;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Page_s the init.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Init(Object sender, EventArgs e)
        {
            string mAction = GWWebHelper.GetQueryValue(Request, "action");

            if (!String.IsNullOrEmpty(mAction))
            {
                MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(mAction), AccountUtility.CurrentProfile());
                if (!mSecurityInfo.MayDelete)
                {
                    this.searchResults.Columns.RemoveAt(1);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            noResults.Visible = false;
            searchResults.HeaderStyle.ForeColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeaderForeColor]);
            searchResults.HeaderStyle.BackColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeadColor]);
            searchResults.AlternatingRowStyle.BackColor = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.AlternatingRowBackColor]);
            searchResults.RowStyle.BackColor            = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.RowBackColor]);
            if (!String.IsNullOrEmpty(GWWebHelper.GetQueryValue(Request, "Columns")))
            {
                MSearchCriteria mSearchCriteria = new MSearchCriteria();
                mSearchCriteria.Columns          = GWWebHelper.GetQueryValue(Request, "Columns");
                mSearchCriteria.OrderByColumn    = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "OrderByColumn"));
                mSearchCriteria.OrderByDirection = GWWebHelper.GetQueryValue(Request, "OrderByDirection");
                int mTryParse = 0;
                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "PageSize"), out mTryParse))
                {
                    mSearchCriteria.PageSize = int.Parse(GWWebHelper.GetQueryValue(Request, "PageSize"));
                }
                else
                {
                    mSearchCriteria.PageSize = 10;
                }

                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "SelectedPage"), out mTryParse))
                {
                    mSearchCriteria.SelectedPage = int.Parse(GWWebHelper.GetQueryValue(Request, "SelectedPage"));
                }
                else
                {
                    mSearchCriteria.SelectedPage = 1;
                }
                mSearchCriteria.WhereClause = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "WhereClause"));
                mSearchCriteria.WhereClause = mSearchCriteria.WhereClause.Replace("\"", String.Empty);
                string mDesiredPath = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "desiredPath"));
                if (mDesiredPath.Length != 0)
                {
                    m_CurrentDirectory = mDesiredPath;
                }
                string mTestFunctionSeqID = GWWebHelper.GetQueryValue(Request, "functionSeqID");
                if (!String.IsNullOrEmpty(mTestFunctionSeqID))
                {
                    int mFunctionSeqId = int.Parse(mTestFunctionSeqID);
                }
                bindData(mSearchCriteria);
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String mGroupSeqId = GWWebHelper.GetQueryValue(Request, "GroupSeqID");

            if (!String.IsNullOrEmpty(mGroupSeqId))
            {
                int mGroupID = int.Parse(mGroupSeqId);
                if (mGroupID != -1)
                {
                    m_Profile = GroupUtility.GetProfile(mGroupID);
                }
                else
                {
                    m_Profile = new MGroupProfile();
                }
                HttpContext.Current.Session.Add("EditId", m_Profile.Id);
                populatePage();
            }
        }
Ejemplo n.º 9
0
        public IHttpActionResult DeleteNameValuePairDetail(UINVPDetailProfile uiProfile)
        {
            string          mRetVal          = false.ToString();
            String          mAction          = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action");
            int             mEditId          = int.Parse(HttpContext.Current.Items["EditId"].ToString());
            MAccountProfile mUpdatingAccount = AccountUtility.CurrentProfile();
            MSecurityInfo   mSecurityInfo    = new MSecurityInfo(FunctionUtility.GetProfile(mAction), mUpdatingAccount);

            Logger mLog = Logger.Instance();

            if (mEditId != uiProfile.NVP_SEQ_DET_ID)
            {
                Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            if (!mSecurityInfo.MayDelete)
            {
                Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to delete");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            try
            {
                MNameValuePairDetail mProfile = new MNameValuePairDetail();
                mProfile.NameValuePairSeqId = uiProfile.NVP_SEQ_ID;
                mProfile.Id          = uiProfile.NVP_SEQ_DET_ID;
                mProfile.UpdatedBy   = mUpdatingAccount.Id;
                mProfile.UpdatedDate = DateTime.Now;
                mProfile.SortOrder   = uiProfile.SortOrder;
                mProfile.Text        = uiProfile.Text;
                mProfile.Value       = uiProfile.Value;
                mProfile.Status      = uiProfile.Status;
                NameValuePairUtility.DeleteDetail(mProfile);
            }
            catch (Exception ex)
            {
                mLog.Error(ex);
                throw;
            }
            return(this.Ok(mRetVal));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        /// <param name="searchCriteria">The search criteria.</param>
        private void bindData(MSearchCriteria searchCriteria)
        {
            try
            {
                HttpServerUtility mServer          = Server;
                string            mAction          = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action");
                MFunctionProfile  mFunctionProfile = FunctionUtility.GetProfile(mAction);
                m_DirectoryProfile = DirectoryUtility.GetProfileByFunction(mFunctionProfile.Id);
                string    mDirectoryPath = m_DirectoryProfile.Directory + m_CurrentDirectory;
                DataTable mDataTable     = FileUtility.GetDirectoryTableData(mDirectoryPath, m_DirectoryProfile, false);
                SortTable mSorter        = new SortTable();
                string    mColName       = searchCriteria.OrderByColumn;
                mSorter.Sort(mDataTable, mColName, searchCriteria.OrderByDirection);

                DataView mView = mDataTable.DefaultView;
                mView.Sort = "type desc";
                mDataTable = DataHelper.GetTable(ref mView);
                //mDataTable = DataHelper.GetPageOfData(ref mDataTable, ref searchCriteria);
                string mSort = "type desc, " + searchCriteria.OrderByColumn + " " + searchCriteria.OrderByDirection;
                mDataTable = DataHelper.GetPageOfData(ref mDataTable, mSort, searchCriteria);
                if (mDataTable != null && mDataTable.Rows.Count > 0)
                {
                    DataView mDataView = mDataTable.DefaultView;
                    recordsReturned.Value    = mDataTable.Rows[0][DataHelper.TotalRowColumnName].ToString();
                    searchResults.DataSource = mDataTable;
                    searchResults.DataBind();
                }
                else
                {
                    noResults.Visible = true;
                }
            }
            catch (DirectoryNotFoundException)
            {
                litErrorMSG.Visible = true;
                litErrorMSG.Text    = "The Directory has not been setup or is unavalible.";
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Enables processing of HTTP Web requests for downloading files that implements the <see cref="T:System.Web.IHttpHandler" /> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext" /> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>

        public void ProcessRequest(HttpContext context)
        {
            String mFilename            = GWWebHelper.GetQueryValue(context.Request, "fileName");
            String mPath                = GWWebHelper.GetQueryValue(context.Request, "thePath");
            String mFunctionSeqIDString = GWWebHelper.GetQueryValue(context.Request, "functionSeqID");

            if (!String.IsNullOrEmpty(mFilename) && !String.IsNullOrEmpty(mFunctionSeqIDString) && !String.IsNullOrEmpty(mPath))
            {
                int mFunctionSeqID = int.Parse(mFunctionSeqIDString);
                MDirectoryProfile mDirectoryProfile = DirectoryUtility.GetProfile(mFunctionSeqID);
                context.Response.ContentType = "application/octet-stream";
                context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", mFilename));
                using (Stream s = new FileStream(mDirectoryProfile.Directory + mPath + "/" + mFilename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    s.CopyTo(context.Response.OutputStream);
                }
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("Invalid filename");
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string NVP_SEQ_ID             = GWWebHelper.GetQueryValue(Request, "NVP_SEQ_ID");
            string NVP_Detail_SeqID       = GWWebHelper.GetQueryValue(Request, "NVP_Detail_SeqID");
            MNameValuePairDetail mProfile = new MNameValuePairDetail();

            if (!String.IsNullOrEmpty(NVP_SEQ_ID) && !String.IsNullOrEmpty(NVP_Detail_SeqID))
            {
                int mSeqId    = int.Parse(NVP_SEQ_ID);
                int mSeqDetId = int.Parse(NVP_Detail_SeqID);
                if (mSeqDetId != -1)
                {
                    mProfile = NameValuePairUtility.GetNameValuePairDetail(mSeqDetId, mSeqId);
                }
                hdnNVP_SEQ_ID.Value     = mSeqId.ToString();
                hdnNVP_SEQ_DET_ID.Value = mProfile.Id.ToString();
                txtValue.Value          = mProfile.Value;
                txtText.Value           = mProfile.Text;
                txtSortOrder.Value      = mProfile.SortOrder.ToString();
                HttpContext.Current.Session.Add("EditId", mProfile.Id);
            }
            HttpContext.Current.Session.Add("EditId", mProfile.Id);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            m_SecurityInfo    = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
            noResults.Visible = false;
            searchResults.HeaderStyle.ForeColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeaderForeColor]);
            searchResults.HeaderStyle.BackColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeadColor]);
            searchResults.AlternatingRowStyle.BackColor = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.AlternatingRowBackColor]);
            searchResults.RowStyle.BackColor            = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.RowBackColor]);
            if (!String.IsNullOrEmpty(GWWebHelper.GetQueryValue(Request, "Columns")))
            {
                MSearchCriteria mSearchCriteria = new MSearchCriteria();
                mSearchCriteria.Columns          = GWWebHelper.GetQueryValue(Request, "Columns");
                mSearchCriteria.OrderByColumn    = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "OrderByColumn"));
                mSearchCriteria.OrderByDirection = GWWebHelper.GetQueryValue(Request, "OrderByDirection");
                int mTryParse = 0;
                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "PageSize"), out mTryParse))
                {
                    mSearchCriteria.PageSize = int.Parse(GWWebHelper.GetQueryValue(Request, "PageSize"));
                }
                else
                {
                    mSearchCriteria.PageSize = 10;
                }

                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "SelectedPage"), out mTryParse))
                {
                    mSearchCriteria.SelectedPage = int.Parse(GWWebHelper.GetQueryValue(Request, "SelectedPage"));
                }
                else
                {
                    mSearchCriteria.SelectedPage = 1;
                }
                mSearchCriteria.WhereClause = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "WhereClause"));
                mSearchCriteria.WhereClause = mSearchCriteria.WhereClause.Replace("\"", String.Empty);
                bindData(mSearchCriteria);
            }
        }
Ejemplo n.º 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     btnSave.Visible = false;
     m_Action        = GWWebHelper.GetQueryValue(Request, "Action");
     if (!String.IsNullOrEmpty(Request.QueryString["AccountSeqID"]))
     {
         int mAccountSeqID = int.Parse(Request.QueryString["AccountSeqID"].ToString());
         if (mAccountSeqID != -1)
         {
             m_Profile = AccountUtility.GetProfile(mAccountSeqID);
         }
         else
         {
             m_Profile = new MAccountProfile();
         }
     }
     else
     {
         m_Profile              = AccountUtility.CurrentProfile();
         btnSave.Visible        = true;
         hdnCanSaveRoles.Value  = false.ToString();
         hdnCanSaveGroups.Value = false.ToString();
         hdnCanSaveStatus.Value = false.ToString();
         tdStatus.Style.Add("display", "none");
         dropStatus.Style.Add("display", "none");
         if (m_Action.ToUpper(CultureInfo.InvariantCulture).IndexOf("REGISTER") > -1)
         {
             m_Profile                = new MAccountProfile();
             trAccount.Visible        = false;
             tabsDerivedRoles.Visible = false;
             derivedRolesTab.Visible  = false;
         }
     }
     HttpContext.Current.Session.Add("EditId", m_Profile.Id);
     populatePage();
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Ons the state of the acquire request.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void onAcquireRequestState(object sender, EventArgs e)
        {
            Logger mLog         = Logger.Instance();
            string mAccountName = AccountUtility.HttpContextUserName();

            mLog.Debug("Started");
            mLog.Debug("CurrentExecutionFilePath " + HttpContext.Current.Request.CurrentExecutionFilePath);
            mLog.Debug("HttpContextUserName: "******"ANONYMOUS")
            {
                string mMessage = "Could not find account '" + mAccountName + "'";
                mLog.Info(mMessage);
                if (ConfigSettings.AutoCreateAccount)
                {
                    mMessage = "Creating new account for '" + mAccountName + "'";
                    mLog.Info(mMessage);
                    AccountUtility.AutoCreateAccount();
                }
            }
            if (mAccountName.ToUpper(CultureInfo.InvariantCulture) != "ANONYMOUS" & (mAccountProfile.LastLogOn.ToShortDateString() != DateTime.Now.ToShortDateString()))
            {
                mAccountProfile.LastLogOn = DateTime.Now;
                AccountUtility.Save(mAccountProfile, false, false);
            }
            if (HttpContext.Current.Session == null)
            {
                mLog.Debug("No Session!");
                mLog.Debug("Ended");
                return;
            }
            if (!processRequest())
            {
                mLog.Debug("Request not for processing!");
                mLog.Debug("Ended");
                return;
            }
            if ((HttpContext.Current.Session["EditId"] != null))
            {
                HttpContext.Current.Items["EditId"] = HttpContext.Current.Session["EditId"];
            }
            MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(mAccountName);

            HttpContext.Current.Items[MClientChoices.SessionName] = mClientChoicesState;
            string mAction = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action");

            if (string.IsNullOrEmpty(mAction))
            {
                mLog.Debug("No Action!");
                mLog.Debug("Ended");
                return;
            }
            MFunctionProfile mFunctionProfile = FunctionUtility.CurrentProfile();

            if (mFunctionProfile == null)
            {
                mFunctionProfile = FunctionUtility.GetProfile(mAction);
            }
            if (!mFunctionProfile.Source.ToUpper(CultureInfo.InvariantCulture).Contains("MENUS") && !(mAction.ToUpper(CultureInfo.InvariantCulture) == "LOGOFF" | mAction.ToUpper(CultureInfo.InvariantCulture) == "LOGON" | mAction.ToUpper(CultureInfo.InvariantCulture) == "CHANGEPASSWORD"))
            {
                FunctionUtility.SetCurrentProfile(mFunctionProfile);
                dynamic mSecurityInfo = new MSecurityInfo(mFunctionProfile, mAccountProfile);
                HttpContext.Current.Items["SecurityInfo"] = mSecurityInfo;
                switch (mAccountProfile.Status)
                {
                case (int)SystemStatus.ChangePassword:
                    mException = new WebSupportException("Your password needs to be changed before any other action can be performed.");
                    GWWebHelper.ExceptionError = mException;
                    mFunctionProfile           = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_ChangePassword", true));
                    string mChangePasswordPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                    HttpContext.Current.Response.Redirect(mChangePasswordPage + "?Action=" + mFunctionProfile.Action);
                    break;

                case (int)SystemStatus.SetAccountDetails:
                    if (HttpContext.Current.Request.Path.ToUpper(CultureInfo.InvariantCulture).IndexOf("/API/", StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        mFunctionProfile = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditAccount", true));
                        if (mAction.ToUpper(CultureInfo.InvariantCulture) != mFunctionProfile.Action.ToUpper(CultureInfo.InvariantCulture))
                        {
                            mException = new WebSupportException("Your account details need to be set.");
                            GWWebHelper.ExceptionError = mException;
                            string mEditAccountPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                            HttpContext.Current.Response.Redirect(mEditAccountPage + "?Action=" + mFunctionProfile.Action);
                        }
                    }
                    break;

                default:
                    string mPage = string.Empty;
                    if (!mSecurityInfo.MayView)
                    {
                        if (mAccountProfile.Account.ToUpper(CultureInfo.InvariantCulture) == "ANONYMOUS")
                        {
                            mException = new WebSupportException("Your session has timed out.<br/>Please sign in.");
                            GWWebHelper.ExceptionError = mException;
                            mFunctionProfile           = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_Logon", true));
                            mPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                            HttpContext.Current.Response.Redirect(mPage + "?Action=" + mFunctionProfile.Action);
                        }
                        mFunctionProfile = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_AccessDenied", true));
                        mLog.Warn("Access was denied to Account: " + mAccountProfile.Account + " for Action: " + mFunctionProfile.Action);
                        mPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                        HttpContext.Current.Response.Redirect(mPage + "?Action=" + mFunctionProfile.Action);
                    }
                    break;
                }
            }
            else
            {
                mLog.Debug("Menu data or Logoff/Logon or ChangePassword requested");
            }
            //processOverridePage(mFunctionProfile);
        }
Ejemplo n.º 16
0
        public IHttpActionResult SaveNameValuePair(UINVPProfile uiProfile)
        {
            string         mRetVal  = false.ToString();
            MNameValuePair mProfile = new MNameValuePair();
            String         mAction  = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action");
            int            mEditId  = int.Parse(HttpContext.Current.Items["EditId"].ToString());
            Logger         mLog     = Logger.Instance();

            if (mEditId != uiProfile.NVP_SEQ_ID)
            {
                Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }

            MAccountProfile        mUpdatingAccount       = AccountUtility.CurrentProfile();
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MSecurityInfo          mSecurityInfo          = new MSecurityInfo(FunctionUtility.GetProfile(mAction), mUpdatingAccount);
            String mGroups        = String.Join(",", uiProfile.Groups);
            String mRoles         = String.Join(",", uiProfile.Roles);
            String mCommaSepRoles = mUpdatingAccount.GetCommaSeparatedAssignedRoles;

            if (uiProfile.NVP_SEQ_ID != -1)
            {
                if (!mSecurityInfo.MayAdd)
                {
                    Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to add");
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }
            else
            {
                if (!mSecurityInfo.MayAdd)
                {
                    Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to edit");
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }
            if (uiProfile.NVP_SEQ_ID != -1)
            {
                mProfile = NameValuePairUtility.GetNameValuePair(uiProfile.NVP_SEQ_ID);
            }
            else
            {
                mProfile.AddedBy   = mUpdatingAccount.Id;
                mProfile.AddedDate = DateTime.Today;
            }

            mProfile.UpdatedBy   = mUpdatingAccount.Id;
            mProfile.UpdatedDate = DateTime.Today;
            mProfile.StaticName  = uiProfile.STATIC_NAME;
            mProfile.SchemaName  = uiProfile.SchemaName;
            mProfile.Display     = uiProfile.Display;
            mProfile.Description = uiProfile.Description;
            mProfile.Status      = uiProfile.Status;
            int mID         = NameValuePairUtility.Save(mProfile);
            int mSecurityId = mSecurityEntityProfile.Id;

            NameValuePairUtility.UpdateRoles(mID, mSecurityId, mRoles, mProfile);
            NameValuePairUtility.UpdateGroups(mID, mSecurityId, mGroups, mProfile);
            return(this.Ok(mRetVal));
        }
Ejemplo n.º 17
0
        //http://osman.it/aspnet/jquery-ajax-file-upload/
        public void ProcessRequest(HttpContext context)
        {
            string mResponse = "Success";

            try
            {
                string            mAction           = GWWebHelper.GetQueryValue(context.Request, "Action");
                string            mCurrentDirectory = GWWebHelper.GetQueryValue(context.Request, "CurrentDirectory");
                MFunctionProfile  mFunctionProfile  = FunctionUtility.GetProfile(mAction);
                MDirectoryProfile mDirectoryInfo    = DirectoryUtility.GetProfileByFunction(mFunctionProfile.Id);
                string            mDirectory        = mDirectoryInfo.Directory;
                if (!string.IsNullOrEmpty(mCurrentDirectory))
                {
                    if (mDirectory.LastIndexOf(Path.DirectorySeparatorChar) != mDirectory.Length)
                    {
                        mDirectory += Path.DirectorySeparatorChar + mCurrentDirectory;
                    }
                }
                string mUploadDirectory = "";
                try
                {
                    mUploadDirectory = context.Request.Files.AllKeys[0].ToString().Substring(0, context.Request.Files.AllKeys[0].LastIndexOf("."));
                }
                catch (Exception)
                {
                    mUploadDirectory = context.Request["fileName"].ToString();
                    mUploadDirectory = mUploadDirectory.Substring(0, mUploadDirectory.LastIndexOf("."));
                    mUploadDirectory = Path.DirectorySeparatorChar + mUploadDirectory;
                }
                if (!Directory.Exists(mUploadDirectory))
                {
                    FileUtility.CreateDirectory(mDirectory, mUploadDirectory, mDirectoryInfo);
                }
                mUploadDirectory = mDirectory + Path.DirectorySeparatorChar + mUploadDirectory;
                if (context.Request["completed"] == null)
                {
                    if (mDirectoryInfo != null)
                    {
                        FileUtility.DoUpload(context.Request.Files.AllKeys[0], context.Request.Files[0], mUploadDirectory, mDirectoryInfo);
                        if (context.Request["single"] != null)
                        {
                            string mFileName = context.Request.Files[0].FileName;
                            string mNewpath  = Path.Combine(mUploadDirectory, mFileName);
                            FileUtility.RenameFile(mNewpath, mDirectory + mFileName, mDirectoryInfo);
                            FileUtility.DeleteDirectory(mUploadDirectory, mDirectoryInfo);
                        }
                    }
                }
                else
                {
                    if (context.Request["completed"].ToString().ToLowerInvariant() == "true")
                    {
                        string mFileName = context.Request["fileName"].ToString();
                        string mPath     = mUploadDirectory;
                        string mNewpath  = Path.Combine(mPath, mFileName);
                        char   mDirectorySeparatorChar = Path.DirectorySeparatorChar;
                        if (mDirectoryInfo != null)
                        {
                            DataTable mFileTable = FileUtility.GetDirectoryTableData(mUploadDirectory, mDirectoryInfo, true);
                            SortTable mSorter    = new Framework.Common.SortTable();
                            String    mColName   = "Name";
                            mSorter.Sort(mFileTable, mColName, "ASC");

                            DataView mFiles = mFileTable.DefaultView;
                            mFiles.RowFilter = "Name like '" + mFileName.Substring(0, mFileName.Length - 4) + "%'";
                            foreach (DataRowView rowView in mFiles)
                            {
                                DataRow row = rowView.Row;
                                string  mPartialFileName = mUploadDirectory + mDirectorySeparatorChar.ToString() + row["Name"].ToString();
                                if (mPartialFileName.EndsWith("_UploadNumber_1"))
                                {
                                    if (File.Exists(mNewpath))
                                    {
                                        File.Delete(mNewpath);
                                    }
                                }
                                if (mPartialFileName != mNewpath)
                                {
                                    mergeFiles(mNewpath, mPartialFileName);
                                }
                            }
                            FileUtility.RenameFile(mNewpath, mDirectory + mFileName, mDirectoryInfo);
                            FileUtility.DeleteDirectory(mUploadDirectory, mDirectoryInfo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger mLog = Logger.Instance();
                mLog.Error(ex);
                mResponse = "Error";
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(mResponse);
        }