Ejemplo n.º 1
0
        /// <summary>
        /// Prevents a default instance of the <see cref="SystemSetting"/> class from being created.
        /// </summary>
        SystemSetting()
        {
            IUser         usrMgr  = (IUser)ObjectFactory.CreateInstance("BusinessProcess.Security.BUser, BusinessProcess.Security");
            DataSet       theDS   = usrMgr.GetFacilitySettings();
            DataRow       r       = theDS.Tables[1].Rows[0];
            SystemVersion version = new SystemVersion()
            {
                Id          = Convert.ToInt32(r["Id"]),
                AppVersion  = r["AppVer"].ToString(),
                DBVersion   = r["DbVer"].ToString(),
                ReleaseDate = Convert.ToDateTime(r["RelDate"]),
                VersionName = Convert.ToString(r["VersionName"])
            };

            this.isValid = true;
            List <Facility> facilities = null;

            this.responseCode = SystemSettingResponseCode.Success;
            if (theDS.Tables[0].Rows.Count > 0)
            {
                facilities = (from row in theDS.Tables[0].AsEnumerable()
                              select new Facility()
                {
                    Currency = row["Currency"].ToString(),
                    MasterIndex = row["PosID"].ToString(),
                    PaperLess = Convert.ToBoolean(row["Paperless"]),
                    Preffered = Convert.ToBoolean(row["Preferred"]),
                    Id = Convert.ToInt32(row["FacilityID"]),
                    Name = Convert.ToString(row["FacilityName"]),
                    GracePeriod = Convert.ToInt32(row["AppGracePeriod"]),
                    BackupDrive = row["BackupDrive"].ToString(),
                    Active = true,
                    LoginImage = row["Image"].ToString(),
                    SystemId = Convert.ToInt32(row["SystemId"]),
                    SatelliteId = Convert.ToInt32(row["SatelliteID"]),
                    DeleteFlag = false
                }
                              ).ToList();
                Configured = true;
            }
            else
            {
                this.responseCode = SystemSettingResponseCode.NoFacilityDefined;
                this.isValid      = false;
                Configured        = false;
            }
            if (version.AppVersion != GblIQCare.AppVersion || version.ReleaseDate.ToString("dd-MMM-yyyy") != GblIQCare.ReleaseDate)
            {
                this.responseCode = SystemSettingResponseCode.WrongVersion;
                this.isValid      = false;
            }
            this.Facilities = facilities;
            this.Version    = version;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the application parameters.
        /// </summary>
        private void GetApplicationParameters()
        {
            //IUser ApplicationManager;
            //  ApplicationManager = (IUser)ObjectFactory.CreateInstance("BusinessProcess.Security.BUser, BusinessProcess.Security");
            SystemSettingResponseCode response = SystemSetting.GetFacilitySettings();
            DateTime theDTime = SystemSetting.SystemDate;

            ViewState["theCurrentDate"] = theDTime;
            lblDate.Text = theDTime.ToString("dd-MMM-yyyy");
            Application["AppCurrentDate"]  = theDTime.ToString("dd-MMM-yyyy");
            Session["AppCurrentDateClass"] = theDTime.ToString("dd-MMM-yyyy");


            #region "Version Control"


            if (response == SystemSettingResponseCode.WrongVersion)
            {
                string script = "<script language = 'javascript' defer ='defer' id = 'confirm'>\n";
                script += "var ans=true;\n";
                script += "alert('You are using a Wrong Version of Application. Please contact Support staff.');\n";
                script += "if (ans==true)\n";
                script += "{\n";
                script += "window.close() - y;\n";
                script += "}\n";
                script += "</script>\n";
                ClientScript.RegisterStartupScript(this.GetType(), "confirm", script);
                btnLogin.Enabled = false;
                return;
            }

            if (response == SystemSettingResponseCode.NoFacilityDefined)
            {
                btnLogin.Text        = "Go to Setup";
                txtuname.Text        = "Admin";
                txtpassword.Text     = "SetupPassword";
                txtpassword.ReadOnly = txtuname.ReadOnly = true;
                ddLocation.Items.Insert(0, new ListItem("Select", "0"));
                ddLocation.SelectedIndex   = 0;
                Session["AppUserId"]       = "";
                Session["AppUserName"]     = "";
                btnLogin.CommandName       = "Setup";
                Session["AppLocationId"]   = "";
                Session["AppLocation"]     = "";
                btnLogin.UseSubmitBehavior = true;
                btnLogin.OnClientClick     = string.Format("javascript:window.location='{0}'; return false;", "../AdminForms/frmAdmin_FacilityList.aspx");
                //  string theUrl = string.Format("{0}", "./AdminForms/frmAdmin_FacilityList.aspx");

                //HttpContext.Current.ApplicationInstance.CompleteRequest();
                // Response.Redirect(theUrl,false);
                return;
            }
            if (response == SystemSettingResponseCode.Success)
            {
                SystemSetting setting = SystemSetting.CurrentSystem;
                btnLogin.CommandName = "Login";
                if (!string.IsNullOrEmpty(setting.DefaultFacility.LoginImage))
                {
                    imgLogin.ImageUrl = string.Format("images/{0}", setting.DefaultFacility.LoginImage);
                }
                else
                {
                    imgLogin.ImageUrl = "~/Images/Login.jpg";
                }
                Session["SystemId"] = Convert.ToInt32(setting.DefaultFacility.SystemId);
                BindCombo();
            }
            #endregion
        }