public void AddMYFvrt(MyFavourite myFvrt)
 {
     try
     {
         DatabaseHelper.Insert <MyFavourite>(myFvrt);
     }
     catch (Exception ex) { throw new Exception(ex.Message, ex); }
 }
Beispiel #2
0
        public void Execute(object sender)
        {
            if (Interlocked.Exchange(ref _IsRunning, 1) == 0)
            {
                try
                {
                    string starTime = DateTime.Now.ToString("HH:mm:ss");

                    //LogEvent.logSuccess(string.Format("Refresh Cache Start - {0}", DateTime.Now.ToString("HH:mm:ss")), 1);

                    ContainerEload.Cache.RefreshCache();
                    //LogEvent.logSuccess("ContainerEload Refresh Cache Success", 1);

                    ContainerMain.Cache.RefreshCache();
                    //LogEvent.logSuccess("ContainerMain Refresh Cache Success", 1);

                    ContainerPlan.Cache.RefreshCache();
                    //LogEvent.logSuccess("ContainerPlan Refresh Cache Success", 1);

                    ContainerDetail.Cache.RefreshCache();
                    //LogEvent.logSuccess("ContainerDetail Refresh Cache Success", 1);

                    Notice.Cache.RefreshCache();
                    //LogEvent.logSuccess("Notice Refresh Cache Success", 1);

                    OTruck.Cache.RefreshCache();
                    //LogEvent.logSuccess("Truck Refresh Cache Success", 1);


                    TVDangerPlan.Cache.RefreshCache();
                    //LogEvent.logSuccess("TVDangerPlan Refresh Cache Success", 1);

                    TVDangerContainer.Cache.RefreshCache();
                    //LogEvent.logSuccess("TVDangerContainer Refresh Cache Success", 1);

                    OVesselPlan.Cache.RefreshCache();
                    //LogEvent.logSuccess("VesselPlan Refresh Cache Success", 1);

                    PortOfCall.Cache.RefreshCache();
                    //LogEvent.logSuccess("PortOfCall Refresh Cache Success", 1);

                    MyFavourite.ReloadAll("database");

                    //LogEvent.logSuccess("Favourite Refresh Cache Success", 1);

                    LogEvent.logSuccess(string.Format("Refresh Cache Start-{0}\r\n Refresh Cache End - {1}", starTime, DateTime.Now.ToString("HH:mm:ss")), 1);
                }
                catch (Exception ex)
                {
                    LogEvent.logErro(ex, 1);
                }
                finally
                {
                    Interlocked.Exchange(ref _IsRunning, 0);
                }
            }
        }
Beispiel #3
0
        protected void lvMyfvrt_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteMyfvrt")
            {
                try
                {
                    lblMyfabourite.Text = string.Empty;

                    int MyfabouriteID = Convert.ToInt32(e.CommandArgument);
                    hdmyfvrt.Value = MyfabouriteID.ToString();
                    using (MyFavouriteRT receiverTransfer = new MyFavouriteRT())
                    {
                        receiverTransfer.DeleteMyfabourite(MyfabouriteID);
                        lblMyfabourite.Text      = "Data successfully deleted...";
                        lblMyfabourite.ForeColor = System.Drawing.Color.Green;
                    }
                }
                catch (Exception ex)
                {
                    lblMyfabourite.Text      = "Error : " + ex.Message;
                    lblMyfabourite.ForeColor = System.Drawing.Color.Red;
                }
            }

            else if (e.CommandName == "EditMyfvrt")
            {
                try
                {
                    using (AdGiverRT receiverTransfer = new AdGiverRT())
                    {
                        lblMyfabourite.Text = string.Empty;
                        string  userEmailId    = Convert.ToString(Session["UserName"]);
                        AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);

                        using (MyFavouriteRT receiverTransferMyfvrt = new MyFavouriteRT())
                        {
                            //int MaterialID = Convert.ToInt32(Request.QueryString["ID"]);
                            List <MyFavourite> EmailIDfrmMyfvrt = receiverTransferMyfvrt.GetEmailIDfrmMyfvrt(userEmailId);

                            if (adgiverEmailId.EmailID != null && EmailIDfrmMyfvrt != null && EmailIDfrmMyfvrt.Count > 0)
                            {
                                int         UrlID = Convert.ToInt32(e.CommandArgument);
                                MyFavourite url   = receiverTransferMyfvrt.GetUrlFrmMyfvrt(UrlID);
                                Response.Redirect("DetailPage?option=" + StringCipher.Encrypt(url.MaterialID.ToString()));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    lblMyfabourite.Text      = "Error : " + ex.Message;
                    lblMyfabourite.ForeColor = System.Drawing.Color.Red;
                }
            }
        }
Beispiel #4
0
        public MyFavourite AddMyFavourite(int memID, string favname)
        {
            MyFavourite mFav = new MyFavourite();

            mFav.MemberID        = memID;
            mFav.MyFavouriteName = favname;
            int         returnedID = mContext.AddFavouriteGroup(memID, favname);
            MyFavourite returnFav  = mContext.GetSingleMyFavourite(memID, returnedID);

            return(returnFav);
        }
        protected void btnFvrt_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["UserName"] == null)
                {
                    Response.Redirect("~/LoginPage");
                }
                else
                {
                    using (AdGiverRT receiverTransfer = new AdGiverRT())
                    {
                        string  userEmailId    = Convert.ToString(Session["UserName"]);
                        AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);

                        if (adgiverEmailId != null)
                        {
                            using (MyFavouriteRT receiverTransferMyfvrt = new MyFavouriteRT())
                            {
                                int         MaterialID         = Convert.ToInt32(Session["detailID"]);
                                MyFavourite EmailIDnMaterialID = receiverTransferMyfvrt.GetEmailIDnMaterialID(userEmailId, MaterialID);
                                MyFavourite myFvrt             = CreatemyFavrt();
                                if (EmailIDnMaterialID == null)
                                {
                                    receiverTransferMyfvrt.AddMYFvrt(myFvrt);

                                    lblFvrt.Text      = "You Add your Favourite Item Successfully...";
                                    lblFvrt.ForeColor = System.Drawing.Color.DarkSlateBlue;
                                }
                                else
                                {
                                    lblFvrt.Text      = "This Item is already added to your Favourite...";
                                    lblFvrt.ForeColor = System.Drawing.Color.Red;
                                }
                            }
                        }
                        else
                        {
                            lblFvrt.Text      = "Data not Added...";
                            lblFvrt.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblFvrt.Text      = "Error : " + ex.Message;
                lblFvrt.ForeColor = System.Drawing.Color.Red;
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Favorite(Guid id)
        {
            var CurrentUser    = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var FavoritesCount = _context.MyFavourite.Where(favorite => favorite.UserId == CurrentUser && favorite.VehicleId == id).Count();

            if (FavoritesCount == 0)
            {
                MyFavourite favorite = new MyFavourite();
                favorite.Id        = Guid.NewGuid();
                favorite.UserId    = CurrentUser;
                favorite.VehicleId = id;
                _context.MyFavourite.Add(favorite);
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(Index)));
        }
        private MyFavourite CreatemyFavrt()
        {
            MyFavourite MyFvrt = new MyFavourite();

            try
            {
                MyFvrt.MaterialID  = Convert.ToInt32(Session["detailID"]);
                MyFvrt.UserLoginID = Convert.ToString(Session["UserName"]);
                MyFvrt.CreatedDate = DateTime.Now;
                MyFvrt.ReturnURL   = Convert.ToString(Session["backMaterialURL"]);
            }
            catch (Exception ex)
            {
                lblFvrt.Text      = "Error : " + ex.Message;
                lblFvrt.ForeColor = System.Drawing.Color.Red;
            }
            return(MyFvrt);
        }
Beispiel #8
0
        public void Execute(object sender)
        {
            if (Interlocked.Exchange(ref _IsRunning, 1) == 0)
            {
                try
                {
                    MyFavourite.ReloadAll("database");

                    LogEvent.logSuccess("Favourite Refresh Cache Success");
                }
                catch (Exception ex)
                {
                    LogEvent.logErro(ex);
                }
                finally
                {
                    Interlocked.Exchange(ref _IsRunning, 0);
                }
            }
        }
Beispiel #9
0
        protected void rptrFavourite_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                string _strVP_Info = string.Empty;

                MyFavourite fav = e.Item.DataItem as MyFavourite;

                Literal ltrlFavourite = e.Item.FindControl("ltrlFavourites") as Literal;

                string _update = string.Empty;
                if (fav.STATUS == 1)
                {
                    _update = "<span class=\"ui-li-count\">New</span>";
                }

                switch (fav.OBJECTTYPE.ToUpper())
                {
                case "CONTAINERPLAN":
                    string _tmpltrlContainerPlan = "<li style=\"cursor: pointer\" onclick=\"window.location.href=\'{0}\'\"><h3>{1}</h3><p>申请/实际进港时间:{2}</p><p> 进港结束时间:{3} </p>{4}</li>";

                    ContainerPlan cp = ContainerPlan.Cache.Load(fav.OBJECTID);

                    if (cp != null)
                    {
                        string _planTime = "";

                        if (!string.IsNullOrEmpty(cp.PlanTime.ToString()))
                        {
                            _planTime = cp.PlanTime.ToString();
                            _planTime = _planTime.Substring(0, _planTime.Length - 3);
                        }

                        string _planAcceptedTime = "";

                        if (!string.IsNullOrEmpty(cp.PlanAcceptedTime.ToString()))
                        {
                            _planAcceptedTime = cp.PlanAcceptedTime.ToString();
                            _planAcceptedTime = _planAcceptedTime.Substring(0, _planAcceptedTime.Length - 3);
                        }

                        ltrlFavourite.Text = string.Format(_tmpltrlContainerPlan, fav.URL, cp.ID, _planTime, _planAcceptedTime, _update);
                    }
                    else
                    {
                        ltrlFavourite.Visible = false;
                    }

                    break;

                case "CONTAINERMAIN":
                    string _tmpltrlContainerMain = "<li style=\"cursor: pointer\" onclick=\"window.location.href=\'{0}\'\"><h3>{1}</h3><p>进港时间:{2} </p>{3}</li>";

                    ContainerMain c = new ContainerMain();
                    c.ID = fav.OBJECTID;
                    c.Select();

                    if (c != null)
                    {
                        string _arriveContainerTime = "";

                        if (!string.IsNullOrEmpty(c.ArrivalContainerTime.ToString()))
                        {
                            _arriveContainerTime = c.ArrivalContainerTime.ToString();
                            _arriveContainerTime = _arriveContainerTime.Substring(0, _arriveContainerTime.Length - 3);
                        }

                        ltrlFavourite.Text = string.Format(_tmpltrlContainerMain, fav.URL, c.ContainerNo, _arriveContainerTime, _update);
                    }
                    else
                    {
                        ltrlFavourite.Visible = false;
                    }
                    break;

                case "CONTAINERDETAIL":
                    string _tmpltrlContainerDetail = "<li style=\"cursor: pointer\" onclick=\"window.location.href=\'{0}\'\"><h3>{1}</h3><p>进场:{2} | 出场:{3} </p> <p>入场方式:{4} | 出场方式:{5}</p>{6}</li>";

                    ContainerMain cm = new ContainerMain();
                    cm.ID = fav.OBJECTID;
                    cm.Select();

                    if (cm != null)
                    {
                        string _arriveTime = "";

                        if (!string.IsNullOrEmpty(cm.ArriveTime.ToString()))
                        {
                            _arriveTime = cm.ArriveTime.ToString();
                            _arriveTime = _arriveTime.Substring(0, _arriveTime.Length - 3);
                        }

                        string _departureTime = "";

                        if (!string.IsNullOrEmpty(cm.DepartureTime.ToString()))
                        {
                            _departureTime = cm.DepartureTime.ToString();
                            _departureTime = _departureTime.Substring(0, _departureTime.Length - 3);
                        }

                        ltrlFavourite.Text = string.Format(_tmpltrlContainerDetail, fav.URL, cm.ContainerNo, _arriveTime, _departureTime, cm.ArriveType.ToString(), cm.DepartureType.ToString(), _update);
                    }
                    else
                    {
                        ltrlFavourite.Visible = false;
                    }
                    break;

                case "CONTAINERELOAD":
                    string _tmpltrlContainerEload = "<li style=\"cursor: pointer\" onclick=\"window.location.href=\'{0}\'\"><h3>{1}</h3><p>船名:{2} | 航次:{3} </p><p> 进港时间: {4}</p>{5}</li>";

                    ContainerEload ce = new ContainerEload();
                    ce.ID = fav.OBJECTID;
                    ce.Select();

                    if (ce != null)
                    {
                        string _sendPackingListTime = "";

                        if (!string.IsNullOrEmpty(ce.SendPackingListTime.ToString()))
                        {
                            _sendPackingListTime = ce.SendPackingListTime.ToString();
                            _sendPackingListTime = _sendPackingListTime.Substring(0, _sendPackingListTime.Length - 3);
                        }

                        ltrlFavourite.Text = string.Format(_tmpltrlContainerEload, fav.URL, ce.ContainerNo, ce.VesselName, ce.VoyageNumber, _sendPackingListTime, _update);
                    }
                    else
                    {
                        ltrlFavourite.Visible = false;
                    }
                    break;

                case "TRUCK":
                    string _tmpltrlOTruck = "<li style=\"cursor: pointer\" onclick=\"window.location.href=\'{0}\'\"><h3>{1}</h3><p>进堆场时间:{2} </p><p> 出堆场时间:{3} </p>{4}</li>";

                    OTruck t = OTruck.Cache.Load(fav.OBJECTID);

                    if (t != null)
                    {
                        string _arriveYardTime = "";

                        if (!string.IsNullOrEmpty(t.ArriveYardTime.ToString()))
                        {
                            _arriveYardTime = t.ArriveYardTime.ToString();
                            _arriveYardTime = _arriveYardTime.Substring(0, _arriveYardTime.Length - 3);
                        }
                        string _departureYardTime = "";

                        if (!string.IsNullOrEmpty(t.DepartureYardTime.ToString()))
                        {
                            _departureYardTime = t.DepartureYardTime.ToString();
                            _departureYardTime = _departureYardTime.Substring(0, _departureYardTime.Length - 3);
                        }

                        ltrlFavourite.Text = string.Format(_tmpltrlOTruck, fav.URL, t.TruckNo, _arriveYardTime, _departureYardTime, _update);
                    }
                    else
                    {
                        ltrlFavourite.Visible = false;
                    }
                    break;

                case "VESSELPLAN":

                    string _tmpltrlVesselPlan = "<li style=\"cursor: pointer\" onclick=\"window.location.href=\'{0}\'\"><h3>{1}({2})</h3><p>航次:{3} | 进/出口:{4} | 范围:{5}</p>{6}</li>";

                    OVesselPlan vp = OVesselPlan.Cache.Load(fav.OBJECTID);

                    if (vp != null)
                    {
                        ltrlFavourite.Text = string.Format(_tmpltrlVesselPlan, fav.URL, vp.VesselName, vp.VesselEnglishName, vp.VoyageNumber, vp.ImportOrExportFlag.Equals("E", StringComparison.OrdinalIgnoreCase) ? "出口" : "进口", vp.VesselPlanStatus, _update);
                    }
                    else
                    {
                        ltrlFavourite.Visible = false;
                    }
                    break;

                case "TVDANGERPLAN":
                    string _tmpltrlTVDangerPlan = "<li style=\"cursor: pointer\" onclick=\"window.location.href=\'{0}\'\"><h3>{1}</h3><p>船名/航次:{2}</p><p> 直装时间:{3} </p>{4}</li>";

                    TVDangerPlan tv = TVDangerPlan.Cache.Load(fav.OBJECTID);

                    if (tv != null)
                    {
                        string _TVDate = "";

                        if (!string.IsNullOrEmpty(tv.TVDATE.ToString()))
                        {
                            _TVDate = tv.TVDATE.ToString();
                            _TVDate = _TVDate.Substring(0, _TVDate.Length - 3);
                        }



                        ltrlFavourite.Text = string.Format(_tmpltrlTVDangerPlan, fav.URL, tv.ID, tv.VESSELVOYAGE, tv.TVDATE, _update);
                    }
                    else
                    {
                        ltrlFavourite.Visible = false;
                    }

                    break;

                default:

                    break;
                }
            }
        }
Beispiel #10
0
        public void ProcessRequest(HttpContext context)
        {
            string responseText = string.Empty;

            try
            {
                string _url      = string.Empty;
                string _username = string.Empty;

                if (!string.IsNullOrEmpty(context.Request.QueryString["PageUrl"]))
                {
                    _url = context.Request.QueryString["PageUrl"];
                }

                if (context.Request.Cookies["uid"] != null)
                {
                    _username = context.Request.Cookies["uid"].Values.ToString();
                }

                if (!string.IsNullOrEmpty(context.Request.QueryString["Method"]))
                {
                    if (context.Request.QueryString["Method"].Equals("get"))
                    {
                        #region Check Favourite Code
                        MyFavourite mf = MyFavourite.Cache.FavouriteList_Active.Find(f =>
                                                                                     f.USERNAME.Equals(_username, StringComparison.OrdinalIgnoreCase) && f.URL.Equals(_url, StringComparison.OrdinalIgnoreCase));

                        if (mf != null)
                        {
                            mf.STATUS = 0;
                            mf.Update();

                            MyFavourite.Cache.RefreshCache();

                            responseText = Boolean.TrueString;
                        }
                        else
                        {
                            responseText = Boolean.FalseString;
                        }
                        #endregion
                    }
                    else if (context.Request.QueryString["Method"].Equals("dele"))
                    {
                        if (!string.IsNullOrEmpty(_username))
                        {
                            #region Remove Favourite Code
                            MyFavourite mf = MyFavourite.Cache.FavouriteList_Active.Find(f =>
                                                                                         f.USERNAME.Equals(_username, StringComparison.OrdinalIgnoreCase) && f.URL.Equals(_url, StringComparison.OrdinalIgnoreCase));

                            if (mf != null)
                            {
                                mf.ISACTIVE = 0;
                                mf.Update();

                                MyFavourite.Cache.RefreshCache();

                                responseText = "success";
                            }
                            else
                            {
                                throw new Exception("收藏夹中未找到对应关注项");
                            }
                            #endregion
                        }
                        else
                        {
                            throw new Exception("nologin");
                        }
                    }
                    else if (context.Request.QueryString["Method"].Equals("post"))
                    {
                        if (!string.IsNullOrEmpty(_username))
                        {
                            #region Add Favourtie Code
                            string _objectID = string.Empty;
                            if (!string.IsNullOrEmpty(context.Request.QueryString["ObjectID"]))
                            {
                                _objectID = context.Request.QueryString["ObjectID"];
                            }

                            string _objectType = string.Empty;
                            if (!string.IsNullOrEmpty(context.Request.QueryString["ObjectType"]))
                            {
                                _objectType = context.Request.QueryString["ObjectType"];
                            }


                            if (MyFavourite.Cache.FavouriteList_Active.Exists(f =>
                                                                              f.USERNAME.Equals(_username, StringComparison.OrdinalIgnoreCase) && f.URL.Equals(_url, StringComparison.OrdinalIgnoreCase) &&
                                                                              f.OBJECTID.Equals(_objectID, StringComparison.OrdinalIgnoreCase) && f.OBJECTTYPE.Equals(_objectType, StringComparison.OrdinalIgnoreCase)))
                            {
                                throw new Exception("收藏夹中已有相同关注项");
                            }

                            MyFavourite fav = new MyFavourite();

                            fav.ID         = "";
                            fav.URL        = _url;
                            fav.USERNAME   = _username;
                            fav.UPDATETIME = DateTime.Now;
                            fav.CREATETIME = DateTime.Now;
                            fav.STATUS     = 0;
                            fav.OBJECTID   = _objectID;
                            fav.OBJECTTYPE = _objectType;

                            JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                            string _objectContent = "";

                            switch (_objectType)
                            {
                            case "ContainerEload":
                                ContainerEload listContainerEload = ContainerEload.Cache.Load(_objectID);
                                _objectContent = jsonSerializer.Serialize(listContainerEload);
                                break;

                            case "ContainerMain":
                            case "ContainerDetail":
                                ContainerMain listContainerMain = ContainerMain.Cache.Load(_objectID);
                                _objectContent = jsonSerializer.Serialize(listContainerMain);
                                break;

                            case "ContainerPlan":
                                ContainerPlan listContainerPlan = ContainerPlan.Cache.Load(_objectID);
                                _objectContent = jsonSerializer.Serialize(listContainerPlan);
                                break;

                            case "Truck":
                                OTruck listOTruck = OTruck.Cache.Load(_objectID);
                                _objectContent = jsonSerializer.Serialize(listOTruck);
                                break;

                            case "VesselPlan":
                                OVesselPlan listOVesselPlan = OVesselPlan.Cache.Load(_objectID);
                                _objectContent = jsonSerializer.Serialize(listOVesselPlan);
                                break;

                            case "TVDangerPlan":
                                TVDangerPlan listTVDangerPlan = TVDangerPlan.Cache.Load(_objectID);
                                _objectContent = jsonSerializer.Serialize(listTVDangerPlan);
                                break;

                            default:
                                break;
                            }

                            fav.OBJECTCONTENT = _objectContent;
                            fav.ISACTIVE      = 1;
                            fav.REMARK        = string.Empty;

                            fav.Insert();

                            MyFavourite.Cache.RefreshCache();

                            responseText = "success";

                            #endregion
                        }
                        else
                        {
                            throw new Exception("nologin");
                        }
                    }
                    else if (context.Request.QueryString["Method"].Equals("refresh"))
                    {
                        if (!string.IsNullOrEmpty(_username))
                        {
                            MyFavourite.RefreshByUser(_username, "cache");

                            responseText = "success";
                        }
                        else
                        {
                            throw new Exception("nologin");
                        }
                    }
                }
                else
                {
                    throw new Exception("传参错误,请重试");
                }
            }
            catch (Exception ex)
            {
                responseText = ex.Message;
            }

            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(responseText);
            context.Response.End();
        }
Beispiel #11
0
        public MyFavourite GetMyFavourite(int memID, int favID)
        {
            MyFavourite nFav = mContext.GetSingleMyFavourite(memID, favID);

            return(nFav);
        }