Ejemplo n.º 1
0
        public void Run(JobContext context)
        {
            Common = Common ?? new CommonConst();

            LogList.Remove(0, LogList.Length);

            LogFile = context.Properties["BizLog"];

            WriteLog("第三方库存同步Job已启动。", true);

            WriteLog("正在检索本次需要同步库存的数据信息……", true);

            try
            {
                ThirdPartInventoryBPBase bp = new ThirdPartInventoryBP(Common);

                WriteLog(string.Format("本次共检测到{0}条需同步的数据。", bp.Count), true);

                bp.OnRunningBefor += WriteDataLog;
                bp.OnRunningAfter += ModifyLocalQty;
                bp.OnError        += WriteErrorLog;

                bp.Start();
            }
            catch (Exception ex)
            {
                ExceptionHelper.HandleException(ex);
                WriteLog(string.Format("{0} \r\n {1}", ex.Message, ex.StackTrace), true);
            }
            finally
            {
                WriteLog("本次同步结束,Job退出。\r\n\r\n", true);
                EndLog();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 统计商品访问量
 /// </summary>
 /// <param name="pid"></param>
 public static void StatisticProductVisitCount(long pid, long shopId)
 {
     Task.Factory.StartNew(() => {
         lock (_productVisitLocker)
         {
             if (!_productVisitLockerDict.Keys.Contains(pid))
             {
                 _productVisitLockerDict.Add(pid, new object());
             }
         }
         lock (_productVisitLockerDict[pid])
         {
             string key = CommonConst.HIMALL_PRODUCT_VISIT_COUNT(pid.ToString());
             int count  = 1;
             if (Core.Cache.Exists(key))
             {
                 count = (int)Core.Cache.Get(key);
                 count++;
             }
             if (count >= CommonConst.HIMALL_PRODUCT_VISIT_COUNT_MAX)
             {
                 _StatisticsService.AddProductVisit(DateTime.Now.Date, pid, shopId, count);
                 count = 0;
             }
             Core.Cache.Insert(key, count);
         }
     });
 }
Ejemplo n.º 3
0
 public ADOHelper(string dbname, string procedureName)
 {
     Connection             = new SqlConnection(CommonConst.GetConnectionString(dbname));
     Command                = new SqlCommand(procedureName, Connection);
     Command.CommandType    = System.Data.CommandType.StoredProcedure;
     Command.CommandTimeout = Timeout;
 }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ControlProject.CheckSession(this);
            ControlProject.VisibleMenu(true, this);
            Status.Text = "";

            if (!IsPostBack)
            {
                GetData();
            }
            //ADOHelper helper = new ADOHelper("users_get");

            XmlNodeList xnList = CommonConst.GetDataXML("Users");
            DataTable   dt     = CommonConst.ConvertXmlNodeListToDataTable(xnList);

            dt.Columns.Remove("user_password");
            dt.Columns.Remove("user_date_pass");
            gvMessageInfo.DataSource = dt;
            gvMessageInfo.DataBind();
            try
            {
                if (int.Parse(Session["GroupID"].ToString()) > 5)
                {
                    aUsers.Visible  = false;
                    aGroups.Visible = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Session[CommonConst.S_User] == null)
            {
                context.Session[CommonConst.S_User] = CommonConst.GetUserByIP(context.Request.UserHostAddress, context.Application[CommonConst.A_PredefinedUsers]);
            }

            User user = (User)context.Session[CommonConst.S_User];

            //save new message
            if (context.Request.Form.Count > 0)
            {
                var imgData = context.Request.Form[0];

                context.Application[CommonConst.A_Drawing] = imgData;
            }
            else
            {
                var data = context.Application[CommonConst.A_Drawing];

                //var obj = new { Content = data };
                //var serial = JsonConvert.SerializeObject(obj);

                ////context.Response.ContentType = "text/plain";
                //context.Response.Write(serial);

                //context.Response.ContentType = "image/octet-stream";
                context.Response.Write(data);
            }
        }
Ejemplo n.º 6
0
    private void SaveFriendsForMap(JSONArray dataFriends)
    {
        if (FacebookUtils.friendAvatarUrls != "")
        {
            return;
        }

        List <string> avatarUrlList   = new List <string>();
        List <int>    selectedIndexes = new List <int>();

        for (int i = 0; i < CommonConst.MAX_FRIEND_IN_MAP; i++)
        {
            if (selectedIndexes.Count >= dataFriends.Count)
            {
                break;
            }
            int index = 0;
            while (true)
            {
                index = UnityEngine.Random.Range(0, dataFriends.Count - 1);
                if (!selectedIndexes.Contains(index))
                {
                    selectedIndexes.Add(index);
                    break;
                }
            }
            string avatarUrl = dataFriends[index]["picture"]["data"]["url"].Value;
            avatarUrlList.Add(avatarUrl);
        }

        string avatarUrls = CUtils.BuildStringFromCollection(avatarUrlList);

        FacebookUtils.friendAvatarUrls = avatarUrls;

        // levels
        List <int> friendLevels = new List <int>();

        for (int i = 0; i < CommonConst.START_FRIEND_LEVELS.Length; i++)
        {
            friendLevels.Add(CommonConst.START_FRIEND_LEVELS[i]);
        }
        string strFriendLevels = CUtils.BuildStringFromCollection(friendLevels);

        FacebookUtils.friendLevels = strFriendLevels;

        // scores
        for (int i = 0; i < friendLevels.Count; i++)
        {
            List <int> scores = new List <int>();
            for (int level = 1; level < friendLevels[i]; level++)
            {
                int baseScore = CommonConst.GetTargetScore(level);
                int score     = UnityEngine.Random.Range(baseScore, baseScore * 3);
                score = (score / 10) * 10;
                scores.Add(score);
            }
            string strScores = CUtils.BuildStringFromCollection(scores);
            FacebookUtils.SetFriendScores(i, strScores);
        }
    }
Ejemplo n.º 7
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            if (Session[CommonConst.S_User] == null)
            {
                Session[CommonConst.S_User] = CommonConst.GetUserByIP(Request.UserHostAddress, HttpContext.Current.Application[CommonConst.A_PredefinedUsers]);
            }

            User = (User)Session[CommonConst.S_User];
        }
Ejemplo n.º 8
0
 private void Init(CommonConst Common)
 {
     OnRunningBefor = new ThirdPartInventoryRunning(On_RunningBefor);
     //OnRunning = new ThirdPartInventoryRunning(On_Running);
     OnRunningAfter     = new ThirdPartInventoryRunning(On_RunningAfter);
     OnError            = new ThirdPartInventoryRunningError(On_Error);
     ThirdPartInventory = ThirdPartInventoryDA.Query(Common);
     Count       = ThirdPartInventory.Count;
     IsActive    = true;
     this.Common = Common;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 统计店铺访问人数(cookie机制)
        /// 按天统计,一天内计一次
        /// </summary>
        /// <param name="shopId"></param>
        public static void StatisticShopVisitUserCount(long shopId)
        {
            var cookieKey = CommonConst.HIMALL_SHOP_VISIT_COUNT(shopId.ToString());
            var shopVisit = WebHelper.GetCookie(cookieKey);
            var nowTicks  = DateTime.Now.Date.Ticks;

            if (!string.IsNullOrWhiteSpace(shopVisit))
            {
                var  statisticTimestamp = Decrypt(shopVisit);//解密
                long ticks = 0;
                if (!long.TryParse(statisticTimestamp, out ticks))
                {//格式异常
                    return;
                }
                if (ticks >= nowTicks)
                {//有今天的统计cookie,说明已经统计
                    return;
                }
            }
            var nowDate = new DateTime(nowTicks);

            //没有今天的统计cookie,则统计数加1
            Task.Factory.StartNew(() =>
            {
                lock (_shopVisitLocker)
                {
                    if (!_shopVisitLockerDict.Keys.Contains(shopId))
                    {
                        _shopVisitLockerDict.Add(shopId, new object());
                    }
                }
                lock (_shopVisitLockerDict[shopId])
                {
                    string key = CommonConst.HIMALL_SHOP_VISIT_COUNT(shopId.ToString());
                    int count  = 1;
                    if (Core.Cache.Exists(key))
                    {
                        count = (int)Core.Cache.Get(key);
                        count++;
                    }
                    if (count >= CommonConst.HIMALL_SHOP_VISIT_COUNT_MAX)
                    {
                        _StatisticsService.AddShopVisitUser(nowDate, shopId, count);
                        count = 0;
                    }
                    Core.Cache.Insert(key, count);
                }
            });

            //加密
            shopVisit = Encrypt(nowTicks.ToString());
            WebHelper.SetCookie(cookieKey, shopVisit);
        }
Ejemplo n.º 10
0
        private void GetData()
        {
            XmlNodeList xnList = CommonConst.GetDataXML("Groups");
            DataTable   dt     = CommonConst.ConvertXmlNodeListToDataTable(xnList);

            //ADOHelper helper  = new ADOHelper("groups_get");
            //DataTable dt = helper.Execute();
            Session["groups"]       = dt;
            ddlGroup.DataTextField  = "grou_name";
            ddlGroup.DataValueField = "grou_id";
            ddlGroup.DataSource     = dt;
            ddlGroup.DataBind();
        }
Ejemplo n.º 11
0
        public static void InsertQty(InventoryQtyEntity entity)
        {
            CommonConst commonConst = new CommonConst();
            DataCommand command     = DataCommandManager.GetDataCommand("InsertQty");

            command.SetParameterValue("@ProductMappingSysNo", entity.ProductMappingSysNo);
            command.SetParameterValue("@ProductDescription", "");
            command.SetParameterValue("@InventoryQty", entity.InventoryQty);
            command.SetParameterValue("@CompanyCode", commonConst.CompanyCode);
            command.SetParameterValue("@StoreCompanyCode", commonConst.StoreCompanyCode);
            command.SetParameterValue("@InUser", commonConst.UserLoginName);
            command.SetParameterValue("@InventoryAlarmQty", commonConst.InventoryAlarmQty);

            command.ExecuteNonQuery();
        }
Ejemplo n.º 12
0
        public static void InsertStockQty(ProductEntity entity)
        {
            CommonConst commonConst = new CommonConst();
            DataCommand command     = DataCommandManager.GetDataCommand("InsertStockQty");

            command.SetParameterValue("@ProductMappingSysNo", entity.ProductMappingSysNo);
            command.SetParameterValue("@WarehouseNumber", entity.WarehouseNumber);
            command.SetParameterValue("@WarehouseName", "");
            command.SetParameterValue("@InventoryQty", entity.ResultQty);
            command.SetParameterValue("@CompanyCode", commonConst.CompanyCode);
            command.SetParameterValue("@StoreCompanyCode", commonConst.StoreCompanyCode);
            command.SetParameterValue("@InUser", commonConst.UserLoginName);

            command.ExecuteNonQuery();
        }
Ejemplo n.º 13
0
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");

            if (context.Session[CommonConst.S_User] == null)
            {
                context.Session[CommonConst.S_User] = CommonConst.GetUserByIP(context.Request.UserHostAddress, context.Application[CommonConst.A_PredefinedUsers]);
            }

            User user = (User)context.Session[CommonConst.S_User];

            var users = context.Application[CommonConst.A_Users] as IList <User>;

            ////update user online status
            //if (users.Count(o => o.Username == user.Username) == 0)
            //{
            //    users.Add(user);
            //    context.Application[CommonConst.A_Users] = users;
            //}

            //var @where = users.Where(o => o.Username != user.Username);
            var online = users.Where(o => (DateTime.Now - o.LastOnlineTime).TotalSeconds < 5);

            ////set offline time
            //var offline = users.Where(o => online.Count(p => p.IPAddress == o.IPAddress) == 0);
            //foreach (var u in offline)
            //{
            //    u.LastOfflineTime = DateTime.Now;
            //}

            //response
            var arr = from m in online //users//online//@where
                      orderby m.IPAddress ascending
                                       //select new { User = m.FullName //+ " " + m.IPAddress
                                       //    +" "//+ " lastOnline:"
                                       //    + m.LastOnlineTime.ToLongTimeString()
                                       //+ " " + DateTime.Now.ToLongTimeString()
                                       //};
                      select new { User = m.FullName };

            var serial = JsonConvert.SerializeObject(arr);

            //context.Response.ContentType = "text/plain";
            context.Response.Write(serial);
        }
Ejemplo n.º 14
0
        public static List <ThirdPartInventoryEntity> Query(CommonConst Common)
        {
            CustomDataCommand command = DataCommandManager.CreateCustomDataCommandFromConfig("QueryThirdPartInventory");

            //CommonConst commonConst = new CommonConst();
            string sql = command.CommandText;

            sql = sql.Replace("#WarehouseNumber#", Util.Contract(",", Common.WareHourseNumbers));
            sql = sql.Replace("#PartnerType#", "'" + Common.PartnerType + "'");
            sql = sql.Replace("#CompanyCode#", "'" + Common.CompanyCode + "'");

            command.CommandText = sql;

            List <ThirdPartInventoryEntity> list = command.ExecuteEntityList <ThirdPartInventoryEntity>();

            return(list);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 修改分仓库存
        /// </summary>
        /// <param name="list"></param>
        public static void ModifyQty(List <ProductEntity> list)
        {
            CommonConst commonConst = new CommonConst();

            foreach (ProductEntity entity in list)
            {
                if (entity.InventoryAlarmQty.HasValue)
                {
                    DataCommand command = DataCommandManager.GetDataCommand("ModifyStockQty");
                    command.SetParameterValue("@ProductMappingSysNo", entity.ProductMappingSysNo);
                    command.SetParameterValue("@WarehouseNumber", entity.WarehouseNumber);
                    command.SetParameterValue("@InventoryQty", entity.ResultQty);
                    command.SetParameterValue("@CompanyCode", commonConst.CompanyCode);

                    command.ExecuteNonQuery();
                }
                else
                {
                    InsertStockQty(entity);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 修改总仓库存
        /// </summary>
        /// <param name="list"></param>
        public static void ModifyQty(List <InventoryQtyEntity> list)
        {
            CommonConst commonConst = new CommonConst();

            foreach (InventoryQtyEntity entity in list)
            {
                if (entity.InventoryAlarmQty.HasValue)
                {
                    DataCommand command = DataCommandManager.GetDataCommand("ModifyQty");
                    command.SetParameterValue("@ProductSysNo", entity.ProductSysNo);
                    command.SetParameterValue("@InventoryQty", entity.InventoryQty);
                    command.SetParameterValue("@SKU", entity.SKU);
                    command.SetParameterValue("@Type", entity.PartnerType);
                    command.SetParameterValue("@CompanyCode", commonConst.CompanyCode);
                    command.SetParameterValue("@InventoryAlarmQty", entity.InventoryAlarmQty);

                    command.ExecuteNonQuery();
                }
                else
                {
                    InsertQty(entity);
                }
            }
        }
Ejemplo n.º 17
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Session[CommonConst.S_User] == null)
            {
                context.Session[CommonConst.S_User] = CommonConst.GetUserByIP(context.Request.UserHostAddress, context.Application[CommonConst.A_PredefinedUsers]);
            }

            User user = (User)context.Session[CommonConst.S_User];

            //update user online status
            var users = context.Application[CommonConst.A_Users] as IList <User>;

            if (users.Count(o => o.IPAddress == user.IPAddress) == 0)
            {
                user.LastOnlineTime = DateTime.Now;
                users.Add(user);
            }
            else
            {
                var appUser = users.Single(o => o.IPAddress == user.IPAddress);
                appUser.LastOnlineTime = DateTime.Now;
            }
            context.Application[CommonConst.A_Users] = users;


            var messages = context.Application[CommonConst.A_Chat] as IList <Message>;

            var lastID = Convert.ToInt32(context.Request.QueryString["LastID"]);

            //Debug.WriteLine("QueryString:"+context.Request.QueryString["LastID"].ToString()+" "+ user.FullName);

            //save new message
            //if (context.Request.QueryString["Content"] != null)
            bool isPostingForm = false;

            try
            {
                if (context.Request.Form.Count > 0)
                {
                    isPostingForm = true;
                }
            }
            catch (HttpRequestValidationException e)
            {
                isPostingForm = true;
            }

            if (isPostingForm)
            {
                //var str = context.Request.QueryString["Content"];
                var str = context.Request.Form[0];

                var id = messages.Count + 1;
                //var id = (messages.Count == 0 ? 0 : messages.Max(o => o.ID)) + 1;
                //var id = DateTime.Now.Ticks;

                messages.Add(new Message
                {
                    Content = str,
                    Sender  = user,
                    Time    = DateTime.Now,
                    ID      = id,
                    IsPic   = context.Request.QueryString["isPic"] != null,
                    From    = user.FullName,
                    To      = context.Request.QueryString["to"]
                });
            }

            //Debug.WriteLine("save new :" + id);

            //if (lastID > messages.Count()) //服务器重启
            //{
            //}

            //if(messages.Count()>0)
            //    Debug.WriteLine(lastID + " " + messages.Last().ID );


            //response
            //var @where = messages.Where(o => o.ID > lastID);
            var @where = messages.Where(o => o.To == "" || o.From == user.FullName || o.To == user.FullName); //过滤不是自己消息

            @where = lastID > messages.Count ? @where : @where.Where(o => o.ID > lastID);                     //过滤已经收到过的消息

            //string timeMask = "MM/dd HH:mm:ss";
            string timeMask = "HH:mm:ss";

            var arr = from m in @where
                      select new { Content = m.Content, ID = m.ID, User = m.Sender.FullName, Time = m.Time.ToString(timeMask), IsPic = m.IsPic, To = m.To, From = m.From };
            var serial = JsonConvert.SerializeObject(arr);

            //context.Response.ContentType = "text/plain";
            context.Response.Write(serial);
        }
Ejemplo n.º 18
0
        //private void LoadUserTable(string xmlPath)
        //{
        //    //Jak jest DataSet to działa jak nie to nie wypełnia DatasSetu
        //    DataSet1 dataSet = new DataSet1();
        //    XmlDocument doc = new XmlDocument();
        //    doc.Load(xmlPath);
        //    XmlNodeReader reader = new XmlNodeReader(doc);
        //    dataSet.ReadXml(reader);


        //    //XmlDataDocument xmlDatadoc = new XmlDataDocument();
        //    //xmlDatadoc.DataSet.ReadXml(xmlPath);

        //    DataSet1 ds = new DataSet1();
        //    //ds = xmlDatadoc.DataSet1;
        //}

        protected void LoginClick(object sender, EventArgs e)
        {
            //ADOHelper helper = new ADOHelper("users_get");
            //DataTable dt = helper.Execute();


            int         start  = DateTime.Now.Millisecond;
            XmlNodeList xnList = CommonConst.GetDataXML("Users");
            int         end    = DateTime.Now.Millisecond;
            int         supply = end - start;

            foreach (XmlNode xn in xnList)
            {
                string login = xn["user_login"].InnerText;
                string pass  = xn["user_password"].InnerText;
                if (login == tbxLogin.Text)
                {
                    if (Decode.Decrypt(pass, CommonConst.MilaKey) == tbPass.Text)
                    {
                        CreateSession(xn);
                        if (Session["GroupID"].ToString() == "6")
                        {
                            Response.Redirect("~/ClientDashboard.aspx");
                        }
                        if (Session["GroupID"].ToString() == "3")
                        {
                            Response.Redirect("~/WorkerDashboard.aspx");
                        }
                        if (Session["GroupID"].ToString() == "4")
                        {
                            Response.Redirect("~/StoreDashboard.aspx");
                        }
                        else
                        {
                            Response.Redirect("~/About.aspx");
                        }
                        return;
                    }
                    else
                    {
                        FailureText.Text = "Błedne hasło!"; return;
                    }
                }
            }

            //DataSet a = new data

            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    if (dt.Rows[i]["user_login"].ToString() == tbxLogin.Text)
            //    {
            //        if (Decode.Decrypt(dt.Rows[i]["user_password"].ToString(), CommonConst.MilaKey) == tbPass.Text)
            //            {
            //                CreateSession(dt , i);
            //                if (Session["GroupID"].ToString() == "6") Response.Redirect("~/ClientDashboard.aspx");
            //                if (Session["GroupID"].ToString() == "3") Response.Redirect("~/WorkerDashboard.aspx");
            //                if (Session["GroupID"].ToString() == "4") Response.Redirect("~/StoreDashboard.aspx");
            //                else Response.Redirect("~/About.aspx");
            //                return;
            //            }
            //            else { FailureText.Text = "Błedne hasło!"; return; }
            //    }
            //}
            FailureText.Text = "Błedny login lub hasło!";
        }
Ejemplo n.º 19
0
 public ThirdPartInventoryBP(CommonConst Common) : base(Common)
 {
 }
Ejemplo n.º 20
0
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");

            if (context.Session[CommonConst.S_User] == null)
            {
                context.Session[CommonConst.S_User] = CommonConst.GetUserByIP(context.Request.UserHostAddress, context.Application[CommonConst.A_PredefinedUsers]);
            }

            User user = (User)context.Session[CommonConst.S_User];

            //Online Users
            var users = context.Application[CommonConst.A_DrawingUsers] as IList <User>;

            if (users.Count(o => o.IPAddress == user.IPAddress) == 0)
            {
                user.LastOnlineTimeDrawing = DateTime.Now;
                users.Add(user);
            }
            else
            {
                var appUser = users.Single(o => o.IPAddress == user.IPAddress);
                appUser.LastOnlineTimeDrawing = DateTime.Now;
            }
            context.Application[CommonConst.A_DrawingUsers] = users;

            var online = users.Where(o => (DateTime.Now - o.LastOnlineTimeDrawing).TotalSeconds < 5);


            //chat
            var messages = context.Application[CommonConst.A_DrawingChat] as IList <Message>;
            var lastID   = Convert.ToInt32(context.Request.QueryString["LastID"]);
            //save new message
            String strChat = null;
            var    msgID   = 0;

            if (context.Request.QueryString["Content"] != null)
            {
                strChat = context.Request.QueryString["Content"];
                msgID   = messages.Count + 1;
                messages.Add(new Message {
                    Content = strChat, Sender = user, Time = DateTime.Now, ID = msgID
                });
            }
            var    @where   = lastID > messages.Count ? messages : messages.Where(o => o.ID > lastID);
            string timeMask = "HH:mm:ss";
            var    arrChat  = from m in @where
                              select new { Content = m.Content, ID = m.ID, User = m.Sender.FullName, Time = m.Time.ToString(timeMask) };


            //Drawing Controlling
            var draw = context.Application[CommonConst.A_DrawingControl] == null
                ? new Class.Drawing
            {
                Keyword           = "",
                HostUserIPAddress = "",
                Step = 0
            }
                : (Class.Drawing)context.Application[CommonConst.A_DrawingControl];


            switch (draw.Step)
            {
            case 0:
                if (online.Count() > 1)
                {
                    NewGame(online, draw);
                }
                else if (String.IsNullOrEmpty(draw.TipStep))
                {
                    draw.TipStep = "等待其他玩家进入。。。";
                    //draw.TipStep += "<br/>暫くお待ちください。。。";
                }
                break;

            case 1:
                if (online.Count() <= 1)
                {
                    draw.Step    = 0;
                    draw.EndTime = DateTime.Now;
                    //draw.TipEndReason = "人数不足,游戏中断。";
                    draw.TipStep = "人数不足,游戏中断。等待其他玩家进入。。。";
                    //draw.TipStep += "<br/>ゲームが中断しました。暫くお待ちください。。。";
                }
                else if (online.Count(o => o.IPAddress == draw.HostUserIPAddress) == 0 && online.Count() > 1)
                {
                    draw.Step    = 2;
                    draw.EndTime = DateTime.Now;
                    //draw.TipEndReason = "作画者离开了游戏。";
                    draw.TipStep = "作画者离开了游戏。10秒后开始新游戏。。。";
                    //draw.TipStep += "<br/>作画者が離れました。10秒後新しいゲームを開始。。。";
                }
                else if ((DateTime.Now - draw.BeginTime).TotalSeconds <= 60)
                {
                    draw.TipStep = "游戏进行中。。。剩余时间 " + (60 - Math.Round((DateTime.Now - draw.BeginTime).TotalSeconds)) + " 秒{0}";
                    //draw.TipStep += "<br/>ゲーム進行中。。。残り時間 " + (60 - Math.Round((DateTime.Now - draw.BeginTime).TotalSeconds)) + " 秒{1}";

                    //是否回答正确
                    if (user.IPAddress != draw.HostUserIPAddress && draw.CorrectUsers.Count(o => o == user.IPAddress) == 0)
                    {
                        if (strChat == draw.Keyword)
                        {
                            draw.CorrectUsers.Add(user.IPAddress);

                            //如果超过两个人 答对问题不要显示答案
                            if (online.Count() > 2)
                            {
                                messages.Last().Content = "**** (正解!)";
                            }
                            else
                            {
                                messages.Last().Content = messages.Last().Content + " (正解!)";
                            }
                        }
                    }

                    //除了作画者以外的人 全部答对就结束游戏
                    if (online.Count(o => o.IPAddress != draw.HostUserIPAddress && draw.CorrectUsers.Count(p => p == o.IPAddress) == 0) == 0)
                    {
                        draw.Step    = 2;
                        draw.EndTime = DateTime.Now;
                        //draw.TipEndReason = "时间到。";
                        draw.TipStep = "游戏结束。答案是 " + draw.Keyword + " 。10秒后开始新游戏。。。";
                        //draw.TipStep += "ゲーム終了。回答は " + draw.Keyword + " です。10秒後新しいゲームを開始。。。";
                    }

                    if (user.IPAddress == draw.HostUserIPAddress)
                    {
                        draw.TipStep = draw.TipStep.Replace("{0}", "   你要画的是:" + draw.Keyword);
                        //draw.TipStep = draw.TipStep.Replace("{1}", "   これを描いてください:" + draw.Keyword);
                    }
                    else
                    {
                        //二级提示
                        if ((DateTime.Now - draw.BeginTime).TotalSeconds > 45)
                        {
                            if (draw.idx == -1)
                            {
                                var random = new Random();
                                draw.idx = random.Next(0, draw.Keyword.Length);
                            }
                            string result = "";
                            for (var i = 0; i < draw.Keyword.Length; i++)
                            {
                                result += "※";
                            }
                            result = result.Substring(0, draw.idx) + draw.Keyword[draw.idx] + result.Substring(draw.idx + 1);

                            draw.TipStep = draw.TipStep.Replace("{0}", "   提示:" + result);
                            //draw.TipStep = draw.TipStep.Replace("{1}", "   ヒント:" + result);
                        }
                        //一级提示
                        else if ((DateTime.Now - draw.BeginTime).TotalSeconds > 10)
                        {
                            draw.TipStep = draw.TipStep.Replace("{0}", "   提示:" + draw.Keyword.Length + "个字");
                            //draw.TipStep = draw.TipStep.Replace("{1}", "   ヒント:" + draw.Keyword.Length + "個文字");
                        }
                        else
                        {
                            draw.TipStep = draw.TipStep.Replace("{0}", "");
                            //draw.TipStep = draw.TipStep.Replace("{1}", "");
                        }
                    }
                }
                else
                {
                    draw.Step    = 2;
                    draw.EndTime = DateTime.Now;
                    //draw.TipEndReason = "时间到。";
                    draw.TipStep = "游戏结束。答案是 " + draw.Keyword + " 。10秒后开始新游戏。。。";
                    //draw.TipStep += "<br/>ゲーム終了。回答は " + draw.Keyword + " です。10秒後新しいゲームを開始。。。";

                    //id = messages.Count + 1;
                    //messages.Add(new Message { Content = "", Sender = new User { FullName="系统"}, Time = DateTime.Now, ID = id });
                }
                break;

            case 2:
                if ((DateTime.Now - draw.EndTime).TotalSeconds < 10)
                {
                    draw.TipStep = "游戏结束。答案是 " + draw.Keyword + " 。" + (10 - Math.Round((DateTime.Now - draw.EndTime).TotalSeconds)) + "秒后开始新游戏。。。";
                    //draw.TipStep += "<br/>ゲーム終了。回答は " + draw.Keyword + " です。" + (10 - Math.Round((DateTime.Now - draw.EndTime).TotalSeconds)) + "秒後新しいゲームを開始。。。";
                }
                else if (online.Count() <= 1)
                {
                    draw.Step    = 0;
                    draw.EndTime = DateTime.Now;
                    //draw.TipEndReason = "人数不足。";
                    draw.TipStep = "人数不足。等待其他玩家进入。。。";
                    //draw.TipStep += "<br/>人数不足。暫くお待ちください。。。";
                }
                else
                {
                    NewGame(online, draw);
                }
                break;

            default:
                break;
            }

            if (draw.HostUserIPAddress == "" || online.Count(o => o.IPAddress == draw.HostUserIPAddress) == 0)
            {
            }

            context.Application[CommonConst.A_DrawingControl] = draw;

            //output
            var arr = from m in online
                      orderby m.IPAddress ascending
                      select new
            {
                User = m.FullName,
                Tip  = draw.Step == 1         //游戏中
                                    ? (m.IPAddress == draw.HostUserIPAddress
                                        ? "(作画中。。。)"
                                        : (draw.CorrectUsers.Count(o => o == m.IPAddress) > 0
                                            ? "(正解!)"
                                            : "(回答中。。。)"))
                                    : (draw.Step == 2//游戏结束后
                                        ? (m.IPAddress == draw.HostUserIPAddress
                                            ? "(作画者)"
                                            : (draw.CorrectUsers.Count(o => o == m.IPAddress) > 0
                                            ? "(正解!)"
                                            : "(残念。。。)"))
                                        : ""),
                IP = m.IPAddress          //+m.LastOnlineTime+m.LastOnlineTimeDrawing
            };

            var serial = JsonConvert.SerializeObject(new
            {
                Users   = arr,
                Chat    = arrChat,
                isDraw  = draw.HostUserIPAddress == user.IPAddress,
                isGuess = draw.HostUserIPAddress != user.IPAddress,
                Step    = draw.Step,
                Tip     = //draw.TipEndReason +
                          draw.TipStep,
                Keyword = draw.Keyword
            });

            //context.Response.ContentType = "text/plain";
            context.Response.Write(serial);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 修改本地第三方库存
        /// </summary>
        /// <param name="InventoryQty">分仓的库存增量</param>
        /// <param name="SynInventoryQty">总仓的增量</param>
        /// <param name="ProductMappingSysno"></param>
        public static void Modify(int InventoryQty, int SynInventoryQty, int ProductMappingSysno, CommonConst Common)
        {
            DataCommand command = DataCommandManager.GetDataCommand("ModifyThirdPartInventory");

            //CommonConst commonConst = new CommonConst();
            command.SetParameterValue("@InventoryQty", InventoryQty);
            command.SetParameterValue("@SynInventoryQty", SynInventoryQty);
            command.SetParameterValue("@ProductMappingSysno", ProductMappingSysno);
            command.SetParameterValue("@EditUser", Common.UserLoginName);
            command.SetParameterValue("@CompanyCode", Common.CompanyCode);
            command.ExecuteNonQuery();
        }
Ejemplo n.º 22
0
 public ThirdPartInventoryBPBase(CommonConst Common)
 {
     Init(Common);
 }
Ejemplo n.º 23
0
        internal static string BuilderSql(CustomDataCommand command, QueryConditionEntity <QueryProduct> query)
        {
            CommonConst commonConst = new CommonConst();

            string sql      = command.CommandText;
            bool   hasWhere = false;

            using (DynamicQuerySqlBuilder builder = new DynamicQuerySqlBuilder(
                       sql, command, query.PagingInfo, "its.StockSysNo"))
            {
                QueryProduct condition = query.Condition;
                if (!string.IsNullOrEmpty(condition.CompanyCode))
                {
                    builder.AddCondition(QueryConditionRelationType.AND,
                                         "ppm.CompanyCode",
                                         DbType.String,
                                         "@CompanyCode",
                                         QueryConditionOperatorType.Equal,
                                         condition.CompanyCode
                                         );
                    hasWhere = true;
                }
                if (!string.IsNullOrEmpty(condition.PartnerType))
                {
                    builder.AddCondition(QueryConditionRelationType.AND,
                                         "ppm.PartnerType",
                                         DbType.String,
                                         "@PartnerType",
                                         QueryConditionOperatorType.Equal,
                                         condition.PartnerType
                                         );
                    hasWhere = true;
                }
                if (condition.ProductID != null && condition.ProductID.Length > 0)
                {
                    string productIds = Util.Contract("','", condition.ProductID);
                    productIds = "'" + productIds + "'";
                    builder.AddCondition(QueryConditionRelationType.AND,
                                         "ppm.ProductID",
                                         DbType.String,
                                         "@ProductID",
                                         QueryConditionOperatorType.In,
                                         productIds
                                         );
                    hasWhere = true;
                }
                if (condition.ProductSysNo != null && condition.ProductSysNo.Length > 0)
                {
                    string productSysNos = Util.Contract("','", condition.ProductSysNo);
                    productSysNos = "'" + productSysNos + "'";
                    builder.AddCondition(QueryConditionRelationType.AND,
                                         "ppm.ProductSysNo",
                                         DbType.String,
                                         "@ProductSysNo",
                                         QueryConditionOperatorType.In,
                                         productSysNos
                                         );
                    hasWhere = true;
                }
                if (condition.SysProductID != null && condition.SysProductID.Length > 0)
                {
                    string sysProductIds = Util.Contract("','", condition.SysProductID);
                    sysProductIds = "'" + sysProductIds + "'";
                    builder.AddCondition(QueryConditionRelationType.AND,
                                         "ppm.SysProductID",
                                         DbType.String,
                                         "@SysProductID",
                                         QueryConditionOperatorType.In,
                                         sysProductIds
                                         );
                    hasWhere = true;
                }
                if (condition.WareHourseNumber != null && condition.WareHourseNumber.Length > 0)
                {
                    string wareHourseNumbers = Util.Contract(",", condition.WareHourseNumber);

                    builder.ConditionConstructor.AddSubQueryCondition(QueryConditionRelationType.AND,
                                                                      "its.StockSysNo",
                                                                      QueryConditionOperatorType.In,
                                                                      wareHourseNumbers
                                                                      );
                    hasWhere = true;
                }

                //状态筛选
                builder.AddCondition(QueryConditionRelationType.AND,
                                     "ppm.Status",
                                     DbType.String,
                                     "@Status",
                                     QueryConditionOperatorType.Equal,
                                     'A'
                                     );
                hasWhere = true;

                sql = builder.BuildQuerySql();

                //有库存变化的才进行数据捞取
                string where = "(isnull(its.AvailableQty,0)+ isnull(its.ConsignQty,0)+isnull(its.VirtualQty,0)) <> isnull(ppsi.InventoryQty,0)";

                sql = sql.Replace("@Where@", string.Format("{0}{1}", hasWhere ? " AND " : " ", where));
            }

            return(sql);
        }
Ejemplo n.º 24
0
        public void Run(JobContext context)
        {
            LogList.Clear();

            LogFile = context.Properties["BizLog"];

            WriteLog("第三方库存同步Job已启动。\r\n");

            WriteLog("正在检索本次需要同步库存的数据信息……");

            SynInventoryQtyBase synBP = new SynInventoryQtyBP();

            synBP.OnRunningAfter += new SynInventoryQtyRunning(ModifyLocalInventoryQty);

            //库存发生变化的商品
            List <ProductEntity> productList = GetProductEntityList();

            //需要同步库存的商品库存信息
            List <InventoryQtyEntity> inventoryQtyEntityList = GetInventoryEntity(productList);

            WriteLog(string.Format("本次共检测到{0}条需同步的数据", inventoryQtyEntityList.Count));

            CommonConst commonConst = new CommonConst();

            int batchNum = commonConst.BatchNumber;

            int pageSize = inventoryQtyEntityList.Count <= 0 ? 0 : (inventoryQtyEntityList.Count <= batchNum ? 1 : (inventoryQtyEntityList.Count % batchNum == 0 ? inventoryQtyEntityList.Count / batchNum : inventoryQtyEntityList.Count / batchNum + 1));

            WriteLog("开始第三方库存同步,请稍后……");

            for (int i = 0; i < pageSize; i++)
            {
                List <InventoryQtyEntity> list = inventoryQtyEntityList.Skip(i * batchNum).Take(batchNum).ToList();
                List <ProductEntity>      productEntityListResult = FindProductListByInventoryQtyEntity(productList, list);
                WriteLog(string.Format("正在同步第{0}批数据,本批共{1}条数据", i + 1, list.Count));
                try
                {
                    synBP.SynInventoryQty(productEntityListResult, list);
                    WriteLog("本批次第三方库存同步结束,同步结果:成功");
                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (ProductEntity p in productEntityListResult)
                    {
                        sb.AppendFormat("ProductSysNo:({0})_SKU:({1})_ResultQty:({2})_WarehouseNumber:({3})\r\n", new object[] {
                            p.ProductSysNo,
                            p.SKU,
                            p.ResultQty,
                            p.WarehouseNumber
                        });
                    }
                    WriteLog(string.Format("同步出错商品信息:库存预警({0})\r\n{1}", commonConst.InventoryAlarmQty, sb.ToString()));

                    WriteLog(string.Format("{0}\r\n{1}", ex.Message, ex.StackTrace));
                    //break;
                }
            }

            WriteLog("同步库存完成,Job结束。\r\n\r\n\r\n");

            EndLog();
        }
Ejemplo n.º 25
0
        public static void Insert(int InventoryQty, int SynInventoryQty, int ProductMappingSysno, CommonConst Common)
        {
            DataCommand command = DataCommandManager.GetDataCommand("InsertThirdPartInventory");

            //CommonConst commonConst = new CommonConst();
            command.SetParameterValue("@ProductMappingSysno", ProductMappingSysno);
            command.SetParameterValue("@WarehouseNumber", Common.ThirdPartWareHourseNumber);
            command.SetParameterValue("@WarehouseName", Common.ThirdPartWareHourseName);
            command.SetParameterValue("@InventoryQty", InventoryQty);
            command.SetParameterValue("@ProductDescription", "");
            command.SetParameterValue("@SynInventoryQty", SynInventoryQty);
            command.SetParameterValue("@PurchasePrice", 0);
            command.SetParameterValue("@CompanyCode", Common.CompanyCode);
            command.SetParameterValue("@StoreCompanyCode", Common.StoreCompanyCode);
            command.SetParameterValue("@InUser", Common.UserLoginName);
            command.SetParameterValue("@InventoryAlarmQty", Common.InventoryAlarmQty);
            command.ExecuteNonQuery();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 统计商品访问人数(cookie机制)
        /// </summary>
        /// <param name="pid"></param>
        public static void StatisticProductVisitUserCount(long pid, long shopId)
        {
            var cookieKey   = CommonConst.HIMALL_PRODUCT_VISIT_COUNT_COOKIE;
            var cookieValue = WebHelper.GetCookie(cookieKey);
            var nowTicks    = DateTime.Now.Date.Ticks;

            if (!string.IsNullOrWhiteSpace(cookieValue))
            {
                cookieValue = Decrypt(cookieValue); //解密 格式:"时间|商品ID,商品ID,"
                string[] strArray = cookieValue.Split('|');
                if (strArray.Length < 2)            //格式异常
                {
                    return;
                }
                var  statisticTimestamp = strArray[0];//时间戳
                long ticks = 0;
                if (!long.TryParse(statisticTimestamp, out ticks))
                {//格式异常,为非法数据
                    return;
                }
                if (ticks > nowTicks)
                {//时间戳比当前的大,为非法数据
                    return;
                }
                if (ticks == nowTicks)
                {     //时间戳为当天,看是否浏览过些商品
                    if (strArray[1].Contains(pid.ToString() + ","))
                    { //当天已浏览过,不统计
                        return;
                    }
                    cookieValue = cookieValue + pid.ToString() + ",";
                }
                else //没有当天cookie,直接组装数据
                {
                    cookieValue = nowTicks.ToString() + "|" + pid.ToString() + ",";
                }
            }
            else
            {
                cookieValue = nowTicks.ToString() + "|" + pid.ToString() + ",";
            }
            var nowDate = new DateTime(nowTicks);

            //没有今天的统计cookie,则统计数加1
            Task.Factory.StartNew(() =>
            {
                lock (_productVisitLocker)
                {
                    if (!_productVisitLockerDict.Keys.Contains(pid))
                    {
                        _productVisitLockerDict.Add(pid, new object());
                    }
                }
                lock (_productVisitLockerDict[pid])
                {
                    string key = CommonConst.HIMALL_PRODUCT_VISITUSER_COUNT(pid.ToString());
                    int count  = 1;
                    if (Core.Cache.Exists(key))
                    {
                        count = (int)Core.Cache.Get(key);
                        count++;
                    }
                    if (count >= CommonConst.HIMALL_PRODUCT_VISITUSER_COUNT_MAX)
                    {
                        _StatisticsService.AddProductVisitUser(nowDate, pid, shopId, count);
                        count = 0;
                    }
                    Core.Cache.Insert(key, count);
                }
            });

            //加密
            cookieValue = Encrypt(cookieValue);
            WebHelper.SetCookie(cookieKey, cookieValue);
        }