Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            uniSelector.StopProcessing = true;
        }
        else
        {
            if (!RequestHelper.IsPostBack())
            {
                drpClassType.Items.Clear();
                drpClassType.Items.Add(new ListItem(ResHelper.GetString("general.documenttype"), "doctype"));

                if (ShowCustomTableClasses && CustomTableHelper.GetCustomTableClasses(SiteContext.CurrentSiteID).HasResults())
                {
                    drpClassType.Items.Add(new ListItem(ResHelper.GetString("queryselection.classtype.customtables"), "customtables"));
                }

                lblDocType.ResourceString = "queryselection.lbldoctypes";

                Initialize();
            }

            ReloadData();

            WhereCondition = GenerateWhereCondition();
        }
    }
Esempio n. 2
0
    private string GetAllTasksWhere(out bool classesFound)
    {
        string where = BASE_TASK_WHERE;
        string classWhere = string.Empty;

        classesFound = false;

        // Ensure only data task selection
        if (string.IsNullOrEmpty(objectType))
        {
            DataSet dsTables = CustomTableHelper.GetCustomTableClasses(CurrentSiteID).Column("ClassName");
            if (!DataHelper.DataSourceIsEmpty(dsTables))
            {
                foreach (DataRow dr in dsTables.Tables[0].Rows)
                {
                    classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',";
                }

                classWhere   = classWhere.TrimEnd(',');
                classesFound = true;
            }

            where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")");
        }

        return(where);
    }
Esempio n. 3
0
    /// <summary>
    /// Resolves backward compatibility issue.
    /// </summary>
    private void GetOlderValues()
    {
        DataSet data;

        switch (ClassType)
        {
        // Custom tables
        case 0:
        {
            data = CustomTableHelper.GetCustomTableClasses(SiteContext.CurrentSiteID)
                   .Column("ClassName");
        }
        break;

        // System tables
        case 2:
        {
            data = DataClassInfoProvider.GetClasses()
                   .WhereTrue("ClassShowAsSystemTable")
                   .Column("ClassName");
            break;
        }

        // Document types
        default:
        {
            data = DataClassInfoProvider.GetClasses()
                   .OnSite(SiteContext.CurrentSiteID)
                   .WhereTrue("ClassIsDocumentType")
                   .WhereTrue("ClassIsCoupledClass")
                   .Column("ClassName");
            break;
        }
        }

        // Get GUID
        string[] values = mValue.Split('|');
        Guid     guid   = new Guid(values[0]);

        // Go thru selected classes and try find right field
        foreach (DataRow row in data.Tables[0].Rows)
        {
            string className = row["ClassName"].ToString();
            var    fi        = FormHelper.GetFormInfo(className, false);

            if (fi != null)
            {
                // Find field with given GUID
                var ffi = fi.GetFields(true, true).FirstOrDefault(f => f.Guid == guid);
                if (ffi != null)
                {
                    // Column found, preselect class name and column in drop down lists
                    selectionElem.DropDownSingleSelect.SelectedValue = className;
                    LoadFields(false);
                    drpFields.SelectedValue = guid.ToString();
                    return;
                }
            }
        }
    }
Esempio n. 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var selectedRow = dgCustomTable.SelectedRows[0];
            int id          = -1;

            if (selectedRow == null)
            {
                MessageBox.Show("Nalezy wybrac wiersz przeznaczony do usunięcia", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            foreach (DataGridViewCell cell in selectedRow.Cells)
            {
                if (cell.ColumnIndex == selectedRow.Cells.Count - 1)
                {
                    id = (int)cell.Value;
                }
            }

            var DialogResult = MessageBox.Show("Czy na pewno chcesz BEZPOWROTNIE usunąć wiersz z bazy danych ? " + Environment.NewLine
                                               + "Tej operacji nie mozna cofnąć", "Ostrzeżenie", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (DialogResult == DialogResult.OK)
            {
                CustomTableHelper.DeleteRow(id, userDefinedTable.TableName);
            }
            Refresh();
            InitDataGrid();
        }
Esempio n. 5
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (StopProcessing)
        {
            uniSelector.StopProcessing = true;
        }
        else
        {
            if (!RequestHelper.IsPostBack())
            {
                drpClassType.Items.Clear();
                drpClassType.Items.Add(new ListItem(ResHelper.GetString("general.documenttype"), DOCUMENT_TYPE));

                if (ShowCustomTableClasses && CustomTableHelper.GetCustomTableClasses(SiteContext.CurrentSiteID).HasResults())
                {
                    drpClassType.Items.Add(new ListItem(ResHelper.GetString("queryselection.classtype.customtables"), CUSTOM_TABLE));
                }

                Initialize();
            }

            SetupSelector();

            WhereCondition = GenerateWhereCondition();
        }
    }
    /// <summary>
    /// Creates tree view.
    /// </summary>
    private void CreateTreeView()
    {
        objectTree.Nodes.Clear();

        // Fill in the custom tables
        TreeNode rootNode = new TreeNode();

        rootNode.Text        = "<span class=\"ContentTreeSelectedItem\" id=\"treeSelectedNode\" onclick=\"SelectNode('##ALL##', this); \"><span class=\"Name\">" + GetString("DataStaging.RootNodeText") + "</span></span>";
        rootNode.Expanded    = true;
        rootNode.NavigateUrl = "#";
        objectTree.Nodes.Add(rootNode);

        string objectType = null;

        if (Request.Params["objectType"] != null)
        {
            objectType = ValidationHelper.GetString(Request.Params["objectType"], null);
        }
        // Initialize tree view with custom tables
        bool tableSelected = false;

        DataSet dsTables = CustomTableHelper.GetCustomTableClasses(SiteContext.CurrentSiteID).Columns("ClassID", "ClassDisplayName", "ClassName");

        if (!DataHelper.DataSourceIsEmpty(dsTables))
        {
            DataTable table = dsTables.Tables[0];

            foreach (DataRow dr in table.Rows)
            {
                string tableDisplayName = ResHelper.LocalizeString(dr["ClassDisplayName"].ToString());

                TreeNode tableNode = new TreeNode();

                string currentObjectType = CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString());
                if (currentObjectType == objectType)
                {
                    tableNode.Text = "<span class=\"ContentTreeSelectedItem\" id=\"treeSelectedNode\" onclick=\"SelectNode('" + currentObjectType + "', this); \"><span class=\"Name\">" + HTMLHelper.HTMLEncode(tableDisplayName) + "</span></span>";
                    tableSelected  = true;
                }
                else
                {
                    tableNode.Text = "<span class=\"ContentTreeItem\" onclick=\"SelectNode('" + currentObjectType + "', this); \"><span class=\"Name\">" + HTMLHelper.HTMLEncode(tableDisplayName) + "</span></span>";
                }
                tableNode.Value       = currentObjectType;
                tableNode.NavigateUrl = "#";

                objectTree.Nodes[0].ChildNodes.Add(tableNode);
            }
        }

        string script = "var currentNode = document.getElementById('treeSelectedNode');\n";

        if ((objectType != null) && tableSelected)
        {
            script += " \t SelectNode('" + objectType + "');\n";
        }

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "RefreshScript", ScriptHelper.GetScript(script));
    }
Esempio n. 7
0
 public CustomTableFrame()
 {
     InitializeComponent();
     // TOD O: CHECK FOR UDT  CHECK DATETIME OBJECT PUSHING TO DB
     userDefinedTable          = CustomTableHelper.GetTableInfoAboutTables_OneRowVersion();
     dgCustomTable.MultiSelect = false;
     InitDataGrid();
 }
Esempio n. 8
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            chosenTable = CustomTableHelper.GetTableInfoAboutTable(listBoxCustomTable.SelectedItem.ToString());

            if (chosenTable != null)
            {
                isTableChosen = true;
                this.Hide();
            }
        }
Esempio n. 9
0
    /// <summary>
    /// Resolves backward compatibility issue.
    /// </summary>
    private string GetObsoleteSelectedClassName(Guid guid)
    {
        DataSet data;

        switch (ClassType)
        {
        // Custom tables
        case 0:
        {
            data = CustomTableHelper.GetCustomTableClasses(SiteContext.CurrentSiteID)
                   .Column("ClassName");
        }
        break;

        // System tables
        case 2:
        {
            data = DataClassInfoProvider.GetClasses()
                   .WhereTrue("ClassShowAsSystemTable")
                   .Column("ClassName");
            break;
        }

        // Document types
        default:
        {
            data = DataClassInfoProvider.GetClasses()
                   .OnSite(SiteContext.CurrentSiteID)
                   .WhereTrue("ClassIsDocumentType")
                   .WhereTrue("ClassIsCoupledClass")
                   .Column("ClassName");
            break;
        }
        }

        // Go through selected classes and try find right field
        foreach (DataRow row in data.Tables[0].Rows)
        {
            string className = row["ClassName"].ToString();
            var    fi        = FormHelper.GetFormInfo(className, false);

            if (fi != null)
            {
                // Find field with given GUID
                var ffi = fi.GetFields(true, true).FirstOrDefault(f => f.Guid == guid);
                if (ffi != null)
                {
                    return(className);
                }
            }
        }

        return(null);
    }
Esempio n. 10
0
        public ChooseUDTDialog()
        {
            InitializeComponent();
            isTableChosen      = false;
            this.StartPosition = FormStartPosition.CenterScreen;
            listOfTableInfos   = CustomTableHelper.GetTableInfosAboutCustomTables();

            foreach (TableInfo tableInfo in listOfTableInfos)
            {
                listBoxCustomTable.Items.Add(tableInfo.TableName);
            }
        }
Esempio n. 11
0
        private void AddRowOkClick()
        {
            List <object> vals = new List <object>();

            foreach (CustomTableDialogControls dialogControls in listOfControls)
            {
                // WSZYSTKO musi byc string
                // kolejnosc parametrów taka jak kolejnosc kolumn w tabeli

                vals.Add(dialogControls.ValueString);
            }
            CustomTableHelper.AddRowToCustomTable(tableInfo, vals.ToArray());
        }
    /// <summary>
    /// Data reloading event handler.
    /// </summary>
    /// <param name="completeWhere">Complete where condition</param>
    /// <param name="currentOrder">Current order by clause</param>
    /// <param name="currentTopN">Current top N value</param>
    /// <param name="columns">Currently selected columns</param>
    /// <param name="currentOffset">Current page offset</param>
    /// <param name="currentPageSize">Current size of page</param>
    /// <param name="totalRecords">Returns number of returned records</param>
    protected DataSet uniGrid_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        var data = CustomTableHelper.GetFilteredTablesByPermission(completeWhere, currentOrder, currentTopN, columns);

        totalRecords = data.Tables[0].Rows.Count;

        // Redirect to access denied page if user doesn't have permission to any custom table only if filter is not set
        if ((totalRecords == 0) && !uniGrid.FilterIsSet)
        {
            MissingPermissionsRedirect();
        }

        return(data);
    }
Esempio n. 13
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var DialogResult = MessageBox.Show("Czy na pewno chcesz BEZPOWROTNIE usunąć zbiór danych ? " + Environment.NewLine
                                               + "Tej operacji nie mozna cofnąć", "Ostrzeżenie", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (DialogResult == DialogResult.OK)
            {
                chosenTable = CustomTableHelper.GetTableInfoAboutTable(listBoxCustomTable.SelectedItem.ToString());
                CustomTableHelper.DeleteTable(chosenTable.TableName);

                this.Refresh();
                return;
            }
        }
Esempio n. 14
0
        private void EditRowOkClick()
        {
            int ID = (int)selectedRow.Cells[selectedRow.Cells.Count - 1].Value;

            List <object> vals = new List <object>();

            foreach (CustomTableDialogControls dialogControls in listOfControls)
            {
                // WSZYSTKO musi byc string
                // kolejnosc parametrów taka jak kolejnosc kolumn w tabeli

                vals.Add(dialogControls.ValueString);
            }
            CustomTableHelper.EditCustomTableCells(ID, tableInfo, tableInfo.ColumnsNames_String().ToArray(), vals.ToArray());
        }
Esempio n. 15
0
    /// <summary>
    /// Initialize permission type drop down list.
    /// </summary>
    private void InitializeDropDownListPermissionType()
    {
        // Initialize drop down list with types
        drpPermissionType.Items.Clear();
        drpPermissionType.Items.Add(new ListItem(GetString("objecttype.cms_resource"), PermissionTypes.Module.ToString()));
        drpPermissionType.Items.Add(new ListItem(GetString("general.documenttype"), PermissionTypes.DocumentType.ToString()));

        // Check if any custom table available under site
        if (CustomTableHelper.GetCustomTableClasses(SiteID).HasResults() ||
            (ValidationHelper.GetString(siteSelector.Value, String.Empty) == siteSelector.GlobalRecordValue) ||
            (globalRecord && MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)))
        {
            drpPermissionType.Items.Add(new ListItem(GetString("general.customtable"), PermissionTypes.CustomTable.ToString()));
        }
    }
Esempio n. 16
0
    private List <string> GetObjectTypes()
    {
        // Get custom tables object types
        var objectTypes = new List <string>();

        DataSet dsTables = CustomTableHelper.GetCustomTableClasses(CurrentSiteID).Column("ClassName");

        if (!DataHelper.DataSourceIsEmpty(dsTables))
        {
            DataTable table = dsTables.Tables[0];
            foreach (DataRow dr in table.Rows)
            {
                objectTypes.Add(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString()));
            }
        }

        return(objectTypes);
    }
Esempio n. 17
0
        private void btnAcceptAllRows_Click(object sender, EventArgs e)
        {
            // txtTableName.BackColor =
            lblInfo.Visible = false;
            SetCustomRowsBackgroundTransparent();
            if (AreRowsContainsSpecialChars())
            {
                lblInfo.Text    = "Zawartosc pola nazwy nie może być pusta ani zawierać znaków specjalnych";
                lblInfo.Visible = true;
                return;
            }
            if (CustomTableHelper.IsTableNameInUse(txtTableName.Text))
            {
                lblInfo.Text    = "Nazwa zbioru danych jest już zajęta";
                lblInfo.Visible = true;
                return;
            }
            if (listOfColumnTemplates.Count == 0)
            {
                lblInfo.Text    = "Zbiór danych musi posiadac co najmniej jedno pole";
                lblInfo.Visible = true;
                return;
            }

            var tableInfo = new TableInfo(txtTableName.Text);

            foreach (TableTemplate dbColumn in listOfColumnTemplates)
            {
                tableInfo.Add(dbColumn.GetColumnInfo());
            }

            tableInfo.ColumnInfos_Row.Reverse();

            dbHelpers.TableEditors.CustomTableHelper.AddCustomTable(tableInfo);

            MessageBox.Show("Stworzenie nowego zbioru danych powidło się");

            this.Hide();
            //  Owner.Show();
            this.Dispose();
        }
Esempio n. 18
0
    protected DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        // Get the tasks
        string where = "TaskSiteID IS NULL";
        string classWhere = string.Empty;

        // Ensure only data task selection
        if (string.IsNullOrEmpty(objectType))
        {
            DataSet dsTables = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName");
            if (!DataHelper.DataSourceIsEmpty(dsTables))
            {
                foreach (DataRow dr in dsTables.Tables[0].Rows)
                {
                    classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',";
                }
                classWhere = classWhere.TrimEnd(new [] { ',' });
            }
            where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")");
        }

        DataSet ds = null;

        // There are some custom tables assigned to the site, get the data
        if (!string.IsNullOrEmpty(classWhere) || !string.IsNullOrEmpty(objectType))
        {
            ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, currentOrder, 0, columns, currentOffset, currentPageSize, ref totalRecords);
        }
        else
        {
            totalRecords = -1;
        }

        pnlFooter.Visible = (totalRecords > 0);
        return(ds);
    }
Esempio n. 19
0
    /// <summary>
    /// All items synchronization.
    /// </summary>
    protected void SynchronizeAll(object parameter)
    {
        string result = string.Empty;

        eventCode      = "SYNCALLDATA";
        CanceledString = GetString("Tasks.SynchronizationCanceled");
        try
        {
            string where = "TaskSiteID IS NULL";
            string classWhere = string.Empty;

            AddLog(GetString("Synchronization.RunningTasks"));

            // Ensure only data task selection
            if (string.IsNullOrEmpty(objectType))
            {
                DataSet dsTables = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName");
                if (!DataHelper.DataSourceIsEmpty(dsTables))
                {
                    foreach (DataRow dr in dsTables.Tables[0].Rows)
                    {
                        classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',";
                    }
                    classWhere = classWhere.TrimEnd(new [] { ',' });
                }
                where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")");
            }

            // Get the tasks
            DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", -1, "TaskID,TaskTitle");

            // Run the synchronization
            result = StagingHelper.RunSynchronization(ds, serverId, true, currentSiteId, AddLog);

            // Log possible error
            if (result != string.Empty)
            {
                CurrentError = GetString("Tasks.SynchronizationFailed");
                AddErrorLog(CurrentError, null);
            }
            else
            {
                CurrentInfo = GetString("Tasks.SynchronizationOK");
                AddLog(CurrentInfo);
            }
        }
        catch (ThreadAbortException ex)
        {
            string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
            if (state == CMSThread.ABORT_REASON_STOP)
            {
                // Canceled by user
                CurrentInfo = CanceledString;
                AddLog(CurrentInfo);
            }
            else
            {
                CurrentError = GetString("Tasks.SynchronizationFailed");
                AddErrorLog(CurrentError, result);
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message;
            AddErrorLog(CurrentError);
        }
        finally
        {
            // Finalize log context
            FinalizeContext();
        }
    }
Esempio n. 20
0
    /// <summary>
    /// Deletes all tasks.
    /// </summary>
    protected void DeleteAll(object parameter)
    {
        eventCode      = "DELETEALLDATA";
        CanceledString = GetString("Tasks.DeletionCanceled");
        try
        {
            AddLog(GetString("Synchronization.DeletingTasks"));

            string where = "TaskSiteID IS NULL";
            string classWhere = string.Empty;

            // Ensure only data task selection
            if (string.IsNullOrEmpty(objectType))
            {
                DataSet dsTables = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName");
                if (!DataHelper.DataSourceIsEmpty(dsTables))
                {
                    foreach (DataRow dr in dsTables.Tables[0].Rows)
                    {
                        classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',";
                    }
                    classWhere = classWhere.TrimEnd(new char[] { ',' });
                }
                where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")");
            }

            // Get the tasks
            DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", 0, "TaskID, TaskTitle");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    int taskId = ValidationHelper.GetInteger(row["TaskID"], 0);
                    if (taskId > 0)
                    {
                        string taskTitle = ValidationHelper.GetString(row["TaskTitle"], null);
                        AddLog(string.Format(ResHelper.GetAPIString("deletion.running", "Deleting '{0}' task"), HTMLHelper.HTMLEncode(taskTitle)));
                        // Delete synchronization
                        SynchronizationInfoProvider.DeleteSynchronizationInfo(taskId, serverId, currentSiteId);
                    }
                }
            }

            CurrentInfo = GetString("Tasks.DeleteOK");
            AddLog(CurrentInfo);
        }
        catch (ThreadAbortException ex)
        {
            string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
            if (state == CMSThread.ABORT_REASON_STOP)
            {
                // Canceled by user
                CurrentInfo = CanceledString;
                AddLog(CurrentInfo);
            }
            else
            {
                CurrentError = GetString("Tasks.DeletionFailed");
                AddErrorLog(CurrentError);
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message;
            AddErrorLog(CurrentError);
        }
        finally
        {
            // Finalize log context
            FinalizeContext();
        }
    }
Esempio n. 21
0
        private void InitDataGrid()
        {
            if (userDefinedTable == null)
            {
                MessageBox.Show("Obecnie nie ma żadnych " + dbHelpers.NamesTypes.CommonCustomTableName_POLISH_ADJECTIVE, "Uwaga", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Dispose();
                return;
            }
            //DODAWANIA CUSTOM TABLE   dgCustomTable.
            dgCustomTable.Rows.Clear();
            dgCustomTable.Columns.Clear();

            dgCustomTable.Columns.Add("OrdinalNumber", "L.P.");
            foreach (ColumnInfo columnInfo in userDefinedTable.ColumnInfos_Row)
            {
                dgCustomTable.Columns.Add(columnInfo.Name, columnInfo.Name);

                if (columnInfo.ColumnType == ColumnType.DataType)
                {
                    dgCustomTable.Columns[columnInfo.Name].ValueType = typeof(DateTime);
                }
            }
            ////////////
            dgCustomTable.Columns.Add("TableID", "TableID");
            dgCustomTable.Columns["TableID"].Visible = false;
            dgCustomTable.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            ///////////
            int customRowCount = CustomTableHelper.GetRowCount(userDefinedTable.TableName);

            tableRows = CustomTableHelper.GetAllRowsFromCustomTable(userDefinedTable);

            for (int i = 0; i < customRowCount; i++)
            {
                // Columns
                var currentRow = tableRows.Row[i];
                dgCustomTable.Rows.Add(1);
                dgCustomTable.Rows[i].Cells[0].Value = (int)i + 1;

                // Columns of row
                for (int j = 0; j < currentRow.Count; j++)
                {
                    switch (currentRow[j].GetType())
                    {
                    case TypeCode.DateTime:
                        //  buf_DataTime = (DateTime) currentRow[i].Value;
                        dgCustomTable.Rows[i].Cells[j + 1].ValueType = typeof(DateTime);
                        dgCustomTable.Rows[i].Cells[j + 1].Value     = (DateTime)currentRow[j].Value;
                        break;

                    case TypeCode.String:
                        //   buf_descr = (string) currentRow[i].Value;
                        dgCustomTable.Rows[i].Cells[j + 1].Value = (string)currentRow[j].Value;
                        break;

                    case TypeCode.Char:
                        //    buf_shortText = (string) currentRow[i].Value;
                        dgCustomTable.Rows[i].Cells[j + 1].Value = (string)currentRow[j].Value;
                        break;

                    case TypeCode.Int32:
                        //   buf_Numeric = (int) currentRow[i].Value;
                        dgCustomTable.Rows[i].Cells[j + 1].ValueType = typeof(int);
                        dgCustomTable.Rows[i].Cells[j + 1].Value     = (int)currentRow[j].Value;
                        break;

                    default: throw new Exception("CustomTableFrame Type Code Error");
                    }
                }
                ////////
                dgCustomTable.Rows[i].Cells[dgCustomTable.Rows[i].Cells.Count - 1].Value = currentRow[currentRow.Count - 1].ID;
                ////////
            }
        }
Esempio n. 22
0
    /// <summary>
    /// Complete synchronization.
    /// </summary>
    public void SynchronizeComplete(object parameter)
    {
        string result = null;

        eventCode      = "SYNCCOMPLETEDATA";
        CanceledString = GetString("Tasks.SynchronizationCanceled");
        try
        {
            int sid = serverId;
            if (sid <= 0)
            {
                sid = SynchronizationInfoProvider.ENABLED_SERVERS;
            }

            AddLog(GetString("Synchronization.LoggingTasks"));

            // Get custom tables object types
            string  objectTypes = string.Empty;
            DataSet dsTables    = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName");
            if (!DataHelper.DataSourceIsEmpty(dsTables))
            {
                DataTable table = dsTables.Tables[0];
                foreach (DataRow dr in table.Rows)
                {
                    objectTypes += CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString()) + ";";
                }
            }

            // Get the tasks
            List <ISynchronizationTask> tasks = SynchronizationHelper.LogObjectChange(objectTypes.Trim(';'), 0, DateTimeHelper.ZERO_TIME, TaskTypeEnum.UpdateObject, true, false, false, false, false, currentSiteId, sid);

            AddLog(GetString("Synchronization.RunningTasks"));

            // Run the synchronization
            result = StagingHelper.RunSynchronization(tasks, serverId, true, currentSiteId, AddLog);

            // Log possible errors
            if (!string.IsNullOrEmpty(result))
            {
                CurrentError = GetString("Tasks.SynchronizationFailed");
                AddErrorLog(CurrentError, null);
            }
            else
            {
                CurrentInfo = GetString("Tasks.SynchronizationOK");
                AddLog(CurrentInfo);
            }
        }
        catch (ThreadAbortException ex)
        {
            string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
            if (state == CMSThread.ABORT_REASON_STOP)
            {
                // Canceled by user
                CurrentInfo = CanceledString;
                AddLog(CurrentInfo);
            }
            else
            {
                CurrentError = GetString("Tasks.SynchronizationFailed");
                AddErrorLog(CurrentError, result);
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message;
            AddErrorLog(CurrentError);
        }
        finally
        {
            // Finalize log context
            FinalizeContext();
        }
    }
 /// <summary>
 /// Data reloading event handler.
 /// </summary>
 /// <param name="completeWhere">Complete where condition</param>
 /// <param name="currentOrder">Current order by clause</param>
 /// <param name="currentTopN">Current top N value</param>
 /// <param name="columns">Currently selected columns</param>
 /// <param name="currentOffset">Current page offset</param>
 /// <param name="currentPageSize">Current size of page</param>
 /// <param name="totalRecords">Returns number of returned records</param>
 protected DataSet uniGrid_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
 {
     // Get all custom tables which may current user read
     return(CustomTableHelper.GetFilteredTablesByPermission(completeWhere, currentOrder, currentTopN, columns));
 }