示例#1
0
        private void SortGridView(string sortExpression, string direction)
        {
            objPreTool = new ToolBarPresenter(this);

            //Get the Favorites from session
            objUserInfo = (UserInfo)Session["objUserInfo"];
            //objPreTool.getFavorites(objUserInfo.FavList);
            objPreTool.getFavorites();

            DataView dv = new DataView(dtFavorites);
            dv.Sort = sortExpression + " " + direction;

            gvFavorites.DataSource = dv;
            gvFavorites.DataBind();

            DataTable dt = dv.ToTable();

            if (objUserInfo != null)
            {
                objUserInfo.DtFavorites = dt;
                Session["objUserInfo"] = objUserInfo;
            }

            //favorites.Attributes["class"] = "show";
            if (hdnGridImages_Status != null)
            {
                favorites.Attributes.Add("class", hdnGridImages_Status.Value);

            }
        }
示例#2
0
        //Method to fetch the favourites from DB for a particualr user
        protected void getFavorites()
        {
            string strUserName = string.Empty;
            try
            {

                objPreTool = new ToolBarPresenter(this);
                objPreTool.getCultureCode();
                objUserInfo = (UserInfo)Session["objUserInfo"];

                if (objUserInfo != null)
                {
                    objPreTool.getFavorites();

                }
            }
            catch (Exception ex)
            {
                AgriCastException currEx = new AgriCastException(objServicePre.GetServiceDetails(), ex);
                AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
                HttpContext.Current.Session["ErrorMessage"] = objPreTool.getTranslatedText(Constants.FAVORITE_GENERIC_FAILURE, strCulCode) + ex.Message.ToString();
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                objPreTool = new ToolBarPresenter(this);
                objSvcInfo = (ServiceInfo)Session["serviceInfo"];
                objLocInfo = (LocationInfo)Session["objLocationInfo"];
                objSvcPre = new ServicePresenter();
                if (!IsPostBack)
                {

                    //Set the UserName
                    objUserInfo = (UserInfo)Session["objuserinfo"];
                    if (objUserInfo != null)
                    {
                        /*IM01246266 - New Agricast - can't save a favourite - Begin */
                        //userName.InnerText = objUserInfo.UserName;
                        if (!string.IsNullOrEmpty(objUserInfo.UserName))
                        {
                            if (objUserInfo.UserName.IndexOf('^') > -1)
                            {
                                userName.InnerText = objUserInfo.UserName.Substring(objUserInfo.UserName.IndexOf('^') + 1);
                            }
                        }
                        /*IM01246266 - New Agricast - can't save a favourite - End */
                    }

                    objSvcPre = new ServicePresenter(this);

                    string strLink = ConfigurationManager.AppSettings["link"];
                    userName.HRef = strLink;
                    //objSvcPre.createServiceSession("Demo");

                    objPreTool.loadPageSettings();

                    if (!showFavorites)
                    {
                        imgFav.Visible = false;
                    }
                    else
                    {
                        //getFavorites();
                        /*IM01246233 :- New Agricast - missing translation tags - Begin */
                        //add the clientclick event for validation only when Email is enabled

                        Fav_AddToFavorites.Attributes.Add("OnClick", "Javascript:return ValidateFavName(" + "'" + objCommonUtil.getTransText(Constants.FAV_NAME_EMPTY_CHECK) + "'" + ");");
                        /*IM01246233 :- New Agricast - missing translation tags - End */
                    }

                    if (!showPrint)
                        imgPrint.Visible = false;

                    if (!showEmail)
                        imgEmail.Visible = false;
                    /*IM01246233 :- New Agricast - missing translation tags - Begin */
                    else
                    {
                        //add the clientclick event for validation only when Email is enabled
                        EMailPage.Attributes.Add("OnClick", "Javascript:return ValidateEMail(" + "'" + objCommonUtil.getTransText(Constants.EMAIL_ID_EMPTY_CHECK) + "'" + ");");
                    }
                    /*IM01246233 :- New Agricast - missing translation tags - End */

                    if (!showExportExcel)
                        btnExcel.Visible = false;

                    if (!showFeedback)
                        imgFB.Visible = false;

                    LoadCulture();

                    objPreTool.getCultureCode();
                    changeLabelText(strCulCode);

                }

                //Load units if not postback or in case culture has changed.
                if ((!IsPostBack) || ddlCulture.SelectedValue != objSvcInfo.Culture)
                    LoadUnits();

                LoadCustomSettings();

                getFavorites();
                if (!IsPostBack)
                {
                    LoadCaptcha();
                    //set the first value in Dropdown as default unit and add it o session
                    DefaultUnitSettings = dtUnits.Rows[0][0].ToString();
                    if (objSvcInfo.Unit.Trim() != "")
                    {int count=0;
                       for(int i=0; i< dtUnits.Rows.Count; i++)
                       {
                           if(objSvcInfo.Unit.Trim().ToLower().ToString() == dtUnits.Rows[i][0].ToString().ToLower().Trim())
                           {
                               ddlUnits.SelectedIndex = ddlUnits.Items.IndexOf(ddlUnits.Items.FindByValue(objSvcInfo.Unit.Trim()));
                               count++;
                               break;
                           }
                       }
                        if (count==0)
                            objSvcInfo.Unit = DefaultUnitSettings;
                    }
                    else
                        objSvcInfo.Unit = DefaultUnitSettings;

                }
                setEmailValues();

            }
            catch (Exception ex)
            {
                AgriCastException currEx = new AgriCastException(objServicePre.GetServiceDetails(), ex);
                AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
                HttpContext.Current.Session["ErrorMessage"] = objPreTool.getTranslatedText(Constants.TOOLBAR_LOADFAILURE, strCulCode) + ex.Message.ToString();
                return;
            }
        }
示例#4
0
        public void getFavorites()
        {
            try
            {

                ObjUserInfo = (UserInfo)HttpContext.Current.Session["objUserInfo"];

                objITool.dtFavorites = ObjUserInfo.DtFavorites;
                //1objService.getFavorites();//objFavList);

            }
            catch (Exception ex)
            {
                AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex);
                AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
                HttpContext.Current.Session["ErrorMessage"] = getTranslatedText(Constants.FAVORITE_GENERIC_FAILURE, objSvcInfo.Culture) + ex.Message.ToString();
            }
        }
示例#5
0
        public bool AddToFavorites(string strFavName)
        {
            //Update the Dt Favorites Datatable in session
            ObjUserInfo = (UserInfo)HttpContext.Current.Session["objUserInfo"];

            //Location Info object - moved code here  - trans message change
            objLocationinfo = (LocationInfo)HttpContext.Current.Session["objLocationInfo"];

            if (ObjUserInfo != null)
            {
                //Check if the Newly Added Key allreeady Exists in datatable
                //check whether the the Dictionary key exists in Datatable
                var res = from p in ObjUserInfo.DtFavorites.AsEnumerable()
                          where p[Constants.FAV_FAVORITENAME].Equals(strFavName)
                          select p[Constants.FAV_FAVORITENAME];

                //when no matach found
                if (res.ToList().Count == 1)
                {
                    isFavoriteAdded = false;
                    HttpContext.Current.Session["ErrorMessage"] = getTranslatedText(Constants.FAVORITE_UPDATE_DUPLICATE, objLocationinfo.ServiceInfo.Culture) + strFavName + getTranslatedText(Constants.GENERIC_ALREADYEXISTS, objLocationinfo.ServiceInfo.Culture);

                }
                else
                {
                    //Fetch all the Values from Session
                    isFavoriteAdded = true;

                    //Check if the Object is null
                    if (ObjUserInfo != null)
                    {
                        dtTemp = ObjUserInfo.DtFavorites;

                        dr = dtTemp.NewRow();

                        //Take the User Entered Favorite name
                        dr[Constants.FAV_Key] = strFavName.Trim();
                        dr[Constants.FAV_FAVORITENAME] = strFavName.Trim();

                        //Fetch Id from LocationInfo Object
                        if (objLocationinfo != null)
                        {
                            //Fetch the Datapoint Info from Location Info itself
                            objDataPointInfo = objLocationinfo.DataPointInfo;

                            //Fetch the Service Info from Location Info itself
                            objServiceInfo = objLocationinfo.ServiceInfo;

                            dr[Constants.FAV_ALTITUDE] = objDataPointInfo.altitude;//Altitude
                            dr[Constants.FAV_LATITUDE] = objLocationinfo.latitude;//Place - Latitude
                            dr[Constants.FAV_LONGITUDE] = objLocationinfo.longitude;//Place - Longitiude
                            dr[Constants.FAV_PLACENAME] = objLocationinfo.placeName;//PlaceName

                            dr[Constants.FAV_PLACEID] = objLocationinfo.placeID;//Place ID

                            dr[Constants.FAV_SERVICENAME] = objServiceInfo.ServiceName;//ServieName

                            dr[Constants.FAV_MODULENAME] = objServiceInfo.Module;//ModuleName
                        }

                        //add the New Row to DtFavorites
                        dtTemp.Rows.Add(dr);

                        ObjUserInfo.DtFavorites = dtTemp;

                        //Add the Userinfo Back to Sessions
                        HttpContext.Current.Session["ObjUserInfo"] = ObjUserInfo;
                    }
                }
            }
            return isFavoriteAdded;
        }
示例#6
0
        public bool updateFavorite(string strNewFavName, string strFavKey)
        {
            DataTable dtTemp = null;
            DataRow[] drRow = null;
            //Update the Dt Favorites Datatable in session
            ObjUserInfo = (UserInfo)HttpContext.Current.Session["objUserInfo"];

            dtTemp = ObjUserInfo.DtFavorites;

            //First Check if the Favorite with the same name exist in that datatable
            drRow = dtTemp.Select(Constants.FAV_FAVORITENAME + "=" + "'" + strNewFavName + "'");

            // if exists, do not update the dataTable
            if (drRow != null && drRow.Length != 1)
            {
                //Edit the Datatable
                drRow = dtTemp.Select(Constants.FAV_Key + "=" + "'" + strFavKey + "'");

                //Access the Row to be edited
                drRow[0].BeginEdit();

                //Modify the Name
                drRow[0][Constants.FAV_FAVORITENAME] = strNewFavName;

                drRow[0].AcceptChanges();

                ObjUserInfo.DtFavorites = dtTemp;

                HttpContext.Current.Session["objUserInfo"] = ObjUserInfo;

                isFavoriteUpdated = true;
                //objComData.updateFavorite(strNewFavName, intFavId);
            }

            return isFavoriteUpdated;
        }
示例#7
0
        public void DeleteFavorite(string strFavKey)
        {
            DataTable dtTemp = null;

            //Update the Dt Favorites Datatable in session
            ObjUserInfo = (UserInfo)HttpContext.Current.Session["objUserInfo"];

            dtTemp = ObjUserInfo.DtFavorites;

            //Edit the Datatable
            DataRow[] drRow = dtTemp.Select(Constants.FAV_Key + "=" + "'" + strFavKey + "'");

            dtTemp.Rows.Remove(drRow[0]);

            ObjUserInfo.DtFavorites = dtTemp;

            HttpContext.Current.Session["objUserInfo"] = ObjUserInfo;
        }
示例#8
0
        public ArrayList GetServiceDetails()
        {
            if (HttpContext.Current.Session == null || HttpContext.Current.Session["serviceInfo"] == null)
            {

                objServiceInfo = new ServiceInfo();
            }
            else
            {
                objServiceInfo = (ServiceInfo)HttpContext.Current.Session["serviceInfo"];
            }
            if (HttpContext.Current.Session == null || HttpContext.Current.Session["objUserInfo"] == null)
            {

                objUserInfo = new UserInfo();
            }
            else
            {
                objUserInfo = (UserInfo)HttpContext.Current.Session["objUserInfo"];
            }

            ArrayList alError = new ArrayList();
            alError.Add(objServiceInfo.ServiceName);
            alError.Add(objServiceInfo.Module);
            if (objUserInfo != null) alError.Add(objUserInfo.UserName);
            else alError.Add(string.Empty);
            return alError;
        }