Пример #1
0
        public static ItemVM NewGroup()
        {
            Item   item   = NewData.NewGroup();
            ItemVM itemVM = ItemToVM(item);

            return(itemVM);
        }
Пример #2
0
        /// <summary>
        /// Begins synchronization.
        /// </summary>
        public async Task Start()
        {
            if (_apiService == null)
            {
                Console.WriteLine("That's dope man.");
            }
            DateTime today    = DateTime.Now.Subtract(DateTime.Now.TimeOfDay);
            DateTime tomorrow = today.AddDays(1);
            List <T> list;

            try
            {
                list = await _apiService.GetAllBetweenDatesAsync <T>(_apiResourceUri, today, tomorrow);
            }
            catch (Flurl.Http.FlurlHttpException ex)
            {
                throw;
            }
            Console.WriteLine("Number of initial elements: " + list.Count);
            if (list.Count > 0)
            {
                _repository.AddRange(list);
                NewData?.Invoke(this, new DataSyncEventArgs <T>()
                {
                    ChangedElements = list
                });
            }
            //foreach (T item in _repository.Cast<T>())
            //{
            //    Console.WriteLine(item.GetSyncId());
            //}
            _timer.Start();
        }
Пример #3
0
        /// <summary>
        /// 根据要素ID修改要素信息
        /// </summary>
        /// <param name="element">要素目录实体</param>
        public void UpdateElementByEID(Element element)
        {
            DateTime   dt         = NewData.NewDate();
            ElementDAL elementDAL = new ElementDAL();

            elementDAL.UpdateElementByEID(element, dt);
        }
Пример #4
0
 public IActionResult Data(NewData MovieData)
 {
     //TempStorage.AddApplication(MovieData);
     _mvCollectionDbContext.NewDatas.Add(MovieData);
     _mvCollectionDbContext.SaveChanges();
     return(View("Confirmation", MovieData));
 }
Пример #5
0
        private void SetDataContext()
        {
            try
            {
                Shortcuts shortcuts = null;
                if (IsFirstTimeRun())
                {
                    // This is the first time the application is runing.
                    shortcuts = NewData.NewShortcuts();
                    SaveData.SaveShortcuts(shortcuts, true);
                }
                else
                {
                    // This is not the first time the application is runing.
                    // Get the shortcuts data
                    shortcuts = ShortcutsData.GetShortcuts();

                    // If shortcuts is null then perhaps the sortcut data file is corrupted.
                    if (shortcuts == null)
                    {
                        MessageBoxResult messageBoxResult = MessageBox.Show("For some reason shortcuts are corrupted.\nReseting shortcuts.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        shortcuts = NewData.NewShortcuts();
                        SaveData.SaveShortcuts(shortcuts, true);
                    }
                }
                DataContext = ContextHelper.ShortcutsToVM(shortcuts);
            }
            catch (Exception ex)
            {
                Error.ShowDialog(ex);
            }
        }
    static void Main(string[] args)
    {
        List <OldData> oldItems = new List <OldData>();
        OldData        oldData1 = new OldData();

        oldData1.Name         = "Test01";
        oldData1.OriginalPath = "D:/Temp01";
        oldItems.Add(oldData1);
        OldData oldData2 = new OldData();

        oldData2.Name         = "Test02";
        oldData2.OriginalPath = "D:/Temp02";
        oldItems.Add(oldData2);
        List <NewData> newItems = new List <NewData>();
        NewData        newData1 = new NewData();

        newData1.Name         = "Test01";
        newData1.OriginalPath = "D:/Temp01";
        newItems.Add(newData1);
        NewData newData2 = new NewData();

        newData2.Name         = "Test05";
        newData2.OriginalPath = "D:/Temp05";
        newItems.Add(newData2);
        oldItems = oldItems.Where(x => newItems != null && !newItems.Any(y => x.Name == y.Name && x.OriginalPath == y.OriginalPath)).ToList();
    }
Пример #7
0
        /// <summary>
        /// 新增角色用户 同步人员权限
        /// </summary>
        /// <param name="roleUesrJson">角色用户实体字符串</param>
        /// <returns></returns>
        public void CreateRoleUser(string roleUesrJson)
        {
            //获取当前时间
            DateTime    dt          = NewData.NewDate();
            var         roleUesr    = JsonConvert.DeserializeObject <List <RoleUesr> >(roleUesrJson);
            RoleUserDAL roleUserDAL = new RoleUserDAL();

            for (int i = 0; i < roleUesr.Count; i++)
            {
                //新增角色用户
                string ifsuccess = roleUserDAL.CreateRoleUser(roleUesr[i], dt);
                if (ifsuccess == "OK")
                {
                    MainAuthorityDAL mainAuthorityDAL = new MainAuthorityDAL();
                    //根据角色ID获取主体权限ID
                    List <MainAuthority> mainAuthority = mainAuthorityDAL.GetAllAIDByRoleID(roleUesr[i].RID);
                    //同步人员权限
                    PersonnelAuthorityDAL personnelAuthorityDAL = new PersonnelAuthorityDAL();
                    for (int j = 0; j < mainAuthority.Count; j++)
                    {
                        personnelAuthorityDAL.CreatePersonnelAuthority(mainAuthority[j].AID);
                    }
                }
            }
        }
Пример #8
0
        public IActionResult EditMovie(int movieId)
        {
            // Use "movieId" to identify which movie record we will open the edit form for.
            NewData movie = _mvCollectionDbContext.NewDatas.First(i => i.MovieId == movieId);

            // Take the user to the Edit form where they can modify each record
            return(View(movie));
        }
Пример #9
0
        /// <summary>
        /// 根据ID修改资源目录
        /// </summary>
        /// <param name="resource">资源目录对象</param>
        /// <param name="dt">最后修改时间</param>
        public void PutResourceByID(Resource resource)
        {
            ///获取当前时间
            DateTime    dt          = NewData.NewDate();
            ResourceDAL resourceDAL = new ResourceDAL();

            resourceDAL.PutResourceByID(resource, dt);
        }
Пример #10
0
        /// <summary>
        /// 根据ID修改资源目录
        /// </summary>
        /// <param name="countNorm">资源目录对象</param>
        /// <param name="dt">最后修改时间</param>
        public void PutCountNormByID(CountNorm countNorm)
        {
            ///获取当前时间
            DateTime     dt           = NewData.NewDate();
            CountNormDAL countNormDAL = new CountNormDAL();

            countNormDAL.PutCountNormByID(countNorm, dt);
        }
Пример #11
0
        /// <summary>
        /// 根据ID修改文本值域选项
        /// </summary>
        /// <param name="elementRange">文本值域选项对象</param>
        /// <param name="dt">最后修改时间</param>
        public void PutElementRangeByID(ElementRange elementRange)
        {
            ///获取当前时间
            DateTime        dt = NewData.NewDate();
            ElementRangeDAL elementRangeDAL = new ElementRangeDAL();

            elementRangeDAL.PutElementRangeByID(elementRange, dt);
        }
Пример #12
0
        /// <summary>
        /// 要素目录新增
        /// </summary>
        /// <param name="element"></param>
        public void CreateElement(Element element)
        {
            DateTime   dt         = NewData.NewDate();
            string     uid        = NewData.NewGuid();
            ElementDAL elementDAL = new ElementDAL();

            elementDAL.CreateElement(element, dt, uid);
        }
Пример #13
0
        /// <summary>
        /// 根据ID修改要素分类
        /// </summary>
        /// <param name="elementClassify">要素分类对象</param>
        /// <param name="dt">最后修改时间</param>
        public void PutElementClassifyByID(ElementClassify elementClassify)
        {
            ///获取当前时间
            DateTime           dt = NewData.NewDate();
            ElementClassifyDAL elementClassifyDAL = new ElementClassifyDAL();

            elementClassifyDAL.PutElementClassifyByID(elementClassify, dt);
        }
Пример #14
0
        public void NewFuncTest()
        {
            String s        = "1 2 3";
            string actual   = NewData.GetRecessivePr(s);
            string expected = "0,31667";

            Assert.Equal(expected, actual);
        }
Пример #15
0
        /// <summary>
        /// 新增资源目录
        /// </summary>
        /// <param name="resource">资源目录对象</param>
        /// <param name="dt">最后修改时间</param>
        /// <param name="nid">新GUID</param>
        public void CreateResource(Resource resource)
        {
            ///获取当前时间
            DateTime dt = NewData.NewDate();
            //获取新的GUID
            string      nid         = NewData.NewGuid();
            ResourceDAL resourceDAL = new ResourceDAL();

            resourceDAL.CreateResource(resource, dt, nid);
        }
Пример #16
0
        /// <summary>
        /// 新增统计指标
        /// </summary>
        /// <param name="countNorm">统计指标对象</param>
        /// <param name="dt">最后修改时间</param>
        /// <param name="nid">新GUID</param>
        public void CreateCountNorm(CountNorm countNorm)
        {
            ///获取当前时间
            DateTime dt = NewData.NewDate();
            //获取新的GUID
            string       nid          = NewData.NewGuid();
            CountNormDAL countNormDAL = new CountNormDAL();

            countNormDAL.CreateCountNorm(countNorm, dt, nid);
        }
Пример #17
0
        /// <summary>
        /// 新增文本值域选项
        /// </summary>
        /// <param name="elementRange">文本值域选项对象</param>
        /// <param name="dt">最后修改时间</param>
        /// <param name="nid">新GUID</param>
        public void CreateElementRange(ElementRange elementRange)
        {
            ///获取当前时间
            DateTime dt = NewData.NewDate();
            //获取新的GUID
            string          nid             = NewData.NewGuid();
            ElementRangeDAL elementRangeDAL = new ElementRangeDAL();

            elementRangeDAL.CreateElementRange(elementRange, dt, nid);
        }
Пример #18
0
        public IActionResult DeleteMovie(int movieId)
        {
            NewData Movie = _mvCollectionDbContext.NewDatas.First(x => x.MovieId == movieId);

            //NewData Movie = _mvCollectionDbContext.NewDatas.Find(MovieId);

            _mvCollectionDbContext.Remove(Movie);
            _mvCollectionDbContext.SaveChanges();
            return(RedirectToAction("mvDB"));
        }
Пример #19
0
        /// <summary>
        /// 新增要素分类
        /// </summary>
        /// <param name="elementClassify">要素分类对象</param>
        /// <param name="dt">最后修改时间</param>
        /// <param name="nid">新GUID</param>
        public void CreateElementClassify(ElementClassify elementClassify)
        {
            ///获取当前时间
            DateTime dt = NewData.NewDate();
            //获取新的GUID
            string             nid = NewData.NewGuid();
            ElementClassifyDAL elementClassifyDAL = new ElementClassifyDAL();

            elementClassifyDAL.CreateElementClassify(elementClassify, dt, nid);
        }
Пример #20
0
        private void ReceiveLoop(CancellationToken ct)
        {
            while (!ct.IsCancellationRequested)
            {
                string msg = GetNextMessage();
                if (msg == "")
                {
                    continue;
                }
                XmlDocument doc    = new XmlDocument();
                XmlSchema   schema = new XmlSchema();
                schema.Namespaces.Add("stream", "http://etherx.jabber.org/streams");
                doc.Schemas.Add(schema);

                //quit if the stream has been closed
                if (msg.IndexOf("</stream:stream>") != -1)
                {
                    StreamClosed?.Invoke();
                    return;
                }
                bool wtf = false;
                // Correct XML errors: stream opening should be the only case in which there is an open tag
                if (msg.IndexOf("<stream:stream") != -1)
                {
                    msg += "</stream:stream>";
                    wtf  = true;
                }
                else
                {
                    msg = GetStreamHeader() + msg + "</stream:stream>";
                }

                doc.LoadXml(msg);
                XmlNodeList nodes = null;
                if (wtf)
                {
                    nodes = doc.ChildNodes;
                }
                else
                {
                    nodes = doc.LastChild.ChildNodes;
                }

                foreach (XmlNode node in nodes)
                {
                    NewData?.Invoke(node);
                    if (node.Name.Equals("iq"))
                    {
                        NewIq?.Invoke(node);
                    }
                }
            }
        }
Пример #21
0
 void OnTick(object sender, EventArgs e)
 {
     if (file.BaseStream.Length != oldSize)
     {
         var res   = file.BaseStream.Seek(oldSize, SeekOrigin.Begin);
         var bytes = file.ReadBytes((int)file.BaseStream.Length - oldSize);
         var str   = Encoding.UTF8.GetString(bytes);
         NewData?.Invoke(this, str);
         OnNewData(str);
     }
     oldSize = (int)file.BaseStream.Length;
 }
Пример #22
0
        public async Task FetchAsync()
        {
            var lastEntry = await context.Data.AsQueryable().OrderByDescending(a => a.Timestamp).FirstOrDefaultAsync();

            if (lastEntry?.Timestamp != null && lastEntry.Timestamp.Add(RefreshRate) > DateTime.UtcNow)
            {
                return;
            }

            bool traverse     = true;
            var  foundEntries = new Stack <InstagramData>();

            while (traverse)
            {
                var data = await HttpClient.GetStringAsync(GetMediaUri(100, "id,timestamp,permalink", null));

                var response = JsonConvert.DeserializeObject <InstagramResponse>(data);
                if (response.Paging.Next == null)
                {
                    traverse = false;                               //If there's no next, no need to fetch more
                }
                foreach (var item in response.Data)
                {
                    if (item.Timestamp <= lastEntry?.Timestamp)
                    {
                        traverse = false;
                        break;
                    }

                    var uri = await GetOembedUriAsync(item.Permalink !);

                    var embedData = await HttpClient.GetStringAsync(uri);

                    var embedResponse = JsonConvert.DeserializeObject <OembedData>(embedData, new JsonSerializerSettings
                    {
                        ContractResolver = new DefaultContractResolver
                        {
                            NamingStrategy = new SnakeCaseNamingStrategy()
                        }
                    }) ?? throw new NullReferenceException("Couldn't deserialise Oembed data");

                    var entry = new InstagramData(item.Id !, item.Timestamp !.Value, embedResponse);
                    await context.Data.InsertOneAsync(entry);

                    foundEntries.Push(entry);
                }
            }
            if (foundEntries.Count > 0)
            {
                NewData?.Invoke(this, foundEntries);
            }
        }
Пример #23
0
        /// <summary>
        /// 根据AID修改主体权限
        /// </summary>
        /// <param name="mainAuthority">主体权限对象</param>
        /// <param name="dt">最后修改时间</param>
        public void PutMainAuthorityByAID(MainAuthority mainAuthority)
        {
            ///获取当前时间
            DateTime dt = NewData.NewDate();
            //新增主体权限
            MainAuthorityDAL mainAuthorityDAL = new MainAuthorityDAL();

            mainAuthorityDAL.PutMainAuthorityByAID(mainAuthority, dt);
            //新增人员权限
            PersonnelAuthorityDAL personnelAuthorityDAL = new PersonnelAuthorityDAL();

            personnelAuthorityDAL.CreatePersonnelAuthority(mainAuthority.AID);
        }
Пример #24
0
        /// <summary>
        /// Invoke the order event to add a new order
        /// </summary>
        /// <param name="request">String with order information</param>
        /// <returns>Return the order plates and order number</returns>
        private async Task <string> AddOrderAsync(string request)
        {
            var response = "";

            await Task.Run(() =>
            {
                var eventArgs = new OrderEventArgs(request);
                NewData?.Invoke(this, eventArgs);
                response = eventArgs.Response;
            });

            return(response);
        }
Пример #25
0
        /// <summary>
        /// Асинхронный запуск сервера
        /// </summary>
        /// <returns></returns>
        public Task StartAsync()
        {
            return(Task.Factory.StartNew(() =>
            {
                try
                {
                    if (MessageEncryptionEnabled)
                    {
                        Console.WriteLine($"Server run on {Port} with encryption channel");
                    }
                    else
                    {
                        Console.WriteLine($"Server run on {Port}");
                    }

                    _listener.Start();

                    while (true)
                    {
                        TcpClient client = _listener.AcceptTcpClient();

                        Task.Factory.StartNew(() =>
                        {
                            var fluffyClient = new FluffyClient(client, this);

                            AddConnectedClient(fluffyClient);

                            StoreInit?.Invoke(fluffyClient);

                            NewClientConnected?.Invoke(fluffyClient);

                            fluffyClient.Disconnected += client1 => { ClientDisconnected?.Invoke(client1); };

                            fluffyClient.NewData += (data) =>
                            {
                                NewData?.Invoke(fluffyClient, data);
                            };

                            fluffyClient.NewPacket += (ref int id, PacketParser <Packet> parser, FluffyClient xFuffyClient) =>
                            {
                                NewPacket?.Invoke(ref id, parser, xFuffyClient);
                            };
                        });
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message + " " + e.StackTrace);
                }
            }));
        }
 public void its_subtype_should_be_serializable_deserialiazble()
 {
     var newData = new NewData
     {
         stringValue = "qwerty",
         intValue = 12345,
         boolValue = true,
         stringArray = new[] { "q", "w", "e" },
         Dictionary = new Dictionary<string, int> { { "kq", 1 }, { "k2", 2 } }
     };
     var stream = ProtoBufSerializer.Serialize(newData);
     stream.Should().NotBeNull();
     ProtoBufSerializer.Deserialize<NewData>(stream).ShouldBeEquivalentTo(newData);
 }
Пример #27
0
 //IDataBase con = new PostgreSQL();
 #region 添加用户
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public AjaxMsgResult Add(UC_User model, string CreateUser = null)
 {
     result.Success = false;
     try
     {
         if (IsRepeat(model.LoginName, model.Mobile, model.Email) == true)
         {
             result.State = AjaxMsgResult.StateEnum.IsExist;
             result.Msg   = "添加失败,存在相同的数据!";
             return(result);
         }
         if (string.IsNullOrWhiteSpace(model.LoginName) && string.IsNullOrWhiteSpace(model.Mobile) && string.IsNullOrWhiteSpace(model.Email))
         {
             result.State = AjaxMsgResult.StateEnum.VerifyFailed;
             result.Msg   = "添加失败,注册用户名为空!";
             return(result);
         }
         Dictionary <string, object> dic = new Dictionary <string, object>();
         StringBuilder sql = new StringBuilder();
         sql.Append(@" INSERT INTO UC_User(Id,UserName,LoginName,PassWord,IsValid,Status,Mobile,CreateUser,CreateTime) VALUES (?Id,?UserName,?LoginName,?PassWord,?IsValid,?Status,?Mobile,?CreateUser,?CreateTime)");
         string id = NewData.NewId("YH");
         dic.Add("Id", id);
         dic.Add("UserName", model.UserName);
         dic.Add("LoginName", model.LoginName);
         dic.Add("PassWord", Com.SHA512Encrypt(model.PassWord));
         dic.Add("IsValid", model.IsValid);
         dic.Add("Status", model.Status);
         dic.Add("Mobile", model.Mobile);
         dic.Add("CreateUser", CreateUser == null? id:model.CreateUser);
         dic.Add("CreateTime", DateTime.Now);
         int count = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteNonQuery(sql.ToString(), dic);
         if (count == 1)
         {
             if (userExtendService.Add(id).Success == true)
             {
                 result = Verify(model);
             }
         }
         else
         {
             result.Msg = "添加失败,请检查数据合法性!";
         }
     }
     catch (Exception e)
     {
         result.Msg = e.ToString();
     }
     return(result);
 }
Пример #28
0
        /// <inheritdoc/>
        public override void Apply(Vector2 terrainCoords, TerrainBrush brush)
        {
            // Calculate top-left point of area to modify
            var offset = new Point(
                (int)Math.Round(terrainCoords.X / Terrain.Size.StretchH) - brush.Size / 2,
                (int)Math.Round(terrainCoords.Y / Terrain.Size.StretchH) - brush.Size / 2);

            var oldData = new byte[brush.Size, brush.Size];
            var newData = new byte[brush.Size, brush.Size];
            ModifyTerrain(offset, brush, oldData, newData);

            OldData.AddFirst(offset, oldData);
            NewData.AddLast(offset, newData);
            _engineTerrain.ModifyHeight(offset, newData); // Live-update engine terrain
        }
Пример #29
0
        /// <summary>
        /// 角色权限管理页面其他权限管理新增主体权限 同步人员权限
        /// </summary>
        /// <param name="mainAuthority">主体权限实体</param>
        /// <param name="dt">最后修改时间</param>
        public void CreateMainAuthorityByOthers(MainAuthority mainAuthority)
        {
            //获取当前时间
            DateTime              dt = NewData.NewDate();
            MainAuthorityDAL      mainAuthorityDAL      = new MainAuthorityDAL();
            PersonnelAuthorityDAL personnelAuthorityDAL = new PersonnelAuthorityDAL();
            //主体权限新增
            string ifsuccess = mainAuthorityDAL.CreateMainAuthorityByOthers(mainAuthority, dt);

            if (ifsuccess == "OK")
            {
                //人员权限同步
                personnelAuthorityDAL.CreatePersonnelAuthority(mainAuthority.AID);
            }
        }
Пример #30
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            NewData = await _context.NewDatas.FirstOrDefaultAsync(m => m.MovieId == id);

            if (NewData == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #31
0
        /// <summary>
        /// 新增主体权限
        /// </summary>
        /// <param name="mainAuthority">主体权限对象</param>
        /// <param name="dt">最后修改时间</param>
        /// <param name="nid">新GUID</param>
        public void CreateMainAuthority(MainAuthority mainAuthority)
        {
            //获取当前时间
            DateTime dt = NewData.NewDate();
            //获取新的GUID
            string nid = NewData.NewGuid();
            //新增主体权限
            MainAuthorityDAL mainAuthorityDAL = new MainAuthorityDAL();

            mainAuthorityDAL.CreateMainAuthority(mainAuthority, dt, nid);
            //新增人员权限
            PersonnelAuthorityDAL personnelAuthorityDAL = new PersonnelAuthorityDAL();

            personnelAuthorityDAL.CreatePersonnelAuthority(nid);
        }
 public void cache_entry_should_support_this_type_subtype()
 {
     var newData = new NewData
     {
         stringValue = "qwerty",
         intValue = 12345,
         boolValue = true,
         stringArray = new[] { "q", "w", "e" },
         Dictionary = new Dictionary<string, int> { { "kq", 1 }, { "k2", 2 } }
     };
     var cacheEntry = new CacheEntry<SomeData> { Value = newData };
     var stream = ProtoBufSerializer.Serialize(cacheEntry);
     stream.Should().NotBeNull();
     ProtoBufSerializer.Deserialize<CacheEntry<SomeData>>(stream).ShouldBeEquivalentTo(cacheEntry, options => options.Excluding(x => x.Value));
 }