Exemple #1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="relateKey"></param>
        /// <returns></returns>
        protected virtual bool SaveKey(string key, string relateKey)
        {
            var info = new KeyEntity
            {
                SaveType = SaveType.Add,
                Name     = key,
                Ip       = System.Web.HttpContext.Current.Request.UserHostAddress,
                Source   = "B2C"
            };

            Ioc.Resolve <IApplicationService, KeyEntity>()
            .Save(info);
            if (string.IsNullOrEmpty(relateKey) || key == relateKey)
            {
                return(true);
            }
            Ioc.Resolve <IApplicationService, RelateKeyEntity>()
            .Save(new RelateKeyEntity
            {
                SaveType = SaveType.Add,
                KeyName  = key,
                Name     = relateKey,
                Ip       = System.Web.HttpContext.Current.Request.UserHostAddress,
                Source   = "B2C"
            });
            return(true);
        }
Exemple #2
0
        public ulong Delete(string key, ulong latestCommitedVersionShouldBe, string transactionId)
        {
            // TODO: merge this with Set using KeyEntity class
            var entities = GetKeyVersionsGreaterThanOrEqual(key, latestCommitedVersionShouldBe);

            if (entities.Count() == 1)
            {
                if (entities.Last().Tombstoned)
                {
                    throw new ArgumentException("Key does not exist");
                }

                var nextVersion = entities.Last().Version + 1;
                var kv          = new KeyEntity(key, nextVersion, null)
                {
                    Tombstoned         = true,
                    CreatorTransaction = transactionId
                };

                return(SetKeyWithVersionToValue(kv));
            }
            else
            {
                // TODO: remove this exception. use azure storage concurrency.
                throw new ArgumentException("Key does not exist");
            }
        }
        /// <summary>
        /// 执行事件。
        /// </summary>
        /// <param name="args">参数数组。</param>
        /// <returns>执行是否成功。</returns>
        /// <remarks>
        /// <para>孙涛</para>
        /// <para>2015/8/17</para>
        /// </remarks>
        public virtual bool Execute(object[] args)
        {
            try
            {
                int arg   = (args == null || args.Length == 0) ? 100 : Convert.ToInt32(args[0]);
                int count = arg > 0 ? arg : 100;
                EnsureOpenQueue();
                var infos = new List <KeyEntity>();

                KeyEntity info = null;
                while ((info = QueueRepository.Pop <KeyEntity>(QueueName)) != null)
                {
                    infos.Add(info);
                    if (infos.Count > count)
                    {
                        break;
                    }
                }

                var unitofworks = DomainService.Handle <KeyEntity>(infos);
                return(Commit(unitofworks));
            }
            catch
            {
                return(false);
            }
        }
Exemple #4
0
    public override void Interact(EscapeGame game)
    {
        if (string.IsNullOrEmpty(m_KeyIdentifier))
        {
            Open(game);
            return;
        }
        KeyEntity key = game.TakenEntity as KeyEntity;

        if (key != null)
        {
            if (key.Identifier == m_KeyIdentifier)
            {
                Open(game);
            }
            else
            {
                Debug.Log(string.Format("This item cannot be opened by the key <color=white>{0}</color>", key.Name));
            }
        }
        else
        {
            Debug.Log("You need a key to open it.");
        }
    }
Exemple #5
0
        private void DoThreadTask()
        {
            KeyEntity keyEntity = keyList.Dequeue();

            apiClient = new Common.APIClient(keyEntity.AppKey, keyEntity.SecretKey);
            GoChildGategory(0, 0);
            msg("执行完毕");
        }
Exemple #6
0
        private ulong SetKeyWithVersionToValue(KeyEntity keyValue)
        {
            TableOperation opr = TableOperation.Insert(keyValue);

            var tableResult = table.Execute(opr);

            return((tableResult.Result as KeyEntity).Version);
        }
        private void HookKeyboardEngine_KeyDown(object sender, KeyEventArgs e)
        {
            KeyEntity k = new KeyEntity();

            k.Key  = e.KeyCode;
            k.Time = DateTime.Now;
            _current.AddDown(k);
        }
Exemple #8
0
        public static long GetNextKeyValueLong(String keyID)
        {
            KeyDAO    keyDAO    = new KeyDAO();
            KeyEntity keyEntity = null;

            cache.TryGetValue(keyID, out keyEntity);
            long keyValue = 0;

            if (keyEntity == null)
            {//双重检查防止并发
                lock (myLock)
                {
                    cache.TryGetValue(keyID, out keyEntity);
                    if (keyEntity == null)
                    {
                        keyEntity = keyDAO.Load(keyID);
                        if (keyEntity == null)
                        {
                            keyEntity = new KeyEntity
                            {
                                Steps     = defaultKeyCount,
                                Key_id    = keyID,
                                Max_value = defaultKeyCount,
                                LastValue = 0
                            };
                            keyDAO.Insert(keyEntity);
                        }
                        else
                        {
                            keyDAO.UpdateMaxValue(keyID, keyEntity.Steps);
                            keyEntity.LastValue  = keyEntity.Max_value;
                            keyEntity.Max_value += keyEntity.Steps;
                        }
                        cache[keyID] = keyEntity;
                    }
                }
            }

            lock (keyEntity)
            {
                keyValue = keyEntity.GetNextValue();
                if (keyValue == 0)
                {
                    //缓存里的值已经用完,再次申请
                    keyDAO.UpdateMaxValue(keyID, keyEntity.Steps);
                    keyEntity.LastValue  = keyEntity.Max_value;
                    keyEntity.Max_value += keyEntity.Steps;
                }
            }

            return(keyValue);
        }
Exemple #9
0
        public virtual void LoadLines(string[] lines)
        {
            int i = 0, imax = lines.Length, k = 0;

            m_KeyEntities = new KeyEntity[imax];
            for (; i < imax; ++i)
            {
                if (string.IsNullOrEmpty(lines[i]) || lines[i].StartsWith(";"))
                {
                    continue;
                }
                m_KeyEntities[k++] = new KeyEntity(this, lines[i].Split(SPLIT_CSV));
            }
        }
        private void btn_image_shotcut_Click(object sender, RoutedEventArgs e)
        {
            ShortCutEntitys shortcut = new ShortCutEntitys();

            KeyEntity keyEntity = new KeyEntity();

            keyEntity.Key = System.Windows.Forms.Keys.D;
            shortcut.Add(keyEntity);

            keyEntity     = new KeyEntity();
            keyEntity.Key = System.Windows.Forms.Keys.D;
            shortcut.Add(keyEntity);

            this.image.GetImgOperate().RegisterPartShotCut(shortcut);
        }
        private void HookKeyboardEngine_KeyUp(object sender, KeyEventArgs e)
        {
            KeyEntity k = new KeyEntity();

            k.Key  = e.KeyCode;
            k.Time = DateTime.Now;
            _current.RemoveDown(k);
            _current.Add(k);

            foreach (var item in _collection)
            {
                // Todo :匹配规则触发任务
                if (_current.Equals(item.Item1))
                {
                    item.Item2.Invoke();
                }
            }
        }
Exemple #12
0
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = _vm;


            // Todo :双击大小写切换
            ShortCutEntitys s = new ShortCutEntitys();

            KeyEntity k = new KeyEntity();

            k.Key = Keys.LShiftKey;
            s.Add(k);

            KeyEntity c = new KeyEntity();

            c.Key = Keys.LShiftKey;
            s.Add(c);

            ShortCutHookService.Instance.RegisterCommand(s, RefreshVisible);
        }
Exemple #13
0
        private void DoAttributeTask()
        {
            //循环类目 获取对应的属性
            KeyEntity keyEntity = keyList.Dequeue();

            apiClient = new Common.APIClient(keyEntity.AppKey, keyEntity.SecretKey);
            //GoChildGategory(0, 0);
            //msg("执行完毕");

            while (true)
            {
                List <CategoryInfoEntity> list = DAL.CategoryInfoDAL.GetList_9();
                if (list == null || list.Count <= 0)
                {
                    break;
                }
                foreach (CategoryInfoEntity item in list)
                {
                    GoAttribute(item.categoryID);
                    DAL.CategoryInfoDAL.Modify_Process(item.ID);
                }
            }
            msg("执行完毕");
        }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Action <ShortCutEntity> action = l =>
            {
                Debug.WriteLine(l);

                this.tb_output.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " - 注册事件被触发 : " + l.ToString() + Environment.NewLine + this.tb_output.Text;
            };

            {
                ShortCutEntity shortcut = new ShortCutEntity();

                KeyEntity keyEntity = new KeyEntity();
                keyEntity.Key = Keys.D;
                shortcut.Add(keyEntity);

                keyEntity     = new KeyEntity();
                keyEntity.Key = Keys.D;
                shortcut.Add(keyEntity);

                ShortCutService.Instance.RegisterCommand(shortcut, action);

                this.tb.Text += "注册快捷键: " + shortcut.ToString() + Environment.NewLine;
            }


            {
                // Todo :双击大小写切换
                ShortCutEntity shortcut = new ShortCutEntity();

                shortcut = new ShortCutEntity();

                KeyEntity up = new KeyEntity();
                up.Key = Keys.Up;
                shortcut.Add(up);

                ShortCutService.Instance.RegisterCommand(shortcut, action);

                this.tb.Text += "注册快捷键: " + shortcut.ToString() + Environment.NewLine;
            }


            {
                ShortCutEntity shortcut = new ShortCutEntity();

                KeyEntity down = new KeyEntity();
                down.Key = Keys.Down;
                shortcut.Add(down);

                ShortCutService.Instance.RegisterCommand(shortcut, action);

                this.tb.Text += "注册快捷键: " + shortcut.ToString() + Environment.NewLine;
            }


            {
                // Todo :双击Ctrl键
                ShortCutEntity shortcut = new ShortCutEntity();

                KeyEntity c1 = new KeyEntity();
                c1.Key = Keys.LControlKey;
                shortcut.Add(c1);

                KeyEntity c2 = new KeyEntity();
                c2.Key = Keys.LControlKey;
                shortcut.Add(c2);

                ShortCutService.Instance.RegisterCommand(shortcut, action);

                this.tb.Text += "注册快捷键: " + shortcut.ToString() + Environment.NewLine;
            }

            {
                // Todo :双击Ctrl键
                ShortCutEntity shortcut = new ShortCutEntity();

                KeyEntity c1 = new KeyEntity();
                c1.Key = Keys.LShiftKey;
                shortcut.AddDown(c1);

                KeyEntity c2 = new KeyEntity();
                c2.Key = Keys.S;
                shortcut.Add(c2);

                ShortCutService.Instance.RegisterCommand(shortcut, action);

                this.tb.Text += "注册快捷键: " + shortcut.ToString() + Environment.NewLine;
            }
        }
 /// <summary>
 /// 添加搜索关键词记录。
 /// </summary>
 /// <param name="KeyEntity">搜索关键词信息。</param>
 /// <remarks>
 /// <para>孙涛</para>
 /// <para>2015/8/17</para>
 /// </remarks>
 public virtual void Add(KeyEntity keyEntity)
 {
     EnsureOpenQueue();
     QueueRepository.Push <KeyEntity>(QueueName, keyEntity);
 }
Exemple #16
0
 /// <summary>
 /// 设置词存储类型
 /// </summary>
 /// <param name="words"></param>
 /// <param name="info"></param>
 protected virtual void SetWordSaveType(Dictionary <string, WordEntity> words, KeyEntity info)
 {
     if (words.ContainsKey(info.Name))
     {
         var word = words[info.Name];
         if (word.Count == long.MaxValue)
         {
             return;
         }
         word.Count++;
         word.SaveType = SaveType.Modify;
         word.SetProperty(it => it.Count);
     }
     else
     {
         var word = new WordEntity
         {
             Name     = info.Name,
             Pinyin   = GetPinyin(info.Name),
             Count    = 1,
             IsForbid = false,
             SaveType = SaveType.Add
         };
         words.Add(info.Name, word);
     }
 }
Exemple #17
0
        /// <summary>
        /// 执行下级分类
        /// </summary>
        private void GoChildGategory(long pid, int level)
        {
            try
            {
                ApiResult entity = apiClient.GetCategoryID(pid);
                Thread.Sleep(300);
                if (entity == null)
                {
                    KeyEntity keyEntity = keyList.Dequeue();
                    apiClient = new Common.APIClient(keyEntity.AppKey, keyEntity.SecretKey);
                    entity    = apiClient.GetCategoryID(pid);
                }
                CategoryInfoEntity categoryInfo_1688 = entity.categoryInfo[0];
                if (categoryInfo_1688 != null)
                {
                    if (categoryInfo_1688.categoryID > 0)
                    {
                        long parentID = categoryInfo_1688.parentIDs[0];
                        #region 保存到数据库

                        SqlParameter[] pramsWhere =
                        {
                            DALUtil.MakeInParam("@categoryID", SqlDbType.Int, 4, categoryInfo_1688.categoryID)
                        };
                        CategoryInfoEntity categoryEntity = DAL.CategoryInfoDAL.Get1("categoryID", pramsWhere);
                        if (categoryEntity != null && categoryEntity.categoryID > 0)
                        {
                            DAL.CategoryInfoDAL.Modify(categoryInfo_1688.categoryID, categoryInfo_1688.name, parentID, level, categoryInfo_1688.isLeaf);
                            msg("存在===" + categoryInfo_1688.name + "->【" + level + "级】" + categoryInfo_1688.name);
                        }
                        else
                        {
                            DAL.CategoryInfoDAL.Add(categoryInfo_1688.categoryID, categoryInfo_1688.name, parentID, level, categoryInfo_1688.isLeaf);
                            msg("已添加===" + "->【" + level + "级】" + categoryInfo_1688.name);
                        }
                        #endregion
                    }

                    //执行子级查询
                    ChildCategorysEntity[] childCategorys = categoryInfo_1688.childCategorys;
                    if (childCategorys != null && childCategorys.Length > 0)
                    {
                        if (childCategorys != null && childCategorys.Length > 0)
                        {
                            foreach (ChildCategorysEntity item in childCategorys)
                            {
                                GoChildGategory(item.id, level + 1);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                KeyEntity keyEntity = keyList.Dequeue();
                if (keyEntity != null)
                {
                    apiClient = new Common.APIClient(keyEntity.AppKey, keyEntity.SecretKey);
                    GoChildGategory(pid, level);
                }
                else
                {
                    msg("-----------没有可用账号");
                }
            }
        }
Exemple #18
0
        public virtual void OnClick(KeyEntity key)
        {
            bool isEvent = false, isUpdateKeys = false;

            switch (key.cmd)
            {
            //
            case KeyCommand.Text:
                AppendText(key.Text);
                if (isShift)
                {
                    isShift      = false;
                    isUpdateKeys = true;
                }
                break;

            //
            case KeyCommand.Backspace:
                m_KeyEvent.keyCode = KeyCode.Backspace;
                isEvent            = true;
                break;

            case KeyCommand.Delete:
                m_KeyEvent.keyCode = KeyCode.Delete;
                isEvent            = true;
                break;

            case KeyCommand.Enter:
                m_KeyEvent.keyCode = KeyCode.Return;
                isEvent            = true;
                break;

            //
            case KeyCommand.CapsLock:
                isCapsLock   = !isCapsLock;
                isEvent      = false;
                isUpdateKeys = true;
                break;

            case KeyCommand.Shift:
                isShift      = !isShift;
                isEvent      = true;
                isUpdateKeys = true;
                break;

            case KeyCommand.GotoPage:
                SetPage(int.Parse(key.shift));
                break;
            }
            if (isEvent)
            {
                if (m_InputField != null)
                {
                    m_InputField.Select();
                    m_InputField.ProcessEvent(m_KeyEvent);
                    //if(m_KeyEvent.keyCode==KeyCode.Return) {
                    //	gameObject.SetActive(false);
                    //	m_InputField.OnDeselect(null);
                    //}
                }
            }
            if (isUpdateKeys)
            {
                int i = m_KeyEntities.Length;
                while (i-- > 0)
                {
                    if (m_KeyEntities[i] != null)
                    {
                        m_KeyEntities[i].UpdateText();
                    }
                }
            }
        }
Exemple #19
0
        private void GoAttribute(long categoryID)
        {
            try
            {
                ApiResult attributeInfo = apiClient.GetAttributeInfo(categoryID);
                Thread.Sleep(200);
                if (attributeInfo != null)
                {
                    #region 属性

                    AttributeInfoEntity[] attributes = attributeInfo.attributes;

                    if (attributes.Length > 0)
                    {
                        int index = 0;
                        foreach (AttributeInfoEntity item in attributes)
                        {
                            //try
                            //{
                            index++;

                            #region 类目下的属性

                            string units = string.Empty;
                            if (item.units != null && item.units.Length > 0)
                            {
                                units = string.Join(",", item.units);
                            }

                            AttributeInfoEntity attrEntity = DAL.AttributeInfoDAL.Get_98(item.attrID, "attrID");
                            if (attrEntity != null && attrEntity.attrID > 0)
                            {
                                //int row_Mod = DAL.AttributeInfoDAL.Modify(categoryID, item.attrID, item.name, Convert.ToInt32(item.required), units, item.inputType, item.parentAttrID, item.parentAttrValueID, item.aspect, Convert.ToInt32(item.isSKUAttribute));
                                //msg("******修改属性" + item.name);
                            }
                            else
                            {
                                int row_Add = DAL.AttributeInfoDAL.Add(categoryID, item.attrID, item.name, Convert.ToInt32(item.required), units, item.inputType, item.parentAttrID, item.parentAttrValueID, item.aspect, Convert.ToInt32(item.isSKUAttribute));
                                msg("******属性-增加" + item.name);
                            }
                            #endregion

                            #region 类目与属性关联中间表
                            int count = Category_Attr_RelatedDAL.GetSingle("count(0)", "  categoryID={0} AND attrID={1} ", categoryID, item.attrID);
                            if (count == 0)
                            {
                                Category_Attr_RelatedDAL.Add(categoryID, item.attrID);
                                msg("******关联-增加====" + item.name);
                            }
                            #endregion

                            #region 增加类目属性对应的 选项
                            AttributeValueInfoEntity[] attrValueList = item.attrValues;
                            if (attrValueList.Length > 0)
                            {
                                foreach (AttributeValueInfoEntity itemValue in attrValueList)
                                {
                                    AttributeValueInfoEntity attrValueEntity = DAL.AttributeValueInfoDAL.Get_98(itemValue.attrValueID, "attrValueID");
                                    if (attrValueEntity != null && attrValueEntity.attrValueID > 0)
                                    {
                                        //int row_Mod2 = DAL.AttributeValueInfoDAL.Modify(itemValue.attrValueID, itemValue.name, itemValue.enName, Convert.ToInt32(itemValue.isSKU));
                                        //msg("#####修改选项:" + itemValue.name);
                                    }
                                    else
                                    {
                                        int row_Add2 = DAL.AttributeValueInfoDAL.Add(itemValue.attrValueID, itemValue.name, itemValue.enName, Convert.ToInt32(itemValue.isSKU));
                                        msg("#####选项-增加:" + itemValue.name);
                                    }
                                }
                            }
                            #endregion


                            //}
                            //catch (Exception ex)
                            //{

                            //}
                        }
                    }

                    #endregion

                    #region 属性子级关联
                    PostLevelAttrRelEntity[] levelAttrRelList = attributeInfo.levelAttrRelList;
                    if (levelAttrRelList != null && levelAttrRelList.Length > 0)
                    {
                        foreach (PostLevelAttrRelEntity itemAttrRel in levelAttrRelList)
                        {
                            if (itemAttrRel.subFids != null && itemAttrRel.subFids.Length > 0)
                            {
                                foreach (int subID in itemAttrRel.subFids)
                                {
                                    int count = PostLevelAttrRelDAL.GetSingle("count(0)", "  fid={0} AND subID={1} ", itemAttrRel.fid, subID);
                                    if (count == 0)
                                    {
                                        PostLevelAttrRelDAL.Add(itemAttrRel.fid, subID, itemAttrRel.attrType);
                                        msg("******属性子级关联-增加====" + itemAttrRel.fid);
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                }
            }
            catch (Exception)
            {
                KeyEntity keyEntity = keyList.Dequeue();
                if (keyEntity != null)
                {
                    apiClient = new Common.APIClient(keyEntity.AppKey, keyEntity.SecretKey);
                    GoAttribute(categoryID);
                }
                else
                {
                    msg("-----------没有可用账号");
                }
            }
        }
Exemple #20
0
        private IEnumerable <KeyEntity> GetKeyVersionsGreaterThanOrEqual(string key, ulong minVersion)
        {
            var partitionMatchFilter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, key);
            var rowKeyFilter         = TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, keyPrefix + KeyEntity.FormatVersionToString(minVersion));
            var rowKeyFilterEnd      = TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThan, keyPrefixEnd);
            var filter = TableQuery.CombineFilters(partitionMatchFilter, TableOperators.And, rowKeyFilter);

            filter = TableQuery.CombineFilters(filter, TableOperators.And, rowKeyFilterEnd);
            var q = new TableQuery <KeyEntity>().Where(filter);

            var entities = table.ExecuteQuery <KeyEntity>(q);

            return(entities);
        }
Exemple #21
0
        /// <summary> 此方法的说明 </summary>
        public void RegisterApi()
        {
            // Todo :双击大小写切换
            ShortCutEntitys s = new ShortCutEntitys();

            KeyEntity k = new KeyEntity();

            k.Key = Keys.Capital;
            s.Add(k);

            KeyEntity c = new KeyEntity();

            c.Key = Keys.Capital;
            s.Add(c);

            ShortCutHookService.Instance.RegisterCommand(s, RefreshVisible);


            // Todo :双击Ctrl键
            ShortCutEntitys d = new ShortCutEntitys();

            KeyEntity c1 = new KeyEntity();

            c1.Key = Keys.LControlKey;
            d.Add(c1);

            KeyEntity c2 = new KeyEntity();

            c2.Key = Keys.LControlKey;
            d.Add(c2);

            Action action = () =>
            {
                // HTodo  :双击ctrl 模拟delete按键
                KeyHelper.OnKeyPress((byte)Keys.Delete);
            };

            ShortCutHookService.Instance.RegisterCommand(d, action);


            // Todo :复制当前时间
            ShortCutEntitys tt = new ShortCutEntitys();

            KeyEntity t1 = new KeyEntity();

            t1.Key = Keys.E;
            tt.Add(t1);

            KeyEntity t2 = new KeyEntity();

            t2.Key = Keys.D;
            tt.Add(t2);

            Action actiont = () =>
            {
                // Todo :复制当前时间格式
                System.Windows.Clipboard.SetText(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
            };

            ShortCutHookService.Instance.RegisterCommand(tt, actiont);

            ShortCutEntitys ed = new ShortCutEntitys();

            KeyEntity e = new KeyEntity();

            e.Key = Keys.E;
            ed.Add(e);

            KeyEntity dd = new KeyEntity();

            dd.Key = Keys.D;
            ed.Add(dd);

            ShortCutHookService.Instance.RegisterCommand(ed, actiont);
        }