示例#1
0
文件: Program.cs 项目: qiuhy/zj
        public static List <Bill> readFile(string fn, int skipRows, Str2Bill toBill)
        {
            List <Bill> billList = new List <Bill>();
            Encoding    encode   = CommUtil.GetFileEncoding(fn);

            using (FileStream fs = new FileStream(fn, FileMode.Open))
            {
                StreamReader sr   = new StreamReader(fs, encode);
                int          irow = 0;
                while (!sr.EndOfStream)
                {
                    string sLine = sr.ReadLine();
                    irow++;

                    if (irow > skipRows)
                    {
                        Bill b = toBill(sLine);
                        if (b != null)
                        {
                            if (b.id == 0)
                            {
                                b.id = irow - skipRows;
                            }
                            billList.Add(b);
                        }
                    }
                }
                sr.Close();
            }
            billList.Sort();
            return(billList);
        }
        /// <summary>
        ///查询训练计划分析页面展示的信息,参数为AppConfig中的当前训练计划id,当前训练课程id
        /// </summary>
        /// <returns></returns>
        public TrainingPlanVO GetTrainingPlanVO()
        {
            string trainingPlanId   = CommUtil.GetSettingString("trainingPlanId");
            string trainingCourseId = CommUtil.GetSettingString("trainingCourseId");

            return(trainingPlanDAO.GetTrainingPlanVO(trainingPlanId, trainingCourseId));
        }
示例#3
0
        /// <summary>
        /// fill module accessright from datarow
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="allowAccessActionList"></param>
        /// <param name="accessRightDA"></param>
        /// <returns></returns>
        private ModuleRightModel FillModuleRightModel(DataRow dr, List <string> allowAccessActionList, AccessRightDA accessRightDA)
        {
            ModuleRightModel mrModel = new ModuleRightModel();

            mrModel.ModuleCode = CommUtil.ConvertObjectToString(dr["code"]);
            mrModel.ModuleName = CommUtil.ConvertObjectToString(dr["name"]);

            DataTable dtAccessRight             = accessRightDA.GetAccessRightByModuleCode(dr["code"].ToString());
            Dictionary <string, bool> dicAction = new Dictionary <string, bool>();

            for (int j = 0; j < dtAccessRight.Rows.Count; j++)
            {
                DataRow drAction = dtAccessRight.Rows[j];
                if (drAction["name"] != null)
                {
                    if (allowAccessActionList.Contains(mrModel.ModuleCode + "_" + drAction["code"].ToString()))
                    {
                        dicAction[drAction["name"].ToString()] = true;
                    }
                    else
                    {
                        dicAction[drAction["name"].ToString()] = false;
                    }
                }
            }
            mrModel.DicAction = dicAction;
            return(mrModel);
        }
示例#4
0
 private void ExcelToPdf()
 {
     Dispatcher.Invoke(new Action(() =>
     {
         using (Workbook workbook = new Workbook())
         {
             workbook.LoadFromFile(CommUtil.GetDocPath("test.xlsx"));
             workbook.SaveToFile(CommUtil.GetDocPath("test.pdf"), Spire.Xls.FileFormat.PDF);
             //Worksheet sheet = workbook.Worksheets[0];
             //sheet.SaveToPdf(@"e:\test.pdf");
             //Console.WriteLine("转换执行完成了");
             ////获取第一张工作表
             //Worksheet sheet = workbook.Worksheets[0];
             ////设置打印区域(设置你想要转换的单元格范围)
             //sheet.PageSetup.PrintArea = "A1:K48";
             ////将指定范围内的单元格保存为PDF
             //sheet.SaveToPdf(@"e:\test.pdf");
             //文档输出
             //Console.WriteLine("转换完成了");
             if (SaveToPath != "" && SaveToPath != null)
             {
                 File.Copy(CommUtil.GetDocPath("test.pdf"), SaveToPath, true);
             }
         }
         PdfViewer.valueChange.Flag = true;
     }));
 }
示例#5
0
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PdfDocument doc = new PdfDocument();
                doc.LoadFromFile(CommUtil.GetDocPath("test.pdf"));
                PrintDialog dialogPrint = new PrintDialog();
                dialogPrint.AllowPrintToFile            = true;
                dialogPrint.AllowSomePages              = true;
                dialogPrint.PrinterSettings.MinimumPage = 1;
                dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
                dialogPrint.PrinterSettings.FromPage    = 1;
                dialogPrint.PrinterSettings.ToPage      = doc.Pages.Count;

                if (dialogPrint.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    //设置打印的起始页码
                    doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;

                    //设置打印的终止页码
                    doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;

                    //选择打印机
                    doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;

                    PrintDocument printDoc = doc.PrintDocument;
                    dialogPrint.Document = printDoc;
                    printDoc.Print();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("打印异常");
            }
        }
示例#6
0
        /// <summary>
        /// Get the module allow action by groupid
        /// </summary>
        /// <param name="groupID"></param>
        /// <returns></returns>
        private List <string> GetModuleAccessRightByGroupID(string groupID)
        {
            List <string> moduleARList  = new List <string>();
            AccessRightDA accessRightDA = null;
            DataTable     dt            = new DataTable();

            try
            {
                accessRightDA = new AccessRightDA();
                dt            = accessRightDA.GetAccessRightByGroupID(groupID);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    string  allowAccessModuleAction = CommUtil.ConvertObjectToString(dr["ModuleCode"]) + "_" + CommUtil.ConvertObjectToString(dr["ActionCode"]);
                    moduleARList.Add(allowAccessModuleAction);
                }
            }
            finally
            {
                if (accessRightDA != null)
                {
                    accessRightDA.CloseConnection();
                }
            }
            return(moduleARList);
        }
        /// <summary>
        /// EditActity页活动分组Expnder中的个人设置查询 分组是前端根据活动类型分
        /// </summary>
        /// <returns></returns>
        public List <ActivityGroupDTO> ListActivitysGroupAndPersonalSetting()
        {
            //当前正在进行和训练课程ID
            long courseId = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("trainingCourseId"));

            return(activityDAO.ListActivitysGroupAndPersonalSetting(courseId));
        }
示例#8
0
        public UserM GetUser(string userID)
        {
            UserDA  userDA = null;
            DataRow dr;
            var     u = new UserM {
            };

            try
            {
                userDA = new UserDA();

                dr = userDA.GetUsers(userID).Rows[0];

                u = new UserM
                {
                    UserID    = dr["UserID"].ToString(),
                    UserName  = dr["UserName"].ToString(),
                    Active    = CommUtil.ConvertObjectToBool(dr["Active"]),
                    IsDeleted = Convert.ToByte(dr["IsDeleted"]),
                };
            }
            finally
            {
                if (userDA != null)
                {
                    userDA.CloseConnection();
                }
            }

            return(u);
        }
示例#9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Height = SystemParameters.WorkArea.Size.Height;
            var hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;

            SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
            //获取最初姓名
            origin_name = t2.Text;
            //获取最初姓名
            origin_name_pinyin = SelectUser.User_Namepinyin;
            //获得最初的手机号
            origin_phone = SelectUser.User_Phone;
            //获得最初的身份证号
            origin_IDCard = SelectUser.User_IDCard;
            photoName     = SelectUser.User_PhotoLocation;

            // 加zai用戶的照片
            //更新完用戶后刷新一下展示的tu片
            //selectUser = (User)UsersInfo.SelectedItem;
            string path = CommUtil.GetUserPic() + photoName; // huo的用戶的tu片url

            if (File.Exists(path))
            {
                BitmapImage i = new BitmapImage(new Uri(path,
                                                        UriKind.Absolute)); //打开图片
                pic.Source = i.Clone();                                     //将控件和图片绑定
            }
            else
            {
                BitmapImage bitmap = new BitmapImage(new Uri(@"\view\images\NoPhoto.png", UriKind.Relative));
                pic.Source = bitmap;
            }
        }
示例#10
0
 private static void Main()
 {
     IsDeployClickOnce = true;
     ClickOnceUpdateDN = (_IsHyweb ? "mhr.hyweb.com.tw" : "mi.baphiq.gov.tw");
     Counter           = 0;
     Upgraded          = false;
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(defaultValue: false);
     if (ApplicationDeployment.CurrentDeployment.IsFirstRun)
     {
         CommUtil.WriteToFile("Config.ini", "\r\nMDBPath=" + ApplicationDeployment.CurrentDeployment.DataDirectory, 'A', string.Empty);
         copyShortcut("家禽屠宰衛生檢查系統", "家禽屠宰衛生檢查系統.appref-ms", "家禽屠宰衛生檢查系統(V3.3.0.1版).appref-ms");
     }
     if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Common Files\\MSSoap\\Binaries\\MSSOAP30.dll"))
     {
         MessageBox.Show("您尚未安裝過SOAP, 現在開始安裝。");
         Process process = Process.Start("soapsdk.exe");
         while (!process.HasExited)
         {
             Application.DoEvents();
             process.WaitForExit(50);
         }
     }
     Application.Run(new frmUpdate());
     if (Upgraded)
     {
         Application.Restart();
     }
 }
示例#11
0
 private void Btn_Confirm(object sender, RoutedEventArgs e)
 {//MessageBox.Show(LanguageUtils.ConvertLanguage("你确认要保存更改吗", "Are you sure you want to save your changes?"), LanguageUtils.ConvertLanguage("提示:", "Tips"), MessageBoxButton.OKCancel) == MessageBoxResult.OK
     if (MessageBoxX.Question(LanguageUtils.ConvertLanguage("你确认要保存更改吗", "Are you sure you want to save your changes?")))
     {
         string textValue1 = textBox1.Text;                         //机构团体名称
         string textValue2 = textBox2.Text;                         //照片保存文档
         string textValue3 = textBox3.Text;                         //机构电话
         //string textValue4 = textBox4.Text;//版本
         string        textValue5        = textBox5.Text;           //备份
         int           comboBox1Selected = comboBox1.SelectedIndex; //机构区分被选择的index
         int           comboBox2Selected = comboBox2.SelectedIndex; //语言被选择的index
         entity.Setter setter            = new entity.Setter();
         setter.Pk_Set_Id             = Pk_Set_Id;
         setter.Set_OrganizationName  = textValue1;
         setter.Set_PhotoLocation     = textValue2;
         setter.Set_OrganizationPhone = textValue3;
         //setter.Set_Version = textValue4;
         if (textValue5.Contains(" "))
         {
             MessageBoxX.Warning(LanguageUtils.ConvertLanguage("备份路径不能含有空格", "Backup path cannot contain spaces"));
         }
         else
         {
             setter.Back_Up              = textValue5;//备份路径
             setter.Set_Version          = CommUtil.GetCurrentVersion();
             setter.Set_Language         = comboBox2Selected;
             setter.Set_OrganizationSort = comboBox1Selected.ToString();
             setterDao.UpdateSetter(setter);
             //切换语言
             LanguageUtils.SetLanguage();
             GoBack(null, null);
         }
     }
 }
示例#12
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            if (!m_Connected)
            {
                return;
            }

            String DeviceName = DeviceAddr.Text;

            String[]      values = DeviceData.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            StringBuilder data   = new StringBuilder();

            try
            {
                foreach (String v in values)
                {
                    byte c = byte.Parse(v);
                    data.Append((Char)(c));
                }

                String dataStr = data.ToString();
                CommUtil.SetStringToDevice(dataStr, DeviceName, dataStr.Length, m_PLCCom);

                MessageBox.Show("写入成功", "信息");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "错误");
            }
        }
示例#13
0
        private void ReadButton_Click(object sender, EventArgs e)
        {
            if (!m_Connected)
            {
                return;
            }

            String DeviceName = DeviceAddr.Text;
            int    DeviceSize;

            if (!int.TryParse(DeviceNum.Text, out DeviceSize))
            {
                DeviceSize     = 1;
                DeviceNum.Text = DeviceSize.ToString();
            }

            try
            {
                String        data = CommUtil.GetStringFromDevice(DeviceName, DeviceSize * 2, m_PLCCom);
                StringBuilder msg  = new StringBuilder();
                foreach (Char c in data)
                {
                    msg.Append((short)(c));
                    msg.Append(" ");
                }
                DeviceData.Text = msg.ToString();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "错误");
            }
        }
示例#14
0
        public List <SelectListItem> GetAllOperation()
        {
            List <SelectListItem> _operationList = new List <SelectListItem>();

            OperationDA opDA = null;
            DataTable   dt   = new DataTable();

            try
            {
                opDA = new OperationDA();
                dt   = opDA.GetAllOperation();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow        dr   = dt.Rows[i];
                    SelectListItem item = new SelectListItem();
                    item.Text  = CommUtil.ConvertObjectToString(dr["Operation_desc"]);
                    item.Value = CommUtil.ConvertObjectToString(dr["Operation_code"]);
                    _operationList.Add(item);
                }
            }
            finally
            {
                if (opDA != null)
                {
                    opDA.CloseConnection();
                }
            }

            return(_operationList);
        }
示例#15
0
        public Int16 GetPicturePackCount(string idCard)
        {
            UserService userService = new UserService();
            User        u           = userService.GetByIdCard(idCard);
            string      path        = CommUtil.GetUserPic(u.User_PhotoLocation);

            return((Int16)GetPicturePackCount(path, ProtocolConstant.PIC_PACK_SIZE));
        }
示例#16
0
        public byte[] GetPictureData(string idCard, int packNum)
        {
            UserService userService = new UserService();
            User        u           = userService.GetByIdCard(idCard);
            string      path        = CommUtil.GetUserPic(u.User_PhotoLocation);

            return(GetPictureData(path, packNum, ProtocolConstant.PIC_PACK_SIZE));
        }
示例#17
0
        // 用户自主选择照片
        private void Select_Picture_Show(object sender, RoutedEventArgs e)
        {
            if (t3.Text == "" || IDCard.Text == "")
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("请填写完整信息", "Please fill in the complete information"));
                return;
            }

            using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog())
            {
                ofd.Title           = "请选择要插入的图片";
                ofd.Filter          = "JPG图片|*.jpg|BMP图片|*.bmp|Gif图片|*.gif";
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                ofd.Multiselect     = false;

                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    BitmapImage image = new BitmapImage(new Uri(ofd.FileName, UriKind.Absolute));//打开图片
                    var         win2  = new PhotoCutWindow(image)
                    {
                        Owner                 = Window.GetWindow(this),
                        ShowActivated         = true,
                        ShowInTaskbar         = false,
                        WindowStartupLocation = WindowStartupLocation.CenterScreen
                    };
                    win2.getName      = t3.Text;
                    win2.id           = IDCard.Text;
                    win2.oldPhotoName = oldPhotoName;
                    //如果是免冠照片
                    double p = image.Width / image.Height;//照片比例
                    if (p > 0.6 && p < 0.8)
                    {
                        PicZipUtil.GetPicThumbnail(ofd.FileName, CommUtil.GetUserPic() + win2.getPhotoName());
                    }
                    else
                    {
                        win2.ShowDialog();
                    }
                    photoName    = win2.photoName;
                    oldPhotoName = photoName;
                    //photograph.Close();
                    Console.WriteLine(photoName);
                    //在更新页面上展示用户 刚刚更新的照片
                    string photoUpdatePhoto = CommUtil.GetUserPic() + photoName;
                    if (File.Exists(photoUpdatePhoto))
                    {
                        //MessageBox.Show("hi open!");
                        BitmapImage i = new BitmapImage(new Uri(photoUpdatePhoto, UriKind.Absolute)); //打开图片
                        pic.Source = i.Clone();                                                       //将控件和图片绑定
                    }
                }
                else
                {
                    userIfSelectPic = false;
                }
            }
        }
示例#18
0
        public ResultModel Login(LoginViewModel model)
        {
            ResultModel result = new ResultModel();

            UserDA    userDA = null;
            DataTable dt     = new DataTable();

            try
            {
                userDA = new UserDA();
                dt     = userDA.GetUsers(model.UserID.Trim());

                if (dt == null)
                {
                    result.IsSuccess = false;
                    result.Exception = string.Format("User does not exist!");
                    return(result);
                }

                DataRow dr = dt.Rows[0];

                if (!string.Equals(dr["password"], GetSHA512Encrypt(model.Password)))
                {
                    result.IsSuccess = false;
                    result.Exception = string.Format("The Password is incorrect");
                    return(result);
                }

                if (!CommUtil.ConvertObjectToBool(dr["active"]))
                {
                    result.IsSuccess = false;
                    result.Exception = string.Format("User blocked, please contact your administrator!");
                    return(result);
                }

                // TODO: Add web service logic here

                UserName = dr["UserName"].ToString();
                UserID   = dr["UserID"].ToString();
                UserUID  = dr["UID"].ToString();
                //Operation = "EEGHK";//在未完成Operation模块时作为测试数据
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Exception = ex.Message;
            }
            finally
            {
                if (userDA != null)
                {
                    userDA.CloseConnection();
                }
            }

            return(result);
        }
示例#19
0
        public IEnumerable <MenuModel> GetMenu()
        {
            List <string> moduleList = new List <string>();

            List <MenuModel> menuList = new List <MenuModel>();
            ModuleDA         moduleDA = null;
            DataTable        dt       = new DataTable();

            try
            {
                moduleDA = new ModuleDA();
                dt       = moduleDA.GetMenuByUserID(UserUID, Operation);


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];

                    if ("".Equals(CommUtil.ConvertObjectToString(dr["ModuleCode"])) || moduleList.Contains(CommUtil.ConvertObjectToString(dr["ModuleCode"])))
                    {
                        continue;
                    }
                    else
                    {
                        moduleList.Add(CommUtil.ConvertObjectToString(dr["ModuleCode"]));
                    }

                    MenuModel mm = new MenuModel();
                    mm.ModuleCode       = CommUtil.ConvertObjectToString(dr["ModuleCode"]);
                    mm.ModuleName       = CommUtil.ConvertObjectToString(dr["ModuleName"]);
                    mm.ModuleController = CommUtil.ConvertObjectToString(dr["ModuleController"]);
                    mm.ModuleAction     = CommUtil.ConvertObjectToString(dr["ModuleAction"]);
                    mm.IsFatherNode     = CommUtil.ConvertObjectToBool(dr["IsFatherNode"]);
                    bool isSelect = false;
                    if (mm.IsFatherNode)
                    {
                        mm.SubMenu = GetSubMenu(mm.ModuleCode, 1, out isSelect);
                    }
                    else
                    {
                        isSelect = CheckMenuSelected(mm.ModuleController, mm.ModuleAction);
                    }

                    mm.IsSelect = isSelect;
                    menuList.Add(mm);
                }
            }
            finally
            {
                if (moduleDA != null)
                {
                    moduleDA.CloseConnection();
                }
            }

            return(menuList);
        }
示例#20
0
        //查询按钮,刷新加载图表
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //选择的次数
            int num      = CommUtil.ParseInt(comboxNum.Text);
            int deviceId = CommUtil.ParseInt(comboxDevice.SelectedValue.ToString());


            RefreshChart(userId, deviceId, num);
        }
示例#21
0
        //按钮:更新
        private void UserUpdata(object sender, RoutedEventArgs e)
        {
            // 切换用户图片的显示,解决线程占用问题
            BitmapImage bitmap = new BitmapImage(new Uri(@"\view\images\NoPhoto.png", UriKind.Relative));

            UserPhoto.Source = bitmap;

            //检查是否选中
            if ((User)UsersInfo.SelectedItem == null)
            //if (selectUser == null)//4.7 lzh
            {
                MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                // MessageBox.Show(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                return;
            }

            UserUpdata userUpdata = new UserUpdata
            {
                Owner                 = Window.GetWindow(this),
                ShowActivated         = true,
                ShowInTaskbar         = false,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            //类中使用
            User user = (User)UsersInfo.SelectedItem;

            userUpdata.SelectUser = user;
            //UI中使用
            userUpdata.selectUser.DataContext = user;
            //Console.WriteLine("123123:   " + user.User_Privateinfo);
            userUpdata.noPublicInfoText.Text = user.User_Privateinfo;
            //Console.WriteLine("123123aaaaa:   " + userUpdata.noPublicInfoText.Text);
            userUpdata.ShowDialog();

            //关闭后刷新界面
            users = userService.GetAllUsers();
            UsersInfo.ItemsSource = users;

            // 加载用户头像
            string photoUrl = CommUtil.GetUserPic() + selectUser.User_PhotoLocation;

            if (selectUser.User_PhotoLocation != null)
            {
                try
                {
                    BitmapImage b = new BitmapImage(new Uri(photoUrl, UriKind.Absolute)); //打开图片
                    UserPhoto.Source = b.Clone();                                         //将控件和图片绑定
                }
                catch (Exception ee)
                {
                }
            }
            //更新之后,刷新左下角
            Refresh_RecordFrame_Action();
        }
        /// <summary>
        /// 批量插入训练活动
        /// </summary>
        /// <param name="activities"></param>
        /// <returns></returns>
        public long BatchSaveActivity(List <ActivityEntity> activities)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                UploadManagementDAO uploadManagementDao2 = new UploadManagementDAO();
                long result = 0;
                //判断登陆用户,是教练自己锻炼。还是教练为用户进行设置。决定传哪个参数
                string currentMemberPK = CommUtil.GetSettingString("memberPrimarykey");
                string currentCoachId  = CommUtil.GetSettingString("coachId");
                if ((currentMemberPK == null || currentMemberPK == "") && (currentCoachId != null && currentCoachId != ""))
                {
                    //无用户登陆。教练单独登陆时对教练进行设置
                    foreach (var activity in activities)
                    {
                        activity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                        activity.Member_id             = CommUtil.GetSettingString("memberId");
                        activity.Fk_member_id          = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("coachId"));
                        activity.Fk_training_course_id = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("trainingCourseId"));
                        activity.Gmt_create            = System.DateTime.Now;
                        activity.Is_complete           = false;
                        activity.current_turn_number   = 0;
                        //插入至上传表
                        uploadManagementDao2.Insert(new UploadManagement(activity.Id, "bdl_activity", 0));
                    }
                    //批量插入训练活动
                    result = activityDAO.BatchInsert(activities);
                    //根据训练活动批量插入个人设置记录 传入教练的主键id
                    personalSettingService.SavePersonalSettings(ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("coachId")));
                }
                else
                {
                    //只要用户登录,为用户进行设置
                    foreach (var activity in activities)
                    {
                        activity.Id                    = KeyGenerator.GetNextKeyValueLong("bdl_activity");
                        activity.Member_id             = CommUtil.GetSettingString("memberId");
                        activity.Fk_member_id          = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("memberPrimarykey"));
                        activity.Fk_training_course_id = ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("trainingCourseId"));
                        activity.Gmt_create            = System.DateTime.Now;
                        activity.Is_complete           = false;
                        activity.current_turn_number   = 0;
                        //插入至上传表

                        uploadManagementDao2.Insert(new UploadManagement(activity.Id, "bdl_activity", 0));
                    }

                    //批量插入训练活动
                    result = activityDAO.BatchInsert(activities);
                    //根据训练活动批量插入个人设置记录 传入会员的主键id
                    personalSettingService.SavePersonalSettings(ParseIntegerUtil.ParseInt(CommUtil.GetSettingString("memberPrimarykey")));
                }

                ts.Complete();
                return(result);
            }
        }
示例#23
0
        /// <summary>
        /// 箭筒截图是否成功
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ImageDealer_OnOnCutImaging(object sender, RoutedEventArgs e)
        {
            var    ddd = (BitmapSource)e.OriginalSource;
            Bitmap bit = BitmapFromSource(ddd);

            //指定照片尺寸这么大
            var      bmcpy = new Bitmap(183, 256);
            Graphics gh    = Graphics.FromImage(bmcpy);

            gh.DrawImage(bit, new System.Drawing.Rectangle(0, 0, 183, 256));

            bmcpy.Save(CommUtil.GetUserPic() + photoName, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
示例#24
0
        /// <summary>
        /// Get all goup info
        /// </summary>
        /// <param name="groupID"></param>
        /// <param name="selectedGroupID"></param>
        /// <param name="selectedGroupName"></param>
        /// <returns></returns>
        private List <GroupM> GetAllGroup(string groupID, out string selectedGroupID, out string selectedGroupName)
        {
            selectedGroupID   = "";
            selectedGroupName = "";

            bool getGroupFisrstElement = false;

            if (groupID == null)
            {
                getGroupFisrstElement = true;
            }

            List <GroupM> groupList = new List <GroupM>();

            GroupDA   groupDA = null;
            DataTable dt      = new DataTable();

            try
            {
                groupDA = new GroupDA();
                dt      = groupDA.GetAllGroup(Operation);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr    = dt.Rows[i];
                    GroupM  group = new GroupM();
                    group.GroupID   = CommUtil.ConvertObjectToString(dr["GroupID"]);
                    group.GroupName = CommUtil.ConvertObjectToString(dr["GroupName"]);
                    groupList.Add(group);

                    if (i == 0 && getGroupFisrstElement)
                    {
                        selectedGroupID   = group.GroupID;
                        selectedGroupName = group.GroupName;
                    }

                    if (group.GroupID.Equals(groupID))
                    {
                        selectedGroupID   = group.GroupID;
                        selectedGroupName = group.GroupName;
                    }
                }
            }
            finally
            {
                if (groupDA != null)
                {
                    groupDA.CloseConnection();
                }
            }
            return(groupList);
        }
示例#25
0
 /// <summary>
 /// 备份
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BackUp(object sender, RoutedEventArgs e)
 {
     try
     {
         string DbUserName = ConfigUtil.GetEncrypt("DbUserName", "");
         string DbPassword = ConfigUtil.GetEncrypt("DbPassword", "");
         string DbUrl      = ConfigUtil.GetEncrypt("DbUrl", "");
         //指令
         string strAddress = string.Format("mysqldump -h{0} -u{1} -p{2} --default-character-set=utf8 --lock-tables --routines --force --quick ", DbUrl, DbUserName, DbPassword);
         //string strAddress = string.Format("mysqldump -h{0} -u{1} -p{2} --default-character-set=utf8 --lock-tables --routines --force --quick ", "127.0.0.1", "root", "53231323xjh");
         //数据库名称
         //string strDB = "bdl1";
         string strDB = ConfigUtil.GetEncrypt("DbName", "");
         //mysql的路径
         string mysqlPath = new SetterService().getPath() + @"\bin";
         //备份的路径(获取前端页面)
         //string filePath = System.AppDomain.CurrentDomain.BaseDirectory + @"\BackUp\";
         string filePath = textBox5.Text;
         if (!Directory.Exists(filePath))         //如果不存在就创建file文件夹                 
         {
             Directory.CreateDirectory(filePath); //创建该文件夹  
         }
         //判断是否含空格
         if (filePath.IndexOf(" ") != -1)
         {
             Console.WriteLine("保存路径中含空格");
             MessageBoxX.Warning(LanguageUtils.ConvertLanguage("备份路径不能含有空格", "Backup path cannot contain spaces"));
             return;
         }
         //执行的指令
         string cmd    = strAddress + strDB + " > " + filePath + "bdl.sql";
         string result = CommUtil.RunCmd(mysqlPath, cmd);
         //MessageBox.Show(result);
         //图片备份
         CommUtil.CopyDirectory(filePath);
         if (("mysqldump: [Warning] Using a password on the command line interface can be insecure.".Trim()).Contains(result.Trim()) ||
             ("Warning: Using a password on the command line interface can be insecure.".Trim()).Contains(result.Trim()))
         {
             MessageBoxX.Info(LanguageUtils.ConvertLanguage("数据备份成功", "Successful data backup"));
         }
         else
         {
             MessageBoxX.Error(LanguageUtils.ConvertLanguage("数据备份失败", " Data backup failed"));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("执行sql异常,备份异常" + ex.ToString());
     }
 }
示例#26
0
        /// <summary>
        /// 测试激活
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_16(object sender, RoutedEventArgs e)
        {
            SetterDAO setterDAO = new SetterDAO();

            //获取mac地址
            StringBuilder stringBuilder = new StringBuilder();
            //string strMac = CommUtil.GetMacAddress();
            // List<string> Macs = CommUtil.GetMacByWMI();
            List <string> Macs = CommUtil.GetMacByIPConfig();

            foreach (string mac in Macs)
            {
                string prefix = "物理地址. . . . . . . . . . . . . : ";
                string Mac    = mac.Substring(prefix.Length - 1);
                stringBuilder.Append(Mac);
            }
            //Console.WriteLine("==================="+stringBuilder.ToString());
            //MessageBox.Show("===================" + stringBuilder.ToString());
            entity.Setter setter = new entity.Setter();
            //mac地址先变为byte[]再aes加密
            byte[] byteMac = Encoding.GetEncoding("GBK").GetBytes(stringBuilder.ToString());
            byte[] AesMac  = AesUtil.Encrypt(byteMac, ProtocolConstant.USB_DOG_PASSWORD);
            //存入数据库
            //setter.Set_Unique_Id = Encoding.GetEncoding("GBK").GetString(AesMac);
            setter.Set_Unique_Id = ProtocolUtil.BytesToString(AesMac);

            /*AES解密
             * byte[] a = ProtocolUtil.StringToBcd(setter.Set_Unique_Id);
             * byte[] b = AesUtil.Decrypt(a, ProtocolConstant.USB_DOG_PASSWORD);
             * Console.WriteLine(Encoding.GetEncoding("GBK").GetString(b));*/
            //默认照片路径,激活时获取(路径中不要有汉字)
            string basePath = System.AppDomain.CurrentDomain.BaseDirectory;
            string path     = ConfigurationManager.AppSettings["PicPath"];

            setter.Set_PhotoLocation = basePath + path;
            setter.Set_Language      = 1;
            setter.Pk_Set_Id         = 1;
            //设置版本号
            setter.Set_Version = CommUtil.GetCurrentVersion();
            if (!Directory.Exists(@setter.Set_PhotoLocation))
            {
                Directory.CreateDirectory(@setter.Set_PhotoLocation);//不存在就创建目录
            }

            /*if (Directory.Exists(@setter.Set_PhotoLocation)) {  //存在就删除
             *  Directory.Delete(@setter.Set_PhotoLocation, true);
             *  Directory.CreateDirectory(@setter.Set_PhotoLocation);
             * }*/
            setterDAO.InsertOneMacAdress(setter);
        }
示例#27
0
        //private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
        //{
        //    e.Row.Header = e.Row.GetIndex() + 1;
        //}



        /// <summary>
        /// 选中使用者信息时触发,将详细信息展示在左下角
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_Click(object sender, MouseButtonEventArgs e)
        {
            ifSelecUser = true;
            if (UsersInfo.SelectedIndex == -1)
            {
                id.Content = null;
            }
            else
            {
                id.Content = UsersInfo.SelectedIndex + 1;//使用者详细信息展示框id设置
            }
            selectUser = (User)UsersInfo.SelectedItem;

            //UserInfo
            UserInfo.DataContext = selectUser;
            string path = null;

            // 选中用户的时候初始化
            is_signinformationrecord.Focus();

            //选中用户时展示 症状 训练 体力的记录框的frame
            //Radio_Check_Action();
            // 给frame加入数据
            Refresh_RecordFrame_Action();

            if (selectUser != null && selectUser.User_IDCard != null && selectUser.User_Namepinyin != null && selectUser.User_IDCard != "" && selectUser.User_Namepinyin != "")
            {
                path  = CommUtil.GetUserPic();
                path += selectUser.User_PhotoLocation;
            }
            else
            {
                return;
            }

            //看照片是否存在
            if (!File.Exists(path))
            {
                BitmapImage bitmap = new BitmapImage(new Uri(@"\view\images\NoPhoto.png", UriKind.Relative));

                UserPhoto.Source = bitmap;

                return;
            }
            else
            {
                UserPhoto.Source = new BitmapImage(new Uri(path)).Clone();
            }
        }
示例#28
0
 /// <summary>
 /// 作用:经过初步测试,第一次Excel转pdf相对较慢,所以在进入程序的时候,执行一次Excel转PDF
 /// </summary>
 public void InitializationExcelToPdf()
 {
     try
     {
         using (Workbook workbook = new Workbook())
         {
             workbook.LoadFromFile(CommUtil.GetDocPath("test1.xlsx"));
             workbook.SaveToFile(CommUtil.GetDocPath("test1.pdf"), Spire.Xls.FileFormat.PDF);
         }
     }
     catch (Exception e)
     {
         initializationExcelToPdfThread.Abort();
     }
 }
示例#29
0
        public byte[] GetPictureData(string idCard)
        {
            UserService userService = new UserService();
            User        u           = userService.GetByIdCard(idCard);
            string      path        = CommUtil.GetUserPic(u.User_PhotoLocation);

            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                byte[] byteData = new byte[fs.Length];
                fs.Read(byteData, 0, byteData.Length);


                return(byteData);
            }
        }
示例#30
0
        /// <summary>
        /// 点击裁剪按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //创建文件夹
            CreateDir(CommUtil.GetUserPic());
            ImageDealer.CutImage();

            /*
             * string newFileName = photoName.Replace(".jpg", ".gif");
             *
             * if (PicZipUtil.GetPicThumbnail(CommUtil.GetUserPic() + photoName, CommUtil.GetUserPic() + newFileName, 50))
             * {
             *
             *  photoName = newFileName;
             * }*/
            this.Close();
        }