示例#1
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                var superKey = "";
                var newId    = SystemEntityTypeDataManager.GetNextSequence("TaskAlgorithmItem", (int)SystemEntity.TaskAlgorithmItem, SessionVariables.RequestProfile);
                var TaskAlgorithmItemdata = new TaskAlgorithmItemDataModel();
                var systemdevdata         = new SystemDevNumbersDataModel();
                systemdevdata.ApplicationUserId = SessionVariables.RequestProfile.AuditId;
                var dtnumbers = SystemDevNumbersDataManager.Search(systemdevdata, SessionVariables.RequestProfile);
                var rangefrom =
                    Convert.ToInt32(dtnumbers.Rows[0][SystemDevNumbersDataModel.DataColumns.RangeFrom].ToString());
                var rangeto =
                    Convert.ToInt32(dtnumbers.Rows[0][SystemDevNumbersDataModel.DataColumns.RangeTo].ToString());
                if (Request.QueryString["SuperKey"] != null)
                {
                    superKey = Request.QueryString["SuperKey"].ToString();
                    var data = new SuperKeyDetailDataModel();
                    data.SuperKeyId         = Convert.ToInt32(superKey);
                    data.SystemEntityTypeId = (int)SystemEntity.TaskAlgorithmItem;
                    var dt = SuperKeyDetailDataManager.Search(data, SessionVariables.RequestProfile);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            var key = Convert.ToInt32(dr[SuperKeyDetailDataModel.DataColumns.EntityKey]);
                            TaskAlgorithmItemdata.TaskAlgorithmItemId = key;

                            var TaskAlgorithmItemdt = TaskAlgorithmItemDataManager.GetDetails(TaskAlgorithmItemdata, SessionVariables.RequestProfile);

                            if (TaskAlgorithmItemdt.Rows.Count == 1)
                            {
                                var row = TaskAlgorithmItemdt.Rows[0];

                                if (Request.QueryString["Mode"].ToString().Equals("Test"))
                                {
                                    TaskAlgorithmItemdata.TaskAlgorithmItemId = GetNextValidId(rangefrom);
                                }
                                TaskAlgorithmItemdata.ActivityId  = Convert.ToInt32(row[TaskAlgorithmItemDataModel.DataColumns.ActivityId]);
                                TaskAlgorithmItemdata.Description = Convert.ToString(row[TaskAlgorithmItemDataModel.DataColumns.Description]);
                                TaskAlgorithmItemdata.SortOrder   = Convert.ToInt32(row[TaskAlgorithmItemDataModel.DataColumns.SortOrder]);

                                TaskAlgorithmItemDataManager.Create(TaskAlgorithmItemdata, SessionVariables.RequestProfile);
                            }
                        }
                    }
                }
                else if (Request.QueryString["SetId"] != null)
                {
                    var key = int.Parse(Request.QueryString["SetId"]);
                    TaskAlgorithmItemdata.TaskAlgorithmItemId = key;

                    var TaskAlgorithmItemdt = TaskAlgorithmItemDataManager.GetDetails(TaskAlgorithmItemdata, SessionVariables.RequestProfile);

                    if (TaskAlgorithmItemdt.Rows.Count == 1)
                    {
                        var row = TaskAlgorithmItemdt.Rows[0];

                        var newTaskAlgorithmItemdata = new TaskAlgorithmItemDataModel();
                        if (Request.QueryString["Mode"].ToString().Equals("Test"))
                        {
                            newTaskAlgorithmItemdata.TaskAlgorithmItemId = newId = (int)GetNextValidId(rangefrom);
                        }
                        newTaskAlgorithmItemdata.ActivityId  = Convert.ToInt32(row[TaskAlgorithmItemDataModel.DataColumns.ActivityId]);
                        newTaskAlgorithmItemdata.Description = Convert.ToString(row[TaskAlgorithmItemDataModel.DataColumns.Description]);
                        newTaskAlgorithmItemdata.SortOrder   = Convert.ToInt32(row[TaskAlgorithmItemDataModel.DataColumns.SortOrder]);

                        UpdatedFKDepenedencies(key, newId);
                        TaskAlgorithmItemDataManager.Delete(TaskAlgorithmItemdata, SessionVariables.RequestProfile);
                        TaskAlgorithmItemDataManager.Create(newTaskAlgorithmItemdata, SessionVariables.RequestProfile);
                    }
                }
                else if (Request.QueryString["Mode"].ToString().Equals("Renumber"))
                {
                    var seed = int.Parse(Request.QueryString["Seed"].ToString());
                    //ApplicationVariables.Seed;
                    var increment = int.Parse(Request.QueryString["Increment"].ToString());
                    //ApplicationVariables.Increment;
                    TaskAlgorithmItemDataManager.Renumber(seed, increment, SessionVariables.RequestProfile);
                }
                base.OnInit(e);

                Response.Redirect("Default.aspx?Added=true", false);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
示例#2
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                var superKey      = string.Empty;
                var newId         = SystemEntityTypeDataManager.GetNextSequence("Client", (int)SystemEntity.Client, SessionVariables.RequestProfile);
                var clientData    = new ClientDataModel();
                var systemDevData = new SystemDevNumbersDataModel();

                systemDevData.ApplicationUserId = SessionVariables.RequestProfile.AuditId;
                var dtnumbers = SystemDevNumbersDataManager.Search(systemDevData, SessionVariables.RequestProfile);

                var rangefrom = Convert.ToInt32(dtnumbers.Rows[0][SystemDevNumbersDataModel.DataColumns.RangeFrom].ToString());
                var rangeto   = Convert.ToInt32(dtnumbers.Rows[0][SystemDevNumbersDataModel.DataColumns.RangeTo].ToString());

                if (Request.QueryString["SuperKey"] != null)
                {
                    superKey = Request.QueryString["SuperKey"];
                    var data = new SuperKeyDetailDataModel();

                    data.SuperKeyId         = Convert.ToInt32(superKey);
                    data.SystemEntityTypeId = (int)SystemEntity.Client;
                    var dt = SuperKeyDetailDataManager.Search(data, SessionVariables.RequestProfile);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            var key = (int)(dr[SuperKeyDetailDataModel.DataColumns.EntityKey]);
                            clientData.ClientId = key;

                            var clientdt = ClientDataManager.GetDetails(clientData, SessionVariables.RequestProfile);

                            if (clientdt.Rows.Count == 1)
                            {
                                var row = clientdt.Rows[0];

                                if (Request.QueryString["Mode"].Equals("Test"))
                                {
                                    clientData.ClientId = GetNextValidId(rangefrom);
                                }
                                clientData.Name        = Convert.ToString(row[StandardDataModel.StandardDataColumns.Name]);
                                clientData.Description = Convert.ToString(row[StandardDataModel.StandardDataColumns.Description]);
                                clientData.SortOrder   = (int)(row[StandardDataModel.StandardDataColumns.SortOrder]);

                                ClientDataManager.Create(clientData, SessionVariables.RequestProfile);
                            }
                        }
                    }
                }
                else if (Request.QueryString["SetId"] != null)
                {
                    var key = int.Parse(Request.QueryString["SetId"]);
                    clientData.ClientId = key;

                    var clientdt = ClientDataManager.GetDetails(clientData, SessionVariables.RequestProfile);

                    if (clientdt.Rows.Count == 1)
                    {
                        var row = clientdt.Rows[0];

                        var newclientdata = new ClientDataModel();

                        if (Request.QueryString["Mode"].Equals("Test"))
                        {
                            newclientdata.ClientId = newId = GetNextValidId(rangefrom);
                        }

                        newclientdata.Name        = Convert.ToString(row[StandardDataModel.StandardDataColumns.Name]);
                        newclientdata.Description = Convert.ToString(row[StandardDataModel.StandardDataColumns.Description]);
                        newclientdata.SortOrder   = (int)(row[StandardDataModel.StandardDataColumns.SortOrder]);

                        UpdatedFKDepenedencies(key, newId);

                        ClientDataManager.Delete(clientData, SessionVariables.RequestProfile);
                        ClientDataManager.Create(newclientdata, SessionVariables.RequestProfile);
                    }
                }
                else if (Request.QueryString["Mode"].Equals("Renumber"))
                {
                    var seed = int.Parse(Request.QueryString["Seed"]);
                    //ApplicationVariables.Seed;
                    var increment = int.Parse(Request.QueryString["Increment"]);
                    //ApplicationVariables.Increment;
                    ClientDataManager.Renumber(seed, increment, SessionVariables.RequestProfile);
                }
                base.OnInit(e);

                Response.Redirect(Page.GetRouteUrl("ClientEntityRoute", new { Action = "Default", SetId = true }), false);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }