Ejemplo n.º 1
0
 public ActionResult Logout()
 {
     if (Session["hasLogged"] != null)
     {
         if ((bool)Session["hasLogged"] == true)
         {
             IDSLogin.IDSLoginservice client = new IDSLogin.IDSLoginservice();
             client.LogOutWeb((String)Session["sessionID"], (String)Session["sessionKey"]);
             //очищаем персональные данные
             Session["sessionKey"] = null;
             Session["sessionKey"] = null;
             Session["certInfo"] = null;
             Session["tempKey"] = null;
             Session["tempKeySignature"] = null;
             Session["hasLogged"] = false;
         }
     }
     return Json(true);
 }
Ejemplo n.º 2
0
 public ActionResult GetTempKey()
 {
     IDSLogin.IDSLoginservice client = new IDSLogin.IDSLoginservice();
     string tempKey=client.GetTempKeyWeb();
     return Json(tempKey);
 }
Ejemplo n.º 3
0
        public ActionResult Login(string tempKey, string tempKeySignature, string[] certInfo)
        {
            bool res = true;
            IDSLogin.IDSLoginservice loginClient = new IDSLogin.IDSLoginservice();
            IDSLogin.TUserData userData=new IDSLogin.TUserData();
            userData.ClientLocalIP = Request.ServerVariables["REMOTE_ADDR"];
            //!TODO change this
            userData.ClientHardwareID = "6B50564A9446D655BF6BC077F866E9B4";
            userData.ClientSoftwareGUID = "{1234806C-6DB0-4E27-B85E-990DCAFA8E4A}";
            userData.ClientSoftwareVersion = "1.0.0.0";

            CertInfo cert = new CertInfo();
            cert.CNOwner = certInfo[0];
            cert.OrganizationOwner = certInfo[1];
            cert.CountryOwner = certInfo[2];
            cert.Area = certInfo[3];
            cert.LocalityOwner = certInfo[4];
            cert.StreetOwner = certInfo[5];
            cert.Post = certInfo[6];
            cert.SurnameOwner = certInfo[7];
            cert.NameAndMiddleName = certInfo[8];
            cert.CNPublisher = certInfo[9];
            cert.OrganizationPublisher = certInfo[10];
            cert.CountryPublisher = certInfo[11];
            cert.SectionPublisher = certInfo[12];
            cert.LocalityPublisher = certInfo[13];
            cert.StreetPublisher = certInfo[14];
            cert.EmailPublisher = certInfo[15];
            cert.IDKey = certInfo[16];
            cert.BasicLimits = certInfo[17];
            cert.Key4Use = certInfo[18];
            cert.IDKeySubject = certInfo[19];
            cert.ImprovedKey = certInfo[20];
            cert.UNP = certInfo[21];
            cert.DurationPublicKey = certInfo[22];
            cert.PassportData = certInfo[23];
            cert.PublicKey = certInfo[24];

            Session["certInfo"] = cert;

            //эти данные будут нужны для "тихой" повторной авторизации
            Session["tempKey"] = tempKey;
            Session["tempKeySignature"] = tempKeySignature;

            string sessionKey = null;
            string sessisonID = null;
            Session["Acred"] = false;
            try
            {
                sessisonID = loginClient.LogInWeb(tempKey, tempKeySignature, ref userData, out sessionKey);
            }
            catch (SoapException ex)
            {
                Session["hasLogged"] = false;
                string errtext = ex.Message;
                string[] sep = { "\n" };
                string[] sepdata = { "\t" };
                string[] strarray = errtext.Split(sep, StringSplitOptions.None);

                string errCritical = strarray[0];
                string errCode = strarray[1];
                string errData = strarray[2];
                string errMessage = "";

                for (int i = 3; i < strarray.Length; i++ )
                {
                    errMessage += strarray[i];
                }

                if (errCritical == "0")
                {
                    Session["errCode"] = errCode;

                    switch (errCode)
                    {
                        case c_Err_MmbrNoFnd_UsrNoFnd:
                            {
                                Session["Acred"] = true;
                                res = false;
                                ErrorMessage errorMessage;
                                errorMessage.message = errMessage;
                                errorMessage.result = res;
                                return Json(errorMessage);
                            }
                        case c_Err_MmbrFnd_UsrNoFnd:
                            {
                                string[] strData = errData.Split(sepdata, StringSplitOptions.None);
                                Hashtable ht = new Hashtable();
                                for (int i = 0; i < strData.Length; i++)
                                {
                                    ht.Add(strData[i].Split('=')[0], strData[i].Split('=')[1]);
                                }

                                Session["Acred"] = true;
                                res = false;
                                ErrorMessage errorMessage;
                                errorMessage.message = errMessage;
                                errorMessage.result = res;
                                return Json(errorMessage);
                            }
                        case c_Err_MmbrFnd_UsrFnd_NoReg:
                            {
                                Session["Acred"] = true;
                                res = false;
                                ErrorMessage errorMessage;
                                errorMessage.message = errMessage;
                                errorMessage.result = res;
                                return Json(errorMessage);
                            }
                        default:
                            {
                                Session["Acred"] = true;
                                res = false;
                                ErrorMessage errorMessage;
                                errorMessage.message = errMessage;
                                errorMessage.result = res;
                                return Json(errorMessage);
                            }
                    }
                }
                else if (errCritical == "1")
                {
                    //throw new Exception("Ошибка сервера");
                    throw new Exception(errMessage);
                }

            }

            Session["sessionID"] = sessisonID;
            Session["sessionKey"] = sessionKey;

            Session["hasLogged"] = true;
            Session["Acred"] = true;

            Session["MemberStatus"] = userData.MemberStatus;
            Session["PersonStatus"] = userData.PersonStatus;

            TAuthHeader header = new TAuthHeader();
            header.SessionID = (String)Session["sessionID"];
            header.SessionKey = (String)Session["sessionKey"];
            client.TAuthHeaderValue = header;

            TAuthUserInfo userInfo = new TAuthUserInfo();
            client.GetUserInfo(ref userInfo);
            Session["personName"] = userInfo.PersonName;

            return Json(res);
        }
Ejemplo n.º 4
0
        public ActionResult SaveAbonent(Abonent abonent)
        {
            string regNumber = "";
            int memberID = 0;

            TAccreditationAbonent acredAbonent = new TAccreditationAbonent();

            TPersonAccrediataion[] acredPerson = new TPersonAccrediataion[1];

            acredAbonent.IdPerson = 0;
            acredAbonent.MemberCode = "1";
            acredAbonent.PersonRole = "1";
            acredAbonent.StateAbonentEMP = "1";
            acredAbonent.TIdypeMember = abonent.ATIdypeMember;
            acredAbonent.TypeMember = abonent.ATypeMember;
            acredAbonent.FullNameMemeber = abonent.AFullNameMember;
            acredAbonent.ShortNameMember = abonent.AShortNameMember;
            acredAbonent.Unp = abonent.AUnp;
            acredAbonent.Okpo = abonent.AOkpo;
            acredAbonent.Okogu = abonent.AOkogu;
            acredAbonent.IdOKOGU = abonent.AIDOkogu;
            acredAbonent.OrgGovermentFin = abonent.AOrgGovermentFin;
            acredAbonent.IdOrgLegalForm = abonent.AIdOrgLegalForm;
            acredAbonent.OrgLegalForm = abonent.AOrgLegalForm;
            acredAbonent.City = abonent.ACity;
            acredAbonent.Oksmt = "112";
            acredAbonent.Region = abonent.ARegion;
            acredAbonent.Address = abonent.AAdress;
            acredAbonent.AccountNumber = abonent.ABankAccount;
            acredAbonent.IdBank = abonent.AIdBank;
            acredAbonent.BankAddress = abonent.ABankAddress;
            acredAbonent.BankCode = abonent.ABankCode;
            acredAbonent.BankNAme = abonent.ABankName;
            acredAbonent.BossFirstName = abonent.ABossOtherName;
            acredAbonent.BossLastName = abonent.ABossSecondName;
            acredAbonent.BossPost = abonent.ABossPost;
            acredAbonent.BossSecondName = abonent.ABossSecondName;
            acredAbonent.ContractNumber = "321654987"; // TODO: сгенерировать
            acredAbonent.Email = abonent.AEMail;
            acredAbonent.Fax = abonent.AFax;
            acredAbonent.MemberPhone = abonent.APhone;
            acredAbonent.WwwSite = abonent.ASite;

            acredPerson[0] = new TPersonAccrediataion();
            acredPerson[0].Pk = ((CertInfo)Session["certInfo"]).PublicKey.Replace(" ","");
            acredPerson[0].Id_Person = 1;
            acredPerson[0].NumPerson = 0;
            acredPerson[0].Person_Action = 1;//1 - вставка; 2 - обновление

            acredPerson[0].Person_last_name = abonent.APersonLastName;
            acredPerson[0].Person_name = abonent.APersonName;
            acredPerson[0].Person_Name_Genitive = abonent.APersonNameGenitive;
            acredPerson[0].Person_Data_From_Base_Doc = abonent.APersonDataFromBaseDoc;
            acredPerson[0].Person_Name_Officepost = abonent.APersonNameOfficepost;
            acredPerson[0].Person_Name_Officepost_Genitive = abonent.APersonNameOfficepostGenitive;
            acredPerson[0].Person_Name_Base_Doc_Genitive = abonent.APersonNameBaseDocGetnitive;
            acredPerson[0].Person_Organ_Base_Doc = abonent.APersonOrganBaseDoc;
            acredPerson[0].Person_Date_Begin_Doc = DateTimeUtils.DateTimeToDouble( DateTime.Parse(abonent.APersonDateBeginDoc));
            acredPerson[0].Person_Mail = abonent.APersonMail;
            acredPerson[0].Person_Phone = abonent.APersonPhone;
            acredPerson[0].Pperson_Number_Base_Doc = abonent.APersonNumberBaseDoc;
            acredPerson[0].Person_Id_Base_Doc = abonent.APersonIdBaseDoc;
            acredPerson[0].Person_Date_End_Doc = DateTimeUtils.DateTimeToDouble(DateTime.Parse(abonent.APersonDateBeginDoc));

            acredPerson[0].PersonCode = "1";
            acredPerson[0].PersonState = "1";

            client.TAuthHeaderValue = new TAuthHeader();
            client.AddMember(acredAbonent, acredPerson, ref regNumber);

            client.GetMemberID(((CertInfo)Session["certInfo"]).OrganizationOwner,
                    ((CertInfo)Session["certInfo"]).CNOwner,
                    ((CertInfo)Session["certInfo"]).UNP,
                    ((CertInfo)Session["certInfo"]).CountryOwner,
                    ((CertInfo)Session["certInfo"]).Area,
                    ((CertInfo)Session["certInfo"]).LocalityOwner, ref memberID);

            //TODO silent login

            IDSLogin.IDSLoginservice clientLogin = new IDSLogin.IDSLoginservice();
            IDSLogin.TUserData userData = new IDSLogin.TUserData();
            userData.ClientHardwareID = "6B50564A9446D655BF6BC077F866E9B4";
            userData.ClientSoftwareGUID = "{1234806C-6DB0-4E27-B85E-990DCAFA8E4A}";
            userData.ClientSoftwareVersion = "1.0.0.0";
            string sessionKey = null;
            string sessisonID = null;

            try
            {
                sessisonID = clientLogin.LogInWeb((string)Session["tempKey"], (string)Session["tempKeySignature"], ref userData, out sessionKey);
            }
            catch (SoapException ex)
            {
                string errtext = ex.Message;
                string[] sep = { "\n" };
                string[] sepdata = { "\t" };
                string[] strarray = errtext.Split(sep, StringSplitOptions.None);

                string errCritical = strarray[0];
                string errCode = strarray[1];
                string errData = strarray[2];
                string errMessage = "";

                for (int i = 3; i < strarray.Length; i++)
                {
                    errMessage += strarray[i];
                }

                throw new Exception(errMessage);

            }

            return Json(true);

            //TODO reload client page (js)
        }