Esempio n. 1
0
        private static bool Connect()
        {
            _connetions = new DataConnections
            {
                UserPass = _args.UserPassword
            };

            bool allConnected = true;

            if (_args.PcPath != null && !_connetions.TrySetPcBase(_args.PcPath))
            {
                allConnected &= _connetions.TryCreateAndSetPcBase(_args.PcPath);
            }

            if (_args.PhonePath != null && !_connetions.TrySetPhoneBase(_args.PhonePath))
            {
                allConnected &= _connetions.TryCreateAndSetPhoneBase(_args.PhonePath);
            }

            if (_args.UsePsd)
            {
                allConnected &= ConnectPsd();
            }


            return(allConnected);
        }
Esempio n. 2
0
 bool IDataPersistence.Persist(IPersistence persistence)
 {
     persistence.UpsertField(Constants.IDataPesistence_InitializeMode, InitializeMode.ToString());
     persistence.UpsertField(Constants.IDataPesistence_PersistMode, PersistMode.ToString());
     persistence.UpsertFieldArray(Constants.IDataPesistence_DataConnections, DataConnections.ToArray());
     return(true);
 }
 protected void BtnDelete_Click1(object sender, EventArgs e)
 {
     SqlParameter[] sqlParams;
     {
         sqlParams          = new SqlParameter[3];
         sqlParams[0]       = new SqlParameter("@FirstName", SqlDbType.VarChar, 40);
         sqlParams[0].Value = TxtAddFName.Text.Trim();
         sqlParams[1]       = new SqlParameter("@LastName", SqlDbType.VarChar, 40);
         sqlParams[1].Value = TxtAddLName.Text.Trim();
         sqlParams[2]       = new SqlParameter("@Email", SqlDbType.VarChar, 50);
         sqlParams[2].Value = TxtAddEmail.Text.Trim();
     }
     DataConnections.RunSPReturnNone_PortalAdmin("spS_DeleteUser", sqlParams);
 }
Esempio n. 4
0
        bool IDataPersistence.Retrieve(IPersistence persistence)
        {
            InitializeMode = (eInitializeMode)Enum.Parse(
                typeof(eInitializeMode),
                persistence.GetFieldValue(Constants.IDataPesistence_InitializeMode,
                                          eInitializeMode.None.ToString()));

            PersistMode = (ePersistMode)Enum.Parse(
                typeof(ePersistMode),
                persistence.GetFieldValue(Constants.IDataPesistence_PersistMode,
                                          ePersistMode.Never.ToString()));

            string[] connections = persistence.GetFieldValues(Constants.IDataPesistence_DataConnections, "");
            DataConnections.Clear();
            DataConnections.AddRange(connections);

            return(true);
        }
        protected void BtnAdd_Click1(object sender, EventArgs e)
        {
            SqlParameter[] sqlParams;
            {
                sqlParams          = new SqlParameter[5];
                sqlParams[0]       = new SqlParameter("@FirstName", SqlDbType.VarChar, 40);
                sqlParams[0].Value = TxtAddFName.Text.Trim();
                sqlParams[1]       = new SqlParameter("@LastName", SqlDbType.VarChar, 40);
                sqlParams[1].Value = TxtAddLName.Text.Trim();
                sqlParams[2]       = new SqlParameter("@Email", SqlDbType.VarChar, 50);
                sqlParams[2].Value = TxtAddEmail.Text.Trim();
                sqlParams[3]       = new SqlParameter("@Password", SqlDbType.VarChar, 40);
                sqlParams[3].Value = TxtAddPassword.Text.Trim();
                sqlParams[4]       = new SqlParameter("@IsActive", SqlDbType.Bit, 1);
                sqlParams[4].Value = CheckBox1.Checked;
            }

            DataConnections.RunSPReturnNone_PortalAdmin("spS_InsertUser", sqlParams);
        }
Esempio n. 6
0
 public PSDForm(DataConnections dataConnections)
 {
     InitializeComponent();
     _connections = dataConnections;
 }
Esempio n. 7
0
 /// <summary>
 /// Get the Data connection based on the id given
 /// </summary>
 /// <param name="id">The id of the connection</param>
 /// <returns>The data connection</returns>
 public DataConnection DataConnection(Guid id)
 => DataConnections.Where(item => item.Id == id).FirstOrDefault();
Esempio n. 8
0
        /// <summary>
        /// Save a piece of information to the appropriate package element
        /// </summary>
        /// <typeparam name="T">The type of data to be saved</typeparam>
        /// <param name="dataToSave">The data to be saved</param>
        /// <returns>The saved data</returns>
        public T Save <T>(T dataToSave) where T : CommonObject
        {
            // Get the type of data to be saved
            String typeOfData = typeof(T).ToShortName();

            // Based on the type of data, save it to the correct repository element
            switch (typeOfData)
            {
            case "apidefinition":

                // Get the actual value from the object wrapper
                ApiDefinition apiDefinition = (ApiDefinition)Convert.ChangeType(dataToSave, typeof(ApiDefinition));

                // If the type is not null
                if (apiDefinition != null)
                {
                    // Does this api definition already exist?
                    ApiDefinition existingApiDefinition =
                        (apiDefinition.Id == Guid.Empty) ? null : this.Api(apiDefinition.Id);

                    // No API Definition found?
                    if (existingApiDefinition == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" api definition
                        existingApiDefinition    = apiDefinition;
                        existingApiDefinition.Id = Guid.NewGuid();

                        // Add this new api definition to the repository
                        ApiDefinitions.Add(existingApiDefinition);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingApiDefinition.Description = apiDefinition.Description;
                        existingApiDefinition.Name        = apiDefinition.Name;
                        existingApiDefinition.LastUpdated = DateTime.Now;

                        // Assign the foreign keys
                        existingApiDefinition.DataConnection   = apiDefinition.DataConnection;
                        existingApiDefinition.DataDefinition   = apiDefinition.DataDefinition;
                        existingApiDefinition.CredentialsLinks = apiDefinition.CredentialsLinks;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingApiDefinition, typeof(T));
                }

                break;

            case "dataitemdefinition":

                // Get the actual value from the object wrapper
                DataItemDefinition dataItemDefinition = (DataItemDefinition)Convert.ChangeType(dataToSave, typeof(DataItemDefinition));

                // If the type is not null
                if (dataItemDefinition != null)
                {
                    // Does this data definition already exist?
                    DataItemDefinition existingDataItemDefinition =
                        (dataItemDefinition.Id == Guid.Empty) ? null : this.DataDefinition(dataItemDefinition.Id);

                    // No data definition found?
                    if (existingDataItemDefinition == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" data definition
                        existingDataItemDefinition    = dataItemDefinition;
                        existingDataItemDefinition.Id = Guid.NewGuid();

                        // Add this new data definition to the repository
                        DataDefinitions.Add(existingDataItemDefinition);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingDataItemDefinition.Description    = dataItemDefinition.Description;
                        existingDataItemDefinition.Name           = dataItemDefinition.Name;
                        existingDataItemDefinition.Culture        = dataItemDefinition.Culture;
                        existingDataItemDefinition.EncodingFormat = dataItemDefinition.EncodingFormat;
                        existingDataItemDefinition.LastUpdated    = DateTime.Now;

                        // Assign the lists
                        existingDataItemDefinition.ItemProperties = dataItemDefinition.ItemProperties;
                        existingDataItemDefinition.PropertyBag    = dataItemDefinition.PropertyBag;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingDataItemDefinition, typeof(T));
                }

                break;

            case "dataconnection":

                // Get the actual value from the object wrapper
                DataConnection connection = (DataConnection)Convert.ChangeType(dataToSave, typeof(DataConnection));

                // If the type is not null
                if (connection != null)
                {
                    // Does this connection already exist?
                    DataConnection existingConnection =
                        (connection.Id == Guid.Empty) ? null : DataConnection(connection.Id);

                    // No connection found?
                    if (existingConnection == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" connection
                        existingConnection    = connection;
                        existingConnection.Id = Guid.NewGuid();

                        // Add this new connection to the repository
                        DataConnections.Add(existingConnection);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingConnection.ConnectionString = connection.ConnectionString;
                        existingConnection.Description      = connection.Description;
                        existingConnection.Name             = connection.Name;
                        existingConnection.ProviderType     = connection.ProviderType;
                        existingConnection.Credentials      = connection.Credentials;
                        existingConnection.LastUpdated      = DateTime.Now;
                        existingConnection.PropertyBag      = connection.PropertyBag;
                        existingConnection.ObjectName       = connection.ObjectName;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingConnection, typeof(T));
                }

                break;

            case "transformation":

                // Get the actual value from the object wrapper
                Transformation transformation = (Transformation)Convert.ChangeType(dataToSave, typeof(Transformation));

                // If the type is not null
                if (transformation != null)
                {
                    // Does this transformation already exist?
                    Transformation existingTransformation =
                        (transformation.Id == Guid.Empty) ? null : Transformation(transformation.Id);

                    // No transformation found?
                    if (existingTransformation == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" transformation
                        existingTransformation    = transformation;
                        existingTransformation.Id = Guid.NewGuid();

                        // Add this new transformation to the repository
                        Transformations.Add(existingTransformation);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingTransformation.Description = transformation.Description;
                        existingTransformation.Name        = transformation.Name;
                        existingTransformation.LastUpdated = DateTime.Now;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingTransformation, typeof(T));
                }

                break;

            case "credentials":

                // Get the actual value from the object wrapper
                Credentials credentials = (Credentials)Convert.ChangeType(dataToSave, typeof(Credentials));

                // If the type is not null
                if (credentials != null)
                {
                    // Does this set of credentials already exist?
                    Credentials existingCredentials =
                        (credentials.Id == Guid.Empty) ? null : this.Credentials(credentials.Id);

                    // Loop the properties and see if any have not been saved before. If not give them an Id
                    credentials.Properties.ForEach(credential =>
                    {
                        if (credential.Id == null)
                        {
                            credential.Id = Guid.NewGuid();
                        }
                    });

                    // No credentials found?
                    if (existingCredentials == null)
                    {
                        // Doesn't exist currently so create a new Id
                        // and assign the object as the "existing" credentials
                        existingCredentials    = credentials;
                        existingCredentials.Id = Guid.NewGuid();

                        // Add this new credentials to the repository
                        CredentialsStore.Add(existingCredentials);
                    }
                    else
                    {
                        // Assign the values from the item to save
                        existingCredentials.Description = credentials.Description;
                        existingCredentials.Name        = credentials.Name;
                        existingCredentials.LastUpdated = DateTime.Now;

                        // Assign the lists
                        existingCredentials.Properties = credentials.Properties;
                    }

                    // Convert the data back to the return data type (which is actually the same)
                    dataToSave = (T)Convert.ChangeType(existingCredentials, typeof(T));
                }

                break;
            }

            // Make sure as the item is saved to this package that the
            // reference to it is inside the object
            dataToSave.ParentPackage = this;

            // Return the data that was saved
            return(dataToSave);
        }