Пример #1
0
 private void CreateStoredProcedure(string path, LibDataAccess dataAccess)
 {
     if (Directory.Exists(path))
     {
         string   extendName = dataAccess.DatabaseType == LibDatabaseType.Oracle ? "*.prc" : "*.sql";
         string[] files      = Directory.GetFiles(path, extendName, SearchOption.AllDirectories);
         if (files != null)
         {
             foreach (string item in files)
             {
                 string sql = string.Empty;
                 using (FileStream fs = new FileStream(item, FileMode.Open))
                 {
                     using (TextReader reader = new StreamReader(fs))
                     {
                         sql = reader.ReadToEnd();
                     }
                 }
                 string name = Path.GetFileNameWithoutExtension(item);
                 if (dataAccess.DatabaseType == LibDatabaseType.SqlServer)
                 {
                     dataAccess.ExecuteNonQuery(string.Format("IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID({0}) AND type in (N'P', N'PC')) DROP PROCEDURE {1} ", LibStringBuilder.GetQuotString(name), name));
                     dataAccess.ExecuteNonQuery(string.Format("IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID({0}) AND type in (N'V')) DROP VIEW {1} ", LibStringBuilder.GetQuotString(name), name));
                 }
                 if (!string.IsNullOrEmpty(sql))
                 {
                     dataAccess.ExecuteNonQuery(sql, false);
                 }
             }
         }
     }
 }
Пример #2
0
 /// <summary>
 /// 添加同步信息到同步信息记录表中
 /// </summary>
 /// <param name="syncInfo"></param>
 /// <returns></returns>
 public static bool AddSyncDataRecord(SyncDataInfo syncInfo)
 {
     try
     {
         if (syncInfo == null ||
             string.IsNullOrEmpty(syncInfo.ProgId) ||
             string.IsNullOrEmpty(syncInfo.InternalId) ||
             string.IsNullOrEmpty(syncInfo.UserId))
         {
             return(false);
         }
         string sql = string.Format("insert into AXPSYNCDATAHISTORY(INFOID,PROGID,INTERNALID,BILLNO,USERID,SITEID,SYNCTIME,SYNCOP,SYNCSTATE,SYNCINFO) "
                                    + "values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9})",
                                    LibStringBuilder.GetQuotString(Guid.NewGuid().ToString()),
                                    LibStringBuilder.GetQuotString(syncInfo.ProgId),
                                    LibStringBuilder.GetQuotString(syncInfo.InternalId),
                                    LibStringBuilder.GetQuotString(syncInfo.BillNo),
                                    LibStringBuilder.GetQuotString(syncInfo.UserId),
                                    LibStringBuilder.GetQuotString(syncInfo.SiteId),
                                    LibDateUtils.DateTimeToLibDateTime(syncInfo.SyncTime),
                                    (int)syncInfo.SyncOp,
                                    (int)syncInfo.SyncState,
                                    LibStringBuilder.GetQuotString(syncInfo.SyncInfo)
                                    );
         LibDataAccess dataAccess = new LibDataAccess();
         int           count      = dataAccess.ExecuteNonQuery(sql);
         return(count > 0);
     }
     catch (Exception exp)
     {
         LibCommUtils.AddOutput("CrossSiteCall", string.Format("error:{0}\r\nStacktrace:{1}", exp.Message, exp.StackTrace));
         return(false);
     }
 }
Пример #3
0
        public static Result FeedbackMsg(string userId, string handle, FeedbackModel info)
        {
            Result res = new Result();

            res.ReturnValue = true;
            LibHandle Handle = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, userId);

            VerificationHandle(userId, handle, Handle, res);
            if (res.ReturnValue)
            {
                LibDataAccess access = new LibDataAccess();
                try
                {
                    string sql = string.Empty;
                    if (!string.IsNullOrEmpty(Handle.PersonId))//待优化
                    {
                        sql = string.Format("Insert into AXPFEEDBACKMSG(GUID, USERID, MESSAGETYPE, MESSAGE) VALUES({0}, {1}, {2}, {3})", LibStringBuilder.GetQuotString(Guid.NewGuid().ToString()), LibStringBuilder.GetQuotString(userId), info.MessageType, LibStringBuilder.GetQuotString(info.Message));
                        access.ExecuteNonQuery(sql);
                        res.ReturnValue = true;
                    }
                    else
                    {
                        res.Message     = "请重新登录!";
                        res.ReturnValue = false;
                    }
                }
                catch (Exception ex)
                {
                    res.ReturnValue = false;
                    res.Message     = "失败!" + ex.Message;
                }
            }
            return(res);
        }
Пример #4
0
        public SetPwdResult SetPassword(string handle, string oldPwd, string newPwd)
        {
            SetPwdResult result    = new SetPwdResult();
            LibHandle    libHandle = LibHandleCache.Default.GetCurrentHandle(handle) as LibHandle;

            if (libHandle == null)
            {
                throw new Exception("用户句柄无效。");
            }
            string sql = string.Format("select USERID from AXPUSER where USERID={0} and USERPASSWORD={1}",
                                       LibStringBuilder.GetQuotString(libHandle.UserId), LibStringBuilder.GetQuotString(oldPwd));
            LibDataAccess dataAccess = new LibDataAccess();
            string        userId     = LibSysUtils.ToString(dataAccess.ExecuteScalar(sql));

            if (string.IsNullOrEmpty(userId))
            {
                result.Msg     = "输入的旧密码与系统不匹配。";
                result.Success = false;
            }
            else
            {
                dataAccess.ExecuteNonQuery(string.Format("update AXPUSER set USERPASSWORD={2} where USERID={0} and USERPASSWORD={1}",
                                                         LibStringBuilder.GetQuotString(libHandle.UserId), LibStringBuilder.GetQuotString(oldPwd),
                                                         LibStringBuilder.GetQuotString(newPwd)));
                result.Success = true;
            }
            return(result);
        }
Пример #5
0
        public string MoveAttach(LibAttachData attachData)
        {
            LibDataAccess dataAccess = new LibDataAccess();
            List <string> listSql    = new List <string>();

            //更新结构
            UpdateAttachStruct(attachData, listSql);
            //更新附件记录明细
            listSql.Add(string.Format("insert into AXPATTACHMENTRECORDDETAIL(BELONGTOID,ORDERID,FILENAME,PERSONID,CREATETIME) values('{0}',{1},'{2}','{3}',{4})",
                                      attachData.AttachSrc, attachData.OrderId, attachData.FileName, attachData.PersonId, LibDateUtils.GetCurrentDateTime()));

            LibDBTransaction trans = dataAccess.BeginTransaction();

            try
            {
                dataAccess.ExecuteNonQuery(listSql);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }

            string path = Path.Combine(EnvProvider.Default.MainPath, "AxFile", "Attachment", attachData.ProgId, attachData.AttachSrc);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string orgFilePath = Path.Combine(EnvProvider.Default.MainPath, "AxFile", "Attachment", attachData.FileName);

            File.Move(orgFilePath, Path.Combine(path, attachData.FileName));
            return(attachData.AttachSrc);
        }
Пример #6
0
        public void RemoveAttach(string attachSrc, int orderId, string personId)
        {
            LibDataAccess dataAccess = new LibDataAccess();

            dataAccess.ExecuteNonQuery(string.Format("insert into AXPATTACHMENTRECORDDETAIL(BELONGTOID,ORDERID,FILENAME,PERSONID,CREATETIME) values('{0}',{1},'{2}','{3}',{4})",
                                                     attachSrc, orderId, string.Empty, personId, LibDateUtils.GetCurrentDateTime()));
        }
Пример #7
0
        /// <summary>
        /// 登录成功后删除验证码
        /// </summary>
        /// <param name="userId"></param>
        private static void DeleteCode(string userId)
        {
            string        sql    = string.Format("DELETE FROM AXPVERIFYCODE WHERE USERID={0}", LibStringBuilder.GetQuotString(userId));
            LibDataAccess access = new LibDataAccess();

            access.ExecuteNonQuery(sql);
        }
Пример #8
0
        private void InitData()
        {
            //授权规格
            LibDataAccess dataAccess = new LibDataAccess();
            decimal       count      = LibSysUtils.ToDecimal((dataAccess.ExecuteScalar("select count(*) from AXPPURCHASESPEC")));

            if (count == 0)
            {
                dataAccess.ExecuteNonQuery("insert into AXPPURCHASESPEC(PURCHASERID,PURCHASERNAME,MAXUSERCOUNT,MAXWORKSTATIONCOUNT) values('ax','ax',1000,-1)");
            }
            bool        existsINTERNALID = false;
            LibSqlModel sqlModel         = LibSqlModelCache.Default.GetSqlModel("axp.User");

            if (sqlModel != null && sqlModel.Tables.Count > 0 && sqlModel.Tables[0].Columns.Contains("INTERNALID"))
            {
                existsINTERNALID = true;
            }
            string userId = LibSysUtils.ToString(dataAccess.ExecuteScalar("select USERID from AXPUSER where USERID='admin'"));

            if (string.IsNullOrEmpty(userId))
            {
                //考虑默认账户 使用admin
                if (existsINTERNALID == false)
                {
                    dataAccess.ExecuteNonQuery("insert into AXPUSER(USERID,USERPASSWORD,ISUSE) values('admin','admin',1)");
                }
                else
                {
                    //如果AXPUser不再是Grid数据,则会有内码字段
                    dataAccess.ExecuteNonQuery("insert into AXPUSER(USERID,USERPASSWORD,ISUSE,INTERNALID,CREATORID,CURRENTSTATE) values('admin','admin',1,'" + Guid.NewGuid().ToString() + "','(NotSet)',2)");
                }
            }
            if (existsINTERNALID)
            {
                // 升级时如果发现系统账户(axp.User)的数据表存在内码字段(即类型已修改为主数据),则需要修改所有内码为空的账户信息,为其生成新的Guid
                if (dataAccess.DatabaseType == LibDatabaseType.SqlServer)
                {
                    dataAccess.ExecuteNonQuery("update AXPUSER set INTERNALID = NEWID(),CURRENTSTATE = 2 where INTERNALID=''");
                }
                else if (dataAccess.DatabaseType == LibDatabaseType.Oracle)
                {
                    dataAccess.ExecuteNonQuery("update AXPUSER set INTERNALID = sys_guid(),CURRENTSTATE = 2 where INTERNALID=''");
                }
            }
        }
Пример #9
0
        public void SetWallpaper(string handle, string wallpaper, bool stretch)
        {
            LibHandle libHandle = LibHandleCache.Default.GetCurrentHandle(handle) as LibHandle;

            if (libHandle == null)
            {
                throw new Exception("用户句柄无效。");
            }
            LibDataAccess dataAccess = new LibDataAccess();

            dataAccess.ExecuteNonQuery(string.Format("update AXPUSER set WALLPAPER={0},WALLPAPERSTRETCH={1} where USERID={2}", LibStringBuilder.GetQuotString(wallpaper), stretch ? 1 : 0, LibStringBuilder.GetQuotString(libHandle.UserId)));
        }
Пример #10
0
        public void RemoveUserPicture(string progId, string internalId, string fileName)
        {
            string path = Path.Combine(EnvProvider.Default.RuningPath, "UserPicture", progId, internalId, fileName);

            if (File.Exists(path))
            {
                File.Delete(path);
                LibDataAccess dataAccess = new LibDataAccess();
                LibSqlModel   model      = LibSqlModelCache.Default.GetSqlModel(progId);
                dataAccess.ExecuteNonQuery(string.Format("update {0} set IMGSRC='' where INTERNALID={1}", model.Tables[0].TableName,
                                                         LibStringBuilder.GetQuotString(internalId)), false);
            }
        }
Пример #11
0
        public string Register(RegisterInfo info)
        {
            string        error      = string.Empty;
            LibDataAccess dataAccess = new LibDataAccess();
            string        userId     = LibSysUtils.ToString(dataAccess.ExecuteScalar(string.Format("select USERID from AXPUSER where USERID={0}",
                                                                                                   LibStringBuilder.GetQuotString(info.inputId))));

            if (string.IsNullOrEmpty(userId))
            {
                string personId = LibSysUtils.ToString(dataAccess.ExecuteScalar(string.Format("select PERSONID from COMPERSON where PERSONNAME={0} and DEPTID={1}",
                                                                                              LibStringBuilder.GetQuotString(info.inputName), LibStringBuilder.GetQuotString(info.inputDept))));
                //如果遇到同部门同名的情况。建议客户手动创建人员主数据。
                if (string.IsNullOrEmpty(personId))
                {
                    LibBcfData bcfData   = (LibBcfData)LibBcfSystem.Default.GetBcfInstance("com.Person");
                    DataSet    dataSet   = bcfData.AddNew(null);
                    DataRow    masterRow = dataSet.Tables[0].Rows[0];
                    masterRow.BeginEdit();
                    try
                    {
                        if (string.IsNullOrEmpty(LibSysUtils.ToString(masterRow["PERSONID"])))
                        {
                            masterRow["PERSONID"] = personId = LibCommUtils.GetInternalId().ToString();
                        }
                        masterRow["PERSONNAME"] = info.inputName;
                        masterRow["GENDER"]     = info.gender;
                        masterRow["DEPTID"]     = info.inputDept;
                        masterRow["MAIL"]       = info.inputEmail;
                        masterRow["PHONENO"]    = info.inputPhone;
                    }
                    finally
                    {
                        masterRow.EndEdit();
                    }
                    dataSet  = bcfData.InnerSave(BillAction.AddNew, new object[] { personId }, dataSet);
                    personId = LibSysUtils.ToString(dataSet.Tables[0].Rows[0]["PERSONID"]);
                }
                if (!string.IsNullOrEmpty(personId))
                {
                    string sql = string.Format("insert into AXPUSER(USERID,USERPASSWORD,PERSONID,ISUSE) values({0},{1},{2},0)",
                                               LibStringBuilder.GetQuotString(info.inputId), LibStringBuilder.GetQuotString(info.inputPassword1),
                                               LibStringBuilder.GetQuotString(personId));
                    dataAccess.ExecuteNonQuery(sql);
                }
            }
            else
            {
                error = "账号已注册";
            }
            return(error);
        }
Пример #12
0
        private static Result SetComPersonInfo(string personId, string value, SetPersonInfoState state)
        {
            Result res        = new Result();
            string columnName = string.Empty;

            switch (state)
            {
            case SetPersonInfoState.phoneNo:
                columnName = "PHONENO";
                break;

            case SetPersonInfoState.Cornet:
                columnName = "CORNET";
                break;

            case SetPersonInfoState.PersonName:
                columnName = "PERSONNAME";
                break;

            case SetPersonInfoState.Email:
                columnName = "MAIL";
                break;
            }
            try
            {
                string        sql        = string.Format("UPDATE COMPERSON SET {0}={1} WHERE PERSONID={2}", columnName, LibStringBuilder.GetQuotString(value), LibStringBuilder.GetQuotString(personId));
                LibDataAccess dataAccess = new LibDataAccess();
                int           count      = -1;
                count = dataAccess.ExecuteNonQuery(sql);
                if (count > 0)
                {
                    res.ReturnValue = true;
                }
                else
                {
                    res.ReturnValue = false;
                    res.Message     = "设置失败!";
                }
            }
            catch (Exception ex)
            {
                res.ReturnValue = false;
                res.Message     = ex.Message;
            }

            return(res);
        }
Пример #13
0
        public static Result GenerateCode(string userId, string phoneNo)
        {
            Result res = new Result();

            try
            {
                // 生成四位数的验证码
                Random r    = new Random();
                int    i    = (int)(r.NextDouble() * 10000);
                string code = i.ToString().PadLeft(4, '0');


                // 查看是否存在该帐号对应的验证码
                LibDataAccess access = new LibDataAccess();
                string        sql    = string.Format("SELECT count(*) FROM AXPVERIFYCODE WHERE USERID = {0}", LibStringBuilder.GetQuotString(userId));
                int           count  = LibSysUtils.ToInt32(access.ExecuteScalar(sql));


                // 生成或者更新验证码
                if (count == 0)
                {
                    sql = string.Format("INSERT INTO AXPVERIFYCODE(USERID, VERIFYCODE, TIME) VALUES({0}, {1}, {2})", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(code), LibDateUtils.GetCurrentDateTime());
                }
                else if (count == 1)
                {
                    sql = string.Format("UPDATE AXPVERIFYCODE SET VERIFYCODE={0}, TIME={1} WHERE USERID={2}", LibStringBuilder.GetQuotString(code), LibDateUtils.GetCurrentDateTime(), LibStringBuilder.GetQuotString(userId));
                }
                access.ExecuteNonQuery(sql);


                // 发送短信
                SendSMSParam sendSMSParam = new SendSMSParam();
                sendSMSParam.Message = "验证码为:" + code;
                sendSMSParam.PhoneList.Add(phoneNo);
                LibSMSHelper.SendMsg(sendSMSParam);


                res.ReturnValue = true;
                res.Message     = "成功!";
            }
            catch (Exception ex)
            {
                res.ReturnValue = false;
                res.Message     = "失败!" + ex.Message;
            }
            return(res);
        }
Пример #14
0
        public string RecoverPassword(string userId)
        {
            string error = string.Empty;

            if (string.Compare(userId, "admin", true) == 0)
            {
                error = "账户admin不允许重置密码";
                return(error);
            }
            LibDataAccess dataAccess = new LibDataAccess();
            string        id = string.Empty, personId = string.Empty, email = string.Empty;

            using (IDataReader reader = dataAccess.ExecuteDataReader(string.Format("select A.USERID,A.PERSONID,B.MAIL from AXPUSER A inner join COMPERSON B on B.PERSONID=A.PERSONID where A.USERID={0}",
                                                                                   LibStringBuilder.GetQuotString(userId))))
            {
                if (reader.Read())
                {
                    id       = LibSysUtils.ToString(reader[0]);
                    personId = LibSysUtils.ToString(reader[1]);
                    email    = LibSysUtils.ToString(reader[2]);
                }
            }
            if (string.IsNullOrEmpty(id))
            {
                error = "该账号未注册";
            }
            else if (string.IsNullOrEmpty(email))
            {
                error = "该账号未关联邮箱,请联系管理员";
            }
            else
            {
                Random random = new Random();
                string pw     = string.Format("{0}{1}", userId, random.Next(1000, 9999));
                dataAccess.ExecuteNonQuery(string.Format("update AXPUSER set USERPASSWORD={0} where USERID={1}", LibStringBuilder.GetQuotString(pw), LibStringBuilder.GetQuotString(userId)));
                List <AxCRL.Core.Mail.LibMailParam> list  = new List <AxCRL.Core.Mail.LibMailParam>();
                AxCRL.Core.Mail.LibMailParam        param = new AxCRL.Core.Mail.LibMailParam();
                param.Content  = string.Format("您的账号 {0} 密码已重置。新密码为{1}", userId, pw);
                param.MailKind = AxCRL.Core.Mail.LibMailKind.Info;
                param.Subject  = "智慧工厂账号密码重置";
                param.To.Add(LibSysUtils.ToString(personId));
                list.Add(param);
                ThreadPool.QueueUserWorkItem(LibMailHelper.SendMail, list);
            }
            return(error);
        }
Пример #15
0
        private static void SaveSysNews(LibDataAccess dataAccess, string title, string mainContent, string personId, string execTaskDataId, List <string> userList)
        {
            List <string> sqlList = new List <string>();

            foreach (string userId in userList)
            {
                if (string.IsNullOrEmpty(userId))
                {
                    continue;
                }
                string newsId = Guid.NewGuid().ToString();
                sqlList.Add(string.Format("Insert into AXPUSERNEWS(NEWSID,USERID,TITLE,MAINCONTENT,INFOID,CREATETIME,PERSONID,ISREAD) values({0},{1},{2},{3},{4},{5},{6},0)",
                                          LibStringBuilder.GetQuotString(newsId), LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(title),
                                          LibStringBuilder.GetQuotString(mainContent), LibStringBuilder.GetQuotString(execTaskDataId), LibDateUtils.GetCurrentDateTime(), LibStringBuilder.GetQuotString(personId)));
            }
            dataAccess.ExecuteNonQuery(sqlList);
        }
Пример #16
0
        /// <summary>
        /// 更新目录下的文档数量
        /// </summary>
        /// <param name="dirId"></param>
        public static void UpdateDocCountOfDir(string dirId, LibDataAccess dataAccess)
        {
            if (string.IsNullOrEmpty(dirId) || dataAccess == null)
            {
                return;
            }
            string sql = "Update DMDIRECTORY set DOCCOUNT = (select count(*) from DMDOCUMENT B where B.DIRID = '" + dirId + "') where DIRID= '" + dirId + "' ";

            try
            {
                dataAccess.ExecuteNonQuery(sql);
            }
            catch (Exception exp)
            {
                DMCommonMethod.WriteLog("DmDirectoryBcf.UpdateDocCountOfDir", string.Format("DirId:{0},\r\nError:{1}", dirId, exp.ToString()));
            }
        }
Пример #17
0
        public static Result PictureUpload(pictureUploadModel model)
        {
            Result res = new Result();

            try
            {
                //var result = "";
                //将byte数组转为base64String
                //string base64String = "/9j/4AAQSkZJRgABAQEAkACQAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAACQAAAAAQAAAJAAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAHKgAwAEAAAAAQAAAHIAAAAA/9sAQwAfFRcbFxMfGxkbIyEfJS9OMi8rKy9fREg4TnBjdnRuY21rfIyyl3yEqYZrbZvTnam4vsjKyHiV2+rZwumyxMjA/9sAQwEhIyMvKS9bMjJbwIBtgMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA/8AAEQgAcgByAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A6GiiigAooqF5scL+dAEpIHU4phmQepquSWOSc0UwJvPH939aPP8A9n9ahooAsCZT1yKeCG6HNVKASDkHFAFyioEm7N+dTAgjIpALRRRQAUUUUAFFFQzv/CPxoAbLJuOB0/nUdFFMAoopyIXPH50ANoqTES9SWPtR+6b1WgCOinPGU56j1ptABTo5Ch9vSm0UAWwQRkdKWq8L4O09DVikAUUUUAIx2qT6VUJycmp5zhQPWoKYBRRRQAdalkOxQi/jUaffX606b/WGgBlFFFAEkTZ+RuhpjDaxHpQn31+tOm/1hoAZRRRQAVajbcgPeqtS255I/GgCeiiikBBcfeA9qiqS4++PpUdMAooooAKlceYoZeo6ioqkjRh82do96AI6KmZoieRk+1N3xr91Mn3oAI12je3QdKjJyST3pXcueaSgAooooAKfD/rBTKfD/rBQBZooopAQ3A6GoasyruQiq1MAoopVG5gPWgB6KFXe34CmO5c5NOmPzbR0FMoAKKKKACpNoePKjkdRUdOiba49+KAG0U6RdrkU2gAqSAfOT6Co6sQLhM+tAElFFFIAqtKm1vY1ZprqHXBoAq06MhXBPSkZSpwaSmArHLE+ppKKKACiiigAooooAfKwZsj0plFABJwOtADkXe2KtdKZGmxffvT6QBRRRQAUUUUANdA4waruhQ89PWrVFAFOip2hU9OKYYXHTBpgR0U7Y/8AdNJsb+6fyoASiniFz2xUiwAfeOaAIVUscAVYjjCD1PrTgABgDFLSAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/2Q==";
                string base64String = model.PersonPicture;

                //将base64String 转为 byte数组
                byte[] byteArray    = Convert.FromBase64String(base64String);
                string saveFileName = DateTime.Now.ToFileTime().ToString() + '.' + model.FileExtension;
                //string saveFileName = DateTime.Now.ToFileTime().ToString() + ".jpg";
                string dirPath = Path.Combine(EnvProvider.Default.RuningPath, "PersonPicture");
                string path    = Path.Combine(dirPath, saveFileName);
                //使用文件流读取byte数组中的数据
                Stream saveStream = new FileStream(path, FileMode.Append);
                saveStream.Write(byteArray, 0, byteArray.Length);
                saveStream.Close();
                string        httpPath   = "http://" + EnvProvider.Default.VisualHostName + ':' + EnvProvider.Default.CurrentPort + '/' + "PersonPicture" + '/' + saveFileName;
                string        sql        = string.Format("UPDATE COMPERSON SET HEADPORTRAIT = {0} WHERE PERSONID = {1}", LibStringBuilder.GetQuotString(httpPath), LibStringBuilder.GetQuotString(model.PrisonId));
                LibDataAccess dataAccess = new LibDataAccess();
                int           count      = -1;
                count = LibSysUtils.ToInt32(dataAccess.ExecuteNonQuery(sql));
                if (count < 0)
                {
                    res.ReturnValue = false;
                    res.Message     = "请求错误";
                }
                else
                {
                    res.ReturnValue = true;
                    res.Info        = httpPath;
                }
            }
            catch (Exception ex)
            {
                res.ReturnValue = false;
                res.Message     = ex.Message;
            }

            return(res);
        }
Пример #18
0
        /// <summary>
        /// 删除索引
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <returns></returns>
        public bool DeleteIndex(AbstractFileBase fileInfo)
        {
            try
            {
                IndexWriter writer = new IndexWriter(FSDirectory.Open(new System.IO.DirectoryInfo(IndexDic)), PanGuAnalyzer, IndexWriter.MaxFieldLength.LIMITED);
                writer.DeleteDocuments(new Term("fileId", fileInfo.FileId));
                //这两句一定要执行
                writer.Optimize();
                writer.Close();

                LibDataAccess dataAccess = new LibDataAccess();
                dataAccess.ExecuteNonQuery(string.Format("update DMDOCUMENT set ISFULLINDEX = 0 where DOCID = {0}", LibStringBuilder.GetQuotString(fileInfo.FileId)));
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #19
0
        /// <summary>
        /// 全文索引创建结果的处理
        /// </summary>
        /// <param name="docId"></param>
        /// <param name="modifyVerId">修订版标识号</param>
        /// <param name="isSuccess"></param>
        public static void DealFullIndexResult(string docId, int modifyVerId, bool isSuccess)
        {
            try
            {
                LibDataAccess    dataAccess = new LibDataAccess();
                LibDBTransaction trans      = dataAccess.BeginTransaction();
                try
                {
                    string sql = "";
                    if (dataAccess.DatabaseType == LibDatabaseType.SqlServer)
                    {
                        sql = string.Format(
                            " update a                        " +
                            " set a.ISFULLINDEX = {2}         " +
                            " from DMDOCUMENT a               " +
                            " where a.DOCID = '{0}' and (select max(DOCMODIFYID) from DMDOCMODIFYHISTORY where DOCID = '{0}') = {1}",//修订号与最新修订号相同才设置索引结果
                            docId, modifyVerId, isSuccess ? 1 : 0);
                    }
                    else
                    {
                        //Oracle To do
                    }

                    if (string.IsNullOrEmpty(sql) == false)
                    {
                        dataAccess.ExecuteNonQuery(sql);
                    }
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
            }
            catch (Exception exp)
            {
                //发生异常时记录日志
                DMCommonMethod.WriteLog("DealFullIndexResult", string.Format("DocId:{0}\r\nIsSuccess{1}\r\nnError:{2}",
                                                                             docId, isSuccess, exp.ToString()));
            }
        }
Пример #20
0
        public static Result SavePictureCalidateCode(string userId, string code)
        {
            Result        result     = new Result();
            LibDataAccess dataAccess = new LibDataAccess();
            string        sql        = string.Format("SELECT count(*) FROM AXPVERIFYCODE WHERE USERID = {0}", LibStringBuilder.GetQuotString(userId));
            int           count      = LibSysUtils.ToInt32(dataAccess.ExecuteScalar(sql));


            // 生成或者更新验证码
            if (count == 0)
            {
                sql = string.Format("INSERT INTO AXPVERIFYCODE(USERID, VERIFYCODE, TIME) VALUES({0}, {1}, {2})", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(code), LibDateUtils.GetCurrentDateTime());
            }
            else if (count == 1)
            {
                sql = string.Format("UPDATE AXPVERIFYCODE SET VERIFYCODE={0}, TIME={1} WHERE USERID={2}", LibStringBuilder.GetQuotString(code), LibDateUtils.GetCurrentDateTime(), LibStringBuilder.GetQuotString(userId));
            }
            dataAccess.ExecuteNonQuery(sql);
            return(result);
        }
Пример #21
0
        public void AddTask(LibBusinessTask task, bool needAddDB = false)
        {
            int curDate = LibDateUtils.GetCurrentDate();

            if (string.IsNullOrEmpty(task.ProgId) || string.IsNullOrEmpty(task.BusinessTaskId))
            {
                return;
            }
            //如果指定的日期大于当前日期,无需执行
            if (task.TaskType == LibTaskType.None && task.ExecDate != 0 && task.ExecDate > curDate)
            {
                return;
            }
            //未指定有效执行日期则跳过
            if (task.ExecDate == 0 && task.RepeatDateMark == 0)
            {
                return;
            }
            //无设置执行时间点则跳过
            if (task.IntervalTime == 0 && task.ExecTime.Count == 0)
            {
                return;
            }
            //初始化Timer
            LibTaskParam param = new LibTaskParam(task);
            string       key   = Guid.NewGuid().ToString();

            param.Task = new LibTask(new Timer(ExecBusinessTask, param, param.GetTaskDueTime(), Timeout.InfiniteTimeSpan));
            TaskList.TryAdd(key, param.Task);
            TaskMap.TryAdd(task.TaskId, key);
            if (task.TaskType == LibTaskType.TempTask && needAddDB)
            {
                LibDataAccess dataAccess = new LibDataAccess();
                dataAccess.ExecuteNonQuery(string.Format("insert into AXPBUSINESSTEMPTASK(TASKID,PROGID,BUSINESSTASKID,EXECDATE,EXECTIME,EXECCONDITION,INTERNALID) values({0},{1},{2},{3},{4},{5},{6})",
                                                         LibStringBuilder.GetQuotString(task.TaskId), LibStringBuilder.GetQuotString(task.ProgId), LibStringBuilder.GetQuotString(task.BusinessTaskId), task.ExecDate, task.ExecTime[0],
                                                         LibStringBuilder.GetQuotString(task.ExecCondition), LibStringBuilder.GetQuotString(task.InternalId)), false);
            }
        }
Пример #22
0
        /// <summary>
        /// 将同步数据的配置更新到数据库
        /// </summary>
        /// <param name="dt"></param>
        public static void UpdateSyncDataSetting(DataTable dt)
        {
            if (dt == null || ExistAxpSyncDataInfo == false || ExistLinkSiteTable == false)
            {
                return;
            }
            List <string> sqlList = new List <string>();
            string        setting = string.Empty;

            foreach (DataRow row in dt.Rows)
            {
                setting = LibSysUtils.ToString(row["SETTINGID"]);
                if (string.IsNullOrEmpty(setting))
                {
                    continue;
                }
                sqlList.Add(string.Format("update AXPSYNCDATASETTING set ISSYNCTO = {0} where SETTINGID = {1}",
                                          LibSysUtils.ToBoolean(row["ISSYNCTO"]) ? 1 : 0, LibStringBuilder.GetQuotString(setting)));
            }
            LibDataAccess dataAccess = new LibDataAccess();

            dataAccess.ExecuteNonQuery(sqlList);
        }
Пример #23
0
 /// <summary>
 /// 根据信息唯一标识InfoId更新数据同步的历史结果
 /// </summary>
 /// <param name="syncInfo"></param>
 /// <returns></returns>
 public static bool UpdateSyncDataRecord(SyncDataInfo syncInfo)
 {
     try
     {
         if (syncInfo == null || string.IsNullOrEmpty(syncInfo.InfoId))
         {
             return(false);
         }
         string sql = string.Format("update AXPSYNCDATAHISTORY set SYNCSTATE={0},SYNCINFO={1} where INFOID={2}",
                                    (int)syncInfo.SyncState,
                                    LibStringBuilder.GetQuotString(syncInfo.SyncInfo),
                                    LibStringBuilder.GetQuotString(syncInfo.InfoId)
                                    );
         LibDataAccess dataAccess = new LibDataAccess();
         int           count      = dataAccess.ExecuteNonQuery(sql);
         return(count > 0);
     }
     catch (Exception exp)
     {
         LibCommUtils.AddOutput("CrossSiteCall", string.Format("error:{0}\r\nStacktrace:{1}", exp.Message, exp.StackTrace));
         return(false);
     }
 }
Пример #24
0
        /// <summary>
        /// 创建索引
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <returns></returns>
        public bool CreateIndex(AbstractFileBase fileInfo)
        {
            try
            {
                IndexWriter writer = new IndexWriter(FSDirectory.Open(new System.IO.DirectoryInfo(IndexDic)), PanGuAnalyzer, IndexWriter.MaxFieldLength.LIMITED);

                //FileStream fs = File.OpenRead(Path.Combine(fileInfo.FilePath, fileInfo.FileName));

                //1.创建Document对象
                Document doc = new Document();

                //2.给doc对象添加Field
                doc.Add(new Field("fileId", fileInfo.FileId, Field.Store.YES, Field.Index.NOT_ANALYZED));
                //doc.Add(new Field("fileName", fileInfo.FileName, Field.Store.YES, Field.Index.ANALYZED));
                //doc.Add(new Field("filePath", fileInfo.FilePath, Field.Store.YES, Field.Index.ANALYZED));
                //doc.Add(new Field("createTime", fileInfo.CreateTime, Field.Store.YES, Field.Index.ANALYZED));
                //doc.Add(new Field("upLoadPersonId", fileInfo.UpLoadPersonId, Field.Store.YES, Field.Index.ANALYZED));
                //doc.Add(new Field("content", new StreamReader(fs, Encoding.UTF8)));
                doc.Add(new Field("content", fileInfo.Content, Field.Store.YES, Field.Index.ANALYZED));

                //将doc对象写入索引文件
                writer.AddDocument(doc);

                writer.Optimize();
                writer.Commit();
                writer.Close();

                //修改数据库的
                LibDataAccess dataAccess = new LibDataAccess();
                dataAccess.ExecuteNonQuery(string.Format("update DMDOCUMENT set ISFULLINDEX = 1 where DOCID = {0}", LibStringBuilder.GetQuotString(fileInfo.FileId)));
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #25
0
        public string SaveAttachStruct(LibAttachData attachData)
        {
            if (attachData.AttachList.Count == 0)
            {
                return(string.Empty);
            }
            LibDataAccess dataAccess = new LibDataAccess();
            List <string> listSql    = new List <string>();

            UpdateAttachStruct(attachData, listSql);
            LibDBTransaction trans = dataAccess.BeginTransaction();

            try
            {
                dataAccess.ExecuteNonQuery(listSql);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            return(attachData.AttachSrc);
        }
Пример #26
0
        public string MoveUserPicture(string progId, string internalId, string fileName)
        {
            string path = Path.Combine(EnvProvider.Default.RuningPath, "UserPicture", progId, internalId);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string        orgFilePath = Path.Combine(EnvProvider.Default.RuningPath, "UserPicture", fileName);
            DirectoryInfo info        = new DirectoryInfo(path);

            FileInfo[] files = info.GetFiles();
            foreach (var item in files)
            {
                item.Delete();
            }
            File.Move(orgFilePath, Path.Combine(path, fileName));
            LibDataAccess dataAccess = new LibDataAccess();
            LibSqlModel   model      = LibSqlModelCache.Default.GetSqlModel(progId);

            dataAccess.ExecuteNonQuery(string.Format("update {0} set IMGSRC={1} where INTERNALID={2}", model.Tables[0].TableName,
                                                     LibStringBuilder.GetQuotString(fileName), LibStringBuilder.GetQuotString(internalId)));
            return(fileName);
        }
Пример #27
0
        public void SystemUpgrade1()
        {
            LibSqlModelCache.Default.RemoveAll();//升级数据库时需要将SqlModel的缓存清空

            //重新生成ProgId

            #region 1.	从实体文件夹中获取dll文件,转到程序集,构建实体列表
            Dictionary <string, Assembly> assemblyDic = new Dictionary <string, Assembly>();
            ProgIdConfigListingManager.BuildListing(EnvProvider.Default.MainPath, EnvProvider.Default.ExtendPath, assemblyDic);
            #endregion

            //在本地构建SqlModel文件,升级数据库表、创建单据存储过程
            ProgIdHost.Instance.Run();
            List <string> updateBusinessTaskList = new List <string>()
            {
                "DELETE FROM AXPBUSINESSTASK"
            };
            foreach (var item in ProgIdHost.Instance.ProgIdRef)
            {
                BcfServerInfo info = item.Value;
                if (!assemblyDic.ContainsKey(info.DllName))
                {
                    continue;
                }
                Assembly assembly = assemblyDic[info.DllName];
                Type     destType = assembly.GetType(info.ClassName);
                if (destType == null)
                {
                    continue;
                }
                try
                {
                    LibBcfBase destObj = destType.InvokeMember(null, BindingFlags.CreateInstance, null, null, null) as LibBcfBase;
                    if (destObj != null)
                    {
                        SaveSqlModel(item.Key, destObj.DataSet);
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception(string.Format("UpdateError(SaveSqlModel):\r\n{0}  {1}  {2}  {3}。", item.Key, item.Value.ClassName, item.Value.DllName, exp.ToString()));
                }
            }
            ILibDbSchema    schemaHelper = null;
            LibDataAccess   dataAccess   = new LibDataAccess();
            LibDatabaseType databaseType = dataAccess.DatabaseType;
            if (LibDatabaseType.Oracle == databaseType)
            {
                schemaHelper = new LibOracleDbSchema();
            }
            else
            {
                schemaHelper = new LibSqlServerDbSchema();
            }
            List <string> updateFunList = new List <string>()
            {
                "DELETE FROM AXPFUNCLIST"
            };
            List <string> updateFunButtonList = new List <string>()
            {
                "DELETE FROM AXPFUNCBUTTON"
            };
            List <string> updateBrowseStoreProcedureList = new List <string>();
            foreach (var item in ProgIdHost.Instance.ProgIdRef)
            {
                BcfServerInfo info = item.Value;
                if (!assemblyDic.ContainsKey(info.DllName))
                {
                    continue;
                }
                Assembly assembly = assemblyDic[info.DllName];
                try
                {
                    Type       destType = assembly.GetType(info.ClassName);
                    LibBcfBase destObj  = destType.InvokeMember(null, BindingFlags.CreateInstance, null, null, null) as LibBcfBase;
                    if (destObj != null)
                    {
                        LibFuncPermission funcPermission = destObj.Template.FuncPermission;
                        updateFunList.Add(GetSqlForFunList(destObj.ProgId, destObj.Template.DisplayText, funcPermission.ConfigPack, funcPermission.CanMenu, funcPermission.KeyCode, funcPermission.Permission, destObj.Template.BillType, LibSysUtils.ToString(funcPermission.ProgTag)));
                        //Dictionary<string, string> dic = destObj.Template.GetViewTemplate(destObj.DataSet).Layout.GetButtonList();
                        //if (dic != null)
                        //{
                        //    foreach (var button in dic)
                        //    {
                        //        updateFunButtonList.Add(string.Format("insert into AXPFUNCBUTTON(PROGID,BUTTONID,BUTTONNAME) values('{0}','{1}','{2}')", destObj.ProgId, button.Key, button.Value));
                        //    }
                        //}

                        if (!destType.IsSubclassOf(typeof(LibBcfData)) && !destType.IsSubclassOf(typeof(LibBcfGrid)))
                        {
                            continue;
                        }
                        schemaHelper.DicUniqueDataSql = destObj.GetUniqueDataSqlForUpdate(dataAccess.DatabaseType);//添加对于唯一性字段数据的提前处理Sql
                        schemaHelper.UpdateTables(destObj.DataSet, false);
                        //schemaHelper.CreateTables(destObj.DataSet);
                        SqlBuilder sqlBuilder = new SqlBuilder(item.Key);
                        string     sql;
                        if (LibDatabaseType.Oracle == databaseType)
                        {
                            sql = sqlBuilder.BuildBrowseStoreProcedureByOracle(destObj.Template.BillType);
                        }
                        else
                        {
                            sql = sqlBuilder.BuildBrowseStoreProcedure(destObj.Template.BillType);
                        }
                        if (!string.IsNullOrEmpty(sql))
                        {
                            string name = destObj.Template.ProgId.Replace('.', '_');
                            if (LibDatabaseType.SqlServer == databaseType)
                            {
                                updateBrowseStoreProcedureList.Add(string.Format("IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID({0}) AND type in (N'P', N'PC')) DROP PROCEDURE {1}", LibStringBuilder.GetQuotString(name), name));
                            }
                            updateBrowseStoreProcedureList.Add(sql);
                        }
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception(string.Format("UpdateError(UpdateTable):\r\n{0}  {1}  {2}  {3}\r\n。", item.Key, item.Value.ClassName, item.Value.DllName, exp.ToString()));
                }
            }

            //创建浏览存储过程
            foreach (string sql in updateBrowseStoreProcedureList)
            {
                try
                {
                    dataAccess.ExecuteNonQuery(sql, false);
                }
                catch (Exception exp)
                {
                    throw new Exception(string.Format("UpdateError(updateBrowseStoreProcedureList):\r\n{0} \r\n{1}。", sql, exp.ToString()));
                }
            }

            //更新功能清单
            dataAccess.ExecuteNonQuery(updateFunList, false);
            //dataAccess.ExecuteNonQuery(updateFunButtonList, false);
            //更新业务任务表
            //dataAccess.ExecuteNonQuery(updateBusinessTaskList, false);
            //创建存储过程
            //CreateStoredProcedure(Path.Combine(EnvProvider.Default.MainPath, "StoredProcedure"), dataAccess);
            //CreateStoredProcedure(Path.Combine(EnvProvider.Default.ExtendPath, "StoredProcedure"), dataAccess);
            //this.InitData();
        }
Пример #28
0
        public LoginInfo AppLogin(string userId, string password, string clientId, int clientType, bool quitOther = false)
        {
            LoginInfo loginInfo = new LoginInfo();
            //检查是否具有 AXPUSERAPP数据表,用于判定是否支持移动端App登录
            LibSqlModel sqlModel      = LibSqlModelCache.Default.GetSqlModel("axp.User");
            bool        hasAXPUSERAPP = false;

            if (sqlModel != null && sqlModel.Tables.Count > 1 && sqlModel.Tables[1].TableName.Equals("AXPUSERAPP"))
            {
                hasAXPUSERAPP = true;
            }
            if (hasAXPUSERAPP == false)
            {
                return(loginInfo);//如果没有需要的相关字段则直接返回
            }

            SqlBuilder builder = new SqlBuilder("axp.User");
            string     sql     = string.Format(@"SELECT 
                                        A.PERSONID,
                                        A.ROLEID,
                                        A.WALLPAPER,A.WALLPAPERSTRETCH,B.PERSONNAME,B.PHONENO,B.CORNET,B.HEADPORTRAIT,B.MAIL   
                                        FROM AXPUSER A LEFT JOIN COMPERSON B ON B.PERSONID=A.PERSONID   
                                        WHERE A.USERID={0} and A.USERPASSWORD={1} AND A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(password));
            //builder.GetQuerySql(0, "A.PERSONID,A.PERSONNAME,A.PHONENO,A.CORNET,A.HEADPORTRAIT,A.MAIL,A.ROLEID,A.WALLPAPER,A.WALLPAPERSTRETCH", string.Format("A.USERID={0} And A.USERPASSWORD={1} And A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(password)));
            LibDataAccess dataAccess = new LibDataAccess();
            string        roleId     = string.Empty;
            bool          exists     = false;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    loginInfo.PersonId   = LibSysUtils.ToString(reader["PERSONID"]);
                    loginInfo.PersonName = LibSysUtils.ToString(reader["PERSONNAME"]);
                    roleId = LibSysUtils.ToString(reader["ROLEID"]);
                    loginInfo.Wallpaper = LibSysUtils.ToString(reader["WALLPAPER"]);
                    loginInfo.Stretch   = LibSysUtils.ToBoolean(reader["WALLPAPERSTRETCH"]);
                    //20170214 施卢威 增加头像 Email 短号信息
                    loginInfo.Headportrait = LibSysUtils.ToString(reader["HEADPORTRAIT"]);
                    loginInfo.UserEMail    = LibSysUtils.ToString(reader["MAIL"]);
                    loginInfo.Cornet       = LibSysUtils.ToString(reader["CORNET"]);
                    loginInfo.UserPhone    = LibSysUtils.ToString(reader["PHONENO"]);
                    exists = true;
                }
            }
            if (exists)
            {
                #region 帐号与登录设备关联
                string appSql = string.Empty;
                //查询帐号是否已有设备标识
                int isAPPClient = LibSysUtils.ToInt32(dataAccess.ExecuteScalar(string.Format("SELECT COUNT(*) from AXPUSERAPP WHERE USERID = '{0}' and CLIENTTYPE={1}", userId, clientType)));
                if (isAPPClient > 0)
                {
                    //更新设备标识信息
                    appSql = string.Format("UPDATE AXPUSERAPP SET  CLIENTID={1}    WHERE USERID={0} AND CLIENTTYPE={2}", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(clientId), clientType);
                }
                else
                {
                    int curMaxRowId = LibSysUtils.ToInt32(dataAccess.ExecuteScalar(string.Format("SELECT Max(ROW_ID) from AXPUSERAPP WHERE USERID='{0}'", userId)));
                    //插入账户对应的App设备标识信息。
                    appSql = string.Format("insert into AXPUSERAPP(USERID,ROW_ID,ROWNO,CLIENTTYPE,CLIENTID) values('{0}',{1},{2},{3},'{4}')",
                                           userId, curMaxRowId + 1, curMaxRowId + 1, clientType, clientId, 1);
                }
                dataAccess.ExecuteNonQuery(appSql);

                #endregion

                LibHandle handle = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, userId);
                if (handle != null)
                {
                    if (quitOther)
                    {
                        LibHandleCache.Default.RemoveHandle(handle.Handle);
                    }
                    else
                    {
                        loginInfo.IsUsed = true;
                    }
                }
                if (!loginInfo.IsUsed)
                {
                    long currentCount = LibHandleCache.Default.GetCount();
                    long maxUserCount = (long)LibHandleCache.Default.MaxUserCount;
                    if (maxUserCount != -1 && maxUserCount < currentCount)
                    {
                        loginInfo.IsOverUser = true;
                    }
                    else
                    {
                        string loginIp = string.Empty;
                        //Zhangkj20161219 增加LoginIp
                        System.ServiceModel.OperationContext context = System.ServiceModel.OperationContext.Current;
                        //对于非WCF的访问context为null
                        if (context != null)
                        {
                            System.ServiceModel.Channels.MessageProperties             properties = context.IncomingMessageProperties;
                            System.ServiceModel.Channels.RemoteEndpointMessageProperty endpoint   = properties[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
                            loginIp = endpoint.Address + ":" + endpoint.Port.ToString();
                            handle  = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, userId, loginInfo.PersonId, loginInfo.PersonName, roleId, loginIp);
                        }
                        else
                        {
                            handle = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, userId, loginInfo.PersonId, loginInfo.PersonName, roleId);
                        }
                        //创建新的Handle

                        if (handle != null)
                        {
                            loginInfo.Handle = handle.Handle;
                        }
                    }
                }
            }
            return(loginInfo);
        }
Пример #29
0
        private void ExecBusinessTask(object obj)
        {
            LibTaskParam    param      = (LibTaskParam)obj;
            LibBusinessTask taskDefine = param.TaskDefine;

            //系统当天是否可以执行
            if (IsExecOfDay(taskDefine))
            {
                try
                {
                    param.Task.TaskState = TaskRunState.Running;
                    LibBcfBase bcf = LibBcfSystem.Default.GetBcfInstance(taskDefine.ProgId);
                    bcf.Handle = LibHandleCache.Default.GetSystemHandle();
                    Type     type      = bcf.GetType();
                    object[] destParam = RestoreParamFormat(type, taskDefine.BusinessTaskId, new string[] { taskDefine.ExecCondition });
                    object   result    = bcf.GetType().InvokeMember(taskDefine.BusinessTaskId, BindingFlags.InvokeMethod, null, bcf, destParam);
                    switch (bcf.Template.BillType)
                    {
                    case AxCRL.Template.BillType.Master:
                    case AxCRL.Template.BillType.Bill:
                        break;

                    case AxCRL.Template.BillType.Grid:
                        break;

                    case AxCRL.Template.BillType.DataFunc:
                        break;

                    case AxCRL.Template.BillType.Rpt:
                    case AxCRL.Template.BillType.DailyRpt:
                        DataSet dataSet = result as DataSet;
                        if (dataSet != null)
                        {
                            LibSysNews news = new LibSysNews();
                            news.Content  = taskDefine.MainContent;
                            news.Data     = LibBillDataSerializeHelper.Serialize(dataSet);
                            news.PersonId = "SYSTEM";
                            news.ProgId   = taskDefine.ProgId;
                            news.Title    = taskDefine.Title;
                            foreach (LibBusinessTaskLiaison item in taskDefine.Liaison)
                            {
                                news.UserList.Add(item.UserId);
                            }
                            LibSysNewsHelper.SendNews(news, false);
                        }
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    //将错误输出
                    string path = System.IO.Path.Combine(AxCRL.Comm.Runtime.EnvProvider.Default.MainPath, "Output", "Error", "ScheduleTask", string.Format("{0}.txt", DateTime.Now.Ticks));
                    OutputInfo(path, ex.ToString());
                }
                finally
                {
                    param.Task.TaskState = TaskRunState.Wait;
                }
            }
            bool canNextExec = true;

            if (taskDefine.ExecDate != 0)
            {
                int curDate = LibDateUtils.GetCurrentDate();
                if (taskDefine.ExecDate > curDate)
                {
                    param.Task.Timer.Dispose();
                    canNextExec          = false;
                    param.Task.TaskState = TaskRunState.Stop;
                }
                else if (taskDefine.ExecDate == curDate && taskDefine.ExecTime.Count > 0)
                {
                    int curTime = LibDateUtils.GetLibTimePart(LibDateUtils.GetCurrentDateTime(), LibDateTimePartEnum.Time);
                    if (taskDefine.ExecTime[taskDefine.ExecTime.Count - 1] < curTime)
                    {
                        param.Task.Timer.Dispose();
                        canNextExec          = false;
                        param.Task.TaskState = TaskRunState.Stop;
                    }
                }
            }
            if (canNextExec)
            {
                param.Task.Timer.Change(param.GetTaskDueTime(), Timeout.InfiniteTimeSpan);
            }
            else if (taskDefine.TaskType == LibTaskType.TempTask)
            {
                //删除临时任务
                LibDataAccess dataAccess = new LibDataAccess();
                dataAccess.ExecuteNonQuery(string.Format("delete AXPBUSINESSTEMPTASK where TASKID={0}", LibStringBuilder.GetQuotString(taskDefine.TaskId)), false);
            }
        }
Пример #30
0
        public void RemoveFromSaleBillNo(string fromSaleBillNo)
        {
            //通过销售订单号查找派工单号
            string        sql        = string.Format(@"SELECT DISTINCT F.BILLNO
                                          FROM WORKORDER A
                                         INNER JOIN WORKORDERDETAIL B
                                            ON A.BILLNO = B.BILLNO
                                         INNER JOIN PLSSALESORDER C
                                            ON B.FROMBILLNO = C.BILLNO
                                         INNER JOIN PLSPRODUCEMONTHPLANDETAIL D
                                            ON D.WORKORDERBILLNO = B.BILLNO
                                         INNER JOIN PLSPRODUCEDAYPLANDETAIL E
                                            ON E.FROMBILLNO = D.BILLNO
                                           AND E.FROMROWID = D.ROW_ID
                                         INNER JOIN PPWORKORDER F
                                            ON E.PWORKORDERNO = F.BILLNO
                                         WHERE A.PARENTBILLNO IS NULL AND C.BILLNO = {0} ", LibStringBuilder.GetQuotString(fromSaleBillNo));
            LibDataAccess dataAccess = new LibDataAccess();
            StringBuilder builder    = new StringBuilder();
            Int32         index      = 1;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    string        workOrderNo   = LibSysUtils.ToString(reader["BILLNO"]);
                    HYProduceData hyProduceData = LibHYProduceCache.Default.GetProduceData(workOrderNo);
                    DataTable     dt            = hyProduceData.TenWorkRecord.Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string saleBillNo = LibSysUtils.ToString(dt.Rows[i]["FROMSALEBILLNO"]);
                        if (saleBillNo == fromSaleBillNo)
                        {
                            dt.Rows[i].Delete();
                        }
                    }
                    dt.AcceptChanges();
                    if (index == 1)
                    {
                        builder.AppendFormat(" AND (WORKORDERNO = {0}", LibStringBuilder.GetQuotObject(reader["BILLNO"]));
                    }
                    else
                    {
                        builder.AppendFormat(" OR WORKORDERNO = {0}", LibStringBuilder.GetQuotObject(reader["BILLNO"]));
                    }
                    index++;
                }
            }
            if (builder.Length > 0)
            {
                builder.Append(")");
                sql = string.Format(@"DELETE FROM PPTENWORKRECORD WHERE 1=1 {0} AND FROMSALEBILLNO = '{1}'", builder.ToString(), fromSaleBillNo);
                LibDBTransaction trans = dataAccess.BeginTransaction();
                try
                {
                    int result = dataAccess.ExecuteNonQuery(sql);
                    trans.Commit();
                }
                catch (Exception)
                {
                    trans.Rollback();
                }
            }
        }