コード例 #1
0
        //----------------------------------------------------------
        public string Them_Hoac_Xoa_Information_Trong_Project(UIApplication uiapp, Document doc)
        {
            string result = "F";

            try
            {
                Transaction transaction = new Transaction(doc);
                transaction.Start("Parameters");
                if (number.SelectedItem != null && block.Text != "")
                {
                    var projectInfor      = doc.ProjectInformation;
                    data_information item = (data_information)number.SelectedItem;
                    projectInfor.Number       = item.project_number;
                    projectInfor.Name         = item.project_name;
                    projectInfor.Address      = item.project_address;
                    projectInfor.BuildingName = block.Text;
                    if (projectInfor.LookupParameter("Class") != null)
                    {
                        projectInfor.LookupParameter("Class").Set(descipline);
                    }
                    result = "S";
                }
                else
                {
                    MessageBox.Show("Missing data!!!", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                transaction.Commit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(result);
        }
コード例 #2
0
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------
        public UserControl1(UIApplication _uiapp)
        {
            InitializeComponent();
            uiapp   = _uiapp;
            uidoc   = uiapp.ActiveUIDocument;
            doc     = uidoc.Document;
            version = Convert.ToInt32(uiapp.Application.VersionNumber);

            user = uiapp.Application.Username;
            string myIP = Dns.GetHostAddresses(Dns.GetHostName()).First(x => x.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();
            string path = Source.pathUserPassword + "\\" + myIP;

            if (File.Exists(path))
            {
                data_information information = JsonConvert.DeserializeObject <data_information>(File.ReadAllText(path));
                user = information.user_name;
            }

            Function_Dau_Vao();
        }
コード例 #3
0
 //--------------------------------------------------------------------------------------------------------------------------------------------------------------
 void get_role_check_clash()
 {
     try
     {
         string path = Source.pathUserPassword + "\\" + Dns.GetHostAddresses(Dns.GetHostName())[0].ToString();
         if (File.Exists(path))
         {
             data_information information = JsonConvert.DeserializeObject <data_information>(File.ReadAllText(path));
             if (!string.IsNullOrEmpty(information.user_id) && !string.IsNullOrEmpty(information.user_password))
             {
                 List <string> Para2 = new List <string>()
                 {
                     "@DBUserId", "@DBUserPassWord"
                 };
                 List <string> Para2_Values = new List <string>()
                 {
                     information.user_id, information.user_password
                 };
                 var listtotal = SQL.SQLRead(Source.path_WEB, "dbo.spRead_Role_By_User", Source.type_Procedure, Para2, Para2_Values);
                 if (listtotal.Rows.Count > 0)
                 {
                     List <data_role_user> my_role_user = JsonConvert.DeserializeObject <List <data_role_user> >(listtotal.Rows[0]["Project"].ToString());
                     foreach (data_role_user data in my_role_user)
                     {
                         if (data.projectNumber == project_number)
                         {
                             if (data.role.Contains("CheckClash"))
                             {
                                 delete_parent.IsEnabled = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #4
0
        public string Logout()
        {
            string result = "F";

            try
            {
                string myIP = Dns.GetHostAddresses(Dns.GetHostName()).First(x => x.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();
                path = Source.pathUserPassword + "\\" + myIP;

                if (Directory.Exists(Source.pathUserPassword) == false)
                {
                    Directory.CreateDirectory(Source.pathUserPassword);
                }

                if (File.Exists(path))
                {
                    data_information data = JsonConvert.DeserializeObject <data_information>(File.ReadAllText(path));
                    File.Delete(path);
                    data_information listUser = new data_information()
                    {
                        user_name = data.user_name,
                        user_id   = data.user_id
                    };
                    File.WriteAllText(path, JsonConvert.SerializeObject(listUser));

                    user.Text = data.user_name;
                    result    = "S";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                File.Delete(path);
            }
            return(result);
        }
コード例 #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            data_information data = (data_information)value;

            return(data != null ? data.project_name : "");
        }
コード例 #6
0
        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public string Check_Permission(UIControlledApplication application)
        {
            string addin = null;

            try
            {
                List <data_information> data = new List <data_information>();
                var listDataUser             = SQL.SQLRead(Source.path_WEB, "dbo.spRead_User", Source.type_Query, new List <string>(), new List <string>());
                for (var i = 0; i < listDataUser.Rows.Count; i++)
                {
                    if (!string.IsNullOrEmpty(listDataUser.Rows[i]["SystemRole"].ToString()))
                    {
                        data.Add(new data_information()
                        {
                            user_name     = listDataUser.Rows[i]["UserName"].ToString(),
                            user_id       = listDataUser.Rows[i]["UserId"].ToString(),
                            user_password = listDataUser.Rows[i]["UserPassWord"].ToString(),
                            role          = listDataUser.Rows[i]["SystemRole"].ToString()
                        });
                    }
                }

                List <data_role> role = new List <data_role>();
                var listDataRole      = SQL.SQLRead(Source.path_Manage, "dbo.sp_ReadData_RoleManage", Source.type_Query, new List <string>(), new List <string>());
                for (var i = 0; i < listDataRole.Rows.Count; i++)
                {
                    role.Add(new data_role()
                    {
                        role  = listDataRole.Rows[i]["Role"].ToString(),
                        addin = listDataRole.Rows[i]["Addin"].ToString()
                    });
                }

                string myIP = Dns.GetHostAddresses(Dns.GetHostName()).First(x => x.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();
                string path = pathUserPassword + "\\" + myIP;

                if (File.Exists(path))
                {
                    string           role_addin = "";
                    data_information data_infor = JsonConvert.DeserializeObject <data_information>(File.ReadAllText(path));
                    var infor = data.Where(x => x.user_id == data_infor.user_id && x.user_password == data_infor.user_password).ToList();
                    if (infor.Count() == 1)
                    {
                        role_addin = data_infor.role;
                    }

                    var data_addin = role.Where(x => x.role == role_addin).ToList();
                    if (data_addin.Count() == 1)
                    {
                        addin = data_addin[0].addin;
                    }
                    if (string.IsNullOrEmpty(addin))
                    {
                        MessageBoxResult messageBoxResult = MessageBox.Show("You are not logged in !!! \nAre you logged in ???", "ERROR", MessageBoxButton.YesNo, MessageBoxImage.Error);
                        if (messageBoxResult == MessageBoxResult.Yes)
                        {
                            UserControl1 mainWindow = new UserControl1();
                            mainWindow.ShowDialog();
                            Check_Permission(application);
                        }
                    }
                    else
                    {
                        AddRibbonPanel(application, addin);
                    }
                }
            }
            catch (Exception)
            {
                if (string.IsNullOrEmpty(addin))
                {
                    MessageBoxResult messageBoxResult = MessageBox.Show("You are not logged in !!! \nAre you logged in ???", "ERROR", MessageBoxButton.YesNo, MessageBoxImage.Error);
                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        UserControl1 mainWindow = new UserControl1();
                        mainWindow.ShowDialog();
                        Check_Permission(application);
                    }
                }
            }
            return(addin);
        }