コード例 #1
0
 /// <summary>
 /// Gets the name of the project.
 /// </summary>
 /// <param name="userCred">The user credentials.</param>
 public static void InitDatabase(DB_BackgroundTransaction <RivieraDesignDatabase, Object> .TaskFinishHandler taskCompleted)
 {
     try
     {
         var tr = new Oracle_BackgroundTransaction <RivieraDesignDatabase, Object>();
         tr.Transaction =
             (DB_Connector conn, RivieraDesignDatabase[] rivDesignDB) =>
         {
             var dsgResult = new Dictionary <DesignLine, Object>();
             //Tablas globales de la aplicación
             RivieraDatabaseResult result = new RivieraDatabaseResult();
             result.RivieraCodeRows = RivieraCodeRow.SelectAll(conn);
             //Tablas exclusivas para una línea de diseño
             foreach (RivieraDesignDatabase db in rivDesignDB)
             {
                 dsgResult.Add(db.Line, db.InitDesignDatabase(conn));
             }
             result.DesignResult = dsgResult;
             return(result);
         };
         tr.TaskCompleted = taskCompleted;
         tr.Run(App.Riviera.OracleConnection, App.Riviera.Database.LineDB.Values.ToArray());
     }
     catch (Exception exc)
     {
         throw exc.CreateNamelessException <RivieraException>(ERR_INIT_DB);
     }
 }
コード例 #2
0
        /// <summary>
        /// Logins this instance.
        /// </summary>
        public static void Login(this CtrlOracleLogin login, UserCredential userCred)
        {
            var tr = new Oracle_BackgroundTransaction <Object, Object>();

            //Background Task
            tr.Transaction = (DB_Connector conn, Object[] input) =>
            {
                RivieraProject project;
                UserCredential cred        = input[0] as UserCredential;
                String         projectName = input[1] as String;
                int            exId        = Ejecutivo.GetEjecutivoId(cred, conn);
                if (exId == -1)
                {
                    throw new RivieraException(ERR_INVALID_USER_PASS);
                }
                project = RivieraProject.SelectProject(exId, projectName, conn);
                return(project);
            };
            //Task Completed action
            tr.TaskCompleted = async(BackgroundWorker worker, object result) =>
            {
                String         msg;
                RivieraProject prj = null;
                if (result is Exception)
                {
                    msg = (result as Exception).Message;
                }
                else if (result != null)
                {
                    prj                     = (RivieraProject)result;
                    login.ProjectId         = prj.Id;
                    userCred.ProjectId      = login.ProjectId;
                    App.Riviera.Credentials = userCred;
                    msg                     = String.Format(MSG_SESS_INIT, userCred.Username, prj.ProjectName);
                }
                else
                {
                    msg = String.Format(ASK_NEW_PROJECT, login.tboProject.Text);
                }
                if (!(result is Exception) && (prj == null && await login.ShowQuestionDialog(msg, String.Empty)))
                {
                    login.Login_CreateProject(userCred);
                }
                else
                {
                    await login.ShowDialog((result is Exception)?ERR_LOGIN : CAPTION_LOG_IN, msg);
                    await CloseProgressDialog();
                }
            };
            tr.Run(App.Riviera.OracleConnection, userCred, login.tboProject.Text);
        }
コード例 #3
0
        /// <summary>
        /// Login to the database creating a new project.
        /// </summary>
        /// <param name="login">The UI login.</param>
        /// <param name="userCred">The user credentials.</param>
        public static void Login_CreateProject(this CtrlOracleLogin login, UserCredential userCred)
        {
            var tr = new Oracle_BackgroundTransaction <Object, Object>();

            //Background Task
            tr.Transaction = (DB_Connector conn, Object[] input) =>
            {
                UserCredential cred        = input[0] as UserCredential;
                String         projectName = input[1] as String;
                int            exId        = Ejecutivo.GetEjecutivoId(cred, conn);
                RivieraProject pData       = new RivieraProject(projectName, exId),
                               newProject;//Nuevo proyecto
                if (pData.Insert <RivieraProject>(conn, out newProject))
                {
                    return(newProject);
                }
                else
                {
                    throw new RivieraException(String.Format(ERR_INS_PRJ, projectName, conn.Errors.Last().Message));
                }
            };
            tr.TaskCompleted = async(BackgroundWorker worker, object result) =>
            {
                String         msg;
                RivieraProject prj = null;
                if (result is Exception)
                {
                    msg = (result as Exception).Message;
                }
                else
                {
                    prj                     = (RivieraProject)result;
                    login.ProjectId         = prj.Id;
                    App.Riviera.Credentials = userCred;
                    msg                     = String.Format(MSG_SESS_INIT, userCred.Username, prj.ProjectName);
                }
                await login.ShowDialog((result is Exception)?ERR_LOGIN : CAPTION_LOG_IN, msg);
                await CloseProgressDialog();
            };
            tr.Run(App.Riviera.OracleConnection, userCred, login.tboProject.Text);
        }