Ejemplo n.º 1
0
        public FormCollection GetFormForOrderEdit(IObjectFacade order,
                                                  SalesOrderHeader soh,
                                                  string modifiedDate,
                                                  out IDictionary <string, string> idToRawValue)
        {
            var nakedObjectSpecification = order.Specification;
            var assocS  = nakedObjectSpecification.Properties.Single(p => p.Id == "Status");
            var assocSC = nakedObjectSpecification.Properties.Single(p => p.Id == "StoreContact");
            var assocBA = nakedObjectSpecification.Properties.Single(p => p.Id == "BillingAddress");
            var assocPO = nakedObjectSpecification.Properties.Single(p => p.Id == "PurchaseOrderNumber");
            var assocSA = nakedObjectSpecification.Properties.Single(p => p.Id == "ShippingAddress");
            var assocSM = nakedObjectSpecification.Properties.Single(p => p.Id == "ShipMethod");
            var assocAN = nakedObjectSpecification.Properties.Single(p => p.Id == "AccountNumber");
            var assocCR = nakedObjectSpecification.Properties.Single(p => p.Id == "CurrencyRate");
            var assocCC = nakedObjectSpecification.Properties.Single(p => p.Id == "CreditCard");
            var assocC  = nakedObjectSpecification.Properties.Single(p => p.Id == "Comment");
            var assocSP = nakedObjectSpecification.Properties.Single(p => p.Id == "SalesPerson");
            var assocST = nakedObjectSpecification.Properties.Single(p => p.Id == "SalesTerritory");
            var assocMD = nakedObjectSpecification.Properties.Single(p => p.Id == "ModifiedDate");

            string idS  = IdHelper.GetFieldInputId(order, (assocS));
            string idSC = IdHelper.GetFieldInputId(order, (assocSC));
            string idBA = IdHelper.GetFieldInputId(order, (assocBA));
            string idPO = IdHelper.GetFieldInputId(order, (assocPO));
            string idSA = IdHelper.GetFieldInputId(order, (assocSA));
            string idSM = IdHelper.GetFieldInputId(order, (assocSM));
            string idAN = IdHelper.GetFieldInputId(order, (assocAN));
            string idCR = IdHelper.GetFieldInputId(order, (assocCR));
            string idCC = IdHelper.GetFieldInputId(order, (assocCC));
            string idC  = IdHelper.GetFieldInputId(order, (assocC));
            string idSP = IdHelper.GetFieldInputId(order, (assocSP));
            string idST = IdHelper.GetFieldInputId(order, (assocST));
            string idMD = IdHelper.GetConcurrencyFieldInputId((order), (assocMD));

            var ct  = soh.Contact;
            var cus = soh.Customer;
            var sc  = FindStoreContactForContact(ct, cus);

            idToRawValue = new Dictionary <string, string> {
                { idS, soh.Status.ToString() },
                { idSC, NakedObjectsFramework.GetObjectId(sc) },
                { idBA, NakedObjectsFramework.GetObjectId(soh.BillingAddress) },
                { idPO, soh.PurchaseOrderNumber },
                { idSA, NakedObjectsFramework.GetObjectId(soh.ShippingAddress) },
                { idSM, NakedObjectsFramework.GetObjectId(soh.ShipMethod) },
                { idAN, soh.AccountNumber },
                { idCR, "" },
                { idCC, NakedObjectsFramework.GetObjectId(soh.CreditCard) },
                { idC, Guid.NewGuid().ToString() },
                { idSP, NakedObjectsFramework.GetObjectId(soh.SalesPerson) },
                { idST, NakedObjectsFramework.GetObjectId(soh.SalesTerritory) },
                { idMD, modifiedDate }
            };

            return(GetForm(idToRawValue));
        }
        private ActionResult ApplyAction(ObjectAndControlData controlData)
        {
            var targetNakedObject = FilterCollection(controlData.GetNakedObject(Facade), controlData);
            var targetAction      = controlData.GetAction(Facade);

            CheckConcurrency(targetNakedObject, null, controlData, (z, x, y) => IdHelper.GetConcurrencyActionInputId(x, targetAction, y));

            if (targetNakedObject.IsNotPersistent)
            {
                RefreshTransient(targetNakedObject, controlData.Form);
            }

            // do after any parameters set by contributed action so this takes priority
            SetSelectedParameters(targetAction);

            var ac = GetParameterValues(targetAction, controlData);
            ActionResultContextFacade ar;

            if (targetNakedObject.Specification.IsCollection && !targetNakedObject.Specification.IsParseable)
            {
                var oids = targetNakedObject.ToEnumerable().Select(no => Facade.OidTranslator.GetOidTranslation(no)).ToArray();
                var spec = targetNakedObject.ElementSpecification;

                ar = Facade.ExecuteListAction(oids, spec, targetAction.Id, ac);
            }
            else
            {
                var oid = Facade.OidTranslator.GetOidTranslation(targetNakedObject);
                ar = Facade.ExecuteObjectAction(oid, targetAction.Id, ac);
            }

            if (!HasError(ar))
            {
                targetNakedObject.SetIsNotQueryableState(targetAction.IsContributed);
                return(AppropriateView(controlData, GetResult(ar), targetAction));
            }

            foreach (var parm in ar.ActionContext.VisibleParameters)
            {
                if (!string.IsNullOrEmpty(parm.Reason))
                {
                    ModelState.AddModelError(IdHelper.GetParameterInputId(targetAction, parm.Parameter), parm.Reason);
                }
            }

            if (!(string.IsNullOrEmpty(ar.ActionContext.Reason)))
            {
                ModelState.AddModelError("", ar.ActionContext.Reason);
            }

            var property = DisplaySingleProperty(controlData, controlData.DataDict);

            return(View(property == null ? "ActionDialog" : "PropertyEdit", new FindViewModel {
                ContextObject = targetNakedObject.GetDomainObject(), ContextAction = targetAction, PropertyName = property
            }));
        }
Ejemplo n.º 3
0
        public IActionResult Merge()
        {
            var result = new ResultAdaptDto();

            try
            {
                string guid      = RequestHelper.GetQueryString("guid");
                string fileName  = RequestHelper.GetQueryString("fileName");
                var    tempDir   = GlobalContext.WebRootPath + "/UploadTemp/" + guid;                                  // 缓存文件夹
                var    targetDir = GlobalContext.WebRootPath + "/upfiles/videos/" + DateTime.Now.ToString("yyyyMMdd"); // 目标文件夹
                //uploadfile,uploadvideo
                string action = RequestHelper.GetPostString("action");
                if (action == "uploadfile")
                {
                    targetDir = GlobalContext.WebRootPath + "/upfiles/attachments/" + DateTime.Now.ToString("yyyyMMdd"); // 目标文件夹
                }
                if (!System.IO.Directory.Exists(targetDir))
                {
                    System.IO.Directory.CreateDirectory(targetDir);
                }

                int    index        = fileName.LastIndexOf('.');
                string extName      = fileName.Substring(index);
                string guidFileName = IdHelper.ObjectId() + extName;
                var    finalPath    = Path.Combine(targetDir, guidFileName);

                var files = System.IO.Directory.GetFiles(tempDir);//获得下面的所有文件
                using (FileStream fs = System.IO.File.Create(finalPath))
                {
                    foreach (var part in files.OrderBy(x => x.Length).ThenBy(x => x))//排一下序,保证从0-N Write
                    {
                        var bytes = System.IO.File.ReadAllBytes(part);
                        fs.Write(bytes, 0, bytes.Length);
                        bytes = null;
                        System.IO.File.Delete(part);//删除分块
                    }
                    fs.Flush();
                }
                string returnPath = "/upfiles/videos/" + DateTime.Now.ToString("yyyyMMdd") + "/" + guidFileName;
                if (action == "uploadfile")
                {
                    returnPath = "/upfiles/attachments/" + DateTime.Now.ToString("yyyyMMdd") + "/" + guidFileName;
                }
                result.data.Add("url", returnPath);

                //文件合并完成后移除缓存
                FileChunkCache.RemoveChunkId(guid);
                result.data.Add("fileName", fileName);
            }
            catch (Exception ex)
            {
                result.status  = false;
                result.message = ex.Message;
            }
            return(Content(result.ToJson()));
        }
Ejemplo n.º 4
0
        public void GenerateShortIdCase()
        {
            const uint originalId = 2028044070;

            var idShortString = IdHelper.ToShortString(originalId);

            var idShort = IdHelper.FromShortString(idShortString);

            Assert.AreEqual(idShort, originalId);
        }
Ejemplo n.º 5
0
        private IEnumerable <StoreCategoryViewModel> ConvertToStoreCategoriesView(Item item)
        {
            var categories = item.GetMultiListValueItems(Templates.Store.Fields.StoreCategories);

            return(categories.Select(x => new StoreCategoryViewModel
            {
                Id = IdHelper.NormalizeGuid(x.ID),
                Name = x.GetString(Templates.StoreCategory.Fields.Value)
            }));
        }
Ejemplo n.º 6
0
        private Expression <Func <IndexedItem, bool> > GetTemplatePredicates(IEnumerable <ID> templates)
        {
            var expression = PredicateBuilder.False <IndexedItem>();

            foreach (var template in templates)
            {
                expression = expression.Or(i => i.AllTemplates.Contains(IdHelper.NormalizeGuid(template)));
            }
            return(expression);
        }
        internal static void AddPartialFieldValueClause(BooleanQuery query, string fieldName, string fieldValue)
        {
            if (fieldValue.IsNullOrEmpty())
            {
                return;
            }

            fieldValue = IdHelper.ProcessGUIDs(fieldValue);
            query.Add(new QueryParser(fieldName, ItemBucket.Kernel.Util.IndexSearcher.Index.Analyzer).Parse(fieldValue), BooleanClause.Occur.MUST);
        }
        public BasicResponse <string> AddPositionBySql(AddPositionBySqlRequest request)
        {
            var id = IdHelper.CreateLongId().ToString();
            var dt = _Repository.QueryTable("global_PointDefineService_AddPosition", id, request.Wz, DateTime.Now);

            return(new BasicResponse <string>()
            {
                Data = dt.Rows[0][0].ToString()
            });
        }
        internal static void ApplyContextItemRemoval(CombinedQuery query, string Id)
        {
            if (Id.IsNullOrEmpty())
            {
                return;
            }

            Id = IdHelper.NormalizeGuid(Id);
            query.Add(new FieldQuery(BuiltinFields.ID, Id), QueryOccurance.MustNot);
        }
    private void CreateActiveRotors(GameEntity entity)
    {
        var removerId = IdHelper.GetNewRemoverId();
        var pos       = entity.gridPosition.value;

        CreateActivePositiveItemService.CreateActiveRotor(_contexts, RotorDirection.Left, pos, removerId);
        CreateActivePositiveItemService.CreateActiveRotor(_contexts, RotorDirection.Right, pos, removerId);
        CreateActivePositiveItemService.CreateActiveRotor(_contexts, RotorDirection.Up, pos, removerId);
        CreateActivePositiveItemService.CreateActiveRotor(_contexts, RotorDirection.Down, pos, removerId);
    }
        internal static void AddFieldValueClause(CombinedQuery query, string fieldName, string fieldValue, QueryOccurance occurance)
        {
            if (fieldName.IsNullOrEmpty() || fieldValue.IsNullOrEmpty())
            {
                return;
            }

            fieldValue = IdHelper.ProcessGUIDs(fieldValue);
            query.Add(new FieldQuery(fieldName, fieldValue), occurance);
        }
Ejemplo n.º 12
0
        public List <string> GetId(int count)
        {
            var result = new List <string>(count);

            for (int i = 0; i < count; i++)
            {
                result.Add(IdHelper.GetId());
            }
            return(result);
        }
Ejemplo n.º 13
0
        public static string Issue(this UrlHelper helper, string id, IssueTab?tab = null, string token = null)
        {
            if (token != null)
            {
                return(helper.Action("public", "issue", tab != null ? (object)new { token, tab = tab.ToString().ToLowerInvariant(), Area = string.Empty } : new { id, Area = string.Empty }));
            }

            id = IdHelper.GetFriendlyId(id);
            return(helper.Action("index", "issue", tab != null ? (object)new { id, tab = tab.ToString().ToLowerInvariant(), Area = string.Empty } : new { id, Area = string.Empty }));
        }
    public static int CreatePositiveItem(PositiveItem itemType, Vector2Int pos, Color color = Color.Blue)
    {
        var contexts        = Contexts.sharedInstance;
        var posItem         = contexts.game.CreateEntity();
        var itemTypeInBoard = ItemTypeInBoard.Tnt;

        if (itemType == PositiveItem.Rotor)
        {
            var axis = Random.Range(0, 2);
            itemTypeInBoard = axis == 0 ? ItemTypeInBoard.RotorHorizontal : ItemTypeInBoard.RotorVertical;
        }

        else if (itemType == PositiveItem.Tnt)
        {
            itemTypeInBoard = ItemTypeInBoard.Tnt;
        }

        else if (itemType == PositiveItem.Puzzle)
        {
            switch (color)
            {
            case Color.Blue:
                itemTypeInBoard = ItemTypeInBoard.BluePuzzle;
                break;

            case Color.Green:
                itemTypeInBoard = ItemTypeInBoard.GreenPuzzle;
                break;

            case Color.Orange:
                itemTypeInBoard = ItemTypeInBoard.OrangePuzzle;
                break;

            case Color.Purple:
                itemTypeInBoard = ItemTypeInBoard.PurplePuzzle;
                break;

            case Color.Red:
                itemTypeInBoard = ItemTypeInBoard.RedPuzzle;
                break;

            case Color.Yellow:
                itemTypeInBoard = ItemTypeInBoard.YellowPuzzle;
                break;

            default:
                itemTypeInBoard = ItemTypeInBoard.BluePuzzle;
                break;
            }
        }

        posItem.AddWillSpawnItem(itemTypeInBoard, pos, pos.y);
        posItem.AddId(IdHelper.GetNewId());
        return(posItem.id.Value);
    }
Ejemplo n.º 15
0
        /// <summary>
        /// 提交数据
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="userDto"></param>
        public void SaveData(sys_user dto, List <long> positions, LoginUserDto userDto)
        {
            // dto.pass_word = Encrypt.DesEncrypt(dto.pass_word.Trim());

            dto.email        = dto.email ?? string.Empty;
            dto.mobile_phone = dto.mobile_phone ?? string.Empty;
            if (dto.dept_id == 0)
            {
                dto.dept_name = "";
            }
            else
            {
                var deptName = Sqldb.Select <sys_dept>().Where(s => s.id == dto.dept_id).First(s => s.dept_name);
                dto.dept_name = deptName ?? "";
            }
            if (dto.user_avatar.IsEmpty())
            {
                dto.user_avatar = "";
            }

            dto.update_by   = userDto.LoginName;
            dto.update_time = DateTime.Now;
            if (dto.id == 0)
            {
                dto.id          = IdHelper.NextId();
                dto.del_flag    = DataStatusConstant.NOT_DELETED;
                dto.create_time = DateTime.Now;
                dto.create_by   = userDto.LoginName;
                Sqldb.Insert(dto).ExecuteAffrows();
            }
            else
            {
                Sqldb.Update <sys_user>().SetSource(dto)
                .IgnoreColumns(s => new { s.create_by, s.create_time, s.user_name, s.del_flag }).ExecuteAffrows();
                Sqldb.Delete <sys_user_position>().Where(s => s.user_id == dto.id).ExecuteAffrows();
            }

            //插入职位信息

            if (positions != null && positions.Count > 0)
            {
                List <sys_user_position> positionsList = new List <sys_user_position>();
                foreach (int pid in positions)
                {
                    sys_user_position positionMoel = new sys_user_position();
                    positionMoel.user_id     = dto.id;
                    positionMoel.position_id = pid;
                    positionMoel.create_by   = userDto.LoginName;
                    positionMoel.create_time = dto.update_time;
                    positionsList.Add(positionMoel);
                }

                Sqldb.Insert(positionsList).ExecuteAffrows();
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 添加一个全新信息到请求库表并返回成功后的请求库对象(支持添加、更新,根据状态来判断)
        /// </summary>
        /// <param name="requestDTO"></param>
        /// <returns></returns>
        public BasicResponse <RequestInfo> AddRequestEx(RequestAddRequest requestrequest)
        {
            BasicResponse <RequestInfo> Result = new BasicResponse <RequestInfo>();
            RequestInfo requestDTO             = requestrequest.RequestInfo;

            try
            {
                long ID = 0;
                if (requestDTO == null)
                {
                    ThrowException("AddRequestEx", new Exception("请求库对象为空,请检查是否已赋值!"));
                }
                if (requestDTO.InfoState == InfoState.NoChange)
                {
                    ThrowException("AddRequestEx", new Exception("DTO对象未设置状态,请先设置!"));
                }
                if (string.IsNullOrEmpty(requestDTO.RequestCode))
                {
                    ThrowException("AddRequestEx", new Exception("请求库编码不能为空,请重新输入!"));
                }
                if (string.IsNullOrEmpty(requestDTO.RequestName))
                {
                    ThrowException("AddRequestEx", new Exception("请求库名称不能为空,请重新输入!"));
                }
                if (requestDTO.InfoState == InfoState.AddNew)
                {
                    //判断请求库名是否存在,只有不存在才能插入
                    if (!CheckRequestNameExist(requestDTO.RequestName) && !CheckRequestCodeExist(requestDTO.RequestCode))
                    {
                        ID = IdHelper.CreateLongId();
                        requestDTO.RequestID = ID.ToString();
                        var _request   = ObjectConverter.Copy <RequestInfo, RequestModel>(requestDTO);
                        var resultmenu = _Repository.AddRequest(_request);
                        Result.Data = ObjectConverter.Copy <RequestModel, RequestInfo>(resultmenu);
                    }
                    else
                    {
                        ThrowException("AddRequestEx", new Exception("请求库对象已存在,请重新输入!"));
                    }
                }
                else
                {
                    var _request = ObjectConverter.Copy <RequestInfo, RequestModel>(requestDTO);
                    _Repository.UpdateRequest(_request);
                    var resultmenu = _Repository.GetRequestById(requestDTO.RequestID);
                    Result.Data = ObjectConverter.Copy <RequestModel, RequestInfo>(resultmenu);
                }
            }
            catch (System.Exception ex)
            {
                Result.Code    = 1;
                Result.Message = ex.Message;
            }
            return(Result);
        }
Ejemplo n.º 17
0
        public HttpResponseMessage PostMessage(PD_MessageDTO item, int id)
        {
            //if (item.EndPoints[0] == 0.0 && item.EndPoints[1] == 0.0) return null; //older versions
            //else if (item.EndPoints.Length == 2) return null;
            var _p = _db.PD_Processes.Find(id);

            if (User.Identity.Name.Equals(_p.LockedBy))
            {
                foreach (var i in _p.Messages) //this foreach shouldnt be necessary, by doing a simple update via javascript, but doesn't seem to be working
                {
                    if (i.EndPoints != null)   //for older versions
                    {
                        var source1 = Convert.ToDouble(i.EndPoints.Split('|')[0]);
                        var source2 = Convert.ToDouble(i.EndPoints.Split('|')[1]);
                        if (source1 == item.EndPoints[0] && source2 == item.EndPoints[1])
                        {
                            i.EndPoints = (item.EndPoints[0]).ToString() + "|" + (item.EndPoints[1]).ToString() + "|" + (item.EndPoints[2]).ToString() + "|" + (item.EndPoints[3]).ToString();
                            i.To        = item.To;
                            _db.SaveChanges();
                            return(null);
                        }
                    }
                }


                PD_Message m = new PD_Message()
                {
                    From = item.From, To = item.To
                };
                m.Id = IdHelper.getMessageId(_db, id);
                if (item.EndPoints.Length == 2)  //si me da igual, algo hay q guardar simplemente
                {
                    m.EndPoints = (item.EndPoints[0]).ToString() + "|" + (item.EndPoints[1]).ToString() + "|0|0";
                }
                else
                {
                    m.EndPoints = (item.EndPoints[0]).ToString() + "|" + (item.EndPoints[1]).ToString() + "|" + (item.EndPoints[2]).ToString() + "|" + (item.EndPoints[3]).ToString();
                }
                //m.EndPoints = item.EndPoints;
                _p.Messages.Add(m);
                _db.SaveChanges();
                var response = Request.CreateResponse <PD_MessageDTO>(HttpStatusCode.Created, new PD_MessageDTO()
                {
                    Id = m.Id, From = m.From, To = m.To, TypeName = "newMessage", EndPoints = item.EndPoints
                });

                string uri = Url.Content("Designer" + id + "/Messages/" + m.Id);
                response.Headers.Location = new Uri(uri);
                return(response);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 生成馈电记录结构体
        /// </summary>
        /// <param name="BJID">报警ID</param>
        /// <param name="KDID">馈电ID</param>
        /// <param name="stime">报警开始时间</param>
        /// <returns></returns>
        private Jc_KdInfo GetNewJCKDInfo(string BJID, string KDID, DateTime stime)
        {
            Jc_KdInfo jk = new Jc_KdInfo();

            jk.ID        = IdHelper.CreateLongId().ToString();
            jk.BJID      = BJID;
            jk.KDID      = KDID;
            jk.Timer     = stime;
            jk.InfoState = InfoState.AddNew;
            return(jk);
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            new IdHelperBootstrapper()
            //设置WorkerId
            .SetWorkderId(1)
            .Boot();

            Console.WriteLine($"WorkerId:{IdHelper.WorkerId},Id:{IdHelper.GetId()}");

            Console.ReadLine();
        }
Ejemplo n.º 20
0
        private IQueryable <BlogArticleSearchResultItem> ApplyTagIdPredicate(IQueryable <BlogArticleSearchResultItem> query, ID[] tagIds)
        {
            var expression = PredicateBuilder.False <BlogArticleSearchResultItem>();

            foreach (var tagId in tagIds)
            {
                expression = expression.Or(i => i.Tags.Contains(IdHelper.NormalizeGuid(tagId)));
            }

            return(query.Where(expression));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 添加用户信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <bool> PostUserAsync(AddUserInfoDto input, string openId, string sessionKey)
        {
            Wx_UserInfo user = iMapper.Map <Wx_UserInfo>(input);

            user.ID = IdHelper.CreateGuid();

            if (openId != null)
            {
                user.OpenId = openId;
                if (input.EncryptedData != "" && input.IV != "")
                {
                    user.MobilePhone = WxHelper.getPhoneNumber(input.EncryptedData, input.IV, sessionKey);
                }
            }

            var result = 0;

            return(await Task.Run(() =>
            {
                var isAny = db.Queryable <Wx_UserInfo>().Where(a => a.OpenId == openId).Any();

                if (isAny == false)
                {
                    result = db.Insertable(user).ExecuteCommand();
                }
                else
                {
                    if (user.MobilePhone == null)
                    {
                        throw new Exception("没有获取到用户手机号码!");
                    }

                    result = db.Updateable <Wx_UserInfo>().SetColumns(a => new Wx_UserInfo()
                    {
                        MobilePhone = user.MobilePhone, FollowDate = DateTime.Now
                    })
                             .Where(a => a.OpenId == openId).ExecuteCommand();

                    if (result > 0)
                    {
                        if (input.TeamId != null)
                        {
                            var userId = db.Queryable <Wx_UserInfo>().Where(a => a.OpenId == openId).First()?.ID;

                            db.Updateable <TeamMember>().SetColumns(a => new TeamMember()
                            {
                                MobilePhone = user.MobilePhone
                            }).Where(a => a.TeamId == input.TeamId && a.JoinedUserId == userId && a.IsDeleted == false).ExecuteCommand();
                        }
                    }
                }
                return result > 0;
            }));
        }
Ejemplo n.º 22
0
 private IInputDevice CreateDevice(DeviceInstance deviceInstance, List <string> uniqueIds)
 {
     try
     {
         if (!directInput.IsDeviceAttached(deviceInstance.InstanceGuid))
         {
             return(null);
         }
         var joystick = new Joystick(directInput, deviceInstance.InstanceGuid);
         if (joystick.Capabilities.AxeCount < 1 && joystick.Capabilities.ButtonCount < 1)
         {
             joystick.Dispose();
             return(null);
         }
         bool   isHid         = deviceInstance.IsHumanInterfaceDevice;
         string interfacePath = null;
         string uniqueIdBase;
         string hardwareId = null;
         if (isHid)
         {
             if (ignoredDeviceService.IsIgnored(joystick.Properties.InterfacePath))
             {
                 joystick.Dispose();
                 return(null);
             }
             interfacePath = joystick.Properties.InterfacePath;
             uniqueIdBase  = interfacePath;
             hardwareId    = IdHelper.GetHardwareId(interfacePath);
         }
         else
         {
             uniqueIdBase = string.Join(":", deviceInstance.ProductGuid.ToString(), deviceInstance.InstanceGuid.ToString());
         }
         string uniqueId = IdHelper.GetUniqueId(uniqueIdBase);
         if (uniqueIds.Any(uid => uid == uniqueId))
         {
             notificationService.Add(Notifications.DirectInputInstanceIdDuplication, new[] { uniqueId }, NotificationTypes.Warning);
         }
         uniqueIds.Add(uniqueId);
         if (currentDevices.Any(d => d.UniqueId == uniqueId))
         {
             joystick.Dispose();
             return(null);
         }
         joystick.Properties.BufferSize = 128;
         return(new DirectInputDevice(inputConfigManager, joystick, deviceInstance.InstanceGuid.ToString(), deviceInstance.ProductName,
                                      deviceInstance.ForceFeedbackDriverGuid != Guid.Empty, uniqueId, hardwareId, interfacePath));
     }
     catch (Exception ex)
     {
         logger.Error("Failed to create device " + deviceInstance.InstanceGuid + " " + deviceInstance.InstanceName + ex.ToString());
         return(null);
     }
 }
Ejemplo n.º 23
0
        internal void InitializeControl(IntersectForm parent)
        {
            // Ask the enclosing property sheet whether we are updating
            // an existing feature or not.

            // If we are updating a previously existing point, select
            // the previously defined entity type.
            IntersectOperation op = parent.GetUpdateOp();

            if (op == null)
            {
                // Load the entity combo box with a list for point features.
                IEntity ent = pointTypeComboBox.Load(SpatialType.Point);

                // Load the ID combo (reserving the first available ID).
                IdHelper.LoadIdCombo(pointIdComboBox, ent, m_PointId);

                // If we are auto-numbering, disable the ID combo.
                EditingController controller = EditingController.Current;
                if (controller.IsAutoNumber)
                {
                    pointIdComboBox.Enabled = false;
                }
            }
            else
            {
                pointTypeComboBox.SelectedValueChanged -= pointTypeComboBox_SelectedValueChanged;
                pointIdComboBox.SelectedValueChanged   -= pointIdComboBox_SelectedValueChanged;

                pointTypeComboBox.Enabled = false;
                pointIdComboBox.Enabled   = false;

                // Load the entity combo box with a list for point features and disable it.
                ILayer layer = EditingController.Current.ActiveLayer;
                pointTypeComboBox.Load(SpatialType.Point, layer);

                // Scroll the entity combo to the previously defined
                // entity type for the intersection point.
                PointFeature feat   = op.IntersectionPoint;
                IEntity      curEnt = feat.EntityType;
                if (curEnt != null)
                {
                    pointTypeComboBox.SelectEntity(curEnt);
                }

                // Display the point key (if any)
                pointIdComboBox.DropDownStyle = ComboBoxStyle.DropDown;
                pointIdComboBox.Text          = feat.FormattedKey;

                // Intersects involving line features...
                m_CloseTo = op.ClosePoint;
                ShowCloseTo();
            }
        }
Ejemplo n.º 24
0
        private static List <string> GetAllTemplates(Item item)
        {
            Assert.ArgumentNotNull(item, "item");
            Assert.IsNotNull(item.Template, "Item template not found.");
            var list = new List <string> {
                IdHelper.NormalizeGuid(item.TemplateID)
            };

            RecurseTemplates(list, item.Template);
            return(list);
        }
        public SearchItems GetArticleItems(string category, Data.ID siteId, int page = 0, int pageSize = 100)
        {
            using (var searchContext = ContentSearchManager.GetIndex(this.IndexName).CreateSearchContext())
            {
                var query = PredicateBuilder.True <ArticleIndex>();
                query = query.And(x => x.ArticleCategory.Equals(category.Trim(), StringComparison.OrdinalIgnoreCase));
                query = query.And(x => x.MallSite.Contains(IdHelper.NormalizeGuid(siteId)));

                return(GetResults(searchContext, query, page, pageSize));
            }
        }
Ejemplo n.º 26
0
        protected void AddFieldValueClause(CombinedQuery query, string fieldName, string fieldValue, QueryOccurance occurance)
        {
            if (String.IsNullOrEmpty(fieldName) || String.IsNullOrEmpty(fieldValue))
            {
                return;
            }

            // if we are searching by _id field, do not lowercase
            fieldValue = IdHelper.ProcessGUIDs(fieldValue);
            query.Add(new FieldQuery(fieldName.ToLowerInvariant(), fieldValue), occurance);
        }
Ejemplo n.º 27
0
 private static void RecurseTemplates(ICollection <string> list, TemplateItem template)
 {
     foreach (var baseTemplateItem in template.BaseTemplates)
     {
         list.Add(IdHelper.NormalizeGuid(baseTemplateItem.ID));
         if (baseTemplateItem.ID != TemplateIDs.StandardTemplate)
         {
             RecurseTemplates(list, baseTemplateItem);
         }
     }
 }
Ejemplo n.º 28
0
        public string Convert(object o)
        {
            if (o == null)
                return null;

            var s = o as string;
            if (s == null)
                return o.ToString();

            return IdHelper.GetFriendlyId(s);
        }
Ejemplo n.º 29
0
 private string GetUniqueId(DeviceInstance deviceInstance, Joystick joystick)
 {
     if (deviceInstance.IsHumanInterfaceDevice)
     {
         return(IdHelper.GetUniqueId(joystick.Properties.InterfacePath));
     }
     else
     {
         return(deviceInstance.InstanceGuid.ToString());
     }
 }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            new IdHelperBootstrapper()
            //使用Zookeeper自动分配管理WorkerId,解决时间回退问题和自动分配问题
            .UseZookeeper("127.0.0.1:2181", 200, "Test")
            .Boot();

            Console.WriteLine($"WorkerId:{IdHelper.WorkerId},Id:{IdHelper.GetId()}");

            Console.ReadLine();
        }