Пример #1
0
        public ActionResult ResetPassword(ResetPasswordViewModel model)
        {
            try
            {
                UserDto   dto = new UserDto();
                Message   msg = new Message();
                DataTable dt  = CMSService.SelectOne("User", "CMSUser", "UserId=" + model.UserId);

                foreach (DataRow dr in dt.Rows)
                {
                    dto = UserMapping.getDTO(dr);
                    dto.UserPassword = CommonTools.ToMd5(model.UserPassword);
                }
                string JsonString = JsonHelper.JsonSerializerBySingleData(dto);
                msg = CMSService.Update("User", JsonString);
                msg.MessageStatus = "Success";
                msg.MessageInfo   = "密码修改成功了";
                ViewBag.Status    = msg.MessageStatus;
                // TODO: Add delete logic here

                return(RedirectTo("/User/Index", msg.MessageInfo));
            }

            catch
            {
                Message msg = new Message();
                msg.MessageStatus = "Error";
                msg.MessageInfo   = "操作出错了";
                ViewBag.Status    = msg.MessageStatus;
                ViewBag.msg       = msg.MessageInfo;
                return(View());
            }
        }
            public void ParametrizedCtor()
            {
                var target = new UserMapping("1", "2");

                Assert.AreEqual("1", target.Name);
                Assert.AreEqual("2", target.ExternalId);
            }
Пример #3
0
        public ActionResult PartialInfo(string username)
        {
            UserViewModel model = new UserViewModel();
            DataTable     dt    = CMSService.SelectOne("User", "CMSUser", "UserName='******'");

            foreach (DataRow dr in dt.Rows)
            {
                UserDto dto = new UserDto();
                dto                    = UserMapping.getDTO(dr);
                model.UserId           = dto.UserId;
                model.UserName         = dto.UserName;
                model.UserRoles        = MyService.RolesIdToRolesName(dto.UserRoles);
                model.UserEmail        = dto.UserEmail;
                model.UserTelephone    = dto.UserTelephone;
                model.UserStatus       = dto.UserStatus;
                model.UserRegisterTime = dto.UserRegisterTime;
                model.UserRealName     = dto.UserRealName;
                model.UserSex          = dto.UserSex;
                model.UserBirthday     = dto.UserBirthday.ToShortDateString();
                if (String.IsNullOrEmpty(dto.UserImg))
                {
                    model.UserImg = "/UserImg/Img/default_48.jpg";
                }
                else
                {
                    model.UserImg = dto.UserImg + "_48.jpg";
                }
            }
            ViewData["Sex"] = MyService.GetSexSelectList();
            return(View(model));
        }
Пример #4
0
        public async Task <List <UserMapping> > GetUserMappings()
        {
            var table = await GetCloudTable(_appSettings.StorageConnectionString, _appSettings.MappingTableContainerName);

            TableContinuationToken token = null;

            var entities = new List <TableEntityAdapter <UserMapping> >();

            TableQuery <TableEntityAdapter <UserMapping> > query = new TableQuery <TableEntityAdapter <UserMapping> >();

            do
            {
                var queryResult = await table.ExecuteQuerySegmentedAsync(query, token);

                entities.AddRange(queryResult.Results);
                token = queryResult.ContinuationToken;
            } while (token != null);

            // create list of objects from the storage entities
            var userMappings = new List <UserMapping>();

            foreach (var entity in entities)
            {
                UserMapping toBeAdded = entity.OriginalEntity;
                toBeAdded.RowKey = entity.RowKey;
                userMappings.Add(toBeAdded);
            }

            return(userMappings);
        }
Пример #5
0
        public async Task <User> GetUserInformationAsync(Guid userId)
        {
            if (userId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            IEnumerable <Models.Repository.Card> dtoCards;
            IEnumerable <Card> cards;
            IEnumerable <Models.Repository.Address> dtoAddresses;
            var dtoUser = await userRepository.GetAsync(userId);

            var user    = UserMapping.ConvertDtoUser(dtoUser);
            var cardIds = await userCardRepository.ListIdsAsync(dtoUser.UserId);

            var addressIds = await userAddressesRepository.ListIdsAsync(dtoUser.UserId);

            if (cardIds != null)
            {
                dtoCards = await cardRepository.ListAsync(cardIds);

                cards = await MapAddressesToCardsAsync(dtoCards);

                user.CreditCards = cards;
            }
            if (addressIds != null)
            {
                dtoAddresses = await addressRepository.ListAsync(addressIds);

                user.Address = AddressMapping.ConvertDtoAddressToAddress(dtoAddresses.FirstOrDefault());
            }

            return(user);
        }
Пример #6
0
        public ProfileMainViewModel GetProfileInfo(string identityName)
        {
            User user = context.Users.Include(u => u.Gender).FirstOrDefault(u => u.Email == identityName) ??
                        context.Users.Include(u => u.Gender).FirstOrDefault(u => u.UserName == identityName);

            return(UserMapping.MapProfileFromDb(user));
        }
Пример #7
0
        private void DoAddition(DialogConfigBLEntities entities, AntragItem item, AntragItem.Item.SubItem x, List <string> errors)
        {
            var existingItem = entities.UserMappings.Find(x.handyNummer, item.Data.datenbankId);

            if (existingItem == null)
            {
                var um = new UserMapping()
                {
                    DatenbankId = item.Data.datenbankId,
                    HandyNummer = x.handyNummer,
                    IsAdmin     = x.isAdmin,
                    IsGesperrt  = x.isGesperrt,
                    Name        = x.name,
                    Vorname     = x.vorname,
                    Module      = x.module,
                    ShortName   = x.shortName
                };
                entities.UserMappings.Add(um);
                try
                {
                    entities.SaveChanges();
                }
                catch (Exception ex)
                {
                    errors.Add(string.Format("ADDITION: Ausnahme: '{2}' für HandyNummer '{0}' und DatanbankId {1}", ex.Message, x.handyNummer, item.Data.datenbankId));
                }
            }
            else
            {
                errors.Add(string.Format("ADDITION: Einen Eintrag in Tabelle UserMappings mit HandyNummer '{0}' und DatanbankId {1} existiert bereits und keine Duplizierungen sind erlaubt!", x.handyNummer, item.Data.datenbankId));
            }
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (UserMapping != null)
         {
             hashCode = hashCode * 59 + UserMapping.GetHashCode();
         }
         if (UserDefault != null)
         {
             hashCode = hashCode * 59 + UserDefault.GetHashCode();
         }
         if (UserEnableDefaultMapping != null)
         {
             hashCode = hashCode * 59 + UserEnableDefaultMapping.GetHashCode();
         }
         if (RequireValidation != null)
         {
             hashCode = hashCode * 59 + RequireValidation.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #9
0
 public dynamic CreateUsersWithListInput([FromBody] List <UserViewModel> userVOList)
 {
     try
     {
         foreach (var addedUser in userVOList)
         {
             var user = new User();
             UserMapping.MapUser(addedUser, user);
             _dbContext.Users.Add(user);
             _dbContext.SaveChanges();
             var userSecurity = new UserSecurity()
             {
                 UserID        = user.KeyID,
                 AllowedUserID = user.KeyID
             };
             _dbContext.UserSecurities.Add(userSecurity);
             _dbContext.SaveChanges();
         }
         return("successful operation");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private bool IsRuleApplicable(RichIdentity sourceUserIdentity, UserMapping rule, bool leftToRight)
        {
            string fromAlias  = (leftToRight ? rule.LeftUser.Alias : rule.RightUser.Alias);
            string fromDomain = (leftToRight ? rule.LeftUser.Domain : rule.RightUser.Domain);
            string toAlias    = (leftToRight ? rule.RightUser.Alias : rule.LeftUser.Alias);

            if (string.IsNullOrEmpty(fromAlias) || string.IsNullOrEmpty(toAlias))
            {
                Debug.Assert(false, "Alias in a user mapping rule should always be an Non-empty string");
                return(false);
            }

            bool aliasRuleIsApplicable = (fromAlias.Equals(UserIdentityMappingConfigSymbols.ANY, StringComparison.OrdinalIgnoreCase) ||
                                          fromAlias.Equals(sourceUserIdentity.Alias ?? string.Empty, StringComparison.OrdinalIgnoreCase));

            if (!aliasRuleIsApplicable)
            {
                return(false);
            }

            bool domainRuleIsApplicable = (string.IsNullOrEmpty(fromDomain) ||
                                           fromDomain.Equals(UserIdentityMappingConfigSymbols.ANY, StringComparison.OrdinalIgnoreCase) ||
                                           fromDomain.Equals(sourceUserIdentity.Domain ?? string.Empty, StringComparison.OrdinalIgnoreCase));

            return(aliasRuleIsApplicable && domainRuleIsApplicable);
        }
        /// <summary>
        /// Returns true if OrgApacheSlingServiceusermappingImplServiceUserMapperImplProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingServiceusermappingImplServiceUserMapperImplProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingServiceusermappingImplServiceUserMapperImplProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     UserMapping == other.UserMapping ||
                     UserMapping != null &&
                     UserMapping.Equals(other.UserMapping)
                     ) &&
                 (
                     UserDefault == other.UserDefault ||
                     UserDefault != null &&
                     UserDefault.Equals(other.UserDefault)
                 ) &&
                 (
                     UserEnableDefaultMapping == other.UserEnableDefaultMapping ||
                     UserEnableDefaultMapping != null &&
                     UserEnableDefaultMapping.Equals(other.UserEnableDefaultMapping)
                 ) &&
                 (
                     RequireValidation == other.RequireValidation ||
                     RequireValidation != null &&
                     RequireValidation.Equals(other.RequireValidation)
                 ));
        }
        /// <summary>
        /// Method to create/update change request
        /// </summary>
        /// <Param>ticket : Ticket to be added or updated</Param>
        /// <Param>action : Insert/Update/Delete</Param>
        /// <returns>Ticket ID</returns>
        public JsonResult AddUser(UserMapping user, Operation action, UserMapping oldUser = null, bool?activation = null)
        {
            string result = null;

            try
            {
                //If it is a new User
                if (action == Operation.Insert)
                {
                    result = InsertUser(user);
                }
                else if (action == Operation.Delete)
                {
                    result = DeactivateUser(user, activation, false);
                }
                else
                {
                    result = EditUser(user, oldUser);
                }
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #13
0
        public async Task InsertAsync(UserMapping entity)
        {
            string sql = @"
INSERT INTO usermapping(UserId, WxUserId, OpenId, AppId, CreateTime, CreateBy) 
VALUE(@UserId, @WxUserId, @OpenId, @AppId, @CreateTime, @CreateBy);";
            await Instance.ExecuteAsync(sql, entity);
        }
Пример #14
0
        public async Task <Rental> GetRentalAsync(Guid rentalId, CancellationToken cancellationToken = default)
        {
            if (rentalId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(rentalId));
            }

            var dtoRental = await rentalRepository.GetAsync(rentalId, cancellationToken);

            var dtoItemRentalDetails = await itemRentalDetailsRepository.GetAsync(dtoRental.ItemRentalDetailsId, cancellationToken);

            var dtoItem = itemRepository.GetAsync(dtoItemRentalDetails.ItemId, cancellationToken);
            var dtoUser = userRepository.GetAsync(dtoRental.UserId, cancellationToken);

            if (dtoRental == null)
            {
                throw new NullReferenceException(nameof(dtoRental));
            }

            var rental            = dtoRental.ConvertDtoRentalToRental();
            var user              = UserMapping.ConvertDtoUser(await dtoUser);
            var itemRentalDetails = ItemMapping.ConvertItemRentalDetails(dtoItemRentalDetails, await dtoItem);

            rental.User = user;
            rental.ItemRentalDetails = itemRentalDetails;

            return(rental);
        }
Пример #15
0
        // 返回用户对应的角色, 在实际中, 可以从SQL数据库中读取用户的角色信息
        private string GetRole(string UserName)
        {
            if (string.IsNullOrEmpty(UserName))
            {
                return("游客");
            }
            else
            {
                UserDto   dto = new UserDto();
                DataTable dt  = CMSService.SelectOne("User", "CMSUser", "UserName='******'");
                foreach (DataRow dataRow in dt.Rows)
                {
                    dto = UserMapping.getDTO(dataRow);
                }


                string   userRoles = "";
                string   roleName  = "";
                string   s         = dto.UserRoles;
                string[] sArray    = s.Split(',');
                foreach (string i in sArray)
                {
                    DataTable dataTable = CMSService.SelectOne("Role", "CMSRole", "RoleId=" + int.Parse(i));
                    foreach (DataRow dataRow in dataTable.Rows)
                    {
                        RoleDto roleDto = new RoleDto();
                        roleDto  = RoleMapping.getDTO(dataRow);
                        roleName = roleDto.RoleName;
                    }
                    userRoles = userRoles + roleName + ",";
                    userRoles = userRoles.Substring(0, userRoles.Length - 1);
                }
                return(userRoles);
            }
        }
            public void DefaultCtor()
            {
                var target = new UserMapping();

                Assert.IsNotNull(target);
                Assert.IsNull(target.Name);
                Assert.IsNull(target.ExternalId);
            }
Пример #17
0
        public static IMapping CreatMapping(string DtoName)
        {
            IMapping Mapping = null;

            if (DtoName == "User")
            {
                Mapping = new UserMapping();
            }
            if (DtoName == "Role")
            {
                Mapping = new RoleMapping();
            }
            if (DtoName == "Category")
            {
                Mapping = new CategoryMapping();
            }
            if (DtoName == "Article")
            {
                Mapping = new ArticleMapping();
            }
            if (DtoName == "Image")
            {
                Mapping = new ImageMapping();
            }
            if (DtoName == "Customer")
            {
                Mapping = new CustomerMapping();
            }
            if (DtoName == "Tizhi")
            {
                Mapping = new TizhiMapping();
            }
            if (DtoName == "Xueya")
            {
                Mapping = new XueyaMapping();
            }
            if (DtoName == "Jianyan")
            {
                Mapping = new JianyanMapping();
            }
            if (DtoName == "Chufang")
            {
                Mapping = new ChufangMapping();
            }
            if (DtoName == "Jixiao")
            {
                Mapping = new JixiaoMapping();
            }
            if (DtoName == "Fankui")
            {
                Mapping = new FankuiMapping();
            }
            if (DtoName == "Yuyue")
            {
                Mapping = new YuyueMapping();
            }
            return(Mapping);
        }
Пример #18
0
 private void ValidateUserMapping(PluginProfileErrorCollection errors)
 {
     if (UserMapping.Select(x => x.Key.ToLower()).Distinct().Count() != UserMapping.Count)
     {
         errors.Add(new PluginProfileError {
             FieldName = "user-mapping", Message = "Can't map a TFS user to TargetProcess user twice."
         });
     }
 }
Пример #19
0
        private UserLogic GetTestSubject()
        {
            var mapperInstance = new UserMapping();

            _userMappingMock.Setup(mock => mock.ToUserResponseDto(It.IsAny <UserModel>())).Returns((UserModel userModel) => mapperInstance.ToUserResponseDto(userModel));
            _userMappingMock.Setup(mock => mock.ToUserModel(It.IsAny <UserDto>())).Returns((UserDto userDto) => mapperInstance.ToUserModel(userDto));

            return(new UserLogic(_offreContextMock.Object, _userMappingMock.Object));
        }
Пример #20
0
        public async Task CreateNewUserAccountAsync(User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            await userRepository.AddAsync(UserMapping.CreateDtoUser(user));
        }
Пример #21
0
        public async Task <IEnumerable <User> > GetAllUsersInTenantAsync(Guid tenantId, CancellationToken cancellationToken = default)
        {
            NullCheckHelpers.EnsureArgumentIsNotNullOrEmpty(tenantId);

            var userIds = await tenantUserRepository.ListAsync(tenantId, cancellationToken);

            var users = await userRepository.GetUsersAsync(userIds, cancellationToken);

            return(UserMapping.ConvertDtoUsers(users));
        }
Пример #22
0
 public UserMappingView(UserMapping userMapping)
 {
     Id            = userMapping.Id;
     GuildId       = userMapping.GuildId.ToString();
     UserA         = userMapping.UserA.ToString();
     UserB         = userMapping.UserB.ToString();
     Reason        = userMapping.Reason;
     CreatedAt     = userMapping.CreatedAt;
     CreatorUserId = userMapping.CreatorUserId.ToString();
 }
Пример #23
0
        public IQueryable <User> GetUsers()
        {
            _logger.Info("START :: UserService.GetUsers()");
            IQueryable <Entities.User> userEntities = _repository.Query <Entities.User>();

            IQueryable <User> users = UserMapping.Map(userEntities);

            _logger.Info("END :: UserService.GetUsers()");
            return(users);
        }
Пример #24
0
        public static string UserIdToName(string strWhere)
        {
            UserDto   dto = new UserDto();
            DataTable dt  = CMSService.SelectOne("User", "CMSUser", strWhere);

            foreach (DataRow dr in dt.Rows)
            {
                dto = UserMapping.getDTO(dr);
            }
            return(dto.UserName);
        }
Пример #25
0
        public override Task OnConnected()
        {
            var name = User.Identity.Name;

            if (UserMapping.GetConnections(name).Count() < 0)
            {
                Clients.AllExcept(Context.ConnectionId).userConnect(name);
            }
            Clients.Caller.connectedUsers(UserMapping.Content().Union(new[] { name }));
            return(base.OnConnected());
        }
Пример #26
0
        public void CreateDiscount_WhenProvidedValidData_ShouldCreateNewUser()
        {
            _fixture.Customize(new ValidUserObjectCreator("Person", "One", "*****@*****.**", "8765432556", true));
            Entities.User  userEntity   = _fixture.Create <Entities.User>();
            Contracts.User userContract = UserMapping.Map(userEntity);

            Contracts.User user = _userService.CreateUser(userContract);

            Assert.IsNotNull(user);
            Assert.AreEqual(user.FirstName, userEntity.FirstName);
        }
Пример #27
0
        public void CreateDtoUser()
        {
            var dtoUser = UserMapping.CreateDtoUser(user);

            Assert.IsType <User>(dtoUser);
            Assert.NotNull(dtoUser.Email);
            Assert.NotNull(dtoUser.FirstName);
            Assert.NotNull(dtoUser.LastName);
            Assert.NotNull(dtoUser.UserName);
            Assert.NotNull(dtoUser.Password);
        }
Пример #28
0
        public void ConvertDtoUser()
        {
            var user = UserMapping.ConvertDtoUser(dtoUser);

            Assert.IsType <Models.API.User>(user);
            Assert.Equal(user.UserId, userId);
            Assert.NotNull(user.Email);
            Assert.NotNull(user.FirstName);
            Assert.NotNull(user.LastName);
            Assert.NotNull(user.UserName);
        }
Пример #29
0
        public IHttpActionResult CreateUser(UserModel user)
        {
            var mappedUser = UserMapping.Map(user);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Ok(_userService.CreateUser(mappedUser)));
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            #region "Mappers"
            UserMapping.Map(modelBuilder);
            #endregion

            #region "Seeders"
            UserSeed.Seed(modelBuilder);
            #endregion
        }
Пример #31
0
    /// <summary>
    /// Checks if the user may login and sets the Session object to check later which type of user is currently logged in.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Login_Click(object sender, EventArgs e)
    {
        UserMapping userMapping = new UserMapping();
        LoginMapping loginMapping = new LoginMapping();
        LoginCheck.LoggedIn = false;
        User user = new User();
        user.Email = logUserName.Text;
        user.Pass = logPassword.Text;

        try
        {
            user = loginMapping.mapFromService(service.Login2(loginMapping.mapToService(user)));

            if (user.MayLogin)
            {
                user = userMapping.mapFromService(service.Login2(userMapping.mapToService(user)));
                Session["UserObject"] = user;
                Session["UserObjectOwn"] = userMapping.mapFromService(service.Login2(userMapping.mapToService(user)));
                userOwn = (User)Session["UserObjectOwn"];

                LoginCheck.LoggedIn = true;
                if (userOwn.UserCompany.CompanyID == 0 && userOwn.UserCv.CvID == 0)
                {
                    if (userOwn.Email.Equals("*****@*****.**"))
                        Response.Redirect("dashboardRamon.aspx");
                    else if (userOwn.Email.Equals("*****@*****.**"))
                        Response.Redirect("dashboardBrian.aspx");
                    else if (userOwn.Email.Equals("*****@*****.**"))
                        Response.Redirect("dashboardDennis.aspx");
                    else if (userOwn.Email.Equals("*****@*****.**"))
                        Response.Redirect("dashboardJan.aspx");
                }
                else
                    Response.Redirect("home.aspx");
            }
            else
            {
                errorMessage.InnerHtml = "<span>Onjuiste inloggegevens</span>";
            }
        }
        catch (System.Net.WebException)
        {
            errorMessage.InnerHtml = "<span>Er kon geen verbinding gemaakt worden met de webservice<br />Probeer het later nog eens</span>";
        }
    }
Пример #32
0
 /// <summary>
 /// Gets all the information this page needs.
 /// </summary>
 public override void CheckTypeAndFill()
 {
     if (!LoginCheck.LoggedIn || user == null)
         Response.Redirect("login.aspx");
     else if (user.UserCv.CvID == 0 && user.UserCompany.CompanyID != 0)
     {
         service = new MatchyService();
         UserMapping mapping = new UserMapping();
         CvMapping cvMapping = new CvMapping();
         user = mapping.mapFromService(service.GetUser(Int32.Parse(profileId))[0]);
         user.UserCv = cvMapping.mapFromService(service.GetCv(getURL())[0]);
         Session["UserObject"] = user;
     }
     else
     {
         var contentPlaceHolder = (ContentPlaceHolder)Master.FindControl("contentPlaceholderHeader");
         var profileLink = (LinkButton)contentPlaceHolder.FindControl("profileLink");
         profileLink.CssClass = "active";
     }
 }
Пример #33
0
    protected void store_Click(object sender, EventArgs e)
    {
        Guid id = new Guid(Hidden1.Value);

        UserMapping oldMap = UserMapping_S.UserMapWithMeterBuilding("Faculty Housing", Convert.ToInt32(metId.Text));

            if (oldMap == null)
            {

                UserMapping map = new UserMapping();
                map.MeterId = Convert.ToInt32(metId.Text);
                map.MeterType = meterTypeList.Text;
                map.UserId = id;

                bool upd = UserMapping_S.UpdateMap(map);
                //Session["Apartment"] = oldMap.Apartment;
                //Session["MeterType"] = map.MeterId.ToString();

                if (upd == true)
                {
                    green0.Text = "Updated";
                    apartmentText.Text = ""; metId.Text = "";
                }
                else
                {
                    green0.Text = "Something went wrong!";
                }

            }
            else
            {
                green0.Text = "Already Exists";
            }
    }
Пример #34
0
 /// <summary>
 /// The standard changeURL for profilescreen
 /// </summary>
 public virtual void changeURL()
 {
     int parseable;
     if (url.Contains("="))
     {
         if(url.Contains("profile="))
             profileId = Request.QueryString["profile"];
         else
             profileId = Request.QueryString["company"];
     }
     service = new MatchyService();
     UserMapping mapping = new UserMapping();
     if (Int32.TryParse(profileId, out parseable))
     {
         try
         {
             user = mapping.mapFromService(service.GetUser(Int32.Parse(profileId))[0]);
             Session["UserObject"] = user;
         }
         catch
         {
             if (user.UserCv.CvID != 0)
                 Response.Redirect("profile.aspx?profile=" + string.Format(user.ProfileId.ToString()));
             else
                 Response.Redirect("company.aspx?company=" + string.Format(user.ProfileId.ToString()));
         }
     }
     else
     {
         if (user.UserCv.CvID != 0)
             Response.Redirect("profile.aspx?profile=" + string.Format(user.ProfileId.ToString()));
         else
             Response.Redirect("company.aspx?company=" + string.Format(user.ProfileId.ToString()));
     }
 }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        UserLogin confirmObj = new UserLogin();

        confirmObj.Building = GridView1.SelectedRow.Cells[0].Text;
        confirmObj.Apartment = GridView1.SelectedRow.Cells[1].Text;
        confirmObj.EMail = GridView1.SelectedRow.Cells[2].Text;
        if (GridView1.SelectedRow.Cells[3].Text != "&nbsp;")
        {
            confirmObj.Mobile = GridView1.SelectedRow.Cells[3].Text;
        }
        confirmObj.UserName = confirmObj.Apartment + "-" + confirmObj.Building;

        MD5 md5 = new MD5CryptoServiceProvider();
        confirmObj.Password = DateTime.Now.ToString("ddmmyyyyHHmm");
        string pass = confirmObj.Password;

        md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(confirmObj.Password));
        byte[] result = md5.Hash;
        StringBuilder strBuilder = new StringBuilder();
        for (int i = 0; i < result.Length; i++)
        {
            //change it into 2 hexadecimal digits
            //for each byte
            strBuilder.Append(result[i].ToString("x2"));
        }

        confirmObj.Password = strBuilder.ToString();

          bool stc =  UserLogin_S.InsertUser(confirmObj);
          if (stc == true)
          {
          UserLogin ul = UserLogin_S.Loging(confirmObj.UserName);

          if (ul != null)
          {
              UserMapping map = new UserMapping();

              map.Apartment = confirmObj.Apartment;
              map.Building = confirmObj.Building;
              map.UserId = ul.UserId;

              bool stst = UserMapping_S.UpdateUserIdinMap(map);

              if (stst == true)
              {
                  SendingMails.SendRegistrationMail(confirmObj, pass);

                  UserRegisteration regObj = new UserRegisteration();

                  regObj.Building = GridView1.SelectedRow.Cells[0].Text;
                  regObj.Apartment = GridView1.SelectedRow.Cells[1].Text;
                  regObj.Status = "aprooved";

                  bool stc2 = User_Registration.UpdateRequest(regObj);
                  if (stc2 == true)
                  {
                      msg.Text = "Registered + Mail sent";
                  }
              }
              else
              {
                  msg.Text = "Cannot update mapping table";
              }
          }
         else
         {
             msg.Text = "Something went wrong in-between";
         }

         GridView1.DataBind();
          }
          else
          {
          msg.Text = "Cannot register";
          }
    }
Пример #36
0
    /// <summary>
    /// Checks if all the fields were Valid and sends it to the service to add the user if valid.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Reg_Click(object sender, EventArgs e)
    {
        if (IsGroupValid(regButton.ValidationGroup))
        {
            UserMapping mapping = new UserMapping();
            User userRegister = new User();
            UserCv cv = null;
            UserCompany company = null;
            userRegister.Email = regMail.Text;
            userRegister.Pass = regPassword.Text;
            userRegister.BirthDay = YearTemp.Text + "-" + MonthTemp.Text + "-" + DayTemp.Text;

            if (cv_companyRadio.SelectedValue.Equals("Particulier"))
            {
                cv = new UserCv();
                cv.Name = regFN.Text + " " + regLN.Text;
                cv.Age = Convert.ToInt32(cvAgeDropDown.SelectedValue);
                cv.City = cvCity.Text;
                cv.Email = userRegister.Email;
                cv.Province = cvProvince.Text;
                cv.Sex = (cvSexOption.SelectedValue).Substring(0, 1);
                cv.Personal = cvPersonal.Text;
                cv.Interests = cvInterests.Text;

                Education educationLevel = new Education();
                educationLevel.EducationId = Convert.ToInt32(cvEducationDropDown.SelectedValue);
                cv.EducationLevel = educationLevel;
                cv.EducationHistory = cvEducation.Text;

                cv.Hours = cvWorkTime.SelectedValue;
                cv.Profession = cvProfession.Text;
                cv.Discipline = cvDiscipline.Text;
                cv.JobRequirements = cvJobRequirements.Text;
                cv.WorkExperience = cvWorkExperience.Text;

                cv.Date = DateTime.Now.ToString();

                Source source = new Source();
                source.Description = "Geregistreerd";
                cv.Source = source;

                userRegister.UserCv = cv;
            }
            else if (cv_companyRadio.SelectedValue.Equals("Bedrijf"))
            {
                company = new UserCompany();

                company.CompanyName = companyName.Text;
                company.CompanyCity = companyCity.Text;
                company.CompanyEmail = companyEmail.Text;
                company.CompanyTel = companyPhone.Text;
                company.CompanyDescription = companyDescription.Text;

                company.CompanyDate = DateTime.Now.ToString();

                userRegister.UserCompany = company;
            }
            try
            {
                int returnType = service.AddUser(mapping.mapToService(userRegister));

                if (returnType == 0)
                {
                    errorMessage.InnerHtml = "<span>De gebruiker kon niet aangemaakt worden probeer het later nog een keer</span>";
                }
                else if (returnType == 1)
                {
                    Response.Redirect("login.aspx?registration=done");
                }
                else
                {
                    errorMessage.InnerHtml = "<span>De gebruiker bestaat al</span>";
                    regMail.Style["border"] = "1px solid red";
                }
            }
            catch (System.Net.WebException)
            {
                errorMessage.InnerHtml = "<span>Er kon geen verbinding gemaakt worden met de webservice<br />Probeer het later nog eens</span>";
            }
        }
    }
Пример #37
0
    protected void calculatePrint(UserMapping userData)
    {
        try
        {
            UserMapping map = UserMapping_S.UserMapWithApartmentBuilding("Faculty Housing", userData.Apartment);
            if (map != null)
            {
                DateTime frDate = DateTime.ParseExact(fromDate.Value + ",000", "dd/MM/yyyy HH:mm:ss,fff",
                                           System.Globalization.CultureInfo.InvariantCulture);
                DateTime tDate = DateTime.ParseExact(toDate.Value + ",000", "dd/MM/yyyy HH:mm:ss,fff",
                                           System.Globalization.CultureInfo.InvariantCulture);
                int day = frDate.Day;
                int month = frDate.Month;
                int year = frDate.Year;

                frDate = new DateTime(year, month, day, 0, 0, 1);
                day = tDate.Day;
                month = tDate.Month;
                year = tDate.Year;

                tDate = new DateTime(year, month, day, 23, 59, 59);

                if (frDate != null && tDate != null)
                {
                    Utilities utFr = Utilitie_S.DateTimeToEpoch(frDate);
                    Utilities utTo = Utilitie_S.DateTimeToEpoch(tDate);

                    int[] timeStMet1; double[] valuesMet1;

                    FetchEnergyDataS_Map.FetchBillConsumption(utFr.Epoch, utTo.Epoch, map.Apartment, meterTyped1 , out timeStMet1, out valuesMet1);

                    int[] timeStMet2; double[] valuesMet2;

                    FetchEnergyDataS_Map.FetchBillConsumption(utFr.Epoch, utTo.Epoch, map.Apartment, meterTyped2, out timeStMet2, out valuesMet2);

                    Utilitie_S.ZeroArrayRefiner(timeStMet1, valuesMet1, out timeStMet1, out valuesMet1);
                    Utilitie_S.ZeroArrayRefiner(timeStMet2, valuesMet2, out timeStMet2, out valuesMet2);

                    if (valuesMet1.Length>1 && valuesMet2.Length>1)
                    {

                        double lightingUnits = (valuesMet2[1] - valuesMet2[0])/1000;
                        double powerUnits = (valuesMet1[1] - valuesMet1[0])/1000;

                        lightingUnits = Math.Round(lightingUnits, 2);
                        powerUnits = Math.Round(powerUnits, 2);

                        double totalUnit = lightingUnits + powerUnits;

                        int dayNo = (utTo.Epoch-utFr.Epoch) / (60 * 60 * 24);

                        double SL1CHRG = 3.7; double SL2CHRG = 5.5; double SL3CHRG = 6.5; double slabSize=6.67;
                        double SL1PRC=0; double SL2PRC=0; double SL3PRC=0;
                        string slabTxt = "";
                        double daslb = dayNo * slabSize;
                        daslb = Math.Round(daslb, 2);

                        if (totalUnit > daslb)
                        {
                            if (totalUnit >= (2 * daslb))
                            {
                                SL1PRC = SL1CHRG * daslb;
                                slabTxt = (daslb).ToString() + " X " + SL1CHRG.ToString() + " = " + SL1PRC.ToString();
                                SL2PRC = SL2CHRG * daslb;
                                slabTxt = slabTxt + "<br />" + (daslb).ToString() + " X " + SL2CHRG.ToString() + " = " + SL2PRC.ToString();
                                SL3PRC = SL3CHRG * (totalUnit - (2 * daslb));
                                slabTxt = slabTxt + "<br />" + (totalUnit - (2 * daslb)).ToString() + " X " + SL3CHRG.ToString() + " = " + SL3PRC.ToString();
                            }
                            else
                            {
                                SL1PRC = SL1CHRG * daslb;
                                slabTxt = (daslb).ToString() + " X " + SL1CHRG.ToString() + " = " + SL1PRC.ToString();
                                SL2PRC = SL2CHRG * (totalUnit - (daslb));
                                slabTxt = slabTxt + "<br />" +(totalUnit- (daslb)).ToString() + " X " + SL2CHRG.ToString() + " = " + SL2PRC.ToString();
                            }
                        }
                        else
                        {
                            SL1PRC = SL1CHRG * totalUnit;
                            slabTxt = (daslb).ToString() + " X " + SL1CHRG.ToString() + " = " + SL1PRC.ToString();
                        }

                        double TotalPRC = SL1PRC + SL2PRC + SL3PRC;
                        double FIXED_CHRG = 6;
                        double FIXED_PRC = FIXED_CHRG * dayNo;

                        double Adj_PRCNT = 1.5;
                        double Def_PRCNT = 8;

                        double Adj_Total_PRC = (Adj_PRCNT / 100) * TotalPRC;
                        double Def_Total_PRC = (Def_PRCNT / 100) * TotalPRC;

                        double Adj_FIX_PRC = (Adj_PRCNT / 100) * FIXED_PRC;
                        double Def_FIX_PRC = (Def_PRCNT / 100) * FIXED_PRC;

                        double temp1 = TotalPRC + Adj_Total_PRC + Def_Total_PRC;
                        double temp2 = FIXED_PRC + Adj_FIX_PRC + Def_FIX_PRC;

                        temp1 = Math.Round(temp1, 2);
                        temp2 = Math.Round(temp2, 2);

                        double subTotal = temp1 + temp2;

                        double ELEC_CHRG_PRCNT = 5;
                        double ELEC_TAX = (ELEC_CHRG_PRCNT / 100) * subTotal;
                        ELEC_TAX = Math.Round(ELEC_TAX, 2);

                        double Final_Total = subTotal + ELEC_TAX;

                        meterType1.Text = meterTyped1;                      meterType2.Text = meterTyped2;
                        metTyp1Units.Text = powerUnits.ToString();          metTyp2Units.Text = lightingUnits.ToString();
                        metTyp1Units0.Text = (Math.Round(valuesMet1[0]/1000,2)).ToString();      metTyp1Units1.Text = (Math.Round(valuesMet1[1]/1000,2)).ToString();
                        metTyp2Units0.Text = (Math.Round(valuesMet2[0]/1000,2)).ToString();      metTyp2Units1.Text = (Math.Round(valuesMet2[1]/1000,2)).ToString();

                        dayTd.InnerHtml ="Days = "+dayNo.ToString();                  totalUnits.Text = totalUnit.ToString();

                        totalUnitsConsumed.Text = totalUnit.ToString();
                        slabText.InnerHtml = slabTxt;
                        fixedText.InnerHtml = FIXED_CHRG.ToString() + " X " + dayNo.ToString() + "(Days)";

                        totalSlabCharge.Text = TotalPRC.ToString();
                        totalFixCharge.Text = FIXED_PRC.ToString();

                        energyChrg.Text = TotalPRC.ToString();
                        fixChrg.Text = FIXED_PRC.ToString();
                        adjEnrgyChrg.Text = Adj_Total_PRC.ToString();
                        adjFixChrg.Text = Adj_FIX_PRC.ToString();
                        defEnrgyChrg.Text = Def_Total_PRC.ToString();
                        defFixChrg.Text = Def_FIX_PRC.ToString();
                        netEnrgyChrg.Text = temp1.ToString();
                        netFixChrg.Text = temp2.ToString();

                        subTotalTxt.Text = "Rs "+subTotal.ToString();
                        elecTax.InnerHtml = "Electricity Tax (" + ELEC_CHRG_PRCNT.ToString() + "%) on (Rs " + subTotal.ToString() + " ) = Rs " + ELEC_TAX.ToString();
                        netBillAmt.InnerHtml = "Net Bill Amount = Rs " +Math.Round( Final_Total,2).ToString();

                        billAmount.InnerHtml = "Bill Amount = Rs " + Math.Round( Final_Total,2).ToString();

                        /****888888888888888888888888888888*******************************/
                        address.InnerHtml = "Flat No: " + map.Apartment + ", " + map.Building + " (IIITD)," + " Okhla Phase III, Delhi";

                        meterNo.InnerText = map.Apartment;
                        billPeriod.InnerText = frDate.ToString("dd/MM/yyyy") + " to " + tDate.ToString("dd/MM/yyyy");
                        dueDate.InnerHtml = "Due Date: " + DateTime.Now.AddDays(7).ToString("dd-MMM-yyyy");
                        billNo.InnerText = "Rep " + meterNo.InnerText + " - " + DateTime.Today.ToString("dd-MMM-yyyy");
                        billDate.InnerText = DateTime.Now.ToString("dd-MMM-yyyy");
                    }
                }
            }
        }
        catch (Exception e)
        {

        }
    }
        /// <summary>
        /// update right hand grid when add or edit a record.
        /// </summary>
        /// <param name="currentStep">
        /// The current Step.
        /// </param>
        /// <param name="item">
        /// The item.
        /// </param>
        private void ContentViewModel_OnPropertyChanged(EnumSteps currentStep, object item)
        {
            switch (Screen)
            {
                #region User
                case EnumScreen.Users:
                    var mainWindowDetailsTabControlViewModelUsers =
                        this.ScreenDetailViewModel as MainWindowDetailsTabControlViewModel;
                    if (mainWindowDetailsTabControlViewModelUsers != null)
                    {
                        var usersViewModel =
                            mainWindowDetailsTabControlViewModelUsers.UsersMainWindowDetailsVm.ScreenDetailViewModel as
                            UsersViewModel;

                        if (usersViewModel != null && usersViewModel.AllUsers != null)
                        {
                            UserMapping userMapping = new UserMapping();

                            var user = usersViewModel.AllUsers.FirstOrDefault(x => x == item as UserDetails);
                                
                            if (user != null)
                            {
                                userMapping.UserEntityId = user.UserEntityId;
                                userMapping.LoginName = user.UserCredentials.LoginName;
                                userMapping.IsEnabled = user.UserCredentials.IsEnabled;
                                DataRow editItem = null;
                                foreach (var row in ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    var userDetails = item as UserDetails;
                                    if (userDetails != null && row["UserEntityId"].ToString() == userDetails.UserEntityId.ToString(CultureInfo.InvariantCulture))
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    ToggleViewModel.GridDynamicViewModel.InsertRow(index, userMapping);
                                }
                                else
                                {
                                    ToggleViewModel.GridDynamicViewModel.AddRow(userMapping);
                                }
                                ToggleViewModel.SetSelectedItem(user);
                            }
                        }
                    }
                    break;
                #endregion

                #region Group
                case EnumScreen.Groups:
                    var mainWindowDetailsTabControlViewModelGroups =
                        this.ScreenDetailViewModel as MainWindowDetailsTabControlViewModel;
                    if (mainWindowDetailsTabControlViewModelGroups != null)
                    {
                        var groupsViewModel =
                            mainWindowDetailsTabControlViewModelGroups.GroupsMainWindowDetailsVm.ScreenDetailViewModel
                            as GroupsViewModel;

                        if (groupsViewModel != null && groupsViewModel.Groups != null)
                        {
                            GroupMapping groupMapping = new GroupMapping();

                            var group = groupsViewModel.Groups.FirstOrDefault(x => x == item as GroupDetails);
                            if (group != null)
                            {
                                groupMapping.UserEntityId = group.UserEntityId;
                                groupMapping.GroupName = group.LXMGroup.GroupName;
                                DataRow editItem = null;
                                foreach (var row in ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    var groupDetails = item as GroupDetails;
                                    if (groupDetails != null && row["UserEntityId"].ToString() == groupDetails.UserEntityId.ToString(CultureInfo.InvariantCulture))
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    ToggleViewModel.GridDynamicViewModel.InsertRow(index, groupMapping);
                                }
                                else
                                {
                                    ToggleViewModel.GridDynamicViewModel.AddRow(groupMapping);
                                }
                                ToggleViewModel.SetSelectedItem(group);
                            }
                        }
                    }
                    break;
                #endregion

                #region ColletionQueues
                case EnumScreen.ColletionQueues:
                    var collectionQueueViewModel = this.ScreenDetailViewModel as MainWindowDetailsTabControlCollectionQueueViewModel;
                    QueueDetailsModel queueSource = item as QueueDetailsModel;
                    if (collectionQueueViewModel != null)
                    {
                        var collectionManagementViewModel =
                            collectionQueueViewModel.ListMainWindowDetailsVm.ScreenDetailViewModel as
                            CollectionsManagementViewModel;

                        if (collectionManagementViewModel != null
                            && collectionManagementViewModel.AllQueueManagementDetails != null)
                        {
                            CollectionsManagementMapping collectionsManagementMapping =
                                new CollectionsManagementMapping();
                            
                            var queue =
                                collectionManagementViewModel.AllQueueManagementDetails.FirstOrDefault(d => queueSource != null && d.QueueDetailId == queueSource.QueueDetailId);
                            if (queue != null)
                            {
                                collectionsManagementMapping.Enabled = queue.CollectionQueue.Enabled;
                                collectionsManagementMapping.ID = queue.CollectionQueue.ID;
                                collectionsManagementMapping.QueueName = queue.CollectionQueue.QueueName;
                                collectionsManagementMapping.AssignmentOrder = queue.CollectionQueue.AssignmentOrder;
                                DataRow editItem = null;
                                foreach (var row in ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    var queueDetailsModel = item as QueueDetailsModel;
                                    if (queueDetailsModel != null && row["ID"].ToString() == queueDetailsModel.QueueDetailId.ToString(CultureInfo.InvariantCulture))
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    ToggleViewModel.GridDynamicViewModel.InsertRow(index, collectionsManagementMapping);
                                }
                                else
                                {
                                    ToggleViewModel.GridDynamicViewModel.AddRow(collectionsManagementMapping);
                                }
                                ToggleViewModel.SetSelectedItem(queue);
                            }
                        }
                    }
                    break;
                #endregion

                #region CollectionAssignment
                case EnumScreen.CollectionAssignment:
                    var collectionAssignmentViewModel =
                        this.ScreenDetailViewModel as MainWindowDetailsViewModel;
                    if (collectionAssignmentViewModel != null)
                    {
                        var viewModel = collectionAssignmentViewModel.ScreenDetailViewModel as CollectionsAssignmentViewModel;
                        CollectionAssignmentModel itemSource = item as CollectionAssignmentModel;
                        if (viewModel != null && itemSource != null)
                        {
                            CollectionAssignmentMapping collectionAssignmentMapping =
                                new CollectionAssignmentMapping();
                            
                            var collectionAssignment =
                                viewModel.FilteredItems.FirstOrDefault(d => d.QueueID == itemSource.QueueID && d.ContractId == itemSource.ContractId);

                            if (collectionAssignment != null)
                            {
                                collectionAssignmentMapping.QueueID = collectionAssignment.QueueID;
                                collectionAssignmentMapping.FollowUpDate = collectionAssignment.FollowUpDate;
                                collectionAssignmentMapping.ContractId = collectionAssignment.ContractId;
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    var collectionAssignmentModel = item as CollectionAssignmentModel;
                                    if (row["QueueID"].ToString() == collectionAssignmentModel.QueueID.ToString(CultureInfo.InvariantCulture) && row["ContractId"].ToString() == collectionAssignmentModel.ContractId.ToString(CultureInfo.InvariantCulture))
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(index, collectionAssignmentMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(collectionAssignmentMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(collectionAssignment);
                            }
                            
                        }
                    }
                    break;
                #endregion

                #region FundingSummary
                case EnumScreen.FundingSummary:
                    var fundingViewModel =
                        this.ScreenDetailViewModel as MainWindowDetailsViewModel;
                    if (fundingViewModel != null)
                    {
                        var fundingSummaryViewModel =
                            fundingViewModel.ScreenDetailViewModel as
                            FundingSummaryViewModel;
                        
                        FundingSummaryMaping fundingSummaryMapping =
                                new FundingSummaryMaping();
                        if (fundingSummaryViewModel != null)
                        {
                            var fundingSummary =
                                fundingSummaryViewModel.TrancheSummary.FirstOrDefault(x => x.TrancheId == (int)item);
                            
                            if (fundingSummary != null)
                            {
                                fundingSummaryMapping.TrancheId = fundingSummary.TrancheId;
                                fundingSummaryMapping.FunderName = fundingSummary.FunderName;
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["TrancheId"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);                                    
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(
                                            index,
                                            fundingSummaryMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(fundingSummaryMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(fundingSummary);
                            }
                            else
                            {
                                if (currentStep == EnumSteps.Delete)
                                {
                                    DataRow editItem = null;
                                    foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                    {
                                        if (row["TrancheId"].ToString() == item.ToString())
                                        {
                                            editItem = row;
                                            break;
                                        }
                                    }
                                    if (editItem != null)
                                    {
                                        this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = false;
                                        int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                        this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    }
                                    this.ToggleViewModel.SetSelectedItem(null);
                                }
                            }
                        }
                    }
                    break;
                #endregion

                #region Asset Class Category
                case EnumScreen.AssetClassesCategory:
                    var mainWindowDetailsTabControlViewModelCategory =
                        this.ScreenDetailViewModel as MainAssetClassesViewModel;
                    if (mainWindowDetailsTabControlViewModelCategory != null)
                    {
                        var categoryViewModel =
                            mainWindowDetailsTabControlViewModelCategory.AssetCategoryViewModel.ScreenDetailViewModel as
                            AssetClassesCategoryViewModel;

                        if (categoryViewModel != null && categoryViewModel.ListDataGridItem != null)
                        {
                            AssetClassesCategoryRowItem categoryMapping = new AssetClassesCategoryRowItem();

                            var category = categoryViewModel.ListDataGridItem.FirstOrDefault(x => x.EquipCategoryId == (item as EquipCategory).EquipCatId);

                            if (category != null)
                            {
                                categoryMapping.EquipCategoryId = (item as EquipCategory).EquipCatId;
                                categoryMapping.Category = (item as EquipCategory).Description;
                                categoryMapping.Enabled = (item as EquipCategory).Enabled;
                                DataRow editItem = null;
                                foreach (var row in ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["EquipCategoryId"].ToString() == (item as EquipCategory).EquipCatId.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    ToggleViewModel.GridDynamicViewModel.InsertRow(index, categoryMapping);
                                }
                                else
                                {
                                    ToggleViewModel.GridDynamicViewModel.AddRow(categoryMapping);
                                }
                                ToggleViewModel.SetSelectedItem(item);
                            }
                        }
                    }
                    break;
                #endregion

                #region Asset Class Type
                case EnumScreen.AssetClassesType:
                    var mainWindowDetailsTabControlViewModelType =
                        this.ScreenDetailViewModel as MainAssetClassesViewModel;
                    if (mainWindowDetailsTabControlViewModelType != null)
                    {
                        var typeViewModel =
                            mainWindowDetailsTabControlViewModelType.AssetClassesTypeViewModel.ScreenDetailViewModel as AssetClassesTypeViewModel;

                        if (typeViewModel != null && typeViewModel.ListDataGridItem != null)
                        {
                            AssetClassesTypeRowItem typeMapping = new AssetClassesTypeRowItem();

                            var type = typeViewModel.ListDataGridItem.FirstOrDefault(x => x.EquipTypeId == (item as EquipType).EquipTypeId);

                            if (type != null)
                            {
                                typeMapping.EquipTypeId = (item as EquipType).EquipTypeId;
                                typeMapping.TypeDescription = (item as EquipType).Description;
                                typeMapping.Enabled = (item as EquipType).Enabled;
                                DataRow editItem = null;
                                foreach (var row in ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["EquipTypeId"].ToString() == (item as EquipType).EquipTypeId.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    ToggleViewModel.GridDynamicViewModel.InsertRow(index, typeMapping);
                                }
                                else
                                {
                                    ToggleViewModel.GridDynamicViewModel.AddRow(typeMapping);
                                }
                                ToggleViewModel.SetSelectedItem(item);
                            }
                        }
                    }
                    break;
                #endregion

                #region AssetClassesModel
                case EnumScreen.AssetClassesModel:
                    var modelViewModel = this.ScreenDetailViewModel as MainAssetClassesViewModel;
                    if (modelViewModel != null)
                    {
                        var modelDetailViewModel = modelViewModel.AssetClassesModelViewModel.ScreenDetailViewModel
                            as AssetClassesModelViewModel;
                        AssetClassesModelRowItem assetModelMapping=new AssetClassesModelRowItem();
                        if (modelDetailViewModel != null)
                        {
                            var assetDetail =
                                modelDetailViewModel.AllAssetModel.FirstOrDefault(x=> x.EquipModelId == ((EquipModel)item).EquipModelId);

                            if (assetDetail != null)
                            {
                                assetModelMapping.EquipModelId = assetDetail.EquipModelId;
                                assetModelMapping.Description = assetDetail.Description;
                                assetModelMapping.Enabled = assetDetail.Enabled;
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["EquipModelId"].ToString() == ((EquipModel)item).EquipModelId.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(
                                            index,
                                            assetModelMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(assetModelMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(item);
                            }
                        }
                    }
                    break;
                #endregion

                #region AssetFeatures
                case EnumScreen.AssetFeatures:
                    var featureViewModel =
                        this.ScreenDetailViewModel as MainWindowDetailsViewModel;
                    if (featureViewModel != null)
                    {
                        var assetFeatureViewModel =
                            featureViewModel.ScreenDetailViewModel as
                            AssetFeaturesViewModel;

                        AssetFeatureTypeRowItem featureTypeMapping =
                                new AssetFeatureTypeRowItem();
                        if (assetFeatureViewModel != null)
                        {
                            var feature =
                                assetFeatureViewModel.AllFeatureTypes.FirstOrDefault(x => x.FeatureTypeId == (int)item);

                            if (feature != null)
                            {
                                featureTypeMapping.FeatureTypeId = feature.FeatureTypeId;
                                featureTypeMapping.FeatureName = feature.FeatureName;
                                featureTypeMapping.Enabled = feature.Enabled;
                                featureTypeMapping.RequiredLength = feature.RequiredLength == -1 ? "N/A" : feature.RequiredLength.ToString();
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["FeatureTypeId"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(
                                            index,
                                            featureTypeMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(featureTypeMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(feature);
                            }
                            else
                            {
                                if (currentStep == EnumSteps.Delete)
                                {
                                    DataRow editItem = null;
                                    foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                    {
                                        if (row["FeatureTypeId"].ToString() == item.ToString())
                                        {
                                            editItem = row;
                                            break;
                                        }
                                    }
                                    if (editItem != null)
                                    {
                                        this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = false;
                                        int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                        this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    }
                                    this.ToggleViewModel.SetSelectedItem(null);
                                }
                            }
                        }
                    }
                    break;
                #endregion

                #region AssetClassesMake
                case EnumScreen.AssetClassesMake:
                    var makeViewModel =
                        this.ScreenDetailViewModel as MainAssetClassesViewModel;
                    if (makeViewModel != null)
                    {
                        var assetClassesMakeViewModel = makeViewModel.AssetClassesMakeViewModel.ScreenDetailViewModel as AssetClassesMakeViewModel;

                        AssetClassesMakeRowItem makeTypeMapping = new AssetClassesMakeRowItem();
                        if (assetClassesMakeViewModel != null)
                        {
                            var make =
                                assetClassesMakeViewModel.AllAssetMake.FirstOrDefault(x => x.EquipMakeId == (int)item);

                            if (make != null)
                            {
                                makeTypeMapping.EquipMakeId = make.EquipMakeId;
                                makeTypeMapping.Description = make.Description;
                                makeTypeMapping.Enabled = make.Enabled;
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["EquipMakeId"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index =
                                        this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(index, makeTypeMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(makeTypeMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(make);
                            }
                        }
                    }
                    break;
                #endregion

                #region Asset Collateral Classes
                case EnumScreen.AssetCollateralClasses:
                    var collateralViewModel =
                        this.ScreenDetailViewModel as MainWindowDetailsViewModel;
                    if (collateralViewModel != null)
                    {
                        var assetCollateralViewModel =
                            collateralViewModel.ScreenDetailViewModel as
                            AssetCollateralClassesViewModel;

                        AssetCollateralRowItem collateralMapping =
                                new AssetCollateralRowItem();
                        if (assetCollateralViewModel != null)
                        {
                            var collateral =
                                assetCollateralViewModel.AllCollateralClasses.FirstOrDefault(x => x.CollateralClassID == (int)item);

                            if (collateral != null)
                            {
                                collateralMapping.Description = collateral.Description;
                                collateralMapping.CollateralClassID = collateral.CollateralClassID;
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["CollateralClassID"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(
                                            index,
                                            collateralMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(collateralMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(collateral);
                            }
                        }
                    }
                    break;
                #endregion

                #region AssetRegister
                case EnumScreen.AssetRegisters:
                    var registerViewModel =
                        this.ScreenDetailViewModel as MainWindowDetailsViewModel;
                    if (registerViewModel != null)
                    {
                        var assetRegisterViewModel =
                            registerViewModel.ScreenDetailViewModel as AssetRegistersViewModel;

                        AssetRegisterRowItem registerMapping = new AssetRegisterRowItem();
                        if (assetRegisterViewModel != null)
                        {
                            var register = assetRegisterViewModel.AllAssetRegister.FirstOrDefault(x => x.ID == (int)item);

                            if (register != null)
                            {
                                registerMapping.ID = register.ID;
                                registerMapping.RegisterName = register.RegisterName;
                                registerMapping.InternalOnly = register.InternalOnly;

                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["ID"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(index, registerMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(registerMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(register);
                            }
                            else
                            {
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["ID"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }
                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = false;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                }
                                this.ToggleViewModel.SetSelectedItem(null);
                            }
                        }
                    }
                    break;
                #endregion

                #region RegisteredAsset
                case EnumScreen.RegisteredAsset:
                    var registeredAssetViewModel =
                        this.ScreenDetailViewModel as MainWindowDetailsViewModel;
                    if (registeredAssetViewModel != null)
                    {
                        var assetRegisterViewModel =
                            registeredAssetViewModel.ScreenDetailViewModel as RegisteredAssetViewModel;

                        RegisteredAssetRowItem registerMapping = new RegisteredAssetRowItem();
                        if (assetRegisterViewModel != null)
                        {
                            var register = assetRegisterViewModel.AllRegisteredAsset.FirstOrDefault(x => x.Id == (int)item);

                            if (register != null)
                            {
                                registerMapping.Id = register.Id;
                                registerMapping.AssetRegisterId = register.AssetRegisterId;
                                registerMapping.AssetState = register.AssetState;

                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["Id"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }

                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = true;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                    this.ToggleViewModel.GridDynamicViewModel.InsertRow(index, registerMapping);
                                }
                                else
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.AddRow(registerMapping);
                                }
                                this.ToggleViewModel.SetSelectedItem(register);
                            }
                            else
                            {
                                DataRow editItem = null;
                                foreach (var row in this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows)
                                {
                                    if (row["Id"].ToString() == item.ToString())
                                    {
                                        editItem = row;
                                        break;
                                    }
                                }
                                if (editItem != null)
                                {
                                    this.ToggleViewModel.GridDynamicViewModel.IsSetSelectedItem = false;
                                    int index = this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.IndexOf(editItem);
                                    this.ToggleViewModel.GridDynamicViewModel.MembersTable.Rows.RemoveAt(index);
                                }
                                this.ToggleViewModel.SetSelectedItem(null);
                            }
                        }
                    }
                    break;
                #endregion
            }
        }
Пример #39
0
    protected void calculatePrint(UserMapping userData)
    {
        try
        {
            UserMapping map = UserMapping_S.UserMapWithApartmentBuilding("Faculty Housing", userData.Apartment);
            if (map != null)
            {
                DateTime frDate = DateTime.ParseExact(fromDate.Value + ",000", "dd/MM/yyyy HH:mm:ss,fff",
                                           System.Globalization.CultureInfo.InvariantCulture);
                DateTime tDate = DateTime.ParseExact(toDate.Value + ",000", "dd/MM/yyyy HH:mm:ss,fff",
                                           System.Globalization.CultureInfo.InvariantCulture);
                int day=frDate.Day;
                int month=frDate.Month;
                int year=frDate.Year;

                frDate=new DateTime(year,month,day,0,0,1);
                day=tDate.Day;
                month=tDate.Month;
                year=tDate.Year;

                tDate=new DateTime(year,month,day,23,59,59);

                if (frDate != null && tDate != null)
                {
                    Utilities utFr=Utilitie_S.DateTimeToEpoch(frDate);
                    Utilities utTo=Utilitie_S.DateTimeToEpoch(tDate);

                    int[] timeStMet1; double[] valuesMet1;

                    FetchEnergyDataS_Map.FetchBillConsumption(utFr.Epoch, utTo.Epoch, map.Apartment,meterTyped1, out timeStMet1, out valuesMet1);

                    int[] timeStMet2; double[] valuesMet2;

                    FetchEnergyDataS_Map.FetchBillConsumption(utFr.Epoch, utTo.Epoch, map.Apartment, meterTyped2, out timeStMet2, out valuesMet2);

                    Utilitie_S.ZeroArrayRefiner(timeStMet1, valuesMet1, out timeStMet1, out valuesMet1);
                    Utilitie_S.ZeroArrayRefiner(timeStMet2, valuesMet2, out timeStMet2, out valuesMet2);

                    if (valuesMet1.Length>1 && valuesMet2.Length>1)
                    {
                        double lightingUnits = (valuesMet2[1] - valuesMet2[0])/1000;
                        double powerUnits = (valuesMet1[1] - valuesMet1[0])/1000;

                        lightingUnits = Math.Round(lightingUnits, 2);
                        powerUnits = Math.Round(powerUnits, 2);

                        double totalUnit = lightingUnits + powerUnits;

                        int dayNo = (timeStMet1[1]-timeStMet2[0]) / (60 * 60 * 24);

                        double SL1CHRG = 3.7; double SL2CHRG = 5.5; double SL3CHRG = 6.5; double slabSize=6.67;
                        double SL1PRC=0; double SL2PRC=0; double SL3PRC=0;
                        string slabTxt = "";
                        double daslb = dayNo * slabSize;
                        daslb = Math.Round(daslb, 2);

                        if (totalUnit > daslb)
                        {
                            if (totalUnit >= (2 * daslb))
                            {
                                SL1PRC = SL1CHRG * daslb;
                                slabTxt = (daslb).ToString() + " X " + SL1CHRG.ToString() + " = " + SL1PRC.ToString();
                                SL2PRC = SL2CHRG * daslb;
                                slabTxt = slabTxt + "<br />" + (daslb).ToString() + " X " + SL2CHRG.ToString() + " = " + SL2PRC.ToString();
                                SL3PRC = SL3CHRG * (totalUnit - (2 * daslb));
                                slabTxt = slabTxt + "<br />" + (totalUnit - (2 * daslb)).ToString() + " X " + SL3CHRG.ToString() + " = " + SL3PRC.ToString();
                            }
                            else
                            {
                                SL1PRC = SL1CHRG * daslb;
                                slabTxt = (daslb).ToString() + " X " + SL1CHRG.ToString() + " = " + SL1PRC.ToString();
                                SL2PRC = SL2CHRG * (totalUnit - (daslb));
                                slabTxt = slabTxt + "<br />" + (totalUnit - (daslb)).ToString() + " X " + SL2CHRG.ToString() + " = " + SL2PRC.ToString();
                            }
                        }
                        else
                        {
                            SL1PRC = SL1CHRG * totalUnit;
                            slabTxt = (daslb).ToString() + " X " + SL1CHRG.ToString() + " = " + SL1PRC.ToString();
                        }

                        double TotalPRC = SL1PRC + SL2PRC + SL3PRC;
                        double FIXED_CHRG = 6;
                        double FIXED_PRC = FIXED_CHRG * dayNo;

                        double Adj_PRCNT = 1.5;
                        double Def_PRCNT = 8;

                        double Adj_Total_PRC = (Adj_PRCNT / 100) * TotalPRC;
                        double Def_Total_PRC = (Def_PRCNT / 100) * TotalPRC;

                        double Adj_FIX_PRC = (Adj_PRCNT / 100) * FIXED_PRC;
                        double Def_FIX_PRC = (Def_PRCNT / 100) * FIXED_PRC;

                        double temp1 = TotalPRC + Adj_Total_PRC + Def_Total_PRC;
                        double temp2 = FIXED_PRC + Adj_FIX_PRC + Def_FIX_PRC;

                        temp1 = Math.Round(temp1, 2);
                        temp2 = Math.Round(temp2, 2);

                        double subTotal = temp1 + temp2;

                        double ELEC_CHRG_PRCNT = 5;
                        double ELEC_TAX = (ELEC_CHRG_PRCNT / 100) * subTotal;
                        ELEC_TAX = Math.Round(ELEC_TAX, 2);

                        double Final_Total = subTotal + ELEC_TAX;

                        meterType1.Text = meterTyped1; meterType2.Text = meterTyped2;
                        metTyp1Units.Text = powerUnits.ToString(); metTyp2Units.Text = lightingUnits.ToString();
                        metTyp1Units0.Text = (Math.Round(valuesMet1[0] / 1000, 2)).ToString(); metTyp1Units1.Text = (Math.Round(valuesMet1[1] / 1000, 2)).ToString();
                        metTyp2Units0.Text = (Math.Round(valuesMet2[0] / 1000, 2)).ToString(); metTyp2Units1.Text = (Math.Round(valuesMet2[1] / 1000, 2)).ToString();

                        dayTd.InnerHtml = "Days = " + dayNo.ToString(); totalUnits.Text = totalUnit.ToString();

                        totalUnitsConsumed.Text = totalUnit.ToString();
                        slabText.InnerHtml = slabTxt;
                        fixedText.InnerHtml = FIXED_CHRG.ToString() + " X " + dayNo.ToString() + "(Days)";

                        totalSlabCharge.Text = TotalPRC.ToString();
                        totalFixCharge.Text = FIXED_PRC.ToString();

                        energyChrg.Text = TotalPRC.ToString();
                        fixChrg.Text = FIXED_PRC.ToString();
                        adjEnrgyChrg.Text = Adj_Total_PRC.ToString();
                        adjFixChrg.Text = Adj_FIX_PRC.ToString();
                        defEnrgyChrg.Text = Def_Total_PRC.ToString();
                        defFixChrg.Text = Def_FIX_PRC.ToString();
                        netEnrgyChrg.Text = temp1.ToString();
                        netFixChrg.Text = temp2.ToString();

                        subTotalTxt.Text = "Rs " + subTotal.ToString();
                        elecTax.InnerHtml = "Electricity Tax (" + ELEC_CHRG_PRCNT.ToString() + "%) on (Rs " + subTotal.ToString() + " ) = Rs " + ELEC_TAX.ToString();
                        netBillAmt.InnerHtml = "Net Bill Amount = Rs " + Math.Round(Final_Total, 2).ToString();

                        billAmount.InnerHtml = "Bill Amount = Rs " + Math.Round(Final_Total, 2).ToString();

                        /****888888888888888888888888888888*******************************/
                        address.InnerHtml = "Flat No: " + map.Apartment + ", " + map.Building + " (IIITD)," + " Okhla Phase III, Delhi";

                        meterNo.InnerText = map.Apartment + " - " + map.MeterId.ToString();
                        billPeriod.InnerText = frDate.ToString("dd/MM/yyyy") + " to " + tDate.ToString("dd/MM/yyyy");
                        dueDate.InnerHtml = "Due Date: " + DateTime.Now.AddDays(7).ToString("dd-MMM-yyyy");
                        billNo.InnerText = "Rep " + meterNo.InnerText + " - " + DateTime.Today.ToString("dd-MMM-yyyy");
                        billDate.InnerText = DateTime.Now.ToString("dd-MMM-yyyy");

                        //this portion for graph below you vs avg + co2 emission
                        double kwh = totalUnit;
                        myEnergy = Convert.ToInt32(totalUnit);
                        double co2Emission =Math.Round( kwh * 0.87,2);
                        string f1 = "<font color='#f18221 !important'>";
                        string f2 = "</font>";
                        co2.InnerHtml = f1 + (kwh).ToString() + "KWhr" + f2 + " of energy combustion is equivalent to CO2 emission of " + f1 + co2Emission.ToString() + " Kg" + f2 + " which is further equivalent to driving your car for " + f1 + (Math.Round((kwh * 5.8), 2)).ToString() + "KM" + f2;

                        //ends here--------------------------------------------

                    }

                    string[] frTim=new string[2];
                    string[] tTim=new string[2];

                    frTim[0]=frDate.ToString("MM/dd/yyyy HH:mm");
                    frTim[1]=tDate.ToString("MM/dd/yyyy HH:mm");

                    tTim[0]=frDate.AddMinutes(-5).ToString("MM/dd/yyyy HH:mm");
                    tTim[1]=tDate.AddMinutes(-5).ToString("MM/dd/yyyy HH:mm");

                    int[] avgTime,avgTime2;
                    double[] avgValues, avgValues2;

                    FetchEnergyDataS_Map.FetchAvgConsumption(frTim, tTim, map.Building, meterTyped1, out avgTime, out avgValues);
                    Utilitie_S.ZeroArrayRefiner(avgTime, avgValues, out avgTime, out avgValues);
                    FetchEnergyDataS_Map.FetchAvgConsumption(frTim, tTim, map.Building, meterTyped2, out avgTime2, out avgValues2);
                    Utilitie_S.ZeroArrayRefiner(avgTime2, avgValues2, out avgTime2, out avgValues2);
                    if (avgTime.Length==2 && avgTime2.Length==2)
                    {
                        int avg = Convert.ToInt32((avgValues2[1] - avgValues2[0]) / 1000);
                        avgEnergy = Convert.ToInt32((avgValues[1]-avgValues[0])/1000);
                        avgEnergy = avgEnergy + avg;
                    }

                    List<int> epochs=Utilitie_S.DashDaysEpochs(utFr.Epoch,5,2);
                    List<int> toEpochs=new List<int>();

                    for(int s=0; s<epochs.Count;s++)
                    {
                        toEpochs.Add(epochs[s]+300);
                    }
                    string[] fromTimes=Utilitie_S.SMapValidDateFormatter(epochs);
                    string[] toTimes=Utilitie_S.SMapValidDateFormatter(toEpochs);

                    //for power meter
                    FetchEnergyDataS_Map.FetchBarConsumption(fromTimes, toTimes, map.Apartment, meterTyped1, out timeArray, out energyArray);
                    Utilitie_S.ZeroArrayRefiner(timeArray, energyArray, out timeArray, out energyArray);
                    for (int ik = energyArray.Length-1; ik > 0; ik=ik-1)
                    {
                        energyArray[ik] =Math.Round((energyArray[ik] - energyArray[ik - 1])/1000,2);
                    }
                    timeArrayFinal = timeArray;
                    timeSeries = new string[energyArray.Length];
                    if (timeSeries.Length > 0)
                    {
                        timeSeries = Utilitie_S.TimeFormatter(timeArrayFinal);
                    }

                    energyArray[0] = 0; timeArray[0] = 0;
                    Utilitie_S.ZeroArrayRefiner(timeArray, energyArray, out timeArray, out energyArray);

                    //for the lighting meter
                    FetchEnergyDataS_Map.FetchBarConsumption(fromTimes, toTimes, map.Apartment, meterTyped2, out timeLightingArray, out energyLightingArray);
                    Utilitie_S.ZeroArrayRefiner(timeLightingArray, energyLightingArray, out timeLightingArray, out energyLightingArray);
                    for (int ki = energyLightingArray.Length-1; ki > 0; ki=ki-1)
                    {
                        energyLightingArray[ki] =Math.Round((energyLightingArray[ki] - energyLightingArray[ki - 1])/1000,2);
                    }
                    energyLightingArray[0]=0;timeLightingArray[0]=0;
                    Utilitie_S.ZeroArrayRefiner(timeLightingArray,energyLightingArray, out timeLightingArray, out energyLightingArray);

                }
            }
        }
        catch (Exception e)
        {

        }
    }
Пример #40
0
    protected void store_Click(object sender, EventArgs e)
    {
        Guid id = new Guid(Hidden1.Value);
        UserMapping oldMap = UserMapping_S.UserMapWithMeterBuilding(buildingList.Text, Convert.ToInt32(metId.Text));
        if (oldMap == null)
        {

            UserMapping map = new UserMapping();
            map.MeterId = Convert.ToInt32(metId.Text);
            map.Apartment = apartmentText.Text;
            map.UserId = id;
            map.Building = buildingList.Text;
            map.Floor = Convert.ToInt32(floorList.Text);
            map.MeterType = meterTypeList.Text;

            bool upd=  UserMapping_S.InsertMap(map);
            Session["Apartment"] = map.Apartment;
            Session["MeterType"] = map.MeterType;
            if (upd == true)
            {
                green0.Text = "Inserted";
                apartmentText.Text = ""; metId.Text = "";
            }
            else
            {
                green0.Text = "Something went wrong!";
            }
        }
        else
        {
            green0.Text = "Already Entered";
        }
    }