Ejemplo n.º 1
0
        /// <summary>
        /// This method updates documents in the collection using linq extended operators
        /// </summary>
        /// <param name="product1"> Product that will be modified during the operation </param>
        private void UpdateUsingExtendedLinq(Product product1)
        {
            // Update the UnitsInStock, UnitPrice for the products with category "Milk Products"
            DBUpdateBuilder update = DBUpdate.Set("UnitsInStock", 3).Set("UnitPrice", 420);
            // Update documents in the Products collection:
            long rowsAffected = _prodUpdatable.Update(update, x => x.ID == product1.ID, WriteConcern.InMemory);

            Console.WriteLine(string.Format("{0} documents updated in '{1}' collection", rowsAffected,
                                            _productsCollection.Name));
        }
Ejemplo n.º 2
0
 public CustomerDataTable()
 {
     cus       = new Customer();
     util      = new Utility(log);
     log       = new LogWrite(new LogOpen());
     dbString  = new DBConnectionString(log);
     dbConnect = new DBConnect(dbString, log);
     dbFill    = new DBFill(dbConnect, log);
     dbDelete  = new DBDelete(dbConnect, log);
     dbInsert  = new DBInsert(dbConnect, log);
     dbUpdate  = new DBUpdate(dbConnect, log);
     dbFilter  = new DBFilter(dbConnect, log);
 }
Ejemplo n.º 3
0
        public IActionResult UpdateDB()
        {
            try
            {
                var task = DBUpdate.Begin(_configuration);

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogCritical("Exception on UpdateDB.", ex);
                return(StatusCode(500));
            }
        }
Ejemplo n.º 4
0
        public Project(int t_Id, string t_ProjectName, string t_ProjectDescription, Nullable <DateTime> t_ApprovalDate, Priority t_Priority, State t_ProjectState, DateTime t_PlannedStartdate, DateTime t_PlannedEnddate, Nullable <DateTime> t_Startdate, Nullable <DateTime> t_Enddate, int t_ProjectProgress, string t_ProjectDocumentsLink, int t_ProjectMethodId, int t_EmployeeId)
        {
            Id                   = t_Id;
            ProjectName          = t_ProjectName;
            ProjectDescription   = t_ProjectDescription;
            ApprovalDate         = t_ApprovalDate;
            Priority             = t_Priority;
            ProjectState         = t_ProjectState;
            PlannedStartdate     = t_PlannedStartdate;
            PlannedEnddate       = t_PlannedEnddate;
            Startdate            = t_Startdate;
            Enddate              = t_Enddate;
            ProjectProgress      = t_ProjectProgress;
            ProjectDocumentsLink = t_ProjectDocumentsLink;
            ProjectMethodId      = t_ProjectMethodId;
            EmployeeId           = t_EmployeeId;

            _dbUpdateObj = new DBUpdate();
        }
Ejemplo n.º 5
0
        // Projektphasen definieren
        public void Define(Nullable <DateTime> t_plannedstartdate, Nullable <DateTime> t_plannedenddate, Nullable <DateTime> t_plannedreviewdate, string t_phasedocumentslink, string t_phasename)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.DefineProjectPhase(Id, t_plannedstartdate, t_plannedenddate, t_plannedreviewdate, t_phasedocumentslink);

            // Prüfen, ob schon ein Meilenstein existiert
            DBGet dbGetObj       = new DBGet();
            var   checkMilestone = dbGetObj.GeneralGet("Milestone", Id);

            // Existiert noch kein Meilenstein, wird eine Meilenstein am geplanten Phasenende definiert
            if (checkMilestone.Count == 0)
            {
                if (t_plannedenddate != null)
                {
                    string milestoneName = t_phasename + " Ende";

                    DBCreate dbCreateObj = new DBCreate();
                    dbCreateObj.MilestoneCreate(milestoneName, t_plannedenddate, Id);
                }
            }
        }
Ejemplo n.º 6
0
        // Effektive Kosten setzen
        public void SetCost(Nullable <int> t_EffectiveCost, string t_Deviation)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.SetExternalCost(Id, t_EffectiveCost, t_Deviation);
        }
Ejemplo n.º 7
0
        // Aktivitätstatus setzen
        public void SetState(int t_ActivityProgress)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.SetActivityState(Id, t_ActivityProgress);
        }
Ejemplo n.º 8
0
        // Aktivitätdatum setzen
        public void SetDates(Nullable <DateTime> t_Startdate, Nullable <DateTime> t_Enddate)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.SetActivityDates(Id, t_Startdate, t_Enddate);
        }
Ejemplo n.º 9
0
        // Effektive Zeit setzen
        public void SetTime(Nullable <int> t_EffectiveTime, string t_Deviation)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.SetEmployeeResource(Id, t_EffectiveTime, t_Deviation);
        }
Ejemplo n.º 10
0
        // ProjektPhase freigeben
        public void Release(Nullable <DateTime> t_approvaldate, string t_visum, State t_projectphasestate)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.SetPhaseApprovalDate(Id, t_approvaldate, t_visum, t_projectphasestate);
        }
Ejemplo n.º 11
0
        // ProjektPhase Status setzen
        public void SetState(int t_progress, State t_phasestate)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.SetPhaseState(Id, t_progress, t_phasestate);
        }
Ejemplo n.º 12
0
        // ProjektPhase Datum setzen
        public void SetDates(Nullable <DateTime> t_StartDate, Nullable <DateTime> t_EndDate, Nullable <DateTime> t_ReviewDate)
        {
            DBUpdate dbUpdateObj = new DBUpdate();

            dbUpdateObj.SetPhaseDates(Id, t_StartDate, t_EndDate, t_ReviewDate);
        }
Ejemplo n.º 13
0
        public static bool TestServer(out string ErrorReason, bool SkipSomeSanityChecks = false)
        {
            ErrorReason = "";

            SQLLib sql = null;

            try
            {
                if (Settings.Default.DBType.ToLower() == "mssql")
                {
                    if (Settings.Default.DBServer == "" || Settings.Default.DBDB == "")
                    {
                        ErrorReason = "Servername / DB missing";
                        return(false);
                    }
                    sql = new SQLLib();
                    sql.SqlCommandTimeout = 0; //waiting .... :-)
                    sql.ApplicationName   = "Fox SDC Server [test/update connection]";
                    sql.ConnectionPooling = false;
                    sql.SEHError          = true;
                    if (sql.ConnectDatabase(Settings.Default.DBServer, Settings.Default.DBDB, true) == false)
                    {
                        ErrorReason = "Cannot connect to the SQL Server";
                        return(false);
                    }
                }
                if (Settings.Default.DBType.ToLower() == "localdb")
                {
                    if (Settings.Default.DBLocalPath == "")
                    {
                        ErrorReason = "LocalDB path missing";
                        return(false);
                    }
                    sql = new SQLLib();
                    sql.SqlCommandTimeout = 0; //waiting .... :-)
                    sql.ApplicationName   = "Fox SDC Server [test/update connection]";
                    sql.ConnectionPooling = false;
                    sql.SEHError          = true;
                    if (sql.ConnectLocalDatabase(Settings.Default.DBLocalPath) == false)
                    {
                        ErrorReason = "Cannot connect to the SQL Server";
                        return(false);
                    }
                }
            }
            catch (Exception ee)
            {
                ErrorReason = "Cannot connect to the SQL Server [SEH]\n" + ee.ToString();
                Debug.WriteLine(ee.ToString());
                return(false);
            }

            if (sql == null)
            {
                ErrorReason = "sql==null //is the SQL Profile properly defined in registry?\n";
                return(false);
            }

            string ServerVersion = Convert.ToString(sql.ExecSQLScalar("SELECT SERVERPROPERTY('productversion')"));
            string ServerVPart   = ServerVersion.Split('.')[0].Trim();
            int    ServerVPartI  = 0;

            if (int.TryParse(ServerVPart, out ServerVPartI) == false)
            {
                sql.CloseConnection();
                ErrorReason = "Cannot read SQL Version";
                return(false);
            }
            if (ServerVPartI < 11)
            {
                sql.CloseConnection();
                ErrorReason = "Unsupported SQL Version - Minimum V.11 (SQL 2012)";
            }

            try
            {
                sql.ExecSQL("SELECT * FROM Config");
            }
            catch
            {
                sql.CloseConnection();
                ErrorReason = "Cannot SELECT Table CONFIG.";
                return(false);
            }

            try
            {
                if (Convert.ToString(sql.ExecSQLScalar("SELECT Value FROM Config WHERE [Key]='ID'")) != "FOXSDCv1")
                {
                    sql.CloseConnection();
                    ErrorReason = "Invalid ID in Config Table";
                    return(false);
                }
            }
            catch
            {
                sql.CloseConnection();
                ErrorReason = "Cannot SELECT Table CONFIG. (ID)";
                return(false);
            }

            while (DBUpdate.UpdateDB(sql) == false)
            {
                ;
            }

            sql.SEHError = true;

            try
            {
                if (Convert.ToInt32(sql.ExecSQLScalar("SELECT Value FROM Config WHERE [Key]='Version'")) != Program.DBVersion)
                {
                    sql.CloseConnection();
                    ErrorReason = "Invalid Version in Config Table";
                    return(false);
                }
            }
            catch
            {
                sql.CloseConnection();
                ErrorReason = "Cannot SELECT Table CONFIG. (Version)";
                return(false);
            }

            if (Convert.ToInt32(sql.ExecSQLScalar("SELECT COUNT(*) FROM Users WHERE Username='******'")) == 0)
            {
                FoxEventLog.WriteEventLog("Creating user ROOT", EventLogEntryType.Warning);
                sql.InsertMultiData("Users",
                                    new SQLData("Username", "root"),
                                    new SQLData("Name", "Root User"),
                                    new SQLData("Password", DefaultPasswordHash),
                                    new SQLData("Permissions", AllPermissions),
                                    new SQLData("MustChangePassword", 1));
            }
            if (Convert.ToInt32(sql.ExecSQLScalar("SELECT COUNT(*) FROM Users WHERE Username='******' AND Permissions=@p", new SQLParam("@p", AllPermissions))) == 0)
            {
                FoxEventLog.WriteEventLog("Fixing user ROOT", EventLogEntryType.Warning);
                sql.ExecSQL("UPDATE Users SET Permissions=@p WHERE Username='******'", new SQLParam("@p", AllPermissions));
            }

            try
            {
                Guid g;
                if (Guid.TryParse(Convert.ToString(sql.ExecSQLScalar("SELECT Value FROM Config WHERE [Key]='GUID'")), out g) == false)
                {
                    FoxEventLog.WriteEventLog("Creating GUID", EventLogEntryType.Warning);
                    sql.ExecSQL("DELETE FROM Config WHERE [Key]='GUID'");
                    sql.ExecSQL("INSERT INTO Config VALUES ('GUID', @g)", new SQLParam("@g", Guid.NewGuid().ToString()));
                }
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.ToString());
                ErrorReason = "Cannot verify GUID";
                return(false);
            }


            SettingsManager.LoadSettings(sql);

            //try
            //{
            //    string ret = Convert.ToString(sql.ExecSQLScalar("select dbo.FoxCreateSerial(1, 1)"));
            //}
            //catch (Exception ee)
            //{
            //    Debug.WriteLine(ee.ToString());
            //    ErrorReason = "Cannot execute FUNCTIONs in SQL";
            //    return (false);
            //}

            sql.CloseConnection();
            ErrorReason = "";
            return(true);
        }