Ejemplo n.º 1
0
 private bool SetDefaultColor(string sColorKey, IColor pNewColor)
 {
     try
     {
         if (string.IsNullOrEmpty(sColorKey))
         {
             return(false);
         }
         if (pNewColor == null)
         {
             return(false);
         }
         if (!(pNewColor is IRgbColor))
         {
             return(false);
         }
         IRgbColor color = null;
         color = pNewColor as IRgbColor;
         Color black = Color.Black;
         black = Color.FromArgb(color.Red, color.Green, color.Blue);
         UtilFactory.GetConfigOpt().SetConfigValue(sColorKey, black.ToArgb().ToString());
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "SetDefaultColor", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);

            UtilFactory.Helpers.CookieHelper.Remove(encrypt.Encrypt("LoginUserID"));
            Response.Redirect("/Login.aspx");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// fire a projectile at the target
        /// </summary>
        /// <returns></returns>
        private BehaviorReturnCode fireAtTarget()
        {
            Position position = (Position)w_PositionMapper.get(w_ThisEntity);
            Position enemy    = (Position)w_PositionMapper.get(w_Target);
            Heading  heading  = (Heading)w_HeadingMapper.get(w_ThisEntity);

            Vector2 dir = (enemy.Pos + enemy.Offset) - (position.Pos + position.Offset);

            dir = VectorHelper.rotateVectorRadians(dir, -0.08726f + (float)w_Random.NextDouble() * 0.1745f);

            dir.Normalize();

            heading.setHeading(dir);

            Vector2 pos = position.Pos;

            Transform trans = new Transform();

            trans.Rotation       = -VectorHelper.getAngle(new Vector2(1, 0), dir);
            trans.RotationOrigin = new Vector2(16);

            EntityFactory.createSonicProjectile(pos + dir * 16, dir, 10, 1000, EntityFactory.createLight(true, 2, new Vector3(pos + position.Offset, 10), 0.7f, Color.Blue.ToVector4()), trans, w_ThisEntity);

            UtilFactory.createSound("audio\\effects\\fire", true, 0.5f);

            return(BehaviorReturnCode.Success);
        }
Ejemplo n.º 4
0
 public void CheckMapFullExtent(IEnvelope pEnvelope)
 {
     try
     {
         if (pEnvelope.XMin < double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMin")))
         {
             pEnvelope.XMin = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMin"));
         }
         if (pEnvelope.XMax > double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMax")))
         {
             pEnvelope.XMax = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMax"));
         }
         if (pEnvelope.YMin < double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMin")))
         {
             pEnvelope.YMin = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMin"));
         }
         if (pEnvelope.YMax > double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMax")))
         {
             pEnvelope.YMax = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMax"));
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "CheckMapFullExtent", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
Ejemplo n.º 5
0
 public IFeatureWorkspace GetFeatureWorkspace(WorkspaceSource pSourceType)
 {
     try
     {
         if (pSourceType != WorkspaceSource.esriWSSdeWorkspaceFactory)
         {
             return(null);
         }
         IWorkspace workspace = null;
         string     serr      = "";
         string     server    = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "DataSource");
         string     instance  = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "Service");
         string     database  = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "InitialCatalog");
         string     version   = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "Version");
         string     user      = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "UserID");
         string     password  = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "Password");
         workspace = this.open_ArcSDE_Workspace(server, instance, user, password, database, version, out serr);
         if (workspace == null)
         {
             MessageBox.Show("服务名、服务器名、数据库名、用户名或密码输入错误", "数据源链接失败!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(null);
         }
         return(workspace as IFeatureWorkspace);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.WorkspaceFun", "GetFeatureWorkspace", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
Ejemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     userApp = new UserApplication();
     if (!IsPostBack)
     {
         try
         {
             IEncrypt encrypt           = UtilFactory.GetEncryptProvider(EncryptType.DES);
             string   username          = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("Login_UserName_")));
             string   password          = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("Login_Password_")));
             string   preFailedUserName = QS("uname");
             if (!string.IsNullOrEmpty(preFailedUserName))//如果前一次登陆成功过,那么就保存cookie, 否则就重新赋值为上一次失败的用户名。
             {
                 txtUserName.Text = preFailedUserName;
                 txtPassword.Focus();
             }
             else
             {
                 txtUserName.Text = username;
                 txtPassword.Text = password;
             }
             chkRemember.Checked = true;
         }
         catch
         {
             txtUserName.Text    = "*****@*****.**";
             txtPassword.Text    = "jacK1234";
             chkRemember.Checked = false;
         }
     }
 }
Ejemplo n.º 7
0
        public UsersEntity Login(string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                this.AddBrokenRuleMessage("Login error", "Username can not be null!");
                return(null);
            }
            if (string.IsNullOrEmpty(password))
            {
                this.AddBrokenRuleMessage("Login error", "Password can not be null!");
                return(null);
            }
            UsersEntity user = GetUserByUserName(username);

            if (user == null)
            {
                return(null);
            }
            else if (user.Status == "INACTIVE")
            {
                this.AddBrokenRuleMessage("Login error", "Account disable!");
                return(null);
            }
            if (user.PassWord == UtilFactory.GetEncryptProvider(EncryptType.MD5).Encrypt(password))
            {
                cache[string.Format(CACHE_USERINFO, user.ID)]       = user;
                cache[string.Format(CACHE_USERINFO, user.UserName)] = user;
                return(user);
            }
            else
            {
                this.AddBrokenRuleMessage("Login error", "The username or password you entered is incorrect.");
                return(null);
            }
        }
Ejemplo n.º 8
0
 public bool SendForgotPasswordEmail(string username)
 {
     try
     {
         this.ClearBrokenRuleMessages();
         UsersEntity user = this.GetUserByUserName(username);
         if (user == null)
         {
             return(false);
         }
         user.AccountStatus = UsersEntity.ForgotPasswordFlag;
         this.UpdateUser(user);
         IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);
         string   enkey   = encrypt.Encrypt(string.Format("{0}_{1}", user.ID.ToString(), DateTime.Now.ToString()));
         string   url     = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host + "/ResetPassword.aspx?link=", enkey);
         string   body    = UtilFactory.Helpers.FileHelper.GetTemplateFileContent("SendEmailToUserForFindPassword.txt");
         body = body.Replace("{FirstName}", user.FirstName);
         body = body.Replace("{LastName}", user.LastName);
         body = body.Replace("{Date}", DateTime.Now.ToString("MM/dd/yyyy")).Replace("{URL}", url);
         if (emailSender.SendMail(username, Config.DefaultSendEmail, "Password Assistance", body))
         {
             return(true);
         }
         this.AddBrokenRuleMessage("Error", "Sorry,mail server is unavailable.");
         return(false);
     }
     catch (Exception ex)
     {
         WebLogAgent.Write(ex);
         return(false);
     }
 }
Ejemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            int eventID;

            if (int.TryParse(context.Request.Form["id"], out eventID))
            {
                IEncrypt encrypt   = UtilFactory.GetEncryptProvider(EncryptType.DES);
                string   strUserID = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("LoginUserID")));
                if (string.IsNullOrEmpty(strUserID))
                {
                    context.Response.Write("0");
                }
                int userID = int.Parse(strUserID);

                EventEntity entity = new EventsApplication().GetEventInfo(eventID);
                if (entity == null || entity.CreatedBy != userID)
                {
                    context.Response.Write("0");
                }

                if (new EventsApplication().Delete(eventID, entity.FromDay.Date))
                {
                    context.Response.Write("1");
                }
                else
                {
                    context.Response.Write("0");
                }
            }
            else
            {
                context.Response.Write("0");
            }
        }
Ejemplo n.º 10
0
        protected UsersEntity GetEntity()
        {
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);

            string[] items = encrypt.Decrypt(Request.Params["link"]).Split("_".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (items.Length != 2)
            {
                return(null);
            }
            int      userid;
            DateTime date;

            if (!int.TryParse(items[0], out userid) || !DateTime.TryParse(items[1], out date))
            {
                return(null);
            }
            if (date.Date != DateTime.Now.Date)
            {
                return(null);
            }
            UserApplication userApp = new UserApplication();
            UsersEntity     user    = userApp.GetUser(userid, false);

            return(user);
        }
Ejemplo n.º 11
0
        private string CheckInput()
        {
            UsersEntity model = UserInfo;
            string      msg   = string.Empty;

            if (model.PassWord != UtilFactory.GetEncryptProvider(EncryptType.MD5).Encrypt(txtOldPassword.Text))
            {
                msg = "The password you gave is incorrect, if you cannot remember you password, please contact the administrator.";
                txtOldPassword.Focus();
            }
            else
            {
                if (string.IsNullOrEmpty(txtPassword.Text))
                {
                    msg = "New password can't be null ";
                    txtPassword.Focus();
                }
                else if (txtPassword.Text != txtConfirmPassword.Text)
                {
                    msg = "Please confirm your new password ";
                    txtConfirmPassword.Focus();
                }
            }
            return(msg);
        }
Ejemplo n.º 12
0
 public Handler(IUnitOfWork unitOfWork,
                IJwtGenerator jwtGenerator, UtilFactory utilFactory, IMapperHelper mapperHelper)
 {
     _unitOfWork   = unitOfWork;
     _jwtGenerator = jwtGenerator;
     _cryptoHelper = utilFactory.CryptoHelper;
     _mapperHelper = mapperHelper;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Login and set cookie
        /// </summary>
        /// <param name="user">Login user</param>
        /// <param name="password"></param>
        /// <param name="remember"></param>
        /// <param name="url">null mean default,a url to redirect</param>
        public void LoginSystem(UsersEntity user, string password, bool remember)
        {
            IEncrypt encrypt            = UtilFactory.GetEncryptProvider(EncryptType.DES);
            string   loginUseridEncrypt = encrypt.Encrypt("LoginUserID");
            string   userIdEncrypt      = encrypt.Encrypt(user.ID.ToString());

            if (user.UserType == "SUNNET")
            {
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LoginUserID"), encrypt.Encrypt(user.ID.ToString()), true);
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_UserName_"), encrypt.Encrypt(user.UserName), true);
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("FirstName"), encrypt.Encrypt(user.FirstName), true);
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LastName"), encrypt.Encrypt(user.LastName), true);
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("CompanyID"), encrypt.Encrypt(user.CompanyID + ""), true);
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UserType"), encrypt.Encrypt(user.UserType), true);
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("ExpireTime"), "", true);
                if (remember)
                {
                    UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), encrypt.Encrypt(password),
                                                         DateTime.Now.AddDays(7));
                }
                else
                {
                    UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), string.Empty,
                                                         DateTime.Now.AddSeconds(1));
                }
            }
            else
            {
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LoginUserID"), encrypt.Encrypt(user.ID.ToString()),
                                                     DateTime.Now.AddMinutes(60));
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_UserName_"), encrypt.Encrypt(user.UserName),
                                                     DateTime.Now.AddDays(7));
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("FirstName"), encrypt.Encrypt(user.FirstName),
                                                     DateTime.Now.AddMinutes(60));
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LastName"), encrypt.Encrypt(user.LastName),
                                                     DateTime.Now.AddMinutes(60));
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("CompanyID"), encrypt.Encrypt(user.CompanyID + ""),
                                                     DateTime.Now.AddMinutes(60));
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UserType"), encrypt.Encrypt(user.UserType),
                                                     DateTime.Now.AddMinutes(60));
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("ExpireTime"), DateTime.Now.ToUniversalTime().AddMinutes(30).ToString(), DateTime.Now.AddMinutes(30));
                UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UtcTimeStamp"), (DateTime.UtcNow.AddMinutes(30) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds.ToString(), DateTime.Now.AddMinutes(30));
                if (remember)
                {
                    UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), encrypt.Encrypt(password),
                                                         DateTime.Now.AddDays(7));
                }
                else
                {
                    UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), string.Empty,
                                                         DateTime.Now.AddSeconds(1));
                }
            }


            IdentityContext.UserID    = user.ID;
            IdentityContext.CompanyID = user.CompanyID;
        }
Ejemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string email   = UserInfo.UserName;
            long   nowTick = DateTime.Now.Ticks;
            string seed    = email + nowTick + "SunNet&543#53";
            string sign    = UtilFactory.GetEncryptProvider(EncryptType.MD5).Encrypt(seed);

            Response.Redirect("http://crm.sunnet.us/sale/SSO.aspx?email=" + email + "&sign=" + sign + "&Timestamp=" + nowTick);
        }
Ejemplo n.º 15
0
        private void ResumeCookie()
        {
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);

            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LoginUserID"), 30);
            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("FirstName"), 30);
            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LastName"), 30);
            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("CompanyID"), 30);
        }
Ejemplo n.º 16
0
        protected override void process(Entity entity)
        {
            Health health = (Health)h_HealthMapper.get(entity);

            if (health.CurrentHealth <= 0)
            {
                Life life = (Life)h_LifeMapper.get(entity);

                if (life.IsAlive)
                {
                    UtilFactory.createSound("audio\\effects\\death", true, 1f);

                    //issue victory
                    Aggrivation aggro = (Aggrivation)h_AggroMapper.get(entity);

                    if (aggro != null)
                    {
                        foreach (Entity receiver in aggro.HateList)
                        {
                            Interactable interactor = (Interactable)h_InteractionMapper.get(entity);
                            Interactable interactee = (Interactable)h_InteractionMapper.get(receiver);

                            if (interactor == null || interactee == null)
                            {
                                continue;
                            }

                            if (interactor.SupportedInteractions.AWARDS_VICTORY &&
                                interactee.SupportedInteractions.MAY_RECEIVE_VICTORY)
                            {
                                UtilFactory.createVictoryAward(entity, receiver, GameConfig.AwardDefs.VictoryMinimum);
                            }
                        }
                    }
                }

                life.IsAlive = false;


                return;
            }

            health.TimeSinceLastRecover += ecs_instance.ElapsedTime;

            if (health.TimeSinceLastRecover > health.RecoveryRate)
            {
                health.TimeSinceLastRecover = 0;

                health.CurrentHealth += health.RecoveryAmmount;

                if (health.CurrentHealth > health.MaxHealth)
                {
                    health.CurrentHealth = health.MaxHealth;
                }
            }
        }
Ejemplo n.º 17
0
        private static void doWeaponDamage(ActionPackage aPack)
        {
            Item aWeapon = ActionUtils.getWeapon(aPack.Owner);
            Item dArmor  = ActionUtils.getArmor(aPack.Target);

            float aSkill = ActionUtils.getSkill(aPack.Owner, aPack.ActionDef.DamageDef.SkillName);
            float dSkill = ActionUtils.getSkill(aPack.Target, SkillName.AVOIDANCE);

            float aStat = ActionUtils.getStat(aPack.Owner, aPack.ActionDef.DamageDef.StatType);
            float dStat = ActionUtils.getStat(aPack.Target, ActionUtils.getOppositeStat(aPack.ActionDef.DamageDef.StatType));

            float aKnow = ActionUtils.getKnowledge(aPack.Owner, aPack.Target);
            float dKnow = ActionUtils.getKnowledge(aPack.Target, aPack.Owner);

            float aProb = ActionUtils.getStatProbability((float)aSkill, (float)aStat, aKnow, (float)aWeapon.Speed);
            float dProb = ActionUtils.getStatProbability((float)dSkill, (float)dStat, dKnow, (float)dArmor.Mobility);

            float hitProb = ActionUtils.getHitProbability(dProb, aProb, 1.75f, 0.15f);

            int damage = ActionUtils.getDamage(hitProb, aSkill, aStat, aWeapon.Lethality, dArmor.Mitigation,
                                               ActionUtils.getStat(aPack.Target, StatType.ENDURANCE));

            Position pos = ComponentMapper.get <Position> (aPack.Target);

            UtilFactory.createDirectDamage(damage,
                                           aPack.ActionDef.DamageDef.DamageType,
                                           aPack.Target,
                                           pos);

            Position newPos = new Position(pos.Pos + new Vector2(rand.Next(16) + 8, 0), Vector2.Zero);

            if (damage == 0)
            {
                UIFactory.createFloatingText("MISS",
                                             "DAMAGE",
                                             Color.White,
                                             500,
                                             newPos);
            }
            else
            {
                UIFactory.createFloatingText("" + damage,
                                             "DAMAGE",
                                             DamageUtils.getDamageColor(aPack.ActionDef.DamageDef.DamageType),
                                             500,
                                             newPos);
            }

            AwardUtils.attemptSkillAward(aPack.Owner, aPack.Target, aSkill, dSkill, aPack.ActionDef.DamageDef.SkillName, 1);
            AwardUtils.attemptStatAward(aPack.Owner, aPack.Target, aStat, dStat, aPack.ActionDef.DamageDef.StatType, 1);
            AwardUtils.attemptStatAward(aPack.Target, aPack.Owner,
                                        ActionUtils.getStat(aPack.Target, StatType.ENDURANCE), aStat,
                                        StatType.ENDURANCE, 1);
        }
Ejemplo n.º 18
0
        public void ProcessRequest(HttpContext context)
        {
            //UtilFactory.Helpers.CookieHelper.ResumeCookie();

            //旧方法有时间问题
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);

            UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("ExpireTime"), DateTime.Now.ToUniversalTime().AddMinutes(30).ToString(), DateTime.Now.AddMinutes(30));
            UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UtcTimeStamp"), (DateTime.UtcNow.AddMinutes(30) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds.ToString(), DateTime.Now.AddMinutes(30));
            context.Response.Write("true");
        }
Ejemplo n.º 19
0
        public void ResumeCookie()
        {
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);

            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LoginUserID"), 30);
            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("FirstName"), 30);
            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LastName"), 30);
            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("CompanyID"), 30);
            UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("UserType"), 30);
            UtilFactory.Helpers.CookieHelper.ResumeExpire(encrypt.Encrypt("ExpireTime"), 30);
            UtilFactory.Helpers.CookieHelper.ResumeExpire(encrypt.Encrypt("UtcTimeStamp"), 30);
        }
Ejemplo n.º 20
0
 public bool LoadPageLayoutTemplate(IPageLayoutControl pPageControl, string sTemplateID)
 {
     try
     {
         if (pPageControl == null)
         {
             Interaction.MsgBox("地图模板加载失败,控件 PageLayoutControl 加载失败。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (string.IsNullOrEmpty(Strings.Trim(sTemplateID)))
         {
             Interaction.MsgBox("地图模板加载失败,模板ID " + sTemplateID + " 错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         string configValue = null;
         configValue = UtilFactory.GetConfigOpt().GetConfigValue(sTemplateID);
         if (string.IsNullOrEmpty(configValue))
         {
             Interaction.MsgBox("地图模板加载失败,目录 " + configValue + " 错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (Strings.Right(configValue, 1) != @"\")
         {
             configValue = configValue + @"\";
         }
         string path = null;
         path = configValue + sTemplateID + ".mxt";
         if (!File.Exists(path))
         {
             Interaction.MsgBox("地图模板加载失败,模板文件 " + path + " 不存在。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (!pPageControl.CheckMxFile(path))
         {
             Interaction.MsgBox("地图模板加载失败,模板文件 " + path + " 内存在错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         pPageControl.LoadMxFile(path, null);
         IActiveView activeView = pPageControl.ActiveView;
         if (activeView.GraphicsContainer != null)
         {
             IViewManager manager          = activeView as IViewManager;
             ISelection   elementSelection = manager.ElementSelection;
             activeView.Selection = elementSelection;
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "LoadPageLayoutTemplate", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Ejemplo n.º 21
0
        protected BaseController()
        {
            ViewBag.LoginUserName = LoginUserName;
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);
            string   userId  = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("LoginUserID")));

            if (string.IsNullOrEmpty(userId))
            {
                IsOut = true;
            }
            ResumeCookie();
        }
Ejemplo n.º 22
0
        private void handleDirectDamage(Damage damage)
        {
            Health health = (Health)_HealthMapper.get(damage.Target);

            if (health != null)
            {
                //damage target
                health.CurrentHealth -= damage.DamageAmount;

                if (damage.DamageAmount > 0)
                {
                    if (((Interactable)_InteractMapper.get(damage.Target)).SupportedInteractions.MAY_ADVANCE)
                    {
                        int endurance = ((Statistics)_AttributeMapper.get(damage.Target)).Endurance.Value;

                        if (health.MaxHealth < (endurance * 5))
                        {
                            if (_Rand.NextDouble() <= ((double)(endurance * 5) - (double)health.MaxHealth) / (double)(endurance * 5))
                            {
                                UtilFactory.createHealthAward(damage.Target, 1);
                            }
                        }
                    }


                    //FIX
                    switch (_Rand.Next(0, 7))
                    {
                    case 1:
                        UtilFactory.createSound("audio\\effects\\hurt", true, 1f);
                        break;

                    case 3:
                        UtilFactory.createSound("audio\\effects\\hurt2", true, 1f);
                        break;

                    case 5:
                        UtilFactory.createSound("audio\\effects\\hurt3", true, 1f);
                        break;

                    case 7:
                        UtilFactory.createSound("audio\\effects\\hurt4", true, 1f);
                        break;

                    default:
                        break;
                    }
                }
            }

            damage.IsActive = false;
        }
Ejemplo n.º 23
0
        public int AddUser(UsersEntity user)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <UsersEntity> validator = new AddUserValidator();

            if (string.IsNullOrEmpty(user.Title))
            {
                user.Title = " ";
            }
            if (string.IsNullOrEmpty(user.Phone))
            {
                user.Phone = " ";
            }
            if (string.IsNullOrEmpty(user.Skype))
            {
                user.Skype = " ";
            }
            if (!validator.Validate(user))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(0);
            }
            if (userRepository.ExistsUserName(user.UserName, 0))
            {
                this.AddBrokenRuleMessage("Existsted Username", "Username already exists. Please input a new username.");
                return(0);
            }
            if (user.PassWord.Length <= 15)
            {
                user.PassWord = UtilFactory.GetEncryptProvider(EncryptType.MD5).Encrypt(user.PassWord);
            }
            int id = userRepository.Insert(user);

            if (id <= 0)
            {
                this.AddBrokenRuleMessage();
                return(0);
            }
            user.ID     = id;
            user.UserID = id;
            if (user.Status == "ACTIVE")
            {
                List <UsersEntity> list = GetActiveUserList();
                if (list != null)
                {
                    list.Add(user);
                }
            }
            return(id);
        }
Ejemplo n.º 24
0
        private void ResumeCookie()
        {
            IEncrypt encrypt  = UtilFactory.GetEncryptProvider(EncryptType.DES);
            string   userType = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("UserType")));

            if (userType != "SUNNET")
            {
                UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LoginUserID"), 30);
                UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("FirstName"), 30);
                UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LastName"), 30);
                UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("CompanyID"), 30);
                UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("UserType"), 30);
                UtilFactory.Helpers.CookieHelper.ResumeExpire(encrypt.Encrypt("ExpireTime"), 30);
            }
        }
Ejemplo n.º 25
0
        public bool UpdateUser(UsersEntity user)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <UsersEntity> validator = new UpdateUserValidator();

            if (!validator.Validate(user))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(false);
            }
            if (userRepository.ExistsUserName(user.UserName, user.ID))
            {
                this.AddBrokenRuleMessage("Existsted username", "Username already exists. Please input a new username.");
                return(false);
            }
            if (user.PassWord.Length <= 15)
            {
                user.PassWord = UtilFactory.GetEncryptProvider(EncryptType.MD5).Encrypt(user.PassWord);
            }
            if (!userRepository.Update(user))
            {
                this.AddBrokenRuleMessage();
                return(false);
            }
            List <UsersEntity> list = GetActiveUserList();

            if (list != null)
            {
                UsersEntity tmpUser = list.Find(r => r.UserID == user.UserID);
                if (tmpUser != null)
                {
                    list.Remove(tmpUser);
                    if (user.Status == "ACTIVE")
                    {
                        list.Add(user);
                    }
                }
                else
                {
                    if (user.Status == "ACTIVE")
                    {
                        list.Add(user);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 26
0
        private static void doStaticDamage(ActionPackage aPack)
        {
            int      dmg = rand.Next(aPack.ActionDef.DamageDef.Min, aPack.ActionDef.DamageDef.Max);
            Position pos = ComponentMapper.get <Position> (aPack.Target);

            UtilFactory.createDirectDamage(dmg,
                                           aPack.ActionDef.DamageDef.DamageType,
                                           aPack.Target,
                                           pos);

            Position newPos = new Position(pos.Pos + new Vector2(rand.Next(16) + 8, 0), Vector2.Zero);

            UIFactory.createFloatingText("" + dmg,
                                         "DAMAGE",
                                         DamageUtils.getDamageColor(aPack.ActionDef.DamageDef.DamageType),
                                         500,
                                         newPos);
        }
Ejemplo n.º 27
0
 private IColor GetDefaultColor(string sColorKey)
 {
     try
     {
         if (string.IsNullOrEmpty(sColorKey))
         {
             return(null);
         }
         Color black = Color.Black;
         black = Color.FromArgb(int.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("Symbol", sColorKey)));
         return(GISFunFactory.ColorFun.GetRGBColor(black));
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "GetDefaultColor", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
Ejemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);

            UtilFactory.Helpers.CookieHelper.Remove(encrypt.Encrypt("LoginUserID"));
            UtilFactory.Helpers.CookieHelper.RemoveAll();
            string url       = "/Login.aspx";
            string returnUrl = Server.UrlDecode(Request.QueryString["returnurl"]);

            if (!string.IsNullOrEmpty(returnUrl) && returnUrl.IndexOf(".aspx") > 0)
            {
                bool exist = File.Exists(Server.MapPath(returnUrl.Substring(0, returnUrl.IndexOf(".aspx") + 5)));
                if (exist)
                {
                    url += "?returnurl=" + Server.UrlEncode(returnUrl);
                }
            }
            Response.Redirect(url);
        }
Ejemplo n.º 29
0
 public bool LoadMapDocument(IMapControlDefault pMapControl, string sMxDocID)
 {
     try
     {
         if (pMapControl == null)
         {
             MessageBox.Show("地图文档加载失败,控件 MapControl 加载失败。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         if (string.IsNullOrEmpty(sMxDocID.Trim()))
         {
             MessageBox.Show("地图文档加载失败,文档ID " + sMxDocID + " 错误。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         string path = null;
         path = UtilFactory.GetConfigOpt().RootPath + @"\" + UtilFactory.GetConfigOpt().GetConfigValue(sMxDocID);
         if (!File.Exists(path))
         {
             MessageBox.Show("地图文档加载失败,文档文件 " + path + " 不存在。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         if (!pMapControl.CheckMxFile(path))
         {
             MessageBox.Show("地图文档加载失败,文档文件 " + path + " 内存在错误。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         pMapControl.LoadMxFile(path, null, null);
         IActiveView activeView = pMapControl.ActiveView;
         if (activeView.GraphicsContainer != null)
         {
             IViewManager manager          = activeView as IViewManager;
             ISelection   elementSelection = manager.ElementSelection;
             activeView.Selection = elementSelection;
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "LoadMapDocument", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Ejemplo n.º 30
0
        public string Login(string desUserName, string desPassword, bool rememberMe, out string id)
        {
            id = string.Empty;
            IEncrypt encrypt  = UtilFactory.GetEncryptProvider(EncryptType.DES);
            string   userName = encrypt.Decrypt(desUserName);
            string   password = encrypt.Decrypt(desPassword);

            if ((string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)))
            {
                return("failure");
            }
            UsersEntity usersEntity = userApplication.Login(userName, password);

            if (usersEntity == null)
            {
                return(FormatMessages(userApplication.BrokenRuleMessages));
            }
            id = usersEntity.UserID.ToString();
            return("successful");
        }