예제 #1
0
        public void OnCellDoubleClick(object sender, RadRoutedEventArgs e)
        {
            SMSRecord obj = gv.SelectedItem as SMSRecord;

            if (obj != null)
            {
                if (obj.GradeType.IsSupervise)
                {
                    SupervisionForm form = new SupervisionForm(obj);
                    form.SaveCallBack = getData;
                    form.IsEnabled    = false;


                    Tools.OpenWindow("督查情况", form, null, 400, 290);
                }
                else
                {
                    SMSRecordForm form = new SMSRecordForm(obj);
                    form.SaveCallBack = getData;
                    form.IsEnabled    = false;


                    Tools.OpenWindow("群众办事登记", form, null, 600, 400);
                }
            }
        }
예제 #2
0
 public ActionResult Wx_SendSms(string mobile)
 {
     if (Regex.IsMatch(mobile, "1[3|5|7|8|][0-9]{9}"))
     {
         string    validateCode = CommonUtilities.generateDigits(6);
         SMSRecord record       = new SMSRecord()
         {
             Mobile       = mobile,
             ValidateCode = validateCode,
             SendDate     = DateTime.Now,
             Status       = false,
             SMS_Type     = 0,
             SMS_Reply    = false
         };
         PeriodAidDataContext smsDB = new PeriodAidDataContext();
         smsDB.SMSRecord.Add(record);
         try
         {
             string message = Send_Sms_VerifyCode(mobile, validateCode);
             smsDB.SaveChanges();
             return(Content(message));
         }
         catch (Exception)
         {
             return(Content("Failure"));
         }
     }
     else
     {
         return(Content("手机号码错误"));
     }
 }
예제 #3
0
 public SMSRecordForm()
 {
     InitializeComponent();
     Loaded     += new RoutedEventHandler(SMSRecordForm_Loaded);
     smsRecord   = new SMSRecord();
     DataContext = smsRecord;
 }
예제 #4
0
 public SupervisionForm()
 {
     InitializeComponent();
     Loaded     += new RoutedEventHandler(SupervisionForm_Loaded);
     smsRecord   = new SMSRecord();
     DataContext = smsRecord;
     count.Value = 1;
 }
예제 #5
0
파일: SMSService.cs 프로젝트: VinasTT/ltb
        public virtual void InsertSMSRecord(SMSRecord smsRecord)
        {
            if (smsRecord == null)
            {
                throw new ArgumentNullException("SMSRecord");
            }

            _SMSRepository.Insert(smsRecord);
        }
예제 #6
0
파일: SMSService.cs 프로젝트: VinasTT/ltb
        public virtual void UpdateSMSRecord(SMSRecord smsRecord)
        {
            if (smsRecord == null)
            {
                throw new ArgumentNullException("SMSRecord");
            }

            _SMSRepository.Update(smsRecord);
        }
예제 #7
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            SMSRecord obj = gv.SelectedItem as SMSRecord;

            if (obj != null)
            {
                SMSRecordForm frm = new SMSRecordForm(obj);
                frm.SaveCallBack = getData;
                Tools.OpenWindow("群众办事登记-编辑", frm, null, 600, 400);
            }
        }
예제 #8
0
        private void edit()
        {
            SMSRecord obj = gv.SelectedItem as SMSRecord;

            if (obj != null)
            {
                SupervisionForm form = new SupervisionForm(obj);
                form.SaveCallBack = getData;

                Tools.OpenWindow("督查情况", form, null, 400, 320);
            }
        }
예제 #9
0
        /// <summary>
        /// 保存或修改
        /// 保存的工作每个业务对象都不相同,有可能重写,请注意!
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public virtual string SaveOrUpdate(string json)
        {
            using (ISession sess = HbmSessionFactory.OpenSession())
            {
                ITransaction tx = null;

                SMSRecord entity = JsonSerializerHelper.JsonToEntity <SMSRecord>(json);
                if (entity.Id == 0)
                {
                    //判断重复录入
                    string hql = string.Format(" from SMSRecord as r where convert(varchar(50),CreatTime,112) = '{0}' and PersonName = '{1}' and WorkType.Id = {2} "
                                               , DateTime.Now.ToString("yyyyMMdd"), entity.PersonName, entity.WorkType.Id);
                    var existList = sess.CreateQuery(hql).List <SMSRecord>();
                    if (existList != null && existList.Count > 0)
                    {
                        return(PackJsonResult("false", "0", "此案件已经录入!"));
                    }

                    if (string.IsNullOrEmpty(entity.PersonMobile))
                    {
                        entity.PersonMobile = defaultMobile;
                    }

                    entity.WorkDate  = DateTime.Now;
                    entity.YearMonth = (DateTime.Now.Year * 100 + DateTime.Now.Month).ToString();
                }

                try
                {
                    tx = sess.BeginTransaction();

                    sess.SaveOrUpdate(entity);
                    tx.Commit();
                    //有点sb了,凑合补救一下
                    //正确的做法是定义个包含Id的interface,所有要持久化的类都实现这个interface
                    dynamic d = entity;
                    return(PackJsonResult("true", d.Id.ToString(), string.Empty));
                }
                catch (Exception ex)
                {
                    if (tx != null && tx.IsActive)
                    {
                        tx.Rollback();
                    }

                    return(PackJsonResult("false", "0", ex.Message));
                }
            }
        }
예제 #10
0
        /// <summary>
        /// 通过id获得一个实体对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual string GetById(int id)
        {
            using (ISession sess = HbmSessionFactory.OpenSession())
            {
                try
                {
                    SMSRecord entity = sess.Get <SMSRecord>(id);

                    string s = JsonSerializerHelper.EntityToJson(entity);

                    return(PackJsonResult("true", s, string.Empty));
                }
                catch (Exception ex)
                {
                    return(PackJsonResult("false", string.Empty, ex.Message));
                }
            }
        }
예제 #11
0
        public virtual string GetByHql(string hql)
        {
            using (ISession sess = HbmSessionFactory.OpenSession())
            {
                try
                {
                    SMSRecord entity = sess.CreateQuery(hql).UniqueResult <SMSRecord>();

                    string s = JsonSerializerHelper.EntityToJson(entity);

                    return(PackJsonResult("true", s, string.Empty));
                }
                catch (Exception ex)
                {
                    return(PackJsonResult("true", string.Empty, ex.Message));
                }
            }
        }
예제 #12
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            SMSRecord obj = gv.SelectedItem as SMSRecord;

            if (obj != null)
            {
                Tools.OpenConfirm(string.Format("是否要删除?"),
                                  new EventHandler <Telerik.Windows.Controls.WindowClosedEventArgs>
                                  (
                                      (c, args) =>
                {
                    if (args.DialogResult == true)
                    {
                        ser.DeleteByIdAsync(obj.Id);
                    }
                }
                                  ));
            }
        }
예제 #13
0
 public SupervisionForm(SMSRecord editObj)
 {
     InitializeComponent();
     isEdit           = true;
     smsRecord        = editObj;
     count.Value      = 1;
     count.IsReadOnly = true;
     date.IsEnabled   = false;
     Loaded          += new RoutedEventHandler(SupervisionForm_Loaded);
     SMSRecordService.SMSRecordServiceClient ser = new SMSRecordService.SMSRecordServiceClient();
     ser.GetByIdCompleted +=
         (object sender, SMSRecordService.GetByIdCompletedEventArgs e) =>
     {
         SMSRecord obj = JsonSerializerHelper.JsonToEntity <SMSRecord>(e.Result);
         this.smsRecord = obj;
         DataContext    = smsRecord;
     };
     ser.GetByIdAsync(editObj.Id);
 }
예제 #14
0
 /// <summary>
 /// 通过id删除一个实体对象
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public virtual string DeleteById(int id)
 {
     using (ISession sess = HbmSessionFactory.OpenSession())
     {
         ITransaction tx = sess.BeginTransaction();
         try
         {
             SMSRecord entity = sess.Load <SMSRecord>(id);
             sess.Delete(entity);
             tx.Commit();
             return(PackJsonResult("true", "true", string.Empty));
         }
         catch (Exception ex)
         {
             tx.Rollback();
             return(PackJsonResult("false", "false", ex.Message));
         }
     }
 }
        /// <summary>
        /// 新增一条质检记录
        /// </summary>
        /// <param name="qcRecord">质检实体</param>
        /// <returns></returns>
        public static bool InsertOneQCRecord(SMSRecord qcRecord)
        {
            bool rbool = true;

            using (DCQUALITYDataContext db = new DCQUALITYDataContext())
            {
                try
                {
                    db.SMSRecord.InsertOnSubmit(qcRecord);
                    db.SubmitChanges();
                    rbool = true;
                }
                catch
                {
                    rbool = false;
                }
                finally { db.Connection.Close(); }
            }
            return(rbool);
        }
예제 #16
0
 public SMSRecordForm(SMSRecord editObj)
 {
     InitializeComponent();
     isEdit       = true;
     this.editObj = editObj;
     smsRecord    = editObj;
     Loaded      += new RoutedEventHandler(SMSRecordForm_Loaded);
     SMSRecordService.SMSRecordServiceClient ser = new SMSRecordService.SMSRecordServiceClient();
     ser.GetByIdCompleted +=
         (object sender, SMSRecordService.GetByIdCompletedEventArgs e) =>
     {
         SMSRecord obj = JsonSerializerHelper.JsonToEntity <SMSRecord>(e.Result);
         this.smsRecord          = obj;
         DataContext             = smsRecord;
         chkIsResponse.IsChecked = smsRecord.IsResponse;
     };
     this.IsEnabled = AppGlobal.HasPermission();
     //查询一次,避免在form更改了数据点击取消后原list界面数据更改(界面双向绑定,但没有提交到数据库)
     ser.GetByIdAsync(editObj.Id);
 }
예제 #17
0
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="record"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public async Task UpdateStatus(SMSRecord record, int status)
        {
            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, false, false, _dbConnectionFactory.CreateSMSRecordAllForSMS(), async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }
                await using (SqlCommand command = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                })
                {
                    SqlParameter parameter;

                    command.CommandText = @"Update [dbo].[SMSRecord]
                                                set [status] = @status
                                                   ,[modifytime] = GETUTCDATE()
                                            where [id] = @id ";

                    parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier)
                    {
                        Value = record.ID
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@status", SqlDbType.Int)
                    {
                        Value = record.Status
                    };
                    command.Parameters.Add(parameter);

                    await command.PrepareAsync();

                    await command.ExecuteNonQueryAsync();
                }
            });
        }
예제 #18
0
        private void edit()
        {
            SMSRecord obj = gv.SelectedItem as SMSRecord;

            if (obj != null)
            {
                if (obj.GradeType.IsSupervise)
                {
                    SupervisionForm form = new SupervisionForm(obj);
                    form.SaveCallBack = getData;

                    Tools.OpenWindow("督查情况", form, null, 400, 320);
                }
                else
                {
                    SMSRecordForm form = new SMSRecordForm(obj);
                    form.SaveCallBack = getData;

                    Tools.OpenWindow("群众办事登记", form, null, 600, 400);
                }
            }
        }
예제 #19
0
        public virtual string SaveList(string json, int cnt)
        {
            using (var sess = HbmSessionFactory.OpenStatelessSession())
            {
                try
                {
                    SMSRecord entity = JsonSerializerHelper.JsonToEntity <SMSRecord>(json);
                    if (entity.WorkDate == null)
                    {
                        entity.WorkDate = DateTime.Now;
                    }
                    entity.YearMonth = (entity.WorkDate.Value.Year * 100 + entity.WorkDate.Value.Month).ToString();
                    DataTable table = new DataTable();
                    table.Columns.Add(new DataColumn("Id"));
                    table.Columns.Add(new DataColumn("YearMonth"));
                    table.Columns.Add(new DataColumn("Name"));
                    table.Columns.Add(new DataColumn("CreateTime"));
                    table.Columns.Add(new DataColumn("TelPhone"));
                    table.Columns.Add(new DataColumn("Address"));
                    table.Columns.Add(new DataColumn("PersonIdCard"));
                    table.Columns.Add(new DataColumn("Sex"));
                    table.Columns.Add(new DataColumn("WorkTypeId"));
                    table.Columns.Add(new DataColumn("WorkDetail"));
                    table.Columns.Add(new DataColumn("PoliceManId"));
                    table.Columns.Add(new DataColumn("ValuationId"));
                    table.Columns.Add(new DataColumn("IsValuation"));
                    table.Columns.Add(new DataColumn("UnitId"));
                    table.Columns.Add(new DataColumn("Valuation"));
                    table.Columns.Add(new DataColumn("IsSend"));
                    table.Columns.Add(new DataColumn("Receiver"));
                    table.Columns.Add(new DataColumn("Number"));
                    table.Columns.Add(new DataColumn("WorkOfficerId"));
                    table.Columns.Add(new DataColumn("LeaderId"));

                    for (int i = 0; i < cnt; i++)
                    {
                        DataRow row = table.NewRow();
                        row[0]  = 0;
                        row[1]  = entity.YearMonth;
                        row[3]  = entity.WorkDate;
                        row[4]  = entity.PersonMobile;
                        row[8]  = entity.WorkType.Id;
                        row[10] = entity.LoginOfficer.Id;
                        row[11] = entity.GradeType.Id;
                        row[12] = entity.IsResponse;
                        row[13] = entity.Organization.Id;
                        row[15] = entity.IsSend;
                        row[18] = entity.WorkOfficer.Id;
                        row[19] = entity.Leader.Id;
                        table.Rows.Add(row);
                    }

                    //只有sql server才能使用
                    if (!(sess.Connection is SqlConnection))
                    {
                        throw new Exception("目前只支持sql server数据库!");
                    }
                    insertBulkTable(sess.Connection as SqlConnection, "SMS_Work", table);
                    return(PackJsonResult("true", "0", string.Empty));
                }
                catch (Exception ex)
                {
                    return(PackJsonResult("false", "0", ex.Message));
                }
            }
        }
예제 #20
0
        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        public async Task Add(SMSRecord record)
        {
            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, false, false, _dbConnectionFactory.CreateSMSRecordAllForSMS(), async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }
                await using (SqlCommand command = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                })
                {
                    SqlParameter parameter;
                    if (record.ID == Guid.Empty)
                    {
                        command.CommandText = @"
                                                INSERT INTO [dbo].[SMSRecord]
                                                     (
		                                                [id]
                                                      ,[phonenumbers]
                                                      ,[content]
                                                      ,[sendendpointname]
                                                      ,[extensioninfo]
                                                      ,[statusdescription]
                                                      ,[status]
                                                      ,[createtime]
                                                      ,[modifytime]
                                                     )
                                                VALUES
                                                    (default
                                                    , @phonenumbers
                                                    , @content
                                                    , @sendendpointname
                                                    , @extensioninfo
                                                    , @statusdescription
                                                    , @status
                                                    , GETUTCDATE()
                                                    , GETUTCDATE());
                                                select @newid =[id] from [dbo].[SMSRecord] where [sequence] = SCOPE_IDENTITY()";
                        parameter           = new SqlParameter("@newid", SqlDbType.UniqueIdentifier)
                        {
                            Direction = ParameterDirection.Output
                        };
                        command.Parameters.Add(parameter);
                    }
                    else
                    {
                        command.CommandText = @"
                                                INSERT INTO [dbo].[SMSRecord]
                                                     (
		                                                [id]
                                                      ,[phonenumbers]
                                                      ,[content]
                                                      ,[sendendpointname]
                                                      ,[extensioninfo]
                                                      ,[statusdescription]
                                                      ,[status]
                                                      ,[createtime]
                                                      ,[modifytime]
                                                     )
                                                VALUES
                                                    (@id
                                                    , @phonenumbers
                                                    , @content
                                                    , @sendendpointname
                                                    , @extensioninfo
                                                    , @statusdescription
                                                    , @status
                                                    , GETUTCDATE()
                                                    , GETUTCDATE())";

                        parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier)
                        {
                            Value = record.ID
                        };
                        command.Parameters.Add(parameter);
                    }
                    parameter = new SqlParameter("@phonenumbers", SqlDbType.NVarChar, 4000)
                    {
                        Value = record.PhoneNumbers
                    };
                    command.Parameters.Add(parameter);
                    parameter = new SqlParameter("@content", SqlDbType.NVarChar, 4000)
                    {
                        Value = record.Content
                    };
                    command.Parameters.Add(parameter);
                    parameter = new SqlParameter("@sendendpointname", SqlDbType.NVarChar, 500)
                    {
                        Value = record.SendEndpointName
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@extensioninfo", SqlDbType.NVarChar, 4000)
                    {
                        Value = record.ExtensionInfo
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@statusdescription", SqlDbType.NVarChar, 4000)
                    {
                        Value = record.StatusDescription
                    };
                    command.Parameters.Add(parameter);

                    parameter = new SqlParameter("@status", SqlDbType.Int)
                    {
                        Value = record.Status
                    };
                    command.Parameters.Add(parameter);

                    await command.PrepareAsync();

                    await command.ExecuteNonQueryAsync();

                    //如果用户未赋值ID则创建成功后返回ID
                    if (record.ID == Guid.Empty)
                    {
                        record.ID = (Guid)command.Parameters["@newid"].Value;
                    }
                    ;
                }
            });
        }