Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Save()
        {
            if (this.LookupID == "")
            {
                this.LookupID = dataLookup.SaveLookup(this.ClientID,
                                                      this.Name,
                                                      this.Description,
                                                      this.IsCore);
            }
            var conn = c.GetServer().Connection();

            if (this.LookupID != "")
            {
                dataLookup.UpdateLookup(this.ClientID, this.LookupID, this.Name, this.Description, this.IsCore);
                foreach (LookupItem itm in this.LookupItems)
                {
                    if (itm.LookUpItemID == "" || itm.LookUpItemID == null)
                    {
                        itm.Save(conn);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// this method load attribute of the component
        /// </summary>
        public override void LoadAttributes()
        {
            Data.Component.ComponentAttribute ca = new Data.Component.ComponentAttribute(ck.GetServer().Connection());
            var dt = new DataTable();

            dt = ca.GetAttributes(this.ComponentID);
            foreach (DataRow dr in dt.Rows)
            {
                string _fieldid = "";
                _fieldid = dr.IsNull("FieldID") ? "" : dr["FieldID"].ToString();
                ComponentAttribute c = new ComponentAttribute(this.ClientID, this.TableID, _fieldid);
                c.AttributeName = dr.IsNull("AttributeName") ? "" : dr["AttributeName"].ToString();
                //      c.FieldName = dr.IsNull("FieldName") ? "" : dr["FieldName"].ToString();
                c.IsRequired    = dr.IsNull("IsRequired") ? false : Convert.ToBoolean(dr["IsRequired"]);
                c.IsUnique      = dr.IsNull("IsUnique") ? false : Convert.ToBoolean(dr["IsUnique"]);
                c.IsCore        = dr.IsNull("IsCore") ? false : Convert.ToBoolean(dr["IsCore"]);
                c.IsReadOnly    = dr.IsNull("IsReadOnly") ? false : Convert.ToBoolean(dr["IsReadOnly"]);
                c.IsSecured     = dr.IsNull("IsSecured") ? false : Convert.ToBoolean(dr["IsSecured"]);
                c.IsAuto        = dr.IsNull("IsAuto") ? false : Convert.ToBoolean(dr["IsAuto"]);
                c.DefaultValue  = dr.IsNull("DefaultValue") ? "" : dr["DefaultValue"].ToString();
                c.FileExtension = dr.IsNull("FileExtension") ? "" : dr["FileExtension"].ToString();
                c.RegExp        = dr.IsNull("RegExp") ? "" : dr["RegExp"].ToString();
                c.LookUpID      = dr.IsNull("LookUpID") ? "" : dr["LookUpID"].ToString();
                c.AttributeType = dr.IsNull("AttributeType") ? ComponentAttribute.ComoponentAttributeType._string : (ComponentAttribute.ComoponentAttributeType)dr["AttributeType"];
                // c.FieldType= dr.IsNull("FieldType") ? DbType.String :(DbType) dr["FieldType"];
                c.Length       = dr.IsNull("length") ? -1 : Convert.ToInt32(dr["length"]);
                c.IsNullable   = dr.IsNull("IsNullable") ? false : Convert.ToBoolean(dr["IsNullable"]);
                c.IsPrimaryKey = dr.IsNull("ISPrimaryKey") ? false : Convert.ToBoolean(dr["ISPrimaryKey"]);
                this.Attributes.Add(c);
            }
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientID"></param>        ///
 public ComponentModal(string clientID, string name, string category, string parentnode)
 {
     ClientID           = clientID;
     c                  = new ClientServer(ClientID);
     ModalName          = name;
     Category           = category;
     ParentComponent    = parentnode;
     ComponentModalRoot = new List <ComponentNode>();
     conn               = c.GetServer().Connection();
     dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());
 }
Esempio n. 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientID"></param>        ///
 public ComponentModal(string clientID)
 {
     ClientID           = clientID;
     c                  = new ClientServer(ClientID);
     ModalName          = "";
     Category           = "";
     ParentComponent    = "";
     ComponentModalRoot = new List <ComponentNode>();
     conn               = c.GetServer().Connection();
     dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());
 }
        public JsonpResult GetTable(string clientid, string tableid)
        {
            ClientServer c = new ClientServer(clientid);

            Tz.Net.DataManager dataManager = new Net.DataManager(tableid, c.GetServer().ServerID, clientid);
            return(new JsonpResult(dataManager.GetTable()));
        }
Esempio n. 6
0
        public bool ExecuteNow()
        {
            ClientServer sc = new ClientServer(this.ClientID);
            DataExport   de = new DataExport(sc.GetServer().Connection());

            de.Merge <ExportSettings>(Settings);
            Data.ImportExport im = new Data.ImportExport();
            try
            {
                Status = ImportExportStatus.progress;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "");
                string fileName = @"/sqldump-" + Guid.NewGuid().ToString() + ".sql";
                var    path     = FolderPath + fileName;
                de.ExportTo(path);
                Status = ImportExportStatus.completed;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "", fileName);
            }
            catch (Exception ex)
            {
                Status = ImportExportStatus.error;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, ex.Message);
                throw ex;
            }
            finally {
            }
            return(true);
        }
Esempio n. 7
0
        public bool RemoveAllRelations()
        {
            var c = new ClientServer(ClientID);
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            dataComponentModal.RemoveAllItemRelation(this.ClientID, this.ComponentModalItemID);
            return(true);
        }
Esempio n. 8
0
        public static string GetConnection(string clientID)
        {
            string       conn;
            ClientServer ck;

            ck   = new ClientServer(clientID);
            conn = ck.GetServer().Connection();
            return(conn);
        }
Esempio n. 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientid"></param>
 public Lookup(string clientid)
 {
     c           = new ClientServer(clientid);
     ClientID    = clientid;
     LookupID    = "";
     Name        = "";
     LookupItems = new List <LookupItem>();
     dataLookup  = new Data.Component.LookUp(c.GetServer().Connection());
 }
Esempio n. 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientid"></param>
 /// <param name="lookupid"></param>
 public Lookup(string clientid, string lookupid)
 {
     ClientID    = clientid;
     c           = new ClientServer(clientid);
     LookupID    = lookupid;
     LookupItems = new List <LookupItem>();
     dataLookup  = new Data.Component.LookUp(c.GetServer().Connection());
     Load();
 }
Esempio n. 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientID"></param>
 /// <param name="componentModalID"></param>
 public ComponentModal(string clientID, string componentModalID)
 {
     this.ClientID           = clientID;
     c                       = new ClientServer(ClientID);
     ComponentModalID        = componentModalID;
     this.ComponentModalRoot = new List <ComponentNode>();
     conn                    = c.GetServer().Connection();
     dataComponentModal      = new Data.Component.ComponentModal(conn);
     LoadModal();
 }
Esempio n. 12
0
 public Component(string clientID)
 {
     ClientID      = clientID;
     ComponentID   = "";
     TableID       = "";
     PrimaryKeys   = "";
     ck            = new ClientServer(clientID);
     State         = ComponentState.draft;
     dataComponent = new Data.Component.Component(ck.GetServer().Connection());
     Attributes    = new List <ComponentAttribute>();
 }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tb"></param>
        /// <param name="currentPage"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public JsonResult GetData(string clientid, string tb, int currentPage, int PageSize)
        {
            ClientServer c = new ClientServer(clientid);

            System.Data.DataTable dt = new DataTable();
            Data.DBDatabase       db = Data.DBDatabase.Create(c.GetServer().Connection(), "MySql.Data.MySqlClient");
            // Data.DBDatabase db = Data.DBDatabase.Create("Server=52.163.241.42; Uid=admin;Pwd=smrtalentoz3106;Initial Catalog=jumbo_talentoz; ", "MySql.Data.MySqlClient");
            //Data.Schema.DBSchemaProvider provider = db.GetSchemaProvider();
            //DBSchemaTable tables = provider.GetTable(tb);
            string  dbname      = c.GetServer().DBName;
            DBQuery totalRecord = DBQuery.SelectCount().From(dbname, tb);
            int     trecord     = Convert.ToInt32(db.ExecuteScalar(totalRecord));
            DBQuery record      = DBQuery.SelectAll().From(dbname, tb).TopRange(currentPage * PageSize, PageSize);
            var     dtRecord    = db.GetDatatable(record);
            string  dtr         = DataResult.Create(dtRecord, PageSize, currentPage, trecord);

            //tables.Columns

            return(Json(dtr, JsonRequestBehavior.AllowGet));
        }
Esempio n. 14
0
        public JsonpResult GetData(int pageSize, int currentPage, string clientid, string tbid)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            ClientServer          c  = new ClientServer(clientid);

            Tz.Net.DataManager dataManager = new Net.DataManager(tbid, c.GetServer().ServerID, clientid);
            dt = dataManager.GetData(currentPage, pageSize);
            int trecord = dataManager.GetDataCount();

            string dtr = DataResult.Create(dt, pageSize, currentPage, trecord);

            return(new JsonpResult(dtr));
        }
Esempio n. 15
0
 /// <summary>
 /// remove field from the table
 /// </summary>
 /// <param name="clientid"></param>
 /// <param name="tbID"></param>
 /// <param name="fieldID"></param>
 /// <returns></returns>
 public JsonpResult RemoveField(string clientid, string tbID, string fieldID)
 {
     try
     {
         ClientServer       c           = new ClientServer(clientid);
         Tz.Net.DataManager dataManager = new Net.DataManager(tbID, c.GetServer().ServerID, clientid);
         dataManager.RemoveField(fieldID);
         return(new JsonpResult("true"));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 16
0
        public static async Task <int> synSever(string ClientID)
        {
            System.Data.DataTable dt = new DataTable();
            ClientServer          c  = new ClientServer(ClientID);

            Tz.ClientManager.Server           s                   = c.GetServer();
            Tech.Data.DBDatabase              db                  = Tech.Data.DBDatabase.Create(s.Connection(), "MySql.Data.MySqlClient");
            Tech.Data.Schema.DBSchemaProvider provider            = db.GetSchemaProvider();
            IEnumerable <Tech.Data.Schema.DBSchemaItemRef> tables = provider.GetAllTables();
            int count = 0;
            List <Tz.Net.Entity.Table> dtTb = Net.Entity.Table.GetTables(ClientID, s.ServerID);
            await Task.Run(() =>
            {
                var dm = new DataManager(s, c.ClientID);
                foreach (Tech.Data.Schema.DBSchemaItemRef df in tables)
                {
                    if (dtTb.Where(x => x.TableName.ToLower() == df.Name.ToLower()).FirstOrDefault() != null)
                    {
                        continue;
                    }
                    dm.NewTable(df.Name, df.Catalog);
                    DBSchemaTable schema = provider.GetTable(df.Name);
                    foreach (Tech.Data.Schema.DBSchemaTableColumn dc in schema.Columns)
                    {
                        if (dc.ColumnFlags == Tech.Data.DBColumnFlags.Nullable)
                        {
                            dm.AddField(dc.Name, dc.DbType, dc.Size, true);
                        }
                        else if (dc.ColumnFlags == Tech.Data.DBColumnFlags.PrimaryKey)
                        {
                            dm.AddPrimarykey(dc.Name, dc.DbType, dc.Size);
                        }
                        else
                        {
                            dm.AddField(dc.Name, dc.DbType, dc.Size, false);
                        }
                    }
                    try {
                        dm.AcceptChanges(true);
                    }
                    catch (Exception ex) {
                    }
                    count = count + 1;
                }
                return(count);
            });

            return(count);
        }
Esempio n. 17
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public JsonResult GetEntity(string clientid)
        {
            System.Data.DataTable dt = new DataTable();
            ClientServer          c  = new ClientServer(clientid);

            Data.DBDatabase db = Data.DBDatabase.Create(c.GetServer().Connection(), "MySql.Data.MySqlClient");
            // Data.DBDatabase db = Data.DBDatabase.Create("Server=52.163.241.42; Uid=admin;Pwd=smrtalentoz3106;Initial Catalog=jumbo_talentoz; ", "MySql.Data.MySqlClient");
            //Server=52.163.241.42; Uid=admin;Pwd=smrtalentoz3106;Initial Catalog=jumbo_talentoz;
            Data.Schema.DBSchemaProvider provider             = db.GetSchemaProvider();
            IEnumerable <Data.Schema.DBSchemaItemRef> tables  = provider.GetAllTables();
            IEnumerable <Data.Schema.DBSchemaItemRef> tables1 = provider.GetAllViews();

            tables = tables.Concat(tables1);
            return(Json(Newtonsoft.Json.JsonConvert.SerializeObject(tables), JsonRequestBehavior.AllowGet));
        }
Esempio n. 18
0
        public string GetData(List <ComponentKey> keys, int currentIndex, int pageSize)
        {
            Component    c  = (Component)_component;
            ClientServer cs = new ClientServer(this.ClientID);
            Server       s  = cs.GetServer();
            var          dm = new Tz.Net.DataManager(this.Component.TableID, s.ServerID, this.ClientID);

            System.Data.DataTable dt = new System.Data.DataTable();
            //var tb = new Tz.Net.Entity.Table(s.ServerID,this.Component.TableID,this.ClientID);
            dt = dm.GetData(currentIndex, pageSize);
            int totalCount = dm.GetDataCount();
            var dtjson     = dt.ToJSON();

            return("{data:" + dtjson + ",total:" + totalCount + "}");
        }
Esempio n. 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="modalid"></param>
        /// <returns></returns>
        public bool RemoveItem(string modalid)
        {
            var c = new ClientServer(ClientID);
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            if (dataComponentModal.RemoveModalItem(this.ClientID, modalid, this.ComponentModalItemID))
            {
                dataComponentModal.RemoveAllItemRelation(this.ClientID, this.ComponentModalItemID);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mrelatedID"></param>
        /// <param name="parentfield"></param>
        /// <param name="relatedfield"></param>
        /// <returns></returns>
        public bool UpdateModalItemRelation(string mrelatedID, string parentfield, string relatedfield)
        {
            var c    = new ClientServer(ClientID);
            var item = this.Relations.Where(x => x.ModalItemRelationID == mrelatedID).FirstOrDefault();
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            if (item != null)
            {
                dataComponentModal.UpdateItemRelation(this.ClientID, mrelatedID, this.ComponentModalItemID, parentfield, relatedfield);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 21
0
        public bool ImportNow()
        {
            ClientServer sc = new ClientServer(this.ClientID);
            DataImport   di = new DataImport(sc.GetServer().Connection());

            Data.ImportExport im = new Data.ImportExport();

            try
            {
                string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                assemblyFolder = assemblyFolder.Replace("\\Debug", "");
                assemblyFolder = assemblyFolder.Replace("\\bin", "");
                assemblyFolder = assemblyFolder.Replace("\\netcoreapp2.1", "");
                assemblyFolder = assemblyFolder.Replace("file:\\", "");
                if (ImportFilePath.StartsWith("~"))
                {
                    ImportFilePath = ImportFilePath.Substring(1);
                }
                string impPath = assemblyFolder + ImportFilePath;
                Status = ImportExportStatus.progress;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "");
                string rst = di.ImportFrom(impPath, IgnoreSQLErrors);
                if (rst == "done")
                {
                    Status = ImportExportStatus.completed;
                    im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "");
                    return(true);
                }
                else
                {
                    Status = ImportExportStatus.error;
                    im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, rst);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Status = ImportExportStatus.error;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, ex.Message);
                throw ex;
            }
            finally
            {
            }
        }
Esempio n. 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tb"></param>
        /// <returns></returns>
        public JsonResult GetFields(string clientid, string tb)
        {
            System.Data.DataTable dt = new DataTable();
            ClientServer          c  = new ClientServer(clientid);

            Data.DBDatabase db = Data.DBDatabase.Create(c.GetServer().Connection(), "MySql.Data.MySqlClient");
            // Data.DBDatabase db = Data.DBDatabase.Create("Server=52.163.241.42; Uid=admin;Pwd=smrtalentoz3106;Initial Catalog=jumbo_talentoz; ", "MySql.Data.MySqlClient");
            Data.Schema.DBSchemaProvider provider = db.GetSchemaProvider();
            DBSchemaTable tables = provider.GetTable(tb);

            if (tables == null)
            {
                DBSchemaView view = provider.GetView(tb);
                return(Json(Newtonsoft.Json.JsonConvert.SerializeObject(view), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(Newtonsoft.Json.JsonConvert.SerializeObject(tables), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientID"></param>
 /// <param name="componentType"></param>
 public Component(string clientID,
                  string name,
                  ComponentType componentType,
                  string title,
                  string titleformat
                  , string category)
 {
     ClientID           = clientID;
     ComponentID        = "";
     TableID            = "";
     PrimaryKeys        = "";
     this.Title         = title;
     this.TitleFormat   = titleformat;
     this.ComponentName = name;
     this.Category      = category;
     this.ComponentType = componentType;
     ck            = new ClientServer(clientID);
     State         = ComponentState.draft;
     dataComponent = new Data.Component.Component(ck.GetServer().Connection());
     Attributes    = new List <ComponentAttribute>();
 }
Esempio n. 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientid"></param>
        /// <returns></returns>
        public static List <Lookup> GetLookUps(string clientid, string lookupIds = "")
        {
            ClientServer  c          = new ClientServer(clientid);
            var           dataLookup = new Data.Component.LookUp(c.GetServer().Connection());
            DataTable     dt         = dataLookup.GetLookUpList(clientid, lookupIds);
            List <Lookup> lup        = new List <Lookup>();

            foreach (DataRow dr in dt.Rows)
            {
                Lookup l = new Lookup(clientid);
                l.Name        = dr["Name"] == null ? "" : dr["Name"].ToString();
                l.IsCore      = DBNull.Value.Equals(dr["IsCore"]) == true ? false : Convert.ToBoolean(dr["IsCore"]);
                l.Description = DBNull.Value.Equals(dr["Description"]) == true ? "" : dr["Description"].ToString();
                l.CreatedOn   = DBNull.Value.Equals(dr["CreatedOn"]) == true ? DateTime.Now : Convert.ToDateTime(dr["LastUPD"]);
                l.LastUPD     = DBNull.Value.Equals(dr["LastUPD"]) == true ? DateTime.Now : Convert.ToDateTime(dr["LastUPD"]);
                l.LookupID    = dr["LookUpID"] == null? "": dr["LookUpID"].ToString();
                //     l.Value = DBNull.Value.Equals(dr["Value"]) == true ? "" : (string)(dr["Value"]);
                lup.Add(l);
            }
            return(lup);
        }
Esempio n. 25
0
 /// <summary>
 /// update existing field
 /// </summary>
 /// <param name="clientid"></param>
 /// <param name="tbID"></param>
 /// <param name="fields"></param>
 /// <returns></returns>
 public JsonpResult UpdateField(string clientid, string tbID, string fields)
 {
     try
     {
         ClientServer       c           = new ClientServer(clientid);
         Tz.Net.DataManager dataManager = new Net.DataManager(tbID, c.GetServer().ServerID, clientid);
         Models.Field       mField      = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Field>(fields);
         //if (mField.IsPrimaryKey)
         //{
         //   // dataManager.AddPrimarykey(mField.FieldName, mField.FieldType, mField.Length);
         //}
         //else
         //{
         dataManager.ChangeField(mField.FieldID, mField.FieldName, mField.FieldType, mField.Length, mField.IsNullable, mField.IsPrimaryKey, mField.NewFieldName);
         dataManager.AcceptChanges();
         // }
         return(new JsonpResult(dataManager.getTableID()));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 26
0
 /// <summary>
 ///  change name of the table
 /// </summary>
 /// <param name="clientid"></param>
 /// <param name="tb"></param>
 /// <returns></returns>
 public JsonpResult UpdateTable(string clientid, string tb)
 {
     try
     {
         ClientServer            c = new ClientServer(clientid);
         Tz.BackApp.Models.Table ModalTable;
         ModalTable = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Table>(tb);
         Tz.Net.DataManager dataManager = new Net.DataManager(ModalTable.TableID, c.GetServer().ServerID, clientid);
         dataManager.Rename(ModalTable.TableName, ModalTable.Category);
         return(new JsonpResult(dataManager.getTableID()));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientid"></param>
        /// <returns></returns>
        public static List <ComponentModal> GetModalList(string clientid)
        {
            DataTable             dt         = new DataTable();
            DataTable             dtModal    = new DataTable();
            DataTable             dtItem     = new DataTable();
            DataTable             dtRelation = new DataTable();
            List <ComponentModal> ModalList  = new List <ComponentModal>();
            var c = new ClientServer(clientid);
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            dt      = dataComponentModal.GetAllModal(clientid);
            dtModal = dt.DefaultView.ToTable(true, "Name", "Catgory", "ParentComponent", "ComponentModalID");

            dtItem     = dt.DefaultView.ToTable(true, "ComponentID", "ChildComponentID", "ComponentModalItemID", "ParentName", "ChildName");
            dtRelation = dt.DefaultView.ToTable(true, "ComponentModalItemID", "ParentField", "ComponentModalID",
                                                "RelatedField", "ComponentModalRelationID", "Parent", "Child", "ParentFieldName", "ChildFieldName");

            foreach (DataRow dr in dtModal.Rows)
            {
                var comp = new ComponentModal(clientid);

                comp.ModalName           = dr.IsNull("Name") ? "" : dr["Name"].ToString();
                comp.Category            = dr.IsNull("Catgory") ? "" : dr["Catgory"].ToString();
                comp.ParentComponent     = dr.IsNull("ParentComponent") ? "" : dr["ParentComponent"].ToString();
                comp.ComponentModalID    = dr.IsNull("ComponentModalID") ? "" : dr["ComponentModalID"].ToString();
                dt.DefaultView.RowFilter = "ComponentModalID ='" + comp.ComponentModalID + "'";
                dt.DefaultView.RowFilter = "";
                dtItem = dt.DefaultView.ToTable(true);
                foreach (DataRow dRow in dtItem.Rows)
                {
                    var           componentID  = dRow.IsNull("ComponentID") ? "" : dRow["ComponentID"].ToString();
                    var           ccomponentid = dRow.IsNull("ChildComponentID") ? "" : dRow["ChildComponentID"].ToString();
                    var           cmodalitemid = dRow.IsNull("ComponentModalItemID") ? "" : dRow["ComponentModalItemID"].ToString();
                    var           pname        = dRow.IsNull("ParentName") ? "" : dRow["ParentName"].ToString();
                    var           cname        = dRow.IsNull("ChildName") ? "" : dRow["ChildName"].ToString();
                    ComponentNode cn           = new ComponentNode(clientid, componentID, ccomponentid, cmodalitemid);
                    cn.ParentName = pname;
                    cn.ChildName  = cname;
                    dtRelation.DefaultView.RowFilter = "ComponentModalItemID ='" + cmodalitemid + "'";
                    var dtr = dtRelation.DefaultView.ToTable(true);
                    dtRelation.DefaultView.RowFilter = "";
                    foreach (DataRow drNodeRe in dtr.Rows)
                    {
                        var mrid   = drNodeRe.IsNull("ComponentModalRelationID") ? "" : drNodeRe["ComponentModalRelationID"].ToString();
                        var pf     = drNodeRe.IsNull("ParentField") ? "" : drNodeRe["ParentField"].ToString();
                        var rf     = drNodeRe.IsNull("RelatedField") ? "" : drNodeRe["RelatedField"].ToString();
                        var p      = drNodeRe.IsNull("Parent") ? "" : drNodeRe["Parent"].ToString();
                        var ch     = drNodeRe.IsNull("Child") ? "" : drNodeRe["Child"].ToString();
                        var pfield = drNodeRe.IsNull("ParentFieldName") ? "" : drNodeRe["ParentFieldName"].ToString();
                        var cfield = drNodeRe.IsNull("ChildFieldName") ? "" : drNodeRe["ChildFieldName"].ToString();
                        cn.AddRelation(new LinkComponentField()
                        {
                            ModalItemRelationID = mrid,
                            Child            = ch,
                            Parent           = p,
                            ParentFieldName  = pfield,
                            RelatedFieldName = cfield,
                            ParentField      = pf,
                            RelatedField     = rf
                        });
                    }
                    comp.ComponentModalRoot.Add(cn);
                }
                ModalList.Add(comp);
            }
            return(ModalList);
        }
Esempio n. 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientid"></param>
        /// <returns></returns>
        public JsonpResult GetTables(string clientid)
        {
            ClientServer c = new ClientServer(clientid);

            return(new JsonpResult(Net.Entity.Table.GetTables(clientid, c.GetServer().ServerID)));
        }
Esempio n. 29
0
        /// <summary>
        ///  new table creation with fields
        /// </summary>
        /// <param name="clientid"></param>
        /// <param name="tb"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public JsonpResult SaveTableField(string clientid, string tb, string fields)
        {
            try
            {
                ClientServer            c = new ClientServer(clientid);
                Tz.BackApp.Models.Table ModalTable;
                ModalTable = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Table>(tb);
                List <Models.Field> mFields = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Models.Field> >(fields);

                if (ModalTable.TableID == "")
                {
                    Tz.Net.DataManager dataManager = new Net.DataManager(c.GetServer().ServerID, clientid);
                    dataManager.NewTable(ModalTable.TableName, ModalTable.Category);
                    foreach (Models.Field f in mFields)
                    {
                        if (f.IsPrimaryKey)
                        {
                            dataManager.AddPrimarykey(f.FieldName, f.FieldType, f.Length);
                        }
                        else
                        {
                            dataManager.AddField(f.FieldName, f.FieldType, f.Length, f.IsNullable);
                        }
                    }
                    dataManager.AcceptChanges();
                    return(new JsonpResult(dataManager.getTableID()));
                }
                else
                {
                    Tz.Net.DataManager dataManager = new Net.DataManager(ModalTable.TableID, c.GetServer().ServerID, clientid);
                    if (ModalTable.TableName != "")
                    {
                        if (dataManager.GetTable().TableName != ModalTable.TableName)
                        {
                            dataManager.Rename(ModalTable.TableName, ModalTable.Category); // rename table
                        }
                    }

                    foreach (Models.Field f in mFields)
                    {
                        if (f.IsChanged || f.FieldID != "")
                        {
                            dataManager.ChangeField(f.FieldID, f.FieldName, f.FieldType, f.Length, f.IsNullable, f.IsPrimaryKey); // alter table field info & new field name
                        }
                        else
                        {
                            if (f.IsPrimaryKey)
                            {
                                dataManager.AddPrimarykey(f.FieldName, f.FieldType, f.Length);
                            }
                            else
                            {
                                dataManager.AddField(f.FieldName, f.FieldType, f.Length, f.IsNullable);
                            }
                        }
                    }
                    dataManager.AcceptChanges();
                    return(new JsonpResult(dataManager.getTableID()));
                    //dataManager
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 30
0
        public static List <Component> GetComponentList(string clientID)
        {
            var ck            = new ClientServer(clientID);
            var dataComponent = new Data.Component.Component(ck.GetServer().Connection());
            var dtFields      = new DataTable();
            var dt            = dataComponent.GetCompnents(clientID);
            var dttable       = dt.DefaultView.ToTable(true,
                                                       "ComponentID",
                                                       "ComponentName",
                                                       "ComponentType",
                                                       "Title",
                                                       "TableID",
                                                       "PrimaryKeys",
                                                       "TitleFormat",
                                                       "Category",
                                                       "IsGlobal"
                                                       );
            var clist = new List <Component>();

            dtFields = dt.DefaultView.ToTable(true, "FieldID",
                                              "AttributeName",
                                              "ComponentID",
                                              "IsRequired",
                                              "IsUnique",
                                              "IsCore",
                                              "IsReadOnly",
                                              "IsSecured",
                                              "IsAuto",
                                              "DefaultValue",
                                              "FileExtension",
                                              "RegExp",
                                              "AttributeType"

                                              );
            foreach (DataRow dr in dttable.Rows)
            {
                var c = new Component(clientID);
                c.ComponentID   = dr.IsNull("ComponentID") ? "" : dr["ComponentID"].ToString();
                c.ComponentName = dr.IsNull("ComponentName") ? "" : dr["ComponentName"].ToString();
                c.ComponentType = dr.IsNull("ComponentType") ? Tz.Core.ComponentType.none : (Tz.Core.ComponentType)dr["ComponentType"];
                c.Title         = dr.IsNull("Title") ? "" : dr["Title"].ToString();
                c.TableID       = dr.IsNull("TableID") ? "" : dr["TableID"].ToString();
                c.PrimaryKeys   = dr.IsNull("PrimaryKeys") ? "" : dr["PrimaryKeys"].ToString();
                c.TitleFormat   = dr.IsNull("TitleFormat") ? "" : dr["TitleFormat"].ToString();
                c.Category      = dr.IsNull("Category") ? "" : dr["Category"].ToString();
                c.IsGlobal      = dr.IsNull("IsGlobal") ? false : Convert.ToBoolean(dr["IsGlobal"]);
                c.State         = dr.IsNull("ComponentState") ? ComponentState.draft  : (ComponentState)(dr["ComponentState"]);

                foreach (DataRow drow in dtFields.Rows)
                {
                    string _fieldid = "";
                    _fieldid = drow.IsNull("FieldID") ? "" : drow["FieldID"].ToString();
                    ComponentAttribute ca = new ComponentAttribute(clientID, c.TableID, _fieldid);
                    ca.AttributeName = drow.IsNull("AttributeName") ? "" : drow["AttributeName"].ToString();
                    // ca.FieldName = drow.IsNull("FieldName") ? "" : drow["FieldName"].ToString();
                    ca.IsRequired    = drow.IsNull("IsRequired") ? false : Convert.ToBoolean(drow["IsRequired"]);
                    ca.IsUnique      = drow.IsNull("IsUnique") ? false : Convert.ToBoolean(drow["IsUnique"]);
                    ca.IsCore        = drow.IsNull("IsCore") ? false : Convert.ToBoolean(drow["IsCore"]);
                    ca.IsReadOnly    = drow.IsNull("IsReadOnly") ? false : Convert.ToBoolean(drow["IsReadOnly"]);
                    ca.IsSecured     = drow.IsNull("IsSecured") ? false : Convert.ToBoolean(drow["IsSecured"]);
                    ca.IsAuto        = drow.IsNull("IsAuto") ? false : Convert.ToBoolean(drow["IsAuto"]);
                    ca.DefaultValue  = drow.IsNull("DefaultValue") ? "" : drow["DefaultValue"].ToString();
                    ca.FileExtension = drow.IsNull("FileExtension") ? "" : drow["FileExtension"].ToString();
                    ca.RegExp        = drow.IsNull("RegExp") ? "" : drow["RegExp"].ToString();
                    ca.LookUpID      = dr.IsNull("LookUpID") ? "" : dr["LookUpID"].ToString();
                    ca.AttributeType = drow.IsNull("AttributeType") ? ComponentAttribute.ComoponentAttributeType._string : (ComponentAttribute.ComoponentAttributeType)drow["AttributeType"];
                    //ca.FieldType = drow.IsNull("FieldType") ? DbType.String : (DbType)drow["FieldType"];
                    ca.Length       = drow.IsNull("length") ? -1 : (int)drow["length"];
                    ca.IsNullable   = drow.IsNull("IsNullable") ? false : (bool)drow["IsNullable"];
                    ca.IsPrimaryKey = drow.IsNull("ISPrimaryKey") ? false : (bool)drow["ISPrimaryKey"];
                    c.Attributes.Add(ca);
                }
                clist.Add(c);
            }
            return(clist);
        }