示例#1
0
        public ActionMessage createDecision(DecisionInfo _Decision, string _userI, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    var quoteInfo = QuoteDataLayer.GetInstance().getQuoteByCode(connection, _Decision.QuoteCode, _userID);
                    if (quoteInfo != null)
                    {
                        _Decision.QuoteID = quoteInfo.QuoteID;
                    }
                    else
                    {
                        _Decision.QuoteID /* = _Decision.ProposalID*/ = 0;
                    }
                    ret.id        = DecisionDataLayer.GetInstance().InsertDecision(connection, _Decision, _userI);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
示例#2
0
        public async Task <ActionMessage> Put(int id, [FromForm] DecisionInfo _Decision, [FromForm] List <IFormFile> files, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = DecisionService.GetInstance().editDecision(id, _Decision, GetUserId(), _userID);
                //update list file
                DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_Decision.ListDocument, TableFile.Decision.ToString(), id);
                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Decision.ToString();
                    documentInfo.PreferId  = id.ToString();
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.Decision.ToString(), _Decision.DecisionID.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#3
0
        public async Task <ActionMessage> PostwithAttFile([FromForm] DecisionInfo DecisionObj, [FromForm] List <IFormFile> files)
        {
            ActionMessage ret     = new ActionMessage();
            int           insetId = -1;

            try
            {
                insetId       = DecisionService.GetInstance().createDecision2(DecisionObj, GetUserId());
                ret.isSuccess = true;
                if (insetId > -1)
                {
                    ret.id = insetId;
                    foreach (var item in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.Decision.ToString();
                        documentInfo.PreferId  = insetId.ToString();
                        documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                        documentInfo.FileName  = item.FileName;
                        documentInfo.Length    = item.Length.ToString();
                        documentInfo.Type      = item.ContentType;
                        ret = await FilesHelpers.UploadFile(TableFile.Decision.ToString(), insetId.ToString(), item, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                    }
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#4
0
        public SingleResponeMessage <DecisionInfo> Get(int id, string _userID)
        {
            SingleResponeMessage <DecisionInfo> ret = new SingleResponeMessage <DecisionInfo>();

            try
            {
                DecisionInfo item = DecisionService.GetInstance().GetDecision(id, _userID);
                if (item == null)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "001";
                    ret.err.msgString = "no Decision found";
                    return(ret);
                }
                ret.item      = item;
                ret.isSuccess = true;
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
        public void TestGetDecision()
        {
            try
            {
                MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDeciInfo);

                AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory);

                DecisionInfo decisionInfo = sdk.GetDecision(session, user, password);

                Assert.IsNotNull(decisionInfo);

                this.logger.Debug(JsonConvert.SerializeObject(decisionInfo));


                Assert.AreEqual(decision, decisionInfo.Decision.Reply.RuleEvents.Decision);

                Assert.AreEqual(deviceInfo.Device.Id, decisionInfo.Device.Id);
                Assert.IsTrue(velocityInfo.Velocity.Password.Equals(decisionInfo.Velocity.Password));
            }
            catch (AccessException ae)
            {
                Assert.Fail($"Bad exception {ae.ErrorType}:{ae.Message}");
            }
        }
示例#6
0
            public void AggregateOtherFileInfo(ParsedFileInfo otherFileInfo)
            {
                LinesCount        += otherFileInfo.LinesCount;
                TokensCount       += otherFileInfo.TokensCount;
                CodeElementsCount += otherFileInfo.CodeElementsCount;

                ParseTimeMs += otherFileInfo.ParseTimeMs;
                for (int i = 0; i < RuleInvocations.Length; i++)
                {
                    RuleInvocations[i] += otherFileInfo.RuleInvocations[i];
                }

                DecisionTimeMs += otherFileInfo.DecisionTimeMs;
                for (int i = 0; i < DecisionInfos.Length; i++)
                {
                    if (DecisionInfos[i] == null)
                    {
                        DecisionInfos[i] = new DecisionInfo(i);
                    }
                    DecisionInfos[i].invocations        += otherFileInfo.DecisionInfos[i].invocations;
                    DecisionInfos[i].LL_ATNTransitions  += otherFileInfo.DecisionInfos[i].LL_ATNTransitions;
                    DecisionInfos[i].LL_DFATransitions  += otherFileInfo.DecisionInfos[i].LL_DFATransitions;
                    DecisionInfos[i].LL_Fallback        += otherFileInfo.DecisionInfos[i].LL_Fallback;
                    DecisionInfos[i].LL_MaxLook         += otherFileInfo.DecisionInfos[i].LL_MaxLook;
                    DecisionInfos[i].LL_MinLook         += otherFileInfo.DecisionInfos[i].LL_MinLook;
                    DecisionInfos[i].LL_TotalLook       += otherFileInfo.DecisionInfos[i].LL_TotalLook;
                    DecisionInfos[i].SLL_ATNTransitions += otherFileInfo.DecisionInfos[i].SLL_ATNTransitions;
                    DecisionInfos[i].SLL_DFATransitions += otherFileInfo.DecisionInfos[i].SLL_DFATransitions;
                    DecisionInfos[i].SLL_MaxLook        += otherFileInfo.DecisionInfos[i].SLL_MaxLook;
                    DecisionInfos[i].SLL_MinLook        += otherFileInfo.DecisionInfos[i].SLL_MinLook;
                    DecisionInfos[i].SLL_TotalLook      += otherFileInfo.DecisionInfos[i].SLL_TotalLook;
                    DecisionInfos[i].timeInPrediction   += otherFileInfo.DecisionInfos[i].timeInPrediction;
                }
            }
示例#7
0
        public ActionMessage editDecision(int id, DecisionInfo _Decision, string _userU, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                var chkDecisionInfo = DecisionDataLayer.GetInstance().getDecision(connection, id, _userID);
                if (chkDecisionInfo != null)
                {
                    try
                    {
                        DecisionDataLayer.GetInstance().UpdateDecision(connection, id, _Decision, _userU);
                        ret.isSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        ret.isSuccess     = false;
                        ret.err.msgCode   = "Internal Error";
                        ret.err.msgString = ex.ToString();
                    }
                }
            }
            return(ret);
        }
示例#8
0
        /// <summary>
        /// Gets the Decision data for the session's username and password.
        /// </summary>
        /// <param name="sessionId">The Session ID returned from the JavaScript data collector.</param>
        /// <param name="username">The username of the user.</param>
        /// <param name="password">The password of the user.</param>
        /// <returns>Decision data</returns>
        public DecisionInfo GetDecision(string sessionId, string username, string password)
        {
            ValidateSession(sessionId);

            using (IWebClient client = this._webClientFactory.Create())
            {
                PrepareWebClient((WebClient)client, true);

                NameValueCollection reqparm = GetRequestedParams(sessionId, username, password);
                this.LogRequest(DecisionEndpoint, username: username, password: password, session: sessionId);

                try
                {
                    byte[]       responsebytes = client.UploadValues(DecisionEndpoint, "POST", reqparm);
                    string       responsebody  = Encoding.UTF8.GetString(responsebytes);
                    DecisionInfo dInfo         = JsonConvert.DeserializeObject <DecisionInfo>(responsebody);

                    return(dInfo);
                }
                catch (WebException ex)
                {
                    HandleWebException(ex);
                }
                return(null);
            }
        }
 public PlayerUI()
 {
     cursor            = null;
     capusuleTransform = null;
     okObj             = null;
     startOkScale      = Vector3.zero;
     decisionInfo      = new DecisionInfo();
 }
示例#10
0
    /// <summary>
    /// Function that chooses a decision when called.
    /// Handles changing states.
    /// </summary>
    /// <param name="info"></param>
    public void ChooseDecision(DecisionInfo info)
    {
        //Set the decision bar back to inactive
        decisionBar.gameObject.SetActive(false);

        //Clear the decision bar.
        for (int i = decisionBar.childCount - 1; i >= 0; i--)
        {
            Destroy(decisionBar.GetChild(i).gameObject);
        }

        //Set the next block, and set onto the next init state.
        cur_block = info.GetNextBlock();
        SetState(DM_STATE.Init);
    }
示例#11
0
        public ActionMessage Post([FromBody] DecisionInfo _decision, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = DecisionService.GetInstance().createDecision(_decision, GetUserId(), _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#12
0
        /// <summary>
        /// </summary>
        /// <returns>Return List<DecisionInfo></returns>
        ///
        public List <DecisionInfo> GetAllDecision(SqlConnection connection, string _userID)
        {
            var result = new List <DecisionInfo>();

            using (var command = new SqlCommand("Select D.* , BP.BidPlanID, BP.BidPlanCode,  Q.QuoteCode," +
                                                "  Q.IsVAT,  Q.VATNumber" + //, P.ProposalCode
                                                " from tbl_Decision D " +
                                                " LEFT JOIN tbl_Quote Q on D.QuoteID  = Q.QuoteID " +
                                                //" LEFT JOIN tbl_Negotiation N on N.NegotiationID  = D.NegotiationID " +
                                                " LEFT JOIN tbl_BidPlan BP on BP.QuoteID  = Q.QuoteID " +
                                                " where  1 = 1 order by D.UpdateTime Desc ", connection))

            {
                if (!string.IsNullOrEmpty(_userID) && _userID != "admin")
                {
                    command.CommandText += " and (D.UserI = @UserID or D.UserU = @UserID or D.UserAssign =@UserID )";
                    AddSqlParameter(command, "@UserID", _userID, SqlDbType.VarChar);
                }
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new DecisionInfo();
                        info.DecisionID   = GetDbReaderValue <int>(reader["DecisionID"]);
                        info.DecisionCode = GetDbReaderValue <string>(reader["DecisionCode"]);

                        info.BidPlanID   = GetDbReaderValue <int>(reader["BidPlanID"]);
                        info.BidMethod   = GetDbReaderValue <int>(reader["BidMethod"]);
                        info.BidPlanCode = GetDbReaderValue <string>(reader["BidPlanCode"]);

                        info.QuoteID   = GetDbReaderValue <int>(reader["QuoteID"]);
                        info.QuoteCode = GetDbReaderValue <string>(reader["QuoteCode"]);
                        info.IsVAT     = GetDbReaderValue <bool>(reader["IsVAT"]);
                        info.VATNumber = GetDbReaderValue <double>(reader["VATNumber"]);

                        info.Comment    = GetDbReaderValue <string>(reader["Comment"]);
                        info.DateIn     = GetDbReaderValue <DateTime>(reader["DateIn"]);
                        info.UserI      = GetDbReaderValue <string>(reader["UserI"]);
                        info.InTime     = GetDbReaderValue <DateTime?>(reader["InTime"]);
                        info.UserU      = GetDbReaderValue <string>(reader["UserU"]);
                        info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]);
                        result.Add(info);
                    }
                }
                return(result);
            }
        }
示例#13
0
        public int InsertDecision(SqlConnection connection, DecisionInfo _Decision, string _userI)
        {
            var currenttime     = DateTime.Now.Date;
            int lastestInserted = 0;

            if (_Decision.DecisionCode == null || _Decision.DecisionCode == "")
            {
                _Decision.DecisionCode = DateTime.Now.ToString("yyMMddHHmmssfff");
            }
            using (var command = new SqlCommand("Insert into [dbo].[tbl_Decision] (DecisionCode, QuoteID,Comment,   CapitalID  ,  UserI, DateIn, BidMethod)" +
                                                "VALUES(@DecisionCode, @QuoteID, @Comment, @CapitalID,  @UserI, @DateIn, @BidMethod) " +
                                                "select IDENT_CURRENT('dbo.tbl_Decision') as LastInserted ", connection))
            {
                AddSqlParameter(command, "@DecisionCode", _Decision.DecisionCode /*"QD-"+ _Decision.ProposalCode*/, System.Data.SqlDbType.NVarChar);
                AddSqlParameter(command, "@QuoteID", _Decision.QuoteID, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@BidMethod", _Decision.BidMethod, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@CapitalID", _Decision.CapitalID, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@Comment", _Decision.Comment, System.Data.SqlDbType.NVarChar);
                AddSqlParameter(command, "@DateIn", _Decision.DateIn, System.Data.SqlDbType.DateTime);
                AddSqlParameter(command, "@UserI", _userI, System.Data.SqlDbType.VarChar);
                WriteLogExecutingCommand(command);
                var lastInsertedRaw = command.ExecuteScalar();
                if (lastInsertedRaw != null && !DBNull.Value.Equals(lastInsertedRaw))
                {
                    lastestInserted = Convert.ToInt32(lastInsertedRaw);
                }
            }


            if (lastestInserted > 0)
            {
                using (var command = new SqlCommand("update  tbl_Proposal_Process " +
                                                    "set DecisionID=@DecisionID  , DecisionTime=@DecisionTime ,  CurrentFeature=@CurrentFeature where QuoteID=@QuoteID", connection))
                {
                    AddSqlParameter(command, "@QuoteID", _Decision.QuoteID, System.Data.SqlDbType.Int);
                    AddSqlParameter(command, "@DecisionID", lastestInserted, System.Data.SqlDbType.Int);
                    AddSqlParameter(command, "@DecisionTime", currenttime, System.Data.SqlDbType.DateTime);
                    AddSqlParameter(command, "@CurrentFeature", "Decision", System.Data.SqlDbType.VarChar);
                    WriteLogExecutingCommand(command);
                    command.ExecuteScalar();
                }
            }

            return(lastestInserted);
        }
示例#14
0
        public int createDecision2(DecisionInfo _Decision, string _userI)
        {
            int ret = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    ret = DecisionDataLayer.GetInstance().InsertDecision(connection, _Decision, _userI);
                }
                catch (Exception ex)
                {
                    ret = -1;
                }
            }
            return(ret);
        }
示例#15
0
        public void UpdateDecision(SqlConnection connection, int _id, DecisionInfo _Decision, string _userU)
        {
            using (var command = new SqlCommand("UPDATE tbl_Decision " +
                                                " SET  DecisionCode = @DecisionCode , Comment = @Comment , CapitalID=@CapitalID,BidMethod =@BidMethod  " +
                                                ", UserU=@UserU,UpdateTime=getdate(), DateIn = @DateIn  " +
                                                " WHERE (DecisionID = @DecisionID) ", connection))
            // " Insert into tbl_Decision_Log ([DecisionID],[DecisionName],[ProposalID],[Comment],[UserI],[Intime],[UserU],[UpdateTime])  (select [DecisionID],[DecisionName],[ProposalID],[Comment],[UserI],[Intime],[UserU],[UpdateTime] from tbl_Decision where DecisionID=@DecisionID ) "
            {
                AddSqlParameter(command, "@DecisionID", _id, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@DecisionCode", _Decision.DecisionCode, System.Data.SqlDbType.NVarChar);
                AddSqlParameter(command, "@QuoteID", _Decision.QuoteID, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@BidMethod", _Decision.BidMethod, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@CapitalID", _Decision.CapitalID, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@Comment", _Decision.Comment, System.Data.SqlDbType.NVarChar);
                AddSqlParameter(command, "@DateIn", _Decision.DateIn, System.Data.SqlDbType.DateTime);
                AddSqlParameter(command, "@UserU", _userU, System.Data.SqlDbType.VarChar);
                WriteLogExecutingCommand(command);

                command.ExecuteScalar();
            }
        }
示例#16
0
        public DecisionInfo GetDecisionByCode(string code, string _userID)
        {
            DecisionInfo         record        = new DecisionInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = DecisionDataLayer.GetInstance().GetDecisionByCode(connection, code, _userID);
                if (record == null)
                {
                    return(null);
                }

                record.Items = new List <ItemInfo>();
                record.Items = QuoteDataLayer.GetInstance().GetQuoteItems(connection, record.QuoteID);

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Decision.ToString();
                documentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Decision.ToString();
                commentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListComment        = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in record.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }

                return(record);
            }
        }
    /// <summary>
    /// Helper function that parses the block of text that is the decisionInfoList text.
    /// </summary>
    /// <param name="decisionInfoListText"></param>
    /// <returns></returns>
    static List <DecisionInfo> ParseDecisioninfoList(string decisionInfoListText)
    {
        List <DecisionInfo> decisionInfoList = new List <DecisionInfo>();

        //Split text
        string[] decisionInfoBlock = (decisionInfoListText.Trim()).Split(":"[0]);

        //Go through all of the text.
        for (int i = 0; i < decisionInfoBlock.Length; i++)
        {
            //Create a decision info.
            DecisionInfo info = new DecisionInfo();
            string       key  = Regex.Replace(decisionInfoBlock[i], "[^\\w\\._]", "");
            i++;
            string val = Regex.Replace(decisionInfoBlock[i], "[^\\w\\s]", "");

            //Set values.
            info.SetNextBlock(SceneBlockDictionary[key]);
            info.SetDecisionText(val);
            decisionInfoList.Add(info);
        }
        return(decisionInfoList);
    }
示例#18
0
        /// <summary>
        /// Simple Example within the Constructor.
        /// </summary>
        public KountAccessExample()
        {
            try
            {
                // Create the SDK. If any of these values are invalid, an com.kount.kountaccess.AccessException will be
                // thrown along with a message detailing why.
                AccessSdk sdk = new AccessSdk(host, merchantId, apiKey);

                // If you want the device information for a particular user's session, just pass in the sessionId. This
                // contains the id (fingerprint), IP address, IP Geo Location (country), whether the user was using a proxy
                // (and it was bypassed), and ...
                DeviceInfo deviceInfo = sdk.GetDevice(this.session);

                this.PrintDeviceInfo(deviceInfo.Device);

                // ... if you want to see the velocity information in relation to the users session and their account
                // information, you can make an access (velocity) request. Usernames and passwords will be hashed prior to
                // transmission to Kount within the SDK. You may optionally hash prior to passing them in as long as the
                // hashing method is consistent for the same value.
                String       username   = "******";
                String       password   = "******";
                VelocityInfo accessInfo = sdk.GetVelocity(session, username, password);

                // Let's see the response
                Console.WriteLine("Response: " + accessInfo);

                // Each Access Request has its own uniqueID
                Console.WriteLine("This is our access response_id: " + accessInfo.ResponseId);

                // The device is included in an access request:
                this.PrintDeviceInfo(accessInfo.Device);

                // you can get the device information from the accessInfo object
                Device device = accessInfo.Device;

                string jsonVeloInfo = JsonConvert.SerializeObject(accessInfo);
                Console.WriteLine(jsonVeloInfo);

                this.PrintVelocityInfo(accessInfo.Velocity);

                // Or you can access specific Metrics directly. Let's say we want the
                // number of unique user accounts used by the current sessions device
                // within the last hour
                int numUsersForDevice = accessInfo.Velocity.Device.ulh;
                Console.WriteLine(
                    "The number of unique user access request(s) this hour for this device is:" + numUsersForDevice);

                // Decision Information is stored in a JSONObject, by entity type
                DecisionInfo decisionInfo = sdk.GetDecision(session, username, password);
                Decision     decision     = decisionInfo.Decision;
                // Let's look at the data
                this.PrintDecisionInfo(decision);

                // Get Kount Access data for session based on what was requested in the info flag
                String          uniq    = "uniq(customer identifier)";
                DataSetElements dataSet = new DataSetElements()
                                          .WithInfo()
                                          .WithVelocity()
                                          .WithDecision()
                                          .WithTrusted()
                                          .WithBehavioSec();

                Info info = sdk.GetInfo(session, username, password, uniq, dataSet);
                this.PrintDeviceInfo(info.Device);
                this.PrintDecisionInfo(info.Decision);
                this.PrintVelocityInfo(info.Velocity);
                this.PrintFields(info.Trusted);
                this.PrintFields(info.BehavioSec);

                // Get devices that belong to a uniq user.
                DevicesInfo devices = sdk.GetDevices(uniq);
                foreach (var d in devices.Devices)
                {
                    this.PrintFields(d);
                }

                // Get the uniq users that belong to a device.
                string deviceId = "DEVICE_ID";
                var    uniques  = sdk.GetUniques(deviceId);
                foreach (var u in uniques.Uniques)
                {
                    this.PrintFields(u);
                }

                // Update device trust referenced by session ID
                sdk.SetDeviceTrustBySession(session, uniq, DeviceTrustState.Banned);

                // Update device trust referenced by device ID
                sdk.SetDeviceTrustByDevice(uniq, deviceId, DeviceTrustState.Trusted);

                // Update behavior data.
                string timing = "timing data";
                // BehavioHost and BehavioEnvironment can be set via AccessSdk constructor too.
                // sdk.BehavioHost = "https://api.behavio.kaptcha.com";
                //sdk.BehavioEnvironment = "sandbox";

                //sdk.SetBehavioSec(session, uniq, timing);
            }
            catch (AccessException ae)
            {
                // These can be thrown if there were any issues making the request.
                // See the AccessException class for more information.
                Console.WriteLine("ERROR Type: " + ae.ErrorType);
                Console.WriteLine("ERROR: " + ae.Message);
            }
        }
示例#19
0
        private static Table CreateTable(DecisionInfo item, double Totalcost)
        {
            //prepare ITEMs
            List <string>         headers = new List <string>();
            List <List <string> > items   = new List <List <string> >();

            headers.Add("STT");
            headers.Add("Tên và mô tả thiết bị");
            headers.Add("Đơn vị tính");
            headers.Add("Số lượng");

            headers.Add("Đơn giá(VNĐ)");
            headers.Add("Thành tiền (VNĐ)");

            int[] widths = { 1000, 3000, 1600, 1600, 1600, 2100 };


            int index = 1;

            foreach (ItemInfo record in item.Items)
            {
                List <string> row = new List <string>();
                row.Add(index.ToString());
                row.Add(record.ItemName);
                row.Add(record.ItemUnit);
                row.Add(record.Amount.ToString());
                row.Add(string.Format("{0:0,0}", record.ItemPrice).Replace(",", "."));
                row.Add(string.Format("{0:0,0}", record.ItemPrice * record.Amount).Replace(",", "."));
                items.Add(row);
                index++;
            }



            //// Create a new table
            Table tbl = new Table();

            //// Create the table properties
            TableProperties    tblProperties = new TableProperties();
            TableJustification just          = new TableJustification();

            just.Val = TableRowAlignmentValues.Center;
            //// Create Table Borders
            TableBorders tblBorders = new TableBorders();
            TopBorder    topBorder  = new TopBorder();

            topBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
            topBorder.Color = "000000";
            tblBorders.AppendChild(topBorder);
            BottomBorder bottomBorder = new BottomBorder();

            bottomBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
            bottomBorder.Color = "000000";
            tblBorders.AppendChild(bottomBorder);
            RightBorder rightBorder = new RightBorder();

            rightBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
            rightBorder.Color = "000000";
            tblBorders.AppendChild(rightBorder);
            LeftBorder leftBorder = new LeftBorder();

            leftBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
            leftBorder.Color = "000000";
            tblBorders.AppendChild(leftBorder);
            InsideHorizontalBorder insideHBorder = new InsideHorizontalBorder();

            insideHBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
            insideHBorder.Color = "000000";
            tblBorders.AppendChild(insideHBorder);
            InsideVerticalBorder insideVBorder = new InsideVerticalBorder();

            insideVBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
            insideVBorder.Color = "000000";
            tblBorders.AppendChild(insideVBorder);
            //// Add the table borders to the properties
            tblProperties.AppendChild(tblBorders);
            tblProperties.AppendChild(just);
            //// Add the table properties to the table
            tbl.AppendChild(tblProperties);
            //// Add a cell to each column in the row
            ///
            List <TableCell> headerCells = new List <TableCell>();
            TableCell        tcName1;

            foreach (string itemHeaders in headers)
            {
                tcName1 = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Center
                }), new Run(Bold(), new Text(itemHeaders))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "3000"
                }));
                headerCells.Add(tcName1);
            }
            //// Create a new row
            TableRow tr = new TableRow();

            tr.Append(headerCells.ToArray());
            tbl.AppendChild(tr);
            List <TableCell> dataCells = new List <TableCell>();

            foreach (List <string> rowItems in items)
            {
                dataCells = new List <TableCell>();
                foreach (string data in rowItems)
                {
                    tcName1 = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                    {
                        Val = JustificationValues.Center
                    }), new Run(Bold(), new Text(data))));
                    tcName1.Append(new TableCellProperties(
                                       new TableCellWidth()
                    {
                        Type = TableWidthUnitValues.Dxa, Width = "3000"
                    }));
                    dataCells.Add(tcName1);
                }
                TableRow tr1 = new TableRow();
                tr1.Append(dataCells.ToArray());
                tbl.AppendChild(tr1);
            }
            TableCellProperties cellOneProperties = new TableCellProperties();

            //if VAT
            if (item.IsVAT)
            {
                // total row
                tr        = new TableRow();
                dataCells = new List <TableCell>();
                tcName1   = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text("Tổng công (chưa bao gồm VAT)"))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "1000"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);

                for (int loopindex = 1; loopindex < widths.Length - 1; loopindex++)
                {
                    tcName1 = new TableCell(new Paragraph());
                    tcName1.Append(new TableCellProperties(
                                       new TableCellWidth()
                    {
                        Type = TableWidthUnitValues.Dxa, Width = widths[loopindex].ToString()
                    }));
                    cellOneProperties = new TableCellProperties();
                    cellOneProperties.Append(new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    });
                    tcName1.Append(cellOneProperties);
                    dataCells.Add(tcName1);
                }
                double totalCostWithoutVAT = 0;
                totalCostWithoutVAT = Totalcost / ((item.VATNumber + 100) / 100);
                var totalCostWithoutVATstr = string.Format("{0:0,0}", totalCostWithoutVAT).Replace(",", ".");
                tcName1 = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text(totalCostWithoutVATstr))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "1900"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);
                tr.Append(dataCells.ToArray());
                tbl.AppendChild(tr);



                // total row
                tr        = new TableRow();
                dataCells = new List <TableCell>();
                tcName1   = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text("Thuế VAT " + item.VATNumber.ToString() + "%"))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "200"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);

                for (int loopindex = 1; loopindex < widths.Length - 1; loopindex++)
                {
                    tcName1 = new TableCell(new Paragraph());
                    tcName1.Append(new TableCellProperties(
                                       new TableCellWidth()
                    {
                        Type = TableWidthUnitValues.Dxa, Width = widths[loopindex].ToString()
                    }));
                    cellOneProperties = new TableCellProperties();
                    cellOneProperties.Append(new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    });
                    tcName1.Append(cellOneProperties);
                    dataCells.Add(tcName1);
                }
                double vatCost = 0;
                vatCost = (Totalcost * item.VATNumber) / 100;
                var vatCoststr = string.Format("{0:0,0}", vatCost).Replace(",", ".");
                tcName1 = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text(vatCoststr))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "1900"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);

                tr.Append(dataCells.ToArray());
                tbl.AppendChild(tr);

                // total row
                tr        = new TableRow();
                dataCells = new List <TableCell>();
                tcName1   = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text("TỔNG CỘNG (đã bao gồm VAT)"))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "200"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);

                for (int loopindex = 1; loopindex < widths.Length - 1; loopindex++)
                {
                    tcName1 = new TableCell(new Paragraph());
                    tcName1.Append(new TableCellProperties(
                                       new TableCellWidth()
                    {
                        Type = TableWidthUnitValues.Dxa, Width = widths[loopindex].ToString()
                    }));
                    cellOneProperties = new TableCellProperties();
                    cellOneProperties.Append(new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    });
                    tcName1.Append(cellOneProperties);
                    dataCells.Add(tcName1);
                }

                var TotalCost = string.Format("{0:0,0}", Totalcost).Replace(",", ".");
                tcName1 = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text(TotalCost))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "1900"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);

                tr.Append(dataCells.ToArray());
                tbl.AppendChild(tr);
            }
            else
            {
                // total row
                tr        = new TableRow();
                dataCells = new List <TableCell>();
                tcName1   = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text("TỔNG CỘNG "))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "200"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);

                for (int loopindex = 1; loopindex < widths.Length - 1; loopindex++)
                {
                    tcName1 = new TableCell(new Paragraph());
                    tcName1.Append(new TableCellProperties(
                                       new TableCellWidth()
                    {
                        Type = TableWidthUnitValues.Dxa, Width = widths[loopindex].ToString()
                    }));
                    cellOneProperties = new TableCellProperties();
                    cellOneProperties.Append(new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    });
                    tcName1.Append(cellOneProperties);
                    dataCells.Add(tcName1);
                }

                var TotalCost = string.Format("{0:0,0}", Totalcost).Replace(",", ".");
                tcName1 = new TableCell(new Paragraph(new ParagraphProperties(new Justification()
                {
                    Val = JustificationValues.Right
                }), new Run(new Text(TotalCost))));
                tcName1.Append(new TableCellProperties(
                                   new TableCellWidth()
                {
                    Type = TableWidthUnitValues.Dxa, Width = "1900"
                }));
                cellOneProperties = new TableCellProperties();
                cellOneProperties.Append(new HorizontalMerge()
                {
                    Val = MergedCellValues.Restart
                });
                tcName1.Append(cellOneProperties);
                dataCells.Add(tcName1);

                tr.Append(dataCells.ToArray());
                tbl.AppendChild(tr);
            }
            return(tbl);
        }
示例#20
0
        public static MemoryStream GetTemplate(int id, string path, out string code, string _userID)
        {
            double Totalcost    = 0;
            var    memoryStream = new MemoryStream();

            DecisionInfo item = DecisionService.GetInstance().GetDecision(id, _userID);

            QuoteRelation relation = ProposalService.GetInstance().getQuoteRelation(item.QuoteID);

            item.AuditCode   = relation.AuditCode;
            item.AuditTime   = relation.AuditTime;
            item.BidPlanCode = relation.BidPlanCode;
            item.BidPlanTime = relation.BidPlanTime;

            item.NegotiationCode = relation.NegotiationCode;
            item.NegotiationTime = relation.NegotiationTime;

            using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
                fileStream.CopyTo(memoryStream);
            code = "";//item.ProposalCode;
            using (var document = WordprocessingDocument.Open(memoryStream, true))
            {
                document.ChangeDocumentType(WordprocessingDocumentType.Document); // change from template to document
                DateTime date = DateTime.Now;

                var body  = document.MainDocumentPart.Document.Body;
                var paras = body.Elements <Paragraph>();
                foreach (ItemInfo record in item.Items)
                {
                    Totalcost += record.ItemPrice * record.Amount;
                }

                if (item.IsVAT)
                {
                    Totalcost = Totalcost * (item.VATNumber + 100) / 100;
                }

                Table tableData = CreateTable(item, Totalcost);

                string dateInStr = "";
                dateInStr = "ngày " + item.DateIn.Day + " tháng " + item.DateIn.Month + " năm " + item.DateIn.Year;

                string audittimeStr       = "ngày " + item.AuditTime.Day + "/" + item.AuditTime.Month + "/" + item.AuditTime.Year;
                string bidplantimeStr     = "ngày " + item.BidPlanTime.Day + "/" + item.BidPlanTime.Month + "/" + item.BidPlanTime.Year;
                string negotiationtimeStr = "ngày " + item.NegotiationTime.Day + "/" + item.NegotiationTime.Month + "/" + item.NegotiationTime.Year;

                string decisionCodeStr = "";
                if (item.DecisionCode != null && item.DecisionCode != "")
                {
                    decisionCodeStr = item.DecisionCode + "/QĐ-TMHH";
                }
                else
                {
                    decisionCodeStr = "...../QĐ-TMHH";
                }


                var newType = "Về việc chọn đơn vị cung cấp hàng hóa ";
                if (item.BidMethod != 1)
                {
                    newType += "theo hình thức " + HardData.bidMethod[item.BidMethod - 1];
                }
                foreach (var text in body.Descendants <Text>())
                {
                    text.Text = text.Text.Replace("#", "");
                    text.Text = text.Text.Replace("auditcode", WordUtils.checkNull(item.AuditCode));
                    text.Text = text.Text.Replace("bidplancode", WordUtils.checkNull(item.BidPlanCode));
                    text.Text = text.Text.Replace("negotiationcode", WordUtils.checkNull(item.NegotiationCode));
                    text.Text = text.Text.Replace("audittime", audittimeStr);
                    text.Text = text.Text.Replace("bidplantime", bidplantimeStr);
                    text.Text = text.Text.Replace("negotiationtime", negotiationtimeStr);
                    text.Text = text.Text.Replace("newtype", newType);
                    text.Text = text.Text.Replace("datein", WordUtils.checkNull(dateInStr));
                    text.Text = text.Text.Replace("newtype", WordUtils.checkNull(dateInStr));
                    text.Text = text.Text.Replace("costnumber", string.Format("{0:0,0}", Totalcost).Replace(",", "."));
                    text.Text = text.Text.Replace("coststring", WordUtils.checkNull(Utils.NumberToTextVN((decimal)Totalcost)));
                    text.Text = text.Text.Replace("capname", WordUtils.checkNull(item.CapitalName));
                    text.Text = text.Text.Replace("bidtype", item.BidType);
                    text.Text = text.Text.Replace("bidexpired", item.BidExpirated + " " + item.BidExpiratedUnit);
                    text.Text = text.Text.Replace("customername", WordUtils.checkNull(item.CustomerName));
                    text.Text = text.Text.Replace("address", WordUtils.checkNull(item.Address));
                    text.Text = text.Text.Replace("departmentNames", WordUtils.checkNull(item.DepartmentNames));
                    text.Text = text.Text.Replace("vatnumber", WordUtils.checkNull(item.VATNumber.ToString()));
                    //   text.Text = text.Text.Replace("currentyear", );
                    text.Text = text.Text.Replace("bidmethod", HardData.bidMethod[item.BidMethod - 1]);
                    text.Text = text.Text.Replace("decisionCode", " " + WordUtils.checkNull(decisionCodeStr));
                    if (text.Text == "table")
                    {
                        DocumentFormat.OpenXml.OpenXmlElement textP1 = text.Parent;
                        DocumentFormat.OpenXml.OpenXmlElement textP2 = textP1.Parent;
                        body.InsertAfter(tableData, textP2);
                        textP1.Remove();
                    }
                }

                document.Save();
                document.Close();
            }
            return(memoryStream);
        }
示例#21
0
        public List <DecisionInfo> getDecision(SqlConnection connection, DecisionSeachCriteria _criteria, string _userID)
        {
            var result = new List <DecisionInfo>();

            using (var command = new SqlCommand(" Select D.* , BP.BidPlanID, BP.BidPlanCode,  Q.QuoteCode,  Q.IsVAT,  Q.VATNumber from (Select D.* " +

                                                " from tbl_Decision D where  1 = 1 and D.DateIn between @FromDate and @ToDate ", connection))
            {
                AddSqlParameter(command, "@FromDate", _criteria.FromDate.Value.ToString("yyyy-MM-dd 00:00:00"), System.Data.SqlDbType.DateTime);
                AddSqlParameter(command, "@ToDate", _criteria.ToDate.Value.ToString("yyyy-MM-dd 23:59:59"), System.Data.SqlDbType.DateTime);

                if (!string.IsNullOrEmpty(_criteria.DecisionCode))
                {
                    command.CommandText += " and D.DecisionCode = @DecisionCode";
                    AddSqlParameter(command, "@DecisionCode", _criteria.DecisionCode, System.Data.SqlDbType.NVarChar);
                }

                command.CommandText += "  ) as D " +
                                       " LEFT JOIN tbl_Quote Q on D.QuoteID  = Q.QuoteID " +
                                       " LEFT JOIN tbl_BidPlan BP on BP.QuoteID  = Q.QuoteID " +
                                       " Left join tbl_Quote_Customer QC on Q.QuoteID = QC.QuoteID  and QC.IsChoosed = 1 " +
                                       " LEFT join tbl_Customer C on C.CustomerID = QC.CustomerID " +

                                       " where  1 = 1 ";

                if (!string.IsNullOrEmpty(_criteria.QuoteCode))
                {
                    command.CommandText += " and Q.QuoteCode like '%" + _criteria.QuoteCode + "%'";
                }
                if (!string.IsNullOrEmpty(_criteria.DecisionCode))
                {
                    command.CommandText += " and D.DecisionCode like '%" + _criteria.DecisionCode + "%'";
                }
                if (!string.IsNullOrEmpty(_userID) && _userID != "admin")
                {
                    command.CommandText += " and (D.UserI = @UserID or D.UserU = @UserID or D.UserAssign =@UserID )";
                    AddSqlParameter(command, "@UserID", _userID, SqlDbType.VarChar);
                }
                if (_criteria.CustomerID != 0)
                {
                    command.CommandText += " and C.CustomerID = @CustomerID";
                    AddSqlParameter(command, "@CustomerID", _criteria.CustomerID, System.Data.SqlDbType.Int);
                }
                command.CommandText += " order by D.UpdateTime Desc ";


                if (_criteria.pageSize == 0)
                {
                    _criteria.pageSize = 10;
                }
                var offSet = _criteria.pageIndex * _criteria.pageSize;
                command.CommandText += " OFFSET @OFFSET ROWS FETCH NEXT @PAGESIZE ROWS ONLY ";
                AddSqlParameter(command, "@OFFSET", offSet, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@PAGESIZE", _criteria.pageSize, System.Data.SqlDbType.Int);
                WriteLogExecutingCommand(command);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new DecisionInfo();
                        info.DecisionID   = GetDbReaderValue <int>(reader["DecisionID"]);
                        info.DecisionCode = GetDbReaderValue <string>(reader["DecisionCode"]);
                        //info.NegotiationID = GetDbReaderValue<int>(reader["NegotiationID"]);
                        //info.NegotiationCode = GetDbReaderValue<string>(reader["NegotiationCode"]);
                        info.BidPlanID   = GetDbReaderValue <int>(reader["BidPlanID"]);
                        info.BidMethod   = GetDbReaderValue <int>(reader["BidMethod"]);
                        info.BidPlanCode = GetDbReaderValue <string>(reader["BidPlanCode"]);
                        //info.ProposalID = GetDbReaderValue<int>(reader["ProposalID"]);
                        //info.ProposalCode = GetDbReaderValue<string>(reader["ProposalCode"]);
                        info.IsVAT     = GetDbReaderValue <bool>(reader["IsVAT"]);
                        info.VATNumber = GetDbReaderValue <double>(reader["VATNumber"]);
                        //info.DepartmentName = GetDbReaderValue<string>(reader["DepartmentName"]);
                        info.QuoteID   = GetDbReaderValue <int>(reader["QuoteID"]);
                        info.QuoteCode = GetDbReaderValue <string>(reader["QuoteCode"]);
                        //info.AuditID = GetDbReaderValue<int>(reader["AuditID"]);
                        //info.AuditCode = GetDbReaderValue<string>(reader["AuditCode"]);
                        info.Comment    = GetDbReaderValue <string>(reader["Comment"]);
                        info.DateIn     = GetDbReaderValue <DateTime>(reader["DateIn"]);
                        info.UserI      = GetDbReaderValue <string>(reader["UserI"]);
                        info.InTime     = GetDbReaderValue <DateTime?>(reader["InTime"]);
                        info.UserU      = GetDbReaderValue <string>(reader["UserU"]);
                        info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]);
                        result.Add(info);
                    }
                }
                return(result);
            }
        }
示例#22
0
        public DecisionInfo GetDecisionByCode(SqlConnection connection, string _code, string _userID)
        {
            DecisionInfo info = null;

            //using (var command = new SqlCommand(" Select D.* , N.NegotiationCode, BP.BidPlanID, BP.BidPlanCode, A.AuditID, A.AuditCode, Q.QuoteID, Q.QuoteCode, Q.IsVAT,  Q.VATNumber ," +
            //        "Q.TotalCost as QuoteTotalCost, Q.Intime as QuoteTime,  BP.InTime as BidPlanTime, N.InTime as NegotiationTime, C.CustomerName, C.Address , A.InTime as  AuditTime  , P.ProposalCode, DP.DepartmentName  from (Select D.* " +
            using (var command = new SqlCommand(" Select D.* , tblCap.CapitalName, BP.BidPlanID, BP.BidPlanCode, Q.QuoteCode, Q.IsVAT,  Q.VATNumber ," +
                                                "Q.TotalCost as QuoteTotalCost, Q.DateIn as QuoteTime,  BP.DateIn as BidPlanTime,  C.CustomerName, C.Address  from (Select D.* " + //,  P.ProposalCode
                                                " from tbl_Decision D where  D.DecisionCode = @DecisionCode) as D " +
                                                " LEFT JOIN tbl_Quote Q on D.QuoteID  = Q.QuoteID " +
                                                " LEFT JOIN tbl_BidPlan BP on BP.QuoteID  = Q.QuoteID " +
                                                " Left join tbl_Quote_Customer QC on Q.QuoteID = QC.QuoteID  and QC.IsChoosed = 1 " +
                                                " LEFT join tbl_Customer C on C.CustomerID = QC.CustomerID " +
                                                "left join tbl_Capital tblCap on tblCap.CapitalID = D.CapitalID " +
                                                "where  1 = 1", connection))

            {
                if (!string.IsNullOrEmpty(_userID) && _userID != "admin")
                {
                    command.CommandText += " and (D.UserI = @UserID or D.UserU = @UserID or D.UserAssign = @UserID )";
                    AddSqlParameter(command, "@UserID", _userID, SqlDbType.VarChar);
                }
                AddSqlParameter(command, "@DecisionCode", _code, SqlDbType.NVarChar);
                WriteLogExecutingCommand(command);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        info              = new DecisionInfo();
                        info.DecisionID   = GetDbReaderValue <int>(reader["DecisionID"]);
                        info.DecisionCode = GetDbReaderValue <string>(reader["DecisionCode"]);
                        info.CapitalID    = GetDbReaderValue <int>(reader["CapitalID"]);
                        info.CapitalName  = GetDbReaderValue <string>(reader["CapitalName"]);
                        info.BidPlanID    = GetDbReaderValue <int>(reader["BidPlanID"]);
                        info.BidPlanCode  = GetDbReaderValue <string>(reader["BidPlanCode"]);
                        //info.ProposalID = GetDbReaderValue<int>(reader["ProposalID"]);
                        //info.ProposalCode = GetDbReaderValue<string>(reader["ProposalCode"]);
                        //info.DepartmentName = GetDbReaderValue<string>(reader["DepartmentName"]);
                        info.BidMethod = GetDbReaderValue <int>(reader["BidMethod"]);
                        info.QuoteID   = GetDbReaderValue <int>(reader["QuoteID"]);
                        info.QuoteCode = GetDbReaderValue <string>(reader["QuoteCode"]);
                        info.IsVAT     = GetDbReaderValue <bool>(reader["IsVAT"]);
                        info.VATNumber = GetDbReaderValue <double>(reader["VATNumber"]);
                        //info.AuditID = GetDbReaderValue<int>(reader["AuditID"]);
                        //info.AuditCode = GetDbReaderValue<string>(reader["AuditCode"]);
                        info.Comment    = GetDbReaderValue <string>(reader["Comment"]);
                        info.DateIn     = GetDbReaderValue <DateTime>(reader["DateIn"]);
                        info.UserI      = GetDbReaderValue <string>(reader["UserI"]);
                        info.InTime     = GetDbReaderValue <DateTime?>(reader["InTime"]);
                        info.UserU      = GetDbReaderValue <string>(reader["UserU"]);
                        info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]);

                        info.BidPlanTime = GetDbReaderValue <DateTime>(reader["BidPlanTime"]);
                        // info.NegotiationTime = GetDbReaderValue<DateTime>(reader["NegotiationTime"]);
                        info.QuoteTime = GetDbReaderValue <DateTime>(reader["QuoteTime"]);
                        // info.AuditTime = GetDbReaderValue<DateTime>(reader["AuditTime"]);

                        info.Address      = GetDbReaderValue <string>(reader["Address"]);
                        info.CustomerName = GetDbReaderValue <string>(reader["CustomerName"]);
                    }
                }
            }
            return(info);
        }
示例#23
0
 public ParsedFileInfo(string textName, int parserRulesCount, int parserDecisionsCount)
 {
     Name            = textName;
     RuleInvocations = new int[parserRulesCount];
     DecisionInfos   = new DecisionInfo[parserDecisionsCount];
 }
        public void TestSdkInit()
        {
            ILoggerFactory factory = LogFactory.GetLoggerFactory();

            this.logger = factory.GetLogger(typeof(AccessSDKTestBase).ToString());

            deviceInfo        = new DeviceInfo();
            deviceInfo.Device = new Device {
                Country = ipGeo, Region = "ID", GeoLat = 43.37, GeoLong = -116.200, Id = fingerprint, IpAddress = ipAddress, IpGeo = ipGeo, Mobile = 1, Proxy = 0
            };
            deviceInfo.ResponseId = responseId;
            jsonDevInfo           = JsonConvert.SerializeObject(deviceInfo);

            velocityInfo                  = new VelocityInfo();
            velocityInfo.Device           = deviceInfo.Device;
            velocityInfo.ResponseId       = responseId;
            velocityInfo.Velocity         = new Velocity();
            velocityInfo.Velocity.Account = new SubAccount {
                dlh = 1, dlm = 1, iplh = 1, iplm = 1, plh = 1, plm = 1, ulh = 1, ulm = 1
            };
            velocityInfo.Velocity.Device = new SubDevice {
                alh = 1, alm = 1, iplh = 3, iplm = 3, plh = 2, plm = 2, ulh = 1, ulm = 1
            };
            velocityInfo.Velocity.IpAddress = new SubAddress {
                ulm = 3, ulh = 3, plm = 3, plh = 3, alh = 2, alm = 2, dlh = 1, dlm = 1
            };
            velocityInfo.Velocity.Password = new SubPassword {
                dlm = 2, dlh = 2, alm = 2, alh = 2, iplh = 1, iplm = 1, ulh = 3, ulm = 3
            };
            velocityInfo.Velocity.User = new SubUser {
                iplm = 3, iplh = 3, alh = 2, alm = 2, dlh = 2, dlm = 2, plh = 1, plm = 1
            };
            jsonVeloInfo = JsonConvert.SerializeObject(velocityInfo);

            decisionInfo            = new DecisionInfo();
            decisionInfo.Device     = deviceInfo.Device;
            decisionInfo.ResponseId = responseId;
            decisionInfo.Velocity   = velocityInfo.Velocity;
            decisionInfo.Decision   = new Decision
            {
                Errors = new List <string> {
                    "E1", "E2"
                },
                Warnings = new List <string> {
                    "W1", "W2"
                },
                Reply = new Reply
                {
                    RuleEvents = new RuleEvents
                    {
                        Decision = decision,
                        Total    = 10,
                        Events   = new List <string> {
                            "Event 1", "Event 2"
                        }
                    }
                }
            };

            jsonDeciInfo = JsonConvert.SerializeObject(decisionInfo);

            info            = new Info();
            info.Device     = deviceInfo.Device;
            info.Decision   = decisionInfo.Decision;
            info.Velocity   = velocityInfo.Velocity;
            info.ResponseId = responseId;
            info.Trusted    = new TrustState()
            {
                State = DeviceTrustState.Trusted
            };
            info.BehavioSec = new BehavioSec()
            {
                Confidence = 0,
                IsBot      = false,
                IsTrained  = false,
                PolicyId   = 4,
                Score      = 0
            };

            jsonInfo = JsonConvert.SerializeObject(info);

            devicesInfo            = new DevicesInfo();
            devicesInfo.ResponseId = responseId;
            devicesInfo.Devices    = new List <DeviceBasicInfo>()
            {
                new DeviceBasicInfo()
                {
                    DeviceId = "54569fcbd187483a8a1570a3c67d1113", FriendlyName = "Device A", TrustState = DeviceTrustState.Trusted, DateFirstSeen = DateTime.UtcNow.AddHours(-1)
                },
                new DeviceBasicInfo()
                {
                    DeviceId = "abcdef12345678910abcdef987654321", FriendlyName = "Device B", TrustState = DeviceTrustState.Banned, DateFirstSeen = DateTime.UtcNow.AddHours(-2)
                }
            };

            jsonDevicesInfo = JsonConvert.SerializeObject(devicesInfo);

            uniquesInfo            = new UniquesInfo();
            uniquesInfo.ResponseId = responseId;
            uniquesInfo.Uniques    = new List <Unique>()
            {
                new Unique()
                {
                    UniqueId = "55e9fbfda2ce489d83b4a99c84c6f3e1", DateLastSeen = DateTime.UtcNow.AddHours(-1), TrustState = DeviceTrustState.Trusted
                },
                new Unique()
                {
                    UniqueId = "55e9fbfda2ce489d83b4a99c84c6f3e2", DateLastSeen = DateTime.UtcNow.AddHours(-2), TrustState = DeviceTrustState.Banned
                }
            };

            jsonUniquesInfo = JsonConvert.SerializeObject(uniquesInfo);
        }