Exemplo n.º 1
0
        private async Task <bool> CheckDatabase(string dbName)
        {
            lblStatus.Text = "در حال بررسی وجود دیتابیس!";
            var connectionString = "";

            connectionString = ConfigurationManager.ConnectionStrings[dbName + "ConnectionString"].ConnectionString;
            var connectionStringBuilder = new SqlConnectionStringBuilder(connectionString);

            if (!await CheckDataBaseExists(connectionStringBuilder, dbName))
            {
                lblStatus.Text = "در حال ایجاد دیتابیس!";
                IEContext db = new IEContext(connectionString);
                if (dbName == "IE")
                {
                    if (!db.Database.CreateIfNotExists())
                    {
                        return(false);
                    }
                    InsertAdminUser(db);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var       iEConnectionString = ConfigurationManager.ConnectionStrings["IEConnectionString"].ConnectionString;
            IEContext ie = new IEContext(iEConnectionString);
            var       q  = ie.Users.Where(w => w.UserName == txtUserName.Text).Count();

            if (q == 0)
            {
                MessageBox.Show("نام کاربری اشتباه است");
            }
            else
            {
                var user    = ie.Users.Where(w => w.UserName == txtUserName.Text).Single();
                var current = new HashGenerator(txtPassword.Text);
                if (current.Hash() == user.Password)
                {
                    Main m = new IE.Main();
                    this.Hide();
                    m.ShowDialog();
                }
                else
                {
                    MessageBox.Show("رمز عبور اشتباه است");
                }
            }
        }
Exemplo n.º 3
0
        private void ConfigureDataContexts()
        {
            var iEConnectionString = ConfigurationManager.ConnectionStrings["IEConnectionString"].ConnectionString;

            ie = new IEContext(iEConnectionString);
            Database.SetInitializer <IEContext>(null);
            db = new DelphiEntities.LinQ.DelphiDataContext(ConfigurationManager.ConnectionStrings["DelphiConnectionString"].ConnectionString);
            g3 = new G3Context(ConfigurationManager.ConnectionStrings["Fin3ConnectionString"].ConnectionString);
        }
Exemplo n.º 4
0
 private void InsertAdminUser(IEContext db)
 {
     db.Users.Add(new User()
     {
         UserID     = 1,
         UserName   = "******",
         Password   = "******",
         CreateDate = DateTime.Now
     });
     db.SaveChanges();
 }
Exemplo n.º 5
0
        private void Login_Load(object sender, EventArgs e)
        {
            var       iEConnectionString = ConfigurationManager.ConnectionStrings["IEConnectionString"].ConnectionString;
            IEContext ie      = new IEContext(iEConnectionString);
            var       newHash = new HashGenerator("123");

            if (ie.Users.Count() == 0)
            {
                var newUser = new User();
                newUser.CreateDate = DateTime.Now;
                newUser.Password   = newHash.Hash();
                newUser.UserName   = "******";
                ie.Users.Add(newUser);
                ie.SaveChanges();
            }
        }
Exemplo n.º 6
0
        private static void InstallIeContextMenuItem(string registryKeyName, string suffix,
                                                     IEContext contexts)
        {
            lock (_filesCreateLock)
            {
                try
                {
                    var resShowMessageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                        "Rsdn.Janus." + typeof(GoUrl).Assembly.ManifestModule.Name + suffix);
                    if (resShowMessageStream == null)
                    {
                        throw new ApplicationException("Could not create resource stream");
                    }

                    const int copyBufSize = 8192;
                    var       buffer      = new byte[copyBufSize];

                    using (var fs = new FileStream(typeof(GoUrl).Assembly.Location + suffix, FileMode.Create))
                    {
                        int bytesRead;
                        while ((bytesRead = resShowMessageStream.Read(buffer, 0, copyBufSize)) != 0)
                        {
                            fs.Write(buffer, 0, bytesRead);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            using (var rk = Registry.CurrentUser.CreateSubKey(registryKeyName))
            {
                if (rk == null)
                {
                    throw new ApplicationException("Could not create registry key");
                }
                rk.SetValue("", typeof(GoUrl).Assembly.CodeBase + suffix);
                if (contexts != IEContext.Unknown)
                {
                    rk.SetValue("contexts", (int)contexts);
                }
                rk.SetValue(ClsId, "");
            }
        }
Exemplo n.º 7
0
        private bool ReadConfigurations()
        {
            var       iEConnectionString = ConfigurationManager.ConnectionStrings["IEConnectionString"].ConnectionString;
            IEContext ie = new IEContext(iEConnectionString);

            if (ie.Configurations.Where(w => w.Name == "Branch").Count() == 0)
            {
                return(false);
            }
            else
            {
                var q = ie.Configurations.Where(w => w.Name == "Branch").Single();
                BranchRef = long.Parse(q.Value);
            }

            if (ie.Configurations.Where(w => w.Name == "Ledger").Count() == 0)
            {
                return(false);
            }
            else
            {
                var q = ie.Configurations.Where(w => w.Name == "Ledger").Single();
                LedgerRef = long.Parse(q.Value);
            }

            if (ie.Configurations.Where(w => w.Name == "FiscalYear").Count() == 0)
            {
                return(false);
            }
            else
            {
                var q = ie.Configurations.Where(w => w.Name == "FiscalYear").Single();
                FiscalYearRef = long.Parse(q.Value);
            }
            return(true);
        }
Exemplo n.º 8
0
 public AnswerRepository(IEContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
 public QuestionsRepository(IEContext context)
 {
     _context = context;
 }