Esempio n. 1
0
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(PurposeTypes purposetypes, System.Data.DataSet data)
        {
            // Do nothing if we have nothing
            if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
            {
                return;
            }


            // Create a local variable for the new instance.
            PurposeType newobj = null;

            // Create a local variable for the data row instance.
            System.Data.DataRow dr = null;


            // Iterate through the table rows
            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                // Get a reference to the data row
                dr = data.Tables[0].Rows[i];
                // Create a new object instance
                newobj = System.Activator.CreateInstance(purposetypes.ContainsType[0]) as PurposeType;
                // Let the instance set its own members
                newobj.SetMembers(ref dr);
                // Add the new object to the collection instance
                purposetypes.Add(newobj);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Fill method for populating an entire collection of PurposeTypes
        /// </summary>
        public virtual void Fill(PurposeTypes purposeTypes)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(PurposeType.GetConnectionString());


            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectPurposeTypes");


                    // Send the collection and data to the object factory
                    CreateObjectsFromData(purposeTypes, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
Esempio n. 3
0
 public PurposeInsertModel(string name, string description, PurposeType type, Scope purposeScope)
 {
     this.Name         = name;
     this.Description  = description;
     this.Type         = type;
     this.PurposeScope = purposeScope;
 }
Esempio n. 4
0
        public PurposeWindow(string sender, int EpicOrCardId, int ProjectId, int ExecutorId)
        {
            InitializeComponent();

            if (sender == "Epic")
            {
                purposeType = PurposeType.Epic;
            }

            else if (sender == "Project")
            {
                purposeType = PurposeType.Project;
            }

            else if (sender == "Card")
            {
                purposeType   = PurposeType.Card;
                cardExecutors = context.Executors.Where(ce => ce.CardId == EpicOrCardId).ToList();

                if (ExecutorId == 0)
                {
                    DeleteButton.Visibility = Visibility.Hidden;
                    DeleteButton.IsEnabled  = false;
                }
            }

            this.EpicOrCardId = EpicOrCardId;
            this.ProjectId    = ProjectId;
            this.ExecutorId   = ExecutorId;

            FillDataGrid();
        }
Esempio n. 5
0
 protected void CheckAccessibility(PurposeType purposeType, object ownerId, string tableId, object rowId, string columnId)
 {
     CheckAccessibility
     (
         purposeType: purposeType,
         ownerId: ownerId,
         tableIds: new string[] { tableId },
         rowIds: new (string tableId, object rowId)[] { (tableId, rowId) },
 public PurposeUpdateModel(object purposeId, string name, string description, PurposeType type, Scope purposeScope)
 {
     this.ID           = purposeId;
     this.Name         = name;
     this.Description  = description;
     this.Type         = type;
     this.PurposeScope = purposeScope;
 }
Esempio n. 7
0
 protected void CheckAccessibility(PurposeType purposeType, object ownerId, string tableId, IEnumerable <object> rowIds, IEnumerable <string> columnIds)
 {
     CheckAccessibility
     (
         purposeType: purposeType,
         ownerId: ownerId,
         tableIds: new string[] { tableId },
         rowIds: rowIds.Select(r => (tableId, r)),
         columnIds: columnIds.Select(c => (tableId, c))
     );
 }
Esempio n. 8
0
        /// <summary>
        /// Deletes the object.
        /// </summary>
        public virtual void Delete(PurposeType deleteObject)
        {
            // create a new instance of the connection
            SqlConnection cnn = new SqlConnection(PurposeType.GetConnectionString());
            // create local variable array for the sql parameters
            SqlParameterHash sqlparams = null;


            try
            {
                // discover the parameters
                sqlparams = SqlHelperParameterCache.GetSpParameterSet(PurposeType.GetConnectionString(), "gsp_DeletePurposeType");


                // Store the parameter for the Id attribute.
                sqlparams["@id"].Value = deleteObject.Id;


                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // Execute the stored proc to perform the delete on the instance.
                    SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_DeletePurposeType", sqlparams);


                    // close the connection after usage
                    cnn.Close();
                }


                // nullify the connection var
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }


            // nullify the reference
            deleteObject = null;
        }
Esempio n. 9
0
        /// <summary>
        /// Fills a single instance with data based on its primary key values.
        /// </summary>
        public virtual void Fill(PurposeType pt, System.Int16 id)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(PurposeType.GetConnectionString());

            try
            {
                // discover the sql parameters
                SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(PurposeType.GetConnectionString(), "gsp_SelectPurposeType");


                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // set the parameters
                    sqlparams["@id"].Value = id;


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectPurposeType", sqlparams);


                    if (datareader.Read())
                    {
                        pt.SetMembers(ref datareader);
                    }


                    cnn.Close();                     // close the connection
                }


                // nullify the connection var
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
Esempio n. 10
0
        public async Task <AjaxResponse> SendPhoneCode(string phoneNumber, PurposeType type)
        {
            SmsManager smsManager = new SmsManager(phoneNumber, type, _userVerifyAppService);
            await smsManager.SendAuthCode();

            var sendResult = smsManager.Result;

            switch (sendResult.Code)
            {
            case 403:
            case 406:
            case 4080:
            case 4082:
                sendResult.Msg = L("Code" + sendResult.Code);
                break;

            default:
                sendResult.Msg = "未知错误:" + sendResult.Code;
                break;
            }
            return(new AjaxResponse(sendResult));
        }
Esempio n. 11
0
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(PurposeTypes purposetypes, System.Data.SqlClient.SqlDataReader data)
        {
            // Do nothing if we have nothing
            if (data == null)
            {
                return;
            }


            // Create a local variable for the new instance.
            PurposeType newobj = null;

            // Iterate through the data reader
            while (data.Read())
            {
                // Create a new object instance
                newobj = System.Activator.CreateInstance(purposetypes.ContainsType[0]) as PurposeType;
                // Let the instance set its own members
                newobj.SetMembers(ref data);
                // Add the new object to the collection instance
                purposetypes.Add(newobj);
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Persists the object.
 /// </summary>
 public virtual void Persist(PurposeType persistObject)
 {
     // Make a call to the overloaded method with a null transaction
     Persist(persistObject, null);
 }
Esempio n. 13
0
 public SmsManager(string phoneNumber, PurposeType type, IUserVerifyAppService userVerifyAppService) : this(phoneNumber, userVerifyAppService)
 {
     CodePurposeType = type;
 }
Esempio n. 14
0
        public void Insert(int PurposeTypesKey,string PurposeDescription)
        {
            PurposeType item = new PurposeType();

            item.PurposeTypesKey = PurposeTypesKey;

            item.PurposeDescription = PurposeDescription;

            item.Save(UserName);
        }
Esempio n. 15
0
        public void Update(int PurposeTypesKey,string PurposeDescription)
        {
            PurposeType item = new PurposeType();
            item.MarkOld();
            item.IsLoaded = true;

            item.PurposeTypesKey = PurposeTypesKey;

            item.PurposeDescription = PurposeDescription;

            item.Save(UserName);
        }
Esempio n. 16
0
        public void CreateMyListView(Object obj, PurposeType purposeItem)
        {
            //a basic initialization for the table (which based on listview)
            listView.View      = View.Details;
            listView.GridLines = true;
            listView.Sorting   = SortOrder.Ascending;
            listView.Columns.Add("שם", 250, HorizontalAlignment.Center);
            listView.Columns.Add("הרשאה", 250, HorizontalAlignment.Center);

            //Display a CList
            if (purposeItem == PurposeType.CList)
            {
                this.label2.Text = ((Models.User)obj).userName + " הרשאות עבור המשתמש ";//header for the form
                bool empty = true;
                //scan every access right of the user stored in userRole.filesDict and exctarct them
                foreach (var dictItem in ((Models.User)obj).userRole.filesDict)
                {
                    //dictItem is a dictionary item, its key is the file name and its value is the user access for the file
                    empty = false;
                    //create a new entry in the CList that contains the file name and the acces type
                    listView.Items.Add(new ListViewItem(dictItem.Key.fileName)).SubItems.Add((dictItem.Value.ToString()));
                }
                if (empty)
                {
                    listView.Items.Add(new ListViewItem("ריק")).SubItems.Add(("ריק"));//for empty clist
                }
            }

            //Display ACL
            else if (purposeItem == PurposeType.ACL)
            {
                this.label2.Text = ((Models.File)obj).fileName + " הרשאות עבור הקובץ";//header for the form
                bool empty = true;
                //scan every user
                foreach (Models.User user in Models.Environment.usersList)
                {
                    empty = false;
                    //scan and extract only the users access rights for this file alone
                    foreach (var dictItem in user.userRole.filesDict.Where(item => (item.Key.fileName == ((Models.File)obj).fileName)))
                    {
                        //create a new entry in the ACL that contains the user name and the access type
                        listView.Items.Add(new ListViewItem(user.userName)).SubItems.Add((dictItem.Value.ToString()));
                    }
                }
                if (empty)
                {
                    listView.Items.Add(new ListViewItem("ריק")).SubItems.Add(("ריק"));//for empty ACL
                }
            }

            //display Access Matrix
            else if (purposeItem == PurposeType.AccessMatrix)
            {
                this.label2.Text = "מטריצת גישה מלאה";//header for the form
                listView.Columns.Clear();
                listView.Items.Clear();
                //add to the table a column for every user
                listView.Columns.Add("משתמשים / קבצים", 250);
                foreach (var user in Models.Environment.usersList)
                {
                    listView.Columns.Add(user.userName, 100);
                }

                bool empty = true;
                //scan every file in the system
                foreach (var file in Models.Environment.filesList)
                {
                    empty = false;
                    //create a new line in the table, the first cell is the file name
                    ListViewItem lwi = new ListViewItem(file.fileName);
                    foreach (var user in Models.Environment.usersList)
                    {
                        //for every user in the system add its access type (if exists) for this file to the right cell
                        if (user.userRole.filesDict.ContainsKey(file))
                        {
                            lwi.SubItems.Add(user.userRole.filesDict[file].ToString());
                        }
                        else
                        {
                            lwi.SubItems.Add("ריק"); //if there is no access right
                        }
                    }

                    listView.Items.Add(lwi);
                }
            }
            this.Controls.Add(listView);
        }
Esempio n. 17
0
 public AccessDetailsForm(Object obj, PurposeType purposeItem)
 {
     InitializeComponent();
     CreateMyListView(obj, purposeItem); //this func do all the work, now just pass the wanted object (file or user) and access model
 }
Esempio n. 18
0
        /// <summary>
        /// Persists the object.
        /// </summary>
        public virtual void Persist(PurposeType persistObject, SqlTransaction sqlTrans)
        {
            // create local variable array for the sql parameters
            SqlParameterHash sqlparams = null;
            // Create a local variable for the connection
            SqlConnection cnn = null;


            // Use the parameter overload or create a new instance
            if (sqlTrans == null)
            {
                cnn = new SqlConnection(PurposeType.GetConnectionString());
            }


            try
            {
                // discover the parameters
                if (persistObject.Persisted)
                {
                    sqlparams = SqlHelperParameterCache.GetSpParameterSet(PurposeType.GetConnectionString(), "gsp_UpdatePurposeType");
                }
                else
                {
                    sqlparams = SqlHelperParameterCache.GetSpParameterSet(PurposeType.GetConnectionString(), "gsp_CreatePurposeType");
                }


                // Store the parameter for the Name attribute.
                sqlparams["@name"].Value = persistObject.Name;
                // Store the parameter for the EnumeratedName attribute.
                sqlparams["@enumeratedName"].Value = persistObject.EnumeratedName;
                // Store the parameter for the Description attribute.
                if (!persistObject.DescriptionIsNull)
                {
                    sqlparams["@description"].Value = persistObject.Description;
                }
                // Store the parameter for the Id attribute.
                sqlparams["@id"].Value = persistObject.Id;
                if (!persistObject.Persisted)
                {
                    // store the create only (historical fixed) values
                }
                else
                {
                    // store the update only (historical changeable) values
                }


                if (sqlTrans == null)
                {
                    // Process using the isolated connection
                    using (cnn)
                    {
                        // open the connection
                        cnn.Open();


                        if (!persistObject.Persisted)
                        {
                            SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_CreatePurposeType", sqlparams);
                        }
                        else
                        {
                            SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdatePurposeType", sqlparams);
                        }


                        // close the connection after usage
                        cnn.Close();
                    }


                    // nullify the connection var
                    cnn = null;
                }
                else
                {
                    // Process using the shared transaction
                    if (!persistObject.Persisted)
                    {
                        SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_CreatePurposeType", sqlparams);
                    }
                    else
                    {
                        SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdatePurposeType", sqlparams);
                    }
                }
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
Esempio n. 19
0
 public MechanicVehicle()
 {
     weight      = 0;
     length      = 0;
     Purposetype = PurposeType.None;
 }