示例#1
0
        private int GetSelectedAnswer(PollingData p, String resID)
        {
            int selectedAnswer = 0;

            if (selectedAnswer == 0)
            {
                String[] arr1 = p.Answer1String.Split(',');
                foreach (String str in arr1)
                {
                    if (str == resID)
                    {
                        selectedAnswer = 1;
                    }
                }
            }

            if (selectedAnswer == 0)
            {
                String[] arr2 = p.Answer2String.Split(',');
                foreach (String str in arr2)
                {
                    if (str == resID)
                    {
                        selectedAnswer = 2;
                    }
                }
            }

            if (selectedAnswer == 0)
            {
                String[] arr3 = p.Answer3String.Split(',');
                foreach (String str in arr3)
                {
                    if (str == resID)
                    {
                        selectedAnswer = 3;
                    }
                }
            }


            if (selectedAnswer == 0)
            {
                String[] arr4 = p.Answer4String.Split(',');
                foreach (String str in arr4)
                {
                    if (str == resID)
                    {
                        selectedAnswer = 4;
                    }
                }
            }

            return(selectedAnswer);
        }
        public int insert(PollingData pollingData)
        {
            try
            {
                EncDecArrayClass objenc = new EncDecArrayClass();
                string[]         uregid = pollingData.userName.Split('$');
                pollingData.userName = objenc.DecryptInteger(uregid[0], uregid[1]);

                string[] uregid1 = pollingData.refMobileNo.Split('$');
                pollingData.refMobileNo = objenc.DecryptInteger(uregid1[0], uregid1[1]);



                sqlCommand = new SqlCommand();
                sqlCommand.Parameters.Add(new SqlParameter("@userName", pollingData.userName));
                sqlCommand.Parameters.Add(new SqlParameter("@wardNo", pollingData.wardNo));
                sqlCommand.Parameters.Add(new SqlParameter("@boothNo", pollingData.boothNo));
                sqlCommand.Parameters.Add(new SqlParameter("@noOfVotings", pollingData.noOfVoting));
                sqlCommand.Parameters.Add(new SqlParameter("@voters", pollingData.voters));
                sqlCommand.Parameters.Add(new SqlParameter("@localBody", pollingData.localBody));
                sqlCommand.Parameters.Add(new SqlParameter("@imeino", pollingData.imeino));
                sqlCommand.Parameters.Add(new SqlParameter("@userType", pollingData.userType));
                sqlCommand.Parameters.Add(new SqlParameter("@currentDate", pollingData.date));
                sqlCommand.Parameters.Add(new SqlParameter("@refMoNo", pollingData.refMobileNo));

                SqlParameter retrunParameter = sqlCommand.CreateParameter();
                retrunParameter.Direction = ParameterDirection.ReturnValue;
                retrunParameter.SqlDbType = SqlDbType.Int;
                sqlCommand.Parameters.Add(retrunParameter);

                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandText = "[TrueVoterDB].[dbo].[uspInsertPollingData]";
                sqlCommand.CommandType = CommandType.StoredProcedure;
                if (sqlCommand.Connection.State == ConnectionState.Closed)
                {
                    sqlCommand.Connection.Open();
                }

                int result = sqlCommand.ExecuteNonQuery();
                if (Convert.ToString(retrunParameter.Value) == "1")
                {
                    return(CommonCode.OK);
                }
                else
                {
                    return(CommonCode.FAIL);
                }
            }
            catch (SqlException)
            {
                return(CommonCode.ERROR);
            }
            finally { sqlCommand.Connection.Close(); sqlCommand.Dispose(); }
        }
        public String insert(string pollingData)
        {
            try
            {
                string   result           = string.Empty;
                string[] pollingDataArray = pollingData.Split(new char[] { '#', '*' });
                if ((pollingDataArray.Length % 10) == 0)
                {
                    PollingDataDAL pollingDataDal = new PollingDataDAL();
                    for (int i = 0; i < pollingDataArray.Length; i += 10)
                    {
                        PollingData pollingDataClass = new PollingData();
                        pollingDataClass.userName    = pollingDataArray[i];
                        pollingDataClass.wardNo      = Convert.ToInt32(pollingDataArray[i + 1]);
                        pollingDataClass.boothNo     = pollingDataArray[i + 2] != "" ? Convert.ToInt32(pollingDataArray[i + 2]) : 0;
                        pollingDataClass.noOfVoting  = Convert.ToInt32(pollingDataArray[i + 3]);
                        pollingDataClass.voters      = pollingDataArray[i + 4];
                        pollingDataClass.localBody   = Convert.ToInt32(pollingDataArray[i + 5]);
                        pollingDataClass.imeino      = pollingDataArray[i + 6];
                        pollingDataClass.userType    = pollingDataArray[i + 7];
                        pollingDataClass.date        = pollingDataArray[i + 8];
                        pollingDataClass.refMobileNo = pollingDataArray[i + 9];

                        result += pollingDataDal.insert(pollingDataClass) + "*";
                    }
                    return(result.Substring(0, result.Length - 1));
                }
                else
                {
                    return(CommonCode.WRONG_INPUT.ToString());
                }
            }
            catch
            {
                return(CommonCode.WRONG_INPUT.ToString());
            }
        }
示例#4
0
        public void DeleteNotPresent(List <string> keys)
        {
            var NotPresents = PollingData.Where(d => keys.Contains(d.Key) == false).Select(d => d.Key).ToList();

            NotPresents.ForEach(np => PollingData.Remove(np));
        }
示例#5
0
 public bool IsTaskActive(string key)
 {
     return(PollingData.ContainsKey(key) ? PollingData[key].Status != TaskStatus.RanToCompletion : false);
 }