Beispiel #1
0
        public void GetBillsToShow()
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                List <BILL> rndBillsDB = GetSomeRandomBillsDB(context);

                foreach (var b in rndBillsDB)
                {
                    Customer customer = new Customer();

                    var accountDB  = context.ACCOUNTs.Where(c => c.ID == b.ACCOUNT_ID).FirstOrDefault();
                    var customerDB = context.CUSTOMERs.Where(c => c.ACCOUNT_ID == accountDB.ID).FirstOrDefault();

                    CustomerType customerType;
                    Address      address;

                    GetAddressAndCustomerTypeForCustomer(context, customerDB, out customerType, out address);

                    customer.Id      = customerDB.ID;
                    customer.Surname = customerDB.SURNAME;
                    customer.Name    = customerDB.NAME;
                    customer.Address = address;

                    Bills.Add(new Bill()
                    {
                        Id = b.ID, Number = b.NUMBER, Period = HelperMethod.GetFullMonthName(b.PERIOD), Date = b.DATE, Sum = b.SUM, Paid = b.PAID, Customer = customer
                    });
                }
            }
        }
Beispiel #2
0
 public Donation()
 {
     Id        = Guid.NewGuid().ToString();
     CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     Status    = DonationStatusEnum.Pending;
 }
        void check()
        {
            //если дочерний элементе детализации не синхронизирован укрупнением родительского элемента
            //то такой дочерний элемент доступен для синхронизации
            if ((HelperMethod.IsListNullOrEmpty(Укрупнения) ||
                 !Укрупнения.Any(pmw => ProjectManagementWork.GetProject(pmw) == ProjectStartSelectBiggerPE)))
            {
                if (!ProjectElement.Children.Any(ch => ch == ProjectStartSelectBiggerPE))
                {
                    _isSelectObjToSynch = true;
                    containsObjSync     = true;
                    _isObjectToSync     = true;
                }

                List <ReferenceObject> УкрупненияДетализации = Synchronization.GetSynchronizedWorks(ProjectElement.Parent, true);

                if (!HelperMethod.IsListNullOrEmpty(УкрупненияДетализации))
                {
                    PEForSync = УкрупненияДетализации.FirstOrDefault(pe => ProjectManagementWork.GetProject(pe) == ProjectStartSelectBiggerPE);
                }
            }
            else
            {
                _isSelectObjToSynch = false;
                _isObjectToSync     = false;
            }
        }
        public static Map LoadLvlMap(string mapname)
        {
            var mappath = Path.Combine(CONTENT_MANAGER.LocalRootPath, "map", mapname + ".lvl");

            if (!File.Exists(mappath))
            {
                return(null);
            }

            var mapdata = File.ReadAllText(mappath).Split('|');

            mappath = Path.Combine(CONTENT_MANAGER.LocalRootPath, "map", mapname + ".tmx");

            if (File.Exists(mappath))
            {
                var checksum = Convert.ToBase64String(HelperMethod.GetMD5CheckSum(mappath));
                if (string.Compare(checksum, mapdata[0]) != 0)
                {
                    return(LoadTmxMap(mapname));
                }
            }

            var map = JsonConvert.DeserializeObject <Map>(CompressHelper.UnZip(mapdata[1]));

            var interactableObj = from obj in map.Objects
                                  where !string.IsNullOrEmpty(obj.Value.OnActivate) || !string.IsNullOrEmpty(obj.Value.OnDeactivate)
                                  select obj.Value;

            map.InteractLink = ProcessInteractableObject(ref map, interactableObj);

            return(map);
        }
Beispiel #5
0
 public Vote()
 {
     Id        = Guid.NewGuid().ToString();
     CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     Status    = VoteStatusEnum.UpVote;
 }
Beispiel #6
0
        /// <summary>
        /// Gets the path of the last solution of the AStar algorithm.
        /// Will return a partial path if the algorithm has not finished yet.
        /// </summary>
        /// <returns>Returns null if the algorithm has never been run.</returns>
        public IEnumerable <(Direction, bool)> GetPath(Map map)
        {
            if (current != null)
            {
                var next = current;
                var path = new List <(Direction, bool)>();
                while (next.Parent != null)
                {
                    var parent  = next.Parent as GridNode;
                    var n       = next as GridNode;
                    var d       = HelperMethod.GetDirectionFromPointAtoPointB(parent.X, parent.Y, n.X, n.Y);
                    var mapCell = map.Tiles[map.GetCellIndex(n.X, n.Y)];

                    if (mapCell is Floor)
                    {
                        path.Add((d, false));
                    }
                    else
                    {
                        //path.Add((d, false));
                        var timeToDig = mapCell is Wall ? (mapCell as Wall).Heath : 1;
                        for (int i = 0; i < timeToDig; i++)
                        {
                            path.Add((d, true));
                        }
                    }

                    next = next.Parent;
                }
                path.Reverse();
                return(path);
            }
            return(null);
        }
Beispiel #7
0
        private IKVM.Reflection.Emit.MethodBuilder IKVMCreateStoreMethod(HelperMethod helper, IKVMCompilationContext context, IKVM.Reflection.Universe universe)
        {
            var builder = context.ExportsBuilder.DefineMethod(
                $"☣ {helper}",
                IKVMCompilationContext.HelperMethodAttributes,
                universe.Import(typeof(void)),
                new[]
            {
                universe.Import(typeof(uint)),             //Address
                universe.Import(this.Type.ToSystemType()), //Value
                universe.Import(typeof(uint)),             //Offset
                context.ExportsBuilder.AsType(),
            }
                );
            var il = builder.GetILGenerator();

            il.Emit(IKVM.Reflection.Emit.OpCodes.Ldarg_0);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Ldarg_2);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Add_Ovf_Un);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Ldarg_3);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Call, IKVMCreateRangeCheck(this.RangeCheckHelper, context, universe));
            il.Emit(IKVM.Reflection.Emit.OpCodes.Ldarg_3);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Ldfld, context.Memory);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Call, Runtime.UnmanagedMemory.IKVMStartGetter(universe));
            il.Emit(IKVM.Reflection.Emit.OpCodes.Add);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Ldarg_1);
            il.Emit(this.IKVMEmittedOpCode);
            il.Emit(IKVM.Reflection.Emit.OpCodes.Ret);

            return(builder);
        }
Beispiel #8
0
        public async Task <ServiceResult> AddAsync(AddUserContract user)
        {
            ServiceResult result = new ServiceResult();

            try
            {
                var check = await userRepository.GetCountAsync(userRepository.GetTable.Where(d => d.UserID.Equals(user.UserID)).AsQueryable());

                if (check == 0)
                {
                    tUser data = new tUser
                    {
                        UserID     = Guid.Parse(user.UserID.ToString()),
                        Password   = HelperMethod.encrypt(user.Password),
                        FirstName  = user.FirstName,
                        LastName   = user.LastName,
                        CreateDate = DateTime.Now,
                        UpdateDate = DateTime.Now
                    };
                    var save = await userRepository.AddAsync(data);

                    result = save.status;
                }
                else
                {
                    result.BadRequest("REGISTERED_ALREADY");
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.Error("ERROR", ex.Message);
            }
            return(result);
        }
 public BlogComment()
 {
     Id        = Guid.NewGuid().ToString();
     CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     Status    = BlogCommentStatusEnum.Published;
 }
Beispiel #10
0
        public static string GetBuildingImageForCustomerDetailsView(int buildingId)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                IMAGE_BUILDING imageDB     = null;
                string         imageName   = "";
                string         imagePath   = "";
                string         imagePathDB = "";
                string         folderName  = "";

                var buildingDB = context.BUILDINGs.Where(b => b.ID == buildingId).FirstOrDefault();

                if (buildingDB != null)
                {
                    imageDB = context.IMAGE_BUILDINGs.Where(i => i.ID == buildingDB.IMAGE_ID).FirstOrDefault();
                }

                if (imageDB != null)
                {
                    imagePathDB = imageDB.PATH.ToString();
                    folderName  = Path.GetFileName(Path.GetDirectoryName(imagePathDB));
                    imageName   = Path.GetFileName(imagePathDB);
                    imagePath   = "/Content/Images/TownBuildings/" + folderName + "/" + imageName;
                }
                else
                {
                    imagePath = "/Content/Images/EmptyImages/NoImageBuilding" + HelperMethod.UppercaseFirstLetter(HelperMethod.GetCurrentLanguage()) + ".jpg";
                }

                return(imagePath);
            }
        }
Beispiel #11
0
        public EditFilme(int codFilme)
        {
            InitializeComponent();
            try
            {
                FilmeCrud crud = new FilmeCrud();
                filme = crud.ObterFilme(codFilme);

                tituloTextBox.Text                = filme.Titulo;
                titulo_OriginalTextBox.Text       = filme.Titulo_Original;
                editQuantidade.Text               = filme.Quantidade.ToString();
                localizacaoTextBox.Text           = filme.Localizacao;
                idiomaTextBox.Text                = filme.Idioma;
                legendaTextBox.Text               = filme.Legenda;
                anoDeProducaoDateTimePicker.Value = filme.AnoDeProducao;
                ator_PrincipalTextBox.Text        = filme.Ator_Principal;
                classificacaoTextBox.Text         = filme.Classificacao;
                fornecedorTextBox.Text            = filme.Fornecedor;
                generoCmb1.SelectedItem           = filme.Genero;

                this.generoCmb1.DataSource = HelperMethod.EnumToList <Generos>();

                generoCmb1.SelectedItem = null;
                generoCmb1.SelectedText = "Selecione um gênero";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #12
0
        public async Task <ActionResult> UploadFile([FromForm] string fileName, string Path)
        {
            try
            {
                string uploadfile = HelperMethod.GetFileNamePath(fileName, Path);

                // only file which has permitted extension is allowed to upload
                if (!HelperMethod.IsPermittedFile(fileName))
                {
                    return(StatusCode(415, $"Only ( {string.Join(",", HelperMethod.PERMITTED_FILE_EXTENSION)} ) extension supported"));
                }

                BlobClient _blobClient = _blobContainerClient.GetBlobClient(fileName);

                // if file size to upload is greater than 5MB, discard and return
                long fileLength = new System.IO.FileInfo(uploadfile).Length;
                if ((fileLength / 1024) / 1024 > 5)
                {
                    return(StatusCode(413, "file size more than 5 MB is not allowed to upload"));
                }

                using var fileStream = System.IO.File.OpenRead(uploadfile);
                await _blobClient.UploadAsync(fileStream, true);

                fileStream.Close();

                // successfully created blob hence 201
                return(StatusCode(201, $"{fileName} file successfully uploaded"));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Beispiel #13
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            var dig = new OpenFileDialog();

            dig.Multiselect      = true;
            dig.Filter           = "sql files (*.sql)|*.sql";
            dig.RestoreDirectory = false;
            var rst = dig.ShowDialog();

            if (rst != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            // Init Cop Context
            tbSql.TabPages.Clear();
            Contexts.Clear();
            FileNames = dig.FileNames.ToList();
            foreach (var fpath in FileNames)
            {
                var fileName = HelperMethod.GetFileNameByPath(fpath);
                tbSql.TabPages.Add(fileName);
                Contexts.Add(new StyleCopContext(fpath));
            }

            InitRunContext();
            tbSql_SelectedIndexChanged(sender, EventArgs.Empty);
        }
Beispiel #14
0
        private void deleteBookingBTN_Click(object sender, EventArgs e)
        {
            //Which booking to delet
            int bookingId = GetIdOfSelectedRow(bookingHistoryDataGridView);

            //if bookingId is valid
            if (bookingId > 0)
            {
                //And if starttime is after current time
                if ((DateTime)bookingHistoryDataGridView[3,
                                                         HelperMethod.GetSelectedRowIndex(bookingHistoryDataGridView)
                    ].Value > DateTime.Now)
                {
                    //then remove booking
                    _dataAccess.DeleteBooking(bookingId);

                    RefreshTables();

                    deleteInfoLabel.Text = "Booking successfully removed";
                }
                else
                {
                    deleteInfoLabel.Text = "You cannot delete booking \nafter it started.";
                }
            }
        }
Beispiel #15
0
        public void GetSingleNews(int newsId)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                var    singleNewsDB    = context.NEWS.Find(newsId);
                string currentLanguage = HelperMethod.GetCurrentLanguage();

                var newsTitle = context.NEWS_TITLEs.
                                Where(t => t.NEWS_ID == singleNewsDB.ID).
                                Where(t => t.LANGUAGE == currentLanguage).
                                FirstOrDefault().TITLE;

                var chaptersDB = context.NEWS_CHAPTERs.
                                 Where(c => c.NEWS_ID == newsId).
                                 Where(c => c.LANGUAGE == currentLanguage).
                                 ToList();

                SingleNews.Title = newsTitle;
                SingleNews.Date  = singleNewsDB.DATE;

                foreach (var ch in chaptersDB)
                {
                    SingleNews.NewsChapters.Add(new NewsChapter()
                    {
                        Id = ch.ID, Text = ch.TEXT
                    });
                }
            }
        }
        private MethodBuilder CreateStoreMethod(HelperMethod helper, CompilationContext context)
        {
            var builder = context.ExportsBuilder.DefineMethod(
                $"☣ {helper}",
                CompilationContext.HelperMethodAttributes,
                typeof(void),
                new[]
            {
                typeof(uint),             //Address
                this.Type.ToSystemType(), //Value
                typeof(uint),             //Offset
                context.ExportsBuilder.AsType(),
            }
                );
            var il = builder.GetILGenerator();

            il.Emit(OpCodes.Ldarg_0);
            il.Emit(OpCodes.Ldarg_2);
            il.Emit(OpCodes.Add_Ovf_Un);
            il.Emit(OpCodes.Ldarg_3);
            il.Emit(OpCodes.Call, context[this.RangeCheckHelper, CreateRangeCheck]);
            il.Emit(OpCodes.Ldarg_3);
            il.Emit(OpCodes.Ldfld, context.Memory);
            il.Emit(OpCodes.Call, Runtime.UnmanagedMemory.StartGetter);
            il.Emit(OpCodes.Add);
            il.Emit(OpCodes.Ldarg_1);
            il.Emit(this.EmittedOpCode);
            il.Emit(OpCodes.Ret);

            return(builder);
        }
Beispiel #17
0
 public Category()
 {
     Id        = Guid.NewGuid().ToString();
     CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     Status    = CategoryStatusEnum.Show;
 }
Beispiel #18
0
 public ProjectImage()
 {
     Id        = Guid.NewGuid().ToString();
     CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     Status    = ProjectImageStatusEnum.Show;
 }
Beispiel #19
0
 public Follow()
 {
     Id        = Guid.NewGuid().ToString();
     CreatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     UpdatedAt = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     Status    = FollowStatusEnum.Followed;
 }
 public Project()
 {
     Id          = Guid.NewGuid().ToString();
     CreatedAt   = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     UpdatedAt   = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     CurrentFund = 0;
     Status      = ProjectStatusEnum.Establishing;
 }
        public void GetDataForUtility(string utilityName)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                var utilityDB   = context.UTILITYs.Where(u => u.NAME == utilityName).FirstOrDefault();
                var unitDB      = context.UNITs.Find(utilityDB.UNIT_ID);
                var utilitiesDB = context.UTILITYs.ToList();


                Unit.Id   = unitDB.ID;
                Unit.Name = unitDB.NAME;

                Utility.Id           = utilityDB.ID;
                Utility.Name         = utilityDB.NAME;
                Utility.Price        = utilityDB.PRICE;
                Utility.ResourceName = GetResourceNameForUtility(utilityDB.NAME);
                Utility.ImagePath    = HelperMethod.GetUtilityImage(utilityDB.ID);

                if (utilityDB.USAGEFORSTANDARTPRICE != null)
                {
                    Utility.UsageForStandartPrice = (decimal)utilityDB.USAGEFORSTANDARTPRICE;
                }
                if (utilityDB.BIGUSAGEPRICE != null)
                {
                    Utility.BigUsagePrice = (decimal)utilityDB.BIGUSAGEPRICE;
                }

                Utility.Unit = Unit;

                foreach (var u in utilitiesDB)
                {
                    if (u.NAME != Utility.Name)
                    {
                        Utilities.Add(new Utility()
                        {
                            Name = u.NAME, ResourceName = GetResourceNameForUtility(u.NAME)
                        });
                    }
                }

                var           meterTypesDB  = context.METER_TYPEs.Where(mt => mt.UTILITY_ID == Utility.Id).ToList();
                var           metersDB      = context.METERs.ToList();
                HashSet <int> meterTypesIds = new HashSet <int>();

                foreach (var m in meterTypesDB)
                {
                    meterTypesIds.Add(m.ID);
                }

                foreach (var m in metersDB)
                {
                    if (meterTypesIds.Contains(m.METER_TYPE_ID))
                    {
                        MeterQty += 1;
                    }
                }
            }
        }
Beispiel #22
0
            public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
            {
                var dictionary = (DynamicHelper)Value;

                if (!dictionary.Methods.ContainsKey(binder.Name))
                {
                    Logger.Error("Unable to find method [{0}]", binder.Name);
                    return(null);
                }

                var          helperMethodInstanceList = dictionary.Methods[binder.Name];
                HelperMethod helperMethodInstance     = null;

                // Find correct method
                foreach (var helperMethod in helperMethodInstanceList)
                {
                    var parameterInfos = helperMethod.Method.GetParameters();
                    if (helperMethod.Method.GetParameters().Length == args.Length)
                    {
                        bool isMethodFound = true;
                        for (int i = 0; i < parameterInfos.Length; i++)
                        {
                            var parameterInfo = parameterInfos[i];
                            var argumentType  = args[i].RuntimeType ?? parameterInfo.ParameterType;
                            if (!parameterInfo.ParameterType.IsAssignableFrom(argumentType))
                            {
                                isMethodFound = false;
                            }
                        }
                        if (isMethodFound)
                        {
                            helperMethodInstance = helperMethod;
                            break;
                        }
                    }
                }

                if (helperMethodInstance == null)
                {
                    // Todo, write parameters
                    throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Unable to find target method [{0}]", binder.Name));
                }

                var methodParams = new Expression[args.Length];

                for (int i = 0; i < args.Length; i++)
                {
                    methodParams[i] = args[i].Expression;
                }

                var methodToString = typeof(TemplateWriter).GetMethod("ToString");

                var computeResult =
                    Expression.Call(Expression.Call(Expression.Constant(helperMethodInstance.Template), helperMethodInstance.Method, methodParams),
                                    methodToString);

                return(new DynamicMetaObject(computeResult, BindingRestrictions.GetTypeRestriction(Expression, LimitType)));
            }
Beispiel #23
0
        public override void Update(GameTime gameTime)
        {
            if (HelperMethod.IsKeyPress(Keys.Escape, CONTENT_MANAGER.CurrentInputState.keyboardState, CONTENT_MANAGER.LastInputState.keyboardState))
            {
                CONTENT_MANAGER.gameInstance.Exit();
            }

            canvas.Update(gameTime, CONTENT_MANAGER.CurrentInputState, CONTENT_MANAGER.LastInputState);
        }
        public ActionResult EditMeterData(int meterItemId)
        {
            var model = new MeterItemModel();

            model.GetMeterAndDataToEdit(meterItemId);

            ViewBag.CurrentCulture = HelperMethod.GetCurrentLanguage();

            return(View(model));
        }
Beispiel #25
0
        public ActionResult ShowTemperatureChart()
        {
            var model = new AddressModel();

            ViewBag.TownList = model.GetTowns();

            ViewBag.ImageIconPath = HelperMethod.GetTemperatureIconImage();

            return(View());
        }
Beispiel #26
0
 /// <summary>
 /// Проверка на возможность смены флага
 /// </summary>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public bool CanExecuteSyncResCommand(object parameter)
 {
     if (HelperMethod.IsListNullOrEmpty(_detailingProjects))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Beispiel #27
0
        //网校接口调课程
        public static List <Entity.Respose.olschoolsubject> GetOLSchoolAllList()
        {
            HelperMethod p        = new HelperMethod();
            string       path     = HelperAppSet.getAppSetting("olschoolpath");
            string       fullpath = path + "/Member/GetOrgCourse?classid=9";
            var          hrr      = HttpHelper.Singleton.HttpGet(fullpath);
            string       json     = hrr.Result.Data;

            Entity.Respose.GTXResult result = Untity.HelperJson.DeserializeObject <Entity.Respose.GTXResult>(json);
            return(Untity.HelperJson.DeserializeObject <List <Entity.Respose.olschoolsubject> >(HelperDataCvt.objToString(result.Data)));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,Description,CreatedAt,UpdatedAt,DeletedAt,Status")] Category category)
 {
     if (!ModelState.IsValid)
     {
         return(View(category));
     }
     category.UpdatedAt        = HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow);
     _db.Entry(category).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Beispiel #29
0
Datei: zoo.cs Projekt: ztgz/MyZoo
        /* ----------------- Helper Methods ------------------------*/
        private int GetIdOfSelectedRow()
        {
            int row = HelperMethod.GetSelectedRowIndex(searchDataGridView);

            if (row >= 0)
            {
                return((int)searchDataGridView[0, row].Value);
            }

            return(-1);
        }
        public IndexView_test()
        {
            //_driver = new ChromeDriver();
            _driver = new PhantomJSDriver();
            help    = new HelperMethod(_driver);

            _context    = new ApplicationDbContext();
            _unitOfWork = new UnitOfWork(_context);
            userRepo    = new UsersRepository(_context);
            baseURL     = Globals.Url_Localhost;
        }