Exemplo n.º 1
0
        private void InsertEvent_Load(object sender, EventArgs e)
        {
            DataTable dtLoc = new DataTable();
            DataTable dtCat = new DataTable();
            DataTable dtUse = new DataTable();

            Category cat = new Category();
            User use = new User();
            BusinessLayer.Location loc = new Location();

            dtLoc = loc.getLocaitonPickList();
            dtCat = cat.getCategoryPickList();
            dtUse = use.getPersonList();

            cboCat.DataSource = dtCat;
            cboLoc.DataSource = dtLoc;
            cboUser.DataSource = dtUse;

            cboCat.DisplayMember = "Descr";
            cboCat.ValueMember = "CategoryID";

            cboLoc.DisplayMember = "Descr";
            cboLoc.ValueMember = "LocationID";

            cboUser.DisplayMember = "Display";
            cboUser.ValueMember = "UserID";
        }
Exemplo n.º 2
0
        public void ModifyUser(String at, int userId, string forename, string surname, string password)
        {
            AuthenticationToken oAt = new AuthSvc().AuthUser(at, userId);

            BusinessLayer.User u = BusinessLayer.User.Populate(userId);

            u.Forename = forename;
            u.Password = password;
            u.Surname  = surname;

            u.Save();
        }
Exemplo n.º 3
0
        public static User CreateUser(string forename, string surname, string username, string password)
        {
            User u = new User();
                u.Forename = forename;
                u.Surname = surname;
                u.Username = username;
                u.Password = password;
                u.context = new marcdissertation_dbEntities();
                u = u.context.Users.Add(u);

                if (u.context.Users.Count(x => x.Username.Equals(username)) > 0) {
                    throw new Exception("Username must be unique.");
                }

                errors = u.context.GetValidationErrors();
            try {
                u.context.SaveChanges();
            } catch (Exception e) {
                throw App.ExceptionFormatter(errors);
            }
            return u;
        }
Exemplo n.º 4
0
        static public async Task<List<Task>> UploadTasksAsync(List<Task> tasks, User user)
        {

            // let the magic start, but now asynchronously, boom boom
            DataAccessLayer.DAL_Task dal_task = new DataAccessLayer.DAL_Task();
            return await dal_task.InsertTasksAsync(tasks, user);

        }
Exemplo n.º 5
0
        static public List<Task> UploadTasks(List<Task> tasks, User user)
        {

            // let the magic start
            DataAccessLayer.DAL_Task dal_task = new DataAccessLayer.DAL_Task();
            return dal_task.InsertTasks(tasks, user);

        }
Exemplo n.º 6
0
 static public async Task<List<Task>> UploadOfflineTasksAsync(User user)
 {
     // Better Performance because all the offline and online stuff is done in one place, but async
     DataAccessLayer.DAL_Task dal_task = new DataAccessLayer.DAL_Task();
     return await dal_task.UploadOfflineTasksAsync(user);
 }
Exemplo n.º 7
0
 static public List<Task> UploadOfflineTasks(User user)
 {
     // Better Performance because all the offline and online stuff is done in one place
     DataAccessLayer.DAL_Task dal_task = new DataAccessLayer.DAL_Task();
     return dal_task.UploadOfflineTasks(user);
 }
Exemplo n.º 8
0
        public override async Task<Position> GetPreisBeforeCommitAsync(Position position, string kundeId, Artikel artikel, string datum, string menge, string deviceLanguage, User user)
        {

            if (String.IsNullOrEmpty(kundeId))
                kundeId = "0";
            if (String.IsNullOrEmpty(menge))
                menge = "0";

            // it does not make a difference to use the function of angebot
            DataAccessLayer.DAL_Angebot dal_Angebot = new DataAccessLayer.DAL_Angebot();
            return await dal_Angebot.GetAngebotPreisBeforeCommitAsync(this,position,kundeId, artikel, datum, menge, deviceLanguage,  user);

        }
Exemplo n.º 9
0
        public override async System.Threading.Tasks.Task<DataAccessLayer.SOAResult> DownloadLocalAsync(User user, string deviceLanguage)
        {
            Console.WriteLine("__________________________________ START ___________________________________________________");
            DataAccessLayer.SOAResult result = DataAccessLayer.SOAResult.FALSE;
            try
            {
                // In this progress we increase the progress status, too
                // Main step: Lieranten Data
                ResetProgressStatus();

                ProgressStatusWish = 1;
                DataAccessLayer.DAL_Lieferant dal_Lieferant = new DataAccessLayer.DAL_Lieferant();

                // first check permission
                if (!user.HasPermission(DAC_Object.Lieferant,BusinessLayer.DAC_Permission.DOWN_UPLOAD))
                    return DataAccessLayer.SOAResult.TRUE;

                using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result = await dal_Lieferant.InsertLieferantAsync(this, user, true);
                }
                ProgressStatus = 1;

                // Then the related data
                // 1. Ansprechpartner
                // We don't check permission for Ansprechpartner, cause Tasks and other modules will use it 
                if (result == DataAccessLayer.SOAResult.TRUE )
                {

                    ProgressStatusWish += 2;
                    List<Ansprechpartner> ansprechpartnern = await Ansprechpartner.GetAnsprechpartnernAsync(this.ID, deviceLanguage,user);
                    ProgressStatus += 2;
                    ProgressStatusWish += 1;
                    DataAccessLayer.DAL_Ansprechpartner dal_ansprechpartner = new DataAccessLayer.DAL_Ansprechpartner();
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                        result = await System.Threading.Tasks.Task.Run(() => dal_ansprechpartner.InsertAnsprechpartnernAsync(ansprechpartnern, user, true));
                    }
                    ProgressStatus += 1;
                }

                // 2. PersonUmsatz for Charts
                if (result == DataAccessLayer.SOAResult.TRUE && user.HasPermission(DAC_Object.Lieferant_Chart,DAC_Permission.DOWN_UPLOAD))
                {

                    ProgressStatusWish += 3;
                    List<BusinessLayer.PersonUmsatz> PersonUmsatzList = await GetPersonTimeUmsatzAsync("36", user);
                    ProgressStatus += 3;
                    ProgressStatusWish += 2;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                        result = await System.Threading.Tasks.Task.Run(() => dal_Lieferant.InsertPersonUmsatzAsync(PersonUmsatzList, this, user, true));
                    }
                    ProgressStatus += 2;
                }

                // 3. Tasks and related data
                // I. Tasks
                DataAccessLayer.DAL_Task dal_task = new DataAccessLayer.DAL_Task();
                if (result == DataAccessLayer.SOAResult.TRUE && user.HasPermission(DAC_Object.Lieferant_Task,DAC_Permission.DOWN_UPLOAD))
                {

                    ProgressStatusWish += 11;
                    List<Task> tasks = await dal_task.GetTasksAsync(ID, user);
                    ProgressStatus += 11;
                    ProgressStatusWish += 32;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                                          result = await System.Threading.Tasks.Task.Run(() => dal_task.InsertTasksAsync(tasks, user, true));
                    }

                    //result = await dal_task.InsertTasksAsync(tasks, user, true);
                    ProgressStatus += 32;

                }

                // II. TaskArt
                // These are help data, so permission checking is not needed
                if (result == DataAccessLayer.SOAResult.TRUE )
                {

                    ProgressStatusWish += 2;
                    List<TaskArt> taskArts = await DataAccessLayer.DAL_Task.GetTaskArtsAsync(user);
                    ProgressStatus += 2;
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                                           result = await System.Threading.Tasks.Task.Run(() => dal_task.InsertTaskArtsAsync(taskArts, user, true));
                    }
                    ProgressStatus += 1;
                }

                // III. TaskTyp
                // These are help data, so permission checking is not needed
                if (result == DataAccessLayer.SOAResult.TRUE )
                {
                    ProgressStatusWish += 3;
                    List<TaskTyp> taskTyps = await DataAccessLayer.DAL_Task.GetTaskTypsAsync(user);
                    ProgressStatus += 3;
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                        result = await System.Threading.Tasks.Task.Run(() => dal_task.InsertTaskTypsAsync(taskTyps, user, true));
                    }
                    ProgressStatus += 1;
                }

                // IV. Mitarbeiter
                // These are help data, so permission checking is not needed
                if (result == DataAccessLayer.SOAResult.TRUE )
                {

                    ProgressStatusWish += 2;
                    List<Mitarbeiter> mitarbeitern = await DataAccessLayer.DAL_Task.GetTaskMitarbeiternAsync(user);
                    ProgressStatus += 2;
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                        result = await System.Threading.Tasks.Task.Run(() => dal_task.InsertMitarbeiternAsync(mitarbeitern, user, true));
                    }
                    ProgressStatus += 1;
                }

                // V. Abteilung
                // These are help data, so permission checking is not needed
                if (result == DataAccessLayer.SOAResult.TRUE )
                {
                    ProgressStatusWish += 2;
                    List<Abteilung> abteilungen = await DataAccessLayer.DAL_Task.GetTaskAbteilungenAsync(user);
                    ProgressStatus += 2;
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                                           result = await System.Threading.Tasks.Task.Run(() => dal_task.InsertAbteilungenAsync(abteilungen, user, true));
                    }
                    ProgressStatus += 1;
                }

                // VI. Anfragen
                DataAccessLayer.DAL_Anfrage dal_anfrage = new DataAccessLayer.DAL_Anfrage();
                DataAccessLayer.DAL_Position dal_position = new DataAccessLayer.DAL_Position();
                if (result == DataAccessLayer.SOAResult.TRUE && user.HasPermission(DAC_Object.Lieferant_Anfrage,DAC_Permission.DOWN_UPLOAD))
                {
                    ProgressStatusWish += 7;
                    List<Anfrage> anfragen = await dal_anfrage.GetAnfragenAsync(ID, deviceLanguage, user);
                    ProgressStatus += 7;
                    foreach (var anfrage in anfragen)
                    {
                        List<Position> positionen = await dal_position.GetPositionenAsync(anfrage.ID, anfrage.Waehrung, deviceLanguage, user);
                        result = await System.Threading.Tasks.Task.Run(() => dal_position.InsertPositionenAsync(positionen, user, true));
                    }
                    ProgressStatusWish += 11;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result =  await System.Threading.Tasks.Task.Run(() => dal_anfrage.InsertAnfragenAsync(anfragen, user, true));
                    }
                    ProgressStatus += 11;

                }

                // VI. Bestellungen
                DataAccessLayer.DAL_Bestellung dal_bestellung = new DataAccessLayer.DAL_Bestellung();

                if (result == DataAccessLayer.SOAResult.TRUE && user.HasPermission(DAC_Object.Lieferant_Bestellung,DAC_Permission.DOWN_UPLOAD))
                {
                    ProgressStatusWish += 7;
                    List<Bestellung> bestellungen = await dal_bestellung.GetBestellungenAsync(ID, deviceLanguage, user);
                    ProgressStatus += 7;
                    foreach (var bestellung in bestellungen)
                    {
                        List<Position> positionen = await dal_position.GetPositionenAsync(bestellung.ID, bestellung.Waehrung, deviceLanguage, user);
                        result = await System.Threading.Tasks.Task.Run(() => dal_position.InsertPositionenAsync(positionen, user, true));
                    }
                    ProgressStatusWish += 6;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                                           result =  await System.Threading.Tasks.Task.Run(() => dal_bestellung.InsertBestellungenAsync(bestellungen, user, true));
                    }
                    ProgressStatus += 6;

                }
            }
            catch (Exception ex)
            {
                DataAccessLayer.ExceptionWriter.WriteLogFile(ex);
            }

            return result;
        }
Exemplo n.º 10
0
        public static async Task<User> CreateAsync( string name, string password, string mandant, DataAccessLayer.NetworkState state, bool offline)
        {

            DataAccessLayer.DAL_Session dal_Session = new DataAccessLayer.DAL_Session ();
            var session = BusinessLayer.Session.Create ();

            // First the Name and Password have to be authiticated
            session = await dal_Session.GetSessionAsync (name, password, mandant, offline); 
            //DataAccessLayer.SOAResult result = await dal_Session.GetSessionAsync (session, name, password, mandant, state);
            if (session.Success == DataAccessLayer.SOAResult.Disconnected)
            {
                // Then there is a connection failure
                return null;
            }

            var user = new User ();

            if (session.Success == DataAccessLayer.SOAResult.FALSE)
            {
                // Username and Password were wrong, return an empty object
                return user;    
            }


            DataAccessLayer.DAL_User dal_User = new DataAccessLayer.DAL_User ();

            user.IdSession = session.ID;
            user.ID = session.UserID;
            user.Name = name;
            user.Password = password;
            user.Mandant = mandant;
            if (offline == true)
                user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;
            else
                user.NetworkStatus = state;


            if (state != DataAccessLayer.NetworkState.Disconnected && offline == false)
                await dal_User.SetUserPermissionsAsync ( user);

            return user;


        }
Exemplo n.º 11
0
        public static User Create( string name, string password, string mandant, DataAccessLayer.NetworkState state)
        {

            DataAccessLayer.DAL_Session dal_Session = new DataAccessLayer.DAL_Session ();
            var session = BusinessLayer.Session.Create ();

            // First the Name and Password have to be authiticated
            if (dal_Session.GetSession (ref session,name,password,mandant,state) == DataAccessLayer.SOAResult.Disconnected)
            {
                // Then there is a connection failure
                return null;
            }

            var user = new User ();

            if (session.Success == DataAccessLayer.SOAResult.FALSE)
            {
                // Username and Password were wrong, return an empty object
                return user;    
            }


            DataAccessLayer.DAL_User dal_User = new DataAccessLayer.DAL_User ();

            user.IdSession = session.ID;
            user.ID = session.UserID;
            user._Abteilung = session.Abteilung;
            user.Name = name;
            user.Password = password;
            user.Mandant = mandant;
            user.NetworkStatus = state;


            if (state != DataAccessLayer.NetworkState.Disconnected)
                dal_User.SetUserPermissions (ref user);

            return user;


        } 
Exemplo n.º 12
0
        public static async Task<User> CreateAsync( string name, string password, string mandant, DataAccessLayer.NetworkState state, bool offline)
        {

            DataAccessLayer.DAL_Session dal_Session = new DataAccessLayer.DAL_Session ();
            var session = BusinessLayer.Session.Create ();

            // First the Name and Password have to be authiticated
            session = await dal_Session.GetSessionAsync (name, password, mandant, offline); 
            //DataAccessLayer.SOAResult result = await dal_Session.GetSessionAsync (session, name, password, mandant, state);
            if (session.Success == DataAccessLayer.SOAResult.Disconnected)
            {
                // Then there is a connection failure
                return null;
            }

            var user = new User ();

            if (session.Success == DataAccessLayer.SOAResult.FALSE)
            {
                // Username and Password were wrong, return an empty object
                return user;    
            }


            DataAccessLayer.DAL_User dal_User = new DataAccessLayer.DAL_User ();

            user.IdSession = session.ID;
            user.ID = session.UserID;

            if (state != DataAccessLayer.NetworkState.Disconnected && offline == false)
            {
                user = await dal_User.SetUserPermissionsAsync(user);

                // set if the user is able to create tasks in the offline modus
                DataAccessLayer.DAL_User.SetOfflineInsertTask(
                    user.HasPermission(DAC_Object.Kunde_Task, BusinessLayer.DAC_Permission.CREATE),
                    user.HasPermission(DAC_Object.Lieferant_Task, BusinessLayer.DAC_Permission.CREATE),
                    user.HasPermission(DAC_Object.Interessent_Task, BusinessLayer.DAC_Permission.CREATE));                 
            }
            user.ID = session.UserID;
            user.Name = name;
            user.Password = password;
            user.Mandant = mandant;
            user.Abteilung = session.Abteilung;
            user.Adr_Vertr = session.Adr_Vertr;
            user.Adr_KeyAccount = session.Adr_KeyAccount;
            if (offline == true)
                user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;
            else
                user.NetworkStatus = state;



            return user;


        }
Exemplo n.º 13
0
        public override async Task<Position> GetPreisBeforeCommitAsync(Position position, string kundeId, Artikel artikel, string datum, string menge, string deviceLanguage, User user)
        {

            if (String.IsNullOrEmpty(kundeId))
                kundeId = "0";
            if (String.IsNullOrEmpty(menge))
                menge = "0";

            DataAccessLayer.DAL_Bestellung dal_Bestellung = new DataAccessLayer.DAL_Bestellung();
            return await dal_Bestellung.GetBestellungPreisBeforeCommitAsync(this,position,kundeId, artikel, datum, menge, deviceLanguage,  user);

        }
Exemplo n.º 14
0
        public override async System.Threading.Tasks.Task<DataAccessLayer.SOAResult> DownloadLocalAsync(User user, string deviceLanguage)
        {
            Console.WriteLine("__________________________________ START ___________________________________________________");
            DataAccessLayer.SOAResult result = DataAccessLayer.SOAResult.FALSE;
            try
                {
                // In this progress we increase the progress status, too
                // Main step: Kunden Data
                DataAccessLayer.PerformanceWatch stopWatch = new DataAccessLayer.PerformanceWatch();
                stopWatch.Start();
                ResetProgressStatus();

                ProgressStatusWish = 1;
                DataAccessLayer.DAL_Kunde dal_Kunde = new DataAccessLayer.DAL_Kunde();

                using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result = await dal_Kunde.InsertKundeAsync(this, user,true); 
                }
//                result = await dal_Kunde.InsertKundeAsync(this,  user,true);
                ProgressStatus = 1;
                stopWatch.Stop();
                stopWatch.PrintConsole ("InsertKundeAsync");



                // Then the related data
                // 1. Ansprechpartner

                if (result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 2;
                    List<Ansprechpartner> ansprechpartnern = await Ansprechpartner.GetAnsprechpartnernAsync(this.ID, deviceLanguage, user);
                    ProgressStatus += 2;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetAnsprechpartnernAsync");
                    stopWatch.Start();
                    ProgressStatusWish += 1;
                    DataAccessLayer.DAL_Ansprechpartner dal_ansprechpartner = new DataAccessLayer.DAL_Ansprechpartner();
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result =  await System.Threading.Tasks.Task.Run(() =>dal_ansprechpartner.InsertAnsprechpartnernAsync(ansprechpartnern,user,true));
                    }
                    ProgressStatus += 1;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertAnsprechpartnernAsync");
                    ansprechpartnern = null;
                }

                // 2. PersonUmsatz for Charts
                if (result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 3;
                    List<BusinessLayer.PersonUmsatz> PersonUmsatzList =  await GetPersonTimeUmsatzAsync ("36",   user);
                    ProgressStatus += 3;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetPersonTimeUmsatzAsync");
                    stopWatch.Start();
                    ProgressStatusWish += 2;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result =  await System.Threading.Tasks.Task.Run(() =>dal_Kunde.InsertPersonUmsatzAsync(PersonUmsatzList ,this, user, true));
                    }
                    ProgressStatus += 2;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertPersonUmsatzAsync");
                    PersonUmsatzList = null;
                    stopWatch.PrintConsole ("Finished InsertPersonUmsatzAsync");
                }

                // 3. Tasks and related data
                // I. Tasks
                DataAccessLayer.DAL_Task dal_task = new DataAccessLayer.DAL_Task();
                if (result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 11;
                    Console.WriteLine("Start dal_task.GetTasksAsync");
                    List<Task> tasks = await dal_task.GetTasksAsync(this.ID,  user);
                    ProgressStatus += 11;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetTasksAsync");
                    stopWatch.Start();
                    stopWatch.PrintConsole ("GetTasksAsync2");
                    ProgressStatusWish += 32;
                    stopWatch.PrintConsole ("GetTasksAsync3");

                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                                           result =  await System.Threading.Tasks.Task.Run(() =>dal_task.InsertTasksAsync(tasks, user, true));
                    }
                    stopWatch.PrintConsole ("GetTasksAsync4");

                    //result = await dal_task.InsertTasksAsync(tasks, user, true);
                    ProgressStatus += 32;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertTasksAsync");
                    tasks = null;

                }

                // II. TaskArt
                if (result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 2;
                    List<TaskArt> taskArts = await DataAccessLayer.DAL_Task.GetTaskArtsAsync(user);
                    ProgressStatus += 2;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetTaskArtsAsync");
                    stopWatch.Start();
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result =  await System.Threading.Tasks.Task.Run(() =>dal_task.InsertTaskArtsAsync(taskArts, user, true));
                    }
                    ProgressStatus += 1;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertTaskArtsAsync");
                    taskArts = null;
                }

                // III. TaskTyp
                if (result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 3;
                    List<TaskTyp> taskTyps = await DataAccessLayer.DAL_Task.GetTaskTypsAsync(user);
                    ProgressStatus += 3;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetTaskTypsAsync");
                    stopWatch.Start();
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                                           result =  await System.Threading.Tasks.Task.Run(() =>dal_task.InsertTaskTypsAsync(taskTyps, user, true));
                    }
                    ProgressStatus += 1;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertTaskTypsAsync");
                }

                // IV. Mitarbeiter
                if (result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 2;
                    List<Mitarbeiter> mitarbeitern = await DataAccessLayer.DAL_Task.GetTaskMitarbeiternAsync(user);
                    ProgressStatus += 2;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetTaskMitarbeiternAsync");
                    stopWatch.Start();
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result =  await System.Threading.Tasks.Task.Run(() =>dal_task.InsertMitarbeiternAsync(mitarbeitern, user, true));
                    }
                    ProgressStatus += 1;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertMitarbeiternAsync");
                }

                // V. Abteilung
                if (result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 2;
                    List<Abteilung> abteilungen = await DataAccessLayer.DAL_Task.GetTaskAbteilungenAsync(user);
                    ProgressStatus += 2;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetTaskAbteilungenAsync");
                    stopWatch.Start();
                    ProgressStatusWish += 1;
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result =  await System.Threading.Tasks.Task.Run(() => dal_task.InsertAbteilungenAsync(abteilungen, user, true));
                    }
                    ProgressStatus += 1;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertAbteilungenAsync");
                }

                // VI. Angebote
                DataAccessLayer.DAL_Angebot dal_angebot = new DataAccessLayer.DAL_Angebot();
                DataAccessLayer.DAL_Position dal_position = new DataAccessLayer.DAL_Position();
                if(result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 7;
                    List<Angebot> angebote = await dal_angebot.GetAngeboteAsync(ID, deviceLanguage, user);
                    ProgressStatus += 7;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetAngeboteAsync");
                    stopWatch.Start();
                    foreach (var angebot in angebote)
                    {
                        List<Position> positionen = await dal_position.GetPositionenAsync(angebot.ID, angebot.Waehrung, deviceLanguage, user);
                        result = await System.Threading.Tasks.Task.Run(() => dal_position.InsertPositionenAsync(positionen, user, true));
                    }
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("AngebotGetPositionenAsyncInsertPositionenAsync");
                    ProgressStatusWish += 11;
                    stopWatch.Start();
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                    result =  await System.Threading.Tasks.Task.Run(() => dal_angebot.InsertAngeboteAsync(angebote, user, true));
                    }
                    ProgressStatus += 11;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertAngeboteAsync");

                }

                // VI. Auftraege
                DataAccessLayer.DAL_Auftrag dal_auftrag = new DataAccessLayer.DAL_Auftrag();

                if(result == DataAccessLayer.SOAResult.TRUE)
                {
                    stopWatch.Start();
                    ProgressStatusWish += 7;
                    List<Auftrag> auftraege = await dal_auftrag.GetAuftraegeAsync(ID, deviceLanguage, user);
                    ProgressStatus += 7;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("GetAuftraegeAsync");
                    stopWatch.Start();
                    foreach (var auftrag in auftraege)
                    {

                        List<Position> positionen = await dal_position.GetPositionenAsync(auftrag.ID, auftrag.Waehrung, deviceLanguage, user);
                        result = await System.Threading.Tasks.Task.Run(() => dal_position.InsertPositionenAsync(positionen, user, true));
                    }
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("AuftragGetPositionenAsyncInsertPositionenAsync");
                    ProgressStatusWish += 6;
                    stopWatch.Start();
                    using (await DataAccessLayer.SQLiteUtilities.Mutex.LockAsync ().ConfigureAwait (false)) { 
                                           result =  await System.Threading.Tasks.Task.Run(() => dal_auftrag.InsertAuftraegeAsync(auftraege, user, true));
                    }
                    ProgressStatus += 6;
                    stopWatch.Stop();
                    stopWatch.PrintConsole ("InsertAuftraegeAsync");
                    Console.WriteLine("__________________________________ END ___________________________________________________");

                }
            }
            catch (Exception ex)
            {
                DataAccessLayer.ExceptionWriter.WriteLogFile(ex);
            }

            return result;

        }
Exemplo n.º 15
0
        public override DataAccessLayer.SOAResult DownloadLocal( string deviceLanguage ,ref User user)
        {
            // First we have to save the Kunde data
            DataAccessLayer.SOAResult result;
            DataAccessLayer.DAL_Kunde dal_Kunde = new DataAccessLayer.DAL_Kunde();
            result = dal_Kunde.InsertKunde(this, ref user,true);

            // Then the related data
            // 1. Ansprechpartner
            if (result == DataAccessLayer.SOAResult.TRUE)
            {
                ProgressStatusWish += 3;
                List<Ansprechpartner> ansprechpartnern = Ansprechpartner.GetAnsprechpartnern(this.ID, deviceLanguage, ref user);
                ProgressStatus += 3;
                ProgressStatusWish += 1;
                DataAccessLayer.DAL_Ansprechpartner dal_ansprechpartner = new DataAccessLayer.DAL_Ansprechpartner();
                result = dal_ansprechpartner.InsertAnsprechpartnern(ansprechpartnern,user,true);
                ProgressStatus += 1;
            }

            if (result == DataAccessLayer.SOAResult.TRUE)
            {
                ProgressStatusWish += 3;
                List<BusinessLayer.PersonUmsatz> PersonUmsatzList = GetPersonTimeUmsatz("36", ref user);
                ProgressStatus += 3;
                ProgressStatusWish += 4;
                result = dal_Kunde.InsertPersonUmsatz(PersonUmsatzList, this, user, true);
                ProgressStatus += 4;

            }

            DataAccessLayer.DAL_Task dal_task = new DataAccessLayer.DAL_Task();
            if (result == DataAccessLayer.SOAResult.TRUE)
            {
                ProgressStatusWish += 11;
                List<Task> tasks = dal_task.GetTasks(ID, ref user);
                ProgressStatus += 11;
                ProgressStatusWish += 51;
                result = dal_task.InsertTasks(tasks, user, true);
                ProgressStatus += 51;
            }

            if (result == DataAccessLayer.SOAResult.TRUE)
            {
                ProgressStatusWish += 4;
                List<TaskArt> taskArts =  DataAccessLayer.DAL_Task.GetTaskArts(ref user);
                ProgressStatusWish += 1;
                result = dal_task.InsertTaskArts(taskArts, user, true);
                ProgressStatus += 1;
            }

            // III. TaskTyp
            if (result == DataAccessLayer.SOAResult.TRUE)
            {
                ProgressStatusWish += 4;
                List<TaskTyp> taskTyps = DataAccessLayer.DAL_Task.GetTaskTyps(ref user);
                ProgressStatus += 4;
                ProgressStatusWish += 1;
                result = dal_task.InsertTaskTyps(taskTyps, user, true);
                ProgressStatus += 1;
            }

            // IV. Mitarbeiter
            if (result == DataAccessLayer.SOAResult.TRUE)
            {
                ProgressStatusWish += 6;
                List<Mitarbeiter> mitarbeitern = DataAccessLayer.DAL_Task.GetTaskMitarbeitern(ref user);
                ProgressStatus += 6;
                ProgressStatusWish += 3;
                result = dal_task.InsertMitarbeitern(mitarbeitern, user, true);
                ProgressStatus += 3;
            }
                
            // V. Abteilung
            if (result == DataAccessLayer.SOAResult.TRUE)
            {
                ProgressStatusWish += 6;
                List<Abteilung> abteilungen =  DataAccessLayer.DAL_Task.GetTaskAbteilungen(ref user);
                ProgressStatus += 6;
                ProgressStatusWish += 1;
                result =  dal_task.InsertAbteilungen(abteilungen, user, true);
                ProgressStatus += 1;
            }
    
            return result;
        }